merge JABAWS_Release_2_1 into develop
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Mon, 29 Jul 2013 12:58:12 +0000 (13:58 +0100)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Mon, 29 Jul 2013 12:58:12 +0000 (13:58 +0100)
15 files changed:
.classpath
.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs [new file with mode: 0644]
.settings/org.eclipse.wst.common.component
WEB-INF/lib/derby-10.8.2.2.jar [moved from WEB-INF/lib/derby.jar with 59% similarity]
conf/log4j.properties [deleted file]
conf/settings/AAConParameters.xml
engine/compbio/engine/local/ExecutableWrapper.java
log/log4j.properties
statpages/ServicesStatus.jsp
testsrc/compbio/ws/client/TestAAConWS.java
webservices/compbio/stat/collector/JobStat.java
webservices/compbio/stat/collector/StatDB.java
webservices/compbio/ws/client/WSTester.java
webservices/compbio/ws/server/MainManager.java
webservices/compbio/ws/server/SetExecutableFlag.java

index 2d206e3..261bdb3 100644 (file)
@@ -13,7 +13,7 @@
        <classpathentry kind="lib" path="WEB-INF/lib/log4j-1.2.15.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/compbio-annotations-1.0.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/compbio-util-1.4.jar"/>
-       <classpathentry kind="lib" path="WEB-INF/lib/derby.jar"/>
+       <classpathentry kind="lib" path="WEB-INF/lib/derby-10.8.2.2.jar"/>
        <classpathentry kind="lib" path="WEB-INF/lib/compbio-ga-1.0.jar"/>
        <classpathentry kind="output" path="WEB-INF/classes"/>
 </classpath>
diff --git a/.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs b/.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs
new file mode 100644 (file)
index 0000000..7c8126d
--- /dev/null
@@ -0,0 +1,5 @@
+XDOCLETBUILDERACTIVE=true
+XDOCLETHOME=
+XDOCLETUSEGLOBAL=true
+XDOCLETVERSION=1.2.1
+eclipse.preferences.version=1
index f062064..f33c768 100644 (file)
@@ -2,11 +2,11 @@
 <project-modules id="moduleCoreId" project-version="1.5.0">
     <wb-module deploy-name="jaba">
         <wb-resource deploy-path="/" source-path="/website" tag="defaultRootSource"/>
-       <wb-resource deploy-path="/binaries" source-path="binaries"/>
-       <wb-resource deploy-path="/jobsout" source-path="jobsout"/>
-       <wb-resource deploy-path="/ExecutionStatistic" source-path="ExecutionStatistic"/>
-       <wb-resource deploy-path="/conf" source-path="conf"/>
-       <wb-resource deploy-path="/statpages" source-path="statpages"/>
+        <wb-resource deploy-path="/binaries" source-path="binaries"/>
+        <wb-resource deploy-path="/jobsout" source-path="jobsout"/>
+        <wb-resource deploy-path="/ExecutionStatistic" source-path="ExecutionStatistic"/>
+        <wb-resource deploy-path="/conf" source-path="conf"/>
+        <wb-resource deploy-path="/statpages" source-path="statpages"/>
         <wb-resource deploy-path="/WEB-INF" source-path="WEB-INF"/>
         <wb-resource deploy-path="/META-INF" source-path="META-INF"/>
         <wb-resource deploy-path="/WEB-INF/classes" source-path="/log"/>
similarity index 59%
rename from WEB-INF/lib/derby.jar
rename to WEB-INF/lib/derby-10.8.2.2.jar
index 631cdd7..b595559 100644 (file)
Binary files a/WEB-INF/lib/derby.jar and b/WEB-INF/lib/derby-10.8.2.2.jar differ
diff --git a/conf/log4j.properties b/conf/log4j.properties
deleted file mode 100644 (file)
index f1567cc..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-\r
-## CHANGE THIS (The root directory where to store all the log files)  \r
-#logDir = .\r
-\r
-## Uncomment to enable JWS2 activity logging to standard out (to the console if available)\r
-## for possible log levels please refer to Log4j documentation http://logging.apache.org/log4j/1.2/manual.html \r
-## Valid log levels are:\r
-## TRACE - log everything from below including very detailed messages (useful for debugging only)\r
-## DEBUG - log everything from below including some minor events (useful for debugging only)\r
-## INFO - log everything from below including some information messages\r
-## WARN - log error and warnings\r
-## ERROR - log errors and fatal events only \r
-## FATAL - log fatal events only\r
-\r
-## Uncomment this if you would like the system to log messages into stdout\r
-#log4j.rootLogger=TRACE, rootfile\r
-#log4j.appender.rootfile=org.apache.log4j.RollingFileAppender\r
-#log4j.appender.rootfile.File=JABAWSLogFilename.log\r
-#log4j.appender.rootfile.Target=System.out\r
-#log4j.appender.rootfile.layout=org.apache.log4j.PatternLayout\r
-#log4j.appender.rootfile.layout.ConversionPattern=%t %d %m%n\r
-\r
-## Uncomment to enable JWS2 activity logging to the file\r
-#log4j.logger.compbio=TRACE, ACTIVITY\r
-#log4j.appender.ACTIVITY=org.apache.log4j.RollingFileAppender\r
-################log4j.appender.ACTIVITY.File=${logDir}/activity.log\r
-#log4j.appender.ACTIVITY.File=${catalina.base}/logs/JABAWSLogFilename.log\r
-#log4j.appender.ACTIVITY.MaxFileSize=10MB\r
-#log4j.appender.ACTIVITY.MaxBackupIndex=10000\r
-#log4j.appender.ACTIVITY.layout=org.apache.log4j.PatternLayout\r
-#log4j.appender.ACTIVITY.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %-5p %3x - %m%n\r
-\r
-## Uncomment for separate local engine execution log (debugging only)\r
-#log4j.logger.compbio.engine.local.LocalExecutorService=INFO, C\r
-#log4j.appender.C=org.apache.log4j.FileAppender\r
-#log4j.appender.C.File=LocalExecutorService.log\r
-#log4j.appender.C.layout=org.apache.log4j.PatternLayout\r
-#log4j.appender.C.layout.ConversionPattern=%m%n\r
-\r
-##################################################################################################################################\r
-# log4j.properties from runner/\r
-\r
-#log4j.appender.stdout=org.apache.log4j.ConsoleAppender\r
-#log4j.appender.stdout.Target=System.out\r
-#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout\r
-#log4j.appender.stdout.layout.ConversionPattern=%m%n\r
-#log4j.rootLogger=info, stdout\r
-\r
-log4j.rootLogger=TRACE, rootfile\r
-log4j.appender.rootfile=org.apache.log4j.FileAppender\r
-log4j.appender.rootfile.File=${catalina.base}/logs/JABAWSLogFilename.log1\r
-log4j.appender.rootfile.Target=System.out\r
-log4j.appender.rootfile.layout=org.apache.log4j.PatternLayout\r
-log4j.appender.rootfile.layout.ConversionPattern=%t %d %m%n\r
-\r
-# %d{ABSOLUTE} %5p %c{1}:%L -\r
-log4j.logger.compbio=TRACE, B\r
-log4j.appender.B=org.apache.log4j.FileAppender\r
-#log4j.appender.B.File=engine.log\r
-log4j.appender.B.File=${catalina.base}/logs/engine.log\r
-log4j.appender.B.layout=org.apache.log4j.PatternLayout\r
-log4j.appender.B.layout.ConversionPattern=%m%n %d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - \r
-\r
-# %d{ABSOLUTE} %5p %c{1}:%L -\r
-#log4j.logger.compbio.engine.local.LocalExecutorService=INFO, C\r
-#log4j.appender.C=org.apache.log4j.FileAppender\r
-#log4j.appender.C.File=LocalExecutorService.log\r
-#log4j.appender.C.layout=org.apache.log4j.PatternLayout\r
-#log4j.appender.C.layout.ConversionPattern=%m%n\r
-# %d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - \r
-\r
-#log4j.logger.RunnerLogger=ERROR, D\r
-#log4j.appender.D=org.apache.log4j.ConsoleAppender \r
-#log4j.appender.D.layout=org.apache.log4j.PatternLayout\r
-#log4j.appender.D.layout.ConversionPattern=%r [%t] %p %c %x - %m%n\r
index 6ebcad4..bdc1ef7 100644 (file)
@@ -55,7 +55,7 @@
     <furtherDetails>prog_docs/aacon.txt</furtherDetails>\r
     <defaultValue>MID_SCORE</defaultValue>\r
     <possibleValues>MAX_SCORE</possibleValues>\r
-        <possibleValues>MID_SCORE</possibleValues>\r
+    <possibleValues>MID_SCORE</possibleValues>\r
   </parameters>\r
 \r
   <parameters>\r
index 597af4e..9e652f9 100644 (file)
@@ -75,17 +75,14 @@ public final class ExecutableWrapper implements
 \r
        pbuilder = new ProcessBuilder(params);\r
        if (executable.getEnvironment() != null) {\r
-           log.debug("Setting command environment variables: "\r
-                   + pbuilder.environment());\r
-           Util.mergeEnvVariables(pbuilder.environment(), executable\r
-                   .getEnvironment());\r
+           log.debug("Setting command environment variables: " + pbuilder.environment());\r
+           Util.mergeEnvVariables(pbuilder.environment(), executable.getEnvironment());\r
            log.debug("Process environment:" + pbuilder.environment());\r
        }\r
        log.debug("Setting command: " + pbuilder.command());\r
        PathValidator.validateDirectory(workDirectory);\r
        pbuilder.directory(new File(workDirectory));\r
-       log.debug("Current working directory is "\r
-               + SysPrefs.getCurrentDirectory());\r
+       log.debug("Current working directory is " + SysPrefs.getCurrentDirectory());\r
        log.debug("Setting working directory: " + workDirectory);\r
        // Initialize private executor to dump processes output if any to the\r
        // file system\r
@@ -98,8 +95,7 @@ public final class ExecutableWrapper implements
                // get access to the thread efficiently deadlocking the\r
                // proccess!\r
                this.es = Executors.newCachedThreadPool();\r
-               log\r
-                       .debug("Initializing executor for local processes output dump");\r
+               log.debug("Initializing executor for local processes output dump");\r
                // Make sure that the executors are going to be properly closed\r
                Runtime.getRuntime().addShutdownHook(new Thread() {\r
                    @Override\r
@@ -119,7 +115,7 @@ public final class ExecutableWrapper implements
      */\r
     public static final void shutdownService() {\r
        if (es != null) {\r
-           es.shutdownNow();\r
+               es.shutdownNow();\r
        }\r
     }\r
 \r
index fc6e3a9..07df1cc 100644 (file)
 #log4j.appender.stdout.layout.ConversionPattern=%m%n\r
 #log4j.rootLogger=info, stdout\r
 \r
-log4j.rootLogger=ERROR, errorfile\r
-log4j.appender.errorfile=org.apache.log4j.FileAppender\r
-log4j.appender.errorfile.File=${catalina.base}/logs/JABAWSErrorFile.log\r
-log4j.appender.errorfile.Target=System.out\r
-log4j.appender.errorfile.layout=org.apache.log4j.PatternLayout\r
-log4j.appender.errorfile.layout.ConversionPattern=%t %d %m%n\r
+log4j.rootLogger=ERROR, R\r
+log4j.appender.R=org.apache.log4j.FileAppender\r
+log4j.appender.R.File=${catalina.base}/logs/JABAWSErrorFile.log\r
+log4j.appender.R.layout=org.apache.log4j.PatternLayout\r
+log4j.appender.R.layout.ConversionPattern=%m%n %d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - \r
 \r
 # %d{ABSOLUTE} %5p %c{1}:%L -\r
-log4j.logger.compbio=TRACE, B\r
+log4j.logger.compbio=WARN, B\r
 log4j.appender.B=org.apache.log4j.FileAppender\r
 log4j.appender.B.File=${catalina.base}/logs/engine.log\r
 log4j.appender.B.layout=org.apache.log4j.PatternLayout\r
index 533f172..b9c4fb2 100644 (file)
@@ -17,7 +17,9 @@ TODO refactor
 </c:import>  \r
 <div style="margin: 20px ">\r
 <h2 style="text-align: center;">JABAWS Services Status</h2>\r
-<h2 style="text-align: center;">Server: <span style="color: green">${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}</span> </h2>\r
+<h2 style="text-align: center;">Server: \r
+<a href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}">\r
+<span style="color: green">${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}</span></a></h2>\r
 <br/>\r
 <p>All the services were tested while this page was loading. If you want to test the services again, just reload this page. Click on the service status to see the results of the testing.</p>\r
 <table class="its" >\r
@@ -74,4 +76,4 @@ the HTTP code response service checker. It responds with HTTP status code depend
 of the web service.\r
 For more information please refer to <a href="man_serverwar.html#usingWsTester">Testing JABAWS server</a> help page.</p>\r
 </div><!-- margin div -->      \r
-<jsp:include page="footer.jsp" />
\ No newline at end of file
+<jsp:include page="footer.jsp" />\r
index 19cd0b2..d54e67f 100644 (file)
@@ -3,12 +3,13 @@ package compbio.ws.client;
 import static org.testng.Assert.assertEquals;\r
 import static org.testng.Assert.assertNotNull;\r
 import static org.testng.Assert.fail;\r
-\r
+import static org.testng.Assert.assertTrue;\r
 import java.io.File;\r
 import java.io.FileInputStream;\r
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
 import java.net.ConnectException;\r
+import java.util.ArrayList;\r
 import java.util.List;\r
 \r
 import javax.xml.ws.WebServiceException;\r
@@ -25,6 +26,8 @@ import compbio.data.sequence.SequenceUtil;
 import compbio.metadata.AllTestSuit;\r
 import compbio.metadata.JobSubmissionException;\r
 import compbio.metadata.LimitExceededException;\r
+import compbio.metadata.Option;\r
+import compbio.metadata.Preset;\r
 import compbio.metadata.PresetManager;\r
 import compbio.metadata.ResultNotAvailableException;\r
 import compbio.metadata.RunnerConfig;\r
@@ -135,6 +138,16 @@ public class TestAAConWS {
 \r
        }\r
        @Test(groups = {AllTestSuit.test_group_webservices})\r
+       public void testRecoverArgsForPreset() throws Exception {\r
+               PresetManager<AACon> presets = msaws.getPresets();\r
+               for (Preset<AACon> preset:presets.getPresets())\r
+               {\r
+                       List<Option<AACon>> args = preset.getArguments(msaws.getRunnerOptions());\r
+                       List opts = preset.getOptions();\r
+                       assertTrue(args.size()>=opts.size(),"Couldn't recover all Option items for preset "+preset.getName());\r
+               }\r
+       }\r
+       @Test(groups = {AllTestSuit.test_group_webservices})\r
        public void testPresetAnalize() throws FileNotFoundException, IOException {\r
 \r
                String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()\r
@@ -201,21 +214,23 @@ public class TestAAConWS {
                // System.out.println(options.getArguments());\r
 \r
                try {\r
-                       options.getArgument("Calculation method").setDefaultValue("SMERFS");\r
+                       List<Option<AACon>> args = new ArrayList<Option<AACon>>();\r
+                       Option<AACon> arg,normarg;\r
+                       args.add(arg=options.getArgument("SMERFS"));\r
+                       args.add(normarg=options.getArgument("Normalize"));\r
+                       arg.setValue(arg.getPossibleValues().get(0));\r
                        // options.getArgument("SMERFS Column Scoring Method")\r
                        // .setDefaultValue("MAX_SCORE");\r
                        // options.getArgument("SMERFS Gap Threshhold").setDefaultValue("1");\r
-                       String jobId = msaws.customAnalize(fsl, options.getArguments());\r
+                       String jobId = msaws.customAnalize(fsl, args);\r
                        ScoreManager result = msaws.getAnnotation(jobId);\r
                        assertNotNull(result);\r
                        assertEquals(result.asSet().size(), 1);\r
                        assertEquals(result.asSet().iterator().next().getScores().get(0),\r
                                        0.698f);\r
-\r
-                       options.getArgument("Calculation method").setDefaultValue("SMERFS");\r
-                       options.removeArgument("Normalize");\r
-                       System.out.println(options);\r
-                       jobId = msaws.customAnalize(fsl, options.getArguments());\r
+                       args.remove(normarg); // remove normalization argument\r
+                       // System.out.println(options);\r
+                       jobId = msaws.customAnalize(fsl, args);\r
                        result = msaws.getAnnotation(jobId);\r
                        assertNotNull(result);\r
                        assertEquals(result.asSet().size(), 1);\r
index 72c7ae1..2ad48ff 100644 (file)
-/* Copyright (c) 2011 Peter Troshin\r
- *  \r
- *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
- * \r
- *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
- *  Apache License version 2 as published by the Apache Software Foundation\r
- * \r
- *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
- *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
- *  License for more details.\r
- * \r
- *  A copy of the license is in apache_license.txt. It is also available here:\r
- * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
- * \r
- * Any republication or derived work distributed in source code form\r
- * must include this copyright and license notice.\r
- */\r
-package compbio.stat.collector;\r
-\r
-import java.sql.Timestamp;\r
-import java.text.DateFormat;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Comparator;\r
-import java.util.Date;\r
-import java.util.Locale;\r
-\r
-import compbio.engine.client.ConfExecutable;\r
-import compbio.util.Util;\r
-import compbio.ws.client.Services;\r
-\r
-public class JobStat {\r
-\r
-       static final Comparator<JobStat> RUNTIME = new Comparator<JobStat>() {\r
-               @Override\r
-               public int compare(JobStat o1, JobStat o2) {\r
-                       return new Integer(o2.getRuntime()).compareTo(o1.getRuntime());\r
-               }\r
-       };\r
-\r
-       static final Comparator<JobStat> STARTTIME = new Comparator<JobStat>() {\r
-               @Override\r
-               public int compare(JobStat o1, JobStat o2) {\r
-                       return new Long(o1.start).compareTo(o2.start);\r
-               }\r
-       };\r
-\r
-       static final Comparator<JobStat> RESULTSIZE = new Comparator<JobStat>() {\r
-               @Override\r
-               public int compare(JobStat o1, JobStat o2) {\r
-                       return new Long(o2.resultSize).compareTo(o1.resultSize);\r
-               }\r
-       };\r
-\r
-       private static DateFormat DATE_TIME = SimpleDateFormat.getDateTimeInstance(\r
-                       DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.UK);\r
-\r
-       Services webService;\r
-       String clusterJobId;\r
-       String jobname;\r
-       long start;\r
-       long finish;\r
-       long inputSize;\r
-       long resultSize;\r
-       boolean isCollected;\r
-       boolean isCancelled;\r
-\r
-       private JobStat(Services webService, String clusterJobId, String jobname,\r
-                       long start, long finish, long inputSize, long resultSize,\r
-                       boolean isCancelled, boolean isCollected) {\r
-               super();\r
-               this.webService = webService;\r
-               this.clusterJobId = clusterJobId;\r
-               this.jobname = jobname;\r
-               this.start = start;\r
-               this.finish = finish;\r
-               this.inputSize = inputSize;\r
-               this.resultSize = resultSize;\r
-               this.isCancelled = isCancelled;\r
-               this.isCollected = isCollected;\r
-               validate();\r
-       }\r
-\r
-       static JobStat newInstance(Services webService, String clusterJobId,\r
-                       String jobname, long start, long finish, long inputSize,\r
-                       long resultSize, boolean isCancelled, boolean isCollected) {\r
-               return new JobStat(webService, clusterJobId, jobname, start, finish,\r
-                               inputSize, resultSize, isCancelled, isCollected);\r
-       }\r
-\r
-       static JobStat newInstance(Services webService, String clusterJobId,\r
-                       String jobname, Timestamp start, Timestamp finish, long inputSize,\r
-                       long resultSize, boolean isCancelled, boolean isCollected) {\r
-               long startm = ExecutionStatCollector.UNDEFINED;\r
-               long stopm = ExecutionStatCollector.UNDEFINED;\r
-               if (start != null) {\r
-                       startm = start.getTime();\r
-               }\r
-               if (finish != null) {\r
-                       stopm = finish.getTime();\r
-               }\r
-               return new JobStat(webService, clusterJobId, jobname, startm, stopm,\r
-                               inputSize, resultSize, isCancelled, isCollected);\r
-       }\r
-\r
-       void validate() {\r
-               if (webService == null) {\r
-                       throw new AssertionError("webService must be defined!:\n " + this);\r
-               }\r
-               if (Util.isEmpty(jobname)) {\r
-                       throw new AssertionError("jobname must be defined!:\n" + this);\r
-               }\r
-       }\r
-\r
-       private JobStat(String jobId) {\r
-               assert !Util.isEmpty(jobname);\r
-               this.jobname = jobId;\r
-       }\r
-\r
-       static JobStat newIncompleteStat(String jobname) {\r
-               return new JobStat(jobname);\r
-       }\r
-\r
-       public boolean isClusterJob() {\r
-               return jobname.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX);\r
-       }\r
-\r
-       @Override\r
-       public int hashCode() {\r
-               final int prime = 31;\r
-               int result = 1;\r
-               result = prime * result + ((jobname == null) ? 0 : jobname.hashCode());\r
-               return result;\r
-       }\r
-\r
-       @Override\r
-       public boolean equals(Object obj) {\r
-               if (this == obj)\r
-                       return true;\r
-               if (obj == null)\r
-                       return false;\r
-               if (getClass() != obj.getClass())\r
-                       return false;\r
-               JobStat other = (JobStat) obj;\r
-               if (jobname == null) {\r
-                       if (other.jobname != null)\r
-                               return false;\r
-               } else if (!jobname.equals(other.jobname))\r
-                       return false;\r
-               return true;\r
-       }\r
-\r
-       public int getRuntime() {\r
-               if (start != ExecutionStatCollector.UNDEFINED\r
-                               && finish != ExecutionStatCollector.UNDEFINED) {\r
-                       return (int) (finish - start) / 1000;\r
-               }\r
-               return ExecutionStatCollector.UNDEFINED;\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               return getJobReport();\r
-       }\r
-\r
-       String getJobReport() {\r
-               String report = "WS: " + webService + "\n";\r
-               report += "JOB: " + jobname + "\n";\r
-               if (start != ExecutionStatCollector.UNDEFINED) {\r
-                       report += "Started " + new Date(start) + "\n";\r
-               }\r
-               if (finish != ExecutionStatCollector.UNDEFINED) {\r
-                       report += "Finished " + new Date(finish) + "\n";\r
-               }\r
-               if (start != ExecutionStatCollector.UNDEFINED\r
-                               && finish != ExecutionStatCollector.UNDEFINED) {\r
-                       report += "Runtime " + getRuntime() + "\n";\r
-               }\r
-               report += "Input size " + inputSize + "\n";\r
-               report += "Result size " + resultSize + "\n";\r
-               report += "ClusterJobID " + clusterJobId + "\n";\r
-               report += "Collected? " + isCollected + "\n";\r
-               report += "Cancelled? " + isCancelled + "\n";\r
-               return report;\r
-       }\r
-\r
-       /**\r
-        * Header Job Started Finished Runtime Input Result\r
-        */\r
-       String getJobReportTabulated() {\r
-               String report = webService + "\t";\r
-               report += jobname + "\t";\r
-               if (start != ExecutionStatCollector.UNDEFINED) {\r
-                       report += ExecutionStatCollector.DF.format(new Date(start)) + "\t";\r
-               } else {\r
-                       report += ExecutionStatCollector.UNDEFINED + "\t";\r
-               }\r
-               if (finish != ExecutionStatCollector.UNDEFINED) {\r
-                       report += ExecutionStatCollector.DF.format(new Date(finish)) + "\t";\r
-               } else {\r
-                       report += ExecutionStatCollector.UNDEFINED + "\t";\r
-               }\r
-               if (start != ExecutionStatCollector.UNDEFINED\r
-                               && finish != ExecutionStatCollector.UNDEFINED) {\r
-                       report += getRuntime() + "\t";\r
-               } else {\r
-                       report += ExecutionStatCollector.UNDEFINED + "\t";\r
-               }\r
-               report += inputSize + "\t";\r
-               report += resultSize + "\t";\r
-               report += clusterJobId + "\t";\r
-               report += isCollected + "\t";\r
-               report += isCancelled + "\t";\r
-               return report;\r
-       }\r
-\r
-       public Services getWebService() {\r
-               return webService;\r
-       }\r
-\r
-       public String getClusterJobId() {\r
-               return clusterJobId;\r
-       }\r
-\r
-       public String getJobname() {\r
-               return jobname;\r
-       }\r
-\r
-       public String getEscJobname() {\r
-               String[] parts = jobname.split("#");\r
-               return parts[0] + "%23" + parts[1];\r
-       }\r
-\r
-       public String getStart() {\r
-               if (start != ExecutionStatCollector.UNDEFINED) {\r
-                       return DATE_TIME.format(new Date(start));\r
-               }\r
-               return "?";\r
-       }\r
-\r
-       public String getFinish() {\r
-               if (finish != ExecutionStatCollector.UNDEFINED) {\r
-                       return DATE_TIME.format(new Date(finish));\r
-               }\r
-               return "?";\r
-       }\r
-\r
-       public long getInputSize() {\r
-               if (inputSize != ExecutionStatCollector.UNDEFINED) {\r
-                       return inputSize;\r
-               }\r
-               return 0;\r
-       }\r
-\r
-       public long getResultSize() {\r
-               if (resultSize > 0) {\r
-                       return resultSize;\r
-               }\r
-               return 0;\r
-       }\r
-\r
-       public boolean hasResult() {\r
-               return resultSize > 0;\r
-       }\r
-\r
-       public boolean hasStarted() {\r
-               return start != ExecutionStatCollector.UNDEFINED;\r
-       }\r
-\r
-       public boolean getIsCollected() {\r
-               return isCollected;\r
-       }\r
-\r
-       public boolean getIsCancelled() {\r
-               return isCancelled;\r
-       }\r
-\r
-       public boolean getIsFinished() {\r
-               return finish != ExecutionStatCollector.UNDEFINED;\r
-       }\r
-\r
-}
\ No newline at end of file
+/* Copyright (c) 2011 Peter Troshin
+ *  
+ *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     
+ * 
+ *  This library is free software; you can redistribute it and/or modify it under the terms of the
+ *  Apache License version 2 as published by the Apache Software Foundation
+ * 
+ *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache 
+ *  License for more details.
+ * 
+ *  A copy of the license is in apache_license.txt. It is also available here:
+ * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
+ * 
+ * Any republication or derived work distributed in source code form
+ * must include this copyright and license notice.
+ */
+package compbio.stat.collector;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.Locale;
+
+import compbio.engine.client.ConfExecutable;
+import compbio.util.Util;
+import compbio.ws.client.Services;
+
+public class JobStat {
+
+       static final Comparator<JobStat> RUNTIME = new Comparator<JobStat>() {
+               @Override
+               public int compare(JobStat o1, JobStat o2) {
+                       return new Integer(o2.getRuntime()).compareTo(o1.getRuntime());
+               }
+       };
+
+       static final Comparator<JobStat> STARTTIME = new Comparator<JobStat>() {
+               @Override
+               public int compare(JobStat o1, JobStat o2) {
+                       return new Long(o1.start).compareTo(o2.start);
+               }
+       };
+
+       static final Comparator<JobStat> RESULTSIZE = new Comparator<JobStat>() {
+               @Override
+               public int compare(JobStat o1, JobStat o2) {
+                       return new Long(o2.resultSize).compareTo(o1.resultSize);
+               }
+       };
+
+       private static DateFormat DATE_TIME = SimpleDateFormat.getDateTimeInstance(
+                       DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.UK);
+
+       Services webService;
+       String clusterJobId;
+       String jobname;
+       long start;
+       long finish;
+       long inputSize;
+       long resultSize;
+       boolean isCollected;
+       boolean isCancelled;
+
+       private JobStat(Services webService, String clusterJobId, String jobname,
+                       long start, long finish, long inputSize, long resultSize,
+                       boolean isCancelled, boolean isCollected) {
+               super();
+               this.webService = webService;
+               this.clusterJobId = clusterJobId;
+               this.jobname = jobname;
+               this.start = start;
+               this.finish = finish;
+               this.inputSize = inputSize;
+               this.resultSize = resultSize;
+               this.isCancelled = isCancelled;
+               this.isCollected = isCollected;
+               validate();
+       }
+
+       public static JobStat newInstance(Services webService, String clusterJobId,
+                       String jobname, long start, long finish, long inputSize,
+                       long resultSize, boolean isCancelled, boolean isCollected) {
+               return new JobStat(webService, clusterJobId, jobname, start, finish,
+                               inputSize, resultSize, isCancelled, isCollected);
+       }
+
+       public static JobStat newInstance(Services webService, String clusterJobId,
+                       String jobname, Timestamp start, Timestamp finish, long inputSize,
+                       long resultSize, boolean isCancelled, boolean isCollected) {
+               long startm = ExecutionStatCollector.UNDEFINED;
+               long stopm = ExecutionStatCollector.UNDEFINED;
+               if (start != null) {
+                       startm = start.getTime();
+               }
+               if (finish != null) {
+                       stopm = finish.getTime();
+               }
+               return new JobStat(webService, clusterJobId, jobname, startm, stopm,
+                               inputSize, resultSize, isCancelled, isCollected);
+       }
+
+       void validate() {
+               if (webService == null) {
+                       throw new AssertionError("webService must be defined!:\n " + this);
+               }
+               if (Util.isEmpty(jobname)) {
+                       throw new AssertionError("jobname must be defined!:\n" + this);
+               }
+       }
+
+       private JobStat(String jobId) {
+               assert !Util.isEmpty(jobname);
+               this.jobname = jobId;
+       }
+
+       public static JobStat newIncompleteStat(String jobname) {
+               return new JobStat(jobname);
+       }
+
+       public boolean isClusterJob() {
+               return jobname.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX);
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((jobname == null) ? 0 : jobname.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               JobStat other = (JobStat) obj;
+               if (jobname == null) {
+                       if (other.jobname != null)
+                               return false;
+               } else if (!jobname.equals(other.jobname))
+                       return false;
+               return true;
+       }
+
+       public int getRuntime() {
+               if (start != ExecutionStatCollector.UNDEFINED && finish != ExecutionStatCollector.UNDEFINED) {
+                       return (int) (finish - start) / 1000;
+               }
+               return ExecutionStatCollector.UNDEFINED;
+       }
+
+       @Override
+       public String toString() {
+               return getJobReport();
+       }
+
+       String getJobReport() {
+               String report = "WS: " + webService + "\n";
+               report += "JOB: " + jobname + "\n";
+               if (start != ExecutionStatCollector.UNDEFINED) {
+                       report += "Started " + new Date(start) + "\n";
+               }
+               if (finish != ExecutionStatCollector.UNDEFINED) {
+                       report += "Finished " + new Date(finish) + "\n";
+               }
+               if (start != ExecutionStatCollector.UNDEFINED && finish != ExecutionStatCollector.UNDEFINED) {
+                       report += "Runtime " + getRuntime() + "\n";
+               }
+               report += "Input size " + inputSize + "\n";
+               report += "Result size " + resultSize + "\n";
+               report += "ClusterJobID " + clusterJobId + "\n";
+               report += "Collected? " + isCollected + "\n";
+               report += "Cancelled? " + isCancelled + "\n";
+               return report;
+       }
+
+       /**
+        * Header Job Started Finished Runtime Input Result
+        */
+       String getJobReportTabulated() {
+               String report = webService + "\t";
+               report += jobname + "\t";
+               if (start != ExecutionStatCollector.UNDEFINED) {
+                       report += ExecutionStatCollector.DF.format(new Date(start)) + "\t";
+               } else {
+                       report += ExecutionStatCollector.UNDEFINED + "\t";
+               }
+               if (finish != ExecutionStatCollector.UNDEFINED) {
+                       report += ExecutionStatCollector.DF.format(new Date(finish)) + "\t";
+               } else {
+                       report += ExecutionStatCollector.UNDEFINED + "\t";
+               }
+               if (start != ExecutionStatCollector.UNDEFINED && finish != ExecutionStatCollector.UNDEFINED) {
+                       report += getRuntime() + "\t";
+               } else {
+                       report += ExecutionStatCollector.UNDEFINED + "\t";
+               }
+               report += inputSize + "\t";
+               report += resultSize + "\t";
+               report += clusterJobId + "\t";
+               report += isCollected + "\t";
+               report += isCancelled + "\t";
+               return report;
+       }
+
+       public Services getWebService() {
+               return webService;
+       }
+
+       public String getClusterJobId() {
+               return clusterJobId;
+       }
+
+       public String getJobname() {
+               return jobname;
+       }
+
+       public String getEscJobname() {
+               String[] parts = jobname.split("#");
+               return parts[0] + "%23" + parts[1];
+       }
+
+       public String getStart() {
+               if (start != ExecutionStatCollector.UNDEFINED) {
+                       return DATE_TIME.format(new Date(start));
+               }
+               return "?";
+       }
+
+       public long getNumericalStart() {
+                       return start;
+       }
+
+       public long getNumericalFinish() {
+               return finish;
+       }
+
+       public String getFinish() {
+               if (finish != ExecutionStatCollector.UNDEFINED) {
+                       return DATE_TIME.format(new Date(finish));
+               }
+               return "?";
+       }
+
+       public long getInputSize() {
+               if (inputSize != ExecutionStatCollector.UNDEFINED) {
+                       return inputSize;
+               }
+               return 0;
+       }
+
+       public long getResultSize() {
+               if (resultSize > 0) {
+                       return resultSize;
+               }
+               return 0;
+       }
+
+       public boolean hasResult() {
+               return resultSize > 0;
+       }
+
+       public boolean hasStarted() {
+               return start != ExecutionStatCollector.UNDEFINED;
+       }
+
+       public boolean getIsCollected() {
+               return isCollected;
+       }
+
+       public boolean getIsCancelled() {
+               return isCancelled;
+       }
+
+       public boolean getIsFinished() {
+               return finish != ExecutionStatCollector.UNDEFINED;
+       }
+}
index b469c44..3af1b14 100644 (file)
@@ -52,22 +52,19 @@ public class StatDB {
 \r
        static Connection conn;\r
 \r
-       private synchronized static Connection getDBConnection()\r
-                       throws SQLException {\r
+       private synchronized static Connection getDBConnection() throws SQLException {\r
 \r
                if (conn != null && !conn.isClosed()) {\r
                        return conn;\r
                } else {\r
                        try {\r
                                String dbpath = PropertyHelperManager.getLocalPath();\r
-                               log.info("Looking for JABAWS access statistics database at: "\r
-                                               + dbpath);\r
+                               log.info("Looking for JABAWS access statistics database at: " + dbpath);\r
                                System.setProperty("derby.system.home", dbpath);\r
                                // Apparently under Tomcat webapp you cannot rely on Java\r
                                // auto discovery and have to register the driver explicitly\r
                                Class.forName(driver);\r
-                               conn = DriverManager.getConnection(protocol + statDBName\r
-                                               + ";create=false");\r
+                               conn = DriverManager.getConnection(protocol + statDBName + ";create=false");\r
 \r
                                conn.setAutoCommit(true);\r
                                /*\r
@@ -81,6 +78,7 @@ public class StatDB {
                }\r
                return conn;\r
        }\r
+\r
        public StatDB() throws SQLException {\r
                this.conn = getDBConnection();\r
        }\r
index f4a4708..c6eaf76 100644 (file)
@@ -32,8 +32,6 @@ import java.util.List;
 \r
 import javax.xml.ws.WebServiceException;\r
 \r
-import org.apache.log4j.Logger;\r
-\r
 import compbio.data.msa.JABAService;\r
 import compbio.data.msa.Metadata;\r
 import compbio.data.msa.MsaWS;\r
@@ -62,7 +60,6 @@ import compbio.util.Util;
  */\r
 public class WSTester {\r
 \r
-       private static Logger log = Logger.getLogger(WSTester.class);\r
        /**\r
         * Sequences to be used as input for all WS\r
         */\r
index 54f1daf..632ceeb 100644 (file)
@@ -33,7 +33,6 @@ import compbio.engine.conf.PropertyHelperManager;
 import compbio.engine.local.ExecutableWrapper;\r
 import compbio.engine.local.LocalExecutorService;\r
 import compbio.util.PropertyHelper;\r
-import compbio.util.Util;\r
 \r
 /**\r
  * Two tasks:\r
@@ -56,24 +55,26 @@ public class MainManager implements ServletContextListener {
        @Override\r
        public void contextDestroyed(ServletContextEvent ignored) {\r
                // stop cleaning job directories\r
-//             try {\r
+               try {\r
                        if (null != localcl) {\r
                                localcl.cancel(true);\r
                        }\r
                        if (null != clustercl) {\r
                                clustercl.cancel(true);\r
                        }\r
-                       //executor.shutdown();\r
-                       //executor.awaitTermination(3, TimeUnit.SECONDS);\r
-//             } catch (InterruptedException e) {\r
-//                     log.warn(e.getMessage(), e);\r
-//             }\r
-               // Shutdown local engine\r
-               log.info("JABAWS context is destroyed. Shutting down engines...");\r
-               LocalExecutorService.shutDown();\r
-               log.info("Local engine is shutdown OK");\r
-               ExecutableWrapper.shutdownService();\r
-               log.info("Individual executables stream engine is shutdown OK");\r
+                       executor.shutdown();\r
+                       executor.awaitTermination(3, TimeUnit.SECONDS);\r
+               } catch (InterruptedException e) {\r
+                       log.warn(e.getMessage(), e);\r
+               }\r
+\r
+                       // Shutdown local and cluster engines\r
+                       log.info("JABAWS context is destroyed. Shutting down engines...");\r
+                       LocalExecutorService.shutDown();\r
+                       log.info("Local engine is shutdown OK");\r
+                       ExecutableWrapper.shutdownService();\r
+                       log.info("Individual executables stream engine is shutdown OK");\r
+                       StatDB.shutdownDBServer();\r
        }\r
 \r
        @Override\r
@@ -88,7 +89,7 @@ public class MainManager implements ServletContextListener {
                boolean cleanClasterDir = PropertyHelperManager.getBooleanProperty(ph.getProperty("cluster.stat.collector.enable"));\r
                \r
                if (0 < clusterDirLifespan && cleanClasterDir) {\r
-                       DirCleaner clusterDirCleaner = new DirCleaner(  clusterWorkDir, clusterDirLifespan);\r
+                       DirCleaner clusterDirCleaner = new DirCleaner(clusterWorkDir, clusterDirLifespan);\r
                        clustercl = executor.scheduleAtFixedRate(clusterDirCleaner, 1, clusterCleaningRate, TimeUnit.MINUTES);\r
                        log.info("Cleaning local job directory every " + clusterCleaningRate + " minutes");\r
                } else {\r
@@ -102,7 +103,7 @@ public class MainManager implements ServletContextListener {
                boolean cleanLocalDir = PropertyHelperManager.getBooleanProperty(ph.getProperty("local.stat.collector.enable"));\r
 \r
                if (0 < localDirLiveSpan && cleanLocalDir) {\r
-                       DirCleaner localDirCleaner = new DirCleaner(    localWorkDir, localDirLiveSpan);\r
+                       DirCleaner localDirCleaner = new DirCleaner(localWorkDir, localDirLiveSpan);\r
                        localcl = executor.scheduleAtFixedRate(localDirCleaner, 1, localCleaningRate, TimeUnit.MINUTES);\r
                        log.info("Cleaning local job directory every " + localCleaningRate + " minutes");\r
                } else {\r
index dea7cbe..a04e547 100644 (file)
@@ -58,11 +58,10 @@ public class SetExecutableFlag implements ServletContextListener {
                // Run only one once if not on Windows\r
                if (!SysPrefs.isWindows && !isExec) {\r
 \r
-                       // verify script exist\r
+                       // verify script exists\r
                        File scriptFile = new File(workDir, script);\r
                        if (!scriptFile.exists()) {\r
-                               log.debug("Setexecflag.sh script is NOT found in "\r
-                                               + scriptFile.getAbsolutePath());\r
+                               log.debug("Setexecflag.sh script is NOT found in " + scriptFile.getAbsolutePath());\r
                                return;\r
                        } else {\r
                                scriptFile.setExecutable(true);\r