<h2 style="text-align: center;">JABAWS Services Status</h2>\r
\r
<ul style="font-weight: bold;">\r
- <li>All the services are tested while this page is being loaded</li>\r
- <li>If you want to test the services again, just reload this page.</li>\r
- <li>Click on the service status to see the results of the testing.</li>\r
- <li>Server tested: <a href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}">\r
+ <li>All the services are tested while this page is being loaded</li>\r
+ <li>If you want to test the services again, just reload this page.</li>\r
+ <li>Click on the service status to see the results of the testing.</li>\r
+ <li>Server tested: <a href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}">\r
${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}\r
</a> </li>\r
+ <li>Time of execusion: ${timeexec} msec</li>\r
</ul>\r
\r
<br/>\r
conn = DriverManager.getConnection(protocol + statDBName + ";create=false");\r
\r
conn.setAutoCommit(true);\r
- /*\r
- * Runtime.getRuntime().addShutdownHook(new Thread() {\r
- * \r
- * @Override public void run() { shutdownDBServer(); } });\r
- */\r
} catch (ClassNotFoundException e) {\r
log.error(e.getMessage(), e);\r
}\r
* @throws SQLException\r
*/\r
private void createStatTable() throws SQLException {\r
-\r
- /*\r
- * Creating a statement object that we can use for running various SQL\r
- * statements commands against the database.\r
- */\r
+ // Creating a statement object that we can use for running various SQL\r
+ // statements commands against the database.\r
Statement s = conn.createStatement();\r
String create = "create table exec_stat("\r
+ "number INT GENERATED ALWAYS AS IDENTITY,"\r
if (exist) {\r
date = res.getDate(1);\r
}\r
-\r
res.close();\r
st.close();\r
return date;\r
throws ServletException, IOException {\r
\r
try {\r
+ long startTime = System.nanoTime();\r
StatDB db = new StatDB();\r
Date earliestRec = db.getEarliestRecord();\r
if (earliestRec == null) {\r
writer.close();\r
return;\r
}\r
- Map<Date, Totals> monthlyTotals = StatCollection\r
- .getStats(earliestRec);\r
+ Map<Date, Totals> monthlyTotals = StatCollection.getStats(earliestRec);\r
+ long endTime = System.nanoTime();\r
req.setAttribute("stat", monthlyTotals);\r
req.setAttribute("total", Totals.sumOfTotals(monthlyTotals));\r
+ req.setAttribute("timeexec", (endTime - startTime) / 1000000);\r
\r
- RequestDispatcher dispatcher = req\r
- .getRequestDispatcher("statpages/MonthlySummary.jsp");\r
+ RequestDispatcher dispatcher = req.getRequestDispatcher("statpages/MonthlySummary.jsp");\r
\r
req.setAttribute("isAdmin", isAdmin(req));\r
dispatcher.forward(req, resp);\r
import java.io.StringWriter;\r
import java.util.ArrayList;\r
import java.util.List;\r
+import java.util.Collections;\r
\r
import javax.servlet.RequestDispatcher;\r
import javax.servlet.ServletException;\r
import javax.servlet.http.HttpServlet;\r
import javax.servlet.http.HttpServletRequest;\r
import javax.servlet.http.HttpServletResponse;\r
+import javax.servlet.ServletContext;\r
\r
import org.apache.log4j.Logger;\r
\r
+import compbio.stat.servlet.util.Totals;\r
import compbio.ws.client.Services;\r
import compbio.ws.client.WSTester;\r
\r
\r
private final static Logger log = Logger.getLogger(ServiceStatus.class);\r
\r
+\r
+ private static String getURL(HttpServletRequest req) {\r
+ String scheme = req.getScheme(); // http\r
+ String serverName = req.getServerName(); // hostname.com\r
+ int serverPort = req.getServerPort(); // 80\r
+ String contextPath = req.getContextPath(); // /mywebapp\r
+ String servletPath = req.getServletPath(); // /servlet/MyServlet\r
+ String pathInfo = req.getPathInfo(); // /a/b;c=123\r
+ String queryString = req.getQueryString(); // d=789\r
+\r
+ // Reconstruct original requesting URL\r
+ StringBuffer url = new StringBuffer();\r
+ url.append(scheme).append("://").append(serverName);\r
+\r
+ if ((serverPort != 80) && (serverPort != 443)) {\r
+ url.append(":").append(serverPort);\r
+ }\r
+\r
+ url.append(contextPath).append(servletPath);\r
+\r
+ if (pathInfo != null) {\r
+ url.append(pathInfo);\r
+ }\r
+ if (queryString != null) {\r
+ url.append("?").append(queryString);\r
+ }\r
+ return url.toString();\r
+ }\r
+\r
@Override\r
protected void doGet(HttpServletRequest req, HttpServletResponse resp)\r
throws ServletException, IOException {\r
StringBuffer jabawspath = req.getRequestURL();\r
jabawspath = jabawspath.delete(jabawspath.lastIndexOf("/"), jabawspath.length());\r
String serverPath = jabawspath.toString();\r
- System.out.println("Testing services at " + serverPath); \r
+/**\r
+ String host = java.net.InetAddress.getLocalHost().getCanonicalHostName();\r
+ System.out.println("Testing services at " + req.getRequestURL()); \r
+ System.out.println("Really: Testing services at " + serverPath); \r
+ System.out.println(" serverPath2 is " + getURL(req)); \r
System.out.println(" Context Path is " + req.getContextPath()); \r
+ System.out.println(" Host is " + host); \r
System.out.println(" Request URI is " + req.getRequestURI());\r
System.out.println(" Servlet Path is " + req.getServletPath());\r
System.out.println(" Path Info is " + req.getPathInfo());\r
-\r
+ System.out.println(" Local Port is " + req.getLocalPort());\r
+ System.out.println(" Remote Port is " + req.getRemotePort());\r
+ System.out.println(" Local address is " + req.getLocalAddr());\r
+ System.out.println(" Remote address is " + req.getRemoteAddr());\r
+ @SuppressWarnings("unchecked")\r
+ List<String> list = Collections.list(req.getHeaderNames());\r
+ System.out.println(" HTTP header names are " + list.toString());\r
+ for (String hdr : list) {\r
+ System.out.println(" " + hdr + " header is " + req.getHeader(hdr));\r
+ }\r
+*/\r
List<ServiceTestResult> testResults = new ArrayList<ServiceTestResult>();\r
-\r
+ long startTime = System.nanoTime();\r
for (Services service : Services.values()) {\r
StringWriter testres = new StringWriter();\r
PrintWriter writer = new PrintWriter(testres, true);\r
testResults.add(result);\r
}\r
req.setAttribute("results", testResults);\r
+ long endTime = System.nanoTime();\r
+ req.setAttribute("timeexec", (endTime - startTime) / 1000000);\r
RequestDispatcher rd = req.getRequestDispatcher("statpages/ServicesStatus.jsp");\r
rd.forward(req, resp);\r
}\r