Further work to enable stat collection and display
[jabaws.git] / webservices / compbio / stat / collector / StatDB.java
index 40f9d08..56ce9c1 100644 (file)
@@ -49,10 +49,14 @@ public class StatDB {
                                        + ";create=false");\r
 \r
                        conn.setAutoCommit(true);\r
+                       /*\r
+                        * Runtime.getRuntime().addShutdownHook(new Thread() {\r
+                        * \r
+                        * @Override public void run() { shutdownDBServer(); } });\r
+                        */\r
                }\r
                return conn;\r
        }\r
-\r
        public StatDB() throws SQLException {\r
                this.conn = getDBConnection();\r
        }\r
@@ -108,7 +112,8 @@ public class StatDB {
        }\r
 \r
        void insertData(Set<JobStat> jobstatus) throws SQLException {\r
-               System.out.println("Inserting " + jobstatus.size());\r
+               log.info("Inserting " + jobstatus.size()\r
+                               + " new records into the statistics database");\r
 \r
                conn.setAutoCommit(false);\r
                String insert = "insert into exec_stat (service_name, cluster_job_id, job_id, start, finish, "\r
@@ -264,6 +269,18 @@ public class StatDB {
 \r
                return stats;\r
        }\r
+\r
+       /**\r
+        * Removes the job if\r
+        * \r
+        * 1) It has already been recorded\r
+        * \r
+        * 2) It has not completed and did not timeout - this is to prevent\r
+        * recording the information on the incomplete jobs.\r
+        * \r
+        * @param fsJobs\r
+        * @throws SQLException\r
+        */\r
        public void removeRecordedJobs(Set<JobStat> fsJobs) throws SQLException {\r
 \r
                String query = "select job_id from exec_stat";\r
@@ -282,7 +299,7 @@ public class StatDB {
                st.close();\r
        }\r
 \r
-       public void shutdownDBServer() {\r
+       public static synchronized final void shutdownDBServer() {\r
                // ## DATABASE SHUTDOWN SECTION ##\r
                /***\r
                 * In embedded mode, an application should shut down Derby. Shutdown\r