use of org.opennms.netmgt.config.DefaultDataCollectionConfigDao in project opennms by OpenNMS.
the class SnmpInterfaceRrdMigratorOnline method preExecute.
/* (non-Javadoc)
* @see org.opennms.upgrade.api.OnmsUpgrade#preExecute()
*/
public void preExecute() throws OnmsUpgradeException {
printMainSettings();
if (getRrdExtension() == null) {
throw new OnmsUpgradeException("Can't find the configured extension for JRB/RRD.");
}
try {
// Manually initialization of the DataCollectionConfigDao to avoid bootstrap Spring Framework and create a new connection pool.
File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.DATA_COLLECTION_CONF_FILE_NAME);
DefaultDataCollectionConfigDao config = new DefaultDataCollectionConfigDao();
config.setConfigResource(new FileSystemResource(cfgFile));
config.afterPropertiesSet();
config.getConfiguredResourceTypes();
DataCollectionConfigFactory.setInstance(config);
} catch (Exception e) {
throw new OnmsUpgradeException("Can't initialize datacollection-config.xml because " + e.getMessage());
}
interfacesToMerge = getInterfacesToMerge();
}
use of org.opennms.netmgt.config.DefaultDataCollectionConfigDao in project opennms by OpenNMS.
the class CollectorConfigDaoImplIT method initialize.
private void initialize() throws IOException, Exception {
System.setProperty("opennms.home", ConfigurationTestUtils.getDaemonEtcDirectory().getParentFile().getAbsolutePath());
InputStream stream = null;
stream = getInputStreamForFile("/org/opennms/netmgt/config/test-database-schema.xml");
DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(stream));
stream.close();
stream = getInputStreamForFile("/org/opennms/netmgt/config/snmp-config.xml");
SnmpPeerFactory.setInstance(new SnmpPeerFactory(new InputStreamResource(stream)));
stream.close();
stream = getInputStreamForFile("/org/opennms/netmgt/config/datacollection-config.xml");
DefaultDataCollectionConfigDao dataCollectionDao = new DefaultDataCollectionConfigDao();
dataCollectionDao.setConfigResource(new InputStreamResource(stream));
dataCollectionDao.afterPropertiesSet();
DataCollectionConfigFactory.setInstance(dataCollectionDao);
stream.close();
stream = getInputStreamForFile("/org/opennms/netmgt/config/collectd-testdata.xml");
try {
new CollectdConfigFactory(stream, "localhost", false);
} finally {
stream.close();
}
}
use of org.opennms.netmgt.config.DefaultDataCollectionConfigDao in project opennms by OpenNMS.
the class DefaultDataCollectionConfigDaoIT method testCompareOldAndNewStyles.
@Test
public void testCompareOldAndNewStyles() throws Exception {
DefaultDataCollectionConfigDao newDao = instantiateDao("datacollection-config.xml", true);
DefaultDataCollectionConfigDao oldDao = instantiateDao("examples/old-datacollection-config.xml", false);
compareContent(oldDao.getContainer().getObject(), newDao.getContainer().getObject());
}
use of org.opennms.netmgt.config.DefaultDataCollectionConfigDao in project opennms by OpenNMS.
the class DefaultDataCollectionConfigDaoIT method testOldStyle.
@Test
public void testOldStyle() throws Exception {
DefaultDataCollectionConfigDao oldDao = instantiateDao("examples/old-datacollection-config.xml", false);
executeTests(oldDao, 82);
}
use of org.opennms.netmgt.config.DefaultDataCollectionConfigDao in project opennms by OpenNMS.
the class SnmpInterfaceRrdMigratorOnlineTest method setUp.
/**
* Sets up the test.
*
* @throws Exception the exception
*/
@Before
public void setUp() throws Exception {
FileUtils.copyDirectory(new File("src/test/resources/etc"), new File("target/home/etc"));
FileUtils.copyDirectory(new File("src/test/resources/rrd"), new File("target/home/rrd"));
FileUtils.copyDirectory(new File("src/test/resources/jetty-webapps/opennms/WEB-INF"), new File("target/home/jetty-webapps/opennms/WEB-INF/"));
System.setProperty("opennms.home", "target/home");
DefaultDataCollectionConfigDao dao = new DefaultDataCollectionConfigDao();
dao.setConfigResource(new FileSystemResource(new File("target/home/etc/datacollection-config.xml")));
dao.afterPropertiesSet();
DataCollectionConfigFactory.setInstance(dao);
}
Aggregations