use of org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean in project opennms by OpenNMS.
the class JmxDatacollectionConfiggenerator method createMbean.
private Mbean createMbean(ObjectName objectName) {
String typeAndOthers = objectName.getCanonicalName().substring(objectName.getCanonicalName().lastIndexOf("=") + 1);
final Mbean mbean = new Mbean();
mbean.setObjectname(objectName.toString());
mbean.setName(objectName.getDomain() + "." + typeAndOthers);
return mbean;
}
use of org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean in project opennms by OpenNMS.
the class JmxDatacollectionConfiggenerator method generateJmxConfigModel.
public JmxDatacollectionConfig generateJmxConfigModel(List<String> ids, MBeanServerConnection mBeanServerConnection, String serviceName, Boolean runStandardVmBeans, Boolean skipNonNumber, Map<String, String> dictionary) throws MBeanServerQueryException, IOException, JMException {
logger.debug("Startup values: \n serviceName: " + serviceName + "\n runStandardVmBeans: " + runStandardVmBeans + "\n dictionary" + dictionary);
aliasList.clear();
aliasMap.clear();
nameCutter.setDictionary(dictionary);
final QueryResult queryResult = queryMbeanServer(ids, mBeanServerConnection, runStandardVmBeans);
final JmxDatacollectionConfig xmlJmxDatacollectionConfig = createJmxDataCollectionConfig(serviceName, rrd);
final JmxCollection xmlJmxCollection = xmlJmxDatacollectionConfig.getJmxCollection().get(0);
for (QueryResult.MBeanResult eachMBeanResult : queryResult.getMBeanResults()) {
final ObjectName objectName = eachMBeanResult.objectName;
final Mbean xmlMbean = createMbean(objectName);
final QueryResult.AttributeResult attributeResult = eachMBeanResult.attributeResult;
for (MBeanAttributeInfo jmxBeanAttributeInfo : attributeResult.attributes) {
// check for CompositeData
if ("javax.management.openmbean.CompositeData".equals(jmxBeanAttributeInfo.getType())) {
CompAttrib compAttrib = createCompAttrib(mBeanServerConnection, objectName, jmxBeanAttributeInfo, skipNonNumber);
if (compAttrib != null) {
xmlMbean.getCompAttrib().add(compAttrib);
}
}
if (skipNonNumber && !numbers.contains(jmxBeanAttributeInfo.getType())) {
logger.warn("The type of attribute '{}' is '{}' and '--skipNonNumber' is set. Ignoring.", jmxBeanAttributeInfo.getName(), jmxBeanAttributeInfo.getType());
} else {
Attrib xmlJmxAttribute = createAttr(jmxBeanAttributeInfo);
xmlMbean.getAttrib().add(xmlJmxAttribute);
}
}
if (!xmlMbean.getAttrib().isEmpty() || !xmlMbean.getCompAttrib().isEmpty()) {
xmlJmxCollection.getMbeans().getMbean().add(xmlMbean);
}
}
if (xmlJmxCollection.getMbeans().getMbean().size() != queryResult.getMBeanResults().size()) {
logger.warn("Queried {} MBeans, but only got {} in the result set.", queryResult.getMBeanResults().size(), xmlJmxCollection.getMbeans().getMbean().size());
}
return xmlJmxDatacollectionConfig;
}
use of org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean in project opennms by OpenNMS.
the class MbeansHierarchicalContainer method updateDataSource.
protected void updateDataSource(List<Mbean> mbeanList) {
clearContainer();
for (Mbean eachMbean : mbeanList) {
add(eachMbean);
}
sort(new Object[] { MBeansTree.MetaMBeansTreeItem.CAPTION }, new boolean[] { true });
}
use of org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean in project opennms by OpenNMS.
the class MbeansHierarchicalContainer method addNodes.
private String addNodes(List nodesToAdd) {
String rootItemId = null;
Iterator it = nodesToAdd.iterator();
while (it.hasNext()) {
Object eachNode = it.next();
boolean hasChildren = it.hasNext();
if (eachNode instanceof Mbean) {
hasChildren |= ((Mbean) eachNode).getCompAttrib() != null && !((Mbean) eachNode).getCompAttrib().isEmpty();
}
rootItemId = addNode(rootItemId, eachNode, hasChildren);
}
return rootItemId;
}
use of org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean in project opennms by OpenNMS.
the class UniqueAttributeNameValidatorTest method testNotEmpty.
@Test
public void testNotEmpty() {
Mbean mbean = selectionManager.getSelectedMbeans().iterator().next();
DefaultNameProvider nameProvider = new DefaultNameProvider(selectionManager);
List<String> names = new ArrayList<>(nameProvider.getNamesMap().values());
Assert.assertNotNull(names);
Assert.assertEquals(3, names.size());
Collections.sort(names);
Assert.assertTrue(Arrays.equals(new String[] { "attrib1", "compMem1", "compMem2" }, names.toArray(new String[names.size()])));
// alias clash
mbean.getAttrib().add(TestHelper.createAttrib("attribute2", "attrib1"));
names = new ArrayList<>(nameProvider.getNamesMap().values());
Assert.assertEquals(4, names.size());
UniqueAttributeNameValidator validator = new UniqueAttributeNameValidator(nameProvider);
Assert.assertEquals(Boolean.TRUE.booleanValue(), validator.isValid("yes"));
Assert.assertEquals(Boolean.TRUE.booleanValue(), validator.isValid("compMem1"));
Assert.assertEquals(Boolean.FALSE.booleanValue(), validator.isValid("attrib1"));
}
Aggregations