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); }
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()); }
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); }
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()); }
archives = new Archive[reader.getArcCount()]; for (int i = 0; i < archives.length; i++) { archives[i] = new Archive(this, reader, i);
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; } }