use of javax.management.AttributeList in project sling by apache.
the class MBeanResource method getAttributes.
public AttributeList getAttributes() {
if (this.attributeList == null) {
final MBeanAttributeInfo[] infos = info.getAttributes();
final String[] names = new String[infos.length];
int index = 0;
for (final MBeanAttributeInfo i : infos) {
names[index] = i.getName();
index++;
}
try {
this.attributeList = mbeanServer.getAttributes(objectName, names);
} catch (InstanceNotFoundException e) {
// ignore
this.attributeList = new AttributeList();
} catch (ReflectionException e) {
// ignore
this.attributeList = new AttributeList();
}
}
return this.attributeList;
}
use of javax.management.AttributeList in project jetty.project by eclipse.
the class ObjectMBeanUtilTest method getAttributes.
private AttributeList getAttributes(String name, String value) {
Attribute attribute = new Attribute(name, value);
AttributeList attributes = new AttributeList();
attributes.add(attribute);
return attributes;
}
use of javax.management.AttributeList in project jmxtrans by jmxtrans.
the class JmxResultProcessorTest method canReadCompositeData.
@Test
public void canReadCompositeData() throws MalformedObjectNameException, AttributeNotFoundException, MBeanException, ReflectionException, InstanceNotFoundException {
ObjectInstance memory = getMemory();
AttributeList attr = ManagementFactory.getPlatformMBeanServer().getAttributes(memory.getObjectName(), new String[] { "HeapMemoryUsage" });
List<Result> results = new JmxResultProcessor(dummyQueryWithResultAlias(), memory, attr.asList(), memory.getClassName(), TEST_DOMAIN_NAME).getResults();
assertThat(results).hasSize(1);
Result result = results.get(0);
assertThat(result.getAttributeName()).isEqualTo("HeapMemoryUsage");
assertThat(result.getTypeName()).isEqualTo("type=Memory");
Map<String, Object> values = result.getValues();
assertThat(values).hasSize(4);
Object objectValue = result.getValues().get("init");
assertThat(objectValue).isInstanceOf(Long.class);
}
use of javax.management.AttributeList in project jmxtrans by jmxtrans.
the class Query method fetchResults.
public Iterable<Result> fetchResults(MBeanServerConnection mbeanServer, ObjectName queryName) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
MBeanInfo info = mbeanServer.getMBeanInfo(queryName);
ObjectInstance oi = mbeanServer.getObjectInstance(queryName);
List<String> attributes;
if (attr.isEmpty()) {
attributes = new ArrayList<>();
for (MBeanAttributeInfo attrInfo : info.getAttributes()) {
attributes.add(attrInfo.getName());
}
} else {
attributes = attr;
}
try {
if (!attributes.isEmpty()) {
logger.debug("Executing queryName [{}] from query [{}]", queryName.getCanonicalName(), this);
AttributeList al = mbeanServer.getAttributes(queryName, attributes.toArray(new String[attributes.size()]));
return new JmxResultProcessor(this, oi, al.asList(), info.getClassName(), queryName.getDomain()).getResults();
}
} catch (UnmarshalException ue) {
if ((ue.getCause() != null) && (ue.getCause() instanceof ClassNotFoundException)) {
logger.debug("Bad unmarshall, continuing. This is probably ok and due to something like this: " + "http://ehcache.org/xref/net/sf/ehcache/distribution/RMICacheManagerPeerListener.html#52", ue.getMessage());
} else {
throw ue;
}
}
return ImmutableList.of();
}
use of javax.management.AttributeList in project graphdb by neo4j-attic.
the class Neo4jManager method getConfiguration.
public Map<String, Object> getConfiguration() {
final String[] keys;
final AttributeList attributes;
try {
MBeanAttributeInfo[] keyInfo = server.getMBeanInfo(config).getAttributes();
keys = new String[keyInfo.length];
for (int i = 0; i < keys.length; i++) {
keys[i] = keyInfo[i].getName();
}
attributes = server.getAttributes(config, keys);
} catch (Exception e) {
throw new IllegalStateException("Could not access the configuration bean", e);
}
Map<String, Object> configuration = new HashMap<String, Object>();
for (int i = 0; i < keys.length; i++) {
configuration.put(keys[i], attributes.get(i));
}
return configuration;
}
Aggregations