Class NewtsFetchStrategy
- java.lang.Object
-
- org.opennms.netmgt.measurements.impl.NewtsFetchStrategy
-
- All Implemented Interfaces:
MeasurementFetchStrategy
public class NewtsFetchStrategy extends 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 theSampleRepositorywill 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 classNewtsFetchStrategy.LateAggregationParams
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_HEARTBEAT_MSstatic intINTERVAL_DIVIDERstatic longMIN_STEP_MSstatic intPARALLELISM
-
Constructor Summary
Constructors Constructor Description NewtsFetchStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FetchResultsfetch(long start, long end, long step, int maxrows, Long interval, Long heartbeat, List<Source> sources, boolean relaxed)Fetches the measurements for the given sources.protected static NewtsFetchStrategy.LateAggregationParamsgetLagParams(long step, Long interval, Long heartbeat)Calculates the parameters to use for late aggregation.protected voidsetContext(org.opennms.newts.api.Context context)protected voidsetResourceDao(ResourceDao resourceDao)protected voidsetSampleRepository(org.opennms.newts.api.SampleRepository sampleRepository)
-
-
-
Method Detail
-
fetch
public FetchResults fetch(long start, long end, long step, int maxrows, Long interval, Long heartbeat, List<Source> sources, boolean relaxed)
Description copied from interface:MeasurementFetchStrategyFetches the measurements for the given sources.- Specified by:
fetchin 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- iffalsea missing source results in a return ofnull.trueon 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, Long interval, 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)
-
-