statistics processor further work
[jabaws.git] / webservices / compbio / ws / execstat / ExecutionStatCollector.java
index 74218ce..945076e 100644 (file)
@@ -4,9 +4,11 @@ import java.io.File;
 import java.io.FileFilter;\r
 import java.io.FileWriter;\r
 import java.io.IOException;\r
+import java.sql.SQLException;\r
 import java.text.SimpleDateFormat;\r
 import java.util.ArrayList;\r
 import java.util.HashMap;\r
+import java.util.HashSet;\r
 import java.util.List;\r
 import java.util.Map;\r
 \r
@@ -85,8 +87,9 @@ public class ExecutionStatCollector {
         * \r
         * @param args\r
         * @throws IOException\r
+        * @throws SQLException\r
         */\r
-       public static void main(String[] args) throws IOException {\r
+       public static void main(String[] args) throws IOException, SQLException {\r
 \r
                // updateTime(new File(\r
                // "D:\\workspace\\JABA2\\jobsout\\AACon#170462904473672\\STARTED"));\r
@@ -94,7 +97,7 @@ public class ExecutionStatCollector {
                String workDir = PropertyHelperManager.getLocalPath()\r
                                + getLocalJobDir().trim();\r
                System.out.println(workDir);\r
-               File[] files = FileUtil.getFiles("H:/www-jws2/job_dir/jobsout",\r
+               File[] files = FileUtil.getFiles("H:/www-jws2/job_dir/local_jobsout",\r
                                directories);\r
                List<StatProcessor.JobStat> stats = new ArrayList<StatProcessor.JobStat>();\r
                for (File file : files) {\r
@@ -108,6 +111,9 @@ public class ExecutionStatCollector {
                System.out.println("!!!!!!!!!!!!!!!!!!");\r
                System.out.println();\r
                System.out.println(sp.getSingleWSStat(Services.TcoffeeWS).reportStat());\r
+\r
+               StatDB.insertData(new HashSet<StatProcessor.JobStat>(sp\r
+                               .getSingleWSStat(Services.TcoffeeWS).stats));\r
        }\r
 \r
        static FileFilter directories = new FileFilter() {\r
@@ -157,6 +163,20 @@ public class ExecutionStatCollector {
                        return starttime;\r
                }\r
 \r
+               String getClusterJobID() {\r
+                       String clustjobId = "";\r
+                       File jobid = files.get("JOBID");\r
+                       try {\r
+                               if (jobid != null) {\r
+                                       clustjobId = FileUtil.readFileToString(jobid);\r
+                               }\r
+                       } catch (IOException ioe) {\r
+                               ioe.printStackTrace();\r
+                               // TODO LOG\r
+                       }\r
+                       return clustjobId.trim();\r
+               }\r
+\r
                long getFinishedTime() {\r
                        long ftime = UNDEFINED;\r
                        File finished = files.get(JobStatus.FINISHED.toString());\r
@@ -219,9 +239,10 @@ public class ExecutionStatCollector {
                }\r
 \r
                StatProcessor.JobStat getJobStat() {\r
-                       return new StatProcessor.JobStat(getService(), jobdir.getName(),\r
-                                       getStartTime(), getFinishedTime(), getInputSize(),\r
-                                       getResultSize(), isCollected(), isCancelled());\r
+                       return new StatProcessor.JobStat(getService(), getClusterJobID(),\r
+                                       jobdir.getName(), getStartTime(), getFinishedTime(),\r
+                                       getInputSize(), getResultSize(), isCollected(),\r
+                                       isCancelled());\r
                }\r
 \r
                @Override\r