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

« back to all changes in this revision

Viewing changes to source/libs/jdrmaa/src/com/sun/grid/drmaa/howto/Howto5.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
/*************************************************************************
 
2
 *
 
3
 *  The Contents of this file are made available subject to the terms of
 
4
 *  the Sun Industry Standards Source License Version 1.2
 
5
 *
 
6
 *  Sun Microsystems Inc., March, 2001
 
7
 *
 
8
 *
 
9
 *  Sun Industry Standards Source License Version 1.2
 
10
 *  =================================================
 
11
 *  The contents of this file are subject to the Sun Industry Standards
 
12
 *  Source License Version 1.2 (the "License"); You may not use this file
 
13
 *  except in compliance with the License. You may obtain a copy of the
 
14
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
15
 *
 
16
 *  Software provided under this License is provided on an "AS IS" basis,
 
17
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
18
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
19
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
20
 *  See the License for the specific provisions governing your rights and
 
21
 *  obligations concerning the Software.
 
22
 *
 
23
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
24
 *
 
25
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
26
 *
 
27
 *   All Rights Reserved.
 
28
 *
 
29
 ************************************************************************/
 
30
/*___INFO__MARK_END__*/
 
31
package com.sun.grid.drmaa.howto;
 
32
 
 
33
import java.util.Collections;
 
34
import org.ggf.drmaa.DrmaaException;
 
35
import org.ggf.drmaa.JobTemplate;
 
36
import org.ggf.drmaa.Session;
 
37
import org.ggf.drmaa.SessionFactory;
 
38
 
 
39
public class Howto5 {
 
40
   public static void main(String[] args) {
 
41
      SessionFactory factory = SessionFactory.getFactory();
 
42
      Session session = factory.getSession();
 
43
      
 
44
      try {
 
45
         session.init("");
 
46
         JobTemplate jt = session.createJobTemplate();
 
47
         jt.setRemoteCommand("sleeper.sh");
 
48
         jt.setArgs(Collections.singletonList("5"));
 
49
         
 
50
         String id = session.runJob(jt);
 
51
         
 
52
         System.out.println("Your job has been submitted with id " + id);
 
53
         
 
54
         try {
 
55
            Thread.sleep(20 * 1000);
 
56
         } catch (InterruptedException e) {
 
57
            // Don't care
 
58
         }
 
59
         
 
60
         int status = session.getJobProgramStatus(id);
 
61
         
 
62
         switch (status) {
 
63
            case Session.UNDETERMINED:
 
64
               System.out.println("Job status cannot be determined\n");
 
65
               break;
 
66
            case Session.QUEUED_ACTIVE:
 
67
               System.out.println("Job is queued and active\n");
 
68
               break;
 
69
            case Session.SYSTEM_ON_HOLD:
 
70
               System.out.println("Job is queued and in system hold\n");
 
71
               break;
 
72
            case Session.USER_ON_HOLD:
 
73
               System.out.println("Job is queued and in user hold\n");
 
74
               break;
 
75
            case Session.USER_SYSTEM_ON_HOLD:
 
76
               System.out.println("Job is queued and in user and system hold\n");
 
77
               break;
 
78
            case Session.RUNNING:
 
79
               System.out.println("Job is running\n");
 
80
               break;
 
81
            case Session.SYSTEM_SUSPENDED:
 
82
               System.out.println("Job is system suspended\n");
 
83
               break;
 
84
            case Session.USER_SUSPENDED:
 
85
               System.out.println("Job is user suspended\n");
 
86
               break;
 
87
            case Session.USER_SYSTEM_SUSPENDED:
 
88
               System.out.println("Job is user and system suspended\n");
 
89
               break;
 
90
            case Session.DONE:
 
91
               System.out.println("Job finished normally\n");
 
92
               break;
 
93
            case Session.FAILED:
 
94
               System.out.println("Job finished, but failed\n");
 
95
               break;
 
96
         } /* switch */
 
97
         
 
98
         session.deleteJobTemplate(jt);
 
99
         session.exit();
 
100
      } catch (DrmaaException e) {
 
101
         System.out.println("Error: " + e.getMessage());
 
102
      }
 
103
   }
 
104
}