private void calculatePercentileDef(PercentileDef def) throws RrdException { def.calculate(tStart, tEnd); }
/** * Takes the given value and puts it in each position in the 'values' array. * @param value */ private void setValue(double value) { this.m_value = value; long[] times = getTimestamps(); if( times != null ) { int count = times.length; double[] values = new double[count]; for (int i = 0; i < count; i++) { values[i] = m_value; } setValues(values); } }
PercentileDef(String name, Source source, double percentile, boolean ignorenan) { super(name); m_percentile = percentile; m_ignorenan = ignorenan; m_source = source; //The best we can do at this point; until this object has it's value realized over a // particular time period (with calculate()), there's not much else to do this.setValue(Double.NaN); }
/** * Creates a new VDEF datasource that performs a percentile calculation on an * another named datasource to yield a single value. * * Requires that the other datasource has already been defined; otherwise, it'll * end up with no data * * @param name - the new virtual datasource name * @param sourceName - the datasource from which to extract the percentile. Must be a previously * defined virtual datasource * @param percentile - the percentile to extract from the source datasource */ public void addDatasource(String name, String sourceName, double percentile) { Source source = sources.get(sourceName); sources.put(name, new PercentileDef(name, source, percentile)); }
/** * Creates a new VDEF datasource that performs a percentile calculation on an * another named datasource to yield a single value. * * Requires that the other datasource has already been defined; otherwise, it'll * end up with no data * * @param name - the new virtual datasource name * @param sourceName - the datasource from which to extract the percentile. Must be a previously * defined virtual datasource * @param percentile - the percentile to extract from the source datasource * @param ignorenan - true if we include Double.NaN */ public void addDatasource(String name, String sourceName, double percentile, boolean ignorenan) { Source source = sources.get(sourceName); sources.put(name, new PercentileDef(name, source, percentile, ignorenan)); }
/** * Realize the calculation of this definition, over the given time period * * @param tStart the time period start * @param tEnd the time period end * @throws RrdException Thrown if we cannot get a percentile value for the time period. */ public void calculate(long tStart, long tEnd) throws RrdException { if(m_source != null) { this.setValue(m_source.getPercentile(tStart, tEnd, m_percentile)); } }
@Override void setTimestamps(long[] timestamps) { super.setTimestamps(timestamps); //And now also call setValue with the current value, to sort out "values" setValue(m_value); }