org.globus.ogsa.impl.base.gram.client
Class GramJob

java.lang.Object
  extended byorg.globus.ogsa.impl.core.service.ServicePropertiesImpl
      extended byorg.globus.ogsa.impl.base.gram.client.GramJob
All Implemented Interfaces:
NotificationSinkCallback, ServiceProperties
Direct Known Subclasses:
GramJobRun

public class GramJob
extends ServicePropertiesImpl
implements NotificationSinkCallback

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
static ExtendedDateTimeType DEFAULT_TERMINATION_TIME
           
static int DEFAULT_TIMEOUT
           
protected  int error
           
protected  GrimProxyPolicyHandler grimPolicyHandler
           
protected  java.lang.String notificationSinkID
           
protected  NotificationSinkManager notificationSinkManager
           
protected  org.ietf.jgss.GSSCredential proxy
           
protected  ManagedJobServiceGridLocator serviceLocator
           
protected  int status
           
 
Fields inherited from interface org.globus.ogsa.ServiceProperties
ACTIVATE_ON_STARTUP, ACTIVATION, BASE_CLASS_NAME, BOOTSTRAP, CONFIG_PATH, CONTAINS_REFERENCE, CREATION_EXTENSIBILITY, CREATION_EXTENSIBILITY_OUTPUT, CUSTOM_EXTENSIBILITY_DESERIALIZER, CUSTOM_EXTENSIBILITY_SERIALIZER, CUSTOM_MAPPING_REGISTERED, DEACTIVATED_PERSISTENT, DEACTIVATED_STATE, DEACTIVATED_TRANSIENT, DEACTIVATION, DESTROY_LISTENER, DESTRUCTION_SKELETON, DISABLE_FACTORY_REGISTRY, ENDPOINT, ENTRY_INSTANCE_CREATION, FACTORY, FACTORY_CALLBACK, FACTORY_HANDLE, FACTORY_PROVIDER, FACTORY_REGISTRY, GSR_DESCRIPTION, HANDLE, HANDLE_PORT, HANDLE_PROTOCOL, INSTANCE_CLASS, INSTANCE_DEACTIVATION, INSTANCE_GSR_DESCRIPTION, INSTANCE_LIFECYCLE, INSTANCE_PORT_TYPE, INSTANCE_PORT_TYPE_NS, INSTANCE_PREFIX, INSTANCE_REGISTRY, INSTANCE_SCHEMA_PATH, INSTANCE_WSDL, INTERFACE_CLASS_NAME, INVOCATION_ID, LAZY_CREATION, LIFECYCLE, LIFECYCLE_MONITOR, LIFECYCLE_MONITOR_CLASS, NAME, NOTIFICATION_ENGINE, NOTIFICATION_FACTORY, NOTIFICATION_SOURCE, OPERATION_PROVIDERS, PERSISTENT, PERSISTENT_PROPERTIES, PORT, PORT_TYPE, PORT_TYPE_NS, PRIMARY_KEY, PROTOCOL, QUERY_ENGINE, REDIRECT_RESOLVER, REGISTRY, RESOLVER_CACHE, ROUTER_HEADER, ROUTER_VIA, SCHEMA_LOCATION, SCHEMA_PATH, SERVICE_ACTIVATOR, SERVICE_DATA, SERVICE_DEPLOYMENT, SERVICE_GROUP_ENTRY, SERVICE_GROUP_PROVIDER, SERVICE_LOADER, SERVICE_NODE, SINK_ID, STARTUP_STATE, SWEEP_SERVICE_DATA, TIMEOUT, TIMESTAMP, TRANSIENT, TYPE, USER, WEBSTART_PANEL_NAME, WEBSTART_URL, WSDL
 
Constructor Summary
GramJob(org.ietf.jgss.GSSCredential proxy, java.lang.String rsl)
          Creates a gram job with specified rsl and user credentials.
GramJob(java.lang.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 addStderrPath(java.lang.String variableName, java.lang.String path)
          Adds a path in the stderr clause of the RSL.
 void addStdoutPath(java.lang.String variableName, java.lang.String path)
          Adds a path in the stdout clause of the RSL.
 void bind()
          Registers a callback listener for this job.
 void cancel()
          Cancels a job.
 void deliverNotification(ExtensibilityType message)
           
 void destroy()
          Precondition: isRequested() && !isDestroyed() Postcondition: isDestroyed()
 Authorization getAuthorization()
           
 org.ietf.jgss.GSSCredential getCredentials()
          Gets the credentials of this job.
 int getError()
          Gets the error of the job.
 FaultType getFault()
          Return information about the cause of a job failure (when getStatusAsString.equals(JobStateType._Failed))
 boolean getGrimChecks()
           
 HandleType getHandle()
          Precondition: isRequested()
 GlobusURL getID()
          Gets the job handle of this job.
 java.lang.String getIDAsString()
          Gets the job handle of this job and returns it as a string representaion.
 java.lang.Integer getMessageProtectionType()
           
 java.lang.String getRSL()
          Gets the rsl of this job.
 GramJobAttributes getRSLAttributes()
          Returns the current RSL of the job, that is the input RSL plus substitution definitions and references if any have been added via the corresponding methods, or the RSL of the submitted job if it is has been refreshed (which may features substituted values).
static java.util.List getStartedJobs(java.lang.String factoryHandle)
           
static java.util.List getStartedJobs(java.lang.String factoryHandle, org.ietf.jgss.GSSCredential proxy)
           
 int getStatus()
          Gets the current status of this job.
 java.lang.String getStatusAsString()
          Get the status of the GramJob.
static java.lang.String getStatusAsString(int status)
          Convert the status of a GramJob from an integer to a string.
static int getStatusStringAsInt(java.lang.String statusString)
           
 boolean isDestroyed()
           
 boolean isPersonal()
           
 boolean isRequested()
          Returns true if the job has been requested.
 void refreshRSLAttributes()
          Gets submitted RSL from remote Managed Job Service.
 void refreshStatus()
          Asks the job service for its state.
 void removeListener(GramJobListener listener)
          Remove a listener from the GramJob.
 void request(java.lang.String contact)
          Submits a job to the specified gatekeeper as an interactive job.
 void request(java.lang.String contact, boolean batch)
          Submits a job to the specified gatekeeper either as an interactive or batch job.
 void request(java.lang.String contact, boolean batch, boolean limitedDelegation)
          Submits a job to the specified gatekeeper either as an interactive or batch job.
 void request(java.net.URL factoryHandle)
          Submits a job to the specified gatekeeper as an interactive job.
 void request(java.net.URL factoryHandle, boolean batch)
          Submits a job to the specified gatekeeper either as an interactive or batch job.
 void request(java.net.URL factoryHandle, boolean batch, boolean limitedDelegation)
          Submits a job to the specified gatekeeper either as an interactive or batch job.
 void setAuthorization(Authorization auth)
           
 void setCredentials(org.ietf.jgss.GSSCredential newProxy)
          Sets credentials of the job
 void setDryRun(boolean dryRun)
           
protected  void setError(int code)
          Sets the error code of the job.
 void setGrimChecks(boolean grimChecks)
           
 void setHandle(java.lang.String GSH)
           
 void setID(java.lang.String jobUrl)
          Sets the job handle.
 void setMessageProtectionType(java.lang.Integer protectionType)
           
 void setPersonal(boolean personal)
           
 void setServiceDuration(java.util.Date duration)
           
 void setServiceTerminationTime(java.util.Date dateTime)
           
protected  void setStatus(int status)
          Sets the status of the job.
 void setSubstitutionDefinition(java.lang.String substitutionName, java.lang.String substitutionValue)
          Sets substitution definition if exists or adds to RSL if does not.
 void setTimeOut(int timeout)
          Set timeout for HTTP socket.
 int signal(int signal)
          Sends a signal command to the job.
 int signal(int signal, java.lang.String arg)
          Sends a signal command to the job.
 void start()
           
 java.lang.String toString()
          Returns string representation of this job.
 void unbind()
          Unregisters a callback listener for this job.
 
Methods inherited from class org.globus.ogsa.impl.core.service.ServicePropertiesImpl
flush, flush, getPersistentProperty, getProperty, keySet, setPersistentProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.globus.ogsa.ServiceProperties
flush, getPersistentProperty, getProperty, setPersistentProperty, setProperty
 

Field Detail

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
See Also:
Constant Field Values

status

protected int status

error

protected int error

DEFAULT_TERMINATION_TIME

public static final ExtendedDateTimeType DEFAULT_TERMINATION_TIME

proxy

protected org.ietf.jgss.GSSCredential proxy

serviceLocator

protected ManagedJobServiceGridLocator serviceLocator

notificationSinkManager

protected NotificationSinkManager notificationSinkManager

notificationSinkID

protected java.lang.String notificationSinkID

grimPolicyHandler

protected GrimProxyPolicyHandler grimPolicyHandler
Constructor Detail

GramJob

public GramJob(java.lang.String rsl)
Creates a gram job with specified rsl with default user credentials. Currently the rsl is required to be in the new XML-based form. For backwords compatibility this should accept the old format, but the conversion algorithm isn't in place yet.

Parameters:
rsl - resource specification string

GramJob

public GramJob(org.ietf.jgss.GSSCredential proxy,
               java.lang.String rsl)
Creates a gram job with specified rsl and user credentials. Currently the rsl is required to be in the new XML-based form. For backwords compatibility this should accept the old format, but the conversion algorithm isn't in place yet.

Parameters:
proxy - 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:
org.globus.gram.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:
org.globus.gram.GramJobListener

getRSL

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

Returns:
resource specification string

getCredentials

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

Returns:
job credentials. If null none were set.

setCredentials

public void setCredentials(org.ietf.jgss.GSSCredential newProxy)
Sets credentials of the job

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

setID

public void setID(java.lang.String jobUrl)
           throws java.net.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:
java.net.MalformedURLException - if the job handle is invalid

getID

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

Returns:
job handle

getIDAsString

public java.lang.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(java.lang.String contact)
             throws GramException,
                    org.ietf.jgss.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.
org.ietf.jgss.GSSException - if user credentials are invalid.

request

public void request(java.lang.String contact,
                    boolean batch)
             throws GramException,
                    org.ietf.jgss.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.
org.ietf.jgss.GSSException - if user credentials are invalid.
See Also:
for detailed resource manager contact specification.

request

public void request(java.lang.String contact,
                    boolean batch,
                    boolean limitedDelegation)
             throws GramException,
                    org.ietf.jgss.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.
org.ietf.jgss.GSSException - if user credentials are invalid.
See Also:
for detailed resource manager contact specification.

request

public void request(java.net.URL factoryHandle)
             throws GramException,
                    org.ietf.jgss.GSSException
Submits a job to the specified gatekeeper as an interactive job. Performs limited delegation.

Parameters:
factoryHandle - the handle to the job manager factory service
Throws:
GramException - if error occurs during job submission.
org.ietf.jgss.GSSException - if user credentials are invalid.

request

public void request(java.net.URL factoryHandle,
                    boolean batch)
             throws GramException,
                    org.ietf.jgss.GSSException
Submits a job to the specified gatekeeper either as an interactive or batch job. Performs limited delegation.

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

request

public void request(java.net.URL factoryHandle,
                    boolean batch,
                    boolean limitedDelegation)
             throws GramException,
                    org.ietf.jgss.GSSException
Submits a job to the specified gatekeeper either as an interactive or batch job. It can perform limited or full delegation.

Parameters:
factoryHandle - the handle to the job manager factory service
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.
org.ietf.jgss.GSSException - if user credentials are invalid.
See Also:
for detailed resource manager contact specification.

setSubstitutionDefinition

public void setSubstitutionDefinition(java.lang.String substitutionName,
                                      java.lang.String substitutionValue)
                               throws GramException
Sets substitution definition if exists or adds to RSL if does not.

Throws:
GramException

addStdoutPath

public void addStdoutPath(java.lang.String variableName,
                          java.lang.String path)
                   throws GramException
Adds a path in the stdout clause of the RSL.

Parameters:
variableName - name of the variable which value is to be used as the base URL of the complete path to add
path - path element to add to the substituted variable to form the path to add
Throws:
GramException

addStderrPath

public void addStderrPath(java.lang.String variableName,
                          java.lang.String path)
                   throws GramException
Adds a path in the stderr clause of the RSL.

Parameters:
variableName - name of the variable which value is to be used as the base URL of the complete path to add
path - path element to add to the substituted variable to form the path to add
Throws:
GramException

setDryRun

public void setDryRun(boolean dryRun)
               throws GramException
Throws:
GramException

getRSLAttributes

public GramJobAttributes getRSLAttributes()
                                   throws GramException
Returns the current RSL of the job, that is the input RSL plus substitution definitions and references if any have been added via the corresponding methods, or the RSL of the submitted job if it is has been refreshed (which may features substituted values).

Returns:
the current RSL attributes
Throws:
GramException - if needs to parse an RSL string but cannot

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 GramException,
                   org.ietf.jgss.GSSException
Cancels a job.

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

bind

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

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

unbind

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

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

destroy

public void destroy()
             throws GramException
Precondition: isRequested() && !isDestroyed() Postcondition: isDestroyed()

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

isDestroyed

public boolean isDestroyed()

start

public void start()
           throws GramException
Throws:
GramException

signal

public int signal(int signal,
                  java.lang.String arg)
           throws GramException,
                  org.ietf.jgss.GSSException
Sends a signal command to the job.

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

signal

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

Throws:
GramException - if error occurs during signalization.
org.ietf.jgss.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.

getFault

public FaultType getFault()
Return information about the cause of a job failure (when getStatusAsString.equals(JobStateType._Failed))


getHandle

public HandleType getHandle()
Precondition: isRequested()


setHandle

public void setHandle(java.lang.String GSH)
               throws java.lang.Exception
Throws:
java.lang.Exception

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 java.lang.String toString()
Returns string representation of this job.

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

getStatusAsString

public java.lang.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 java.lang.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.

getStatusStringAsInt

public static int getStatusStringAsInt(java.lang.String statusString)

deliverNotification

public void deliverNotification(ExtensibilityType message)

refreshStatus

public void refreshStatus()
                   throws java.lang.Exception
Asks the job service for its state. Useful when cannot subscribe to notifications but need an immediate result.

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

refreshRSLAttributes

public void refreshRSLAttributes()
                          throws java.lang.Exception
Gets submitted RSL from remote Managed Job Service. It is actually not only the final, but substituted RSL. To obtain it call getRSLAttributes afterwards.

Throws:
java.lang.Exception

getStartedJobs

public static java.util.List getStartedJobs(java.lang.String factoryHandle)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

getStartedJobs

public static java.util.List getStartedJobs(java.lang.String factoryHandle,
                                            org.ietf.jgss.GSSCredential proxy)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

setAuthorization

public void setAuthorization(Authorization auth)

getAuthorization

public Authorization getAuthorization()

setGrimChecks

public void setGrimChecks(boolean grimChecks)

getGrimChecks

public boolean getGrimChecks()

setMessageProtectionType

public void setMessageProtectionType(java.lang.Integer protectionType)

getMessageProtectionType

public java.lang.Integer getMessageProtectionType()

setServiceDuration

public void setServiceDuration(java.util.Date duration)
Parameters:
duration - the duration after which the job service should be destroyed. The hours and minutes will be used.

setServiceTerminationTime

public void setServiceTerminationTime(java.util.Date dateTime)
Parameters:
dateTime - the date/time desired for termination of this job service