use of javax.management.InstanceNotFoundException in project metrics by dropwizard.
the class BufferPoolMetricSetTest method ignoresGaugesForObjectsWhichCannotBeFound.
@Test
public void ignoresGaugesForObjectsWhichCannotBeFound() throws Exception {
when(mBeanServer.getMBeanInfo(mapped)).thenThrow(new InstanceNotFoundException());
assertThat(buffers.getMetrics().keySet()).containsOnly("direct.count", "direct.capacity", "direct.used");
}
use of javax.management.InstanceNotFoundException in project jmxtrans by jmxtrans.
the class JmxResultProcessorTest method canReadFieldsOfTabularData.
@Test(timeout = 1000)
public void canReadFieldsOfTabularData() throws MalformedObjectNameException, AttributeNotFoundException, MBeanException, ReflectionException, InstanceNotFoundException {
// Need to induce a GC for the attribute below to be populated
Runtime.getRuntime().gc();
ObjectInstance runtime = null;
try {
runtime = getG1YoungGen();
} catch (InstanceNotFoundException e) {
// ignore test if G1 not enabled
assumeNoException("G1 GC in Java 7/8 needs to be enabled with -XX:+UseG1GC", e);
}
AttributeList attr;
// but takes a non-deterministic amount of time for LastGcInfo to get populated
while (true) {
// but bounded by Test timeout
attr = ManagementFactory.getPlatformMBeanServer().getAttributes(runtime.getObjectName(), new String[] { "LastGcInfo" });
if (((Attribute) attr.get(0)).getValue() != null) {
break;
}
}
List<Result> results = new JmxResultProcessor(dummyQueryWithResultAlias(), runtime, attr.asList(), runtime.getClassName(), TEST_DOMAIN_NAME).getResults();
assertThat(results.size()).isGreaterThan(2);
Optional<Result> result = from(results).firstMatch(new ByAttributeName("LastGcInfo"));
assertThat(result.isPresent()).isTrue();
// Should have primitive typed fields
assertThat(result.get().getValues().size()).isGreaterThan(0);
assertThat(result.get().getValues().get("duration")).isNotNull();
// assert tabular fields are excluded
assertThat(result.get().getValues().get("memoryUsageBeforeGc")).isNull();
assertThat(result.get().getValues().get("memoryUsageAfterGc")).isNull();
}
use of javax.management.InstanceNotFoundException in project databus by linkedin.
the class OpenReplicatorEventProducer method shutdown.
/* (non-Javadoc)
* @see com.linkedin.databus2.producers.AbstractEventProducer#shutdown()
*/
@Override
public synchronized void shutdown() {
_producerThread.shutdown();
super.shutdown();
for (ObjectName name : _registeredMbeans) {
try {
_mbeanServer.unregisterMBean(name);
_log.info("Unregistered or-source mbean: " + name);
} catch (MBeanRegistrationException e) {
_log.warn("Exception when unregistering or-source statistics mbean: " + name + e);
} catch (InstanceNotFoundException e) {
_log.warn("Exception when unregistering or-source statistics mbean: " + name + e);
}
}
}
use of javax.management.InstanceNotFoundException in project databus by linkedin.
the class OracleEventProducer method shutdown.
@Override
public synchronized void shutdown() {
for (ObjectName name : _registeredMbeans) {
try {
_mbeanServer.unregisterMBean(name);
_log.info("Unregistered source mbean: " + name);
} catch (MBeanRegistrationException e) {
_log.warn("Exception when unregistering source statistics mbean: " + name + e);
} catch (InstanceNotFoundException e) {
_log.warn("Exception when unregistering source statistics mbean: " + name + e);
}
}
super.shutdown();
}
use of javax.management.InstanceNotFoundException in project neo4j by neo4j.
the class JMXManagementModule method stop.
@Override
public void stop() {
try {
MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
beanServer.unregisterMBean(createObjectName());
} catch (InstanceNotFoundException e) {
// ok
} catch (Exception e) {
throw new RuntimeException("Unable to shut down jmx management, see nested exception.", e);
}
}
Aggregations