SMILA 1.0 API documentation

org.eclipse.smila.jobmanager.taskgenerator
Class TaskGeneratorBase

java.lang.Object
  extended by org.eclipse.smila.jobmanager.taskgenerator.TaskGeneratorBase
All Implemented Interfaces:
TaskGenerator
Direct Known Subclasses:
CombineInputWithAllTaskGenerator, DefaultTaskGenerator

public abstract class TaskGeneratorBase
extends java.lang.Object
implements TaskGenerator


Field Summary
protected  Log _log
          local logger.
protected  ObjectStoreService _objectStore
          service reference to objectstore.
static java.lang.String PROPERTY_GENERATOR_NAME
          name of property that specifies the generator name in the component description.
 
Constructor Summary
TaskGeneratorBase()
           
 
Method Summary
protected  void activate(ComponentContext context)
          get value of PROPERTY_GENERATOR_NAME in component description.
protected  void addOutputBulks(Task task, Bucket inputBucket, java.util.Map<java.lang.String,Bucket> outputBuckets, AnyMap variableValues)
          create a bulk Id for each output bucket and add it to the task.
protected  void addOutputBulks(Task task, Bucket inputBucket, java.util.Map<java.lang.String,Bucket> outputBuckets, AnyMap variableValues, java.lang.String suffix)
          create a bulk Id for each output bucket and add it to the task.
protected  void checkBucketCounts(java.util.Map<java.lang.String,Bucket> inputBuckets, int expectedNumberOfInputBuckets, java.util.Map<java.lang.String,Bucket> outputBuckets, int expectedNumberOfOutputBuckets)
          check number of buckets passed as input and output.
 java.util.List<Task> createCompletionTasks(java.util.Map<java.lang.String,Bucket> inputBuckets, java.util.Map<java.lang.String,Bucket> outputBuckets, AnyMap parameters, java.lang.String workerName)
          Creates tasks for the completion workflow run, i.e. the run just before the job run is completed to to some cleanup/completion work.
 java.util.List<Task> createRunOnceTasks(java.util.Map<java.lang.String,Bucket> inputBuckets, java.util.Map<java.lang.String,Bucket> outputBuckets, AnyMap parameters, java.lang.String workerName)
          Creates tasks for the RunOnce mode, i.e. for all objects in the input bucket of the start action.
protected  Task createSingleBulkTask(java.lang.String objectId, java.lang.String inputSlotName, Bucket inputBucket, java.util.Map<java.lang.String,Bucket> outputBuckets, AnyMap parameters, java.lang.String workerName)
           
protected  Task createTask(java.lang.String workerName, AnyMap parameters)
           
static java.lang.String createTaskId()
          Creates an unique id.
 void finishTask(Task task, TaskCompletionStatus taskState)
          
 java.lang.String getName()
           
protected  double getParameterValue(java.lang.String parameterValue, double defaultValue)
          Delivers value from given string value.
protected  int getParameterValue(java.lang.String parameterValue, int defaultValue)
          Delivers value from given string value.
protected  long getParameterValue(java.lang.String parameterValue, long defaultValue)
          Delivers value from given string value.
 void setObjectStoreService(ObjectStoreService objectStore)
          method for DS to set a service reference.
 void unsetObjectStoreService(ObjectStoreService objectStore)
          method for DS to unset a service reference.
 void validateParameters(AnyMap parameters)
          Check complex parameters in some task generators if desired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.smila.jobmanager.taskgenerator.TaskGenerator
createTasks
 

Field Detail

PROPERTY_GENERATOR_NAME

public static final java.lang.String PROPERTY_GENERATOR_NAME
name of property that specifies the generator name in the component description.

See Also:
Constant Field Values

_log

protected final Log _log
local logger.


_objectStore

protected ObjectStoreService _objectStore
service reference to objectstore.

Constructor Detail

TaskGeneratorBase

public TaskGeneratorBase()
Method Detail

createTaskId

public static java.lang.String createTaskId()
Creates an unique id.

Returns:
unique id

getName

public java.lang.String getName()
Specified by:
getName in interface TaskGenerator
Returns:
generator name, read from component description.

finishTask

public void finishTask(Task task,
                       TaskCompletionStatus taskState)
                throws TaskGeneratorException

Specified by:
finishTask in interface TaskGenerator
Parameters:
task - The task to be cleaned up
taskState - TODO
Throws:
TaskGeneratorException - error while cleaning up for finished task

activate

protected void activate(ComponentContext context)
get value of PROPERTY_GENERATOR_NAME in component description.

Parameters:
context - OSGi service component context.

createTask

protected Task createTask(java.lang.String workerName,
                          AnyMap parameters)
Parameters:
workerName - name of worker
parameters - task parameters
Returns:
task for worker and with given parameters.

addOutputBulks

protected void addOutputBulks(Task task,
                              Bucket inputBucket,
                              java.util.Map<java.lang.String,Bucket> outputBuckets,
                              AnyMap variableValues)
create a bulk Id for each output bucket and add it to the task.

Parameters:
task - task
inputBucket - needed for special uuid handling
outputBuckets - map of slot names to buckets
variableValues - predefined (e.g. extracted from input bulks) values for data object type variables. May be null.

addOutputBulks

protected void addOutputBulks(Task task,
                              Bucket inputBucket,
                              java.util.Map<java.lang.String,Bucket> outputBuckets,
                              AnyMap variableValues,
                              java.lang.String suffix)
create a bulk Id for each output bucket and add it to the task.

Parameters:
task - task
inputBucket - needed for special uuid handling
outputBuckets - map of slot names to buckets
variableValues - predefined (e.g. extracted from input bulks) values for data object type variables. May be null.
suffix - optional suffix for all bulk object Ids.

checkBucketCounts

protected void checkBucketCounts(java.util.Map<java.lang.String,Bucket> inputBuckets,
                                 int expectedNumberOfInputBuckets,
                                 java.util.Map<java.lang.String,Bucket> outputBuckets,
                                 int expectedNumberOfOutputBuckets)
                          throws TaskGeneratorException
check number of buckets passed as input and output. Use a negative number to disable a check.

Parameters:
inputBuckets - .
expectedNumberOfInputBuckets - .
outputBuckets - .
expectedNumberOfOutputBuckets - .
Throws:
TaskGeneratorException - if size of bucket maps does not match the corresponding expectedNumber argument.

createRunOnceTasks

public java.util.List<Task> createRunOnceTasks(java.util.Map<java.lang.String,Bucket> inputBuckets,
                                               java.util.Map<java.lang.String,Bucket> outputBuckets,
                                               AnyMap parameters,
                                               java.lang.String workerName)
                                        throws TaskGeneratorException
Creates tasks for the RunOnce mode, i.e. for all objects in the input bucket of the start action.

Specified by:
createRunOnceTasks in interface TaskGenerator
Parameters:
inputBuckets - key: input slot name, value: bucket for this slot
outputBuckets - key: output slot name, value: bucket for this slot
parameters - key: param name, value: (evaluated) param value
workerName - (action) worker for which to create new tasks
Returns:
a list of new generated tasks
Throws:
TaskGeneratorException - error while generating tasks

createCompletionTasks

public java.util.List<Task> createCompletionTasks(java.util.Map<java.lang.String,Bucket> inputBuckets,
                                                  java.util.Map<java.lang.String,Bucket> outputBuckets,
                                                  AnyMap parameters,
                                                  java.lang.String workerName)
                                           throws TaskGeneratorException
Creates tasks for the completion workflow run, i.e. the run just before the job run is completed to to some cleanup/completion work.

Specified by:
createCompletionTasks in interface TaskGenerator
Parameters:
inputBuckets - key: input slot name, value: bucket for this slot
outputBuckets - key: output slot name, value: bucket for this slot
parameters - key: param name, value: (evaluated) param value
workerName - (action) worker for which to create new tasks
Returns:
a list of new generated tasks
Throws:
TaskGeneratorException - error while generating tasks

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.

getParameterValue

protected int getParameterValue(java.lang.String parameterValue,
                                int defaultValue)
Delivers value from given string value. If something goes wrong, default value will be delivered.

Parameters:
parameterValue - The given parameter value
Returns:
The value

getParameterValue

protected long getParameterValue(java.lang.String parameterValue,
                                 long defaultValue)
Delivers value from given string value. If something goes wrong, default value will be delivered.

Parameters:
parameterValue - The given parameter value
Returns:
The value

getParameterValue

protected double getParameterValue(java.lang.String parameterValue,
                                   double defaultValue)
Delivers value from given string value. If something goes wrong, default value will be delivered.

Parameters:
parameterValue - The given parameter value
Returns:
The value

validateParameters

public void validateParameters(AnyMap parameters)
                        throws TaskGeneratorException
Check complex parameters in some task generators if desired. Do nothing if no check desired.

Specified by:
validateParameters in interface TaskGenerator
Parameters:
parameters - The map with the parameters
Throws:
TaskGeneratorException - an exception if something is wrong with the parameters

createSingleBulkTask

protected Task createSingleBulkTask(java.lang.String objectId,
                                    java.lang.String inputSlotName,
                                    Bucket inputBucket,
                                    java.util.Map<java.lang.String,Bucket> outputBuckets,
                                    AnyMap parameters,
                                    java.lang.String workerName)
Returns:
a task for the given input bulk

SMILA 1.0 API documentation