Search in sources :

Example 6 with DefaultDataCollectionConfigDao

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();
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) OnmsUpgradeException(org.opennms.upgrade.api.OnmsUpgradeException) DefaultDataCollectionConfigDao(org.opennms.netmgt.config.DefaultDataCollectionConfigDao) OnmsUpgradeException(org.opennms.upgrade.api.OnmsUpgradeException) IOException(java.io.IOException)

Example 7 with DefaultDataCollectionConfigDao

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();
    }
}
Also used : InputStream(java.io.InputStream) SnmpPeerFactory(org.opennms.netmgt.config.SnmpPeerFactory) CollectdConfigFactory(org.opennms.netmgt.config.CollectdConfigFactory) DatabaseSchemaConfigFactory(org.opennms.netmgt.config.DatabaseSchemaConfigFactory) DefaultDataCollectionConfigDao(org.opennms.netmgt.config.DefaultDataCollectionConfigDao) InputStreamResource(org.springframework.core.io.InputStreamResource)

Example 8 with DefaultDataCollectionConfigDao

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());
}
Also used : DefaultDataCollectionConfigDao(org.opennms.netmgt.config.DefaultDataCollectionConfigDao) Test(org.junit.Test)

Example 9 with DefaultDataCollectionConfigDao

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);
}
Also used : DefaultDataCollectionConfigDao(org.opennms.netmgt.config.DefaultDataCollectionConfigDao) Test(org.junit.Test)

Example 10 with DefaultDataCollectionConfigDao

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);
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) DefaultDataCollectionConfigDao(org.opennms.netmgt.config.DefaultDataCollectionConfigDao) Before(org.junit.Before)

Aggregations

DefaultDataCollectionConfigDao (org.opennms.netmgt.config.DefaultDataCollectionConfigDao)12 FileSystemResource (org.springframework.core.io.FileSystemResource)6 File (java.io.File)5 Test (org.junit.Test)4 Before (org.junit.Before)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 MockCollectionAgent (org.opennms.core.collection.test.MockCollectionAgent)2 RrdPersisterFactory (org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory)2 DatabaseSchemaConfigFactory (org.opennms.netmgt.config.DatabaseSchemaConfigFactory)2 NodeDao (org.opennms.netmgt.dao.api.NodeDao)2 FilesystemResourceStorageDao (org.opennms.netmgt.dao.support.FilesystemResourceStorageDao)2 OnmsAssetRecord (org.opennms.netmgt.model.OnmsAssetRecord)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 JRobinRrdStrategy (org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy)2 OnmsUpgradeException (org.opennms.upgrade.api.OnmsUpgradeException)2 InputStreamResource (org.springframework.core.io.InputStreamResource)2 FileInputStream (java.io.FileInputStream)1 FileWriter (java.io.FileWriter)1 Date (java.util.Date)1