@Deprecated Def(String name, String rrdPath, String dsName, ConsolFun consolFun, String backend) { super(name); this.rrdPath = rrdPath; this.dsName = dsName; this.consolFun = consolFun; this.backend = RrdBackendFactory.getFactory(backend); }
/** * Constructor for RrdDbPool. * @since 3.5 */ public RrdDbPool() { defaultFactory = RrdBackendFactory.getDefaultFactory(); }
/** * Registers new (custom) backend factory within the Rrd4j framework and sets this * factory as the default. * * @param factory Factory to be registered and set as default */ public static void registerAndSetAsDefaultFactory(RrdBackendFactory factory) { registerFactory(factory); setDefaultFactory(factory.getName()); }
/** * Determines if the header should be validated. * * @param uri Storage URI * @throws java.io.IOException if header validation fails * @return a boolean. */ protected boolean shouldValidateHeader(URI uri) throws IOException { return shouldValidateHeader(getPath(uri)); }
backendFactory = factoryClass.getConstructor().newInstance(); try { RrdBackendFactory.getFactory(backendFactory.getName()); } catch (IllegalArgumentException e) { RrdBackendFactory.registerFactory(backendFactory); backendName = backendFactory.getName(); } catch (Exception e) { throw new RuntimeException("Failed to configure RrdDbStoreFactory:" + e.getMessage(), e); backendFactory = RrdBackendFactory.getFactory(backendName); RrdBackendFactory.setActiveFactories(backendFactory);
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)); }
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)); }
@Override public void start() { super.start(); boolean filebasedbackend = backendFactory instanceof RrdFileBackendFactory; if(usepool || filebasedbackend) { try { String backendName = backendFactory.getName(); RrdBackendFactory.setDefaultFactory(backendName); logger.trace(Util.delayedFormatString("Store backend set to %s", backendName)); } catch (IllegalStateException e) { logger.warn("Trying to change default backend, a restart is needed"); } catch (Exception e) { throw new RuntimeException("Failed to configure RrdDbStoreFactory:" + e.getMessage(), e); } try { instance = RrdDbPool.getInstance(); instance.setCapacity(dbPoolSize); usepool = true; } catch (Exception e) { logger.warn("Trying to change rrd pool size, a restart is needed"); } } }
if (!factory.exists(path)) { throw new FileNotFoundException("Could not open " + path + " [non existent]"); backend = factory.open(path, readOnly); try { if (factory.shouldValidateHeader(path)) { header.validateHeader();
/** * <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); }
factory = Builder.checkFactory(rrdUri, factory); if (!factory.exists(rrdUri)) { throw new FileNotFoundException("Could not open " + rrdUri + " [non existent]"); backend = factory.getBackend(this, rrdUri, readOnly); try { if (factory.shouldValidateHeader(rrdUri)) { header.validateHeader();
/** * Sets default backend factory to be used. This method is just an alias for * {@link RrdBackendFactory#setDefaultFactory(String)}.<p> * * @param factoryName Name of the backend factory to be set as default. * @throws IllegalArgumentException Thrown if invalid factory name is supplied, or not called * before the first backend object (before the first RrdDb object) is created. */ public static void setDefaultFactory(String factoryName) { RrdBackendFactory.setDefaultFactory(factoryName); }
/** * Registers new (custom) backend factory within the Rrd4j framework. * * @param factory Factory to be registered */ public static void registerFactory(RrdBackendFactory factory) { String name = factory.getName(); if (!factories.containsKey(name)) { factories.put(name, factory); } else { throw new IllegalArgumentException("Backend factory '" + name + "' cannot be registered twice"); } }
/** * Creates RrdBackend object for the given storage path. * @param rrdDb * * @param uri Storage uri * @param readOnly True, if the storage should be accessed in read/only mode. * False otherwise. * @return Backend object which handles all I/O operations for the given storage path * @throws java.io.IOException Thrown in case of I/O error. */ RrdBackend getBackend(RrdDb rrdDb, URI uri, boolean readOnly) throws IOException { checkClosing(); RrdBackend backend = open(getPath(uri), readOnly); backend.done(this, new ClosingReference(rrdDb, backend, refQueue)); return backend; }
/** * Creates RrdBackend object for the given storage path. * * @param path Storage path * @param readOnly True, if the storage should be accessed in read/only mode. * False otherwise. * @return Backend object which handles all I/O operations for the given storage path * @throws java.io.IOException Thrown in case of I/O error. */ RrdBackend getBackend(RrdDb rrdDb, String path, boolean readOnly) throws IOException { checkClosing(); RrdBackend backend = open(path, readOnly); backend.done(this, new ClosingReference(rrdDb, backend, refQueue)); return backend; }
public RrdBerkeleyDbBackendFactory(Database rrdDatabase) { this.rrdDatabase = rrdDatabase; RrdBackendFactory.registerAndSetAsDefaultFactory(this); }
reader = new XmlReader(externalPath); backend = factory.open(rrdPath, false); try { backend.setLength(reader.getEstimatedSize());
/** * <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); }
private static void selectDefaultFactory() { setDefaultFactory("NIO"); }