Search in sources :

Example 6 with InstanceNotFoundException

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");
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) Test(org.junit.Test)

Example 7 with InstanceNotFoundException

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();
}
Also used : AttributeList(javax.management.AttributeList) InstanceNotFoundException(javax.management.InstanceNotFoundException) ObjectInstance(javax.management.ObjectInstance) JmxResultProcessor(com.googlecode.jmxtrans.model.JmxResultProcessor) Result(com.googlecode.jmxtrans.model.Result) Test(org.junit.Test)

Example 8 with InstanceNotFoundException

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);
        }
    }
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 9 with InstanceNotFoundException

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();
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 10 with InstanceNotFoundException

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);
    }
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanServer(javax.management.MBeanServer)

Aggregations

InstanceNotFoundException (javax.management.InstanceNotFoundException)102 ObjectName (javax.management.ObjectName)59 ReflectionException (javax.management.ReflectionException)44 MBeanException (javax.management.MBeanException)32 MalformedObjectNameException (javax.management.MalformedObjectNameException)28 MBeanRegistrationException (javax.management.MBeanRegistrationException)25 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)19 MBeanServer (javax.management.MBeanServer)17 IOException (java.io.IOException)16 AttributeNotFoundException (javax.management.AttributeNotFoundException)16 Attribute (javax.management.Attribute)15 IntrospectionException (javax.management.IntrospectionException)14 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)14 AttributeList (javax.management.AttributeList)12 ObjectInstance (javax.management.ObjectInstance)12 MBeanInfo (javax.management.MBeanInfo)11 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)10 RuntimeOperationsException (javax.management.RuntimeOperationsException)9 ArrayList (java.util.ArrayList)7 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)7