From: pvtroshin Date: Thu, 22 Jul 2010 12:59:22 +0000 (+0000) Subject: Some refactoring X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c2c54b1cab5af0ac2604539a768174f5987fedf9;p=jabaws.git Some refactoring git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@2651 e3abac25-378b-4346-85de-24260fe3988d --- diff --git a/engine/compbio/engine/client/SkeletalExecutable.java b/engine/compbio/engine/client/SkeletalExecutable.java index adc3e0b..dbdb4f5 100644 --- a/engine/compbio/engine/client/SkeletalExecutable.java +++ b/engine/compbio/engine/client/SkeletalExecutable.java @@ -19,6 +19,7 @@ package compbio.engine.client; import java.io.File; +import java.security.InvalidParameterException; import java.util.Arrays; import java.util.List; @@ -258,6 +259,35 @@ public abstract class SkeletalExecutable implements Executable { return settings == null ? "" : settings; } + /** + * + * @return number of cpus to use on the cluster or 0 if the value is + * undefined + */ + public static int getClusterCpuNum(Class> type) { + int cpus = 0; + String cpuNum = ph.getProperty(type.getSimpleName().toLowerCase()+ ".cluster.cpunum"); + if (compbio.util.Util.isEmpty(cpuNum)) { + return 0; + } + try { + cpus = Integer.parseInt(cpuNum); + } catch (NumberFormatException e) { + // safe to ignore + log + .debug("Number of cpus to use for cluster execution is defined but could not be parsed as integer! Given value is: " + + cpuNum); + return 0; + } + if (cpus < 1 || cpus > 100) { + throw new InvalidParameterException( + "Number of cpu for cluster execution must be within 1 and 100! " + + "Look at the value of 'tcoffee.cluster.cpunum' property. Given value is " + + cpus); + } + return cpus; + } + public abstract Class> getType(); } diff --git a/runner/compbio/runner/disorder/Jronn.java b/runner/compbio/runner/disorder/Jronn.java index 1b9037e..0bf17e4 100644 --- a/runner/compbio/runner/disorder/Jronn.java +++ b/runner/compbio/runner/disorder/Jronn.java @@ -23,6 +23,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.security.InvalidParameterException; import java.util.Arrays; import java.util.List; @@ -48,8 +49,18 @@ import compbio.runner.Util; */ public class Jronn extends SkeletalExecutable { + private static Logger log = Logger.getLogger(Jronn.class); + /** + * Number of cores to use, defaults to 1 for local execution or the value of + * "jronn.cluster.cpunum" property for cluster execution + */ + private int ncoreNumber = 0; + + private String ncorePrm = "-n"; + + // Cache for Limits information private static LimitsManager limits; @@ -57,7 +68,7 @@ public class Jronn extends SkeletalExecutable { public static final String STAT_FILE = "stat.txt"; public Jronn() { - addParameters(Arrays.asList("-jar", getLibPath(), "-n=1", "-s=" + addParameters(Arrays.asList("-jar", getLibPath(), "-s=" + STAT_FILE, "-f=H")); } @@ -161,4 +172,19 @@ public class Jronn extends SkeletalExecutable { public static String getStatFile() { return STAT_FILE; } + + public void setNCore(int ncoreNumber) { + if (ncoreNumber < 1 || ncoreNumber > 100) { + throw new IndexOutOfBoundsException( + "Number of cores must be within 1 and 100 "); + } + this.ncoreNumber = ncoreNumber; + cbuilder.setParam(ncorePrm, Integer.toString(getNCore())); + } + + int getNCore() { + return ncoreNumber; + } + + } diff --git a/runner/compbio/runner/msa/Tcoffee.java b/runner/compbio/runner/msa/Tcoffee.java index 2fd2283..949c4f1 100644 --- a/runner/compbio/runner/msa/Tcoffee.java +++ b/runner/compbio/runner/msa/Tcoffee.java @@ -41,173 +41,145 @@ import compbio.runner.Util; import compbio.util.PropertyHelper; public class Tcoffee extends SkeletalExecutable implements - PipedExecutable, ClusterNativeSpecExecutable { +PipedExecutable, ClusterNativeSpecExecutable { - private static Logger log = Logger.getLogger(Tcoffee.class); + private static Logger log = Logger.getLogger(Tcoffee.class); - private static PropertyHelper ph = PropertyHelperManager - .getPropertyHelper(); + private static PropertyHelper ph = PropertyHelperManager + .getPropertyHelper(); - // Cache for Limits information - private static LimitsManager limits; + // Cache for Limits information + private static LimitsManager limits; - public static final String KEY_VALUE_SEPARATOR = "="; + public static final String KEY_VALUE_SEPARATOR = "="; - /** - * Number of cores to use, defaults to 1 for local execution or the value of - * "tcoffee.cluster.cpunum" property for cluster execution - */ - private int ncoreNumber = 0; - - /* - * Number of cores parameter name - */ - private final static String ncorePrm = "-n_core"; + /** + * Number of cores to use, defaults to 1 for local execution or the value of + * "tcoffee.cluster.cpunum" property for cluster execution + */ + private int ncoreNumber = 0; - /** - * - * @param workDirectory - */ - public Tcoffee() { - super(KEY_VALUE_SEPARATOR); /* - * Use "-quiet" to disable sdtout and progress to stderr inorder=input - - * prevent t-coffee from sorting sequences + * Number of cores parameter name */ - addParameters(Arrays.asList("-output=clustalw")); - setInput(super.inputFile); - } - - @Override - public Tcoffee setInput(String inFile) { - super.setInput(inFile); - cbuilder.setParam("-seq", inFile); - return this; - } - - @SuppressWarnings("unchecked") - @Override - public Alignment getResults(String workDirectory) - throws ResultNotAvailableException { - try { - return Util.readClustalFile(workDirectory, getOutput()); - } catch (FileNotFoundException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } catch (IOException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } catch (UnknownFileFormatException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } catch (NullPointerException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } - } - - @Override - public List getCreatedFiles() { - return Arrays.asList(getOutput()); - } + private final static String ncorePrm = "-n_core"; - public void setNCore(int ncoreNumber) { - if (ncoreNumber < 1 || ncoreNumber > 100) { - throw new IndexOutOfBoundsException( - "Number of cores must be within 1 and 100 "); + /** + * + * @param workDirectory + */ + public Tcoffee() { + super(KEY_VALUE_SEPARATOR); + /* + * Use "-quiet" to disable sdtout and progress to stderr inorder=input - + * prevent t-coffee from sorting sequences + */ + addParameters(Arrays.asList("-output=clustalw")); + setInput(super.inputFile); } - this.ncoreNumber = ncoreNumber; - cbuilder.setParam(ncorePrm, Integer.toString(getNCore())); - } - - int getNCore() { - return ncoreNumber; - } - - @Override - public CommandBuilder getParameters(ExecProvider provider) { - // Limit number of cores to 1 for ANY execution which does not set - // Ncores explicitly using setNCore method - if (ncoreNumber == 0) { - setNCore(1); + + @Override + public Tcoffee setInput(String inFile) { + super.setInput(inFile); + cbuilder.setParam("-seq", inFile); + return this; } - if (provider == Executable.ExecProvider.Cluster) { - int cpunum = getClusterCpuNum(); - if (cpunum != 0) { - setNCore(cpunum); - } + + @SuppressWarnings("unchecked") + @Override + public Alignment getResults(String workDirectory) + throws ResultNotAvailableException { + try { + return Util.readClustalFile(workDirectory, getOutput()); + } catch (FileNotFoundException e) { + log.error(e.getMessage(), e.getCause()); + throw new ResultNotAvailableException(e); + } catch (IOException e) { + log.error(e.getMessage(), e.getCause()); + throw new ResultNotAvailableException(e); + } catch (UnknownFileFormatException e) { + log.error(e.getMessage(), e.getCause()); + throw new ResultNotAvailableException(e); + } catch (NullPointerException e) { + log.error(e.getMessage(), e.getCause()); + throw new ResultNotAvailableException(e); + } } - return super.getParameters(provider); - } - @Override - public Limit getLimit(String presetName) { - if (limits == null) { - limits = getLimits(); + @Override + public List getCreatedFiles() { + return Arrays.asList(getOutput()); } - Limit limit = null; - if (limits != null) { - // this returns default limit if preset is undefined! - limit = limits.getLimitByName(presetName); + public void setNCore(int ncoreNumber) { + if (ncoreNumber < 1 || ncoreNumber > 100) { + throw new IndexOutOfBoundsException( + "Number of cores must be within 1 and 100 "); + } + this.ncoreNumber = ncoreNumber; + cbuilder.setParam(ncorePrm, Integer.toString(getNCore())); } - // If limit is not defined for a particular preset, then return default - // limit - if (limit == null) { - log.debug("Limit for the preset " + presetName - + " is not found. Using default"); - limit = limits.getDefaultLimit(); + + int getNCore() { + return ncoreNumber; } - return limit; - } - - @Override - public LimitsManager getLimits() { - // synchronise on static field - synchronized (log) { - if (limits == null) { - limits = Util.getLimits(this.getClass()); - } + + @Override + public CommandBuilder getParameters(ExecProvider provider) { + // Limit number of cores to 1 for ANY execution which does not set + // Ncores explicitly using setNCore method + if (ncoreNumber == 0) { + setNCore(1); + } + if (provider == Executable.ExecProvider.Cluster) { + int cpunum = SkeletalExecutable.getClusterCpuNum(getType()); + if (cpunum != 0) { + setNCore(cpunum); + } + } + return super.getParameters(provider); } - return limits; - } - - @Override - public String getNativeSpecs() { - return getClusterSettings(); - } - - /** - * - * @return number of cpus to use on the cluster or 0 if the value is - * undefined - */ - public static int getClusterCpuNum() { - int cpus = 0; - String cpuNum = ph.getProperty("tcoffee.cluster.cpunum"); - if (compbio.util.Util.isEmpty(cpuNum)) { - return 0; + + @Override + public Limit getLimit(String presetName) { + if (limits == null) { + limits = getLimits(); + } + + Limit limit = null; + if (limits != null) { + // this returns default limit if preset is undefined! + limit = limits.getLimitByName(presetName); + } + // If limit is not defined for a particular preset, then return default + // limit + if (limit == null) { + log.debug("Limit for the preset " + presetName + + " is not found. Using default"); + limit = limits.getDefaultLimit(); + } + return limit; } - try { - cpus = Integer.parseInt(cpuNum); - } catch (NumberFormatException e) { - // safe to ignore - log - .debug("Number of cpus to use for cluster execution is defined but could not be parsed as integer! Given value is: " - + cpuNum); - return 0; + + @Override + public LimitsManager getLimits() { + // synchronise on static field + synchronized (log) { + if (limits == null) { + limits = Util.getLimits(this.getClass()); + } + } + return limits; } - if (cpus < 1 || cpus > 100) { - throw new InvalidParameterException( - "Number of cpu for cluster execution must be within 1 and 100! " - + "Look at the value of 'tcoffee.cluster.cpunum' property. Given value is " - + cpus); + + @Override + public String getNativeSpecs() { + return getClusterSettings(); } - return cpus; - } - @Override - public Class> getType() { - return this.getClass(); - } + + @Override + public Class> getType() { + return this.getClass(); + } } diff --git a/testsrc/compbio/runner/disorder/JronnTester.java b/testsrc/compbio/runner/disorder/JronnTester.java index 0193781..9385eb6 100644 --- a/testsrc/compbio/runner/disorder/JronnTester.java +++ b/testsrc/compbio/runner/disorder/JronnTester.java @@ -66,291 +66,315 @@ import compbio.util.SysPrefs; public class JronnTester { - public static String test_outfile = "TO1381.jronn.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out + public static String test_outfile = "TO1381.jronn.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out - private Jronn jronn; + private Jronn jronn; - @BeforeMethod(alwaysRun = true) - void init() { - jronn = new Jronn(); - jronn.setInput(AllTestSuit.test_input).setOutput(test_outfile); - } + @BeforeMethod(alwaysRun = true) + void init() { + jronn = new Jronn(); + jronn.setInput(AllTestSuit.test_input).setOutput(test_outfile); + } - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner }) - public void testRunOnCluster() { - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); - try { - ConfiguredExecutable confJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Cluster); - JobRunner runner = JobRunner.getInstance(confJronn); - - assertNotNull(runner, "Runner is NULL"); - runner.executeJob(); - // assertNotNull("JobId is null", jobId1); - JobStatus status = runner.getJobStatus(); - assertTrue(status == JobStatus.PENDING - || status == JobStatus.RUNNING, - "Status of the process is wrong!"); - JobInfo info = runner.getJobInfo(); - assertNotNull(info, "JobInfo is null"); - StatisticManager sm = new StatisticManager(info); - assertNotNull(sm, "Statictic manager is null"); - try { - - String exits = sm.getExitStatus(); - assertNotNull("Exit status is null", exits); - // cut 4 trailing zeros from the number - int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits) - .intValue(); - assertEquals(0, exitsInt); - System.out.println(sm.getAllStats()); - - } catch (ParseException e) { - e.printStackTrace(); - fail("Parse Exception: " + e.getMessage()); - } - //assertFalse(runner.cleanup()); - assertTrue(sm.hasExited()); - assertFalse(sm.wasAborted()); - assertFalse(sm.hasDump()); - assertFalse(sm.hasSignaled()); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (DrmaaException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); + @Test(groups = { AllTestSuit.test_group_cluster, + AllTestSuit.test_group_runner }) + public void testRunOnCluster() { + assertFalse(SysPrefs.isWindows, + "Cluster execution can only be in unix environment"); + try { + ConfiguredExecutable confJronn = Configurator + .configureExecutable(jronn, Executable.ExecProvider.Cluster); + JobRunner runner = JobRunner.getInstance(confJronn); + + assertNotNull(runner, "Runner is NULL"); + runner.executeJob(); + // assertNotNull("JobId is null", jobId1); + JobStatus status = runner.getJobStatus(); + assertTrue(status == JobStatus.PENDING + || status == JobStatus.RUNNING, + "Status of the process is wrong!"); + JobInfo info = runner.getJobInfo(); + assertNotNull(info, "JobInfo is null"); + StatisticManager sm = new StatisticManager(info); + assertNotNull(sm, "Statictic manager is null"); + try { + + String exits = sm.getExitStatus(); + assertNotNull("Exit status is null", exits); + // cut 4 trailing zeros from the number + int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits) + .intValue(); + assertEquals(0, exitsInt); + System.out.println(sm.getAllStats()); + + } catch (ParseException e) { + e.printStackTrace(); + fail("Parse Exception: " + e.getMessage()); + } + //assertFalse(runner.cleanup()); + assertTrue(sm.hasExited()); + assertFalse(sm.wasAborted()); + assertFalse(sm.hasDump()); + assertFalse(sm.hasSignaled()); + + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail("DrmaaException caught:" + e.getMessage()); + } catch (JobExecutionException e) { + e.printStackTrace(); + fail("DrmaaException caught:" + e.getMessage()); + } catch (DrmaaException e) { + e.printStackTrace(); + fail("DrmaaException caught:" + e.getMessage()); + } } - } - - /** - * This tests fails from time to time depending on the cluster load or some - * other factors. Any client code has to adjust for this issue - */ - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner }) - public void testRunOnClusterAsync() { - assertFalse(SysPrefs.isWindows, + + /** + * This tests fails from time to time depending on the cluster load or some + * other factors. Any client code has to adjust for this issue + */ + @Test(groups = { AllTestSuit.test_group_cluster, + AllTestSuit.test_group_runner }) + public void testRunOnClusterAsync() { + assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); - try { - ConfiguredExecutable confJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confJronn); - String jobId = aengine.submitJob(confJronn); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - System.out.println("Job Status: " + status); - Thread.sleep(1000); - status = aengine.getJobStatus(jobId); - ConfiguredExecutable result = (ConfiguredExecutable) aengine - .getResults(jobId); - assertNotNull(result); - System.out.println("RES:" + result); - // Some times the job could be removed from the cluster accounting - // before it has been reported to finish. Make sure - // to stop waiting in such case - if (status == JobStatus.UNDEFINED) { - break; + try { + ConfiguredExecutable confJronn = Configurator + .configureExecutable(jronn, Executable.ExecProvider.Cluster); + AsyncExecutor aengine = Configurator.getAsyncEngine(confJronn); + String jobId = aengine.submitJob(confJronn); + assertNotNull(jobId, "Runner is NULL"); + // let drmaa to start + Thread.sleep(500); + JobStatus status = aengine.getJobStatus(jobId); + while (status != JobStatus.FINISHED) { + System.out.println("Job Status: " + status); + Thread.sleep(1000); + status = aengine.getJobStatus(jobId); + ConfiguredExecutable result = (ConfiguredExecutable) aengine + .getResults(jobId); + assertNotNull(result); + System.out.println("RES:" + result); + // Some times the job could be removed from the cluster accounting + // before it has been reported to finish. Make sure + // to stop waiting in such case + if (status == JobStatus.UNDEFINED) { + break; + } + } + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail("DrmaaException caught:" + e.getMessage()); + } catch (InterruptedException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getMessage()); } - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testRunLocally() { - try { - ConfiguredExecutable confJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Local); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confJronn); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - List al2 = confJronn.getResults(); - assertNotNull(al2); - assertEquals(al2.size(), 3); - assertEquals(al1.getResults(), al2); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); + + @Test(groups = { AllTestSuit.test_group_runner }) + public void testRunLocally() { + try { + ConfiguredExecutable confJronn = Configurator + .configureExecutable(jronn, Executable.ExecProvider.Local); + + // For local execution use relative + LocalRunner lr = new LocalRunner(confJronn); + lr.executeJob(); + ConfiguredExecutable al1 = lr.waitForResult(); + assertNotNull(al1.getResults()); + List al2 = confJronn.getResults(); + assertNotNull(al2); + assertEquals(al2.size(), 3); + assertEquals(al1.getResults(), al2); + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (JobExecutionException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void readStatistics() { - try { - ConfiguredExecutable confJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Local); - // For local execution use relavive - - AsyncExecutor sexec = Configurator.getAsyncEngine(confJronn); - String jobId = sexec.submitJob(confJronn); - FilePuller fw = FilePuller.newFilePuller(confJronn - .getWorkDirectory() - + File.separator + Jronn.getStatFile(), - FileWatcher.MIN_CHUNK_SIZE_BYTES); - int count = 0; - long position = 0; - fw.waitForFile(4); - JobStatus status = sexec.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - System.out.println((status != JobStatus.FINISHED) + " d: " - + fw.hasMoreData()); - if (fw.hasMoreData()) { - ChunkHolder ch = fw.pull(position); - System.out.println("p:" + position); - String chunk = ch.getChunk(); - position = ch.getNextPosition(); - System.out.println("np " + position + " c: " + chunk); + + @Test(groups = { AllTestSuit.test_group_runner }) + public void testRunLocallyOnTwoCpu() { + try { + jronn.setNCore(2); + ConfiguredExecutable confJronn = Configurator + .configureExecutable(jronn, Executable.ExecProvider.Local); + + // For local execution use relative + LocalRunner lr = new LocalRunner(confJronn); + lr.executeJob(); + ConfiguredExecutable al1 = lr.waitForResult(); + assertNotNull(al1.getResults()); + List al2 = confJronn.getResults(); + assertNotNull(al2); + assertEquals(al2.size(), 3); + assertEquals(al1.getResults(), al2); + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (JobExecutionException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); } - count++; - // Make sure the loop is terminated if the job fails - if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) { - break; + } + + + @Test(groups = { AllTestSuit.test_group_runner }) + public void readStatistics() { + try { + ConfiguredExecutable confJronn = Configurator + .configureExecutable(jronn, Executable.ExecProvider.Local); + // For local execution use relavive + + AsyncExecutor sexec = Configurator.getAsyncEngine(confJronn); + String jobId = sexec.submitJob(confJronn); + FilePuller fw = FilePuller.newFilePuller(confJronn + .getWorkDirectory() + + File.separator + Jronn.getStatFile(), + FileWatcher.MIN_CHUNK_SIZE_BYTES); + int count = 0; + long position = 0; + fw.waitForFile(4); + JobStatus status = sexec.getJobStatus(jobId); + while (status != JobStatus.FINISHED) { + if (fw.hasMoreData()) { + ChunkHolder ch = fw.pull(position); + String chunk = ch.getChunk(); + position = ch.getNextPosition(); + } + count++; + // Make sure the loop is terminated if the job fails + if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) { + break; + } + Thread.sleep(300); + status = sexec.getJobStatus(jobId); + } + assertTrue(count > 1); + ConfiguredExecutable al = sexec.getResults(jobId); + assertNotNull(al.getResults()); + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (InterruptedException e) { + e.printStackTrace(); + fail(e.getMessage()); } - Thread.sleep(300); - status = sexec.getJobStatus(jobId); - } - System.out.println("\nOut of the LOOP!! "); - assertTrue(count > 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testPersistance() { - try { - Jronn jronn = new Jronn(); - jronn.setError("errrr.txt").setInput(AllTestSuit.test_input) - .setOutput("outtt.txt"); - assertEquals(jronn.getInput(), AllTestSuit.test_input); - assertEquals(jronn.getError(), "errrr.txt"); - assertEquals(jronn.getOutput(), "outtt.txt"); - ConfiguredExecutable cJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Local); - - SyncExecutor sexec = Configurator.getSyncEngine(cJronn); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - // Save run configuration - assertTrue(cJronn.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cJronn - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals( - ((ConfExecutable) cJronn).getRunConfiguration(), - loadedRun); - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCMuscle = (ConfiguredExecutable) cJronn - .loadRunConfiguration(new FileInputStream(new File(cJronn - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(resurrectedCMuscle); - assertEquals(resurrectedCMuscle.getExecutable().getInput(), - AllTestSuit.test_input); - assertEquals(resurrectedCMuscle.getExecutable().getError(), - "errrr.txt"); - assertEquals(resurrectedCMuscle.getExecutable().getOutput(), - "outtt.txt"); - // See in details whether executables are the same - assertEquals(resurrectedCMuscle.getExecutable(), jronn); - - ConfiguredExecutable resJronn = Configurator - .configureExecutable(resurrectedCMuscle.getExecutable(), - Executable.ExecProvider.Local); - - sexec = Configurator.getSyncEngine(resJronn, - Executable.ExecProvider.Local); - sexec.executeJob(); - al = sexec.waitForResult(); - assertNotNull(al); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); + + @Test(groups = { AllTestSuit.test_group_runner }) + public void testPersistance() { + try { + Jronn jronn = new Jronn(); + jronn.setError("errrr.txt").setInput(AllTestSuit.test_input) + .setOutput("outtt.txt"); + assertEquals(jronn.getInput(), AllTestSuit.test_input); + assertEquals(jronn.getError(), "errrr.txt"); + assertEquals(jronn.getOutput(), "outtt.txt"); + ConfiguredExecutable cJronn = Configurator + .configureExecutable(jronn, Executable.ExecProvider.Local); + + SyncExecutor sexec = Configurator.getSyncEngine(cJronn); + sexec.executeJob(); + ConfiguredExecutable al = sexec.waitForResult(); + assertNotNull(al.getResults()); + // Save run configuration + assertTrue(cJronn.saveRunConfiguration()); + + // See if loaded configuration is the same as saved + RunConfiguration loadedRun = RunConfiguration + .load(new FileInputStream(new File(cJronn + .getWorkDirectory(), RunConfiguration.rconfigFile))); + assertEquals( + ((ConfExecutable) cJronn).getRunConfiguration(), + loadedRun); + // Load run configuration as ConfExecutable + ConfiguredExecutable resurrectedCMuscle = (ConfiguredExecutable) cJronn + .loadRunConfiguration(new FileInputStream(new File(cJronn + .getWorkDirectory(), RunConfiguration.rconfigFile))); + assertNotNull(resurrectedCMuscle); + assertEquals(resurrectedCMuscle.getExecutable().getInput(), + AllTestSuit.test_input); + assertEquals(resurrectedCMuscle.getExecutable().getError(), + "errrr.txt"); + assertEquals(resurrectedCMuscle.getExecutable().getOutput(), + "outtt.txt"); + // See in details whether executables are the same + assertEquals(resurrectedCMuscle.getExecutable(), jronn); + + ConfiguredExecutable resJronn = Configurator + .configureExecutable(resurrectedCMuscle.getExecutable(), + Executable.ExecProvider.Local); + + sexec = Configurator.getSyncEngine(resJronn, + Executable.ExecProvider.Local); + sexec.executeJob(); + al = sexec.waitForResult(); + assertNotNull(al); + + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (JobExecutionException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (FileNotFoundException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getMessage()); + } } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testConfigurationLoading() { - try { - RunnerConfig jronnConfig = ConfExecutable - .getRunnerOptions(Jronn.class); - assertNotNull(jronnConfig); - assertTrue(jronnConfig.getArguments().size() > 0); - - PresetManager jronnPresets = ConfExecutable - .getRunnerPresets(Jronn.class); - assertNull(jronnPresets); // there is no presets - - LimitsManager jronnLimits = ConfExecutable - .getRunnerLimits(Jronn.class); - assertNotNull(jronnLimits); - assertTrue(jronnLimits.getLimits().size() > 0); - jronnLimits.validate(jronnPresets); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); + + @Test(groups = { AllTestSuit.test_group_runner }) + public void testConfigurationLoading() { + try { + RunnerConfig jronnConfig = ConfExecutable + .getRunnerOptions(Jronn.class); + assertNotNull(jronnConfig); + assertTrue(jronnConfig.getArguments().size() > 0); + + PresetManager jronnPresets = ConfExecutable + .getRunnerPresets(Jronn.class); + assertNull(jronnPresets); // there is no presets + + LimitsManager jronnLimits = ConfExecutable + .getRunnerLimits(Jronn.class); + assertNotNull(jronnLimits); + assertTrue(jronnLimits.getLimits().size() > 0); + jronnLimits.validate(jronnPresets); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } catch (ValidationException e) { + e.printStackTrace(); + fail(e.getLocalizedMessage()); + } } - } } diff --git a/webservices/compbio/ws/server/TcoffeeWS.java b/webservices/compbio/ws/server/TcoffeeWS.java index afe2cae..07a1f41 100644 --- a/webservices/compbio/ws/server/TcoffeeWS.java +++ b/webservices/compbio/ws/server/TcoffeeWS.java @@ -34,6 +34,7 @@ import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; import compbio.engine.client.ConfiguredExecutable; import compbio.engine.client.Executable; +import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ChunkHolder; import compbio.metadata.JobStatus; import compbio.metadata.JobSubmissionException; @@ -75,18 +76,18 @@ public class TcoffeeWS implements MsaWS { } ConfiguredExecutable init(List sequences) - throws JobSubmissionException { - Tcoffee tcoffee = new Tcoffee(); - tcoffee.setInput("fasta.in").setOutput("fasta.out"); - ConfiguredExecutable confCoffee = Configurator - .configureExecutable(tcoffee, sequences); - if (confCoffee.getExecProvider() == Executable.ExecProvider.Cluster) { - int clusterCpuNum = Tcoffee.getClusterCpuNum(); - if (clusterCpuNum != 0) { - tcoffee.setNCore(clusterCpuNum); - } - } - return confCoffee; + throws JobSubmissionException { + Tcoffee tcoffee = new Tcoffee(); + tcoffee.setInput("fasta.in").setOutput("fasta.out"); + ConfiguredExecutable confCoffee = Configurator + .configureExecutable(tcoffee, sequences); + if (confCoffee.getExecProvider() == Executable.ExecProvider.Cluster) { + int clusterCpuNum = SkeletalExecutable.getClusterCpuNum(Tcoffee.class); + if (clusterCpuNum != 0) { + tcoffee.setNCore(clusterCpuNum); + } + } + return confCoffee; } @Override