Next version of JABA
[jabaws.git] / engine / compbio / engine / SyncExecutor.java
1 /* Copyright (c) 2009 Peter Troshin\r
2  *  \r
3  *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \r
4  * \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
7  * \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
11  * \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
14  * \r
15  * Any republication or derived work distributed in source code form\r
16  * must include this copyright and license notice.\r
17  */\r
18 \r
19 package compbio.engine;\r
20 \r
21 import compbio.engine.client.ConfiguredExecutable;\r
22 import compbio.metadata.JobExecutionException;\r
23 import compbio.metadata.JobStatus;\r
24 import compbio.metadata.JobSubmissionException;\r
25 \r
26 /**\r
27  * Synchronous executor, is an engine to run the Executable synchronously.\r
28  *  \r
29  * @author pvtroshin\r
30  *              Date October 2009\r
31  */\r
32 public interface SyncExecutor {\r
33 \r
34         /**\r
35          * Execute the job \r
36          * \r
37          * @return String - job unique identifier\r
38          * @throws JobSubmissionException\r
39          *             if submission fails\r
40          */\r
41         void executeJob() throws JobSubmissionException;\r
42 \r
43         /**\r
44          * Clean up after the job \r
45          * @return true if all the files created by this job have been removed successfully, false otherwise\r
46          */\r
47         boolean cleanup();\r
48 \r
49         \r
50         /**\r
51          *\r
52          * Call to this method block for as long as it is required for an executable to finish its job. \r
53          * If the calculation has been completed already, the this method returns results immediately. \r
54          * This could return the result directly, but that would be type unsafe\r
55          *\r
56          * @return object from wich the result can be obtained\r
57          * @throws JobExecutionException\r
58          */\r
59         ConfiguredExecutable<?> waitForResult() throws JobExecutionException;\r
60 \r
61         /**\r
62          * \r
63          * @return working directory if the task \r
64          */\r
65         String getWorkDirectory();\r
66 \r
67         /**\r
68          * Stops running job. \r
69          * Clean up is not performed. \r
70          * \r
71          * @return true if job was cancelled successfully, false otherwise\r
72          */\r
73         boolean cancelJob();\r
74 \r
75         /**\r
76          * Query the status of the job by its id. \r
77          * @return - JobStatus \r
78          */\r
79         JobStatus getJobStatus();\r
80 \r
81 }\r