From: Sasha Sherstnev Date: Mon, 29 Jul 2013 12:58:12 +0000 (+0100) Subject: merge JABAWS_Release_2_1 into develop X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=00a2b15acef8866a404db64381d7dfeb93bf7ad9;hp=99c8e29207a787fd85c22cb05ff89271b8097091;p=jabaws.git merge JABAWS_Release_2_1 into develop --- diff --git a/.classpath b/.classpath index 2d206e3..261bdb3 100644 --- a/.classpath +++ b/.classpath @@ -13,7 +13,7 @@ - + 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 index 0000000..7c8126d --- /dev/null +++ b/.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs @@ -0,0 +1,5 @@ +XDOCLETBUILDERACTIVE=true +XDOCLETHOME= +XDOCLETUSEGLOBAL=true +XDOCLETVERSION=1.2.1 +eclipse.preferences.version=1 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index f062064..f33c768 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -2,11 +2,11 @@ - - - - - + + + + + diff --git a/WEB-INF/lib/derby.jar b/WEB-INF/lib/derby-10.8.2.2.jar 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 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 index f1567cc..0000000 --- a/conf/log4j.properties +++ /dev/null @@ -1,75 +0,0 @@ - -## CHANGE THIS (The root directory where to store all the log files) -#logDir = . - -## Uncomment to enable JWS2 activity logging to standard out (to the console if available) -## for possible log levels please refer to Log4j documentation http://logging.apache.org/log4j/1.2/manual.html -## Valid log levels are: -## TRACE - log everything from below including very detailed messages (useful for debugging only) -## DEBUG - log everything from below including some minor events (useful for debugging only) -## INFO - log everything from below including some information messages -## WARN - log error and warnings -## ERROR - log errors and fatal events only -## FATAL - log fatal events only - -## Uncomment this if you would like the system to log messages into stdout -#log4j.rootLogger=TRACE, rootfile -#log4j.appender.rootfile=org.apache.log4j.RollingFileAppender -#log4j.appender.rootfile.File=JABAWSLogFilename.log -#log4j.appender.rootfile.Target=System.out -#log4j.appender.rootfile.layout=org.apache.log4j.PatternLayout -#log4j.appender.rootfile.layout.ConversionPattern=%t %d %m%n - -## Uncomment to enable JWS2 activity logging to the file -#log4j.logger.compbio=TRACE, ACTIVITY -#log4j.appender.ACTIVITY=org.apache.log4j.RollingFileAppender -################log4j.appender.ACTIVITY.File=${logDir}/activity.log -#log4j.appender.ACTIVITY.File=${catalina.base}/logs/JABAWSLogFilename.log -#log4j.appender.ACTIVITY.MaxFileSize=10MB -#log4j.appender.ACTIVITY.MaxBackupIndex=10000 -#log4j.appender.ACTIVITY.layout=org.apache.log4j.PatternLayout -#log4j.appender.ACTIVITY.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %-5p %3x - %m%n - -## Uncomment for separate local engine execution log (debugging only) -#log4j.logger.compbio.engine.local.LocalExecutorService=INFO, C -#log4j.appender.C=org.apache.log4j.FileAppender -#log4j.appender.C.File=LocalExecutorService.log -#log4j.appender.C.layout=org.apache.log4j.PatternLayout -#log4j.appender.C.layout.ConversionPattern=%m%n - -################################################################################################################################## -# log4j.properties from runner/ - -#log4j.appender.stdout=org.apache.log4j.ConsoleAppender -#log4j.appender.stdout.Target=System.out -#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -#log4j.appender.stdout.layout.ConversionPattern=%m%n -#log4j.rootLogger=info, stdout - -log4j.rootLogger=TRACE, rootfile -log4j.appender.rootfile=org.apache.log4j.FileAppender -log4j.appender.rootfile.File=${catalina.base}/logs/JABAWSLogFilename.log1 -log4j.appender.rootfile.Target=System.out -log4j.appender.rootfile.layout=org.apache.log4j.PatternLayout -log4j.appender.rootfile.layout.ConversionPattern=%t %d %m%n - -# %d{ABSOLUTE} %5p %c{1}:%L - -log4j.logger.compbio=TRACE, B -log4j.appender.B=org.apache.log4j.FileAppender -#log4j.appender.B.File=engine.log -log4j.appender.B.File=${catalina.base}/logs/engine.log -log4j.appender.B.layout=org.apache.log4j.PatternLayout -log4j.appender.B.layout.ConversionPattern=%m%n %d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - - -# %d{ABSOLUTE} %5p %c{1}:%L - -#log4j.logger.compbio.engine.local.LocalExecutorService=INFO, C -#log4j.appender.C=org.apache.log4j.FileAppender -#log4j.appender.C.File=LocalExecutorService.log -#log4j.appender.C.layout=org.apache.log4j.PatternLayout -#log4j.appender.C.layout.ConversionPattern=%m%n -# %d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - - -#log4j.logger.RunnerLogger=ERROR, D -#log4j.appender.D=org.apache.log4j.ConsoleAppender -#log4j.appender.D.layout=org.apache.log4j.PatternLayout -#log4j.appender.D.layout.ConversionPattern=%r [%t] %p %c %x - %m%n diff --git a/conf/settings/AAConParameters.xml b/conf/settings/AAConParameters.xml index 6ebcad4..bdc1ef7 100644 --- a/conf/settings/AAConParameters.xml +++ b/conf/settings/AAConParameters.xml @@ -55,7 +55,7 @@ prog_docs/aacon.txt MID_SCORE MAX_SCORE - MID_SCORE + MID_SCORE diff --git a/engine/compbio/engine/local/ExecutableWrapper.java b/engine/compbio/engine/local/ExecutableWrapper.java index 597af4e..9e652f9 100644 --- a/engine/compbio/engine/local/ExecutableWrapper.java +++ b/engine/compbio/engine/local/ExecutableWrapper.java @@ -75,17 +75,14 @@ public final class ExecutableWrapper implements pbuilder = new ProcessBuilder(params); if (executable.getEnvironment() != null) { - log.debug("Setting command environment variables: " - + pbuilder.environment()); - Util.mergeEnvVariables(pbuilder.environment(), executable - .getEnvironment()); + log.debug("Setting command environment variables: " + pbuilder.environment()); + Util.mergeEnvVariables(pbuilder.environment(), executable.getEnvironment()); log.debug("Process environment:" + pbuilder.environment()); } log.debug("Setting command: " + pbuilder.command()); PathValidator.validateDirectory(workDirectory); pbuilder.directory(new File(workDirectory)); - log.debug("Current working directory is " - + SysPrefs.getCurrentDirectory()); + log.debug("Current working directory is " + SysPrefs.getCurrentDirectory()); log.debug("Setting working directory: " + workDirectory); // Initialize private executor to dump processes output if any to the // file system @@ -98,8 +95,7 @@ public final class ExecutableWrapper implements // get access to the thread efficiently deadlocking the // proccess! this.es = Executors.newCachedThreadPool(); - log - .debug("Initializing executor for local processes output dump"); + log.debug("Initializing executor for local processes output dump"); // Make sure that the executors are going to be properly closed Runtime.getRuntime().addShutdownHook(new Thread() { @Override @@ -119,7 +115,7 @@ public final class ExecutableWrapper implements */ public static final void shutdownService() { if (es != null) { - es.shutdownNow(); + es.shutdownNow(); } } diff --git a/log/log4j.properties b/log/log4j.properties index fc6e3a9..07df1cc 100644 --- a/log/log4j.properties +++ b/log/log4j.properties @@ -46,15 +46,14 @@ #log4j.appender.stdout.layout.ConversionPattern=%m%n #log4j.rootLogger=info, stdout -log4j.rootLogger=ERROR, errorfile -log4j.appender.errorfile=org.apache.log4j.FileAppender -log4j.appender.errorfile.File=${catalina.base}/logs/JABAWSErrorFile.log -log4j.appender.errorfile.Target=System.out -log4j.appender.errorfile.layout=org.apache.log4j.PatternLayout -log4j.appender.errorfile.layout.ConversionPattern=%t %d %m%n +log4j.rootLogger=ERROR, R +log4j.appender.R=org.apache.log4j.FileAppender +log4j.appender.R.File=${catalina.base}/logs/JABAWSErrorFile.log +log4j.appender.R.layout=org.apache.log4j.PatternLayout +log4j.appender.R.layout.ConversionPattern=%m%n %d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - # %d{ABSOLUTE} %5p %c{1}:%L - -log4j.logger.compbio=TRACE, B +log4j.logger.compbio=WARN, B log4j.appender.B=org.apache.log4j.FileAppender log4j.appender.B.File=${catalina.base}/logs/engine.log log4j.appender.B.layout=org.apache.log4j.PatternLayout diff --git a/statpages/ServicesStatus.jsp b/statpages/ServicesStatus.jsp index 533f172..b9c4fb2 100644 --- a/statpages/ServicesStatus.jsp +++ b/statpages/ServicesStatus.jsp @@ -17,7 +17,9 @@ TODO refactor

JABAWS Services Status

-

Server: ${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}

+

Server: + +${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}


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.

@@ -74,4 +76,4 @@ the HTTP code response service checker. It responds with HTTP status code depend of the web service. For more information please refer to Testing JABAWS server help page.

- \ No newline at end of file + diff --git a/testsrc/compbio/ws/client/TestAAConWS.java b/testsrc/compbio/ws/client/TestAAConWS.java index 19cd0b2..d54e67f 100644 --- a/testsrc/compbio/ws/client/TestAAConWS.java +++ b/testsrc/compbio/ws/client/TestAAConWS.java @@ -3,12 +3,13 @@ package compbio.ws.client; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.fail; - +import static org.testng.Assert.assertTrue; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.net.ConnectException; +import java.util.ArrayList; import java.util.List; import javax.xml.ws.WebServiceException; @@ -25,6 +26,8 @@ import compbio.data.sequence.SequenceUtil; import compbio.metadata.AllTestSuit; import compbio.metadata.JobSubmissionException; import compbio.metadata.LimitExceededException; +import compbio.metadata.Option; +import compbio.metadata.Preset; import compbio.metadata.PresetManager; import compbio.metadata.ResultNotAvailableException; import compbio.metadata.RunnerConfig; @@ -135,6 +138,16 @@ public class TestAAConWS { } @Test(groups = {AllTestSuit.test_group_webservices}) + public void testRecoverArgsForPreset() throws Exception { + PresetManager presets = msaws.getPresets(); + for (Preset preset:presets.getPresets()) + { + List> args = preset.getArguments(msaws.getRunnerOptions()); + List opts = preset.getOptions(); + assertTrue(args.size()>=opts.size(),"Couldn't recover all Option items for preset "+preset.getName()); + } + } + @Test(groups = {AllTestSuit.test_group_webservices}) public void testPresetAnalize() throws FileNotFoundException, IOException { String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() @@ -201,21 +214,23 @@ public class TestAAConWS { // System.out.println(options.getArguments()); try { - options.getArgument("Calculation method").setDefaultValue("SMERFS"); + List> args = new ArrayList>(); + Option arg,normarg; + args.add(arg=options.getArgument("SMERFS")); + args.add(normarg=options.getArgument("Normalize")); + arg.setValue(arg.getPossibleValues().get(0)); // options.getArgument("SMERFS Column Scoring Method") // .setDefaultValue("MAX_SCORE"); // options.getArgument("SMERFS Gap Threshhold").setDefaultValue("1"); - String jobId = msaws.customAnalize(fsl, options.getArguments()); + String jobId = msaws.customAnalize(fsl, args); ScoreManager result = msaws.getAnnotation(jobId); assertNotNull(result); assertEquals(result.asSet().size(), 1); assertEquals(result.asSet().iterator().next().getScores().get(0), 0.698f); - - options.getArgument("Calculation method").setDefaultValue("SMERFS"); - options.removeArgument("Normalize"); - System.out.println(options); - jobId = msaws.customAnalize(fsl, options.getArguments()); + args.remove(normarg); // remove normalization argument + // System.out.println(options); + jobId = msaws.customAnalize(fsl, args); result = msaws.getAnnotation(jobId); assertNotNull(result); assertEquals(result.asSet().size(), 1); diff --git a/webservices/compbio/stat/collector/JobStat.java b/webservices/compbio/stat/collector/JobStat.java index 72c7ae1..2ad48ff 100644 --- a/webservices/compbio/stat/collector/JobStat.java +++ b/webservices/compbio/stat/collector/JobStat.java @@ -1,281 +1,285 @@ -/* 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 RUNTIME = new Comparator() { - @Override - public int compare(JobStat o1, JobStat o2) { - return new Integer(o2.getRuntime()).compareTo(o1.getRuntime()); - } - }; - - static final Comparator STARTTIME = new Comparator() { - @Override - public int compare(JobStat o1, JobStat o2) { - return new Long(o1.start).compareTo(o2.start); - } - }; - - static final Comparator RESULTSIZE = new Comparator() { - @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(); - } - - 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); - } - - 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; - } - - 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 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; - } - -} \ 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 RUNTIME = new Comparator() { + @Override + public int compare(JobStat o1, JobStat o2) { + return new Integer(o2.getRuntime()).compareTo(o1.getRuntime()); + } + }; + + static final Comparator STARTTIME = new Comparator() { + @Override + public int compare(JobStat o1, JobStat o2) { + return new Long(o1.start).compareTo(o2.start); + } + }; + + static final Comparator RESULTSIZE = new Comparator() { + @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; + } +} diff --git a/webservices/compbio/stat/collector/StatDB.java b/webservices/compbio/stat/collector/StatDB.java index b469c44..3af1b14 100644 --- a/webservices/compbio/stat/collector/StatDB.java +++ b/webservices/compbio/stat/collector/StatDB.java @@ -52,22 +52,19 @@ public class StatDB { static Connection conn; - private synchronized static Connection getDBConnection() - throws SQLException { + private synchronized static Connection getDBConnection() throws SQLException { if (conn != null && !conn.isClosed()) { return conn; } else { try { String dbpath = PropertyHelperManager.getLocalPath(); - log.info("Looking for JABAWS access statistics database at: " - + dbpath); + log.info("Looking for JABAWS access statistics database at: " + dbpath); System.setProperty("derby.system.home", dbpath); // Apparently under Tomcat webapp you cannot rely on Java // auto discovery and have to register the driver explicitly Class.forName(driver); - conn = DriverManager.getConnection(protocol + statDBName - + ";create=false"); + conn = DriverManager.getConnection(protocol + statDBName + ";create=false"); conn.setAutoCommit(true); /* @@ -81,6 +78,7 @@ public class StatDB { } return conn; } + public StatDB() throws SQLException { this.conn = getDBConnection(); } diff --git a/webservices/compbio/ws/client/WSTester.java b/webservices/compbio/ws/client/WSTester.java index f4a4708..c6eaf76 100644 --- a/webservices/compbio/ws/client/WSTester.java +++ b/webservices/compbio/ws/client/WSTester.java @@ -32,8 +32,6 @@ import java.util.List; import javax.xml.ws.WebServiceException; -import org.apache.log4j.Logger; - import compbio.data.msa.JABAService; import compbio.data.msa.Metadata; import compbio.data.msa.MsaWS; @@ -62,7 +60,6 @@ import compbio.util.Util; */ public class WSTester { - private static Logger log = Logger.getLogger(WSTester.class); /** * Sequences to be used as input for all WS */ diff --git a/webservices/compbio/ws/server/MainManager.java b/webservices/compbio/ws/server/MainManager.java index 54f1daf..632ceeb 100644 --- a/webservices/compbio/ws/server/MainManager.java +++ b/webservices/compbio/ws/server/MainManager.java @@ -33,7 +33,6 @@ import compbio.engine.conf.PropertyHelperManager; import compbio.engine.local.ExecutableWrapper; import compbio.engine.local.LocalExecutorService; import compbio.util.PropertyHelper; -import compbio.util.Util; /** * Two tasks: @@ -56,24 +55,26 @@ public class MainManager implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent ignored) { // stop cleaning job directories -// try { + try { if (null != localcl) { localcl.cancel(true); } if (null != clustercl) { clustercl.cancel(true); } - //executor.shutdown(); - //executor.awaitTermination(3, TimeUnit.SECONDS); -// } catch (InterruptedException e) { -// log.warn(e.getMessage(), e); -// } - // Shutdown local engine - log.info("JABAWS context is destroyed. Shutting down engines..."); - LocalExecutorService.shutDown(); - log.info("Local engine is shutdown OK"); - ExecutableWrapper.shutdownService(); - log.info("Individual executables stream engine is shutdown OK"); + executor.shutdown(); + executor.awaitTermination(3, TimeUnit.SECONDS); + } catch (InterruptedException e) { + log.warn(e.getMessage(), e); + } + + // Shutdown local and cluster engines + log.info("JABAWS context is destroyed. Shutting down engines..."); + LocalExecutorService.shutDown(); + log.info("Local engine is shutdown OK"); + ExecutableWrapper.shutdownService(); + log.info("Individual executables stream engine is shutdown OK"); + StatDB.shutdownDBServer(); } @Override @@ -88,7 +89,7 @@ public class MainManager implements ServletContextListener { boolean cleanClasterDir = PropertyHelperManager.getBooleanProperty(ph.getProperty("cluster.stat.collector.enable")); if (0 < clusterDirLifespan && cleanClasterDir) { - DirCleaner clusterDirCleaner = new DirCleaner( clusterWorkDir, clusterDirLifespan); + DirCleaner clusterDirCleaner = new DirCleaner(clusterWorkDir, clusterDirLifespan); clustercl = executor.scheduleAtFixedRate(clusterDirCleaner, 1, clusterCleaningRate, TimeUnit.MINUTES); log.info("Cleaning local job directory every " + clusterCleaningRate + " minutes"); } else { @@ -102,7 +103,7 @@ public class MainManager implements ServletContextListener { boolean cleanLocalDir = PropertyHelperManager.getBooleanProperty(ph.getProperty("local.stat.collector.enable")); if (0 < localDirLiveSpan && cleanLocalDir) { - DirCleaner localDirCleaner = new DirCleaner( localWorkDir, localDirLiveSpan); + DirCleaner localDirCleaner = new DirCleaner(localWorkDir, localDirLiveSpan); localcl = executor.scheduleAtFixedRate(localDirCleaner, 1, localCleaningRate, TimeUnit.MINUTES); log.info("Cleaning local job directory every " + localCleaningRate + " minutes"); } else { diff --git a/webservices/compbio/ws/server/SetExecutableFlag.java b/webservices/compbio/ws/server/SetExecutableFlag.java index dea7cbe..a04e547 100644 --- a/webservices/compbio/ws/server/SetExecutableFlag.java +++ b/webservices/compbio/ws/server/SetExecutableFlag.java @@ -58,11 +58,10 @@ public class SetExecutableFlag implements ServletContextListener { // Run only one once if not on Windows if (!SysPrefs.isWindows && !isExec) { - // verify script exist + // verify script exists File scriptFile = new File(workDir, script); if (!scriptFile.exists()) { - log.debug("Setexecflag.sh script is NOT found in " - + scriptFile.getAbsolutePath()); + log.debug("Setexecflag.sh script is NOT found in " + scriptFile.getAbsolutePath()); return; } else { scriptFile.setExecutable(true);