org.gridbus.broker.farming.common
Class Job

java.lang.Object
  extended by org.gridbus.broker.farming.common.Job

public class Job
extends java.lang.Object

This class represents a Job. A job consists of the Task from which it was derived, a Hashtable of the variable values for this job, a status string

Author:
Srikumar Venugopal (srikumar@cs.mu.oz.au), Jia Yu (jiayu@cs.mu.oz.au)

Field Summary
static int ACTIVE
          Job is active/executing on the remote node
static int DONE
          Job is completed.
static int FAILED
          Job has failed.
static int LOCAL_QUEUED
          Job is waiting on the local broker node, to be submitted to the remote node
static int PENDING
          Job is submitted, but waiting on the remote node.
static int PRESTAGE
          Job is waiting on the local broker node, for files to be pre-staged to the remote node.
static int STAGE_IN
           
static int STAGE_OUT
           
static int STATUS_ANY
          Used to indicate ANY/ALL status
static int SUBMITTED
          Job is submitted on the remote node
static int TYPE_NORMAL
          Used for all normal jobs
static int TYPE_SYSTEM
          Used for probe jobs to discover queues,verify requirements on a server etc.
static int UNKNOWN
          Job status is not known
static int UNSUBMITTED
          Job is waiting on the remote node, to be submitted
 
Constructor Summary
Job()
          Constructor
Job(java.lang.String jobID)
          Constructor - with unique job id passed as a parameter.
 
Method Summary
 void addVariable(SingleVariable var)
          Add a Variable to the variables list
 void clearVariables()
          Clear the variable list for this job
 long getJobCompletedTime()
           
 java.lang.String getJobCompletedTimestamp()
          Returns the timestamp for job completion in the format "dd/MM/yyyy hh:mm:ss"
 java.lang.String getJobError()
          Returns the job error
 java.lang.String getJobErrorFileName()
          Returns the name of the stderr filename for this job
 java.lang.Object getJobHandle()
          Get the unique handle for the job (middleware-dependent)
 java.lang.String getJobID()
          Returns the Identification String for this job
 java.lang.String getJobOutput()
          Returns the job output
 java.lang.String getJobOutputFileName()
          Returns the name of the stdout filename for this job
 JobRequirement getJobRequirement()
           
 int getJobStatus()
          Returns the integer value of the job status.
 long getJobSubmittedTime()
           
 java.lang.String getJobSubmittedTimestamp()
          Returns the timestamp for job submission in the format "dd/MM/yyyy hh:mm:ss"
 JobWrapper getJobWrapper()
          Returns the Job Wrapper for this job.
 Job getPostProcessJob()
           
 JobQueue getQueue()
           
 java.lang.String getRemoteDir()
           
 Requirement getRequirement()
           
 ComputeServer getServer()
          Returns the server to which the job is allocated
 java.lang.String getStatusString()
          Returns the status in the form of a string.
 java.lang.Object getSubmitRecord()
          Returns the submit record object
 Task getTask()
          Task is the sequence of commands that describe what a job has to do.
 int getType()
           
 java.util.Hashtable getVariableTable()
          Returns the hashtable containing variables and their values for this job.
 java.lang.String getVariableValue(java.lang.String name)
          returns the value of the variable name passed.
 java.util.Hashtable getVariableValueTable()
          Returns the table of variables(values)
 void removeVariable(SingleVariable var)
          Remove the variable name passed and its corresponding values from the list of variables
 void reset()
          Resets the job status to UNSUBMITTED and sets the server to null.
 long returnWallClockTimeTaken()
          This function returns the difference between the job completed timestamp and the job submitted timestamp
 void setJobCompletedTime(long jobCompletedTime)
           
 void setJobCompletedTimestamp()
          This function sets a time stamp in the format DateFormat.MEDIUM,DateFormat.MEDIUM It should be called after the job completion.
 void setJobCompletedTimestamp(java.lang.String string)
          Sets the job completed timestamp as the one that is passed as the parameter.
 void setJobErrorFileName(java.lang.String jobErrorFileName)
           
 void setJobHandle(java.lang.Object obj)
          Sets the unique handle for the job which comes from the middleware.
 void setJobID(java.lang.String jobID)
          Sets the job identifier
 void setJobOutputFileName(java.lang.String jobOutputFileName)
           
 void setJobRequirement(JobRequirement jobReq)
           
 void setJobStatus(int status)
          Sets the job status
 void setJobStatus(java.lang.String status)
          Sets the job status
 void setJobSubmittedTime(long jobSubmittedTime)
           
 void setJobSubmittedTimestamp()
          This function sets a time stamp in the format "MMM dd, yyyy hh:mm:ss" using DateFormat classes
 void setJobSubmittedTimestamp(java.lang.String string)
          Sets the job submitted timestamp as the one that is passed as the parameter.
 void setJobWrapper(JobWrapper wrapper)
          Sets the job wrapper for this job, to take care of submission, etc..
 void setPostProcessJob(Job postjob)
           
 void setQueue(JobQueue queue)
           
 void setRemoteDir(java.lang.String remoteDir)
           
 void setRequirement(Requirement jobRequirements)
           
 void setServer(ComputeServer server)
          Sets the server to which the job is to be allocated.
 void setSubmitRecord(java.lang.Object object)
          Sets the submit record object
 void setTask(Task task)
          This sets the task for this job
 void setType(int type)
           
 void setVariableTable(java.util.Hashtable hashtable)
          The variable values for the job are stord in a hashtable in the form of name value pairs This function passes a hashtable to be used as the variable storage..
static int statusInt(java.lang.String jobStatus)
          Returns an integer representation of the status corresponding to the given string.
static java.lang.String statusString(int jobStatus)
          This method converts the input integer job status code to string format.
 void terminate()
          Terminates this job
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATUS_ANY

public static final int STATUS_ANY
Used to indicate ANY/ALL status

See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
Job status is not known

See Also:
Constant Field Values

UNSUBMITTED

public static final int UNSUBMITTED
Job is waiting on the remote node, to be submitted

See Also:
Constant Field Values

SUBMITTED

public static final int SUBMITTED
Job is submitted on the remote node

See Also:
Constant Field Values

ACTIVE

public static final int ACTIVE
Job is active/executing on the remote node

See Also:
Constant Field Values

PENDING

public static final int PENDING
Job is submitted, but waiting on the remote node. (For eg:, it could be in a queue on the remote node

See Also:
Constant Field Values

DONE

public static final int DONE
Job is completed.

See Also:
Constant Field Values

FAILED

public static final int FAILED
Job has failed.

See Also:
Constant Field Values

LOCAL_QUEUED

public static final int LOCAL_QUEUED
Job is waiting on the local broker node, to be submitted to the remote node

See Also:
Constant Field Values

PRESTAGE

public static final int PRESTAGE
Job is waiting on the local broker node, for files to be pre-staged to the remote node.

See Also:
Constant Field Values

STAGE_IN

public static final int STAGE_IN
See Also:
Constant Field Values

STAGE_OUT

public static final int STAGE_OUT
See Also:
Constant Field Values

TYPE_SYSTEM

public static final int TYPE_SYSTEM
Used for probe jobs to discover queues,verify requirements on a server etc.

See Also:
Constant Field Values

TYPE_NORMAL

public static final int TYPE_NORMAL
Used for all normal jobs

See Also:
Constant Field Values
Constructor Detail

Job

public Job()
Constructor


Job

public Job(java.lang.String jobID)
Constructor - with unique job id passed as a parameter.

Parameters:
jobID -
Method Detail

statusString

public static java.lang.String statusString(int jobStatus)
This method converts the input integer job status code to string format.

Parameters:
jobStatus -
Returns:

statusInt

public static int statusInt(java.lang.String jobStatus)
Returns an integer representation of the status corresponding to the given string.

Parameters:
jobStatus -
Returns:

getJobID

public java.lang.String getJobID()
Returns the Identification String for this job

Returns:
job ID

setJobID

public void setJobID(java.lang.String jobID)
Sets the job identifier

Parameters:
jobID -

getServer

public ComputeServer getServer()
Returns the server to which the job is allocated

Returns:
server - the Compute Server if the job is allocated to a server otherwise null

setServer

public void setServer(ComputeServer server)
Sets the server to which the job is to be allocated.

Parameters:
server -

setJobSubmittedTimestamp

public void setJobSubmittedTimestamp()
This function sets a time stamp in the format "MMM dd, yyyy hh:mm:ss" using DateFormat classes

See Also:
It should be called after the job submission.

setJobSubmittedTimestamp

public void setJobSubmittedTimestamp(java.lang.String string)
                              throws java.text.ParseException
Sets the job submitted timestamp as the one that is passed as the parameter. The recommended format for the string passed is DateFormat.MEDIUM,DateFormat.MEDIUM

Parameters:
string -
Throws:
java.text.ParseException - if the string passed in cannot be converted into a valid date

setJobCompletedTimestamp

public void setJobCompletedTimestamp()
This function sets a time stamp in the format DateFormat.MEDIUM,DateFormat.MEDIUM It should be called after the job completion.


setJobCompletedTimestamp

public void setJobCompletedTimestamp(java.lang.String string)
                              throws java.text.ParseException
Sets the job completed timestamp as the one that is passed as the parameter. The recommended format for the string passed is DateFormat.MEDIUM,DateFormat.MEDIUM

Parameters:
string -
Throws:
java.text.ParseException - if the string passed in cannot be converted into a valid date

returnWallClockTimeTaken

public long returnWallClockTimeTaken()
This function returns the difference between the job completed timestamp and the job submitted timestamp

Returns:
time take in milliseconds

getJobSubmittedTimestamp

public java.lang.String getJobSubmittedTimestamp()
Returns the timestamp for job submission in the format "dd/MM/yyyy hh:mm:ss"

Returns:
String - job submitted timestamp or null if it has not been set
See Also:
DateFormat

getJobCompletedTimestamp

public java.lang.String getJobCompletedTimestamp()
Returns the timestamp for job completion in the format "dd/MM/yyyy hh:mm:ss"

Returns:
String - job completed timestamp or null if it has not been set
See Also:
DateFormat

getJobStatus

public int getJobStatus()
Returns the integer value of the job status.

Returns:
job status

setJobStatus

public void setJobStatus(int status)
Sets the job status

Parameters:
status -

setJobStatus

public void setJobStatus(java.lang.String status)
Sets the job status

Parameters:
status -

getStatusString

public java.lang.String getStatusString()
Returns the status in the form of a string. The staus can be any one of "unsubmitted","submitted","active","pending","done" or "failed"

Returns:
status string

getJobWrapper

public JobWrapper getJobWrapper()
Returns the Job Wrapper for this job. JobWrapper handles the actual execution of the job and interacts with the middleware at the remote site.

Returns:
jobWrapper if set or null if not

getTask

public Task getTask()
Task is the sequence of commands that describe what a job has to do. This returns the task for this job

Returns:
task for this job

setTask

public void setTask(Task task)
This sets the task for this job

Parameters:
task -

getVariableTable

public java.util.Hashtable getVariableTable()
Returns the hashtable containing variables and their values for this job.

Returns:
table of variables

setVariableTable

public void setVariableTable(java.util.Hashtable hashtable)
The variable values for the job are stord in a hashtable in the form of name value pairs This function passes a hashtable to be used as the variable storage..

Parameters:
hashtable -

addVariable

public void addVariable(SingleVariable var)
Add a Variable to the variables list

Parameters:
var - - a Variable object which contains the variable name and the variable value

getVariableValue

public java.lang.String getVariableValue(java.lang.String name)
returns the value of the variable name passed.

Parameters:
name -
Returns:
value of the variable

getVariableValueTable

public java.util.Hashtable getVariableValueTable()
Returns the table of variables(values)

Returns:
the table of variable values

removeVariable

public void removeVariable(SingleVariable var)
Remove the variable name passed and its corresponding values from the list of variables

Parameters:
var -

clearVariables

public void clearVariables()
Clear the variable list for this job


setJobWrapper

public void setJobWrapper(JobWrapper wrapper)
Sets the job wrapper for this job, to take care of submission, etc..

Parameters:
wrapper -

terminate

public void terminate()
Terminates this job


getJobHandle

public java.lang.Object getJobHandle()
Get the unique handle for the job (middleware-dependent)

Returns:
job handle

setJobHandle

public void setJobHandle(java.lang.Object obj)
Sets the unique handle for the job which comes from the middleware. This handle would the identifier object using which we can query the job status / access the job details on the remote side.

Parameters:
obj -

getJobError

public java.lang.String getJobError()
Returns the job error

Returns:
String object representing the error

setJobErrorFileName

public void setJobErrorFileName(java.lang.String jobErrorFileName)
Parameters:
jobErrorFileName - The jobErrorFileName to set.

getJobErrorFileName

public java.lang.String getJobErrorFileName()
Returns the name of the stderr filename for this job

Returns:

setJobOutputFileName

public void setJobOutputFileName(java.lang.String jobOutputFileName)
Parameters:
jobOutputFileName - The jobOutputFileName to set.

getJobOutputFileName

public java.lang.String getJobOutputFileName()
Returns the name of the stdout filename for this job

Returns:

getJobOutput

public java.lang.String getJobOutput()
Returns the job output

Returns:
String object representing the output

getSubmitRecord

public java.lang.Object getSubmitRecord()
Returns the submit record object

Returns:
submit record object

setSubmitRecord

public void setSubmitRecord(java.lang.Object object)
Sets the submit record object

Parameters:
object - - submit record

getRemoteDir

public java.lang.String getRemoteDir()
Returns:

setRemoteDir

public void setRemoteDir(java.lang.String remoteDir)
Parameters:
remoteDir - The remoteDir to set.

getType

public int getType()
Returns:

setType

public void setType(int type)
Parameters:
type -

getQueue

public JobQueue getQueue()
Returns:

setQueue

public void setQueue(JobQueue queue)
Parameters:
queue -

setRequirement

public void setRequirement(Requirement jobRequirements)
Parameters:
jobRequirements -

getRequirement

public Requirement getRequirement()
Returns:
Returns the requirement.

getJobCompletedTime

public long getJobCompletedTime()
Returns:
Returns the jobCompletedTime.

setJobCompletedTime

public void setJobCompletedTime(long jobCompletedTime)
Parameters:
jobCompletedTime - The jobCompletedTime to set.

getJobSubmittedTime

public long getJobSubmittedTime()
Returns:
Returns the jobSubmittedTime.

setJobSubmittedTime

public void setJobSubmittedTime(long jobSubmittedTime)
Parameters:
jobSubmittedTime - The jobSubmittedTime to set.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

reset

public void reset()
Resets the job status to UNSUBMITTED and sets the server to null. terminate/clean up.


setJobRequirement

public void setJobRequirement(JobRequirement jobReq)
Parameters:
jobReq -

getJobRequirement

public JobRequirement getJobRequirement()
Returns:

setPostProcessJob

public void setPostProcessJob(Job postjob)
Parameters:
postjob -

getPostProcessJob

public Job getPostProcessJob()