From: Natasha Sherstneva
Date: Thu, 28 Nov 2013 14:46:25 +0000 (+0000)
Subject: the new query jobs by ip
X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b154a542bd08371e3bcc7d92d0ded1c638399087;p=proteocache.git
the new query jobs by ip
---
diff --git a/WEB-INF/web.xml b/WEB-INF/web.xml
index 1c53caf..a7669a5 100644
--- a/WEB-INF/web.xml
+++ b/WEB-INF/web.xml
@@ -61,6 +61,20 @@
ServletJobsByDay
compbio.listeners.ServletJobsByDay
+
+
+
+ ServletJobsByIp
+ ServletJobsByIp
+ compbio.listeners.ServletJobsByIp
+
+
+
+
+ ServletIp
+ ServletIp
+ compbio.listeners.ServletIp
+
ServletDeleteRecord
@@ -74,6 +88,14 @@
ServletJobsByDay
/ServletJobsByDay
+
+ ServletJobsByIp
+ /ServletJobsByIp
+
+
+ ServletIp
+ /ServletIp
+
diff --git a/datadb/compbio/cassandra/CassandraReader.java b/datadb/compbio/cassandra/CassandraReader.java
index cb2492e..e75f148 100644
--- a/datadb/compbio/cassandra/CassandraReader.java
+++ b/datadb/compbio/cassandra/CassandraReader.java
@@ -122,6 +122,37 @@ public class CassandraReader {
return res;
}
+
+ /*
+ * getting jobs by ip
+ */
+ public List> 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 rows = results.all();
+ List> res = new ArrayList>();
+ 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 pair = new Pair(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
*/
@@ -182,6 +213,35 @@ public class CassandraReader {
}
/*
+ * getting ip by counter
+ */
+ public Map 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 rows = results.all();
+ System.out.println("Query time is " + (queryTime - startTime) + " msec");
+ System.out.println(" rows analysed, " + rows.size());
+ Map res = new HashMap();
+ 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) {
diff --git a/datadb/compbio/cassandra/DataBase.java b/datadb/compbio/cassandra/DataBase.java
index c6777fc..26a019a 100644
--- a/datadb/compbio/cassandra/DataBase.java
+++ b/datadb/compbio/cassandra/DataBase.java
@@ -14,6 +14,7 @@ public class DataBase {
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 subProt; // protein sequence divided by several parts for highlighting the particular part
@@ -116,6 +117,14 @@ public class DataBase {
public String getId() {
return id;
}
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getIp() {
+ return ip;
+ }
public void setSubProt(List subProt) {
this.subProt = subProt;
diff --git a/server/compbio/listeners/ServletIp.java b/server/compbio/listeners/ServletIp.java
new file mode 100644
index 0000000..9fb5383
--- /dev/null
+++ b/server/compbio/listeners/ServletIp.java
@@ -0,0 +1,44 @@
+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 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);
+ }
+
+}
diff --git a/server/compbio/listeners/ServletJobsByIp.java b/server/compbio/listeners/ServletJobsByIp.java
new file mode 100644
index 0000000..f8d92b9
--- /dev/null
+++ b/server/compbio/listeners/ServletJobsByIp.java
@@ -0,0 +1,45 @@
+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 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);
+ }
+
+}
diff --git a/server/compbio/statistic/CassandraRequester.java b/server/compbio/statistic/CassandraRequester.java
index 72ec074..f4c4c18 100755
--- a/server/compbio/statistic/CassandraRequester.java
+++ b/server/compbio/statistic/CassandraRequester.java
@@ -235,6 +235,26 @@ public class CassandraRequester {
return query;
}
+ /*
+ * query ip with number of jobs
+ */
+ public List readIpByCounter(Integer minimalcounter) {
+ query = new ArrayList();
+ Map map = db.ReadIpByCounter();
+ if (minimalcounter == null)
+ minimalcounter = 0;
+ if (map == null)
+ return null;
+ for (Map.Entry 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
*/
@@ -249,6 +269,31 @@ public class CassandraRequester {
return query;
}
+
+ /*
+ * query jobs by ipStructureJobLog
+ */
+ public List readIp(String ip) {
+ if (ip == null)
+ return null;
+ List> res = db.ReadIpWithJobs(ip);
+ // System.out.println(res.size());
+ if (res == null)
+ return null;
+ query = new ArrayList();
+ for (Pair 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;
*/
diff --git a/website/AllReports.jsp b/website/AllReports.jsp
index ea597a9..8f3b52a 100644
--- a/website/AllReports.jsp
+++ b/website/AllReports.jsp
@@ -8,4 +8,6 @@
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
diff --git a/website/FullReportJobsByIp.jsp b/website/FullReportJobsByIp.jsp
new file mode 100644
index 0000000..2bba716
--- /dev/null
+++ b/website/FullReportJobsByIp.jsp
@@ -0,0 +1,35 @@
+<%@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"%>
+
+Dundee ProteoCache query result for ${ip}
+
+
+
+ No jobs for an ip ${ip}
+
+
+
+
+
+
+ ID
+ IP
+ Sequence
+
+
+
+
+
+ ${res.id}
+ ${res.ip}
+ ${res.prot}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/website/Index.jsp b/website/Index.jsp
index 56f3a6b..c21434f 100644
--- a/website/Index.jsp
+++ b/website/Index.jsp
@@ -13,6 +13,7 @@
Search by date
Log information for current job
Usage statistics by job time execution
+ Usage statistics by job ip
+
+
+
diff --git a/website/QueryJobsByIP.jsp b/website/QueryJobsByIP.jsp
new file mode 100644
index 0000000..a3e40be
--- /dev/null
+++ b/website/QueryJobsByIP.jsp
@@ -0,0 +1,17 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+ pageEncoding="UTF-8"%>
+
+
+