cleat stats array and simplify internal structure
authorSasha <asherstnev@main-laptop2>
Wed, 24 Apr 2013 16:09:22 +0000 (17:09 +0100)
committerSasha <asherstnev@main-laptop2>
Wed, 24 Apr 2013 16:09:22 +0000 (17:09 +0100)
webservices/compbio/stat/collector/ExecutionStatCollector.java

index c64a5b8..62f39c9 100644 (file)
@@ -72,8 +72,7 @@ public class ExecutionStatCollector implements Runnable {
 \r
        static final int UNDEFINED = -1;\r
 \r
-       private static final Logger log = Logger\r
-                       .getLogger(ExecutionStatCollector.class);\r
+       private static final Logger log = Logger.getLogger(ExecutionStatCollector.class);\r
 \r
        static SimpleDateFormat DF = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");\r
 \r
@@ -95,15 +94,13 @@ public class ExecutionStatCollector implements Runnable {
                log.info("Starting stat collector for directory: " + workDirectory);\r
                log.info("Maximum allowed runtime(h): " + timeOutInHours);\r
                if (!PathValidator.isValidDirectory(workDirectory)) {\r
-                       throw new IllegalArgumentException("workDirectory '"\r
-                                       + workDirectory + "' does not exist!");\r
+                       throw new IllegalArgumentException("workDirectory '" + workDirectory + "' does not exist!");\r
                }\r
                this.workDirectory = new File(workDirectory);\r
                stats = new ArrayList<JobStat>();\r
                if (timeOutInHours <= 0) {\r
                        throw new IllegalArgumentException(\r
-                                       "Timeout value must be greater than 0! Given value: "\r
-                                                       + timeOutInHours);\r
+                                       "Timeout value must be greater than 0! Given value: " + timeOutInHours);\r
                }\r
                this.timeOutInHours = timeOutInHours;\r
        }\r
@@ -348,23 +345,26 @@ public class ExecutionStatCollector implements Runnable {
 \r
        // TODO test!\r
        void collectStatistics() {\r
+               // clear stats array;\r
+               stats.clear();\r
                File[] files = workDirectory.listFiles(directories);\r
                for (File file : files) {\r
-                       if (!InputFilter.accept(new File(file.getPath() + File.separator\r
-                                       + SkeletalExecutable.INPUT))) {\r
-                               // skip work directory with test input\r
-                               continue;\r
-                       }\r
-                       JobDirectory jd = new JobDirectory(file);\r
-                       JobStat jstat = jd.getJobStat();\r
-                       // Do not record stats on the job that has not completed yet\r
-                       if (hasCompleted(jd)) {\r
-                               stats.add(jstat);\r
+                       // skip work directory with test input\r
+                       if (InputFilter.accept(new File(file.getPath() + File.separator + SkeletalExecutable.INPUT))) {\r
+                               JobDirectory jd = new JobDirectory(file);\r
+                               JobStat jstat = jd.getJobStat();\r
+                               // Do not record stats on the job that has not completed yet\r
+                               if (hasCompleted(jd)) {\r
+                                       stats.add(jstat);\r
+                                       System.out.println("added: id = " + jd);\r
+                               } else {\r
+                                       log.debug("Skipping the job: " + jstat);\r
+                                       log.debug("As it has not completed yet");\r
+                               }\r
+                               // System.out.println(jd.getJobStat().getJobReportTabulated());\r
                        } else {\r
-                               log.debug("Skipping the job: " + jstat);\r
-                               log.debug("As it has not completed yet");\r
+                               log.trace("training input: " + file.getPath() + File.separator + SkeletalExecutable.INPUT);\r
                        }\r
-                       // System.out.println(jd.getJobStat().getJobReportTabulated());\r
                }\r
        }\r
        @Override\r