Search in sources :

Example 6 with StatsProviderRegistryElement

use of org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement in project Payara by payara.

the class StatsProviderManagerDelegateImpl method registerAllGmbal.

public void registerAllGmbal() {
    if (logger.isLoggable(Level.FINE))
        logger.fine("Registering all the statsProviders whose enabled flag is 'on' with Gmbal");
    for (StatsProviderRegistryElement spre : statsProviderRegistry.getSpreList()) {
        if (spre.isEnabled()) {
            ManagedObjectManager mom = spre.getManagedObjectManager();
            if (mom == null) {
                mom = registerGmbal(spre.getStatsProvider(), spre.getMBeanName());
                spre.setManagedObjectManager(mom);
            }
        }
    }
}
Also used : ManagedObjectManager(org.glassfish.gmbal.ManagedObjectManager) StatsProviderRegistryElement(org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement)

Example 7 with StatsProviderRegistryElement

use of org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement in project Payara by payara.

the class StatsProviderManagerDelegateImpl method enableStatsProviders.

/* called from SMPD, when monitoring level for a module is turned on */
public void enableStatsProviders(String configElement) {
    // If monitoring-enabled is false, just return
    if (!getMonitoringEnabled())
        return;
    String configLevel = getMonitoringLevel(configElement);
    // Enable all the StatsProviders for a given configElement
    if (logger.isLoggable(Level.FINE))
        logger.fine("Enabling all the statsProviders for - " + configElement);
    List<StatsProviderRegistryElement> spreList = statsProviderRegistry.getStatsProviderRegistryElement(configElement);
    if (spreList == null)
        return;
    for (StatsProviderRegistryElement spre : spreList) {
        // Check to see if the enable is allowed
        // Not allowed if statsProvider is registered for Low and configLevel is HIGH
        boolean isEnableAllowed = spre.isEnableAllowed(configLevel);
        if (!spre.isEnabled()) {
            // OFF->LOW, OFF->HIGH
            if (isEnableAllowed) {
                enableStatsProvider(spre);
            }
        } else {
            // stats were registered at HIGH
            if (!isEnableAllowed) {
                disableStatsProvider(spre);
            }
        // else, Dont do anything LOW->HIGH (stats were registered at LOW)
        }
    }
}
Also used : StatsProviderRegistryElement(org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement)

Example 8 with StatsProviderRegistryElement

use of org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement in project Payara by payara.

the class StatsProviderManagerDelegateImpl method createTreeForStatsProvider.

private List<String> createTreeForStatsProvider(TreeNode parentNode, Object statsProvider) {
    /* construct monitoring tree at PluginPoint using subTreePath */
    List<String> childNodeNames = new ArrayList();
    /* Check for custom reset method and store for later to be called instead of
         standard reset methods on Statistic classes*/
    for (Method m : statsProvider.getClass().getMethods()) {
        ManagedAttribute ma = m.getAnnotation(ManagedAttribute.class);
        Reset resetMeth = m.getAnnotation(Reset.class);
        if (resetMeth != null) {
            StatsProviderRegistryElement spre = this.statsProviderRegistry.getStatsProviderRegistryElement(statsProvider);
            spre.setResetMethod(m);
        }
        if (ma != null) {
            String methodName = m.getName();
            String id = ma.id();
            if ((id == null) || id.isEmpty()) {
                // if id not specified, derive from method name
                String methodNameLower = methodName.toLowerCase(Locale.ENGLISH);
                if (methodNameLower.startsWith("get") && methodNameLower.length() > 3) {
                    id = methodNameLower.substring(3);
                }
            }
            TreeNode attrNode = TreeNodeFactory.createMethodInvoker(id, statsProvider, id, m);
            parentNode.addChild(attrNode);
            childNodeNames.add(attrNode.getName());
        }
    }
    return childNodeNames;
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode) Method(java.lang.reflect.Method) Reset(org.glassfish.external.statistics.annotations.Reset) StatsProviderRegistryElement(org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement) ManagedAttribute(org.glassfish.gmbal.ManagedAttribute)

Aggregations

StatsProviderRegistryElement (org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement)8 ProbeClientMethodHandle (org.glassfish.flashlight.client.ProbeClientMethodHandle)2 TreeNode (org.glassfish.flashlight.datatree.TreeNode)2 PropertyVetoException (java.beans.PropertyVetoException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 Reset (org.glassfish.external.statistics.annotations.Reset)1 ManagedAttribute (org.glassfish.gmbal.ManagedAttribute)1 ManagedObjectManager (org.glassfish.gmbal.ManagedObjectManager)1