SMILA (incubation) API documentation

org.eclipse.smila.jobmanager.internal
Class JobManagerImpl

java.lang.Object
  extended by org.eclipse.smila.jobmanager.internal.JobManagerImpl
All Implemented Interfaces:
JobManager

public class JobManagerImpl
extends java.lang.Object
implements JobManager

Standard implementation of JobManager service.


Constructor Summary
JobManagerImpl()
           
 
Method Summary
protected  void activate(ComponentContext context)
          initialize JobManager internally on service start.
 void addJobListener(JobListener listener)
          Add a RequestHandler..
 void cancelJob(java.lang.String jobName, java.lang.String jobRunId)
           
protected  void deactivate(ComponentContext context)
          clean up JobManager on service shutdown.
 void deleteJobRunData(java.lang.String jobName, java.lang.String jobId)
          delete a previously completed job run.
 void finishJob(java.lang.String jobName, java.lang.String jobRunId)
          
 java.util.List<Task> finishTask(Task currentTask)
          Finishes a task and retrieves the following tasks.
 java.util.Collection<java.lang.String> getCompletedJobRunIds(java.lang.String jobName)
          get Ids of complete job runs.
protected  JobManagerConfiguration getConfiguration()
           
 DefinitionPersistence getDefinitionPersistence()
          
protected  DefinitionPersistence getDefPersistence()
           
protected  DefinitionStorage getDefStorage()
           
 Task getInitialTask(java.lang.String workerName, java.lang.String jobName)
          Creates an initial task for input-workers.
protected  java.util.concurrent.CopyOnWriteArrayList<JobListener> getJobListeners()
           
 AnyMap getJobRunData(java.lang.String jobName, java.lang.String jobId)
          
 AnyMap getJobRunData(java.lang.String jobName, java.lang.String jobId, boolean returnDetails)
          
 JobRunInfo getJobRunInfo(java.lang.String jobName)
          get info on current job run.
protected  java.util.Map<java.lang.String,JobRun> getJobRuns()
           
protected  ObjectStoreService getObjectStore()
           
protected  RunStorage getRunStorage()
           
 TaskGenerator getTaskGenerator(WorkerDefinition worker)
          
protected  TaskGeneratorProvider getTaskGeneratorProvider()
           
protected  TaskManager getTaskManager()
           
 AnyMap getWorkflowRunData(java.lang.String jobName, java.lang.String jobId, java.lang.String workflowRunId)
          get information about a workflow run.
protected  void handleFatalError(java.lang.String jobName, java.lang.String jobRunId, java.lang.String workflowRunId, java.lang.String workerName, Task currentTask, boolean failedAfterRetry)
           
protected  void handleObsoleteTask(java.lang.String jobName, java.lang.String jobRunId, java.lang.String workflowRunId, java.lang.String workerName, Task currentTask)
          finish obsolete task - don't create follow up tasks.
protected  java.util.List<Task> handleRecoverableTaskError(java.lang.String jobName, java.lang.String jobRunId, java.lang.String workflowRunId, java.lang.String workerName, Task currentTask, ResultDescription resultDescription)
           
protected  void handleRecoverableTaskWithAutocommit(java.lang.String jobName, java.lang.String jobRunId, java.lang.String workflowRunId, java.lang.String workerName, Task currentTask, ResultDescription resultDescription, java.util.List<Task> followUpTasks)
          recoverable error on an AUTOCOMMIT worker's task -> task is handled as succeeded.
protected  java.util.List<Task> handleSuccessfulTask(java.lang.String jobName, java.lang.String jobRunId, java.lang.String workflowRunId, java.lang.String workerName, Task currentTask, java.util.Map<java.lang.String,java.lang.Number> workerCounter)
           
 void removeJobListener(JobListener listener)
          Remove the given RequestHandler.
 void setDefinitionStorage(DefinitionStorage defStorage)
           
 void setObjectStoreService(ObjectStoreService objectStore)
          method for DS to set a service reference.
 void setRunStorage(RunStorage runStorage)
           
 void setTaskGeneratorProvider(TaskGeneratorProvider taskGeneratorProvider)
          method for DS to set a service reference.
 void setTaskManager(TaskManager taskManager)
          method for DS to set a service reference.
 java.lang.String startJob(java.lang.String jobName)
          
 java.lang.String startJob(java.lang.String jobName, JobRunMode jobRunMode)
          
 void unsetDefinitionStorage(DefinitionStorage defStorage)
           
 void unsetObjectStoreService(ObjectStoreService objectStore)
          method for DS to unset a service reference.
 void unsetRunStorage(RunStorage runStorage)
           
 void unsetTaskGeneratorProvider(TaskGeneratorProvider taskGeneratorProvider)
          method for DS to unset a service reference.
 void unsetTaskManager(TaskManager taskManager)
          method for DS to unset a service reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobManagerImpl

public JobManagerImpl()
Method Detail

activate

protected void activate(ComponentContext context)
initialize JobManager internally on service start.

Parameters:
context - OSGi service context.

deactivate

protected void deactivate(ComponentContext context)
clean up JobManager on service shutdown.

Parameters:
context - OSGi service context.

getConfiguration

protected JobManagerConfiguration getConfiguration()
Returns:
the configuration

getDefPersistence

protected DefinitionPersistence getDefPersistence()
Returns:
the defPersistence

getDefStorage

protected DefinitionStorage getDefStorage()
Returns:
the defStorage

getRunStorage

protected RunStorage getRunStorage()
Returns:
the runStorage

getObjectStore

protected ObjectStoreService getObjectStore()
Returns:
the objectStore

getTaskGeneratorProvider

protected TaskGeneratorProvider getTaskGeneratorProvider()
Returns:
the taskGeneratorProvider

getTaskManager

protected TaskManager getTaskManager()
Returns:
the taskManager

getJobRuns

protected java.util.Map<java.lang.String,JobRun> getJobRuns()
Returns:
the JobRuns

getJobListeners

protected java.util.concurrent.CopyOnWriteArrayList<JobListener> getJobListeners()
Returns:
the jobListeners

startJob

public java.lang.String startJob(java.lang.String jobName)
                          throws JobManagerException

Specified by:
startJob in interface JobManager
Parameters:
jobName - name of the job to start
Returns:
id of the new job run
Throws:
JobManagerException - error starting job

startJob

public java.lang.String startJob(java.lang.String jobName,
                                 JobRunMode jobRunMode)
                          throws JobManagerException

Specified by:
startJob in interface JobManager
Parameters:
jobName - name of the job to start
jobRunMode - the mode for the job to start.
Returns:
id of the new job run
Throws:
JobManagerException - error starting job

getJobRunData

public AnyMap getJobRunData(java.lang.String jobName,
                            java.lang.String jobId)
                     throws JobManagerException

Specified by:
getJobRunData in interface JobManager
Parameters:
jobName - name of the job for which to monitor the run.
jobId - id of the job run to get the monitoring data. May be either the current run or a completed run.
Returns:
monitoring data for the job run with the given id.
Throws:
JobManagerException - error getting job run data

getJobRunData

public AnyMap getJobRunData(java.lang.String jobName,
                            java.lang.String jobId,
                            boolean returnDetails)
                     throws JobManagerException

Specified by:
getJobRunData in interface JobManager
Parameters:
jobName - name of the job for which to monitor the run.
jobId - id of the job run to get the monitoring data. May be either the current run or a completed run.
returnDetails - whether to return details (e.g. workflow/bucket definition)
Returns:
monitoring data for the job run with the given id.
Throws:
JobManagerException - error getting job run data

getWorkflowRunData

public AnyMap getWorkflowRunData(java.lang.String jobName,
                                 java.lang.String jobId,
                                 java.lang.String workflowRunId)
                          throws JobManagerException
get information about a workflow run.

Specified by:
getWorkflowRunData in interface JobManager
Returns:
a map with JobManagerConstants.DATA_WORKFLOW_RUN_NO_OF_ACTIVE_TASKS and JobManagerConstants.DATA_WORKFLOW_RUN_NO_OF_TRANSIENT_BULKS. Additional keys may be added.
Throws:
JobManagerException - jobrun or workflowrun are not active anymore.

getJobRunInfo

public JobRunInfo getJobRunInfo(java.lang.String jobName)
                         throws JobManagerException
get info on current job run.

Specified by:
getJobRunInfo in interface JobManager
Parameters:
jobName - job name
Returns:
if job is defined and active: id and state of current run. Else null.
Throws:
JobManagerException - error getting state.

getCompletedJobRunIds

public java.util.Collection<java.lang.String> getCompletedJobRunIds(java.lang.String jobName)
                                                             throws JobManagerException
get Ids of complete job runs.

Specified by:
getCompletedJobRunIds in interface JobManager
Parameters:
jobName - job name
Returns:
Ids of completed job runs, sorted lexicographically ascending. Empty set if job is not defined or no completed job runs exists.
Throws:
JobManagerException - error getting state.

deleteJobRunData

public void deleteJobRunData(java.lang.String jobName,
                             java.lang.String jobId)
                      throws JobManagerException
delete a previously completed job run. * @param jobName name of the job for which to monitor the run.

Specified by:
deleteJobRunData in interface JobManager
jobId - id of the complete job run to delete the monitoring data.
Throws:
JobManagerException - run id is not a completed run or error deleting it.

finishJob

public void finishJob(java.lang.String jobName,
                      java.lang.String jobRunId)
               throws JobManagerException

Specified by:
finishJob in interface JobManager
Parameters:
jobName - name of the job for which to finish the run.
jobRunId - id of the job run to finish
Throws:
JobManagerException - error finishing job

cancelJob

public void cancelJob(java.lang.String jobName,
                      java.lang.String jobRunId)
               throws JobManagerException
Specified by:
cancelJob in interface JobManager
Parameters:
jobName - name of the job for which to cancel the run.
jobRunId - id of the job run to cancel
Throws:
JobManagerException - error canceling job

getInitialTask

public Task getInitialTask(java.lang.String workerName,
                           java.lang.String jobName)
                    throws JobManagerException
Creates an initial task for input-workers.

Specified by:
getInitialTask in interface JobManager
Parameters:
workerName - The name of the worker for which this task is requested.
jobName - The id of the task-source (e.g. index name, job id, ...) for which the task is requested. The TaskProducer and the worker requester of the tasks should have a common understanding of what this id is about.
Returns:
A task for the worker or null if task delivery is currently not allowed for this id.
Throws:
JobManagerException - error because there was a jobmanager exception or a non-start-action-worker tried to get an initial task.

finishTask

public java.util.List<Task> finishTask(Task currentTask)
                                throws JobManagerException
Finishes a task and retrieves the following tasks. Dependent on the resultDescription job manager can decide what to do.

Specified by:
finishTask in interface JobManager
Parameters:
currentTask - The finished task.
Returns:
A list of follow up tasks. If there are no follow-up tasks, an empty list will be generated.
Throws:
JobManagerException - error while trying to finish the task.

handleSuccessfulTask

protected java.util.List<Task> handleSuccessfulTask(java.lang.String jobName,
                                                    java.lang.String jobRunId,
                                                    java.lang.String workflowRunId,
                                                    java.lang.String workerName,
                                                    Task currentTask,
                                                    java.util.Map<java.lang.String,java.lang.Number> workerCounter)
                                             throws JobManagerException
Returns:
the follow up tasks of the task that is successfully finished.
Throws:
JobManagerException

handleObsoleteTask

protected void handleObsoleteTask(java.lang.String jobName,
                                  java.lang.String jobRunId,
                                  java.lang.String workflowRunId,
                                  java.lang.String workerName,
                                  Task currentTask)
                           throws JobManagerException
finish obsolete task - don't create follow up tasks.

Throws:
JobManagerException

handleRecoverableTaskError

protected java.util.List<Task> handleRecoverableTaskError(java.lang.String jobName,
                                                          java.lang.String jobRunId,
                                                          java.lang.String workflowRunId,
                                                          java.lang.String workerName,
                                                          Task currentTask,
                                                          ResultDescription resultDescription)
                                                   throws JobManagerException
Returns:
follow up tasks. This could be the current task in case of a retry. If the number of retries exceeded no follow up tasks are generated. In case of mode AUTOCOMMIT task is handled as succeeded.
Throws:
JobManagerException

handleRecoverableTaskWithAutocommit

protected void handleRecoverableTaskWithAutocommit(java.lang.String jobName,
                                                   java.lang.String jobRunId,
                                                   java.lang.String workflowRunId,
                                                   java.lang.String workerName,
                                                   Task currentTask,
                                                   ResultDescription resultDescription,
                                                   java.util.List<Task> followUpTasks)
                                            throws JobManagerException
recoverable error on an AUTOCOMMIT worker's task -> task is handled as succeeded.

Throws:
JobManagerException

handleFatalError

protected void handleFatalError(java.lang.String jobName,
                                java.lang.String jobRunId,
                                java.lang.String workflowRunId,
                                java.lang.String workerName,
                                Task currentTask,
                                boolean failedAfterRetry)
                         throws JobManagerException
Throws:
JobManagerException

setDefinitionStorage

public void setDefinitionStorage(DefinitionStorage defStorage)
Parameters:
defStorage - DefinitionStorage reference.

unsetDefinitionStorage

public void unsetDefinitionStorage(DefinitionStorage defStorage)
Parameters:
defStorage - DefinitionStorage reference.

setRunStorage

public void setRunStorage(RunStorage runStorage)
Parameters:
runStorage - RunStorage reference.

unsetRunStorage

public void unsetRunStorage(RunStorage runStorage)
Parameters:
runStorage - RunStorage reference.

setObjectStoreService

public void setObjectStoreService(ObjectStoreService objectStore)
method for DS to set a service reference.

Parameters:
objectStore - ObjectStoreService reference.

unsetObjectStoreService

public void unsetObjectStoreService(ObjectStoreService objectStore)
method for DS to unset a service reference.

Parameters:
objectStore - ObjectStoreService reference.

setTaskGeneratorProvider

public void setTaskGeneratorProvider(TaskGeneratorProvider taskGeneratorProvider)
method for DS to set a service reference.

Parameters:
taskGeneratorProvider - TaskGeneratorProvider reference.

unsetTaskGeneratorProvider

public void unsetTaskGeneratorProvider(TaskGeneratorProvider taskGeneratorProvider)
method for DS to unset a service reference.

Parameters:
taskGeneratorProvider - TaskGeneratorProvider reference.

setTaskManager

public void setTaskManager(TaskManager taskManager)
method for DS to set a service reference.


unsetTaskManager

public void unsetTaskManager(TaskManager taskManager)
method for DS to unset a service reference.


getTaskGenerator

public TaskGenerator getTaskGenerator(WorkerDefinition worker)

Specified by:
getTaskGenerator in interface JobManager
Parameters:
worker - The worker
Returns:
The matching task generator

addJobListener

public void addJobListener(JobListener listener)
Add a RequestHandler..

Parameters:
listener - the new RequestHandler

removeJobListener

public void removeJobListener(JobListener listener)
Remove the given RequestHandler.

Parameters:
listener - the RequestHandler

getDefinitionPersistence

public DefinitionPersistence getDefinitionPersistence()

Specified by:
getDefinitionPersistence in interface JobManager
Returns:
the DefinitionPersistence reference.

SMILA (incubation) API documentation