/** {@inheritDoc} */ @Override public void createFile(List<Object> rrdDef) throws Exception { for (int i = 0; i < rrdDef.size(); i++) { m_strategies.get(i).createFile(rrdDef.get(i)); } }
/** {@inheritDoc} */ @Override public void createFile(List<Object> rrdDef) throws Exception { for (int i = 0; i < rrdDef.size(); i++) { m_strategies.get(i).createFile(rrdDef.get(i)); } }
/** * <p>createFile</p> * * @param op a {@link Operation} object. * @throws java.lang.Exception if any. */ @Override public void createFile(CreateOperation op) throws Exception { if (m_queueCreates) { addOperation(op); } else { m_delegate.createFile(op.getData()); } }
/** * <p>createFile</p> * * @param op a {@link Operation} object. * @throws java.lang.Exception if any. */ @Override public void createFile(CreateOperation op) throws Exception { if (m_queueCreates) { addOperation(op); } else { m_delegate.createFile(op.getData()); } }
@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; }
/** * <p>createRRD</p> * * @param creator a {@link java.lang.String} object. * @param directory a {@link java.lang.String} object. * @param rrdName a {@link java.lang.String} object. * @param step a int. * @param dataSources a {@link java.util.List} object. * @param rraList a {@link java.util.List} object. * @return a boolean. * @throws org.opennms.netmgt.rrd.RrdException if any. */ private static boolean createRRD(RrdStrategy<?, ?> rrdStrategy, String creator, String directory, String rrdName, int step, List<RrdDataSource> dataSources, List<String> rraList) throws RrdException { Object def = null; try { RrdStrategy<Object, Object> strategy = toGenericType(rrdStrategy); def = strategy.createDefinition(creator, directory, rrdName, step, dataSources, rraList); // def can be null if the rrd-db exists already, but doesn't have to be (see MultiOutput/QueuingRrdStrategy strategy.createFile(def); return true; } catch (Throwable e) { String path = directory + File.separator + rrdName + rrdStrategy.getDefaultFileExtension(); LOG.error("createRRD: An error occurred creating rrdfile {}", path, e); throw new org.opennms.netmgt.rrd.RrdException("An error occurred creating rrdfile " + path + ": " + e, e); } }
/** * <p>createRRD</p> * * @param creator a {@link java.lang.String} object. * @param directory a {@link java.lang.String} object. * @param rrdName a {@link java.lang.String} object. * @param step a int. * @param dataSources a {@link java.util.List} object. * @param rraList a {@link java.util.List} object. * @return a boolean. * @throws org.opennms.netmgt.rrd.RrdException if any. */ private static boolean createRRD(RrdStrategy<?, ?> rrdStrategy, String creator, String directory, String rrdName, int step, List<RrdDataSource> dataSources, List<String> rraList) throws RrdException { Object def = null; try { RrdStrategy<Object, Object> strategy = toGenericType(rrdStrategy); def = strategy.createDefinition(creator, directory, rrdName, step, dataSources, rraList); // def can be null if the rrd-db exists already, but doesn't have to be (see MultiOutput/QueuingRrdStrategy strategy.createFile(def); return true; } catch (Throwable e) { String path = directory + File.separator + rrdName + rrdStrategy.getDefaultFileExtension(); LOG.error("createRRD: An error occurred creating rrdfile {}", path, e); throw new org.opennms.netmgt.rrd.RrdException("An error occurred creating rrdfile " + path + ": " + e, e); } }
@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)); }
EasyMock.expectLastCall().andReturn(null).once(); m_rrdStrategy.createFile(EasyMock.anyObject()); EasyMock.expectLastCall().once();
expect(m_rrdStrategy.createDefinition(isA(String.class), isA(String.class), isA(String.class), anyInt(), isAList(RrdDataSource.class), isAList(String.class))).andReturn(new Object()); m_rrdStrategy.createFile(isA(Object.class));