<servlet-name>ServletJobsByDay</servlet-name>\r
<servlet-class>compbio.listeners.ServletJobsByDay</servlet-class>\r
</servlet>\r
+ <servlet>\r
+ <description>\r
+ </description>\r
+ <display-name>ServletJobsByIp</display-name>\r
+ <servlet-name>ServletJobsByIp</servlet-name>\r
+ <servlet-class>compbio.listeners.ServletJobsByIp</servlet-class>\r
+ </servlet>\r
+ <servlet>\r
+ <description>\r
+ </description>\r
+ <display-name>ServletIp</display-name>\r
+ <servlet-name>ServletIp</servlet-name>\r
+ <servlet-class>compbio.listeners.ServletIp</servlet-class>\r
+ </servlet>\r
\r
<servlet-mapping>\r
<servlet-name>ServletDeleteRecord</servlet-name>\r
<servlet-name>ServletJobsByDay</servlet-name>\r
<url-pattern>/ServletJobsByDay</url-pattern>\r
</servlet-mapping>\r
+ <servlet-mapping>\r
+ <servlet-name>ServletJobsByIp</servlet-name>\r
+ <url-pattern>/ServletJobsByIp</url-pattern>\r
+ </servlet-mapping>\r
+ <servlet-mapping>\r
+ <servlet-name>ServletIp</servlet-name>\r
+ <url-pattern>/ServletIp</url-pattern>\r
+ </servlet-mapping>\r
\r
\r
\r
return res;
}
+
+ /*
+ * getting jobs by ip
+ */
+ public List<Pair<String, String>> ReadIpWithJobs(String ip) {
+ final long startTime = System.currentTimeMillis();
+ String com = "SELECT JobID, Protein, FinalStatus FROM ProteinLog WHERE ip = '" + ip + "';";
+ 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();
+ List<Pair<String, String>> res = new ArrayList<Pair<String, String>>();
+ System.out.println("Query time is " + (queryTime - startTime) + " msec");
+ System.out.println(" rows analysed, " + rows.size());
+ int c = 0;
+ for (Row r : rows) {
+ if (r.getString("FinalStatus").equals("OK")) {
+ Pair<String, String> pair = new Pair<String, String>(r.getString("JobID"), r.getString("Protein"));
+ System.out.println(pair.getElement0());
+ System.out.println(pair.getElement1());
+ res.add(pair);
+ ++c;
+ }
+ }
+ final long endTime = System.currentTimeMillis();
+ System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
+ return res;
+ }
+
/*
* getting part of protein sequence from the db ProteinRow
*/
}
/*
+ * getting ip by counter
+ */
+ public Map<String, Integer> ReadIpByCounter() {
+ final long startTime = System.currentTimeMillis();
+ String com = "SELECT JobID, ip FROM ProteinLog;";
+ 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");
+ System.out.println(" rows analysed, " + rows.size());
+ Map<String, Integer> res = new HashMap<String, Integer>();
+ int c = 0;
+ for (Row r : rows) {
+ String protein = r.getString("ip");
+ String id = r.getString("JobID");
+ if (res.containsKey(protein))
+ res.put(protein, res.get(protein) + 1);
+ else
+ res.put(protein, 1);
+ }
+ final long endTime = System.currentTimeMillis();
+ System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
+ return res;
+ }
+
+ /*
* getting log info for jobid
*/
public StructureJobLog ReadJobLog(String jobid) {
private int totalJobs;
private int totalId; // total jobs for current protein sequence
private String id;
+ private String ip;
private String prot; // protein sequence
private String jpred;
private List<String> subProt; // protein sequence divided by several parts for highlighting the particular part
public String getId() {
return id;
}
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getIp() {
+ return ip;
+ }
public void setSubProt(List<String> subProt) {
this.subProt = subProt;
--- /dev/null
+package compbio.listeners;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import compbio.cassandra.DataBase;
+import compbio.statistic.CassandraRequester;
+
+/**
+ * Servlet implementation class ServletIp
+ */
+public class ServletIp extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ final long startTime = System.currentTimeMillis();
+ String ip = request.getParameter("ip");
+ CassandraRequester cr = new CassandraRequester();
+ List<DataBase> r = cr.readIp(ip);
+ request.setAttribute("results", r);
+ final long endTime = System.currentTimeMillis();
+ request.setAttribute("timeExecution", (endTime - startTime));
+ request.setAttribute("ip", ip);
+ RequestDispatcher rd = request.getRequestDispatcher("/FullReportJobsByIp.jsp");
+ rd.forward(request, response);
+ }
+
+ /**
+ * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ doGet(request, response);
+ }
+
+}
--- /dev/null
+package compbio.listeners;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import compbio.cassandra.DataBase;
+import compbio.statistic.CassandraRequester;
+
+/**
+ * Servlet implementation class ServletJobsByIp
+ */
+public class ServletJobsByIp extends HttpServlet {
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ final long startTime = System.currentTimeMillis();
+ int counter = Integer.parseInt(request.getParameter("counterIp"));
+ CassandraRequester cr = new CassandraRequester();
+ List<DataBase> r = cr.readIpByCounter(counter);
+ request.setAttribute("results", r);
+ final long endTime = System.currentTimeMillis();
+ request.setAttribute("timeExecution", (endTime - startTime));
+ request.setAttribute("counter", counter);
+ RequestDispatcher rd = request.getRequestDispatcher("/ReportJobsByIp.jsp");
+ rd.forward(request, response);
+ }
+
+ /**
+ * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ doGet(request, response);
+ }
+
+}
return query;
}
+ /*
+ * query ip with number of jobs
+ */
+ public List<DataBase> readIpByCounter(Integer minimalcounter) {
+ query = new ArrayList<DataBase>();
+ Map<String, Integer> map = db.ReadIpByCounter();
+ if (minimalcounter == null)
+ minimalcounter = 0;
+ if (map == null)
+ return null;
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
+ if (entry.getValue() > minimalcounter) {
+ DataBase bean = new DataBase();
+ bean.setTotalId(entry.getValue());
+ bean.setIp(entry.getKey());
+ query.add(bean);
+ }
+ }
+ return query;
+ }
/*
* query jobs log info
*/
return query;
}
+
+ /*
+ * query jobs by ipStructureJobLog
+ */
+ public List<DataBase> readIp(String ip) {
+ if (ip == null)
+ return null;
+ List<Pair<String, String>> res = db.ReadIpWithJobs(ip);
+ // System.out.println(res.size());
+ if (res == null)
+ return null;
+ query = new ArrayList<DataBase>();
+ for (Pair<String, String> entry : res) {
+ System.out.println("ip " + ip);
+ System.out.println("id " + entry.getElement0());
+ DataBase bean = new DataBase();
+ bean.setIp(ip);
+ bean.setId(entry.getElement0());
+ bean.setProt(entry.getElement1());
+ query.add(bean);
+ }
+ System.out.println(query.size());
+ return query;
+ }
+
/*
* create list of parts of protein sequence;
*/
response.sendRedirect("QuerySequenceProtein.jsp");
else if (query.equals("log"))
response.sendRedirect("QueryLogInfo.jsp");
+ else if (query.equals("ip"))
+ response.sendRedirect("QueryJobsByIP.jsp");
%>
\ No newline at end of file
--- /dev/null
+<%@page import="java.util.ArrayList"%>
+<%@ page trimDirectiveWhitespaces="true"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
+<%@ taglib uri="http://displaytag.sf.net" prefix="dt"%>
+
+<h3>Dundee ProteoCache query result for ${ip}</h3>
+
+<c:choose>
+ <c:when test="${results == null}">
+ <h3>No jobs for an ip ${ip} </h3>
+ </c:when>
+ <c:otherwise>
+
+ <table border="1" style="border-collapse: collapse; white-space: nowrap">
+ <thead>
+ <tr>
+ <th style="text-align: centre">ID</th>
+ <th style="text-align: left">IP</th>
+ <th style="text-align: left">Sequence</th>
+ </tr>
+ </thead>
+ <tbody>
+ <c:forEach items="${results}" var="res" varStatus="status">
+ <tr>
+ <td><a href="ServletLogInfo?IdJob=${res.id}">${res.id}</a></td>
+ <td style="text-align: left; border-buttom: dotted; font-family: monospace">${res.ip}</td>
+ <td style="text-align: left; border-buttom: dotted; font-family: monospace">${res.prot}</td>
+ </tr>
+ </c:forEach>
+ </tbody>
+ </table>
+ </c:otherwise>
+</c:choose>
\ No newline at end of file
<input type="radio" name="query" value="date">Search by date<br/>
<input type="radio" name="query" value="log">Log information for current job<br/>
<input type="radio" name="query" value="length">Usage statistics by job time execution<br/>
+ <input type="radio" name="query" value="ip">Usage statistics by job ip<br/>
<input type="submit" name="Search" value="Search"/>
</form>
</body>
--- /dev/null
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Query jobs by ip</title>
+</head>
+<body>
+ <br/>
+ <form method="get" action="ServletJobsByIp">
+ <h3>Enter counter for jobs by ip</h3>
+ <input type="text" name="counterIp"><br/>
+ <input type="submit" name="Search" value="Search"/><br/><br/>
+ </form>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@page import="java.util.ArrayList"%>
+<%@ page trimDirectiveWhitespaces="true"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
+<%@ taglib uri="http://displaytag.sf.net" prefix="dt"%>
+
+<h3>Dundee ProteoCache query results for jobs more than ${counter} </h3>
+<h3>Time execution: ${timeExecution} ms</h3>
+<c:choose>
+ <c:when test="${results == null}">
+ <h3> No jobs </h3>
+ </c:when>
+
+ <c:otherwise>
+ <table border="1" style="border-collapse: collapse; white-space: nowrap">
+ <thead>
+ <tr>
+ <th style="text-align: centre">Number of jobs</th>
+ <th style="text-align: left">ip</th>
+ </tr>
+ </thead>
+ <tbody>
+ <c:forEach items="${results}" var="res">
+ <tr>
+ <td>${res.totalId}</td>
+ <td style="text-align: left; border-buttom: dotted; font-family: monospace">
+ <a title="Click to view all jobs" href="ServletIp?ip=${res.ip}">${res.ip}</a>
+ </td>
+ </tr>
+ </c:forEach>
+ </tbody>
+ </table>
+ </c:otherwise>
+</c:choose>
\ No newline at end of file