1 /* Copyright (c) 2009 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
19 package compbio.engine;
\r
21 import compbio.engine.client.ConfiguredExecutable;
\r
22 import compbio.metadata.JobStatus;
\r
23 import compbio.metadata.JobSubmissionException;
\r
24 import compbio.metadata.ResultNotAvailableException;
\r
27 * An asynchronous executor engine, capable of running, cancelling,
\r
28 * obtaining results calculated by a native executable wrapper in Executable interface.
\r
29 * Implementation agnostic. Executables can be run either locally to the JVM or on the cluster.
\r
34 public interface AsyncExecutor {
\r
37 * Submits job for the execution
\r
38 * Immediate execution is not guaranteed, this method puts the job in the queue.
\r
39 * All it guarantees that the job will be eventually executed.
\r
40 * The start of execution will depend on the number of jobs in the queue.
\r
42 * @return unique job identifier
\r
43 * @throws JobSubmissionException
\r
44 * if submission fails. This usually happens due to the problem on a server side.
\r
46 String submitJob(ConfiguredExecutable<?> executable)
\r
47 throws JobSubmissionException;
\r
50 * Retrieve the results of the job. Please not that current implementations of this method
\r
51 * blocks if the task is running until the end of the calculation.
\r
53 * @param jobId job identifier obtained at the job submission
\r
54 * @return ConfiguredExecutable object from which result can be obtained
\r
55 * @throws ResultNotAvailableException if the result is not available for whatever reason.
\r
56 * Could be due to execution failure, or due to the results being removed from the server at
\r
57 * the time of request.
\r
59 ConfiguredExecutable<?> getResults(String jobId)
\r
60 throws ResultNotAvailableException;
\r
64 * @param jobId unique job identifier
\r
65 * @return task working directory
\r
67 String getWorkDirectory(String jobId);
\r
70 * Remove all files and a job directory for a jobid.
\r
72 * @return true if job directory was successfully removed, false otherwise.
\r
74 boolean cleanup(String jobId);
\r
77 * Stop running job. Please not that this method does not guarantee to remove the job directory and files in it.
\r
79 * @return true if job was cancelled successfully, false otherwise
\r
81 boolean cancelJob(String jobId);
\r
84 * Query the status of the job
\r
86 * jobId - unique job identifier
\r
87 * @return The JobStatus object representing the status of the job
\r
90 JobStatus getJobStatus(String jobId);
\r