Class MetricStreamDefinition
- java.lang.Object
-
- com.elastisys.autoscaler.metricstreamers.streamjoiner.config.MetricStreamDefinition
-
public class MetricStreamDefinition extends java.lang.ObjectDescribes aMetricStreampublished by theMetricStreamJoiner. More specifically, it declares a set of input metric streams to be consumed and a join-function used to produce output values for the joined metric stream.- See Also:
MetricStreamJoinerConfig
-
-
Field Summary
Fields Modifier and Type Field Description static com.elastisys.scale.commons.json.types.TimeIntervalDEFAULT_MAX_TIME_DIFF
-
Constructor Summary
Constructors Constructor Description MetricStreamDefinition(java.lang.String id, java.lang.String metric, java.util.Map<java.lang.String,java.lang.String> inputStreams, com.elastisys.scale.commons.json.types.TimeInterval maxTimeDiff, java.util.List<java.lang.String> joinScript)Creates aMetricStreamDefinition.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)javax.script.CompiledScriptgetCompiledJoinScript()Returns thejoinScriptas a compiled a JavaScript.java.lang.StringgetId()The id of the metric stream.java.util.Map<java.lang.String,java.lang.String>getInputStreams()Declares the input metric streams that are to be joined by this metric stream.java.lang.StringgetJoinScript()A JavaScript for the join function.com.elastisys.scale.commons.json.types.TimeIntervalgetMaxTimeDiff()The maximum difference in time between observed metric stream values for the joined metric stream to apply itsjoinScriptand produce a new value.java.lang.StringgetMetric()The name of the metric produced by this metric stream.inthashCode()java.lang.StringtoString()voidvalidate()static voidvalidJavaScriptIdentifier(java.lang.String identifier)Checks that an identifier is a valid JavaScript identifier.
-
-
-
Constructor Detail
-
MetricStreamDefinition
public MetricStreamDefinition(java.lang.String id, java.lang.String metric, java.util.Map<java.lang.String,java.lang.String> inputStreams, com.elastisys.scale.commons.json.types.TimeInterval maxTimeDiff, java.util.List<java.lang.String> joinScript)Creates aMetricStreamDefinition.- Parameters:
id- The id of the metric stream. This is the id that will be used by clients wishing to subscribe to this metric stream. Required.metric- The name of the metric produced by this metric stream. This is the metric that will be set for producedMetricValues. Optional. If left out,idis used.inputStreams- Declares the input metric streams that are to be joined by this metric stream. Keys are metric stream aliases and values are metric stream identifiers. The referenced metric streams must have been declared prior to this metric stream (note that this can be another joined metric stream). A metric stream alias needs to be a valid JavaScript identifier name, as these will be passed as variables to thejoinScript. Required.maxTimeDiff- The maximum difference in time between observed metric stream values for the joined metric stream to apply itsjoinScriptand produce a new value. If stream metrics are farther apart than this, no new metric value is produced on the joined stream. This value should be set so that values that are close enough to be considered relevant to each other can be joined. The default is 0 s, assuming that the input metric streams are scraped at the same instant. May benull.joinScript- An array of JavaScript code lines for the join function. The final statement/expression that the script executes must be a numerical value. The script can assume that, when executed, each of the metric stream aliases defined in theinputStreamssection will be assigned aNumbervalue. Required.
-
-
Method Detail
-
getId
public java.lang.String getId()
The id of the metric stream. This is the id that will be used by clients wishing to subscribe to this metric stream.- Returns:
-
getMetric
public java.lang.String getMetric()
The name of the metric produced by this metric stream. This is the metric that will be set for producedMetricValues.- Returns:
-
getInputStreams
public java.util.Map<java.lang.String,java.lang.String> getInputStreams()
Declares the input metric streams that are to be joined by this metric stream. Keys are metric stream aliases and values are metric stream identifiers. The referenced metric streams must have been declared prior to this metric stream (note that this can be another joined metric stream). A metric stream alias needs to be a valid JavaScript identifier name, as these will be passed as variables to thejoinScript.- Returns:
-
getMaxTimeDiff
public com.elastisys.scale.commons.json.types.TimeInterval getMaxTimeDiff()
The maximum difference in time between observed metric stream values for the joined metric stream to apply itsjoinScriptand produce a new value. If stream metrics are farther apart than this, no new metric value is produced on the joined stream. This value should be set so that values that are close enough to be considered relevant to each other can be joined.- Returns:
-
getJoinScript
public java.lang.String getJoinScript()
A JavaScript for the join function. The final statement/expression that the script executes must be a numerical value. The script can assume that, when executed, each of the metric stream aliases defined in theinputStreamssection will be assigned aNumbervalue.- Returns:
-
getCompiledJoinScript
public javax.script.CompiledScript getCompiledJoinScript() throws java.lang.IllegalArgumentExceptionReturns thejoinScriptas a compiled a JavaScript. If invalid, anIllegalArgumentExceptionis thrown.- Parameters:
javascript-- Throws:
java.lang.IllegalArgumentException
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
validate
public void validate() throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
validJavaScriptIdentifier
public static void validJavaScriptIdentifier(java.lang.String identifier) throws java.lang.IllegalArgumentExceptionChecks that an identifier is a valid JavaScript identifier. Throws anIllegalArgumentExceptionif it isn't.- Parameters:
identifier-- Throws:
java.lang.IllegalArgumentException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-