Simplify the jobdateinfo table (remove Total, Program, Version)
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Mon, 3 Feb 2014 14:05:26 +0000 (14:05 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Mon, 3 Feb 2014 14:05:26 +0000 (14:05 +0000)
datadb/compbio/cassandra/CassandraNativeConnector.java
datadb/compbio/cassandra/CassandraNewTableWriter.java
datadb/compbio/cassandra/CassandraRemover.java
datadb/compbio/cassandra/CassandraWriter.java
datadb/compbio/cassandra/readers/DailyStatisticsReader.java

index f02000c..6deed99 100644 (file)
@@ -86,7 +86,7 @@ public class CassandraNativeConnector {
                                + "predictions map<ascii,ascii>, ArchiveLink varchar, LOG varchar, ProgramName ascii, ProgramVersion ascii, PRIMARY KEY(JobID));");
 
                session.execute("CREATE TABLE IF NOT EXISTS JobDateInfo "
-                               + "(jobday bigint, Total bigint,  TotalOK bigint, TotalStopped bigint, TotalError bigint, TotalTimeOut bigint, Program varchar, Version varchar, PRIMARY KEY(jobday));");
+                               + "(jobday bigint, TotalOK bigint, TotalStopped bigint, TotalError bigint, TotalTimeOut bigint, PRIMARY KEY(jobday));");
 
                session.execute("CREATE TABLE IF NOT EXISTS Programs "
                                + "(Program varchar, Version varchar, Description varchar, weblink varchar, PRIMARY KEY(Program,Version));");
index 3b6c741..db0e70c 100644 (file)
@@ -78,28 +78,6 @@ public class CassandraNewTableWriter {
        }
 
        /*
-        * fill new table
-        */
-       public void FillNewTable() {
-               final long StartTime = System.currentTimeMillis();
-               long erldate = CassandraNativeConnector.getEarliestDateInDB();
-               Calendar runnicCal = Calendar.getInstance();
-               runnicCal.setTime(new Date(erldate));
-               Calendar endcal = Calendar.getInstance();
-               long endTime = endcal.getTime().getTime();
-               for (Date date = runnicCal.getTime(); date.getTime() < endTime; runnicCal.add(Calendar.DATE, 1), date = runnicCal.getTime()) {
-                       try {
-                               ResultSet results = session.execute("SELECT * FROM ProteinData WHERE jobtime = " + date.getTime() + ";");
-                               session.execute("INSERT INTO JobDateInfo " + "(jobday, Total)" + " VALUES (" + date.getTime() + "," + results.all().size()
-                                               + ");");
-                       } catch (QueryExecutionException e) {
-                               e.printStackTrace();
-                       }
-               }
-               System.out.println("Table JobDateInfo filled: total time is " + (System.currentTimeMillis() - StartTime) + " msec");
-       }
-
-       /*
         * fill a table with the database global parameters
         */
        public void FillMainDBParameters() {
index d7aeafb..dbad018 100644 (file)
@@ -60,7 +60,6 @@ public class CassandraRemover extends CassandraReader {
                        return 0;
                }
                Row row = results.one();
-               long njobs = row.getLong("Total") - 1;
                if (status.equals("OK")) {
                        long njobsOK = row.getLong("TotalOK") - 1;
                        String com4 = "DELETE FROM ProteinRow WHERE JobID = '" + jobid + "';";
@@ -70,20 +69,20 @@ public class CassandraRemover extends CassandraReader {
                        String com5 = "DELETE FROM ProteinData WHERE JobID = '" + jobid + "' AND jobtime = " + date + ";";
                        System.out.println("Command: " + com5);
                        CassandraQuery(com5);
-                       UpdateJobDateInfo(date, "TotalOK", njobsOK, njobs);
+                       UpdateJobDateInfo(date, "TotalOK", njobsOK);
                } else {
                        String com6 = "DELETE FROM FailLog WHERE JobID = '" + jobid + "' AND jobtime = " + date + ";";
                        System.out.println("Command: " + com6);
                        CassandraQuery(com6);
                        if (status.equals("STOPPED")) {
                                long njobsStopped = row.getLong("TotalStopped") - 1;
-                               UpdateJobDateInfo(date, "TotalStopped", njobsStopped, njobs);
+                               UpdateJobDateInfo(date, "TotalStopped", njobsStopped);
                        } else if (status.equals("ERROR")) {
                                long njobsError = row.getLong("TotalError") - 1;
-                               UpdateJobDateInfo(date, "TotalError", njobsError, njobs);
+                               UpdateJobDateInfo(date, "TotalError", njobsError);
                        } else if (status.equals("TIMEDOUT")) {
                                long njobsTimeOut = row.getLong("TotalTimeOut") - 1;
-                               UpdateJobDateInfo(date, "TotalTimeOut", njobsTimeOut, njobs);
+                               UpdateJobDateInfo(date, "TotalTimeOut", njobsTimeOut);
                        }
                }
                System.out.println("Job " + jobid + " removed...");
@@ -99,9 +98,8 @@ public class CassandraRemover extends CassandraReader {
         * @return nothing
         * 
         */
-       private void UpdateJobDateInfo(long date, String ColumnName, long totalcol, long total) {
-               String com = "UPDATE JobDateInfo SET " + ColumnName + " = " + totalcol + ", Total = " + total + " WHERE jobday = " + date + ";";
-               System.out.println("Command: " + com);
+       private void UpdateJobDateInfo(long date, String ColumnName, long totalcol) {
+               String com = "UPDATE JobDateInfo SET " + ColumnName + " = " + totalcol + " WHERE jobday = " + date + ";";
                CassandraQuery(com);
        }
 
index b12f59e..8c1bc9d 100644 (file)
@@ -181,9 +181,8 @@ public class CassandraWriter {
                                njobsStop += r.getLong("TotalStopped");
                                njobsTimeOut += r.getLong("TotalTimeOut");
                        }
-                       String com = "INSERT INTO JobDateInfo " + "(jobday, Total, TotalOK, TotalStopped, TotalError, TotalTimeOut)" + " VALUES ("
-                                       + job.getStartingDate() + "," + njobsTotal + "," + njobsOk + "," + njobsStop + "," + njobsError + "," + njobsTimeOut
-                                       + ");";
+                       String com = "INSERT INTO JobDateInfo " + "(jobday, TotalOK, TotalStopped, TotalError, TotalTimeOut)" + " VALUES ("
+                                       + job.getStartingDate() + "," + njobsOk + "," + njobsStop + "," + njobsError + "," + njobsTimeOut + ");";
                        if (null == execute(com)) {
                                System.out.println("CassandraWriter.FormQueryTables: couldn't insert into JobDateInfo");
                                // return 0;
index 2a41621..123af43 100644 (file)
@@ -43,9 +43,12 @@ public class DailyStatisticsReader extends CassandraReader {
                                return null;
                        if (results.isExhausted())
                                continue;
-                       Row therow = results.one();
-                       Total res = new Total(therow.getLong("Total"), therow.getLong("TotalOK"), therow.getLong("TotalStopped"),
-                                       therow.getLong("TotalError"), therow.getLong("TotalTimeOut"));
+                       Row row = results.one();
+                       long nOK = row.getLong("TotalOK");
+                       long nStopped = row.getLong("TotalStopped");
+                       long nError = row.getLong("TotalError");
+                       long nTimeOut = row.getLong("TotalTimeOut");
+                       Total res = new Total(nOK + nStopped + nError + nTimeOut, nOK, nStopped, nError, nTimeOut);
                        if (!results.isExhausted()) {
                                Date dat = new Date(date.getTime());
                                log.warn("CassandraReader.ReadDateTable: date row for " + dat.toString() + " (" + date.getTime() + ") duplicated ");