statistics processor further work
[jabaws.git] / webservices / compbio / ws / execstat / StatProcessor.java
index 0697eb8..16b3234 100644 (file)
@@ -6,6 +6,7 @@ import java.util.Comparator;
 import java.util.Date;\r
 import java.util.List;\r
 \r
+import compbio.engine.client.ConfExecutable;\r
 import compbio.ws.client.Services;\r
 \r
 public class StatProcessor {\r
@@ -16,6 +17,14 @@ public class StatProcessor {
                this.stats = stats;\r
        }\r
 \r
+       /*\r
+        * TODO List<JobStat> getNewStat() throws SQLException { Set<String> jobids\r
+        * = new HashSet<String>(); for(JobStat js: stats) { jobids.add(js.jobname);\r
+        * } StatDB.removeRecordedJobs(jobids); List<String> newjobs = new\r
+        * HashSet<String>(); for(String jobid: jobids) { if(newjobs.co)\r
+        * jobids.add(js.jobname); } }\r
+        */\r
+\r
        List<JobStat> getAbandonedJobs() {\r
                List<JobStat> abJobs = new ArrayList<StatProcessor.JobStat>();\r
                for (JobStat js : stats) {\r
@@ -96,10 +105,18 @@ public class StatProcessor {
                report += "Cancelled Jobs: " + getCancelledJobs().size() + "\n";\r
                report += "Total Runtime (s): " + getTotalRuntime() + "\n";\r
                report += "Unsuccessful Jobs: " + getUnsuccessfulJobs().size() + "\n";\r
-               report += "10 longest jobs: \n\n" + sortByRuntime().subList(0, 9)\r
-                               + "\n";\r
-               report += "10 biggest jobs: \n\n" + sortByResultSize().subList(0, 9)\r
-                               + "\n";\r
+               if (sortByRuntime().size() > 10) {\r
+                       report += "10 longest jobs: \n\n" + sortByRuntime().subList(0, 9)\r
+                                       + "\n";\r
+               } else {\r
+                       report += "longest jobs: \n\n" + sortByRuntime() + "\n";\r
+               }\r
+               if (sortByResultSize().size() > 10)\r
+                       report += "10 biggest jobs: \n\n"\r
+                                       + sortByResultSize().subList(0, 9) + "\n";\r
+               else {\r
+                       report += "biggest jobs: \n\n" + sortByResultSize() + "\n";\r
+               }\r
                return report;\r
        }\r
 \r
@@ -127,6 +144,7 @@ public class StatProcessor {
                };\r
 \r
                Services webService;\r
+               String clusterJobId;\r
                String jobname;\r
                long start;\r
                long finish;\r
@@ -135,11 +153,12 @@ public class StatProcessor {
                boolean isCollected;\r
                boolean isCancelled;\r
 \r
-               JobStat(Services webService, String jobname, long start, long finish,\r
-                               long inputSize, long resultSize, boolean isCollected,\r
-                               boolean isCancelled) {\r
+               JobStat(Services webService, String clusterJobId, String jobname,\r
+                               long start, long finish, long inputSize, long resultSize,\r
+                               boolean isCollected, boolean isCancelled) {\r
                        super();\r
                        this.webService = webService;\r
+                       this.clusterJobId = clusterJobId;\r
                        this.jobname = jobname;\r
                        this.start = start;\r
                        this.finish = finish;\r
@@ -149,6 +168,10 @@ public class StatProcessor {
                        this.isCancelled = isCancelled;\r
                }\r
 \r
+               public boolean isClusterJob() {\r
+                       return jobname.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX);\r
+               }\r
+\r
                @Override\r
                public int hashCode() {\r
                        final int prime = 31;\r
@@ -221,7 +244,9 @@ public class StatProcessor {
                        }\r
                        report += "Input size " + inputSize + "\n";\r
                        report += "Result size " + resultSize + "\n";\r
+                       report += "ClusterJobID " + clusterJobId + "\n";\r
                        report += "Collected? " + isCollected + "\n";\r
+                       report += "Cancelled? " + isCancelled + "\n";\r
                        return report;\r
                }\r
 \r
@@ -251,7 +276,9 @@ public class StatProcessor {
                        }\r
                        report += inputSize + "\t";\r
                        report += resultSize + "\t";\r
+                       report += clusterJobId + "\t";\r
                        report += isCollected + "\t";\r
+                       report += isCancelled + "\t";\r
                        return report;\r
                }\r
 \r