String getRrdToolCommand() { return dump(); } }
/** * <p>Creates new sample with the given timestamp and all datasource values set to * 'unknown'. Use returned <code>Sample</code> object to specify * datasource values for the given timestamp. See documentation for * {@link Sample Sample} for an explanation how to do this.</p> * <p>Once populated with data source values, call Sample's * {@link org.rrd4j.core.Sample#update() update()} method to actually * store sample in the RRD associated with it.</p> * * @param time Sample timestamp rounded to the nearest second (without milliseconds). * @return Fresh sample with the given timestamp and all data source values set to 'unknown'. * @throws java.io.IOException Thrown in case of I/O error. */ public Sample createSample(long time) throws IOException { return new Sample(this, time); }
/** * <p>Creates sample with the timestamp and data source values supplied * in the argument string and stores sample in the corresponding RRD. * This method is just a shortcut for:</p> * <pre> * set(timeAndValues); * update(); * </pre> * * @param timeAndValues String made by concatenating sample timestamp with corresponding * data source values delmited with colons. For example:<br> * <code>1005234132:12.2:35.6:U:24.5</code><br> * <code>NOW:12.2:35.6:U:24.5</code> * @throws IOException Thrown in case of I/O error. */ public void setAndUpdate(String timeAndValues) throws IOException { set(timeAndValues); update(); }
public void commit(JrdsSample sample) { RrdDb rrdDb = null; try { rrdDb = factory.getRrd(getPath()); Sample onesample = rrdDb.createSample(sample.getTime().getTime() / 1000); for(Map.Entry<String, Number> e: sample.entrySet()) { onesample.setValue(e.getKey(), e.getValue().doubleValue()); } if(p.getNamedLogger().isDebugEnabled()) log(Level.DEBUG, "%s", onesample.dump()); onesample.update(); } catch (IOException e) { log(Level.ERROR, e, "Error while collecting: %s", e.getMessage()); } finally { if(rrdDb != null) factory.releaseRrd(rrdDb); } }
protected void flushStatus() { if (transactions > 0) { try { Sample sample = db.createSample(endInterval); if (transactionsEnabled) { sample.setValue("transactions!", transactions); } if (minEnabled) { sample.setValue("min", min); } if (maxEnabled) { sample.setValue("max", max); } if (averageEnabled) { double value = total / (double) transactions; sample.setValue("average", value); } sample.update(); } catch (IOException e) { throw new EtmException(e); } } }
final synchronized void store(Sample sample) throws IOException { if (closed) { throw new IllegalStateException("RRD already closed, cannot store this sample"); } long newTime = sample.getTime(); long lastTime = header.getLastUpdateTime(); if (lastTime >= newTime) { throw new IllegalArgumentException("Bad sample time: " + newTime + ". Last update time was " + lastTime + ", at least one second step is required"); } double[] newValues = sample.getValues(); for (int i = 0; i < datasources.length; i++) { double newValue = newValues[i]; datasources[i].process(newTime, newValue); } header.setLastUpdateTime(newTime); }
Sample(RrdDb parentDb, long time) throws IOException { this.parentDb = parentDb; this.time = time; this.dsNames = parentDb.getDsNames(); values = new double[dsNames.length]; clearValues(); }
/** * Creates sample with the timestamp and data source values supplied * in the argument string and stores sample in the corresponding RRD. * This method is just a shortcut for: * <pre> * set(timeAndValues); * update(); * </pre> * * @param timeAndValues String made by concatenating sample timestamp with corresponding * data source values delmited with colons. For example:<br> * <code>1005234132:12.2:35.6:U:24.5</code><br> * <code>NOW:12.2:35.6:U:24.5</code> * @throws java.io.IOException Thrown in case of I/O error. */ public void setAndUpdate(String timeAndValues) throws IOException { set(timeAndValues); update(); }
final synchronized void store(Sample sample) throws IOException { if (closed) { throw new IllegalStateException("RRD already closed, cannot store this sample"); } long newTime = sample.getTime(); long lastTime = header.getLastUpdateTime(); if (lastTime >= newTime) { throw new IllegalArgumentException("Bad sample time: " + newTime + ". Last update time was " + lastTime + ", at least one second step is required"); } double[] newValues = sample.getValues(); for (int i = 0; i < datasources.length; i++) { double newValue = newValues[i]; datasources[i].process(newTime, newValue); } header.setLastUpdateTime(newTime); }
/** * Stores sample in the corresponding RRD. If the update operation succeeds, * all datasource values in the sample will be set to Double.NaN (unknown) values. * * @throws IOException Thrown in case of I/O error. */ public void update() throws IOException { parentDb.store(this); clearValues(); }
String getRrdToolCommand() { return dump(); } }
Sample(RrdDb parentDb, long time) throws IOException { this.parentDb = parentDb; this.time = time; this.dsNames = parentDb.getDsNames(); values = new double[dsNames.length]; clearValues(); }
/** * <p>Creates new sample with the given timestamp and all datasource values set to * 'unknown'. Use returned <code>Sample</code> object to specify * datasource values for the given timestamp. See documentation for * {@link Sample Sample} for an explanation how to do this.</p> * <p/> * <p>Once populated with data source values, call Sample's * {@link Sample#update() update()} method to actually * store sample in the RRD associated with it.</p> * * @param time Sample timestamp rounded to the nearest second (without milliseconds). * @return Fresh sample with the given timestamp and all data source values set to 'unknown'. * @throws IOException Thrown in case of I/O error. */ public Sample createSample(long time) throws IOException { return new Sample(this, time); }
/** * Stores sample in the corresponding RRD. If the update operation succeeds, * all datasource values in the sample will be set to Double.NaN (unknown) values. * * @throws java.io.IOException Thrown in case of I/O error. */ public void update() throws IOException { parentDb.store(this); clearValues(); }