<classpathentry kind="lib" path="WEB-INF/lib/spring-orm-3.2.3.RELEASE.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/spring-oxm-3.2.3.RELEASE.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/spring-tx-3.2.3.RELEASE.jar"/>
- <classpathentry kind="lib" path="WEB-INF/lib/spring-web-3.2.3.RELEASE.jar"/>
+ <classpathentry kind="lib" path="WEB-INF/lib/spring-web-3.2.3.RELEASE.jar" sourcepath="/home/asherstnev/.m2/repository/org/springframework/spring-web/3.2.3.RELEASE/spring-web-3.2.3.RELEASE-sources.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/spring-webmvc-3.2.3.RELEASE.jar" sourcepath="/home/asherstnev/.m2/repository/org/springframework/spring-webmvc/3.2.3.RELEASE/spring-webmvc-3.2.3.RELEASE-sources.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/spring-context-3.2.3.RELEASE.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/spring-context-support-3.2.3.RELEASE.jar"/>
session.execute("CREATE INDEX IF NOT EXISTS ProteinSeq ON ProteinRow (protein);");
session.execute("CREATE INDEX IF NOT EXISTS ProteinIp ON ProteinLog (ip);");
+ session.execute("CREATE INDEX IF NOT EXISTS ON ProteinLog (ExecutionStatus);");
+ session.execute("CREATE INDEX IF NOT EXISTS ON FailLog (FinalStatus);");
// session.execute("CREATE INDEX IF NOT EXISTS JobDateStamp ON ProteinData (jobtime);");
}
System.out.println(" Metrics Options = " + mopt.toString());
System.out.println(" Query Options = " + qopt.toString());
}
-
+
}
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.ResultSet;
+import compbio.engine.JobStatus;
public class CassandraReader {
private Session session;
public CassandraReader() {
Session inis = CassandraNativeConnector.getSession();
- setSession (inis);
+ setSession(inis);
}
public void setSession(Session s) {
* getting data from the db
*/
public DateBean ReadProteinData(long day, String date) {
- final long startTime = System.currentTimeMillis();
String com = "SELECT JobID, Protein FROM ProteinData WHERE jobtime = " + day + ";";
System.out.println("Command: " + com);
ResultSet results = session.execute(com);
if (results.isExhausted())
return null;
- final long queryTime = System.currentTimeMillis();
List<Row> rows = results.all();
- System.out.println("Query time is " + (queryTime - startTime) + " msec");
DateBean res = new DateBean(date);
- int c = 0;
for (Row r : rows) {
res.setJobidAndSeq(r.getString("JobID"), r.getString("Protein"));
- ++c;
}
- final long endTime = System.currentTimeMillis();
- System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
return res;
}
+
+ /**
+ * getting data from the db
+ */
+ public DateBean ReadFailedJobs(long day, String date, JobStatus status) {
+ // FailLog (jobtime, JobID, ExecTime, ip, FinalStatus)
+ String com = "SELECT JobID FROM FailLog WHERE jobtime = " + day + " and FinalStatus = '" + status.name() + "';";
+ ResultSet results = session.execute(com);
+ if (results.isExhausted())
+ return null;
+ List<Row> rows = results.all();
+ DateBean res = new DateBean(date);
+ for (Row r : rows) {
+ String jobid = r.getString("JobID");
+ String com1 = "SELECT Protein FROM ProteinLog WHERE JobID = '" + jobid + "';";
+ System.out.println("Command: " + com1);
+ ResultSet results2 = session.execute(com1);
+ List<Row> jrows = results2.all();
+ if (1 == jrows.size()) {
+ String protein = jrows.get(0).getString("Protein");
+ res.setJobidAndSeq(jobid, protein);
+ }
+ }
+ return res;
+ }
+
/*
* getting data from the db JobDateInfo
*/
if (results.isExhausted())
return null;
Row therow = results.one();
- Total res = new Total(therow.getLong("Total"), therow.getLong("TotalOK"), therow.getLong("TotalStopped"),
+ Total res = new Total(therow.getLong("Total"), therow.getLong("TotalOK"), therow.getLong("TotalStopped"),
therow.getLong("TotalError"), therow.getLong("TotalTimeOut"));
if (!results.isExhausted()) {
- Date date = new Date (queryDate);
- log.warn("CassandraReader.ReadDateTable: date row for " + date.toString () + " ("+ queryDate + ") duplicated ");
+ Date date = new Date(queryDate);
+ log.warn("CassandraReader.ReadDateTable: date row for " + date.toString() + " (" + queryDate + ") duplicated ");
}
return res;
}
System.out.println("Query time is " + (queryTime - startTime) + " msec");
System.out.println(" rows analysed, " + rows.size());
List<ProteinBean> res = new ArrayList<ProteinBean>();
- ProteinBean structure = new ProteinBean(queryProtein, rows.get(0).getMap(
- "Predictions", String.class, String.class));
+ ProteinBean structure = new ProteinBean(queryProtein, rows.get(0).getMap("Predictions", String.class, String.class));
System.out.println("second size : " + rows.size());
int c = 0;
for (Row r : rows) {
- structure.setJobid(r.getString("JobID"));
+ structure.setJobid(r.getString("JobID"));
++c;
}
res.add(structure);
return res;
}
-
/*
* getting jobs by ip
*/
System.out.println(" rows analysed, " + rows.size());
int c = 0;
for (Row r : rows) {
- if (r.getString("FinalStatus").equals("OK")) {
+ if (r.getString("FinalStatus").equals("OK")) {
String date = r.getString("DataBegin");
- res.put(r.getString("JobID"), new String[] {date.substring(0, date.indexOf(":")), r.getString("Protein")});
+ res.put(r.getString("JobID"), new String[] { date.substring(0, date.indexOf(":")), r.getString("Protein") });
++c;
}
}
for (Row r : rows) {
String prot = r.getString("Protein");
if (prot.matches("(.*)" + queryProtein + "(.*)")) {
- ProteinBean structure = new ProteinBean(prot, r.getMap("Predictions", String.class, String.class));
+ ProteinBean structure = new ProteinBean(prot, r.getMap("Predictions", String.class, String.class));
structure.setJobid(r.getString("JobID"));
res.add(structure);
++c;
if (results1.isExhausted())
return null;
Row row1 = results1.one();
- JobBean res = new JobBean(row.getString("Protein"), row.getString("JobID"), row.getString("DataBegin"),
- row.getString("DataEnd"), row.getString("ip"), row1.getMap("Predictions", String.class, String.class));
+ JobBean res = new JobBean(row.getString("Protein"), row.getString("JobID"), row.getString("DataBegin"), row.getString("DataEnd"),
+ row.getString("ip"), row1.getMap("Predictions", String.class, String.class));
System.out.println("Query time is " + (queryTime - startTime) + " msec");
final long endTime = System.currentTimeMillis();
System.out.println(" rows analysed, execution time is " + (endTime - startTime) + " msec");
package compbio.cassandra;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
*/
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();
String finalstatus = job.getFinalStatus();
String execstatus = job.getExecutionStatus();
- String com1 = "INSERT INTO ProteinLog " + "(JobID, IP, DataBegin, DataEnd, FinalStatus, ExecutionStatus, Protein)"
- + " VALUES ('" + id + "','" + ip + "','" + job.getStartingTimeStr() + "','" + job.getEndTimeStr() + "','" + finalstatus
- + "','" + execstatus + "','" + protein + "');";
+
+ String com1 = "INSERT INTO ProteinLog (JobID, IP, DataBegin, DataEnd, FinalStatus, ExecutionStatus, Protein) VALUES ('" + id
+ + "','" + job.getIP() + "','" + job.getStartingTimeStr() + "','" + job.getEndTimeStr() + "','" + finalstatus + "','"
+ + execstatus + "','" + protein + "');";
session.execute(com1);
- if (execstatus.equals("OK")) {
- String com2 = "INSERT INTO ProteinData " + "(jobtime, JobID, ExecTime, Protein)" + " VALUES (" + job.getStartingDate() + ",'" + id
- + "'," + job.getExecutionTime() + ",'" + protein + "');";
+ if (finalstatus.equals("OK")) {
+ String com2 = "INSERT INTO ProteinData " + "(jobtime, JobID, ExecTime, Protein)" + " VALUES (" + job.getStartingDate()
+ + ",'" + id + "'," + job.getExecutionTime() + ",'" + protein + "');";
session.execute(com2);
-
+
String allpredictions = "";
List<FastaSequence> pr = job.getPredictions();
for (FastaSequence pred : pr) {
final_prediction = allpredictions.substring(0, allpredictions.length() - 1);
}
- String check2 = "SELECT * FROM ProteinRow WHERE JobID = '" + job.getJobID() + "';";
- ResultSet results2 = session.execute(check2);
+ ResultSet results2 = session.execute("SELECT * FROM ProteinRow WHERE JobID = '" + job.getJobID() + "';");
if (results2.isExhausted()) {
- String com3 = "INSERT INTO ProteinRow " + "(Protein, JobID, Predictions)" + " VALUES ('" + protein + "','" + id + "',{"
+ 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 + "');";
+ String com5 = "INSERT INTO FailLog (jobtime, JobID, ExecTime, ip, FinalStatus) VALUES (" + job.getStartingDate() + ",'"
+ + id + "'," + job.getExecutionTime() + ",'" + job.getIP() + "', '" + finalstatus + "');";
session.execute(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);
+
+ // update Main parameters if the job is the earliest job so far
+ ResultSet results3 = session.execute("SELECT * FROM MainParameters WHERE Name = 'EarliestJobDate';");
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.getStartingDate()
- + "');";
- session.execute(com);
+ session.execute("INSERT INTO MainParameters (Name, Value) VALUES ('EarliestJobDate','" + job.getStartingDate() + "');");
}
- String check4 = "SELECT * FROM JobDateInfo WHERE jobday = " + job.getStartingDate() + ";";
- ResultSet results4 = session.execute(check4);
- updateparameter = true;
- int njobs = 1;
+
+ // update internal job counts (used by the Daily Statistics
+ // requests)
+ //TODO I don't like the bit of code. There should not be so many counters...
+ int njobsTotal = 1;
+ int njobsOk = 0;
+ int njobsStop = 0;
+ int njobsError = 0;
+ int njobsTimeOut = 0;
+ if (finalstatus.equals("OK"))
+ njobsOk = 1;
+ else if (finalstatus.equals("TIMEDOUT"))
+ njobsTimeOut = 1;
+ else if (finalstatus.equals("JPREDERROR"))
+ njobsError = 1;
+ else if (finalstatus.equals("STOPPED"))
+ njobsStop = 1;
+ ResultSet results4 = session.execute("SELECT * FROM JobDateInfo WHERE jobday = " + job.getStartingDate() + ";");
if (!results4.isExhausted()) {
Row r = results4.one();
- njobs += r.getLong("Total");
+ njobsTotal += 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, TotalOK, TotalStopped, TotalError, TotalTimeOut)" + " VALUES ("
- + job.getStartingDate() + "," + njobs + "," + njobsOk + "," + njobsStop + "," + njobsError + "," + njobsTimeOut + ");";
+ + job.getStartingDate() + "," + njobsTotal + "," + njobsOk + "," + njobsStop + "," + njobsError + "," + njobsTimeOut
+ + ");";
session.execute(com);
return 1;
}
if (JobisNotArchived(job.getJobID())) {
String id = job.getJobID();
String log = job.getLog().replaceAll("'", "");
- 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 + "');";
+ 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<FastaSequence> predictions = job.getPredictions();
for (FastaSequence p : predictions) {
}
return protein;
}
+ private String parseSeqFile(final InputStream stream, String jobid) throws FileNotFoundException {
+ final FastaReader fr = new FastaReader(stream);
+ String protein = "";
+ final FastaSequence fs = fr.next();
+ protein = fs.getSequence().replaceAll("\n", "");
+ if (fr.hasNext()) {
+ // this is an aligment job...
+ return "alignment";
+ }
+ return protein;
+ }
private String parseLogFile(final InputStream stream) throws IOException {
String out = "";
}
if (!running) {
+ // logging the job
job.setAlignment(alignment);
job.setPredictions(predictions);
+ if (job.getExecutionStatus().equals("FAIL")) {
+ URL sequrl = new URL(maindir + job.getJobID() + ".seq");
+ HttpURLConnection httpConnection_sequrl = (HttpURLConnection) sequrl.openConnection();
+ if (199 < httpConnection_sequrl.getResponseCode() && httpConnection_sequrl.getResponseCode() < 300) {
+ try {
+ job.setProtein(parseSeqFile(sequrl.openStream(), job.getJobID()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
cw.FormQueryTables(job);
+
// archiving the job
if (archiving) {
ArchivedJob ajob = new ArchivedJob(job.getJobID());
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
-import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
-import compbio.cassandra.DataBase;
+import compbio.engine.JobStatus;
import compbio.cassandra.DateBean;
import compbio.cassandra.TotalJobsStatisticBean;
import compbio.statistic.CassandraRequester;
}
@RequestMapping(value = "/stat/oneday", method = RequestMethod.GET)
- public String findJobsInOneDay(@RequestParam("date") String date, Map<String, Object> model) throws ParseException {
+ public String findJobsInOneDay(@RequestParam("date") String date, @RequestParam("status") String status, Map<String, Object> model) throws ParseException {
+
final long startTime = System.currentTimeMillis();
String realdate;
realdate = date;
}
+ if (null == JobStatus.getJobStatus(status)) {
+ return "support/Notimplemented";
+ }
+
CassandraRequester cr = new CassandraRequester();
// IMPORTANT: input should be suppied in the format: DD/MM/YYYY
- DateBean r = cr.readJobByDay(realdate);
+ DateBean r = cr.readJobByDay(realdate, JobStatus.getJobStatus(status));
model.put("results", r);
if (r != null)
model.put("njobs", r.getJobidAndSeq().size());
model.put("date", realdate);
+ model.put("status", status);
final long endTime = System.currentTimeMillis();
model.put("timeExecution", (endTime - startTime));
return "/reportJobStatisticsOneDay";
private static final long serialVersionUID = 1L;
/**
- * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
+ * response)
+ */
+ /*
+ * protected void doGet(HttpServletRequest request, HttpServletResponse
+ * response) throws ServletException, IOException { String date =
+ * request.getParameter("date"); CassandraRequester cr = new
+ * CassandraRequester(); request.setAttribute("result",
+ * cr.readJobByDay(date)); request.setAttribute("date", date);
+ * RequestDispatcher rd =
+ * request.getRequestDispatcher("/ReportJobsByADay.jsp");
+ * rd.forward(request, response); }
*/
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String date = request.getParameter("date");
- CassandraRequester cr = new CassandraRequester();
- request.setAttribute("result", cr.readJobByDay(date));
- request.setAttribute("date", date);
- RequestDispatcher rd = request.getRequestDispatcher("/ReportJobsByADay.jsp");
- rd.forward(request, response);
- }
-
/**
- * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
+ * response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import compbio.cassandra.TotalByCounterBean;
import compbio.cassandra.TotalJobsStatisticBean;
import compbio.cassandra.UserBean;
+import compbio.engine.JobStatus;
public class CassandraRequester {
private CassandraReader db = new CassandraReader();
/*
* query: jobs and sequence at date
*/
- public DateBean readJobByDay(String date) {
+ public DateBean readJobByDay(String date, JobStatus status) {
if (!isThisDateValid(date, formatDDMMYY)) {
System.out.println("CassandraRequester.readJobByDay: Wrong date format for " + date);
return null;
long day = DateParsing(date, formatDDMMYY);
if (day < earlestDate || day > currentDate)
return null;
- return db.ReadProteinData(day, date);
+
+ if (status == JobStatus.OK) {
+ return db.ReadProteinData(day, date);
+ }
+ return db.ReadFailedJobs(day, date, status);
}
/*
<td style="text-align: center">${res.key}</td>
<c:set var="value" value="${res.value}"/>
<td style="text-align: right">${value.total}</td>
- <td style="text-align: right"><a href="${onedayquery}?date=${res.key}">${value.totalOK}</a></td>
- <td style="text-align: right">${value.totalStopped}</td>
- <td style="text-align: right">${value.totalError}</td>
- <td style="text-align: right">${value.totalTimeOut}</td>
+ <td style="text-align: right"><a href="${onedayquery}?date=${res.key}&status=OK">${value.totalOK}</a></td>
+ <td style="text-align: right">
+ <c:choose>
+ <c:when test="${value.totalStopped == 0}">0</c:when>
+ <c:otherwise><a href="${onedayquery}?date=${res.key}&status=Stopped">${value.totalStopped}</a></c:otherwise>
+ </c:choose>
+ </td>
+ <td style="text-align: right">
+ <c:choose>
+ <c:when test="${value.totalError == 0}">0</c:when>
+ <c:otherwise><a href="${onedayquery}?date=${res.key}&status=JpredError">${value.totalError}</a></c:otherwise>
+ </c:choose>
+ </td>
+ <td style="text-align: right">
+ <c:choose>
+ <c:when test="${value.totalTimeOut == 0}">0</c:when>
+ <c:otherwise><a href="${onedayquery}?date=${res.key}&status=TimedOut">${value.totalTimeOut}</a></c:otherwise>
+ </c:choose>
+ </td>
</tr>
</c:forEach>
</tbody>
</div>
</c:otherwise>
</c:choose>
-
</div>
</div>
<div class="container">
<jsp:include page="fragments/mainmenu.jsp" />
<spring:url value="/joblog/query" var="jobquery" />
- <spring:url value="/stat/oneday?date=${date}" var="thequery" />
+ <spring:url value="/stat/oneday?date=${date}&status=${status}" var="thequery" />
<ul class="nav navbar-nav navbar-right">
<li>