/** * Closes RRD. No further operations are allowed on this RrdDb object. * * @throws java.io.IOException Thrown in case of I/O related error. */ @SuppressWarnings("deprecation") public synchronized void close() throws IOException { if (pool != null) { pool.release(this); } else { internalClose(); } }
/** * @param db */ public final static void releaseRrd(RrdDb db) { try { long start = System.currentTimeMillis(); if(usepool) instance.release(db); else db.close(); long finish = System.currentTimeMillis(); waitTime.addAndGet(finish - start); lockCount.incrementAndGet(); } catch (Exception e) { logger.debug("Strange error " + e); } }
/** * @param db */ public void releaseRrd(RrdDb db) { try { long start = System.currentTimeMillis(); if(usepool) instance.release(db); else db.close(); long finish = System.currentTimeMillis(); waitTime.addAndGet(finish - start); lockCount.incrementAndGet(); } catch (Exception e) { logger.debug("Strange error " + e); } }
/** * Cleanup when the JmxCollector is destroyed, e.g., when system is shutdown. Called by blueprint. */ public void destroy() { LOGGER.trace("ENTERING: destroy() for metric {}", metricName); // Shutdown the scheduled threaded executor that is polling the MBean attribute (metric) if (executor != null) { List<Runnable> tasks = executor.shutdownNow(); if (tasks != null) { LOGGER.debug("Num tasks awaiting execution = {}", tasks.size()); } else { LOGGER.debug("No tasks awaiting execution"); } } // Close the RRD DB try { if (rrdDb != null) { rrdDb.close(); pool.release(rrdDb); } } catch (IOException e) { LOGGER.info("Unable to close RRD DB", e); } LOGGER.trace("EXITING: destroy()"); }
private void releaseRrd(RrdDb rrd, Def def) throws IOException { String backend = def.getBackend(); if (poolUsed && backend == null) { RrdDbPool.getInstance().release(rrd); } else { rrd.close(); } }
/** * 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)) { } } } }