Fix problem with filling new tables
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Mon, 11 Nov 2013 17:25:16 +0000 (17:25 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Mon, 11 Nov 2013 17:25:16 +0000 (17:25 +0000)
conf/Proteocache.properties
datadb/compbio/cassandra/CassandraNativeConnector.java
datadb/compbio/cassandra/CassandraNewTableWriter.java
server/compbio/listeners/ContextListener.java

index ffd1a6c..a5e72ab 100644 (file)
@@ -3,7 +3,7 @@
 # test server is 10.0.115.190
 cassandra.host=localhost
 
-cassandra.newtables.update=false;
+cassandra.newtables.update=true
 
 #################################################################################
 # Jpred sources
index acb50de..59a2988 100644 (file)
@@ -70,7 +70,7 @@ public class CassandraNativeConnector {
                                + "predictions map<ascii,ascii>, archive blob, LOG varchar, PRIMARY KEY(JobID));");
                
                session.execute("CREATE TABLE IF NOT EXISTS JobDateInfo "
-                               + "(jobday bigint, Total bigint, PRIMARY KEY(jobday));");
+                               + "(jobday bigint, Total bigint, Program varchar, Version varchar, PRIMARY KEY(jobday));");
 
                session.execute("CREATE INDEX IF NOT EXISTS ProteinSeq ON ProteinRow (protein);");
                session.execute("CREATE INDEX IF NOT EXISTS JobDateStamp ON ProteinData (jobtime);");
index 88a4ca2..0d68b1a 100644 (file)
@@ -49,34 +49,28 @@ public class CassandraNewTableWriter {
         * fill new table
         */
        public void FillNewTable() {
-               long date1 = CassandraNativeConnector.getEarliestDateInDB();
-               Calendar start = Calendar.getInstance();
-               start.setTime(new Date(date1));
+               final long StartTime = System.currentTimeMillis();
+               long erldate = CassandraNativeConnector.getEarliestDateInDB();
+               Calendar runnicCal = Calendar.getInstance();
+               runnicCal.setTime(new Date(erldate));
                Calendar endcal = Calendar.getInstance();
-               Date end = endcal.getTime();
-               for (Date date = start.getTime(); !start.after(end); start.add(Calendar.DATE, 1), date = start.getTime()) {
-                       final long startTime = System.currentTimeMillis();
-                       String query1 = "SELECT * FROM ProteinData WHERE jobtime = " + date.getTime() + ";";
-                       System.out.println("Query db: " + query1);
+               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(query1);
-                               final long queryTime = System.currentTimeMillis();
-                               System.out.println("Query time for " + date.toString() + " is " + (queryTime - startTime) + " msec");
-                               String query2 = "INSERT INTO JobDateInfo " + "(jobday, Total)" + " VALUES (" + date.getTime() + "," + results.all().size()
-                                               + ");";
-                               System.out.println("Insert DB: " + query2);
-                               session.execute(query2);
+                               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");
+               System.out.println("Table JobDateInfo filled: total time is " + (System.currentTimeMillis() - StartTime) + " msec");
        }
 
        /*
         * fill a table with the database global parameters
         */
-       public void FillParameters() {
+       public void FillMainDBParameters() {
                Date bubu = new Date(CassandraNativeConnector.getEarliestDateInDB());
                System.out.println("Old EarliestJobDate is " + bubu.toString());
 
index a1ff9cb..ed15609 100644 (file)
@@ -61,6 +61,7 @@ public class ContextListener implements ServletContextListener {
                FILL_NEWTABLE = initBooleanValue("cassandra.newtables.update");
 
                if (FILL_NEWTABLE) {
+                       System.out.println("Initializating new table update scheduler");
                        update_scheduler = Executors.newSingleThreadScheduledExecutor();
                        update_scheduler.schedule(new Runnable() {
                                @Override