Class MetricStreamJoiner
- java.lang.Object
-
- com.elastisys.autoscaler.metricstreamers.streamjoiner.MetricStreamJoiner
-
- All Implemented Interfaces:
com.elastisys.autoscaler.core.api.Configurable<MetricStreamJoinerConfig>,com.elastisys.autoscaler.core.api.Service<MetricStreamJoinerConfig>,com.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStreamer<MetricStreamJoinerConfig>
public class MetricStreamJoiner extends java.lang.Object implements com.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStreamer<MetricStreamJoinerConfig>
AMetricStreamJoineris a "meta metric streamer", which consumes one or more metric streams and produces a single new metric stream by applying a join script to the consumed stream values. The `MetricStreamJoiner`'s operation can be illustrated by the following schematical image:MetricStream a -> | | MetricStream b -> | MetricStreamJoiner d: joinScript(${a}, ${b}, ${c}) | MetricStream c -> |MetricStreamJoinerlistens for values from existingMetricStreams `a`, `b`, `c` and whenever a new value is received from either stream (and at least one value has been observed on every stream and their timestamps are within `maxTimeDifference` distance of each other) the joiner stream `d` produces a new metric value being its "join function" applied to the most recently observed value from every stream. The `joinScript` can be an arbitrary JavaScript expression like
ora + b + c
The only requirement that the `joinScript` must satisfy is that the end result of executing the last script statement/expression must be a single numerical value.if (a + b > c) { a + b; } else { c; }
-
-
Constructor Summary
Constructors Constructor Description MetricStreamJoiner(org.slf4j.Logger logger, com.elastisys.scale.commons.eventbus.EventBus eventBus, java.util.List<com.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStreamer<?>> priorDeclaredMetricStreamers)Creates aMetricStreamJoiner.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(MetricStreamJoinerConfig newConfig)voidfetch()MetricStreamJoinerConfiggetConfiguration()java.lang.Class<MetricStreamJoinerConfig>getConfigurationClass()com.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStreamgetMetricStream(java.lang.String id)java.util.List<com.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStream>getMetricStreams()com.elastisys.autoscaler.core.api.types.ServiceStatusgetStatus()voidstart()voidstop()voidvalidate(MetricStreamJoinerConfig configuration)
-
-
-
Constructor Detail
-
MetricStreamJoiner
@Inject public MetricStreamJoiner(org.slf4j.Logger logger, com.elastisys.scale.commons.eventbus.EventBus eventBus, java.util.List<com.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStreamer<?>> priorDeclaredMetricStreamers)Creates aMetricStreamJoiner.- Parameters:
logger-Loggerinstance.eventBus-EventBuson which to listen for metrics.priorDeclaredMetricStreamers- The list ofMetricStreamers declared prior to thisMetricStreamerand which can be used as references in input streams. May benull, which is interpreted as an empty list.
-
-
Method Detail
-
validate
public void validate(MetricStreamJoinerConfig configuration) throws java.lang.IllegalArgumentException
- Specified by:
validatein interfacecom.elastisys.autoscaler.core.api.Configurable<MetricStreamJoinerConfig>- Throws:
java.lang.IllegalArgumentException
-
configure
public void configure(MetricStreamJoinerConfig newConfig) throws java.lang.IllegalArgumentException
- Specified by:
configurein interfacecom.elastisys.autoscaler.core.api.Configurable<MetricStreamJoinerConfig>- Throws:
java.lang.IllegalArgumentException
-
start
public void start() throws java.lang.IllegalStateException- Specified by:
startin interfacecom.elastisys.autoscaler.core.api.Service<MetricStreamJoinerConfig>- Throws:
java.lang.IllegalStateException
-
stop
public void stop()
- Specified by:
stopin interfacecom.elastisys.autoscaler.core.api.Service<MetricStreamJoinerConfig>
-
getStatus
public com.elastisys.autoscaler.core.api.types.ServiceStatus getStatus()
- Specified by:
getStatusin interfacecom.elastisys.autoscaler.core.api.Service<MetricStreamJoinerConfig>
-
getConfiguration
public MetricStreamJoinerConfig getConfiguration()
- Specified by:
getConfigurationin interfacecom.elastisys.autoscaler.core.api.Configurable<MetricStreamJoinerConfig>
-
getConfigurationClass
public java.lang.Class<MetricStreamJoinerConfig> getConfigurationClass()
- Specified by:
getConfigurationClassin interfacecom.elastisys.autoscaler.core.api.Configurable<MetricStreamJoinerConfig>
-
getMetricStreams
public java.util.List<com.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStream> getMetricStreams()
- Specified by:
getMetricStreamsin interfacecom.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStreamer<MetricStreamJoinerConfig>
-
getMetricStream
public com.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStream getMetricStream(java.lang.String id) throws java.lang.IllegalArgumentException- Specified by:
getMetricStreamin interfacecom.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStreamer<MetricStreamJoinerConfig>- Throws:
java.lang.IllegalArgumentException
-
fetch
public void fetch() throws com.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStreamException, java.lang.IllegalStateException- Specified by:
fetchin interfacecom.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStreamer<MetricStreamJoinerConfig>- Throws:
com.elastisys.autoscaler.core.monitoring.metricstreamer.api.MetricStreamExceptionjava.lang.IllegalStateException
-
-