/** * Constructor for RrdDbPool. * @since 3.5 */ public RrdDbPool() { defaultFactory = RrdBackendFactory.getDefaultFactory(); }
/** * Constructor used to open already existing RRD. This RRD object will be backed * with a storage (backend) of the default type (file on the disk). Constructor * obtains read or read/write access to this RRD. * * @param path Path to existing RRD. * @param readOnly Should be set to <code>false</code> if you want to update * the underlying RRD. If you want just to fetch data from the RRD file * (read-only access), specify <code>true</code>. If you try to update RRD file * open in read-only mode (<code>readOnly</code> set to <code>true</code>), * <code>IOException</code> will be thrown. * @throws IOException Thrown in case of I/O error. */ public RrdDb(String path, boolean readOnly) throws IOException { this(path, readOnly, RrdBackendFactory.getDefaultFactory()); }
private RrdDbPoolOld() { if (!(RrdBackendFactory.getDefaultFactory() instanceof RrdFileBackendFactory)) { throw new RuntimeException("Cannot create instance of " + getClass().getName() + " with " + "a default backend factory not derived from RrdFileBackendFactory"); } }
protected RrdDbPoolNew() { if (!(RrdBackendFactory.getDefaultFactory() instanceof RrdFileBackendFactory)) { throw new RuntimeException("Cannot create instance of " + getClass().getName() + " with " + "a default backend factory not derived from RrdFileBackendFactory"); } capacity = new Semaphore(maxCapacity, true) { @Override public String toString() { return "Capacity semaphore: " + super.toString(); } }; }
this(rrdPath, externalPath, RrdBackendFactory.getDefaultFactory());
/** * <p>Sets path to RRD.</p> * <p>The will be transformed internally to an URI using the default backend factory.</p> * * @param path path to new RRD. */ public void setPath(String path) { this.uri = RrdBackendFactory.getDefaultFactory().getUri(path); }
public static final void prepare(String backend) { usepool = false; if(backend != null) { StoreOpener.backend = RrdBackendFactory.getFactory(backend); logger.trace(Util.delayedFormatString("Store backend set to %s", backend)); } else StoreOpener.backend = RrdBackendFactory.getDefaultFactory(); logger.debug(Util.delayedFormatString("Store backend used is %s", StoreOpener.backend.getName())); logger.debug(Util.delayedFormatString("use pool: %b", usepool)); }
/** * <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); }
/** * <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); }
public static final void prepare(String backend, int dbPoolSize) { usepool = false; if(backend != null) { try { RrdBackendFactory.setDefaultFactory(backend); logger.trace(Util.delayedFormatString("Store backend set to %s", backend)); } catch (IllegalArgumentException e) { logger.fatal("Backend not configured: " + e.getMessage()); } catch (IllegalStateException e) { logger.warn("Trying to change default backend, a restart is needed"); } } StoreOpener.backend = RrdBackendFactory.getDefaultFactory(); if(StoreOpener.backend instanceof RrdFileBackendFactory && dbPoolSize != 0) { try { instance = RrdDbPool.getInstance(); instance.setCapacity(dbPoolSize); usepool = true; } catch (Exception e) { } } logger.debug(Util.delayedFormatString("Store backend used is %s", StoreOpener.backend.getName())); logger.debug(Util.delayedFormatString("use pool: %b %d", usepool, dbPoolSize)); }