org.glite.wmsui.apij
Class Job

java.lang.Object
  extended byorg.glite.wmsui.apij.Job

public class Job
extends java.lang.Object

Allow controlling the job and perform several operations.

The Job class provides methods that allow controlling the job during its lifetime. The allowed operations are:

Also some special features are provided:

Version:
0.1
Author:
Alessandro Maraschini

Field Summary
static int DAG_AD
          DagAd Constructor Utilised
static int JOB_AD
          JobAd Constructor Utilised
static int JOB_ID
          JobId Constructor utilised
static int JOB_NONE
          Empty Constructor Job
static int JOB_SUBMITTED
          JobAd constructor and then submitted, both JobAd and JobId are avaliable
 
Constructor Summary
Job()
          Instantiates an empty Job object
Job(org.glite.jdl.JobAd ad)
          Instantiates an Job object with a JobAd
Job(JobId id)
          Instantiates an Job object with a JobId
Job(java.lang.String dagFile)
          Instantiates an Job object with a JobAd
 
Method Summary
 void attach(Listener ls)
          Attach the Job with the specified implemented listener
 void attach(Listener ls, int port)
          Attach the Job with the specified implemented listener
 Result cancel()
          Cancel the job from the resource broker ( syncronous version )
 Job copy()
          Create a copy of the Job, including its private JobId and JobAd members information
 boolean equals(Job job)
          Check if two Job objects are the same, i.e have the same JobId
 org.glite.jdl.JobAd getJobAd()
          Get the JobAd instance
 JobId getJobId()
          Get the JobId instance
 Result getLogInfo()
          Retrieve the bookkeeping information of the job ( syncronous version )
 Result getOutput(java.lang.String dirPath)
          Retrieve output files of a submitted job ( syncronous version )
 org.glite.jdl.JobState getState(int step)
          Retrieve the specified checkpointable step from the LB server
 Result getStatus()
          The same as getStatus( true)
 Result getStatus(boolean ad)
          Retrieve the status of the job
 java.util.Vector getSubJobsId()
          Retrieves the Job Id of all sub jobs of the job.
 Result listMatchingCE(Url nsAddr)
          Look for matching Computing Element available resources ( syncronous version )
 void logDefaultValues(boolean set)
          Decide whether to log or not some UI default values such as: UI node name information in UserTags attribute
 Result notify(int[] states, int timeout)
          Retrieves the status of the Job once it enters the specified status code (s)
 org.glite.jdl.JobAd retrieveJobAd()
          Set the JobAd member attribute of the Job instance to the job description got from the LB
 void setCredPath(java.io.File cp)
          Set a different Proxy certificate from the default one and check it
 void setDagAd(java.lang.String ad)
          set the Dagad instance
 void setJobAd(org.glite.jdl.JobAd ad)
          set the JobAd instance
 void setJobId(JobId id)
          set the JobId instance
 void setLoggerLevel(int level)
          Set the NS verbosity level
 Result submit(Url ns, Url lb, java.lang.String ceId)
          Submit the job to the Network Server This method is equal to submit (ns, lb, ceId, null, null)
 Result submit(Url ns, Url lb, java.lang.String ceId, Listener ls, org.glite.jdl.JobState state)
          Submit the job to theNetworkServer.
 void unsetCredPath()
          Set the Proxy certificate as default
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JOB_NONE

public static final int JOB_NONE
Empty Constructor Job

See Also:
Constant Field Values

JOB_ID

public static final int JOB_ID
JobId Constructor utilised

See Also:
Constant Field Values

JOB_AD

public static final int JOB_AD
JobAd Constructor Utilised

See Also:
Constant Field Values

JOB_SUBMITTED

public static final int JOB_SUBMITTED
JobAd constructor and then submitted, both JobAd and JobId are avaliable

See Also:
Constant Field Values

DAG_AD

public static final int DAG_AD
DagAd Constructor Utilised

See Also:
Constant Field Values
Constructor Detail

Job

public Job()
Instantiates an empty Job object


Job

public Job(JobId id)
    throws java.lang.IllegalArgumentException
Instantiates an Job object with a JobId

Parameters:
id - the JobId instance from which the Job has to be created
Throws:
java.lang.IllegalArgumentException - If the JobId is not valid

Job

public Job(org.glite.jdl.JobAd ad)
    throws java.lang.IllegalArgumentException
Instantiates an Job object with a JobAd

Parameters:
ad - the JobAd instance from which the Job has to be created
Throws:
java.lang.IllegalArgumentException - If the JobAd is not valid

Job

public Job(java.lang.String dagFile)
    throws java.lang.IllegalArgumentException
Instantiates an Job object with a JobAd

Parameters:
dagFile - the dagad file instance from which the Dag has to be created
Throws:
java.lang.IllegalArgumentException - If the DagAd is not valid
Method Detail

copy

public Job copy()
Create a copy of the Job, including its private JobId and JobAd members information

Returns:
the copy of the Job instance

equals

public boolean equals(Job job)
Check if two Job objects are the same, i.e have the same JobId

Parameters:
job - the Job to check with the current instance
Returns:
true if the jobs are equal, false otherwise

getJobId

public JobId getJobId()
               throws java.lang.NoSuchFieldException
Get the JobId instance

Returns:
a pointer to the internal JobId intance
Throws:
java.lang.NoSuchFieldException - If the JobId instance is empty

getJobAd

public org.glite.jdl.JobAd getJobAd()
                             throws java.lang.NoSuchFieldException
Get the JobAd instance

Returns:
a pointer to the internal JobAd intance
Throws:
java.lang.NoSuchFieldException - If the JobAd instance is empty

setLoggerLevel

public void setLoggerLevel(int level)
Set the NS verbosity level

Parameters:
level - minimum (no verbosity) level = 0. Maximum (full verbosity) = 6

logDefaultValues

public void logDefaultValues(boolean set)
Decide whether to log or not some UI default values such as: UI node name information in UserTags attribute

Parameters:
set - if set to true the UI will automatically log its default values, otherwise not

setCredPath

public void setCredPath(java.io.File cp)
                 throws org.globus.gsi.GlobusCredentialException,
                        java.io.FileNotFoundException
Set a different Proxy certificate from the default one and check it

Parameters:
cp - The full path of the proxy certificate file to be set
Throws:
java.io.FileNotFoundException - Unable to find-load-read the specified file
org.globus.gsi.GlobusCredentialException - Unable to Load the specified proxy certificate

unsetCredPath

public void unsetCredPath()
                   throws org.globus.gsi.GlobusCredentialException,
                          java.io.FileNotFoundException
Set the Proxy certificate as default

Throws:
java.io.FileNotFoundException - Unable to find-load-read the deafult proxy file
org.globus.gsi.GlobusCredentialException - Unable to Load the default proxy certificate

setJobAd

public void setJobAd(org.glite.jdl.JobAd ad)
              throws java.lang.IllegalArgumentException
set the JobAd instance

Parameters:
ad - the JobAd Instance to set from
Throws:
java.lang.IllegalArgumentException - The JobAd instance has been already set

setDagAd

public void setDagAd(java.lang.String ad)
              throws java.lang.IllegalArgumentException
set the Dagad instance

Parameters:
ad - the Dagad Instance to set from
Throws:
java.lang.IllegalArgumentException - The JobAd instance has been already set

setJobId

public void setJobId(JobId id)
              throws java.lang.IllegalArgumentException
set the JobId instance

Parameters:
id - the JobId Instance to set from
Throws:
java.lang.IllegalArgumentException - If the JobId has been alreaty set

retrieveJobAd

public org.glite.jdl.JobAd retrieveJobAd()
                                  throws org.glite.jdl.JobAdException,
                                         java.lang.UnsupportedOperationException,
                                         java.io.FileNotFoundException,
                                         org.globus.gsi.GlobusCredentialException
Set the JobAd member attribute of the Job instance to the job description got from the LB

Returns:
a pointer to the internal JobAd intance, which has been just loaded from the retrieved LB info
Throws:
org.glite.jdl.JobAdException - when the Jdl has errors
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
java.io.FileNotFoundException - unable to find any certificate file
org.globus.gsi.GlobusCredentialException - proxy certificate information failed

getStatus

public Result getStatus()
                 throws java.lang.UnsupportedOperationException,
                        java.io.FileNotFoundException,
                        org.globus.gsi.GlobusCredentialException
The same as getStatus( true)

Throws:
java.io.FileNotFoundException - Unable to find certificates files
gsi.GlobusCredentialException - error while checking certificates validity
java.lang.UnsupportedOperationException
org.globus.gsi.GlobusCredentialException
See Also:
getStatus(boolean)

getStatus

public Result getStatus(boolean ad)
                 throws java.lang.UnsupportedOperationException,
                        org.globus.gsi.GlobusCredentialException,
                        java.io.FileNotFoundException
Retrieve the status of the job

Parameters:
ad - determine whether to download (true) or not (false) all JobAd information from server
Returns:
the status of the job
Throws:
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
java.io.FileNotFoundException - Unable to find certificates files
gsi.GlobusCredentialException - error while checking certificates validity
org.globus.gsi.GlobusCredentialException

notify

public Result notify(int[] states,
                     int timeout)
              throws java.lang.UnsupportedOperationException,
                     java.io.FileNotFoundException,
                     org.globus.gsi.GlobusCredentialException
Retrieves the status of the Job once it enters the specified status code (s)

Parameters:
states - an array of JobStatus status codes
timeout - seconds the method has to wait for notification. After that period the methods returns anyway. If 0 specified it hangs untill notify arrives
Returns:
a Result containing the JobStatus (or empty when timeout reached)
Throws:
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
java.io.FileNotFoundException - Unable to find certificates files
gsi.GlobusCredentialException - error while checking certificates validity
org.globus.gsi.GlobusCredentialException
See Also:
Result.TIMEOUT_REACHED

getSubJobsId

public java.util.Vector getSubJobsId()
                              throws java.lang.UnsupportedOperationException,
                                     org.globus.gsi.GlobusCredentialException,
                                     java.io.FileNotFoundException
Retrieves the Job Id of all sub jobs of the job.

Returns:
a Vector containing a String representation of all sub jobs JobId.
Throws:
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
java.io.FileNotFoundException - Unable to find certificates files
gsi.GlobusCredentialException - error while checking certificates validity
org.globus.gsi.GlobusCredentialException

getLogInfo

public Result getLogInfo()
                  throws java.lang.UnsupportedOperationException,
                         java.io.FileNotFoundException,
                         org.globus.gsi.GlobusCredentialException
Retrieve the bookkeeping information of the job ( syncronous version )

Returns:
all the events logged during the job life
Throws:
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
java.io.FileNotFoundException - Unable to find certificates files
gsi.GlobusCredentialException - error while checking certificates validity
java.lang.UnsatisfiedLinkError - Unable to fine the native shared library that implements LB-RB functions
org.globus.gsi.GlobusCredentialException

attach

public void attach(Listener ls)
            throws java.lang.Exception
Attach the Job with the specified implemented listener

The port where to listen to is automatically determined: if possible it at appends to the first logged port This method is equal to attach (Listener , 0 )

Parameters:
ls - the implementation of the listener
Throws:
java.lang.Exception
See Also:
attach(Listener, int)

attach

public void attach(Listener ls,
                   int port)
            throws org.glite.jdl.JobAdException,
                   java.lang.UnsupportedOperationException,
                   java.io.FileNotFoundException,
                   org.globus.gsi.GlobusCredentialException,
                   java.net.UnknownHostException
Attach the Job with the specified implemented listener

Parameters:
ls - an implementation of the Listener interface
port - the interactive port where the console listener listens to
Throws:
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
java.net.UnknownHostException - If unable to determine the current system operator
java.lang.NoSuchFieldException - If any required attribute is missing from the JDL
java.io.FileNotFoundException - unable to find any certificate file
org.globus.gsi.GlobusCredentialException - proxy certificate information failed
org.glite.jdl.JobAdException

getState

public org.glite.jdl.JobState getState(int step)
                                throws java.lang.UnsupportedOperationException,
                                       java.io.FileNotFoundException,
                                       org.globus.gsi.GlobusCredentialException,
                                       org.glite.jdl.JobAdException,
                                       java.text.ParseException
Retrieve the specified checkpointable step from the LB server

Parameters:
step - In order to retrieve the last logged checkpointable event, step must be 0. step must be 1 for the last-but-one etc etc
Throws:
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
java.io.FileNotFoundException - unable to find any certificate file
org.globus.gsi.GlobusCredentialException - proxy certificate information failed
java.text.ParseException - Unable to parse the JobState string retrieved from LB
org.glite.jdl.JobAdException - the Jdl has semantic errors

submit

public Result submit(Url ns,
                     Url lb,
                     java.lang.String ceId)
              throws javax.naming.directory.InvalidAttributeValueException,
                     java.net.UnknownHostException,
                     org.glite.jdl.JobAdException,
                     java.lang.NoSuchFieldException,
                     java.lang.UnsupportedOperationException,
                     java.io.FileNotFoundException,
                     org.globus.gsi.GlobusCredentialException
Submit the job to the Network Server This method is equal to submit (ns, lb, ceId, null, null)

Parameters:
ns - The Network Server address
lb - The Logging and bookkeeping address
ceId - The Computing Element Identificator where to perform the job
Throws:
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
InvalidAttributeValueException - Unable to set values inside the JobAd instance
java.net.UnknownHostException - If unable to determine the current system operator
org.glite.jdl.JobAdException - when the Jdl has semantic errors
java.lang.NoSuchFieldException - If any required attribute is missing from the JobAd
java.io.FileNotFoundException - unable to find any certificate file
org.globus.gsi.GlobusCredentialException - proxy certificate information failed
See Also:
Perfroms extra Interactive/checkpointable job activities

submit

public Result submit(Url ns,
                     Url lb,
                     java.lang.String ceId,
                     Listener ls,
                     org.glite.jdl.JobState state)
              throws javax.naming.directory.InvalidAttributeValueException,
                     java.net.UnknownHostException,
                     org.glite.jdl.JobAdException,
                     java.lang.NoSuchFieldException,
                     java.lang.UnsupportedOperationException,
                     java.io.FileNotFoundException,
                     org.globus.gsi.GlobusCredentialException
Submit the job to theNetworkServer. Optional parameter for interactive and checkpointable jobs

Parameters:
ns - The Network Server address
lb - The Logging and bookkeeping address
ceId - The Computing Element Identificator where to force the job submission
ls - an instance implementation of Listener interface.When the submission is finished, the Job will launch the Listener.run method
state - A specific JobState step of the job (which must be of checkpointing jobtype). The job will take on the submission starting from the specified step
Throws:
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
InvalidAttributeValueException - Unable to set values inside the JobAd instance
java.net.UnknownHostException - If unable to determine the current system operator
org.glite.jdl.JobAdException - when the Jdl has semantic errors
java.lang.NoSuchFieldException - If any required attribute is missing from the JobAd
java.io.FileNotFoundException - unable to find any certificate file
org.globus.gsi.GlobusCredentialException - proxy certificate information failed
See Also:
Listener.run( Shadow)

listMatchingCE

public Result listMatchingCE(Url nsAddr)
                      throws org.glite.jdl.JobAdException,
                             java.lang.UnsupportedOperationException,
                             java.io.FileNotFoundException,
                             org.globus.gsi.GlobusCredentialException
Look for matching Computing Element available resources ( syncronous version )

Parameters:
nsAddr - = The Resource Broker full address given in the form :
Returns:
all the Computing Elemets that match with the given JobAd
Throws:
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
org.glite.jdl.JobAdException - when the Jdl has semantic errors
java.io.FileNotFoundException - unable to find any certificate file
org.globus.gsi.GlobusCredentialException - proxy certificate information failed

cancel

public Result cancel()
              throws org.glite.jdl.JobAdException,
                     java.lang.UnsupportedOperationException,
                     java.io.FileNotFoundException,
                     org.globus.gsi.GlobusCredentialException
Cancel the job from the resource broker ( syncronous version )

Returns:
The Result of the operation
Throws:
org.glite.jdl.JobAdException - when the Jdl has semantic errors
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
java.io.FileNotFoundException - unable to find any certificate file
org.globus.gsi.GlobusCredentialException - proxy certificate information failed

getOutput

public Result getOutput(java.lang.String dirPath)
                 throws org.glite.jdl.JobAdException,
                        java.lang.UnsupportedOperationException,
                        java.io.FileNotFoundException,
                        org.globus.gsi.GlobusCredentialException
Retrieve output files of a submitted job ( syncronous version )

Parameters:
dirPath - the path where to retrieve the OutputSandbox files
Returns:
The Result of the operation
Throws:
org.glite.jdl.JobAdException - when the Jdl has semantic errors
java.lang.UnsupportedOperationException - The Operation required is not allowed for the Job
java.io.FileNotFoundException - unable to find any certificate file
org.globus.gsi.GlobusCredentialException - proxy certificate information failed