Search in sources :

Example 1 with ByteBufAllocatorMetricProviderWrapper

use of org.cloudfoundry.reactor.util.ByteBufAllocatorMetricProviderWrapper in project cf-java-client by cloudfoundry.

the class _DefaultConnectionContext method monitorByteBufAllocator.

@PostConstruct
void monitorByteBufAllocator() {
    try {
        ObjectName name = getByteBufAllocatorObjectName();
        if (ManagementFactory.getPlatformMBeanServer().isRegistered(name)) {
            this.logger.warn("MBean '{}' is already registered and will be removed. You should only have a single DefaultConnectionContext per endpoint.", name);
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(name);
        }
        ManagementFactory.getPlatformMBeanServer().registerMBean(new ByteBufAllocatorMetricProviderWrapper(PooledByteBufAllocator.DEFAULT), name);
    } catch (JMException e) {
        this.logger.error("Unable to register ByteBufAllocator MBean", e);
    }
}
Also used : ByteBufAllocatorMetricProviderWrapper(org.cloudfoundry.reactor.util.ByteBufAllocatorMetricProviderWrapper) JMException(javax.management.JMException) ObjectName(javax.management.ObjectName) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)1 JMException (javax.management.JMException)1 ObjectName (javax.management.ObjectName)1 ByteBufAllocatorMetricProviderWrapper (org.cloudfoundry.reactor.util.ByteBufAllocatorMetricProviderWrapper)1