1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
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
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.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
32
package com.sun.grid.drmaa;
34
import java.util.HashMap;
37
import org.ggf.drmaa.*;
40
* This class provides information about a completed Grid Engine job.
41
* @see org.ggf.drmaa.JobInfo
42
* @author dan.templeton@sun.com
46
public class JobInfoImpl implements JobInfo {
47
private static final int EXITED_BIT = 0x00000001;
48
private static final int SIGNALED_BIT = 0x00000002;
49
private static final int COREDUMP_BIT = 0x00000004;
50
private static final int NEVERRAN_BIT = 0x00000008;
51
/* POSIX exit status has only 8 bit */
52
private static final int EXIT_STATUS_BITS = 0x00000FF0;
53
private static final int EXIT_STATUS_OFFSET = 4;
54
private final String signal;
55
private final int status;
56
private final String jobId;
57
private final Map resources;
60
* Creates a new instance of JobInfoImpl
61
* @param jobId the job id string
62
* @param status an opaque status code
63
* @param resourceUsage an array of name=value resource usage pairs
64
* @param signal the string description of the terminating signal
66
JobInfoImpl(String jobId, int status, String[] resourceUsage, String signal) {
69
this.resources = nameValuesToMap(resourceUsage);
73
public int getExitStatus() {
75
throw new IllegalStateException();
78
return ((status & EXIT_STATUS_BITS) >> EXIT_STATUS_OFFSET);
82
* If hasSignaled() returns true, this method returns a representation of
83
* the signal that caused the termination of the job. For signals declared
84
* by POSIX or otherwise known to Grid Engine, the symbolic names are
85
* returned (e.g., SIGABRT, SIGALRM).<BR>
86
* For signals not known by Grid Engine, the string "unknown
87
* signal" is returned.
88
* @return the name of the terminating signal
90
public String getTerminatingSignal() {
92
throw new IllegalStateException();
98
public boolean hasCoreDump() {
99
return ((status & COREDUMP_BIT) != 0);
102
public boolean hasExited() {
103
return ((status & EXITED_BIT) != 0);
106
public boolean hasSignaled() {
107
return ((status & SIGNALED_BIT) != 0);
110
public boolean wasAborted() {
111
return ((status & NEVERRAN_BIT) != 0);
114
public String getJobId() {
118
public Map getResourceUsage() {
122
private static Map nameValuesToMap(String[] nameValuePairs) {
125
if (nameValuePairs != null) {
128
for (int count = 0; count < nameValuePairs.length; count++) {
129
int equals = nameValuePairs[count].indexOf('=');
130
map.put(nameValuePairs[count].substring(0, equals), nameValuePairs[count].substring(equals + 1));