Class LogStreamProcessor
- java.lang.Object
-
- org.nuxeo.lib.stream.computation.log.LogStreamProcessor
-
- All Implemented Interfaces:
StreamProcessor
public class LogStreamProcessor extends Object implements StreamProcessor
- Since:
- 9.3
-
-
Field Summary
Fields Modifier and Type Field Description protected LogManagermanagerprotected booleanneedRegisterprotected static com.fasterxml.jackson.databind.ObjectMapperOBJECT_MAPPERprotected List<ComputationPool>poolsprotected Settingssettingsprotected LogStreamManagerstreamManagerprotected Topologytopology
-
Constructor Summary
Constructors Constructor Description LogStreamProcessor(LogStreamManager streamManager)LogStreamProcessor(LogManager manager)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandrainAndStop(Duration timeout)Stop computations when input streams are empty.protected Codec<Record>getCodecForStreams(String name, Set<String> streams)protected List<List<LogPartition>>getDefaultAssignments(ComputationMetadataMapping meta)protected StringgetEdgeName(Topology.Vertex edge)LatencygetLatency(String computationName)Returns the latency for a computation.longgetLowWatermark()Returns the low watermark for all the computations of the topology.longgetLowWatermark(String computationName)Returns the low watermark for the computation.StreamProcessorinit(Topology topology, Settings settings)Initialize streams, but don't run the computationsprotected List<ComputationPool>initPools()booleanisDone(long timestamp)Returns true if all messages with a lower timestamp has been processed by the topology.booleanisTerminated()True if there is no active processing threads.voidshutdown()Shutdown immediately.voidstart()Run the initialized computations.booleanstartComputation(Name computation)Start a computation thread pool that has been stopped usingStreamProcessor.stopComputation(Name)booleanstop(Duration timeout)Try to stop computations gracefully after processing a record or a timer within the timeout duration.booleanstopComputation(Name computation)Stop a computation thread pool.StringtoJson(Map<String,String> meta)Returns a JSON representation of the processor, this includes the list of streams and computations with their settings along with the topology.booleanwaitForAssignments(Duration timeout)Wait for the computations to have assigned partitions ready to process records.
-
-
-
Field Detail
-
manager
protected final LogManager manager
-
topology
protected Topology topology
-
settings
protected Settings settings
-
pools
protected List<ComputationPool> pools
-
streamManager
protected LogStreamManager streamManager
-
needRegister
protected final boolean needRegister
-
OBJECT_MAPPER
protected static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
-
-
Constructor Detail
-
LogStreamProcessor
@Deprecated public LogStreamProcessor(LogManager manager)
Deprecated.
-
LogStreamProcessor
public LogStreamProcessor(LogStreamManager streamManager)
-
-
Method Detail
-
init
public StreamProcessor init(Topology topology, Settings settings)
Description copied from interface:StreamProcessorInitialize streams, but don't run the computations- Specified by:
initin interfaceStreamProcessor
-
start
public void start()
Description copied from interface:StreamProcessorRun the initialized computations.- Specified by:
startin interfaceStreamProcessor
-
waitForAssignments
public boolean waitForAssignments(Duration timeout) throws InterruptedException
Description copied from interface:StreamProcessorWait for the computations to have assigned partitions ready to process records. The processor must be started. This is useful for writing unit test.Returns
trueif all computations have assigned partitions during the timeout delay.- Specified by:
waitForAssignmentsin interfaceStreamProcessor- Throws:
InterruptedException
-
isTerminated
public boolean isTerminated()
Description copied from interface:StreamProcessorTrue if there is no active processing threads.- Specified by:
isTerminatedin interfaceStreamProcessor
-
toJson
public String toJson(Map<String,String> meta)
Description copied from interface:StreamProcessorReturns a JSON representation of the processor, this includes the list of streams and computations with their settings along with the topology.- Specified by:
toJsonin interfaceStreamProcessor
-
stopComputation
public boolean stopComputation(Name computation)
Description copied from interface:StreamProcessorStop a computation thread pool.- Specified by:
stopComputationin interfaceStreamProcessor- Returns:
- true if computation thread pool was found and stopped.
-
startComputation
public boolean startComputation(Name computation)
Description copied from interface:StreamProcessorStart a computation thread pool that has been stopped usingStreamProcessor.stopComputation(Name)- Specified by:
startComputationin interfaceStreamProcessor- Returns:
- true if computation thread pool has been started.
-
getEdgeName
protected String getEdgeName(Topology.Vertex edge)
-
stop
public boolean stop(Duration timeout)
Description copied from interface:StreamProcessorTry to stop computations gracefully after processing a record or a timer within the timeout duration. If this can not be done within the timeout, shutdown and returns false.- Specified by:
stopin interfaceStreamProcessor
-
drainAndStop
public boolean drainAndStop(Duration timeout)
Description copied from interface:StreamProcessorStop computations when input streams are empty. The timeout is applied for each computation, the total duration can be up to nb computations * timeoutReturns
trueif computations are stopped during the timeout delay.- Specified by:
drainAndStopin interfaceStreamProcessor
-
shutdown
public void shutdown()
Description copied from interface:StreamProcessorShutdown immediately.- Specified by:
shutdownin interfaceStreamProcessor
-
getLowWatermark
public long getLowWatermark()
Description copied from interface:StreamProcessorReturns the low watermark for all the computations of the topology. Any message with an offset below the low watermark has been processed. The returned watermark is local to this processing node.- Specified by:
getLowWatermarkin interfaceStreamProcessor
-
getLatency
public Latency getLatency(String computationName)
Description copied from interface:StreamProcessorReturns the latency for a computation. This works also for distributed computations.- Specified by:
getLatencyin interfaceStreamProcessor
-
getLowWatermark
public long getLowWatermark(String computationName)
Description copied from interface:StreamProcessorReturns the low watermark for the computation. Any message with an offset below the low watermark has been processed by this computation and its ancestors. The returned watermark is local to this processing node, if the computation is distributed the global low watermark is the minimum of all nodes low watermark.- Specified by:
getLowWatermarkin interfaceStreamProcessor
-
isDone
public boolean isDone(long timestamp)
Description copied from interface:StreamProcessorReturns true if all messages with a lower timestamp has been processed by the topology.- Specified by:
isDonein interfaceStreamProcessor
-
initPools
protected List<ComputationPool> initPools()
-
getDefaultAssignments
protected List<List<LogPartition>> getDefaultAssignments(ComputationMetadataMapping meta)
-
-