~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/jdrmaa/src/org/ggf/drmaa/Session.java

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 *
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 *
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 *
 
9
 *
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 *
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 *
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 *
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 *
 
28
 *   All Rights Reserved.
 
29
 *
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
 
 
33
package org.ggf.drmaa;
 
34
 
 
35
import java.util.List;
 
36
 
 
37
/**
 
38
 * This interface represents the operations available for interacting with
 
39
 * the DRM.  In DRMAA, (almost) all DRM interaction occur within the context of
 
40
 * a session.  The DRMAA specification also strongly recommends that a DRMAA
 
41
 * implementation not allow concurrent sessions.  Since DRMAA has no facility
 
42
 * for user authentication or authorization, most DRMAA implementations will
 
43
 * likely only support one session per implementation instance.
 
44
 *
 
45
 * <p>In order to use a Session, it must first be initialized.  Once initialized
 
46
 * it is the responsibility of the programmer to ensure that the session also be
 
47
 * explicitly terminated.  Otherwise, session artifacts may be left behind on
 
48
 * the client and/or server.  A handy way to make sure the Session is terminated
 
49
 * is to set up a shutdown hook to call the exit() method on the active
 
50
 * session.</p>
 
51
 *
 
52
 * <p>To get a Session implementation appropriate for the DRM in use, one uses
 
53
 * the SessionFactory.getSession() method.</p>
 
54
 *
 
55
 * <p>Example:</p>
 
56
 *
 
57
 * <pre>public static void main(String[] args) throws Exception {
 
58
 *   SessionFactory factory = SessionFactory.getFactory();
 
59
 *   Session session = factory.getSession();
 
60
 *
 
61
 *   try {
 
62
 *      session.init(&quot;&quot;);
 
63
 *      JobTemplate jt = session.createJobTemplate();
 
64
 *      jt.setRemoteCommand(&quot;sleeper.sh&quot;);
 
65
 *      jt.setArgs(Collections.singletonList(&quot;5&quot;));
 
66
 *
 
67
 *      String id = session.runJob(jt);
 
68
 *
 
69
 *      session.deleteJobTemplate(jt);
 
70
 *
 
71
 *      while (session.getJobProgramStatus(id) != Session.RUNNING) {
 
72
 *         Thread.sleep(1000);
 
73
 *      }
 
74
 *
 
75
 *      System.out.println(&quot;Job &quot; + id + &quot; is now running.&quot;);
 
76
 *
 
77
 *      session.control(id, Session.SUSPEND);
 
78
 *      Thread.sleep(1000);
 
79
 *      session.control(id, Session.RELEASE);
 
80
 *
 
81
 *      JobInfo info = session.wait(id, Session.TIMEOUT_WAIT_FOREVER);
 
82
 *
 
83
 *      System.out.println(&quot;Job &quot; + info.getJobId () + &quot; exited with status: &quot; +
 
84
 *                         info.getExitStatus ());
 
85
 *
 
86
 *      session.exit();
 
87
 *   }
 
88
 *   catch (DrmaaException e) {
 
89
 *      System.out.println(&quot;Error: &quot; + e.getMessage ());
 
90
 *   }
 
91
 * }
 
92
 * </pre>
 
93
 * @author dan.templeton@sun.com
 
94
 * @see java.lang.Runtime#addShutdownHook
 
95
 * @see org.ggf.drmaa.SessionFactory
 
96
 * @see <a
 
97
 * href="http://gridengine.sunsource.net/project/gridengine/howto/drmaa_java.html">Grid
 
98
 * Engine DRMAA Java&trade; Language Binding HowTo</a>
 
99
 * @since 0.5
 
100
 * @version 1.0
 
101
 */
 
102
public abstract interface Session {
 
103
    /**
 
104
     * Suspend the job.  Used with the Session.control() method.
 
105
     */
 
106
    public static final int SUSPEND = 0;
 
107
    /**
 
108
     * Resume the job.  Used with the Session.control() method.
 
109
     */
 
110
    public static final int RESUME = 1;
 
111
    /**
 
112
     * Put the job on hold.  Used with the Session.control() method.
 
113
     */
 
114
    public static final int HOLD = 2;
 
115
    /**
 
116
     * Release the hold on the job.  Used with the Session.control() method.
 
117
     */
 
118
    public static final int RELEASE = 3;
 
119
    /**
 
120
     * Kill the job.  Used with the Session.control() method.
 
121
     */
 
122
    public static final int TERMINATE = 4;
 
123
    /**
 
124
     * All jobs submitted during this DRMAA session.  Used with the
 
125
     * Session.control() and Session.synchronize() methods.
 
126
     */
 
127
    public static final String JOB_IDS_SESSION_ALL =
 
128
            "DRMAA_JOB_IDS_SESSION_ALL";
 
129
    /**
 
130
     * Any job from the session.  Used with the Session.wait() method.
 
131
     */
 
132
    public static final String JOB_IDS_SESSION_ANY =
 
133
            "DRMAA_JOB_IDS_SESSION_ANY";
 
134
    /**
 
135
     * Wait indefinitely for a result.  Used with the Session.wait() and
 
136
     * Session.synchronize() methods.
 
137
     */
 
138
    public static final long TIMEOUT_WAIT_FOREVER = -1L;
 
139
    /**
 
140
     * Return immediately if no result is available.  Used with the
 
141
     * Session.wait() and Session.synchronize() methods.
 
142
     */
 
143
    public static final long TIMEOUT_NO_WAIT = 0L;
 
144
    /**
 
145
     * Job status cannot be determined.  Used with the
 
146
     * Session.getJobProgramStatus() method.
 
147
     */
 
148
    public static final int UNDETERMINED = 0x00;
 
149
    /**
 
150
     * Job is queued and active.  Used with the
 
151
     * Session.getJobProgramStatus() method.
 
152
     */
 
153
    public static final int QUEUED_ACTIVE = 0x10;
 
154
    /**
 
155
     * Job is queued and in system hold.  Used with the
 
156
     * Session.getJobProgramStatus() method.
 
157
     */
 
158
    public static final int SYSTEM_ON_HOLD = 0x11;
 
159
    /**
 
160
     * Job is queued and in user hold.  Used with the
 
161
     * Session.getJobProgramStatus() method.
 
162
     */
 
163
    public static final int USER_ON_HOLD = 0x12;
 
164
    /**
 
165
     * Job is queued and in user and system hold.  Used with the
 
166
     * Session.getJobProgramStatus() method.
 
167
     */
 
168
    public static final int USER_SYSTEM_ON_HOLD = 0x13;
 
169
    /**
 
170
     * Job is running.  Used with the
 
171
     * Session.getJobProgramStatus() method.
 
172
     */
 
173
    public static final int RUNNING = 0x20;
 
174
    /**
 
175
     * Job is system suspended.  Used with the
 
176
     * Session.getJobProgramStatus() method.
 
177
     */
 
178
    public static final int SYSTEM_SUSPENDED = 0x21;
 
179
    /**
 
180
     * Job is user suspended.  Used with the
 
181
     * Session.getJobProgramStatus() method.
 
182
     */
 
183
    public static final int USER_SUSPENDED = 0x22;
 
184
    /**
 
185
     * Job is user suspended.  Used with the
 
186
     * Session.getJobProgramStatus() method.
 
187
     */
 
188
    public static final int USER_SYSTEM_SUSPENDED = 0x23;
 
189
    /**
 
190
     * Job has finished normally.  Used with the
 
191
     * Session.getJobProgramStatus() method.
 
192
     */
 
193
    public static final int DONE = 0x30;
 
194
    /**
 
195
     * Job finished, but terminated abnormally.  Used with the
 
196
     * Session.getJobProgramStatus() method.
 
197
     */
 
198
    public static final int FAILED = 0x40;
 
199
    
 
200
    /**
 
201
     * Initialize the DRMAA implementation.
 
202
     * <i>contact</i> is an implementation-dependent string that may be used to
 
203
     * specify which DRM system to use.  This routine must be called before any
 
204
     * other DRMAA calls, except for getDrmSystem(),
 
205
     * getDrmaaImplementation(), and getContact().
 
206
     *
 
207
     * <p>If contact is <CODE>null</CODE> or &quot;&quot;, the default DRM system
 
208
     * is used, provided there is only one DRMAA implementation available.
 
209
     * If there is more than one DRMAA implementation available, init() throws a
 
210
     * NoDefaultContactStringSelectedException.</p>
 
211
     *
 
212
     * <p>init() should be called only once, by only one of the threads. The main
 
213
     * thread is recommended.  A call to init() by another thread or additional
 
214
     * calls to init() by the same thread with throw a
 
215
     * SessionAlreadyActiveException.</p>
 
216
     * @param contact implementation-dependent string that may be used to
 
217
     * specify which DRM system to use.
 
218
     * @throws DrmaaException May be be one of the following:
 
219
     * <UL>
 
220
     * <LI>DrmsInitException -- the session could not be initialized</LI>
 
221
     * <LI>InvalidContactStringException -- the contact string is invalid</LI>
 
222
     * <LI>AlreadyActiveSessionException -- the session has already been
 
223
     * initialized</LI>
 
224
     * <LI>DefaultContactStringException -- no contact string was specified, and
 
225
     * the DRMAA implementation was unable to use the default contact
 
226
     * information to connect to a DRM</LI>
 
227
     * <LI>NoDefaultContactStringSelectedException -- no contact string was
 
228
     * specified, and the DRMAA implementation has no default contact
 
229
     * information</LI>
 
230
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
231
     * contact the DRM</LI>
 
232
     * <LI>AuthorizationException -- the executing user does not have
 
233
     * sufficient permissions to execute the desired action</LI>
 
234
     * <LI>IllegalArgumentException -- an argument is invalid</LI>
 
235
     * <LI>InternalException -- an error has occured in the DRMAA
 
236
     * implementation</LI>
 
237
     * </UL>
 
238
     */
 
239
    public abstract void init(String contact) throws DrmaaException;
 
240
    
 
241
    /**
 
242
     * Disengage from the DRM and allow the DRMAA implementation to perform
 
243
     * any necessary internal cleanup.
 
244
     * This routine ends the current DRMAA session but doesn't affect any
 
245
     * jobs which have already been submitted (e.g., queued and running jobs
 
246
     * remain queued and running).
 
247
     * exit() should be called only once, by only one of the threads.
 
248
     * Additional calls to exit() beyond the first will throw a
 
249
     * NoActiveSessionException.
 
250
     * @throws DrmaaException May be one of the following:
 
251
     * <UL>
 
252
     * <LI>DrmsExitException -- an error occured while tearing down the
 
253
     * session</LI>
 
254
     * <LI>NoActiveSessionException -- the session has not yet been initialized
 
255
     * or has already been exited</LI>
 
256
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
257
     * contact the DRM</LI>
 
258
     * <LI>AuthorizationException -- the executing user does not have
 
259
     * sufficient permissions to execute the desired action</LI>
 
260
     * <LI>InternalException -- an error has occured in the DRMAA
 
261
     * implementation</LI>
 
262
     * </UL>
 
263
     */
 
264
    public abstract void exit() throws DrmaaException;
 
265
    
 
266
    /**
 
267
     * Get a new job template.  A job template is used to set the
 
268
     * environment for jobs to be submitted.  Once a job template has been
 
269
     * created, it should also be deleted (via deleteJobTemplate()) when no
 
270
     * longer needed.  Failure to do so may result in a memory leak.
 
271
     * @throws DrmaaException May be one of the following:
 
272
     * <UL>
 
273
     * <LI>NoActiveSessionException -- the session has not yet been initialized
 
274
     * or has already been exited</LI>
 
275
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
276
     * contact the DRM</LI>
 
277
     * <LI>AuthorizationException -- the executing user does not have
 
278
     * sufficient permissions to execute the desired action</LI>
 
279
     * <LI>InternalException -- an error has occured in the DRMAA
 
280
     * implementation</LI>
 
281
     * </UL>
 
282
     * @return a blank JobTemplate instance
 
283
     * @see org.ggf.drmaa.JobTemplate
 
284
     */
 
285
    public abstract JobTemplate createJobTemplate() throws DrmaaException;
 
286
    
 
287
    /**
 
288
     * Deallocate a job template. This routine has no effect on jobs which have
 
289
     * already been submitted.
 
290
     * @param jt the JobTemplate to delete
 
291
     * @throws DrmaaException May be one of the following:
 
292
     * <UL>
 
293
     * <LI>InvalidJobTemplateException -- the JobTemplate instance does not
 
294
     * belong to the current session, was not created with createJobTemplate(),
 
295
     * or has already been deleted</LI>
 
296
     * <LI>NoActiveSessionException -- the session has not yet been initialized
 
297
     * or has already been exited</LI>
 
298
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
299
     * contact the DRM</LI>
 
300
     * <LI>AuthorizationException -- the executing user does not have
 
301
     * sufficient permissions to execute the desired action</LI>
 
302
     * <LI>IllegalArgumentException -- an argument is invalid</LI>
 
303
     * <LI>InternalException -- an error has occured in the DRMAA
 
304
     * implementation</LI>
 
305
     * </UL>
 
306
     */
 
307
    public abstract void deleteJobTemplate(JobTemplate jt)
 
308
            throws DrmaaException;
 
309
    
 
310
    /**
 
311
     * Submit a job with attributes defined in the job template, <i>jt</i>.
 
312
     * The returned job identifier is a String identical to that returned
 
313
     * from the underlying DRM system.
 
314
     * @param jt the job template to be used to create the job
 
315
     * @throws DrmaaException May be one of the following:
 
316
     * <UL>
 
317
     * <LI>TryLaterException -- the DRM was temporarily unable to fulfill the
 
318
     * request, but a retry might succeed</LI>
 
319
     * <LI>DeniedByDrmException -- the DRM has rejected the job due to
 
320
     * configuration problems either in the DRM or the job template</LI>
 
321
     * <LI>InvalidJobTemplateException -- the JobTemplate instance does not
 
322
     * belong to the current session, was not created with createJobTemplate(),
 
323
     * or has already been deleted</LI>
 
324
     * <LI>NoActiveSessionException -- the session has not yet been initialized
 
325
     * or has already been exited</LI>
 
326
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
327
     * contact the DRM</LI>
 
328
     * <LI>AuthorizationException -- the executing user does not have
 
329
     * sufficient permissions to execute the desired action</LI>
 
330
     * <LI>IllegalArgumentException -- an argument is invalid</LI>
 
331
     * <LI>InternalException -- an error has occured in the DRMAA
 
332
     * implementation</LI>
 
333
     * </UL>
 
334
     * @return job identifier String identical to that returned from the
 
335
     * underlying DRM system
 
336
     */
 
337
    public abstract String runJob(JobTemplate jt) throws DrmaaException;
 
338
    
 
339
    /**
 
340
     * Submit a range of parametric jobs,
 
341
     * each with attributes defined in the job template, <i>jt</i>.
 
342
     * The returned job identifiers are Strings identical to those returned
 
343
     * from the underlying DRM system.  The number of jobs submitted will be
 
344
     * Math.floor((<i>end</i> - <i>start</i> + 1) / <i>incr</i>).
 
345
     *
 
346
     * <p>The JobTemplate class defines a <code>PARAMETRIC_INDEX</code>
 
347
     * placeholder for use in specifying paths in the job template.  This
 
348
     * placeholder is used to represent the individual identifiers of the tasks
 
349
     * submitted through this method.</p>
 
350
     *
 
351
     * @return job identifier Strings identical to that returned by the
 
352
     * underlying DRM system
 
353
     * @param start the starting value for the loop index
 
354
     * @param end the terminating value for the loop index
 
355
     * @param incr the value by which to increment the loop index each iteration
 
356
     * @param jt the job template to be used to create the job
 
357
     * @throws DrmaaException May be one of the following:
 
358
     * <UL>
 
359
     * <LI>TryLaterException -- the DRM was temporarily unable to fulfill the
 
360
     * request, but a retry might succeed</LI>
 
361
     * <LI>DeniedByDrmException -- the DRM has rejected the job due to
 
362
     * configuration problems either in the DRM or the job template</LI>
 
363
     * <LI>InvalidJobTemplateException -- the JobTemplate instance does not
 
364
     * belong to the current session, was not created with createJobTemplate(),
 
365
     * or has already been deleted</LI>
 
366
     * <LI>NoActiveSessionException -- the session has not yet been initialized
 
367
     * or has already been exited</LI>
 
368
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
369
     * contact the DRM</LI>
 
370
     * <LI>AuthorizationException -- the executing user does not have
 
371
     * sufficient permissions to execute the desired action</LI>
 
372
     * <LI>IllegalArgumentException -- an argument is invalid</LI>
 
373
     * <LI>InternalException -- an error has occured in the DRMAA
 
374
     * implementation</LI>
 
375
     * </UL>
 
376
     */
 
377
    public abstract List runBulkJobs(JobTemplate jt, int start, int end,
 
378
                                     int incr) throws DrmaaException;
 
379
    
 
380
    /**
 
381
     * <p>Hold, release, suspend, resume, or kill the job identified by
 
382
     * <i>jobId</i>.  If <i>jobId</i> is <code>JOB_IDS_SESSION_ALL</code>, then
 
383
     * this routine acts on all jobs <B>submitted</B> during this DRMAA session
 
384
     * up to the moment control() is called.  To avoid thread races conditions
 
385
     * in multithreaded applications, the DRMAA implementation user should
 
386
     * explicitly synchronize this call with any other job submission or control
 
387
     * calls that may change the number of remote jobs.</p>
 
388
     *
 
389
     * <p>The legal values for <i>action</i> and their meanings are:</p>
 
390
     *
 
391
     * <UL>
 
392
     * <LI><code>SUSPEND</code>: stop the job,</LI>
 
393
     * <LI><code>RESUME</code>: (re)start the job,</LI>
 
394
     * <LI><code>HOLD</code>: put the job on-hold,</LI>
 
395
     * <LI><code>RELEASE</code>: release the hold on the job, and</LI>
 
396
     * <LI><code>TERMINATE</code>: kill the job.</LI>
 
397
     * </UL>
 
398
     *
 
399
     * <p>This method returns once the action has been acknowledged by
 
400
     * the DRM system, but it does not necessarily wait until the action
 
401
     * has been completed.</p>
 
402
     *
 
403
     * <p>Some DRMAA implementations may allow this method to be used to control
 
404
     * jobs submitted external to the DRMAA session, such as jobs submitted by
 
405
     * other DRMAA sessions or jobs submitted via native utilities.</p>
 
406
     *
 
407
     * <p>If <i>jobId</i> is <code>JOB_IDS_SESSION_ALL</code> and the control
 
408
     * action fails for one or more jobs, and InternalException will be thrown,
 
409
     * and the state of the jobs in the session will be undefined.</p>
 
410
     *
 
411
     * @param jobId The id of the job to control
 
412
     * @param action the control action to be taken
 
413
     * @throws DrmaaException May be one of the following:
 
414
     * <UL>
 
415
     * <LI>ResumeInconsistentStateException -- an attempt was made to resume a
 
416
     * job that was not is a suspended state</LI>
 
417
     * <LI>SuspendInconsistentStateException -- an attempt was made to suspend a
 
418
     * job that was not is a running state</LI>
 
419
     * <LI>HoldInconsistentStateException -- an attempt was made to hold a
 
420
     * job that was not is a pending state</LI>
 
421
     * <LI>ReleaseInconsistentStateException -- an attempt was made to release a
 
422
     * job that was not is a held state</LI>
 
423
     * <LI>InvalidJobException -- the job identifier does not refer to an active
 
424
     * job</LI>
 
425
     * <LI>NoActiveSessionException -- the session has not yet been initialized
 
426
     * or has already been exited</LI>
 
427
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
428
     * contact the DRM</LI>
 
429
     * <LI>AuthorizationException -- the executing user does not have
 
430
     * sufficient permissions to execute the desired action</LI>
 
431
     * <LI>IllegalArgumentException -- an argument is invalid</LI>
 
432
     * <LI>InternalException -- an error has occured in the DRMAA
 
433
     * implementation</LI>
 
434
     * </UL>
 
435
     */
 
436
    public abstract void control(String jobId, int action)
 
437
            throws DrmaaException;
 
438
    
 
439
    /**
 
440
     * Wait until all jobs specified by <i>jobIds</i> have finished
 
441
     * execution.  If <i>jobIds</i> contains <code>JOB_IDS_SESSION_ALL</code>,
 
442
     * then this method waits for all jobs <B>submitted</B> during this DRMAA
 
443
     * session up to the moment synchronize() is called.  To avoid thread race
 
444
     * conditions in multithreaded applications, the DRMAA implementation user
 
445
     * should explicitly synchronize this call with any other job submission
 
446
     * or control calls that may change the number of remote jobs.
 
447
     *
 
448
     * <p>To prevent blocking indefinitely in this call, the caller may use a
 
449
     * timeout specifying how many seconds to block in this call.  The value
 
450
     * <code>TIMEOUT_WAIT_FOREVER</code> may be specified to wait indefinitely
 
451
     * for a result.  The value <code>TIMEOUT_NO_WAIT</code> may be specified to
 
452
     * return immediately if no result is available. If the call exits before
 
453
     * the timeout has elapsed, all the jobs have been waited on or there was an
 
454
     * interrupt.  If the invocation exits on timeout, an ExitTimeException is
 
455
     * thrown.  The caller should check system time before and after this call
 
456
     * in order to be sure of how much time has passed.</p>
 
457
     *
 
458
     * <p>The <i>dispose</i> parameter specifies how to treat the reaping of the
 
459
     * remote jobs' internal data records, which includes a record of the jobs'
 
460
     * consumption of system resources during their execution and other
 
461
     * statistical information.  If this parameter is set to <code>true</code>,
 
462
     * the DRM will dispose of the jobs' data records at the end of
 
463
     * the synchroniize() call.  If set to <code>false</code>, the data records
 
464
     * will be left for future access via the wait() method.</p>
 
465
     *
 
466
     * @param jobIds the ids of the jobs to synchronize
 
467
     * @param timeout the maximum number of seconds to wait
 
468
     * @param dispose specifies how to treat reaping information
 
469
     * @throws DrmaaException May be one of the following:
 
470
     * <UL>
 
471
     * <LI>ExitTimeoutException -- the operation timed out before
 
472
     * completing</LI>
 
473
     * <LI>InvalidJobException -- the job identifier does not refer to an active
 
474
     * job</LI>
 
475
     * <LI>NoActiveSessionException -- the session has not yet been initialized
 
476
     * or has already been exited</LI>
 
477
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
478
     * contact the DRM</LI>
 
479
     * <LI>AuthorizationException -- the executing user does not have
 
480
     * sufficient permissions to execute the desired action</LI>
 
481
     * <LI>IllegalArgumentException -- an argument is invalid</LI>
 
482
     * <LI>InternalException -- an error has occured in the DRMAA
 
483
     * implementation</LI>
 
484
     * </UL>
 
485
     * @see #wait
 
486
     */
 
487
    public abstract void synchronize(List jobIds, long timeout, boolean dispose)
 
488
            throws DrmaaException;
 
489
    
 
490
    /**
 
491
     * This method will wait for a job with <i>jobId</i> to finish execution
 
492
     * or fail.  If the special string, <code>JOB_IDS_SESSION_ANY</code>, is
 
493
     * provided as the <i>jobId</i>, this routine will wait for any job from the
 
494
     * session. This routine is modeled on the wait3 POSIX routine.
 
495
     *
 
496
     * <p>The <i>timeout</i> value is used to specify the desired behavior when
 
497
     * a result is not immediately available.  The value,
 
498
     * <code>TIMEOUT_WAIT_FOREVER<code>, may be specified to wait indefinitely
 
499
     * for a result.  The value, <code>TIMEOUT_NO_WAIT<code>, may be specified
 
500
     * to return immediately if no result is available.  Alternatively, a number
 
501
     * of seconds may be specified to indicate how long to wait for a result to
 
502
     * become available.</p>
 
503
     *
 
504
     * <p>If the call exits before timeout, either the job has been waited on
 
505
     * successfully or there was an interrupt. If the invocation exits on
 
506
     * timeout, an ExitTimeoutException is thrown.  The caller should check
 
507
     * system time before and after this call in order to be sure how much time
 
508
     * has passed.</p>
 
509
     *
 
510
     * <p>The routine reaps job data records on a successful call, so any
 
511
     * subsequent calls to wait(), synchronize(), control(), or
 
512
     * getJobProgramStatus() will fail, throwing an InvalidJobException, meaning
 
513
     * that the job's data record has been already reaped. This exception is the
 
514
     * same as if the job were unknown.  (The only case where wait() can be
 
515
     * successfully called on a single job more than once is when the previous
 
516
     * call to wait() timed out before the job finished.)</p>
 
517
     *
 
518
     * <p>When successful, the resource usage information for the job is
 
519
     * provided as a Map of usage parameter names and their values in the
 
520
     * JobInfo object.  The values contain the amount of resources consumed by
 
521
     * the job and are implementation defined.  If no resource usage
 
522
     * information is available for the finished job, the resourceUsage
 
523
     * property of the returned JobInfo instance will be <code>null</code>.</p>
 
524
     *
 
525
     * <p>In the 0.5 version of this method, a NoResourceUsageException would be
 
526
     * thrown if the target job finished with no resource usage information.  In
 
527
     * the current implementation, no exception is thrown in that case.
 
528
     * Instead, the JobInfo.getResourceUsage() method will return null.</p>
 
529
     *
 
530
     * @param jobId the id of the job for which to wait
 
531
     * @param timeout the maximum number of seconds to wait
 
532
     * @return the resource usage and status information
 
533
     * @throws DrmaaException May be one of the following:
 
534
     * <UL>
 
535
     * <LI>ExitTimeoutException -- the operation timed out before
 
536
     * completing</LI>
 
537
     * <LI>InvalidJobException -- the job identifier does not refer to an active
 
538
     * job</LI>
 
539
     * <LI>NoActiveSessionException -- the session has not yet been initialized
 
540
     * or has already been exited</LI>
 
541
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
542
     * contact the DRM</LI>
 
543
     * <LI>AuthorizationException -- the executing user does not have
 
544
     * sufficient permissions to execute the desired action</LI>
 
545
     * <LI>IllegalArgumentException -- an argument is invalid</LI>
 
546
     * <LI>InternalException -- an error has occured in the DRMAA
 
547
     * implementation</LI>
 
548
     * </UL>
 
549
     * @see JobInfo
 
550
     */
 
551
    public abstract JobInfo wait(String jobId, long timeout)
 
552
            throws DrmaaException;
 
553
    
 
554
    /**
 
555
     * Get the program status of the job identified by jobId. The possible
 
556
     * values returned from this method are:
 
557
     *
 
558
     * <UL>
 
559
     * <LI><code>UNDETERMINED</code>: process status cannot be determined</LI>
 
560
     * <LI><code>QUEUED_ACTIVE</code>: job is queued and active</LI>
 
561
     * <LI><code>SYSTEM_ON_HOLD</code>: job is queued and in system hold</LI>
 
562
     * <LI><code>USER_ON_HOLD</code>: job is queued and in user hold</LI>
 
563
     * <LI><code>USER_SYSTEM_ON_HOLD</code>: job is queued and in user and
 
564
     * system hold</LI>
 
565
     * <LI><code>RUNNING</code>: job is running</LI>
 
566
     * <LI><code>SYSTEM_SUSPENDED</code>: job is system suspended</LI>
 
567
     * <LI><code>USER_SUSPENDED</code>: job is user suspended</LI>
 
568
     * <LI><code>USER_SYSTEM_SUSPENDED</code>: job is user and system
 
569
     * suspended</LI>
 
570
     * <LI><code>DONE</code>: job finished normally</LI>
 
571
     * <LI><code>FAILED</code>: job finished, but failed.</LI>
 
572
     * </UL>
 
573
     *
 
574
     * <p>The DRMAA implementation must always get the status of jobId from DRM
 
575
     * system unless the status has already been determined to be
 
576
     * <code>FAILED</code> or <code>DONE</code> and the status has been
 
577
     * successfully cached. Terminated jobs return a <code>FAILED</code>
 
578
     * status.</p>
 
579
     * @return the program status
 
580
     * @param jobId the id of the job whose status is to be retrieved
 
581
     * @throws DrmaaException May be one of the following:
 
582
     * <UL>
 
583
     * <LI>InvalidJobException -- the job identifier does not refer to an active
 
584
     * job</LI>
 
585
     * <LI>NoActiveSessionException -- the session has not yet been initialized
 
586
     * or has already been exited</LI>
 
587
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
588
     * contact the DRM</LI>
 
589
     * <LI>AuthorizationException -- the executing user does not have
 
590
     * sufficient permissions to execute the desired action</LI>
 
591
     * <LI>IllegalArgumentException -- an argument is invalid</LI>
 
592
     * <LI>InternalException -- an error has occured in the DRMAA
 
593
     * implementation</LI>
 
594
     * </UL>
 
595
     */
 
596
    public abstract int getJobProgramStatus(String jobId) throws DrmaaException;
 
597
    
 
598
    /**
 
599
     * If called before init(), this method returns a comma delimited String
 
600
     * containing the contact Strings available from the default DRMAA
 
601
     * implementation, one element per DRM system available. If called after
 
602
     * init(), this method returns the contact String for the DRM system to
 
603
     * which the session is attached. The returned String is implementation
 
604
     * dependent.
 
605
     * @return current contact information for DRM system or a comma delimited
 
606
     * list of possible contact Strings
 
607
     * @throws DrmaaException May be one of the following:
 
608
     * <UL>
 
609
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
610
     * contact the DRM</LI>
 
611
     * <LI>AuthorizationException -- the executing user does not have
 
612
     * sufficient permissions to execute the desired action</LI>
 
613
     * <LI>InternalException -- an error has occured in the DRMAA
 
614
     * implementation</LI>
 
615
     * </UL>
 
616
     */
 
617
    public abstract String getContact();
 
618
    
 
619
    /**
 
620
     * Returns a Version instance containing the major and minor version numbers
 
621
     * of the DRMAA library.  For DRMAA 0.5, major is 0 and minor is 5.
 
622
     * @return the version number as a Version instance
 
623
     * @see Version
 
624
     * @throws DrmaaException May be one of the following:
 
625
     * <UL>
 
626
     * <LI>NoActiveSessionException -- the session has not yet been initialized
 
627
     * or has already been exited</LI>
 
628
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
629
     * contact the DRM</LI>
 
630
     * <LI>AuthorizationException -- the executing user does not have
 
631
     * sufficient permissions to execute the desired action</LI>
 
632
     * <LI>InternalException -- an error has occured in the DRMAA
 
633
     * implementation</LI>
 
634
     * </UL>
 
635
     */
 
636
    public abstract Version getVersion();
 
637
    
 
638
    /**
 
639
     * If called before init(), this method returns a comma delimited list of
 
640
     * available DRM systems, one element per DRM system implementation
 
641
     * provided. If called after init(), this method returns the selected DRM
 
642
     * system. The returned String is implementation dependent.
 
643
     * @return DRM system implementation information
 
644
     * @throws DrmaaException May be one of the following:
 
645
     * <UL>
 
646
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
647
     * contact the DRM</LI>
 
648
     * <LI>AuthorizationException -- the executing user does not have
 
649
     * sufficient permissions to execute the desired action</LI>
 
650
     * <LI>InternalException -- an error has occured in the DRMAA
 
651
     * implementation</LI>
 
652
     * </UL>
 
653
     */
 
654
    public abstract String getDrmSystem();
 
655
    
 
656
    /**
 
657
     * If called before init(), this method returns a comma delimited list of
 
658
     * available DRMAA implementations, one element for each DRMAA
 
659
     * implementation provided.  If called after init(), this method returns the
 
660
     * selected DRMAA implementation.  The returned String is implementation
 
661
     * dependent and may contain the DRM system as a component.
 
662
     * @return DRMAA implementation information
 
663
     * @throws DrmaaException May be one of the following:
 
664
     * <UL>
 
665
     * <LI>DrmCommunicationException -- the DRMAA implementation was unable to
 
666
     * contact the DRM</LI>
 
667
     * <LI>AuthorizationException -- the executing user does not have
 
668
     * sufficient permissions to execute the desired action</LI>
 
669
     * <LI>InternalException -- an error has occured in the DRMAA
 
670
     * implementation</LI>
 
671
     * </UL>
 
672
     */
 
673
    public abstract String getDrmaaImplementation();
 
674
}