From: Sasha Sherstnev Date: Wed, 20 Nov 2013 16:51:30 +0000 (+0000) Subject: Merge branch 'servlets' X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c0b0fef9166684f5e7cfacbc3701471ec8967f56;hp=-c;p=proteocache.git Merge branch 'servlets' --- c0b0fef9166684f5e7cfacbc3701471ec8967f56 diff --combined datadb/compbio/cassandra/CassandraWriter.java index 24abd4b,521f98c..41ce8ba --- a/datadb/compbio/cassandra/CassandraWriter.java +++ b/datadb/compbio/cassandra/CassandraWriter.java @@@ -1,5 -1,8 +1,8 @@@ package compbio.cassandra; + import java.text.ParseException; + import java.text.SimpleDateFormat; + import java.util.Date; import java.util.List; import org.apache.log4j.Logger; @@@ -8,7 -11,6 +11,7 @@@ import com.datastax.driver.core.Row import com.datastax.driver.core.Session; import com.datastax.driver.core.ResultSet; +import compbio.data.sequence.FastaSequence; import compbio.engine.JpredJob; import compbio.engine.ProteoCachePropertyHelperManager; import compbio.util.PropertyHelper; @@@ -49,6 -51,10 +52,10 @@@ public class CassandraWriter */ public int FormQueryTables(JpredJob job) { if (JobisNotInsterted(job.getJobID())) { + int njobsOk = 0; + int njobsStop = 0; + int njobsError = 0; + int njobsTimeOut = 0; String id = job.getJobID(); String ip = job.getIP(); String protein = job.getProtein(); @@@ -58,42 -64,55 +65,55 @@@ + " VALUES ('" + id + "','" + ip + "','" + job.getStartingTimeStr() + "','" + job.getEndTimeStr() + "','" + finalstatus + "','" + execstatus + "','" + protein + "');"; session.execute(com1); - - String com2 = "INSERT INTO ProteinData " + "(jobtime, JobID, Protein)" + " VALUES (" + job.getStartingDate() + ",'" + id - + "','" + protein + "');"; - session.execute(com2); - - String allpredictions = ""; - List pr = job.getPredictions(); - for (FastaSequence pred : pr) { - String predictionname = pred.getId(); - String prediction = pred.getSequence().replaceAll("\n", ""); - allpredictions += "'" + predictionname + "':'" + prediction + "',"; - } - String final_prediction = ""; - if (!allpredictions.equals("")) { - final_prediction = allpredictions.substring(0, allpredictions.length() - 1); - } - - String check2 = "SELECT * FROM ProteinRow WHERE JobID = '" + job.getJobID() + "';"; - ResultSet results2 = session.execute(check2); - if (results2.isExhausted()) { - String com3 = "INSERT INTO ProteinRow " + "(Protein, JobID, Predictions)" + " VALUES ('" + protein + "','" + id + "',{" - + final_prediction + "});"; - session.execute(com3); + if (execstatus.equals("OK")) { + String com2 = "INSERT INTO ProteinData " + "(jobtime, JobID, ExecTime, Protein)" + " VALUES (" + job.getStartingDate() + ",'" + id + + "'," + job.getExecutionTime() + ",'" + protein + "');"; + session.execute(com2); + + String allpredictions = ""; + List pr = job.getPredictions(); + for (FastaSequence pred : pr) { + String predictionname = pred.getId(); + String prediction = pred.getSequence().replaceAll("\n", ""); + allpredictions += "'" + predictionname + "':'" + prediction + "',"; + } + String final_prediction = ""; + if (!allpredictions.equals("")) { + final_prediction = allpredictions.substring(0, allpredictions.length() - 1); + } + + String check2 = "SELECT * FROM ProteinRow WHERE JobID = '" + job.getJobID() + "';"; + ResultSet results2 = session.execute(check2); + if (results2.isExhausted()) { + String com3 = "INSERT INTO ProteinRow " + "(Protein, JobID, Predictions)" + " VALUES ('" + protein + "','" + id + "',{" + + final_prediction + "});"; + session.execute(com3); + } + njobsOk = 1; + } else { + String com5 = "INSERT INTO FailLog " + "(jobtime, JobID, ExecTime, ip, FinalStatus)" + " VALUES (" + + job.getStartingDate() + ",'" + id + + "'," + job.getExecutionTime() + ",'" + ip + "', '" + finalstatus + "');"; + session.execute(com5); + System.out.println(com5); + if (finalstatus.equals("TIMEDOUT")) + njobsTimeOut = 1; + else if (finalstatus.equals("JPREDERROR")) + njobsError = 1; + else if (finalstatus.equals("STOPPED")) + njobsStop = 1; } - // update some internal query tables String check3 = "SELECT * FROM MainParameters WHERE Name = 'EarliestJobDate';"; ResultSet results3 = session.execute(check3); boolean updateparameter = true; if (!results3.isExhausted()) { - Row r = results3.one(); + Row r = results3.one(); if (job.getStartingDate() >= Long.parseLong(r.getString("Value"))) updateparameter = false; } if (updateparameter) { - String com = "INSERT INTO MainParameters " + "(Name, Value)" + " VALUES ('EarliestJobDate','" + job.getStartingDateStr() + String com = "INSERT INTO MainParameters " + "(Name, Value)" + " VALUES ('EarliestJobDate','" + job.getStartingDate() + "');"; session.execute(com); } @@@ -104,10 -123,15 +124,15 @@@ if (!results4.isExhausted()) { Row r = results4.one(); njobs += r.getLong("Total"); + njobsOk += r.getLong("TotalOK"); + njobsError += r.getLong("TotalError"); + njobsStop += r.getLong("TotalStopped"); + njobsTimeOut += r.getLong("TotalTimeOut"); } - String com = "INSERT INTO JobDateInfo " + "(jobday, Total)" + " VALUES (" + job.getStartingDate() + "," + njobs + ");"; + String com = "INSERT INTO JobDateInfo " + "(jobday, Total, TotalOK, TotalStopped, TotalError, TotalTimeOut)" + " VALUES (" + + job.getStartingDate() + "," + njobs + "," + njobsOk + "," + njobsStop + "," + njobsError + "," + njobsTimeOut + ");"; + System.out.println(com); session.execute(com); - return 1; } return 0; @@@ -121,11 -145,10 +146,10 @@@ if (JobisNotArchived(job.getJobID())) { String id = job.getJobID(); String log = job.getLog().replaceAll("'", ""); - String com = "INSERT INTO JpredArchive (JobID, Protein, IP, StartTime, ExecTime,LOG, ArchiveLink) VALUES ('" + id + "','" - + job.getProtein() + "','" + job.getIP() + "'," + job.getStartingTime() + "," + job.getExecutionTime() + ",'" + log - + "','" + archivepath + "');"; + String com = "INSERT INTO JpredArchive (JobID, Protein, IP, StartTime, ExecTime, FinalStatus, ExecutionStatus, LOG, ArchiveLink) VALUES ('" + id + "','" + + job.getProtein() + "','" + job.getIP() + "'," + job.getStartingTime() + "," + job.getExecutionTime() + ",'" + job.getFinalStatus() + "','" + + job.getExecutionStatus() + "','" + log + "','" + archivepath + "');"; session.execute(com); - List predictions = job.getPredictions(); for (FastaSequence p : predictions) { session.execute("UPDATE JpredArchive SET predictions = predictions + {'" + p.getId() + "':'" diff --combined datadb/compbio/cassandra/JpredParserHTTP.java index 2167a2d,bb2993b..129d8d1 --- a/datadb/compbio/cassandra/JpredParserHTTP.java +++ b/datadb/compbio/cassandra/JpredParserHTTP.java @@@ -15,8 -15,6 +15,8 @@@ import java.util.Date import java.util.List; import compbio.cassandra.JpredParser; +import compbio.data.sequence.FastaReader; +import compbio.data.sequence.FastaSequence; import compbio.engine.JpredJob; public class JpredParserHTTP implements JpredParser { @@@ -56,8 -54,8 +56,8 @@@ private String parsePredictions(final InputStream stream, String jobid) throws FileNotFoundException { final FastaReader fr = new FastaReader(stream); String protein = ""; - alignment = new ArrayList(); - predictions = new ArrayList(); + // alignment = new ArrayList(); + // predictions = new ArrayList(); while (fr.hasNext()) { final FastaSequence fs = fr.next(); String seqid = fs.getId(); @@@ -86,6 -84,8 +86,8 @@@ } private int analyseJob(String[] jobinfo) throws IOException { + alignment = new ArrayList(); + predictions = new ArrayList(); boolean running = true; boolean ConcisefileExists = false; boolean LogfileExists = false;