SMILA (incubation) API documentation

org.eclipse.smila.taskworker.output
Class Outputs

java.lang.Object
  extended by org.eclipse.smila.taskworker.io.IODataObjects
      extended by org.eclipse.smila.taskworker.output.Outputs

public class Outputs
extends IODataObjects

Returned by TaskContext.getOutputs() this class provides access to the data objects associated by a task to the output slots of a worker. It can create different kinds of Output wrappers on these data objects that make access for the workers easier. You can create only a single output wrapper for each data object. On the second call, only null will be returned.

See Also:
StreamOutput, RecordOutput, KvoOutput, AppendableOutput

Constructor Summary
Outputs(java.util.Map<java.lang.String,java.util.List<BulkInfo>> dataObjects, ObjectStoreService objectStore)
           
 
Method Summary
 void abortAll()
          Abort all open data objects, if necessary.
 void addOutputCounters(java.util.Map<java.lang.String,java.lang.Number> counters)
          aggregate counters of output slots.
 void commitAll()
          Commit all open data objects, if necessary.
<T extends Output>
T
getAsOutput(java.lang.String slotName, java.lang.Class<T> inputClass)
          Generic method to create output wrapper for the first data object in a slot.
<T extends Output>
T
getAsOutput(java.lang.String slotName, int index, java.lang.Class<T> outputClass)
          Generic method to create output wrappers.
 RecordOutput getAsRecordOutput(java.lang.String slotName)
           
 RecordOutput getAsRecordOutput(java.lang.String slotName, int index)
           
 StreamOutput getAsStreamOutput(java.lang.String slotName)
           
 StreamOutput getAsStreamOutput(java.lang.String slotName, int index)
           
 
Methods inherited from class org.eclipse.smila.taskworker.io.IODataObjects
addCounters, canCreate, getDataObject, getDataObject, getDataObjectCount, getIOData, getObjectStore, putIOData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Outputs

public Outputs(java.util.Map<java.lang.String,java.util.List<BulkInfo>> dataObjects,
               ObjectStoreService objectStore)
Parameters:
dataObjects - The data objects
objectStore - The reference to the object store service
Method Detail

getAsOutput

public <T extends Output> T getAsOutput(java.lang.String slotName,
                                        java.lang.Class<T> inputClass)
Generic method to create output wrapper for the first data object in a slot. See getAsOutput(String, int, Class) for details, this method just calls this method with index = 0

Returns:
first data object in given slot prepared for custom access. Null, if slot is not set, or an output wrapper has already been created earlier.
Throws:
java.lang.IllegalArgumentException - if the outputClass cannot be instantiated.

getAsOutput

public <T extends Output> T getAsOutput(java.lang.String slotName,
                                        int index,
                                        java.lang.Class<T> outputClass)
Generic method to create output wrappers. Any predefined subclass of Output can be used as well as custom defined class if you need it (be sure to implement the necessary constructor). For example, to get an Key-Value-Object wrapper for the first object in slot "kvoOutputSlot", use KvoOutput kvo = taskContext.getOutputs().getAsOutput("kvoOutputSlot", KvoOutput.class);

Returns:
n-th data object in given slot prepared for custom access. Null, if slot is not set, has less objects, or a wrapper has already been created earlier.
Throws:
java.lang.IllegalArgumentException - if the outputClass cannot be instantiated.
See Also:
StreamOutput, RecordOutput, KvoOutput, AppendableOutput

getAsStreamOutput

public StreamOutput getAsStreamOutput(java.lang.String slotName,
                                      int index)
Parameters:
slotName - The slot name
index - The index
Returns:
The data object as StreamOutput with given slot name and index

getAsStreamOutput

public StreamOutput getAsStreamOutput(java.lang.String slotName)
Parameters:
slotName - The slot name
Returns:
The first data object as StreamOutput with given slot name

getAsRecordOutput

public RecordOutput getAsRecordOutput(java.lang.String slotName,
                                      int index)
Parameters:
slotName - The slot name
index - The index
Returns:
The data object as RecordOutput with given slot name and index

getAsRecordOutput

public RecordOutput getAsRecordOutput(java.lang.String slotName)
Parameters:
slotName - The slot name
Returns:
The first data object as RecordOutput with given slot name

commitAll

public void commitAll()
               throws ObjectStoreException,
                      java.io.IOException
Commit all open data objects, if necessary. Called by WorkerManager after task has finished.

Throws:
ObjectStoreException
java.io.IOException

abortAll

public void abortAll()
              throws ObjectStoreException,
                     java.io.IOException
Abort all open data objects, if necessary. Called by WorkerManager after task has finished.

Throws:
ObjectStoreException
java.io.IOException

addOutputCounters

public void addOutputCounters(java.util.Map<java.lang.String,java.lang.Number> counters)
aggregate counters of output slots. Called by WorkerManager after task has finished.


SMILA (incubation) API documentation