use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.
the class JMXCollectorComplianceTest method getRequiredBeans.
@Override
public Map<String, Object> getRequiredBeans() {
MBeanServer mbeanServer = new MBeanServer();
JmxConfigDao jmxConfigDao = mock(JmxConfigDao.class, RETURNS_DEEP_STUBS);
final String host = InetAddrUtils.str(InetAddrUtils.getLocalHostAddress());
when(jmxConfigDao.getConfig().lookupMBeanServer(host, JmxServerConnector.DEFAULT_OPENNMS_JMX_PORT)).thenReturn(mbeanServer);
JmxCollection collection = new JmxCollection();
JMXDataCollectionConfigDao jmxCollectionDao = mock(JMXDataCollectionConfigDao.class, RETURNS_DEEP_STUBS);
when(jmxCollectionDao.getJmxCollection(COLLECTION)).thenReturn(collection);
return new ImmutableMap.Builder<String, Object>().put("jmxConfigDao", jmxConfigDao).put("jmxDataCollectionConfigDao", jmxCollectionDao).build();
}
use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.
the class JMXDataCollectionConfigDao method translateConfig.
@Override
public JmxDatacollectionConfig translateConfig(JmxDatacollectionConfig config) {
for (JmxCollection collection : config.getJmxCollectionList()) {
if (collection.hasImportMbeans()) {
for (String importMbeans : collection.getImportGroupsList()) {
final File file = getOpennmsHome().resolve(Paths.get("etc", importMbeans)).toFile();
LOG.debug("parseJmxMbeans: parsing {}", file);
final Mbeans mbeans = JaxbUtils.unmarshal(Mbeans.class, new FileSystemResource(file));
collection.addMbeans(mbeans.getMbeanList());
}
}
}
return config;
}
use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.
the class JMXDataCollectionConfigDao method buildCollectionMap.
/**
* Build collection map which is a hash map of Collection
* objects indexed by collection name...also build
* collection group map which is a hash map indexed
* by collection name with a hash map as the value
* containing a map of the collections's group names
* to the Group object containing all the information
* for that group. So the associations are:
* <p/>
* CollectionMap
* collectionName -> Collection
* <p/>
* CollectionGroupMap
* collectionName -> groupMap
* <p/>
* GroupMap
* groupMapName -> Group
* <p/>
* This is parsed and built at initialization for
* faster processing at run-time.
*/
private void buildCollectionMap(JmxDatacollectionConfig config) {
m_lock.writeLock().lock();
try {
m_collectionMap.clear();
// global to all the mbeans?
for (JmxCollection collection : config.getJmxCollectionList()) {
// Build group map for this collection
Map<String, Mbean> groupMap = new HashMap<String, Mbean>();
for (Mbean mbean : collection.getMbeans()) {
groupMap.put(mbean.getName(), mbean);
}
m_collectionMap.put(collection.getName(), collection);
}
} finally {
m_lock.writeLock().unlock();
}
}
use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.
the class JMXDataCollectionConfigDao method getJmxCollection.
public JmxCollection getJmxCollection(String collectionName) {
// Try retrieving the object, which will trigger a reload of the cache if it changed
getObject();
m_lock.readLock().lock();
try {
JmxCollection collection = m_collectionMap.get(collectionName);
if (collection == null) {
LOG.warn("No JMX Config for collection '{}' found", collectionName);
}
return collection;
} finally {
m_lock.readLock().unlock();
}
}
Aggregations