New code update
[jabaws.git] / webservices / compbio / stat / collector / ExecutionStatUpdater.java
index f26ecc3..a5d89d1 100644 (file)
@@ -139,9 +139,9 @@ public class ExecutionStatUpdater {
                return new StatProcessor(stats);\r
        }\r
 \r
-       void writeStatToDB() throws SQLException {\r
+       void writeStatToDB(String dbname) throws SQLException {\r
                Set<JobStat> rjobs = new HashSet<JobStat>(stats);\r
-               StatDB statdb = new StatDB();\r
+               StatDB statdb = new StatDB(dbname);\r
                log.debug("Removing records that has already been recorded");\r
                statdb.removeRecordedJobs(rjobs);\r
                log.debug("New records left: " + rjobs.size());\r
@@ -155,18 +155,29 @@ public class ExecutionStatUpdater {
        public static void main(String[] args) throws IOException, SQLException, ParseException {\r
                mainJCommander jct = new mainJCommander();\r
                new JCommander(jct, args);\r
-               String WorkingDir = jct.workingdir;\r
-               String dbname = jct.dbname;\r
-               Date ST = shortDF.parse(jct.starttime);\r
-               Date ET = shortDF.parse(jct.endtime);\r
-               long StartTime = 0;\r
-               if (null != ST) {\r
-                       StartTime = ST.getTime();\r
-               }\r
+               String WorkingDir = "jobsout";\r
+               String DBname = "ExecutionStatistic";\r
+\r
+               long StartTime = 0L;\r
                Date currDate = new Date();\r
                long EndTime = currDate.getTime();\r
-               if (null != ET) {\r
-                       EndTime = ET.getTime();\r
+               if (null != jct.starttime) {\r
+                       Date ST = shortDF.parse(jct.starttime);\r
+                       if (null != ST) {\r
+                               StartTime = ST.getTime();\r
+                       }\r
+               }\r
+               if (null != jct.endtime) {\r
+                       Date ET = shortDF.parse(jct.endtime);\r
+                       if (null != ET) {\r
+                               EndTime = ET.getTime();\r
+                       }\r
+               }\r
+               if (null != jct.dbname) {\r
+                       DBname = jct.dbname;\r
+               }\r
+               if (null != jct.workingdir) {\r
+                       WorkingDir = jct.workingdir;\r
                }\r
 \r
                System.out.println("Start time: " + jct.starttime + " = " + StartTime);\r
@@ -174,7 +185,7 @@ public class ExecutionStatUpdater {
 \r
                ExecutionStatUpdater esu = new ExecutionStatUpdater(WorkingDir, 1);\r
                esu.collectStatistics(StartTime, EndTime);\r
-               esu.writeStatToDB();\r
+               esu.writeStatToDB(DBname);\r
        }\r
 \r
        static FileFilter directories = new FileFilter() {\r
@@ -189,12 +200,14 @@ public class ExecutionStatUpdater {
                // clear stats array;\r
                stats.clear();\r
                File[] dirs = workingDirectory.listFiles(directories);\r
+               log.debug("Start time = " + StartTime + ", end time = " + EndTime);\r
                for (File dir : dirs) {\r
                        // skip work directory with test inputs and out of ordered time\r
                        // range\r
                        log.debug("check directory: " + dir.getName() + "...");\r
                        if (InputFilter.accept(new File(dir.getPath() + File.separator + SkeletalExecutable.INPUT)) && StartTime < dir.lastModified()\r
                                        && dir.lastModified() < EndTime) {\r
+                               log.debug(", ACCEPTED");\r
                                JobDirectory jd = new JobDirectory(dir);\r
                                JobStat jstat = jd.getJobStat();\r
                                // Do not record stats on the job that has not completed yet\r
@@ -204,9 +217,11 @@ public class ExecutionStatUpdater {
                                        log.debug("Skipping the job: " + jstat + " as it has not completed yet");\r
                                }\r
                        } else {\r
+                               log.debug(", REJECTED");\r
                                log.trace("training input: " + dir.getName() + File.separator + SkeletalExecutable.INPUT);\r
                        }\r
                }\r
+               log.debug("Statistics collected!");\r
        }\r
 \r
 }\r