org.globus.exec.client
Class GlobusRun

java.lang.Object
  extended byorg.globus.exec.client.GlobusRun
All Implemented Interfaces:
GramJobListener

public class GlobusRun
extends java.lang.Object
implements GramJobListener

This command-line tool requests and submits jobs to a GT4 GRAM server.

Job Service Destruction

Execution errors and user interrupt events are handled by automatically destroying the requested job service(s), unless the -batch option is on the command-line. The -batch option prevents the tool from listening to job state changes and from waiting for the job to finish. If -batch is selected, the command will return as soon as the remote job has been submitted.

The behavior of the tool with respect to job service destruction will vary in response to several kinds of events:

If the virtual machine aborts, that is, stops running without shutting down cleanly, for instance because it received a SIGKILL signal on Unix, then no guarantee can be made about whether or not the job service(s) will be destroyed.

Note: the shutdown behavior explained above cannot be guaranteed if the JVM option -Xrs is entered. The recommended way to disable service destruction is to specify the -batch option on the command-line. Use -help for more help and a list of available options.


Nested Class Summary
private  class GlobusRun.ShutdownHook
           
 
Field Summary
private  boolean batch
           
private static java.lang.String DATE_FORMAT
           
private  boolean delegationEnabled
           
private static java.lang.String descriptionDesc
           
private static java.lang.String DURATION_FORMAT
          Constants for termination time options.
private static java.lang.String ERROR_MESSAGE_PREFIX
           
private static java.lang.String GLOBUS_VERSION
           
private static int GLOBUSRUN_ARG_AUTHENTICATE_ONLY
           
private static int GLOBUSRUN_ARG_BATCH
           
private static int GLOBUSRUN_ARG_DRYRUN
           
private static int GLOBUSRUN_ARG_FULL_DELEGATION
           
private static int GLOBUSRUN_ARG_LIST
           
private static int GLOBUSRUN_ARG_PARSE_ONLY
           
private static int GLOBUSRUN_ARG_QUIET
          Bit masks for command-line options.
private static org.globus.util.I18n i18n
           
private  boolean isInterrupted
           
private  GramJob job
          Job submission member variables.
private static java.lang.String JOB_FAILED
           
private static java.lang.String JOB_STATE_PREFIX
           
private  boolean jobCompleted
           
private  boolean limitedDelegation
           
private static org.apache.commons.logging.Log logger
           
private  boolean noInterruptHandling
          Application error state.
private  boolean normalApplicationEnd
           
private static java.lang.String optionsDesc
           
private  java.lang.String proxyPath
           
private  boolean quiet
           
private static long STATE_CHANGE_BASE_TIMEOUT_MILLIS
           
private  java.lang.String submissionID
           
private static java.lang.String usageDesc
           
 
Constructor Summary
GlobusRun(java.lang.String[] args)
           
 
Method Summary
private  java.lang.String convertEPRtoString(org.apache.axis.message.addressing.EndpointReferenceType endpoint)
           
private  void destroyJob(GramJob job)
          destroys the job WSRF resource Precondition: job ! =null && job.isRequested() && !job.isLocallyDestroyed()
private  void exit(int exitCode)
          Must be used instead of System.exit.
private  GramJob getExistingJob(java.lang.String jobHandle)
           
private  void kill(java.lang.String jobHandle)
           
private  void listUserJobs(org.apache.axis.message.addressing.EndpointReferenceType factoryEndpoint)
           
static void main(java.lang.String[] args)
           
private  void printError(java.lang.String message)
          Print error message with prefix.
private  void printJobFault(GramJob job)
           
private  void printJobState(org.globus.exec.generated.StateEnumeration jobState, boolean holding)
           
private  void printMessage(java.lang.String message)
          Print message to user if not in quiet mode.
private  void processArguments(java.lang.String[] args)
           
private  void processJob(GramJob job, org.apache.axis.message.addressing.EndpointReferenceType factoryEndpoint, boolean batch)
           
private  void refreshJobStatus(GramJob job)
           
private  void release(java.lang.String jobHandle)
           
private  void state(java.lang.String jobHandle)
           
 void stateChanged(GramJob job)
          Callback as a GramJobListener.
private  void submitRSL(org.apache.axis.message.addressing.EndpointReferenceType factoryEndpoint, java.lang.String simpleJobCommandLine, java.io.File rslFile, Authorization authorization, java.lang.Integer xmlSecurity, boolean batchMode, boolean dryRunMode, boolean quiet, java.util.Date duration, java.util.Date terminationDate, int timeout)
           
private  void waitForJobCompletion(long maxWaitPerStateNotificationMillis)
          Since messaging is assumed to be unreliable (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_CHANGE_BASE_TIMEOUT_MILLIS

private static final long STATE_CHANGE_BASE_TIMEOUT_MILLIS
See Also:
Constant Field Values

GLOBUS_VERSION

private static final java.lang.String GLOBUS_VERSION
See Also:
Constant Field Values

logger

private static org.apache.commons.logging.Log logger

job

private GramJob job
Job submission member variables.


jobCompleted

private boolean jobCompleted

batch

private boolean batch

limitedDelegation

private boolean limitedDelegation

delegationEnabled

private boolean delegationEnabled

quiet

private boolean quiet

DURATION_FORMAT

private static final java.lang.String DURATION_FORMAT
Constants for termination time options.

See Also:
Constant Field Values

DATE_FORMAT

private static final java.lang.String DATE_FORMAT
See Also:
Constant Field Values

GLOBUSRUN_ARG_QUIET

private static final int GLOBUSRUN_ARG_QUIET
Bit masks for command-line options.

See Also:
Constant Field Values

GLOBUSRUN_ARG_DRYRUN

private static final int GLOBUSRUN_ARG_DRYRUN
See Also:
Constant Field Values

GLOBUSRUN_ARG_PARSE_ONLY

private static final int GLOBUSRUN_ARG_PARSE_ONLY
See Also:
Constant Field Values

GLOBUSRUN_ARG_AUTHENTICATE_ONLY

private static final int GLOBUSRUN_ARG_AUTHENTICATE_ONLY
See Also:
Constant Field Values

GLOBUSRUN_ARG_BATCH

private static final int GLOBUSRUN_ARG_BATCH
See Also:
Constant Field Values

GLOBUSRUN_ARG_FULL_DELEGATION

private static final int GLOBUSRUN_ARG_FULL_DELEGATION
See Also:
Constant Field Values

GLOBUSRUN_ARG_LIST

private static final int GLOBUSRUN_ARG_LIST
See Also:
Constant Field Values

submissionID

private java.lang.String submissionID

usageDesc

private static final java.lang.String usageDesc
See Also:
Constant Field Values

descriptionDesc

private static final java.lang.String descriptionDesc
See Also:
Constant Field Values

optionsDesc

private static final java.lang.String optionsDesc

ERROR_MESSAGE_PREFIX

private static final java.lang.String ERROR_MESSAGE_PREFIX
See Also:
Constant Field Values

JOB_FAILED

private static final java.lang.String JOB_FAILED
See Also:
Constant Field Values

JOB_STATE_PREFIX

private static final java.lang.String JOB_STATE_PREFIX
See Also:
Constant Field Values

noInterruptHandling

private boolean noInterruptHandling
Application error state.


isInterrupted

private boolean isInterrupted

normalApplicationEnd

private boolean normalApplicationEnd

proxyPath

private java.lang.String proxyPath

i18n

private static org.globus.util.I18n i18n
Constructor Detail

GlobusRun

public GlobusRun(java.lang.String[] args)
Method Detail

exit

private void exit(int exitCode)
Must be used instead of System.exit. Marks the application as not being interrupted. In this way it is possible to determine when the application exits normally or because of an error as opposed to being interrupted for instance with Ctrl+C.

Parameters:
exitCode - the exit code of the application. If <=0 then the application will be marked as ending normally (i.e. no error).

main

public static void main(java.lang.String[] args)

processArguments

private void processArguments(java.lang.String[] args)

listUserJobs

private void listUserJobs(org.apache.axis.message.addressing.EndpointReferenceType factoryEndpoint)

release

private void release(java.lang.String jobHandle)

kill

private void kill(java.lang.String jobHandle)

state

private void state(java.lang.String jobHandle)

refreshJobStatus

private void refreshJobStatus(GramJob job)

getExistingJob

private GramJob getExistingJob(java.lang.String jobHandle)

submitRSL

private void submitRSL(org.apache.axis.message.addressing.EndpointReferenceType factoryEndpoint,
                       java.lang.String simpleJobCommandLine,
                       java.io.File rslFile,
                       Authorization authorization,
                       java.lang.Integer xmlSecurity,
                       boolean batchMode,
                       boolean dryRunMode,
                       boolean quiet,
                       java.util.Date duration,
                       java.util.Date terminationDate,
                       int timeout)

processJob

private void processJob(GramJob job,
                        org.apache.axis.message.addressing.EndpointReferenceType factoryEndpoint,
                        boolean batch)

waitForJobCompletion

private void waitForJobCompletion(long maxWaitPerStateNotificationMillis)
Since messaging is assumed to be unreliable (i.e. a notification could very well be lost), we implement policy of pulling the remote state when a given waited-for notification has not has been received after a timeout. Note: this could however have the side-effect of hiding bugs in the service-side notification implementation. The base delay in parameter is doubled each time the wait times out (binary exponential backoff). When a state change notification is received, the time out delay is reset to the base value.

Parameters:
maxWaitPerStateNotificationMillis - long base timeout for each state transition before pulling the state from the service

stateChanged

public void stateChanged(GramJob job)
Callback as a GramJobListener. Will not be called in batch mode.

Specified by:
stateChanged in interface GramJobListener
Parameters:
job - The GramJob whose status has changed.

printMessage

private void printMessage(java.lang.String message)
Print message to user if not in quiet mode.

Parameters:
message - the message to send to stdout.

printError

private void printError(java.lang.String message)
Print error message with prefix.


printJobState

private void printJobState(org.globus.exec.generated.StateEnumeration jobState,
                           boolean holding)

printJobFault

private void printJobFault(GramJob job)

convertEPRtoString

private java.lang.String convertEPRtoString(org.apache.axis.message.addressing.EndpointReferenceType endpoint)
                                     throws java.lang.Exception
Throws:
java.lang.Exception

destroyJob

private void destroyJob(GramJob job)
                 throws java.lang.Exception
destroys the job WSRF resource Precondition: job ! =null && job.isRequested() && !job.isLocallyDestroyed()

Throws:
java.lang.Exception