Search in sources :

Example 1 with MBeanMetadata

use of org.infinispan.factories.impl.MBeanMetadata in project infinispan by infinispan.

the class AbstractMetricsRegistration method processComponents.

private void processComponents() {
    for (ComponentRef<?> component : basicComponentRegistry.getRegisteredComponents()) {
        if (!component.isAlias()) {
            Object instance = component.wired();
            if (instance != null) {
                MBeanMetadata beanMetadata = basicComponentRegistry.getMBeanMetadata(instance.getClass().getName());
                if (beanMetadata != null) {
                    Set<Object> ids = registerMetrics(instance, beanMetadata.getJmxObjectName(), beanMetadata.getAttributes(), null, component.getName(), null);
                    metricIds.addAll(ids);
                    if (instance instanceof CustomMetricsSupplier) {
                        metricIds.addAll(registerMetrics(instance, beanMetadata.getJmxObjectName(), ((CustomMetricsSupplier) instance).getCustomMetrics(), null, component.getName(), null));
                    }
                }
            }
        }
    }
}
Also used : MBeanMetadata(org.infinispan.factories.impl.MBeanMetadata)

Example 2 with MBeanMetadata

use of org.infinispan.factories.impl.MBeanMetadata in project infinispan by infinispan.

the class AbstractMetricsRegistration method registerMetrics.

/**
 * Register metrics for a component that was manually registered later, after component registry startup. The metric
 * ids will be tracked and unregistration will be performed automatically on stop.
 */
public void registerMetrics(Object instance, String type, String componentName) {
    if (metricsCollector == null) {
        throw new IllegalStateException("Metrics are not initialized.");
    }
    MBeanMetadata beanMetadata = basicComponentRegistry.getMBeanMetadata(instance.getClass().getName());
    if (beanMetadata == null) {
        throw new IllegalArgumentException("No MBean metadata available for " + instance.getClass().getName());
    }
    Set<Object> ids = registerMetrics(instance, beanMetadata.getJmxObjectName(), beanMetadata.getAttributes(), type, componentName, null);
    metricIds.addAll(ids);
}
Also used : MBeanMetadata(org.infinispan.factories.impl.MBeanMetadata)

Aggregations

MBeanMetadata (org.infinispan.factories.impl.MBeanMetadata)2