/** * <p>closeFile</p> * * @param rrd a {@link java.util.List} object. * @throws java.lang.Exception if any. */ @Override public void closeFile(List<Object> rrd) throws Exception { for (int i = 0; i < rrd.size(); i++) { m_strategies.get(i).closeFile(rrd.get(i)); } }
/** * <p>closeFile</p> * * @param rrd a {@link java.util.List} object. * @throws java.lang.Exception if any. */ @Override public void closeFile(List<Object> rrd) throws Exception { for (int i = 0; i < rrd.size(); i++) { m_strategies.get(i).closeFile(rrd.get(i)); } }
/** * close the rrd file */ private void processClose(final Object rrd) { if (rrd != null) { try { m_delegate.closeFile(rrd); } catch (final Throwable e) { setErrors(getErrors() + 1); logLapTime("Error closing rrd " + rrd + ": " + e.getMessage()); m_log.debug("Error closing rrd {}: {}", rrd, e.getMessage(), e); } } }
/** * close the rrd file */ private void processClose(final Object rrd) { if (rrd != null) { try { m_delegate.closeFile(rrd); } catch (final Throwable e) { setErrors(getErrors() + 1); logLapTime("Error closing rrd " + rrd + ": " + e.getMessage()); m_log.debug("Error closing rrd {}: {}", rrd, e.getMessage(), e); } } }
@Override Object process(Object rrd) throws Exception { // if the rrd is already open we are confused if (rrd != null) { m_log.debug("WHAT! rrd open but not created?"); m_delegate.closeFile(rrd); rrd = null; } // create the file m_delegate.createFile(getData()); // keep stats setCreatesCompleted(getCreatesCompleted() + 1); // return the file return rrd; }
@Override Object process(Object rrd) throws Exception { // if the rrd is already open we are confused if (rrd != null) { m_log.debug("WHAT! rrd open but not created?"); m_delegate.closeFile(rrd); rrd = null; } // create the file m_delegate.createFile(getData()); // keep stats setCreatesCompleted(getCreatesCompleted() + 1); // return the file return rrd; }
try { if (rrd != null) { strategy.closeFile(rrd);
try { if (rrd != null) { strategy.closeFile(rrd);
@Test @Transactional @JUnitCollector( datacollectionConfig = "/org/opennms/netmgt/config/datacollection-config.xml", datacollectionType = "snmp", anticipateRrds = { "test" }, anticipateMetaFiles = false ) public void testUsingFetch() throws Exception { System.err.println("=== testUsingFetch ==="); File snmpDir = (File)m_context.getAttribute("rrdDirectory"); // We initialize an empty attribute map, key=e.g OID; value=e.g. datasource name Map<String,String> attributeMappings = new HashMap<String, String>(); int stepSize = 1; int numUpdates = 2; long start = System.currentTimeMillis(); final int stepSizeInMillis = stepSize*1000; final int rangeSizeInMillis = stepSizeInMillis + 20000; File rrdFile = new File(snmpDir, rrd("test")); RrdStrategy<RrdDef,RrdDb> m_rrdStrategy = new JRobinRrdStrategy(); RrdDataSource rrdDataSource = new RrdDataSource("testAttr", RrdAttributeType.GAUGE, stepSize*2, "U", "U"); RrdDef def = m_rrdStrategy.createDefinition("test", snmpDir.getAbsolutePath(), "test", stepSize, Collections.singletonList(rrdDataSource), Collections.singletonList("RRA:AVERAGE:0.5:1:100")); m_rrdStrategy.createFile(def); RrdDb rrdFileObject = m_rrdStrategy.openFile(rrdFile.getAbsolutePath()); for (int i = 0; i < numUpdates; i++) { m_rrdStrategy.updateFile(rrdFileObject, "test", ((start/1000) - (stepSize*(numUpdates-i))) + ":1"); } m_rrdStrategy.closeFile(rrdFileObject); assertEquals(Double.valueOf(1.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "testAttr", stepSizeInMillis, rangeSizeInMillis)); }
m_rrdStrategy.closeFile(isA(Object.class));