org.globus.gram
Class GramJob

java.lang.Object
  extended by org.globus.gram.GramJob
All Implemented Interfaces:
GRAMConstants
Direct Known Subclasses:
GramJobRun

public class GramJob
extends Object
implements GRAMConstants

This class represents a simple gram job. It allows for submitting a job to a gatekeeper, canceling it, sending a signal command and registering and unregistering from callback.


Field Summary
protected  int error
           
protected  int status
           
 
Fields inherited from interface org.globus.gram.internal.GRAMConstants
SIGNAL_CANCEL, SIGNAL_COMMIT_END, SIGNAL_COMMIT_EXTEND, SIGNAL_COMMIT_REQUEST, SIGNAL_PRIORITY, SIGNAL_RESUME, SIGNAL_STDIO_SIZE, SIGNAL_STDIO_UPDATE, SIGNAL_STOP_MANAGER, SIGNAL_SUSPEND, STATUS_ACTIVE, STATUS_ALL, STATUS_DONE, STATUS_FAILED, STATUS_PENDING, STATUS_STAGE_IN, STATUS_STAGE_OUT, STATUS_SUSPENDED, STATUS_UNSUBMITTED
 
Constructor Summary
GramJob(GSSCredential cred, String rsl)
          Creates a gram job with specified rsl and user credentials.
GramJob(String rsl)
          Creates a gram job with specified rsl with default user credentials.
 
Method Summary
 void addListener(GramJobListener listener)
          Add a listener to the GramJob.
 void bind()
          Registers a callback listener for this job.
 void cancel()
          Cancels a job.
 GSSCredential getCredentials()
          Gets the credentials of this job.
 int getError()
          Gets the error of the job.
 GlobusURL getID()
          Gets the job handle of this job.
 String getIDAsString()
          Gets the job handle of this job and returns it as a string representaion.
 String getRSL()
          Gets the rsl of this job.
 int getStatus()
          Gets the current status of this job.
 String getStatusAsString()
          Get the status of the GramJob.
static String getStatusAsString(int status)
          Convert the status of a GramJob from an integer to a string.
 void removeListener(GramJobListener listener)
          Remove a listener from the GramJob.
 void request(String contact)
          Submits a job to the specified gatekeeper as an interactive job.
 void request(String contact, boolean batch)
          Submits a job to the specified gatekeeper either as an interactive or batch job.
 void request(String contact, boolean batch, boolean limitedDelegation)
          Submits a job to the specified gatekeeper either as an interactive or batch job.
 void setCredentials(GSSCredential credential)
          Sets credentials of the job
protected  void setError(int code)
          Sets the error code of the job.
 void setID(String jobUrl)
          Sets the job handle.
protected  void setStatus(int status)
          Sets the status of the job.
 int signal(int signal)
          Sends a signal command to the job.
 int signal(int signal, String arg)
          Sends a signal command to the job.
 String toString()
          Returns string representation of this job.
 void unbind()
          Unregisters a callback listener for this job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

status

protected int status

error

protected int error
Constructor Detail

GramJob

public GramJob(String rsl)
Creates a gram job with specified rsl with default user credentials.

Parameters:
rsl - resource specification string

GramJob

public GramJob(GSSCredential cred,
               String rsl)
Creates a gram job with specified rsl and user credentials.

Parameters:
cred - user credentials
rsl - resource specification string
Method Detail

addListener

public void addListener(GramJobListener listener)
Add a listener to the GramJob. The listener will be notified whenever the status of the GramJob changes.

Parameters:
listener - The object that wishes to receive status updates.
See Also:
GramJobListener

removeListener

public void removeListener(GramJobListener listener)
Remove a listener from the GramJob. The listener will no longer be notified of status changes for the GramJob.

Parameters:
listener - The object that wishes to stop receiving status updates.
See Also:
GramJobListener

getRSL

public String getRSL()
Gets the rsl of this job.

Returns:
resource specification string

getCredentials

public GSSCredential getCredentials()
Gets the credentials of this job.

Returns:
job credentials. If null none were set.

setCredentials

public void setCredentials(GSSCredential credential)
Sets credentials of the job

Parameters:
credential - user credentials
Throws:
IllegalArgumentException - if credentials are already set

setID

public void setID(String jobUrl)
           throws MalformedURLException
Sets the job handle. It is automatically set after the job successfuly has been successfuly started on a gatekeeper.

Parameters:
jobUrl - job handle in form of url
Throws:
MalformedURLException - if the job handle is invalid

getID

public GlobusURL getID()
Gets the job handle of this job.

Returns:
job handle

getIDAsString

public String getIDAsString()
Gets the job handle of this job and returns it as a string representaion.

Returns:
job handle as string

getStatus

public int getStatus()
Gets the current status of this job.

Returns:
current job status

setStatus

protected void setStatus(int status)
Sets the status of the job. User should not call this function.

Parameters:
status - status of the job

request

public void request(String contact)
             throws GramException,
                    GSSException
Submits a job to the specified gatekeeper as an interactive job. Performs limited delegation.

Parameters:
contact - the resource manager contact. The contact can be specified in number of ways for 1.1.3 gatekeepers:
host
host:port
host:port/service
host/service
host:/service
host::subject
host:port:subject
host/service:subject
host:/service:subject
host:port/service:subject
For 1.1.2 gatekeepers full contact string must be specifed.
Throws:
GramException - if error occurs during job submission.
GSSException - if user credentials are invalid.

request

public void request(String contact,
                    boolean batch)
             throws GramException,
                    GSSException
Submits a job to the specified gatekeeper either as an interactive or batch job. Performs limited delegation.

Parameters:
contact - the resource manager contact.
batch - specifies if the job should be submitted as a batch job.
Throws:
GramException - if error occurs during job submission.
GSSException - if user credentials are invalid.
See Also:
for detailed resource manager contact specification.

request

public void request(String contact,
                    boolean batch,
                    boolean limitedDelegation)
             throws GramException,
                    GSSException
Submits a job to the specified gatekeeper either as an interactive or batch job. It can perform limited or full delegation.

Parameters:
contact - the resource manager contact.
batch - specifies if the job should be submitted as a batch job.
limitedDelegation - true for limited delegation, false for full delegation.
Throws:
GramException - if error occurs during job submission.
GSSException - if user credentials are invalid.
See Also:
for detailed resource manager contact specification.

cancel

public void cancel()
            throws GramException,
                   GSSException
Cancels a job.

Throws:
GramException - if error occurs during job cancelation.
GSSException - if user credentials are invalid.

bind

public void bind()
          throws GramException,
                 GSSException
Registers a callback listener for this job. (Reconnects to the job)

Throws:
GramException - if error occurs during job registration.
GSSException - if user credentials are invalid.

unbind

public void unbind()
            throws GramException,
                   GSSException
Unregisters a callback listener for this job. (Disconnects from the job)

Throws:
GramException - if error occurs during job unregistration.
GSSException - if user credentials are invalid.

signal

public int signal(int signal,
                  String arg)
           throws GramException,
                  GSSException
Sends a signal command to the job.

Parameters:
signal - signal type
arg - argument of signal
Throws:
GramException - if error occurs during signalization.
GSSException - if user credentials are invalid.

signal

public int signal(int signal)
           throws GramException,
                  GSSException
Sends a signal command to the job.

Parameters:
signal - signal type
Throws:
GramException - if error occurs during signalization.
GSSException - if user credentials are invalid.

setError

protected void setError(int code)
Sets the error code of the job. Note: User should not use this method.

Parameters:
code - error code

getError

public int getError()
Gets the error of the job.

Returns:
error number of the job.

toString

public String toString()
Returns string representation of this job.

Overrides:
toString in class Object
Returns:
string representation of this job. Useful for debugging.

getStatusAsString

public String getStatusAsString()
Get the status of the GramJob.

Returns:
string representing the status of the GramJob. This String is useful for user-readable output.

getStatusAsString

public static String getStatusAsString(int status)
Convert the status of a GramJob from an integer to a string. This method is not typically called by users.

Returns:
string representing the status of the GramJob passed as an argument.