/** * <p>Requests a RrdDb reference for the given RRD file path.</p> * <ul> * <li>If the file is already open, previously returned RrdDb reference will be returned. Its usage count * will be incremented by one. * <li>If the file is not already open and the number of already open RRD files is less than * {@link #INITIAL_CAPACITY}, the file will be open and a new RrdDb reference will be returned. * If the file is not already open and the number of already open RRD files is equal to * {@link #INITIAL_CAPACITY}, the method blocks until some RRD file is closed. * </ul> * * @param uri {@link URI} to existing RRD file * @return reference for the give RRD file * @throws java.io.IOException Thrown in case of I/O error * @deprecated Use the {@link org.rrd4j.core.RrdDb.Builder} instead. */ @Deprecated public RrdDb requestRrdDb(URI uri) throws IOException { RrdBackendFactory factory = RrdBackendFactory.findFactory(uri); return requestRrdDb(uri, factory); }
/** * <p>Requests a RrdDb reference for the given RRD file path.</p> * <ul> * <li>If the file is already open, previously returned RrdDb reference will be returned. Its usage count * will be incremented by one. * <li>If the file is not already open and the number of already open RRD files is less than * {@link #INITIAL_CAPACITY}, the file will be open and a new RrdDb reference will be returned. * If the file is not already open and the number of already open RRD files is equal to * {@link #INITIAL_CAPACITY}, the method blocks until some RRD file is closed. * </ul> * <p>The path is transformed internally to URI using the default factory, that is the reference that will * be used elsewhere.</p> * * @param path Path to existing RRD file * @return reference for the give RRD file * @throws java.io.IOException Thrown in case of I/O error * @deprecated Use the {@link org.rrd4j.core.RrdDb.Builder} instead. */ @Deprecated public RrdDb requestRrdDb(String path) throws IOException { return requestRrdDb(defaultFactory.getUri(path), defaultFactory); }
/** * Retrieves the RrdDb instance matching a specific RRD datasource name * (usually a file name) and using a specified RrdBackendFactory. * * @param rrdFile Name of the RRD datasource. * @return RrdDb instance of the datasource. * @throws IOException Thrown in case of I/O error. */ public RrdDb getRrd(String rrdFile) throws IOException { Path rrdPath = Paths.get(rrdFile); long start = System.currentTimeMillis(); RrdDb db; if(usepool) { db = instance.requestRrdDb(rrdPath.toUri()); } else { db = new RrdDb(rrdPath.toRealPath(LinkOption.NOFOLLOW_LINKS).normalize().toString(), backendFactory); } long finish = System.currentTimeMillis(); waitTime.addAndGet(finish - start); lockCount.incrementAndGet(); return db; }
/** * Retrieves the RrdDb instance matching a specific RRD datasource name * (usually a file name) and using a specified RrdBackendFactory. * * @param rrdFile Name of the RRD datasource. * @return RrdDb instance of the datasource. * @throws IOException Thrown in case of I/O error. */ public final static RrdDb getRrd(String rrdFile) throws IOException { File f = new File(rrdFile); String cp = f.getCanonicalPath(); long start = System.currentTimeMillis(); RrdDb db; if(usepool) db = instance.requestRrdDb(cp); else db = new RrdDb(cp, backend); long finish = System.currentTimeMillis(); waitTime.addAndGet(finish - start); lockCount.incrementAndGet(); return db; }
RrdDb requestRrdDb(URI uri, RrdBackendFactory backend, DataImporter importer) throws IOException { return requestRrdDb(RrdDb.getBuilder().setImporter(importer), uri, backend); }
/** * <p>Requests a RrdDb reference for the given RRD file definition object.</p> * <ul> * <li>If the file with the path specified in the RrdDef object is already open, * the method blocks until the file is closed. * <li>If the file is not already open and the number of already open RRD files is less than * {@link #INITIAL_CAPACITY}, a new RRD file will be created and a its RrdDb reference will be returned. * If the file is not already open and the number of already open RRD files is equal to * {@link #INITIAL_CAPACITY}, the method blocks until some RRD file is closed. * </ul> * * @param rrdDef Definition of the RRD file to be created * @return Reference to the newly created RRD file * @throws java.io.IOException Thrown in case of I/O error * @deprecated Use the {@link org.rrd4j.core.RrdDb.Builder} instead. */ @Deprecated public RrdDb requestRrdDb(RrdDef rrdDef) throws IOException { return requestRrdDb(rrdDef, RrdBackendFactory.findFactory(rrdDef.getUri())); }
/** * <p>Requests a RrdDb reference for the given path. The file will be created from * external data (from XML dump or RRDTool's binary RRD file).</p> * <ul> * <li>If the file with the path specified is already open, * the method blocks until the file is closed. * <li>If the file is not already open and the number of already open RRD files is less than * {@link #INITIAL_CAPACITY}, a new RRD file will be created and a its RrdDb reference will be returned. * If the file is not already open and the number of already open RRD files is equal to * {@link #INITIAL_CAPACITY}, the method blocks until some RRD file is closed. * </ul> * <p>The path is transformed internally to URI using the default factory, that is the reference that will * be used elsewhere.</p> * * @param uri Path to RRD file which should be created * @param sourcePath Path to external data which is to be converted to Rrd4j's native RRD file format * @return Reference to the newly created RRD file * @throws java.io.IOException Thrown in case of I/O error * @deprecated Use the {@link org.rrd4j.core.RrdDb.Builder} instead. */ @Deprecated public RrdDb requestRrdDb(URI uri, String sourcePath) throws IOException { RrdBackendFactory backend = RrdBackendFactory.getDefaultFactory(); return requestRrdDb(RrdDb.getBuilder().setExternalPath(sourcePath), uri, backend); }
/** * <p>Requests a RrdDb reference for the given path. The file will be created from * external data (from XML dump or RRDTool's binary RRD file).</p> * <ul> * <li>If the file with the path specified is already open, * the method blocks until the file is closed. * <li>If the file is not already open and the number of already open RRD files is less than * {@link #INITIAL_CAPACITY}, a new RRD file will be created and a its RrdDb reference will be returned. * If the file is not already open and the number of already open RRD files is equal to * {@link #INITIAL_CAPACITY}, the method blocks until some RRD file is closed. * </ul> * <p>The path is transformed internally to URI using the default factory, that is the reference that will * be used elsewhere.</p> * * @param path Path to RRD file which should be created * @param sourcePath Path to external data which is to be converted to Rrd4j's native RRD file format * @return Reference to the newly created RRD file * @throws java.io.IOException Thrown in case of I/O error * @deprecated Use the {@link org.rrd4j.core.RrdDb.Builder} instead. */ @Deprecated public RrdDb requestRrdDb(String path, String sourcePath) throws IOException { URI uri = RrdBackendFactory.getDefaultFactory().getUri(path); RrdBackendFactory backend = RrdBackendFactory.getDefaultFactory(); return requestRrdDb(RrdDb.getBuilder().setExternalPath(sourcePath), uri, backend); }
rrdDb = pool.requestRrdDb(def); } else { LOGGER.debug( "rrd file {} already exists - absolute path = {}", rrdPath, file.getAbsolutePath()); rrdDb = pool.requestRrdDb(rrdPath);
private RrdDb getRrd(Def def) throws IOException { String path = def.getPath(), backend = def.getBackend(); if (poolUsed && backend == null) { return RrdDbPool.getInstance().requestRrdDb(path); } else if (backend != null) { return new RrdDb(path, true, RrdBackendFactory.getFactory(backend)); } else { return new RrdDb(path, true); } }
/** * Import an external rrd data, import definition must have been done using {@link #setExternalPath(String)} * or {@link #setImporter(DataImporter)} * * @throws IOException in case of I/O error. * @throws IllegalArgumentException if the builder settings were incomplete */ @SuppressWarnings("deprecation") public void doimport() throws IOException { if (rrdDef != null || (importer == null && externalPath == null)) { throw new IllegalArgumentException("Not an importing configuration"); } if (path == null && uri == null) { throw new IllegalArgumentException("No rrd destination given"); } URI rrdUri = buildUri(path, uri, factory); factory = checkFactory(rrdUri, factory); if (!factory.canStore(rrdUri)) { throw new IllegalArgumentException("Given a factory incompatible with the URI"); } try (DataImporter rrdImporter = resoleImporter(externalPath, importer)) { if (usePool) { RrdDb db = resolvePool(pool).requestRrdDb(rrdUri, factory, importer); resolvePool(pool).release(db); } else { try (RrdDb db = new RrdDb(path, rrdUri, null, rrdImporter, factory, null)) { } } } }
factory = checkFactory(rrdDef.getUri(), factory); if (usePool) { return resolvePool(pool).requestRrdDb(rrdDef, factory); } else { return new RrdDb(rrdDef, factory, pool); return resolvePool(pool).requestRrdDb(rrdUri, factory); } else { return new RrdDb(null, rrdUri, readOnly, factory, pool); try (DataImporter rrdImporter = resoleImporter(externalPath, importer)) { if (usePool) { return resolvePool(pool).requestRrdDb(rrdUri, factory, importer); } else { return new RrdDb(null, rrdUri, null, rrdImporter, factory, pool);