Class ComputationContextImpl
java.lang.Object
org.nuxeo.lib.stream.computation.internals.ComputationContextImpl
- All Implemented Interfaces:
ComputationContext
- Since:
- 9.3
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected final boolean
protected LogOffset
protected long
protected final StreamManager
protected final ComputationMetadataMapping
protected final ComputationPolicy
protected boolean
-
Constructor Summary
ConstructorDescriptionComputationContextImpl
(ComputationMetadataMapping computationMetadataMapping) ComputationContextImpl
(StreamManager streamManager, ComputationMetadataMapping metadata, ComputationPolicy policy) ComputationContextImpl
(StreamManager streamManager, ComputationMetadataMapping metadata, ComputationPolicy policy, boolean isSpare) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Ask for checkpoint in order to send records, save input stream offset positions.void
Ask to terminate this computation.void
Finally cancel the request to checkpoint the positions.Gets the policy used to run the computation.getRecords
(String streamName) long
boolean
void
produceRecord
(String streamName, Record record) void
produceRecordImmediate
(String streamName, String key, byte[] data) produceRecordImmediate
(String streamName, Record record) Writes to an output stream immediately.void
void
removeTimer
(String key) boolean
boolean
void
setLastOffset
(LogOffset lastOffset) void
setSourceLowWatermark
(long watermark) Set the low watermark for a source computation.void
Register a timer callback for some point in the futuretoString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.nuxeo.lib.stream.computation.ComputationContext
produceRecord
-
Field Details
-
metadata
-
streamRecords
-
timers
-
manager
-
policy
-
isSpare
protected final boolean isSpare -
checkpointFlag
protected boolean checkpointFlag -
lowWatermark
protected long lowWatermark -
terminateFlag
protected boolean terminateFlag -
lastOffset
-
-
Constructor Details
-
ComputationContextImpl
public ComputationContextImpl(StreamManager streamManager, ComputationMetadataMapping metadata, ComputationPolicy policy, boolean isSpare) -
ComputationContextImpl
public ComputationContextImpl(StreamManager streamManager, ComputationMetadataMapping metadata, ComputationPolicy policy) -
ComputationContextImpl
-
-
Method Details
-
getRecords
-
getTimers
-
setTimer
Description copied from interface:ComputationContext
Register a timer callback for some point in the future- Specified by:
setTimer
in interfaceComputationContext
- Parameters:
key
- Name of the timer callback.time
- The (ms since epoch) at which the callback should be fired
-
removeTimer
-
produceRecord
- Specified by:
produceRecord
in interfaceComputationContext
-
produceRecordImmediate
Writes to an output stream immediately. This will creates systematically duplicates on errors, always useproduceRecord(String, Record)
when possible. -
produceRecordImmediate
-
getLastOffset
- Specified by:
getLastOffset
in interfaceComputationContext
- Returns:
- the LogOffset of the last record read.
-
getPolicy
Description copied from interface:ComputationContext
Gets the policy used to run the computation.- Specified by:
getPolicy
in interfaceComputationContext
-
isSpareComputation
public boolean isSpareComputation()- Specified by:
isSpareComputation
in interfaceComputationContext
- Returns:
true
if the computation is a spare instance without any Stream partition assigned. A spare computation will not receive any record and its timer will not be executed.
-
setLastOffset
-
getSourceLowWatermark
public long getSourceLowWatermark() -
setSourceLowWatermark
public void setSourceLowWatermark(long watermark) Description copied from interface:ComputationContext
Set the low watermark for a source computation.- Specified by:
setSourceLowWatermark
in interfaceComputationContext
-
requireCheckpoint
public boolean requireCheckpoint() -
removeCheckpointFlag
public void removeCheckpointFlag() -
askForCheckpoint
public void askForCheckpoint()Description copied from interface:ComputationContext
Ask for checkpoint in order to send records, save input stream offset positions.- Specified by:
askForCheckpoint
in interfaceComputationContext
-
cancelAskForCheckpoint
public void cancelAskForCheckpoint()Description copied from interface:ComputationContext
Finally cancel the request to checkpoint the positions.- Specified by:
cancelAskForCheckpoint
in interfaceComputationContext
-
askForTermination
public void askForTermination()Description copied from interface:ComputationContext
Ask to terminate this computation.- Specified by:
askForTermination
in interfaceComputationContext
-
requireTerminate
public boolean requireTerminate() -
toString
-