Class StreamIntrospectionComputation
- java.lang.Object
-
- org.nuxeo.lib.stream.computation.AbstractComputation
-
- org.nuxeo.ecm.core.bulk.introspection.StreamIntrospectionComputation
-
- All Implemented Interfaces:
Computation
public class StreamIntrospectionComputation extends AbstractComputation
A computation that reads processor and metrics streams to build a representation of stream activities in the cluster. The representation is pushed to the KV Store.- Since:
- 11.5
-
-
Field Summary
Fields Modifier and Type Field Description protected static longCHECK_INTERVAL_MSprotected intcurrentWorkerNodesstatic StringINTROSPECTION_KEYstatic StringINTROSPECTION_KV_STOREprotected longlastMetricsReceivedprotected Map<String,com.fasterxml.jackson.databind.JsonNode>metricsprotected Stringmodelstatic StringNAMEprotected static com.fasterxml.jackson.databind.ObjectMapperOBJECT_MAPPERprotected Map<String,com.fasterxml.jackson.databind.JsonNode>processorsprotected io.dropwizard.metrics5.MetricRegistryregistryprotected intscaleMetricprotected Map<String,com.fasterxml.jackson.databind.JsonNode>streamsprotected static longTTL_SECONDS-
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 StreamIntrospectionComputation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbuildModel()protected intgetCurrentWorkerNodes()protected com.fasterxml.jackson.databind.JsonNodegetJson(Record record)protected KeyValueStoregetKvStore()protected StringgetProcessorKey(com.fasterxml.jackson.databind.JsonNode json)protected intgetScaleMetric()voidinit(ComputationContext context)Called when the framework has registered the computation successfully.protected voidloadModel(String modelJson)voidprocessRecord(ComputationContext context, String inputStreamName, Record record)Process an incoming record on one of the computation's input streams.voidprocessTimer(ComputationContext context, String key, long timestamp)Process a timer callback previously set viaComputationContext.setTimer(String, long).protected voidremoveOldNodes()protected voidupdateModel()protected voidupdateStreamsAndProcessors(com.fasterxml.jackson.databind.JsonNode node)-
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
destroy, signalStop
-
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
INTROSPECTION_KV_STORE
public static final String INTROSPECTION_KV_STORE
- See Also:
- Constant Field Values
-
INTROSPECTION_KEY
public static final String INTROSPECTION_KEY
- See Also:
- Constant Field Values
-
OBJECT_MAPPER
protected static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
-
TTL_SECONDS
protected static final long TTL_SECONDS
- See Also:
- Constant Field Values
-
CHECK_INTERVAL_MS
protected static final long CHECK_INTERVAL_MS
- See Also:
- Constant Field Values
-
model
protected String model
-
registry
protected final io.dropwizard.metrics5.MetricRegistry registry
-
scaleMetric
protected int scaleMetric
-
currentWorkerNodes
protected int currentWorkerNodes
-
lastMetricsReceived
protected long lastMetricsReceived
-
-
Method Detail
-
init
public void init(ComputationContext context)
Description copied from interface:ComputationCalled 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:
initin interfaceComputation- Overrides:
initin classAbstractComputation- Parameters:
context- The computation context object provided by the system.
-
getCurrentWorkerNodes
protected int getCurrentWorkerNodes()
-
getScaleMetric
protected int getScaleMetric()
-
loadModel
protected void loadModel(String modelJson)
-
processTimer
public void processTimer(ComputationContext context, String key, long timestamp)
Description copied from interface:ComputationProcess a timer callback previously set viaComputationContext.setTimer(String, long).- Specified by:
processTimerin interfaceComputation- Overrides:
processTimerin 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.
-
processRecord
public void processRecord(ComputationContext context, String inputStreamName, Record record)
Description copied from interface:ComputationProcess 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.
-
updateStreamsAndProcessors
protected void updateStreamsAndProcessors(com.fasterxml.jackson.databind.JsonNode node)
-
getProcessorKey
protected String getProcessorKey(com.fasterxml.jackson.databind.JsonNode json)
-
updateModel
protected void updateModel()
-
getKvStore
protected KeyValueStore getKvStore()
-
buildModel
protected void buildModel()
-
removeOldNodes
protected void removeOldNodes()
-
getJson
protected com.fasterxml.jackson.databind.JsonNode getJson(Record record)
-
-