Class LatencyTrackerComputation
- java.lang.Object
-
- org.nuxeo.lib.stream.computation.AbstractComputation
-
- org.nuxeo.lib.stream.tools.command.LatencyTrackerComputation
-
- All Implemented Interfaces:
Computation
- Direct Known Subclasses:
LatencyDatadogComputation
,LatencyMonitorComputation
public class LatencyTrackerComputation extends AbstractComputation
A computation that sends periodically latencies information into a Log.- Since:
- 10.1
-
-
Field Summary
Fields Modifier and Type Field Description protected Codec<Record>
codec
protected int
count
protected int
intervalMs
protected List<LogPartitionGroup>
logGroups
protected List<Name>
logNames
protected LogManager
manager
protected static String
OUTPUT_STREAM
protected int
refreshGroupCounter
protected int
remaining
protected boolean
verbose
-
Fields inherited from class org.nuxeo.lib.stream.computation.AbstractComputation
INPUT_1, INPUT_2, INPUT_3, INPUT_NULL, metadata, OUTPUT_1, OUTPUT_2, OUTPUT_3, OUTPUT_4
-
-
Constructor Summary
Constructors Constructor Description LatencyTrackerComputation(LogManager manager, List<Name> logNames, String computationName, int intervalSecond, int count, boolean verbose, Codec<Record> codec, int outputStream)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LogPartitionGroup
decodeKey(String key)
void
destroy()
Called when the framework is ready to shutdown the computation.static String
encodeKey(LogPartitionGroup logGroup, int partition)
protected byte[]
encodeLatency(Latency latency)
protected List<LogPartitionGroup>
getLogGroup()
void
init(ComputationContext context)
Called when the framework has registered the computation successfully.protected void
processLatencies(ComputationContext context, LogPartitionGroup logGroup, List<Latency> latencies)
void
processRecord(ComputationContext context, String inputStreamName, Record record)
Process an incoming record on one of the computation's input streams.void
processTimer(ComputationContext context, String key, long timestamp)
Process a timer callback previously set viaComputationContext.setTimer(String, long)
.protected boolean
refreshGroup()
-
Methods inherited from class org.nuxeo.lib.stream.computation.AbstractComputation
metadata, processFailure, processRetry
-
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
signalStop
-
-
-
-
Field Detail
-
OUTPUT_STREAM
protected static final String OUTPUT_STREAM
- See Also:
- Constant Field Values
-
manager
protected final LogManager manager
-
intervalMs
protected final int intervalMs
-
count
protected final int count
-
verbose
protected final boolean verbose
-
remaining
protected int remaining
-
logGroups
protected final List<LogPartitionGroup> logGroups
-
refreshGroupCounter
protected int refreshGroupCounter
-
-
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
- Overrides:
init
in classAbstractComputation
- 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
- Overrides:
processTimer
in classAbstractComputation
- 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.
-
getLogGroup
protected List<LogPartitionGroup> getLogGroup()
-
refreshGroup
protected boolean refreshGroup()
-
processLatencies
protected void processLatencies(ComputationContext context, LogPartitionGroup logGroup, List<Latency> latencies)
-
encodeLatency
protected byte[] encodeLatency(Latency latency)
-
encodeKey
public static String encodeKey(LogPartitionGroup logGroup, int partition)
-
decodeKey
public static LogPartitionGroup decodeKey(String key)
-
destroy
public void destroy()
Description copied from interface:Computation
Called when the framework is ready to shutdown the computation. Gives users a chance to perform some cleanup before the process is killed.
-
processRecord
public void processRecord(ComputationContext context, String inputStreamName, Record record)
Description copied from interface:Computation
Process an incoming record on one of the computation's input streams.- Parameters:
context
- The computation context object provided by the system.inputStreamName
- Name of the input stream that provides the record.record
- The record.
-
-