use of javax.management.MBeanAttributeInfo in project jersey by jersey.
the class ExecutionStatisticsDynamicBean method initMBeanInfo.
private MBeanInfo initMBeanInfo(final ExecutionStatistics initialStatistics) {
final Map<Long, TimeWindowStatistics> statsMap = initialStatistics.getTimeWindowStatistics();
MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[statsMap.size() * 5];
int i = 0;
for (final TimeWindowStatistics stats : statsMap.values()) {
final long interval = stats.getTimeWindow();
final String postfix = convertIntervalToString((int) interval);
String name = "MinTime[ms]_" + postfix;
attrs[i++] = new MBeanAttributeInfo(name, "long", "Minimum request processing time in milliseconds in last " + postfix + ".", true, false, false);
attributeValues.put(name, new Value<Object>() {
@Override
public Object get() {
return executionStatistics.getTimeWindowStatistics().get(interval).getMinimumDuration();
}
});
name = "MaxTime[ms]_" + postfix;
attrs[i++] = new MBeanAttributeInfo(name, "long", "Minimum request processing time in milliseconds in last " + postfix + ".", true, false, false);
attributeValues.put(name, new Value<Object>() {
@Override
public Object get() {
return executionStatistics.getTimeWindowStatistics().get(interval).getMaximumDuration();
}
});
name = "AverageTime[ms]_" + postfix;
attrs[i++] = new MBeanAttributeInfo(name, "long", "Average request processing time in milliseconds in last " + postfix + ".", true, false, false);
attributeValues.put(name, new Value<Object>() {
@Override
public Object get() {
return executionStatistics.getTimeWindowStatistics().get(interval).getAverageDuration();
}
});
name = "RequestRate[requestsPerSeconds]_" + postfix;
attrs[i++] = new MBeanAttributeInfo(name, "double", "Average requests per second in last " + postfix + ".", true, false, false);
attributeValues.put(name, new Value<Object>() {
@Override
public Object get() {
return executionStatistics.getTimeWindowStatistics().get(interval).getRequestsPerSecond();
}
});
name = "RequestCount_" + postfix;
attrs[i++] = new MBeanAttributeInfo(name, "double", "Request count in last " + postfix + ".", true, false, false);
attributeValues.put(name, new Value<Object>() {
@Override
public Object get() {
return executionStatistics.getTimeWindowStatistics().get(interval).getRequestCount();
}
});
}
return new MBeanInfo(this.getClass().getName(), "Execution statistics", attrs, null, null, null);
}
use of javax.management.MBeanAttributeInfo in project jmxtrans by jmxtrans.
the class TreeWalker method walkTree.
public void walkTree(MBeanServerConnection connection) throws Exception {
// key here is null, null returns everything!
Set<ObjectName> mbeans = connection.queryNames(null, null);
for (ObjectName name : mbeans) {
MBeanInfo info = connection.getMBeanInfo(name);
MBeanAttributeInfo[] attrs = info.getAttributes();
String[] attrNames = new String[attrs.length];
for (int i = 0; i < attrs.length; i++) {
attrNames[i] = attrs[i].getName();
}
try {
AttributeList attributes = connection.getAttributes(name, attrNames);
for (Attribute attribute : attributes.asList()) {
output(name.getCanonicalName() + "%" + attribute.getName(), attribute.getValue());
}
} catch (Exception e) {
log.error("error getting " + name + ":" + e.getMessage(), e);
}
}
}
use of javax.management.MBeanAttributeInfo in project jmxtrans by jmxtrans.
the class TreeWalker3 method walkTree.
public void walkTree(MBeanServerConnection connection, Server server) throws Exception {
// key here is null, null returns everything!
Set<ObjectName> mbeans = connection.queryNames(null, null);
Map<String, String> output = newHashMap();
for (ObjectName name : mbeans) {
MBeanInfo info = connection.getMBeanInfo(name);
MBeanAttributeInfo[] attrs = info.getAttributes();
Query.Builder queryBuilder = Query.builder().setObj(name.getCanonicalName());
ResultCapture resultCapture = new ResultCapture();
queryBuilder.addOutputWriterFactory(resultCapture);
for (MBeanAttributeInfo attrInfo : attrs) {
queryBuilder.addAttr(attrInfo.getName());
}
Query query = queryBuilder.build();
try {
Iterable<Result> results = server.execute(query);
query.runOutputWritersForQuery(server, results);
} catch (AttributeNotFoundException anfe) {
log.error("Error", anfe);
}
for (Result result : resultCapture.results) {
output.put(result.getTypeName(), query.getAttr().toString());
}
}
for (Entry<String, String> entry : output.entrySet()) {
log.debug(entry.getKey());
log.debug(entry.getValue());
log.debug("-----------------------------------------");
}
}
use of javax.management.MBeanAttributeInfo in project neo4j by neo4j.
the class JmxQueryProcedureTest method setup.
@Before
public void setup() throws Throwable {
jmxServer = mock(MBeanServer.class);
beanName = new ObjectName("org.neo4j:chevyMakesTheTruck=bobMcCoshMakesTheDifference");
attributeName = "name";
when(jmxServer.queryNames(new ObjectName("*:*"), null)).thenReturn(asSet(beanName));
when(jmxServer.getMBeanInfo(beanName)).thenReturn(new MBeanInfo("org.neo4j.SomeMBean", "This is a description", new MBeanAttributeInfo[] { new MBeanAttributeInfo(attributeName, "someType", "This is the attribute desc.", true, false, false) }, null, null, null));
}
use of javax.management.MBeanAttributeInfo in project neo4j by neo4j.
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<>();
for (int i = 0; i < keys.length; i++) {
configuration.put(keys[i], attributes.get(i));
}
return configuration;
}
Aggregations