org.rrd4j.core.Sample Java Examples

The following examples show how to use org.rrd4j.core.Sample. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RRDStorage.java    From component-runtime with Apache License 2.0 6 votes vote down vote up
private void save(final Stats stats) {
    db.thenApply(db -> {
        try {
            final Sample sample = db.createSample();
            sample.setValue("projects!", stats.projects.get());
            sample.setValue("sources!", stats.sources.get());
            sample.setValue("processors!", stats.processors.get());
            sample.setValue("endpoints!", stats.endpoints.get());
            stats.facets.forEach((k, v) -> sample.setValue(k + '!', v.get()));
            sample.update();
            savedData = true;
            log.debug("Updated RRD storage");

            final long autoDumpTimeout = config.getAutoDumpTimeout();
            long now;
            if (autoDumpTimeout > 0 && ((now = System.currentTimeMillis()) - lastDump) > autoDumpTimeout) {
                doDump(db);
                lastDump = now;
            }
        } catch (final IOException e) {
            log.error(e.getMessage() + ", stats: " + stats, e);
        }
        return db;
    });
}