Package com.onenetwork.platform.grid
Interface GridJob
public interface GridJob
In-memory representation of a Grid Job (a collection of related Grid Tasks).
Where a
GridTask
represents a single unit of work in the Grid, a GridJob
represents a collection of related tasks. The overall status of the Grid Job will depend
on the states of the tasks it contains. (See JobState
for details.)
Just as a task can depend on another task, a task can depend on a job; thus one can have a task
depend on multiple other tasks by setting its "jobDepend" property.
-
Method Summary
Modifier and Type Method Description void
addTask(GridTask task)
Add a single GridTask to this GridJob.void
addTasks(java.util.Collection<GridTask> tasks)
Add multiple GridTasks to this GridJob.java.lang.Long
getCreatedByUserId()
Optionally used to indicated what user created the jobjava.lang.Long
getEndTime()
Returns the time when job is finished running (either succeeded or failure) in millis since epoch.java.lang.String
getFailureReason()
Returns the failure reason of the last failed task on the jobjava.lang.String
getGetGridJobListenerClass()
Returns the class name for the listener for this job.java.lang.String
getGridJobResult()
java.util.List<GridTask>
getGridTaskList()
Returns the GridTasks added to this joblong
getJobId()
Returns the surrogate key of this job.java.lang.String
getJobName()
Job name (for descriptive purposes only)java.lang.String
getJobParams()
Job parameters (optional, specific to the job type)java.lang.String
getJobType()
Job type (for descriptive purposes only)long
getNumberOfTasks(java.lang.String state)
Returns number of tasks in a job for a given state i.e.java.lang.Long
getStartTime()
Returns the job starting time in millis since epoch.java.lang.String
getState()
Returns the current state of this job - seeJobState
java.lang.String
getTag1()
Tag1 may contain data specific to different job types; the meaning of this value is determined by the job type.java.lang.String
getTag2()
Tag2 may contain data specific to different job types; the meaning of this value is determined by the job type.java.lang.String
getTag3()
Tag3 may contain data specific to different job types; the meaning of this value is determined by the job type.java.lang.String
getTag4()
Tag4 may contain data specific to different job types; the meaning of this value is determined by the job type.void
setCreatedByUserId(java.lang.Long userId)
Optionally used to indicated what user created the jobvoid
setEarliestStartTime(long earliestStartTime)
Set earliest start time for all tasks subsequently added to the job.void
setGridJobListenerClass(java.lang.String listenerClass)
Set the fully-qualified class name for the job implementingGridJobListener
.void
setJobDependency(GridJob jobDependency)
Set a job that all tasks subsequently added to this job will depend on.void
setJobName(java.lang.String jobName)
Sets the job name (for descriptive purposes only)void
setJobParams(java.lang.String jobParams)
Sets the job parameters (optional, specific to the job type)void
setJobType(java.lang.String jobType)
Sets the job type (for descriptive purposes only)void
setLatestStartTime(long latestStartTime)
Set latest start time for all tasks subsequently added to the job.void
setMaxAttempts(long maxAttempts)
Set the max attempts for all tasks subsequently added to the job.void
setMaxRunTimeMillis(long maxRunTimeMillis)
Set the max runtime in milliseconds for all tasks subsequently added to the job.void
setPropagateFail(boolean propagateFail)
Set propagate fail for all tasks subsequently added to the job.void
setRetryDelayMillis(long retryDelayMillis)
Set the retry delay in milliseconds for all tasks subsequently added to the job.void
setTag1(java.lang.String tag1)
Tag1 may contain data specific to different job types; the meaning of this value is determined by the job type.void
setTag2(java.lang.String tag2)
Tag2 may contain data specific to different job types; the meaning of this value is determined by the job type.void
setTag3(java.lang.String tag3)
Tag3 may contain data specific to different job types; the meaning of this value is determined by the job type.void
setTag4(java.lang.String tag4)
Tag4 may contain data specific to different job types; the meaning of this value is determined by the job type.void
setTaskDependency(GridTask taskDependency)
Set a task that all tasks subsequently added to the job will depend on.
-
Method Details
-
addTasks
Add multiple GridTasks to this GridJob. This method is only useful prior to persisting the GridJob with the GridService; once persisted, you cannot add tasks to the job.- Parameters:
tasks
- GridTasks to be added to this GridJob
-
addTask
Add a single GridTask to this GridJob. This method is only useful prior to persisting the GridJob with the GridService; once persisted, you cannot add tasks to the job- Parameters:
task
- GridTask to be added to this GridJob
-
setEarliestStartTime
void setEarliestStartTime(long earliestStartTime)Set earliest start time for all tasks subsequently added to the job. SeeaddTasks(Collection)
.- Parameters:
earliestStartTime
- milliseconds since January 1, 1970, 00:00:00 GMT
-
setLatestStartTime
void setLatestStartTime(long latestStartTime)Set latest start time for all tasks subsequently added to the job. SeeaddTasks(Collection)
.- Parameters:
latestStartTime
- milliseconds since January 1, 1970, 00:00:00 GMT
-
setMaxAttempts
void setMaxAttempts(long maxAttempts)Set the max attempts for all tasks subsequently added to the job. SeeaddTasks(Collection)
.- Parameters:
maxAttempts
- the maximum number of attempts a task can make
-
setMaxRunTimeMillis
void setMaxRunTimeMillis(long maxRunTimeMillis)Set the max runtime in milliseconds for all tasks subsequently added to the job. SeeaddTasks(Collection)
.- Parameters:
maxRunTimeMillis
- maximum run time in milliseconds
-
setRetryDelayMillis
void setRetryDelayMillis(long retryDelayMillis)Set the retry delay in milliseconds for all tasks subsequently added to the job. SeeaddTasks(Collection)
.- Parameters:
retryDelayMillis
- the retry delay in milliseconds
-
setPropagateFail
void setPropagateFail(boolean propagateFail)Set propagate fail for all tasks subsequently added to the job. SeeaddTasks(Collection)
.- Parameters:
propagateFail
- true if the task should propagate failures, false otherwise
-
setJobDependency
Set a job that all tasks subsequently added to this job will depend on. SeeaddTasks(Collection)
.- Parameters:
jobDependency
- job for tasks in this job to depend on
-
setTaskDependency
Set a task that all tasks subsequently added to the job will depend on. SeeaddTasks(Collection)
.- Parameters:
taskDependency
- task that all tasks subsequently added to the job will depend on
-
setGridJobListenerClass
void setGridJobListenerClass(java.lang.String listenerClass)Set the fully-qualified class name for the job implementingGridJobListener
. For EPT-specific listener, specify the listener in following format~ - Parameters:
listenerClass
- fully-qualified class name implementingGridJobListener
-
getTag1
java.lang.String getTag1()Tag1 may contain data specific to different job types; the meaning of this value is determined by the job type. -
setTag1
void setTag1(java.lang.String tag1)Tag1 may contain data specific to different job types; the meaning of this value is determined by the job type. -
getTag2
java.lang.String getTag2()Tag2 may contain data specific to different job types; the meaning of this value is determined by the job type. -
setTag2
void setTag2(java.lang.String tag2)Tag2 may contain data specific to different job types; the meaning of this value is determined by the job type. -
getTag3
java.lang.String getTag3()Tag3 may contain data specific to different job types; the meaning of this value is determined by the job type. -
setTag3
void setTag3(java.lang.String tag3)Tag3 may contain data specific to different job types; the meaning of this value is determined by the job type. -
getTag4
java.lang.String getTag4()Tag4 may contain data specific to different job types; the meaning of this value is determined by the job type. -
setTag4
void setTag4(java.lang.String tag4)Tag4 may contain data specific to different job types; the meaning of this value is determined by the job type. -
getJobId
long getJobId()Returns the surrogate key of this job. A new surrogate id is automatically assigned to a newly created job, so this method can be used immediately after callingGridService.newJob(String, String)
.- Returns:
- surrogate key of this job
-
getState
java.lang.String getState()Returns the current state of this job - seeJobState
- Returns:
- current state of this job
-
getFailureReason
java.lang.String getFailureReason()Returns the failure reason of the last failed task on the job- Returns:
- failure reason of the last failed task on the job
-
getJobName
java.lang.String getJobName()Job name (for descriptive purposes only)- Returns:
- job name
-
setJobName
void setJobName(java.lang.String jobName)Sets the job name (for descriptive purposes only)- Parameters:
jobName
- job name
-
getJobType
java.lang.String getJobType()Job type (for descriptive purposes only)- Returns:
- job type
-
setJobType
void setJobType(java.lang.String jobType)Sets the job type (for descriptive purposes only) -
getJobParams
java.lang.String getJobParams()Job parameters (optional, specific to the job type)- Returns:
- job parameters (optional, specific to the job type)
-
setJobParams
void setJobParams(java.lang.String jobParams)Sets the job parameters (optional, specific to the job type) -
getCreatedByUserId
java.lang.Long getCreatedByUserId()Optionally used to indicated what user created the job- Returns:
- id of the user who created the job
-
setCreatedByUserId
void setCreatedByUserId(java.lang.Long userId)Optionally used to indicated what user created the job- Parameters:
userId
- id of the user who created the job
-
getStartTime
java.lang.Long getStartTime()Returns the job starting time in millis since epoch.- Returns:
- job starting time, or null if it has not started
-
getEndTime
java.lang.Long getEndTime()Returns the time when job is finished running (either succeeded or failure) in millis since epoch.- Returns:
- job finished time, or null if it has not ended
-
getNumberOfTasks
long getNumberOfTasks(java.lang.String state)Returns number of tasks in a job for a given state i.e. returns number of failed task in this job for FAILED state.- Parameters:
state
- value fromTaskState
(FAIL_PENDING not supported)- Returns:
- number of tasks in a job for a given state
-
getGridTaskList
java.util.List<GridTask> getGridTaskList()Returns the GridTasks added to this job- Returns:
-
getGetGridJobListenerClass
java.lang.String getGetGridJobListenerClass()Returns the class name for the listener for this job.- Returns:
GridJobListener
class name for the listener
-
getGridJobResult
java.lang.String getGridJobResult()
-