void set(double value) throws IOException { if (!isCachingAllowed()) { writeDouble(value); } // caching allowed else if (!cached || !Util.equal(cache, value)) { // update cache writeDouble(cache = value); cached = true; } }
double get() throws IOException { if (!isCachingAllowed()) { return readDouble(); } else { if (!cached) { cache = readDouble(); cached = true; } return cache; } } }
/** * Returns archive X-files factor. * * @return Archive X-files factor (between 0 and 1). * @throws java.io.IOException Thrown in case of I/O error. */ public double getXff() throws IOException { return xff.get(); }
Datasource(RrdDb parentDb, DsDef dsDef) throws IOException { boolean shouldInitialize = dsDef != null; this.parentDb = parentDb; dsName = new RrdString<>(this); dsType = new RrdEnum<>(this, DsType.class); heartbeat = new RrdLong<>(this); minValue = new RrdDouble<>(this); maxValue = new RrdDouble<>(this); lastValue = new RrdDouble<>(this); accumValue = new RrdDouble<>(this); nanSeconds = new RrdLong<>(this); accumLastValue = Double.NaN; if (shouldInitialize) { dsName.set(dsDef.getDsName()); dsType.set(dsDef.getDsType()); heartbeat.set(dsDef.getHeartbeat()); minValue.set(dsDef.getMinValue()); maxValue.set(dsDef.getMaxValue()); lastValue.set(Double.NaN); accumValue.set(0.0); Header header = parentDb.getHeader(); nanSeconds.set(header.getLastUpdateTime() % header.getStep()); } }
void setAccumValue(double value) throws IOException { accumValue.set(value); }
/** * Returns the value accumulated so far. * * @return Accumulated value * @throws IOException Thrown in case of I/O error */ public double getAccumValue() throws IOException { return accumValue.get(); }
Datasource(RrdDb parentDb, DsDef dsDef) throws IOException { boolean shouldInitialize = dsDef != null; this.parentDb = parentDb; dsName = new RrdString(this); dsType = new RrdString(this); heartbeat = new RrdLong(this); minValue = new RrdDouble(this); maxValue = new RrdDouble(this); lastValue = new RrdDouble(this); accumValue = new RrdDouble(this); nanSeconds = new RrdLong(this); if (shouldInitialize) { dsName.set(dsDef.getDsName()); dsType.set(dsDef.getDsType().name()); heartbeat.set(dsDef.getHeartbeat()); minValue.set(dsDef.getMinValue()); maxValue.set(dsDef.getMaxValue()); lastValue.set(Double.NaN); accumValue.set(0.0); Header header = parentDb.getHeader(); nanSeconds.set(header.getLastUpdateTime() % header.getStep()); } }
void setAccumValue(double value) throws IOException { accumValue.set(value); }
/** * Returns maximal allowed value for this datasource. * * @return Maximal value allowed. * @throws java.io.IOException Thrown in case of I/O error */ public double getMaxValue() throws IOException { return maxValue.get(); }
ArcState(Archive parentArc, boolean shouldInitialize) throws IOException { this.parentArc = parentArc; accumValue = new RrdDouble<>(this); nanSteps = new RrdLong<>(this); if (shouldInitialize) { Header header = parentArc.getParentDb().getHeader(); long step = header.getStep(); long lastUpdateTime = header.getLastUpdateTime(); long arcStep = parentArc.getArcStep(); long initNanSteps = (Util.normalize(lastUpdateTime, step) - Util.normalize(lastUpdateTime, arcStep)) / step; accumValue.set(Double.NaN); nanSteps.set(initNanSteps); } }
/** * Sets X-files factor to a new value. * * @param xff New X-files factor value. Must be >= 0 and < 1. * @throws java.io.IOException Thrown in case of I/O error */ public void setXff(double xff) throws IOException { if (xff < 0D || xff >= 1D) { throw new IllegalArgumentException("Invalid xff supplied (" + xff + "), must be >= 0 and < 1"); } this.xff.set(xff); }
void set(double value) throws IOException { if (!isCachingAllowed()) { writeDouble(value); } // caching allowed else if (!cached || !Util.equal(cache, value)) { // update cache writeDouble(cache = value); cached = true; } }
double get() throws IOException { if (!isCachingAllowed()) { return readDouble(); } else { if (!cached) { cache = readDouble(); cached = true; } return cache; } } }
/** * Returns last known value of the datasource. * * @return Last datasource value. * @throws java.io.IOException Thrown in case of I/O error */ public double getLastValue() throws IOException { return lastValue.get(); }
ArcState(Archive parentArc, boolean shouldInitialize) throws IOException { this.parentArc = parentArc; accumValue = new RrdDouble(this); nanSteps = new RrdLong(this); if (shouldInitialize) { Header header = parentArc.getParentDb().getHeader(); long step = header.getStep(); long lastUpdateTime = header.getLastUpdateTime(); long arcStep = parentArc.getArcStep(); long initNanSteps = (Util.normalize(lastUpdateTime, step) - Util.normalize(lastUpdateTime, arcStep)) / step; accumValue.set(Double.NaN); nanSteps.set(initNanSteps); } }
/** * Sets X-files factor to a new value. * * @param xff New X-files factor value. Must be >= 0 and < 1. * @throws IOException Thrown in case of I/O error */ public void setXff(double xff) throws IOException { if (xff < 0D || xff >= 1D) { throw new IllegalArgumentException("Invalid xff supplied (" + xff + "), must be >= 0 and < 1"); } this.xff.set(xff); }
/** * Copies object's internal state to another ArcState object. * * @param other New ArcState object to copy state to * @throws IOException Thrown in case of I/O error */ public void copyStateTo(RrdUpdater other) throws IOException { if (!(other instanceof ArcState)) { throw new IllegalArgumentException("Cannot copy ArcState object to " + other.getClass().getName()); } ArcState arcState = (ArcState) other; arcState.accumValue.set(accumValue.get()); arcState.nanSteps.set(nanSteps.get()); }