Package org.nuxeo.lib.stream.computation
Class AbstractComputation
- java.lang.Object
-
- org.nuxeo.lib.stream.computation.AbstractComputation
-
- All Implemented Interfaces:
Computation
- Direct Known Subclasses:
AbstractBatchComputation
,AbstractBulkComputation
,AbstractTransientBlobComputation
,BulkIndexComputation
,BulkScrollerComputation
,BulkStatusComputation
,IndexCompletionComputation
,LatencyTrackerComputation
,StreamAuditStorageWriter.AuditStorageLogWriterComputation
,StreamIntrospectionComputation
,StreamMetricsComputation
,WorkComputation
,WorkManagerRunWorkInFailure.WorkFailureComputation
public abstract class AbstractComputation extends Object implements Computation
An abstractComputation
that manages the metadata init.By convention the inputs streams are named internally: i1, i2 ...
and the output streams are named: o1, o2 ...
- Since:
- 9.3
-
-
Constructor Summary
Constructors Constructor Description AbstractComputation(String name, int nbInputStreams, int nbOutputStreams)
Creates a computation with the requested number of input and output streams.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
init(ComputationContext context)
Called when the framework has registered the computation successfully.ComputationMetadata
metadata()
Identify the computation.void
processFailure(ComputationContext context, Throwable failure)
void
processRetry(ComputationContext context, Throwable failure)
void
processTimer(ComputationContext context, String key, long timestamp)
Process a timer callback previously set viaComputationContext.setTimer(String, long)
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.lib.stream.computation.Computation
destroy, processRecord, signalStop
-
-
-
-
Field Detail
-
metadata
protected final ComputationMetadata metadata
-
INPUT_1
public static final String INPUT_1
- See Also:
- Constant Field Values
-
INPUT_2
public static final String INPUT_2
- See Also:
- Constant Field Values
-
INPUT_3
public static final String INPUT_3
- See Also:
- Constant Field Values
-
OUTPUT_1
public static final String OUTPUT_1
- See Also:
- Constant Field Values
-
OUTPUT_2
public static final String OUTPUT_2
- See Also:
- Constant Field Values
-
OUTPUT_3
public static final String OUTPUT_3
- See Also:
- Constant Field Values
-
OUTPUT_4
public static final String OUTPUT_4
- See Also:
- Constant Field Values
-
INPUT_NULL
public static final String INPUT_NULL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractComputation
public AbstractComputation(String name, int nbInputStreams, int nbOutputStreams)
Creates a computation with the requested number of input and output streams.- Since:
- 10.3
-
-
Method Detail
-
init
public void init(ComputationContext context)
Description copied from interface:Computation
Called when the framework has registered the computation successfully. Gives users a first opportunity to schedule timer callbacks and produce records. This method can be called multiple times.- Specified by:
init
in interfaceComputation
- Parameters:
context
- The computation context object provided by the system.
-
processTimer
public void processTimer(ComputationContext context, String key, long timestamp)
Description copied from interface:Computation
Process a timer callback previously set viaComputationContext.setTimer(String, long)
.- Specified by:
processTimer
in interfaceComputation
- Parameters:
context
- The computation context object provided by the system.key
- The name of the timer.timestamp
- The timestamp (in ms) for which the callback was scheduled.
-
metadata
public ComputationMetadata metadata()
Description copied from interface:Computation
Identify the computation.- Specified by:
metadata
in interfaceComputation
- Returns:
- computation's metadata.
-
processRetry
public void processRetry(ComputationContext context, Throwable failure)
Description copied from interface:Computation
Called after a failure inComputation.processRecord(org.nuxeo.lib.stream.computation.ComputationContext, java.lang.String, org.nuxeo.lib.stream.computation.Record)
orComputation.processTimer(org.nuxeo.lib.stream.computation.ComputationContext, java.lang.String, long)
before retrying.- Specified by:
processRetry
in interfaceComputation
-
processFailure
public void processFailure(ComputationContext context, Throwable failure)
Description copied from interface:Computation
Called whenComputation.processRecord(org.nuxeo.lib.stream.computation.ComputationContext, java.lang.String, org.nuxeo.lib.stream.computation.Record)
orComputation.processTimer(org.nuxeo.lib.stream.computation.ComputationContext, java.lang.String, long)
fails and cannot be retried.- Specified by:
processFailure
in interfaceComputation
-
-