org.gridbus.broker.farming.common
Class Job

java.lang.Object
  extended byorg.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
           
static int DONE
           
static int FAILED
           
static int PENDING
           
static int SUBMITTED
           
static int UNSUBMITTED
           
 
Constructor Summary
Job()
          Constructor
Job(java.lang.String id)
          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
 float getDonetime()
          Returns the time when the job was completed.
 java.lang.String getJobCompletedTimestamp()
          Returns the timestamp for job completion in the format "dd/MM/yyyy hh:mm:ss"
 JobOut getJobError()
          Returns the job error
 java.lang.String getJobHandle()
          Get the unique handle for the job (middleware-dependent)
 java.lang.String getJobID()
          Returns the Identification String for this job
 JobOut getJobOutput()
          Returns the job output
 int getJobStatus()
          Returns the integer value of the job status.
 java.lang.String getJobSubmittedTimestamp()
          Returns the timestamp for job submission in the format "dd/MM/yyyy hh:mm:ss"
 java.lang.Object getJobWrapper()
          Returns the Job Wrapper for this job.
 java.lang.StringBuffer getOutputBuffer()
          The Output Buffer stores the console error and output at the remote node for the job This functions returns the output buffer.
 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.
 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
 long returnWallClockTimeTaken()
          This function returns the difference between the job completed timestamp and the job submitted timestamp It throws exception if the timestamps cannot be parsed or if they are null.
 void setDonetime(float f)
          Sets the done time
 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 setJobError(JobOut out)
          Sets the job error
 void setJobHandle(java.lang.String string)
          Sets the unique handle for the job which comes from the middleware..
 void setJobID(java.lang.String string)
          Sets the job identifier
 void setJobOutput(JobOut out)
          Sets the job output
 void setJobStatus(int status)
          Sets the job status
 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 setOutputBuffer(java.lang.StringBuffer buffer)
          Sets the output buffer.
 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 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..
 java.lang.String submit(ComputeServer server)
          Submits a job to the server that is set within this job Throws exception if the server is null.
 java.lang.String terminate()
          Terminates this job
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNSUBMITTED

public static final int UNSUBMITTED
See Also:
Constant Field Values

SUBMITTED

public static final int SUBMITTED
See Also:
Constant Field Values

ACTIVE

public static final int ACTIVE
See Also:
Constant Field Values

PENDING

public static final int PENDING
See Also:
Constant Field Values

DONE

public static final int DONE
See Also:
Constant Field Values

FAILED

public static final int FAILED
See Also:
Constant Field Values
Constructor Detail

Job

public Job()
Constructor


Job

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

Parameters:
id -
Method Detail

getJobID

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

Returns:
job ID

setJobID

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

Parameters:
string -

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)
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 otherwise the @see #getDonetime function will throw an Exception.

Parameters:
string -

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)
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 otherwise the @see #getDonetime function will throw an Exception.

Parameters:
string -

returnWallClockTimeTaken

public long returnWallClockTimeTaken()
                              throws java.lang.Exception
This function returns the difference between the job completed timestamp and the job submitted timestamp It throws exception if the timestamps cannot be parsed or if they are null.

Returns:
time take in milliseconds
Throws:
java.lang.Exception

getDonetime

public float getDonetime()
Returns the time when the job was completed.

Returns:
float

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 -

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

submit

public java.lang.String submit(ComputeServer server)
                        throws java.lang.Exception
Submits a job to the server that is set within this job Throws exception if the server is null.

Parameters:
server -
Returns:
"OK" string
Throws:
java.lang.Exception

terminate

public java.lang.String terminate()
                           throws java.lang.Exception
Terminates this job

Returns:
"OK" string
Throws:
java.lang.Exception

getOutputBuffer

public java.lang.StringBuffer getOutputBuffer()
The Output Buffer stores the console error and output at the remote node for the job This functions returns the output buffer. It is left to calling function to decide how to handle it

Returns:
The output as a string buffer.

setOutputBuffer

public void setOutputBuffer(java.lang.StringBuffer buffer)
Sets the output buffer.

Parameters:
buffer -

getJobHandle

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

Returns:
job handle

setJobHandle

public void setJobHandle(java.lang.String string)
Sets the unique handle for the job which comes from the middleware..

Parameters:
string -

getJobError

public JobOut getJobError()
Returns the job error

Returns:
JobOut object representing the error

getJobOutput

public JobOut getJobOutput()
Returns the job output

Returns:
JobOut object representing the output

setJobError

public void setJobError(JobOut out)
Sets the job error

Parameters:
out -

setJobOutput

public void setJobOutput(JobOut out)
Sets the job output

Parameters:
out -

setDonetime

public void setDonetime(float f)
Sets the done time

Parameters:
f -

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