Search in sources :

Example 1 with ManagedObjectManager

use of org.glassfish.gmbal.ManagedObjectManager in project Payara by payara.

the class StatsProviderManagerDelegateImpl method unregisterGmbal.

private void unregisterGmbal(StatsProviderRegistryElement spre) {
    // unregister the statsProvider from Gmbal
    ManagedObjectManager mom = spre.getManagedObjectManager();
    if (mom != null) {
        mom.unregister(spre.getStatsProvider());
        try {
            mom.close();
        } catch (IOException ioe) {
            logger.log(Level.SEVERE, gmbalUnRegistrationFailed, ioe);
        }
        spre.setManagedObjectManager(null);
    }
}
Also used : ManagedObjectManager(org.glassfish.gmbal.ManagedObjectManager) IOException(java.io.IOException)

Example 2 with ManagedObjectManager

use of org.glassfish.gmbal.ManagedObjectManager in project Payara by payara.

the class StatsProviderManagerDelegateImpl method enableStatsProvider.

private void enableStatsProvider(StatsProviderRegistryElement spre) {
    Object statsProvider = spre.getStatsProvider();
    if (logger.isLoggable(Level.FINE))
        logger.fine("Enabling the statsProvider - " + statsProvider.getClass().getName());
    // Check if we already have TreeNodes created
    if (spre.getParentTreeNodePath() == null) {
        /* Verify if PluginPoint exists, create one if it doesn't */
        PluginPoint pp = spre.getPluginPoint();
        String subTreePath = spre.getSubTreePath();
        TreeNode ppNode = getPluginPointNode(pp, serverNode);
        TreeNode parentNode = createSubTree(ppNode, subTreePath);
        List<String> childNodeNames = createTreeForStatsProvider(parentNode, statsProvider);
        spre.setParentTreeNodePath(parentNode.getCompletePathName());
        spre.setChildNodeNames(childNodeNames);
    } else {
        updateTreeNodes(spre, true);
    }
    /* Step 2. reset statistics (OFF --> LOW, OFF --> HIGH)*/
    resetStatistics(spre);
    /* Step 3. register the StatsProvider to the flashlight */
    if (spre.getHandles() == null) {
        // register with flashlight and save the handles
        Collection<ProbeClientMethodHandle> handles = registerStatsProviderToFlashlight(statsProvider);
        spre.setHandles(handles);
    } else {
        // Enable the Flashlight handles for this statsProvider
        for (ProbeClientMethodHandle handle : spre.getHandles()) {
            if (!handle.isEnabled())
                handle.enable();
        }
    }
    /* Step 4. gmbal registration */
    if (AMXReady && getMbeanEnabledValue()) {
        // Create mom root using the statsProvider
        String subTreePath = spre.getSubTreePath();
        ManagedObjectManager mom = spre.getManagedObjectManager();
        if (mom == null) {
            mom = registerGmbal(statsProvider, subTreePath);
            spre.setManagedObjectManager(mom);
        }
    }
    spre.setEnabled(true);
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode) ManagedObjectManager(org.glassfish.gmbal.ManagedObjectManager) ProbeClientMethodHandle(org.glassfish.flashlight.client.ProbeClientMethodHandle) PluginPoint(org.glassfish.external.probe.provider.PluginPoint)

Example 3 with ManagedObjectManager

use of org.glassfish.gmbal.ManagedObjectManager in project Payara by payara.

the class StatsProviderManagerDelegateImpl method mbeanRegistered.

// Called when AMX DomainRoot is loaded (when jconsole or gui is started)
// Register statsProviders with gmbal whose configElement is enabled
// Save mom in the spre.  Used in unregister with gmbal later for config change to OFF or undeploy
// Set AMXReady flag to true
@Override
public void mbeanRegistered(final ObjectName objectName, final MBeanListener listener) {
    super.mbeanRegistered(objectName, listener);
    AMXReady = true;
    statsProviderRegistry.setAMXReady(true);
    if (this.getMbeanEnabledValue()) {
        for (StatsProviderRegistry.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 : StatsProviderRegistryElement(org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement) ManagedObjectManager(org.glassfish.gmbal.ManagedObjectManager)

Example 4 with ManagedObjectManager

use of org.glassfish.gmbal.ManagedObjectManager in project Payara by payara.

the class StatsProviderManagerDelegateImpl method registerGmbal.

private ManagedObjectManager registerGmbal(Object statsProvider, String mbeanName) {
    ManagedObjectManager mom = null;
    try {
        // 1 mom per statsProvider
        mom = ManagedObjectManagerFactory.createFederated(MONITORING_SERVER);
        if (mom != null) {
            mom.setJMXRegistrationDebug(false);
            if (mom.isManagedObject(statsProvider)) {
                mom.stripPackagePrefix();
                if (mbeanName != null && !mbeanName.isEmpty()) {
                    if (mbeanName.indexOf('\\') > 0) {
                        mbeanName = StringUtils.removeChar(mbeanName, '\\');
                    }
                    mbeanName = mbeanName.replaceAll(SystemPropertyConstants.SLASH, "/");
                    mom.createRoot(statsProvider, mbeanName);
                } else {
                    mom.createRoot(statsProvider);
                }
            } else {
                String spName = statsProvider.getClass().getName();
                logger.log(Level.INFO, notaManagedObject, new Object[] { spName });
            }
        }
    // To register hierarchy in mom specify parent ManagedObject, and the ManagedObject itself
    // DynamicMBean mbean = (DynamicMBean)mom.register(parent, obj);
    } catch (IllegalArgumentException ex) {
        // full stack trace
        if (ex.getCause().getCause() instanceof InstanceAlreadyExistsException) {
            // createRoot failed - need to return a null mom so we know not
            // to unregister an mbean that does not exist
            mom = null;
            logger.log(Level.INFO, "Could not register MBean - " + "MBean already exists: {0}", ex.getCause().getCause().getMessage());
        } else {
            // createRoot failed - need to return a null mom so we know not
            // to unregister an mbean that does not exist
            mom = null;
            logger.log(Level.SEVERE, gmbalRegistrationFailed, ex);
        }
    } catch (Exception e) {
        // createRoot failed - need to return a null mom so we know not to unregister an mbean that does not exist
        mom = null;
        logger.log(Level.SEVERE, gmbalRegistrationFailed, e);
    }
    return mom;
}
Also used : ManagedObjectManager(org.glassfish.gmbal.ManagedObjectManager) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) PropertyVetoException(java.beans.PropertyVetoException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 5 with ManagedObjectManager

use of org.glassfish.gmbal.ManagedObjectManager 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)

Aggregations

ManagedObjectManager (org.glassfish.gmbal.ManagedObjectManager)5 IOException (java.io.IOException)2 StatsProviderRegistryElement (org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement)2 PropertyVetoException (java.beans.PropertyVetoException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 PluginPoint (org.glassfish.external.probe.provider.PluginPoint)1 ProbeClientMethodHandle (org.glassfish.flashlight.client.ProbeClientMethodHandle)1 TreeNode (org.glassfish.flashlight.datatree.TreeNode)1