Class ComputationContextImpl
- java.lang.Object
-
- org.nuxeo.lib.stream.computation.internals.ComputationContextImpl
-
- All Implemented Interfaces:
ComputationContext
public class ComputationContextImpl extends Object implements ComputationContext
- Since:
- 9.3
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
checkpointFlag
protected boolean
isSpare
protected LogOffset
lastOffset
protected long
lowWatermark
protected StreamManager
manager
protected ComputationMetadataMapping
metadata
protected ComputationPolicy
policy
protected Map<String,List<Record>>
streamRecords
protected boolean
terminateFlag
protected Map<String,Long>
timers
-
Constructor Summary
Constructors Constructor Description ComputationContextImpl(ComputationMetadataMapping computationMetadataMapping)
ComputationContextImpl(StreamManager streamManager, ComputationMetadataMapping metadata, ComputationPolicy policy)
ComputationContextImpl(StreamManager streamManager, ComputationMetadataMapping metadata, ComputationPolicy policy, boolean isSpare)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
askForCheckpoint()
Ask for checkpoint in order to send records, save input stream offset positions.void
askForTermination()
Ask to terminate this computation.void
cancelAskForCheckpoint()
Finally cancel the request to checkpoint the positions.LogOffset
getLastOffset()
ComputationPolicy
getPolicy()
Gets the policy used to run the computation.List<Record>
getRecords(String streamName)
long
getSourceLowWatermark()
Map<String,Long>
getTimers()
boolean
isSpareComputation()
void
produceRecord(String streamName, Record record)
void
produceRecordImmediate(String streamName, String key, byte[] data)
LogOffset
produceRecordImmediate(String streamName, Record record)
Writes to an output stream immediately.void
removeCheckpointFlag()
void
removeTimer(String key)
boolean
requireCheckpoint()
boolean
requireTerminate()
void
setLastOffset(LogOffset lastOffset)
void
setSourceLowWatermark(long watermark)
Set the low watermark for a source computation.void
setTimer(String key, long time)
Register a timer callback for some point in the futureString
toString()
-
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 Detail
-
metadata
protected final ComputationMetadataMapping metadata
-
streamRecords
protected final Map<String,List<Record>> streamRecords
-
manager
protected final StreamManager manager
-
policy
protected final ComputationPolicy policy
-
isSpare
protected final boolean isSpare
-
checkpointFlag
protected boolean checkpointFlag
-
lowWatermark
protected long lowWatermark
-
terminateFlag
protected boolean terminateFlag
-
lastOffset
protected LogOffset lastOffset
-
-
Constructor Detail
-
ComputationContextImpl
public ComputationContextImpl(StreamManager streamManager, ComputationMetadataMapping metadata, ComputationPolicy policy, boolean isSpare)
-
ComputationContextImpl
public ComputationContextImpl(StreamManager streamManager, ComputationMetadataMapping metadata, ComputationPolicy policy)
-
ComputationContextImpl
public ComputationContextImpl(ComputationMetadataMapping computationMetadataMapping)
-
-
Method Detail
-
getRecords
public List<Record> getRecords(String streamName)
-
setTimer
public void setTimer(String key, long time)
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
public void removeTimer(String key)
-
produceRecord
public void produceRecord(String streamName, Record record)
- Specified by:
produceRecord
in interfaceComputationContext
-
produceRecordImmediate
public LogOffset produceRecordImmediate(String streamName, Record record)
Writes to an output stream immediately. This will creates systematically duplicates on errors, always useproduceRecord(String, Record)
when possible.
-
produceRecordImmediate
public void produceRecordImmediate(String streamName, String key, byte[] data)
-
getLastOffset
public LogOffset getLastOffset()
- Specified by:
getLastOffset
in interfaceComputationContext
- Returns:
- the LogOffset of the last record read.
-
getPolicy
public ComputationPolicy 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
public void setLastOffset(LogOffset lastOffset)
-
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()
-
-