Datasource(RrdDb parentDb, DataImporter reader, int dsIndex) throws IOException { this(parentDb, null); dsName.set(reader.getDsName(dsIndex)); dsType.set(reader.getDsType(dsIndex)); heartbeat.set(reader.getHeartbeat(dsIndex)); minValue.set(reader.getMinValue(dsIndex)); maxValue.set(reader.getMaxValue(dsIndex)); lastValue.set(reader.getLastValue(dsIndex)); accumValue.set(reader.getAccumValue(dsIndex)); nanSeconds.set(reader.getNanSeconds(dsIndex)); }
Header(RrdDb parentDb, DataImporter reader) throws IOException { this(parentDb, (RrdDef) null); String version = reader.getVersion(); if (!RRDTOOL_VERSION.equals(version)) { throw new IllegalArgumentException("Could not unserialize xml version " + version); } signature.set(DEFAULT_SIGNATURE); step.set(reader.getStep()); dsCount.set(reader.getDsCount()); arcCount.set(reader.getArcCount()); lastUpdateTime.set(reader.getLastUpdateTime()); }
Archive(RrdDb parentDb, DataImporter reader, int arcIndex) throws IOException { this(parentDb, new ArcDef( reader.getConsolFun(arcIndex), reader.getXff(arcIndex), reader.getSteps(arcIndex), reader.getRows(arcIndex))); int n = parentDb.getHeader().getDsCount(); for (int i = 0; i < n; i++) { // restore state states[i].setAccumValue(reader.getStateAccumValue(arcIndex, i)); states[i].setNanSteps(reader.getStateNanSteps(arcIndex, i)); // restore robins double[] values = reader.getValues(arcIndex, i); robins[i].update(values); } }
protected long getEstimatedSize() throws IOException { int dsCount = getDsCount(); int arcCount = getArcCount(); int rowCount = 0; for (int i = 0; i < arcCount; i++) { rowCount += getRows(i); } String[] dsNames = new String[getDsCount()]; for (int i = 0 ; i < dsNames.length; i++) { dsNames[i] = getDsName(i); } return RrdDef.calculateSize(dsCount, arcCount, rowCount, dsNames); }
long getEstimatedSize() throws IOException { int dsCount = getDsCount(); int arcCount = getArcCount(); int rowCount = 0; for (int i = 0; i < arcCount; i++) { rowCount += getRows(i); } return RrdDef.calculateSize(dsCount, arcCount, rowCount); }
backend.setLength(reader.getEstimatedSize()); datasources = new Datasource[reader.getDsCount()]; for (int i = 0; i < datasources.length; i++) { datasources[i] = new Datasource(this, reader, i); archives = new Archive[reader.getArcCount()]; for (int i = 0; i < archives.length; i++) { archives[i] = new Archive(this, reader, i); reader.release();
private RrdDb(String rrdPath, URI rrdUri, String externalPath, DataImporter importer, RrdBackendFactory factory, RrdDbPool pool) throws IOException { this.pool = pool; rrdUri = Builder.buildUri(rrdPath, rrdUri, factory); factory = Builder.checkFactory(rrdUri, factory); backend = factory.getBackend(this, rrdUri, false); try (DataImporter reader = Builder.resoleImporter(externalPath, importer)) { backend.setLength(reader.getEstimatedSize()); // create header header = new Header(this, reader); // create datasources datasources = new Datasource[reader.getDsCount()]; for (int i = 0; i < datasources.length; i++) { datasources[i] = new Datasource(this, reader, i); } // create archives archives = new Archive[reader.getArcCount()]; for (int i = 0; i < archives.length; i++) { archives[i] = new Archive(this, reader, i); } } catch (IOException e) { backend.rrdClose(); throw e; } }
Datasource(RrdDb parentDb, DataImporter reader, int dsIndex) throws IOException { this(parentDb, null); dsName.set(reader.getDsName(dsIndex)); dsType.set(reader.getDsType(dsIndex)); heartbeat.set(reader.getHeartbeat(dsIndex)); minValue.set(reader.getMinValue(dsIndex)); maxValue.set(reader.getMaxValue(dsIndex)); lastValue.set(reader.getLastValue(dsIndex)); accumValue.set(reader.getAccumValue(dsIndex)); nanSeconds.set(reader.getNanSeconds(dsIndex)); }
Archive(RrdDb parentDb, DataImporter reader, int arcIndex) throws IOException { this(parentDb, new ArcDef( reader.getConsolFun(arcIndex), reader.getXff(arcIndex), reader.getSteps(arcIndex), reader.getRows(arcIndex))); int n = parentDb.getHeader().getDsCount(); for (int i = 0; i < n; i++) { // restore state states[i].setAccumValue(reader.getStateAccumValue(arcIndex, i)); states[i].setNanSteps(reader.getStateNanSteps(arcIndex, i)); // restore robins double[] values = reader.getValues(arcIndex, i); robins[i].update(values); } }
Header(RrdDb parentDb, DataImporter reader) throws IOException { this(parentDb, (RrdDef) null); String importVersion = reader.getVersion(); switch(importVersion) { case RRDTOOL_VERSION1: version = 1; break; case RRDTOOL_VERSION3: version = 2; break; default: throw new IllegalArgumentException("Could not get version " + version); } signature.set(SIGNATURE + ", " + VERSIONS[version - 1]); step.set(reader.getStep()); dsCount.set(reader.getDsCount()); arcCount.set(reader.getArcCount()); lastUpdateTime.set(reader.getLastUpdateTime()); }