/** * Returns archive consolidation function ("AVERAGE", "MIN", "MAX", "FIRST", "LAST" or "TOTAL"). * * @return Archive consolidation function. * @throws java.io.IOException Thrown in case of I/O error. */ public ConsolFun getConsolFun() throws IOException { return consolFun.get(); }
/** * Returns datasource type (GAUGE, COUNTER, DERIVE, ABSOLUTE). * * @return Datasource type. * @throws java.io.IOException Thrown in case of I/O error */ public DsType getType() throws IOException { return dsType.get(); }
String name() throws IOException { return get().name(); }
/** * {@inheritDoc} * * Copies object's internal state to another Datasource object. */ public void copyStateTo(Datasource datasource) throws IOException { if (!datasource.dsName.get().equals(dsName.get())) { throw new IllegalArgumentException("Incompatible datasource names"); } if (datasource.dsType.get() != dsType.get()) { throw new IllegalArgumentException("Incompatible datasource types"); } datasource.lastValue.set(lastValue.get()); datasource.nanSeconds.set(nanSeconds.get()); datasource.accumValue.set(accumValue.get()); }
double updateValue = Double.NaN; if (newTime - oldTime <= heartbeat.get()) { switch (dsType.get()) { case GAUGE: updateValue = newValue;
/** * {@inheritDoc} * * Copies object's internal state to another Archive object. */ public void copyStateTo(Archive arc) throws IOException { if (arc.consolFun.get() != consolFun.get()) { throw new IllegalArgumentException("Incompatible consolidation functions"); } if (arc.steps.get() != steps.get()) { throw new IllegalArgumentException("Incompatible number of steps"); } int count = parentDb.getHeader().getDsCount(); for (int i = 0; i < count; i++) { int j = Util.getMatchingDatasourceIndex(parentDb, i, arc.parentDb); if (j >= 0) { states[i].copyStateTo(arc.states[j]); robins[i].copyStateTo(arc.robins[j]); } } }
private void finalizeStep(ArcState state, Robin robin) throws IOException { // should store long arcSteps = steps.get(); double arcXff = xff.get(); long nanSteps = state.getNanSteps(); double accumValue = state.getAccumValue(); if (nanSteps <= arcXff * arcSteps && !Double.isNaN(accumValue)) { if (consolFun.get() == ConsolFun.AVERAGE) { accumValue /= (arcSteps - nanSteps); } robin.store(accumValue); } else { robin.store(Double.NaN); } state.setAccumValue(Double.NaN); state.setNanSteps(0); }
private void accumulate(ArcState state, double value) throws IOException { if (Double.isNaN(value)) { state.setNanSteps(state.getNanSteps() + 1); } else { switch (consolFun.get()) { case MIN: state.setAccumValue(Util.min(state.getAccumValue(), value)); break; case MAX: state.setAccumValue(Util.max(state.getAccumValue(), value)); break; case FIRST: if (Double.isNaN(state.getAccumValue())) { state.setAccumValue(value); } break; case LAST: state.setAccumValue(value); break; case AVERAGE: case TOTAL: state.setAccumValue(Util.sum(state.getAccumValue(), value)); break; } } }