Class NewtsFetchStrategy
- java.lang.Object
-
- org.opennms.netmgt.measurements.impl.NewtsFetchStrategy
-
- All Implemented Interfaces:
MeasurementFetchStrategy
public class NewtsFetchStrategy extends java.lang.Object implements MeasurementFetchStrategy
Used to retrieve measurements fromSampleRepository
. If a request tofetch(long, long, long, int, java.lang.Long, java.lang.Long, java.util.List<org.opennms.netmgt.measurements.model.Source>, boolean)
spans multiple resources, separate calls to theSampleRepository
will be performed in parallel. Reading the samples and computing the aggregated values can be very CPU intensive. The "parallelism" attribute is used to set an upper limit on how may concurrent threads can be used to perform these calculations. By default, this is set to the number of cores, but can be reduced if the operator wishes to ensure cores are available for other purposes.- Author:
- jwhite
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
NewtsFetchStrategy.LateAggregationParams
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_HEARTBEAT_MS
static int
INTERVAL_DIVIDER
static long
MIN_STEP_MS
static int
PARALLELISM
-
Constructor Summary
Constructors Constructor Description NewtsFetchStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FetchResults
fetch(long start, long end, long step, int maxrows, java.lang.Long interval, java.lang.Long heartbeat, java.util.List<Source> sources, boolean relaxed)
Fetches the measurements for the given sources.protected static NewtsFetchStrategy.LateAggregationParams
getLagParams(long step, java.lang.Long interval, java.lang.Long heartbeat)
Calculates the parameters to use for late aggregation.protected void
setContext(org.opennms.newts.api.Context context)
protected void
setResourceDao(ResourceDao resourceDao)
protected void
setSampleRepository(org.opennms.newts.api.SampleRepository sampleRepository)
-
-
-
Method Detail
-
fetch
public FetchResults fetch(long start, long end, long step, int maxrows, java.lang.Long interval, java.lang.Long heartbeat, java.util.List<Source> sources, boolean relaxed)
Description copied from interface:MeasurementFetchStrategy
Fetches the measurements for the given sources.- Specified by:
fetch
in interfaceMeasurementFetchStrategy
- Parameters:
start
- timestamp in millisecondsend
- timestamp in millisecondsstep
- desired resolution in milliseconds - actual resolution might differmaxrows
- maximum number of rows - no limit when <= 0interval
- duration in milliseconds, used by strategies that implement late aggregationheartbeat
- duration in milliseconds, used by strategies that implement late aggregationsources
- array of sources - these should have unique labelsrelaxed
- iffalse
a missing source results in a return ofnull
.true
on the other hand ignores that source.- Returns:
- null when a resource id or attribute cannot be found
-
getLagParams
protected static NewtsFetchStrategy.LateAggregationParams getLagParams(long step, java.lang.Long interval, java.lang.Long heartbeat)
Calculates the parameters to use for late aggregation. Since we're in the process of transitioning from an RRD-world, most queries won't contain a specified interval or heartbeat. For this reason, we need to derive sensible values that will allow users to visualize the data on the graphs without too many NaNs. The given step size will be variable based on the time range and the pixel width of the graph, so we need to derive the interval and heartbeat accordingly. Let S = step, I = interval and H = heartbeat, the constraints are as follows: 0 < S 0 < I 0 < H S = aI for some integer a >= 2 H = bI for some integer b >= 2 While achieving these constraints, we also want to optimize for: min(|S - S*|) where S* is the user supplied step and S is the effective step.
-
setResourceDao
protected void setResourceDao(ResourceDao resourceDao)
-
setSampleRepository
protected void setSampleRepository(org.opennms.newts.api.SampleRepository sampleRepository)
-
setContext
protected void setContext(org.opennms.newts.api.Context context)
-
-