use of org.opennms.netmgt.config.datacollection.DatacollectionGroup in project opennms by OpenNMS.
the class DataCollectionConfigMigrator17Offline method getDataCollectionGroup.
/**
* Gets the data collection group.
*
* @param configFile the configuration file
* @return the data collection group
*/
private DatacollectionGroup getDataCollectionGroup(File configFile) {
if (dataCollectionGroupMap.get(configFile) == null) {
log("Parsing datacollection-group %s\n", configFile.getAbsolutePath());
DatacollectionGroup grp = JaxbUtils.unmarshal(DatacollectionGroup.class, configFile);
dataCollectionGroupMap.put(configFile, grp);
}
return dataCollectionGroupMap.get(configFile);
}
use of org.opennms.netmgt.config.datacollection.DatacollectionGroup in project opennms by OpenNMS.
the class MibCompilerPanel method generateDataCollection.
/**
* Generate data collection.
*
* @param logger the logger
* @param fileName the file name
*/
private void generateDataCollection(final Logger logger, final String fileName) {
if (parseMib(logger, new File(MIBS_COMPILED_DIR, fileName))) {
final DatacollectionGroup dcGroup = mibParser.getDataCollection();
if (dcGroup == null) {
Notification.show("The MIB couldn't be processed for data collection because: " + mibParser.getFormattedErrors(), Notification.Type.ERROR_MESSAGE);
} else {
if (dcGroup.getGroups().size() > 0) {
try {
final String dataFileName = fileName.replaceFirst("\\..*$", ".xml");
final DataCollectionWindow w = new DataCollectionWindow(mibParser, dataCollectionDao, dataFileName, dcGroup, logger);
getUI().addWindow(w);
} catch (Throwable t) {
Notification.show(t.getMessage(), Notification.Type.ERROR_MESSAGE);
}
} else {
Notification.show("The MIB doesn't contain any metric for data collection.", Notification.Type.WARNING_MESSAGE);
}
}
}
}
use of org.opennms.netmgt.config.datacollection.DatacollectionGroup in project opennms by OpenNMS.
the class DataCollectionConfigParserTest method validateParser.
private static void validateParser(DataCollectionConfigParser parser) {
Map<String, DatacollectionGroup> groupMap = parser.getExternalGroupMap();
int currentResourceTypes = 0;
int currentSystemDefs = 0;
int currentMibGroups = 0;
for (DatacollectionGroup group : groupMap.values()) {
currentResourceTypes += group.getResourceTypes().size();
}
for (DatacollectionGroup group : groupMap.values()) {
currentSystemDefs += group.getSystemDefs().size();
}
for (DatacollectionGroup group : groupMap.values()) {
currentMibGroups += group.getGroups().size();
}
Assert.assertEquals(resourceTypesCount, currentResourceTypes);
Assert.assertEquals(systemDefCount, currentSystemDefs);
Assert.assertEquals(groupsCount, currentMibGroups);
}
Aggregations