void set(long value) throws IOException { if (!isCachingAllowed()) { writeLong(value); } // caching allowed else if (!cached || cache != value) { // update cache writeLong(cache = value); cached = true; } }
long get() throws IOException { if (!isCachingAllowed()) { return readLong(); } else { if (!cached) { cache = readLong(); cached = true; } return cache; } } }
/** * Returns primary RRD time step. * * @return Primary time step in seconds * @throws java.io.IOException Thrown in case of I/O error */ public long getStep() throws IOException { return step.get(); }
Header(RrdDb parentDb, RrdDef rrdDef) throws IOException { this.parentDb = parentDb; String initSignature = null; if(rrdDef != null) { version = rrdDef.getVersion(); initSignature = SIGNATURE + ", " + VERSIONS[version - 1]; } else { initSignature = DEFAULT_SIGNATURE; } signature = new RrdString<>(this); // NOT constant, may be cached step = new RrdLong<>(this, true); // constant, may be cached dsCount = new RrdInt<>(this, true); // constant, may be cached arcCount = new RrdInt<>(this, true); // constant, may be cached lastUpdateTime = new RrdLong<>(this); if (rrdDef != null) { signature.set(initSignature); step.set(rrdDef.getStep()); dsCount.set(rrdDef.getDsCount()); arcCount.set(rrdDef.getArcCount()); lastUpdateTime.set(rrdDef.getStartTime()); } }
void setLastUpdateTime(long lastUpdateTime) throws IOException { this.lastUpdateTime.set(lastUpdateTime); }
/** * Returns the last update time of the RRD. * * @return Timestamp (Unix epoch, no milliseconds) corresponding to the last update time. * @throws java.io.IOException Thrown in case of I/O error */ public long getLastUpdateTime() throws IOException { return lastUpdateTime.get(); }
Header(RrdDb parentDb, RrdDef rrdDef) throws IOException { this.parentDb = parentDb; String initSignature = null; if(rrdDef != null) { version = rrdDef.getVersion(); initSignature = SIGNATURE + ", " + VERSIONS[ version - 1]; } else { initSignature = DEFAULT_SIGNATURE; } signature = new RrdString(this); // NOT constant, may be cached step = new RrdLong(this, true); // constant, may be cached dsCount = new RrdInt(this, true); // constant, may be cached arcCount = new RrdInt(this, true); // constant, may be cached lastUpdateTime = new RrdLong(this); if (rrdDef != null) { signature.set(initSignature); step.set(rrdDef.getStep()); dsCount.set(rrdDef.getDsCount()); arcCount.set(rrdDef.getArcCount()); lastUpdateTime.set(rrdDef.getStartTime()); } }
void setNanSteps(long value) throws IOException { nanSteps.set(value); }
/** * Copies object's internal state to another Header object. * * @param other New Header object to copy state to * @throws IOException Thrown in case of I/O error */ public void copyStateTo(RrdUpdater other) throws IOException { if (!(other instanceof Header)) { throw new IllegalArgumentException( "Cannot copy Header object to " + other.getClass().getName()); } Header header = (Header) other; //header.signature.set(signature.get()); header.lastUpdateTime.set(lastUpdateTime.get()); }
/** * Returns the number of accumulated NaN seconds. * * @return Accumulated NaN seconds. * @throws java.io.IOException Thrown in case of I/O error */ public long getNanSeconds() throws IOException { return nanSeconds.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); } }
void setLastUpdateTime(long lastUpdateTime) throws IOException { this.lastUpdateTime.set(lastUpdateTime); }
void set(long value) throws IOException { if (!isCachingAllowed()) { writeLong(value); } // caching allowed else if (!cached || cache != value) { // update cache writeLong(cache = value); cached = true; } }
long get() throws IOException { if (!isCachingAllowed()) { return readLong(); } else { if (!cached) { cache = readLong(); cached = true; } return cache; } } }
/** * Returns datasource heartbeat * * @return Datasource heartbeat * @throws IOException Thrown in case of I/O error */ public long getHeartbeat() throws IOException { return heartbeat.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); } }
void setNanSteps(long value) throws IOException { nanSteps.set(value); }