edu.sdsc.inca.agent.access
Class GlobusNonBlockingJobListener

java.lang.Object
  extended by edu.sdsc.inca.agent.access.GlobusNonBlockingJobListener
All Implemented Interfaces:
org.globus.gram.GramJobListener

public class GlobusNonBlockingJobListener
extends java.lang.Object
implements org.globus.gram.GramJobListener

Subclass of GramJobListener that can be used to create a non-blocking GRAM request. For example,

   GramJob job = new GramJob( rslString );
   GlobusBlockingJobListener listener = new GlobusBlockingJobListener();
   job.addListener( listener );
   job.request( gramContact );
   listener.waitFor();
   // job is now active
 
Based on Java COG code for globusrun.

Author:
Shava Smallen <ssmallen@sdsc.edu>

Constructor Summary
GlobusNonBlockingJobListener()
           
 
Method Summary
 int getStatus()
          Get the status code for the Globus GRAM job.
 boolean isActive()
          Check for active status of job.
 boolean isFailed()
          Check for failure status of job.
 boolean isFinished()
          Returns true if the job has finished.
 void statusChanged(org.globus.gram.GramJob job)
          This function is called by the COG API after the job.request call whenever the job status changes.
 void waitFor()
          Wait for the job to finish.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobusNonBlockingJobListener

public GlobusNonBlockingJobListener()
Method Detail

getStatus

public int getStatus()
Get the status code for the Globus GRAM job. Should be called after the job is finished.

Returns:
A constant from the GramJob class indicating the status of the job.

isFinished

public boolean isFinished()
Returns true if the job has finished.

Returns:
Returns true if the job status is either done or failed; false otherwise.

isFailed

public boolean isFailed()
Check for failure status of job.

Returns:
Returns true if the job status is failed.

isActive

public boolean isActive()
Check for active status of job.

Returns:
Returns true if the job status is active.

statusChanged

public void statusChanged(org.globus.gram.GramJob job)
This function is called by the COG API after the job.request call whenever the job status changes.

Specified by:
statusChanged in interface org.globus.gram.GramJobListener
Parameters:
job - A pointer to the job that is running so the status can be retrieved.

waitFor

public void waitFor()
             throws java.lang.InterruptedException
Wait for the job to finish. Blocks until another thread notifies it and then checks the job status and returns if finished.

Throws:
java.lang.InterruptedException