use of javax.management.ObjectInstance in project hbase by apache.
the class TestStochasticBalancerJmxMetrics method readJmxMetrics.
/**
* Read the attributes from Hadoop->HBase->Master->Balancer in JMX
* @throws IOException
*/
private Set<String> readJmxMetrics() throws IOException {
JMXConnector connector = null;
ObjectName target = null;
MBeanServerConnection mb = null;
try {
connector = JMXConnectorFactory.connect(JMXListener.buildJMXServiceURL(connectorPort, connectorPort));
mb = connector.getMBeanServerConnection();
Hashtable<String, String> pairs = new Hashtable<>();
pairs.put("service", "HBase");
pairs.put("name", "Master");
pairs.put("sub", "Balancer");
target = new ObjectName("Hadoop", pairs);
MBeanInfo beanInfo = mb.getMBeanInfo(target);
Set<String> existingAttrs = new HashSet<>();
for (MBeanAttributeInfo attrInfo : beanInfo.getAttributes()) {
existingAttrs.add(attrInfo.getName());
}
return existingAttrs;
} catch (Exception e) {
LOG.warn("Failed to get bean!!! " + target, e);
if (mb != null) {
Set<ObjectInstance> instances = mb.queryMBeans(null, null);
Iterator<ObjectInstance> iterator = instances.iterator();
System.out.println("MBean Found:");
while (iterator.hasNext()) {
ObjectInstance instance = iterator.next();
System.out.println("Class Name: " + instance.getClassName());
System.out.println("Object Name: " + instance.getObjectName());
}
}
} finally {
if (connector != null) {
try {
connector.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
return null;
}
use of javax.management.ObjectInstance in project spring-boot by spring-projects.
the class SpringApplicationAdminJmxAutoConfigurationTests method registeredWithProperty.
@Test
public void registeredWithProperty() throws Exception {
load(ENABLE_ADMIN_PROP);
ObjectName objectName = createDefaultObjectName();
ObjectInstance objectInstance = this.mBeanServer.getObjectInstance(objectName);
assertThat(objectInstance).as("Lifecycle bean should have been registered").isNotNull();
}
use of javax.management.ObjectInstance in project spring-boot by spring-projects.
the class InfinispanCacheStatisticsProvider method getObjectName.
@Override
protected ObjectName getObjectName(SpringCache cache) throws MalformedObjectNameException {
ObjectName name = new ObjectName("org.infinispan:component=Statistics,type=Cache,name=\"" + cache.getName() + "(local)\",*");
Set<ObjectInstance> instances = getMBeanServer().queryMBeans(name, null);
if (instances.size() == 1) {
return instances.iterator().next().getObjectName();
}
// None or more than one
return null;
}
use of javax.management.ObjectInstance in project neo4j by neo4j.
the class KernelProxy method allBeans.
protected List<Object> allBeans() {
List<Object> beans = new ArrayList<Object>();
Iterable<ObjectInstance> mbeans;
try {
mbeans = server.queryMBeans(mbeanQuery(), null);
} catch (IOException handled) {
return beans;
}
for (ObjectInstance instance : mbeans) {
String className = instance.getClassName();
Class<?> beanType = null;
try {
if (className != null) {
beanType = Class.forName(className);
}
} catch (Exception ignored) {
// fall through
} catch (LinkageError ignored) {
// fall through
}
if (beanType != null) {
try {
beans.add(BeanProxy.load(server, beanType, instance.getObjectName()));
} catch (Exception ignored) {
// fall through
}
}
}
return beans;
}
use of javax.management.ObjectInstance in project pulsar by yahoo.
the class MBeanStatsGenerator method generate.
private Collection<Metrics> generate() {
List<Metrics> metricsCollection = new ArrayList<Metrics>();
@SuppressWarnings("unchecked") Set<ObjectInstance> instances = mbs.queryMBeans(null, null);
for (ObjectInstance instance : instances) {
String beanName = instance.getObjectName().toString();
// skip GC MBean to avoid recursion
if (beanName.startsWith("java.lang:type=GarbageCollector")) {
continue;
}
Metrics metrics = convert(instance);
if (metrics != null) {
metricsCollection.add(metrics);
}
}
return metricsCollection;
}
Aggregations