Search in sources :

Example 1 with ProbeClientMethodHandle

use of org.glassfish.flashlight.client.ProbeClientMethodHandle in project Payara by payara.

the class StatsProviderManagerDelegateImpl method registerStatsProviderToFlashlight.

private Collection<ProbeClientMethodHandle> registerStatsProviderToFlashlight(Object statsProvider) {
    // register the statsProvider with Flashlight
    Collection<ProbeClientMethodHandle> handles = null;
    // System.out.println("****** Registering the StatsProvider (" + statsProvider.getClass().getName() + ") with flashlight");
    StatsProviderRegistryElement spre = this.statsProviderRegistry.getStatsProviderRegistryElement(statsProvider);
    if (spre != null) {
        handles = pcm.registerListener(statsProvider, spre.getInvokerId());
    } else {
        handles = pcm.registerListener(statsProvider);
    }
    // save the handles also against statsProvider so you can unregister when statsProvider is unregistered
    return handles;
}
Also used : StatsProviderRegistryElement(org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement) ProbeClientMethodHandle(org.glassfish.flashlight.client.ProbeClientMethodHandle)

Example 2 with ProbeClientMethodHandle

use of org.glassfish.flashlight.client.ProbeClientMethodHandle 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 ProbeClientMethodHandle

use of org.glassfish.flashlight.client.ProbeClientMethodHandle in project Payara by payara.

the class StatsProviderManagerDelegateImpl method disableStatsProvider.

private void disableStatsProvider(StatsProviderRegistryElement spre) {
    if (logger.isLoggable(Level.FINE))
        logger.fine("Disabling the statsProvider - " + spre.getStatsProvider().getClass().getName());
    /* Step 1. Disable the tree nodes for StatsProvider */
    updateTreeNodes(spre, false);
    /* Step 2. Disable flashlight handles (Ideally unregister them) */
    for (ProbeClientMethodHandle handle : spre.getHandles()) {
        if (handle.isEnabled())
            handle.disable();
    }
    /* Step 3. Unregister gmbal */
    unregisterGmbal(spre);
    spre.setEnabled(false);
}
Also used : ProbeClientMethodHandle(org.glassfish.flashlight.client.ProbeClientMethodHandle)

Example 4 with ProbeClientMethodHandle

use of org.glassfish.flashlight.client.ProbeClientMethodHandle in project Payara by payara.

the class StatsProviderManagerDelegateImpl method unregister.

public void unregister(Object statsProvider) {
    // Unregisters the statsProvider
    try {
        StatsProviderRegistryElement spre = statsProviderRegistry.getStatsProviderRegistryElement(statsProvider);
        if (spre == null) {
            logger.log(Level.INFO, invalidStatsProvider, new Object[] { statsProvider.getClass().getName() });
            return;
        }
        // get the Parent node and delete all children nodes (only that we know of)
        String parentNodePath = spre.getParentTreeNodePath();
        List<String> childNodeNames = spre.getChildTreeNodeNames();
        TreeNode rootNode = mrdr.get(instanceName);
        if ((rootNode != null) && (parentNodePath != null)) {
            // This has to return one node
            List<TreeNode> nodeList = rootNode.getNodes(parentNodePath, false, true);
            if (nodeList.size() > 0) {
                TreeNode parentNode = nodeList.get(0);
                // Remove each of the child nodes
                Collection<TreeNode> childNodes = parentNode.getChildNodes();
                for (TreeNode childNode : childNodes) {
                    if (childNodeNames.contains(childNode.getName())) {
                        parentNode.removeChild(childNode);
                    }
                }
                if (!parentNode.hasChildNodes())
                    removeParentNode(parentNode);
            }
        }
        // get the handles and unregister the listeners from Flashlight
        Collection<ProbeClientMethodHandle> handles = spre.getHandles();
        if (handles != null) {
            for (ProbeClientMethodHandle handle : handles) {
                // handle.remove????? Mahesh?
                // TODO IMPLEMENTATION
                // For now disable the handle => remove the client from invokerlist
                handle.disable();
            }
        }
        // unregister the statsProvider from Gmbal
        if (spre.getManagedObjectManager() != null)
            unregisterGmbal(spre);
        // Unregister from the MonitoringDataTreeRegistry and the map entries
        statsProviderRegistry.unregisterStatsProvider(statsProvider);
    } catch (Exception ex) {
        String msg = MessageFormat.format(errorUnregisteringStatsProvider, statsProvider.getClass().getName());
        logger.log(Level.SEVERE, msg, ex);
    }
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode) StatsProviderRegistryElement(org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement) ProbeClientMethodHandle(org.glassfish.flashlight.client.ProbeClientMethodHandle) PropertyVetoException(java.beans.PropertyVetoException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

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