SMILA (incubation) API documentation

org.eclipse.smila.taskworker
Interface TaskContext

All Known Implementing Classes:
TaskContextImpl

public interface TaskContext

The TaskContext interface provides methods for accessing input/output slot objects, accessing and logging to the objectstore, and setting statistic counters.


Method Summary
 void addDuration(java.lang.String name, double duration)
          On each call, the value is added to the existing duration value for the given name.
 void addDuration(java.lang.String name, long duration)
          On each call, the value is added to the existing duration value for the given name.
 void addToCounter(java.lang.String name, double value)
          On each call, the value is added to the existing counter value for the given name.
 void addToCounter(java.lang.String name, long value)
          On each call, the value is added to the existing counter value for the given name.
 void cancel()
          cancel task execution.
 java.util.Map<java.lang.String,java.lang.Number> getFinalCounters()
           
 Inputs getInputs()
           
 TaskLog getLog()
           
 ObjectStoreService getObjectStore()
           
 Outputs getOutputs()
           
 Task getTask()
           
 long getTimestamp()
           
 boolean isCanceled()
           
 void measureTime(java.lang.String name, long startTime)
          measure time that has elapsed since the startTime value and add the duration to the named counter.
 

Method Detail

getTask

Task getTask()
Returns:
the current task

getInputs

Inputs getInputs()
Returns:
Inputs object, for accessing objects of the input slots of the worker.

getOutputs

Outputs getOutputs()
Returns:
Outputs object, for accessing objects of the output slots of the worker.

getFinalCounters

java.util.Map<java.lang.String,java.lang.Number> getFinalCounters()
Returns:
calculate and aggregate all counters in this task context and return the complete map. Call this immediately after the worker has finished.

getTimestamp

long getTimestamp()
Returns:
a start time value to use in measureTime(String, long) to measure a duration.

measureTime

void measureTime(java.lang.String name,
                 long startTime)
measure time that has elapsed since the startTime value and add the duration to the named counter.

Parameters:
name - the name of the counter
startTime - the start time

addDuration

void addDuration(java.lang.String name,
                 long duration)
On each call, the value is added to the existing duration value for the given name. Values are assumed to describe the duration in nanoseconds and are converted to a double duration value accordingly. In the final task counters, these durations appear as duration.perform.xxx

Parameters:
name - the name of the counter
duration - the duration in nanoseconds to add.

addDuration

void addDuration(java.lang.String name,
                 double duration)
On each call, the value is added to the existing duration value for the given name. Values are assumed to describe a duration in seconds and are not changed. In the final task counters, these durations appear as duration.perform.xxx

Parameters:
name - the name of the counter
duration - the duration in seconds to add.

addToCounter

void addToCounter(java.lang.String name,
                  long value)
On each call, the value is added to the existing counter value for the given name. No conversion (e.g. milliseconds to seconds or sth. like that) is done. An example would be counting the numbers of objects in processing. The counters will appear in the final task counters.

Parameters:
name - the name of the counter
value - the value to add to the counter

addToCounter

void addToCounter(java.lang.String name,
                  double value)
On each call, the value is added to the existing counter value for the given name. No conversion (e.g. milliseconds to seconds or sth. like that) is done. An example would be counting the object sizes in processing. The counters will appear in the final task counters.

Parameters:
name - the name of the counter
value - the value to add to the counter

isCanceled

boolean isCanceled()
Returns:
true if current task is canceled, false otherwise.

cancel

void cancel()
cancel task execution.


getObjectStore

ObjectStoreService getObjectStore()
Returns:
the object store service used to access the object store.

getLog

TaskLog getLog()
Returns:
the task log, used for logging that can be accessed via REST/JSON API.

SMILA (incubation) API documentation