org.globus.exec.client
Class GramJob

java.lang.Object
  extended byorg.globus.exec.client.GramJob

public class GramJob
extends Object

This class represents a simple gram job. It allows for submitting a job,canceling it, sending a signal command and registering and unregistering job state chang listeners. This class hides the middleware API from the consumer.


Field Summary
static Authorization DEFAULT_AUTHZ
           
static int DEFAULT_DURATION_HOURS
           
static Integer DEFAULT_MSG_PROTECTION
           
static int DEFAULT_TIMEOUT
           
static boolean NOTIF_CONSUMER_SECURITY
           
 
Constructor Summary
GramJob()
          Creates a gram job with no RSL.
GramJob(JobDescriptionType jobDescription)
          Creates a gram job with specified job description.
 
Method Summary
 void addListener(GramJobListener listener)
          Add a listener to the GramJob.
 void addStderrPath(String path)
          Preconditionthe job has not been submitted
 void addStdoutPath(String path)
          Preconditionthe job has not been submitted
 void bind()
          Registers a callback listener for this job.
 void cancel()
          Cancels a job.
 void deliver(List topicPath, EndpointReferenceType producer, Object message)
          Deliver the notification message
 void destroy()
          Precondition: isRequested() Postcondition: isLocallyDestroyed()
 Authorization getAuthorization()
           
 GSSCredential getCredentials()
          Gets the credentials of this job.
 String getDelegationLevel()
           
 JobDescriptionType getDescription()
           
 EndpointReferenceType getEndpoint()
          Precondition: isRequested()
 int getError()
          Gets the error of the job.
 BaseFaultType getFault()
          Return information about the cause of a job failure (when getStateAsString.equals(StateEnumeration._Failed))
 String getHandle()
          Can be used instead of #getEndpointReference Precondition: isRequested()
 Integer getMessageProtectionType()
           
static List getStartedJobs(EndpointReferenceType factoryEndpoint)
           
 StateEnumeration getState()
          Get the current state of this job.
 boolean isLocallyDestroyed()
           
 boolean isPersonal()
           
 boolean isRequested()
          Returns true if the job has been requested.
 boolean isStarted()
           
 void prependBaseURLtoStageInSources(String baseURL)
           
 void prependBaseURLtoStageOutDestinations(String baseURL)
           
 void refreshStatus()
          Asks the job service for its state,i.e.
 void removeListener(GramJobListener listener)
          Remove a listener from the GramJob.
 void setAuthorization(Authorization auth)
           
 void setCredentials(GSSCredential newProxy)
          Sets credentials of the job
 void setDryRun(boolean enabled)
          Preconditionthe job has not been submitted
 void setDuration(Date duration)
          The default lifetime of the resource is 24 hours.
 void setEndpoint(EndpointReferenceType endpoint)
           
protected  void setError(int code)
          Sets the error code of the job.
 void setHandle(String resourceHandle)
          Can be used instead of #setEndpointReference
 void setMessageProtectionType(Integer protectionType)
           
 void setPersonal(boolean personal)
           
 void setServiceTerminationTime()
          Set TerminationTime RP of managed job service based on parameters specified as JavaBean properties on this object.
 void setStarted(boolean jobIsStarted)
           
 void setTerminationTime(Date termTime)
           
 void setTimeOut(int timeout)
          Set timeout for HTTP socket.
 void start()
          postcondition: isStarted()
 void submit(EndpointReferenceType factoryEndpoint)
          Submits an interactive i.e.
 void submit(EndpointReferenceType factoryEndpoint, boolean batch)
          Submits a job with limited delegation.
 void submit(EndpointReferenceType factoryEndpoint, boolean batch, boolean limitedDelegation)
           
 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

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
See Also:
Constant Field Values

NOTIF_CONSUMER_SECURITY

public static final boolean NOTIF_CONSUMER_SECURITY
See Also:
Constant Field Values

DEFAULT_MSG_PROTECTION

public static final Integer DEFAULT_MSG_PROTECTION

DEFAULT_AUTHZ

public static final Authorization DEFAULT_AUTHZ

DEFAULT_DURATION_HOURS

public static final int DEFAULT_DURATION_HOURS
See Also:
Constant Field Values
Constructor Detail

GramJob

public GramJob()
Creates a gram job with no RSL. This default constructor is used in conjunction with #setEndpoint().


GramJob

public GramJob(JobDescriptionType jobDescription)
Creates a gram job with specified job description.

Method Detail

addListener

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

Parameters:
listener - The object that wishes to receive state updates.
See Also:
org.globus.gram.GramJobListener

removeListener

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

Parameters:
listener - The object that wishes to stop receiving state updates.
See Also:
org.globus.gram.GramJobListener

getCredentials

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

Returns:
job credentials. If null none were set.

setCredentials

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

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

getState

public StateEnumeration getState()
Get the current state of this job.

Returns:
current job state

submit

public void submit(EndpointReferenceType factoryEndpoint)
            throws Exception
Submits an interactive i.e. non-batch job with limited delegation

Throws:
Exception
See Also:
for explanation of parameters

submit

public void submit(EndpointReferenceType factoryEndpoint,
                   boolean batch)
            throws Exception
Submits a job with limited delegation.

Throws:
Exception
See Also:
for explanation of parameters

submit

public void submit(EndpointReferenceType factoryEndpoint,
                   boolean batch,
                   boolean limitedDelegation)
            throws Exception
Parameters:
factoryEndpoint - the resource manager service endpoint. The service address can be specified in the following ways:
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
batch - specifies if the job should be submitted as a batch job.
limitedDelegation - true for limited delegation, false for full delegation.
Throws:
Exception
See Also:
for detailed resource manager contact specification.
To do:
add throws ...Exception for invalid credentials? Submits a job to the specified service either as an interactive or batch job. It can perform limited or full delegation.

addStdoutPath

public void addStdoutPath(String path)
Preconditionthe job has not been submitted

Parameters:
path - String

addStderrPath

public void addStderrPath(String path)
Preconditionthe job has not been submitted

Parameters:
path - String

prependBaseURLtoStageInSources

public void prependBaseURLtoStageInSources(String baseURL)

prependBaseURLtoStageOutDestinations

public void prependBaseURLtoStageOutDestinations(String baseURL)

setDryRun

public void setDryRun(boolean enabled)
Preconditionthe job has not been submitted


getDescription

public JobDescriptionType getDescription()
                                  throws Exception
Returns:
the job description
Throws:
Exception

isRequested

public boolean isRequested()
Returns true if the job has been requested. Useful to determine if destroy() can be called when it is not obvious.


setPersonal

public void setPersonal(boolean personal)

isPersonal

public boolean isPersonal()

cancel

public void cancel()
            throws Exception
Cancels a job.

Throws:
Exception

bind

public void bind()
          throws Exception
Registers a callback listener for this job. (Reconnects to the job) Precondition this.jobEndpointReference != null

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

unbind

public void unbind()
            throws NoSuchResourceException,
                   Exception
Unregisters a callback listener for this job. (disconnects from the job) Precondition ClientNotificationConsumer.isListening()

Throws:
NoSuchResourceException
Exception

destroy

public void destroy()
             throws Exception
Precondition: isRequested() Postcondition: isLocallyDestroyed()

Throws:
GramException - if error occurs during job service destruction.
Exception

isLocallyDestroyed

public boolean isLocallyDestroyed()
Returns:
boolean true if #destroy() destroy() has been called

start

public void start()
           throws Exception
postcondition: isStarted()

Throws:
Exception

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.

getFault

public BaseFaultType getFault()
Return information about the cause of a job failure (when getStateAsString.equals(StateEnumeration._Failed))


getEndpoint

public EndpointReferenceType getEndpoint()
Precondition: isRequested()


setEndpoint

public void setEndpoint(EndpointReferenceType endpoint)
                 throws Exception
Throws:
Exception

getHandle

public String getHandle()
Can be used instead of #getEndpointReference Precondition: isRequested()


setHandle

public void setHandle(String resourceHandle)
               throws Exception
Can be used instead of #setEndpointReference

Throws:
Exception

setStarted

public void setStarted(boolean jobIsStarted)

isStarted

public boolean isStarted()

setTimeOut

public void setTimeOut(int timeout)
Set timeout for HTTP socket. Default is 120000 (2 minutes).

Parameters:
timeout - the timeout value, in milliseconds.

toString

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

Returns:
string representation of this job. Useful for debugging.

deliver

public void deliver(List topicPath,
                    EndpointReferenceType producer,
                    Object message)
Deliver the notification message

Parameters:
topicPath - The topic path for the topic that generated the notification
producer - The producer endpoint reference
message - The notification message

refreshStatus

public void refreshStatus()
                   throws Exception
Asks the job service for its state,i.e. its state and the cause if the state is 'Failed'. This is useful when subscribing to notifications is impossible but an immediate result is needed. Preconditionjob has been submitted

Throws:
Exception - if the service data cannot be fetched or the job state not extracted from the data.

getStartedJobs

public static List getStartedJobs(EndpointReferenceType factoryEndpoint)
                           throws Exception
Throws:
Exception

setAuthorization

public void setAuthorization(Authorization auth)

getAuthorization

public Authorization getAuthorization()

setMessageProtectionType

public void setMessageProtectionType(Integer protectionType)

getMessageProtectionType

public Integer getMessageProtectionType()

getDelegationLevel

public String getDelegationLevel()

setDuration

public void setDuration(Date duration)
The default lifetime of the resource is 24 hours.

Parameters:
duration - the duration after which the job service should be destroyed. The hours and minutes will be used.

setTerminationTime

public void setTerminationTime(Date termTime)

setServiceTerminationTime

public void setServiceTerminationTime()
                               throws Exception
Set TerminationTime RP of managed job service based on parameters specified as JavaBean properties on this object. Preconditionjob has been requested

Returns:
Calendar
Throws:
Exception