Search in sources :

Example 1 with TreeNode

use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.

the class AltServletStatsImpl method process.

public ActionReport process(final ActionReport report, final String filter) {
    if (mrdr == null) {
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(rb.getString(LogFacade.MRDR_NULL));
        return report;
    }
    TreeNode serverNode = mrdr.get("server");
    if (serverNode == null) {
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(rb.getString(LogFacade.MRDR_NULL));
        return report;
    }
    String[] patternArr = new String[] { "server.web.servlet.*" };
    long activeServletsLoadedCount = 0;
    long maxServletsLoadedCount = 0;
    long totalServletsLoadedCount = 0;
    for (String pattern : patternArr) {
        List<TreeNode> tnL = serverNode.getNodes(pattern);
        for (TreeNode tn : tnL) {
            if (tn.hasChildNodes()) {
                continue;
            }
            if ("activeservletsloadedcount".equals(tn.getName())) {
                activeServletsLoadedCount = getRangeStatisticValue(tn.getValue());
            } else if ("maxservletsloadedcount".equals(tn.getName())) {
                maxServletsLoadedCount = getCountStatisticValue(tn.getValue());
            } else if ("totalservletsloadedcount".equals(tn.getName())) {
                totalServletsLoadedCount = getCountStatisticValue(tn.getValue());
            }
        }
    }
    report.setMessage(String.format(displayFormat, activeServletsLoadedCount, maxServletsLoadedCount, totalServletsLoadedCount));
    report.setActionExitCode(ExitCode.SUCCESS);
    return report;
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode)

Example 2 with TreeNode

use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.

the class HTTPListenerStatsImpl method process.

public ActionReport process(final ActionReport report, final String filter) {
    if (logger.isLoggable(Level.FINEST)) {
        logger.finest("HTTPListenerStatsImpl: process ...");
    }
    if (mrdr == null) {
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(rb.getString(LogFacade.MRDR_NULL));
        return report;
    }
    TreeNode serverNode = mrdr.get("server");
    if (serverNode == null) {
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(rb.getString(LogFacade.MRDR_NULL));
        return report;
    }
    long errorCount = 0;
    long maxTime = 0;
    double processingTime = 0;
    long requestCount = 0;
    List<TreeNode> tnL = serverNode.getNodes("server.web.request.*");
    for (TreeNode tn : tnL) {
        if (tn.hasChildNodes()) {
            continue;
        }
        if ("errorcount".equals(tn.getName())) {
            errorCount = getCountStatisticValue(tn.getValue());
        } else if ("maxtime".equals(tn.getName())) {
            maxTime = getCountStatisticValue(tn.getValue());
        } else if ("processingtime".equals(tn.getName())) {
            processingTime = getCountStatisticValue(tn.getValue());
        } else if ("requestcount".equals(tn.getName())) {
            requestCount = getCountStatisticValue(tn.getValue());
        }
    }
    // report.setMessage(String.format(displayFormat, "ec", "mt", "pt", "rc"));
    report.setMessage(String.format(displayFormat, errorCount, maxTime, processingTime, requestCount));
    report.setActionExitCode(ExitCode.SUCCESS);
    return report;
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode)

Example 3 with TreeNode

use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.

the class WebModuleVirtualServerStatsImpl method process.

public ActionReport process(final ActionReport report, final String filter) {
    if (mrdr == null) {
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(rb.getString(LogFacade.MRDR_NULL));
        return report;
    }
    TreeNode serverNode = mrdr.get("server");
    if (serverNode == null) {
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(rb.getString(LogFacade.MRDR_NULL));
        return report;
    }
    String[] patternArr;
    if (appName != null) {
        // post prelude - need to fix this for virtual server
        patternArr = new String[] { "server.applications." + appName + ".*.*" };
    } else {
        patternArr = new String[] { "server.web.session.*", "server.web.servlet.*", "server.web.jsp.*" };
    }
    long activeSessionsCount = 0;
    long sessionsTotal = 0;
    long rejectedSessionsTotal = 0;
    long activatedSessionsTotal = 0;
    long activeJspsLoadedCount = 0;
    long maxJspsLoadedCount = 0;
    long totalJspsLoadedCount = 0;
    long activeServletsLoadedCount = 0;
    long maxServletsLoadedCount = 0;
    long totalServletsLoadedCount = 0;
    long lval = 0;
    for (String pattern : patternArr) {
        List<TreeNode> tnL = serverNode.getNodes(pattern);
        for (TreeNode tn : tnL) {
            if (tn.hasChildNodes()) {
                continue;
            }
            if ("activesessionscount".equals(tn.getName())) {
                activeSessionsCount = getRangeStatisticValue(tn.getValue());
            } else if ("activatedsessionstotal".equals(tn.getName())) {
                activatedSessionsTotal = getCountStatisticValue(tn.getValue());
            } else if ("rejectedsessionstotal".equals(tn.getName())) {
                rejectedSessionsTotal = getCountStatisticValue(tn.getValue());
            } else if ("sessionstotal".equals(tn.getName())) {
                sessionsTotal = getCountStatisticValue(tn.getValue());
            } else if ("activejspsloadedcount".equals(tn.getName())) {
                activeJspsLoadedCount = getRangeStatisticValue(tn.getValue());
            } else if ("maxjspsloadedcount".equals(tn.getName())) {
                maxJspsLoadedCount = getCountStatisticValue(tn.getValue());
            } else if ("totaljspsloadedcount".equals(tn.getName())) {
                totalJspsLoadedCount = getCountStatisticValue(tn.getValue());
            } else if ("activeservletsloadedcount".equals(tn.getName())) {
                activeServletsLoadedCount = getRangeStatisticValue(tn.getValue());
            } else if ("maxservletsloadedcount".equals(tn.getName())) {
                maxServletsLoadedCount = getCountStatisticValue(tn.getValue());
            } else if ("totalservletsloadedcount".equals(tn.getName())) {
                totalServletsLoadedCount = getCountStatisticValue(tn.getValue());
            }
        }
    }
    report.setMessage(String.format(displayFormat, activeSessionsCount, activatedSessionsTotal, rejectedSessionsTotal, sessionsTotal, activeJspsLoadedCount, maxJspsLoadedCount, totalJspsLoadedCount, activeServletsLoadedCount, maxServletsLoadedCount, totalServletsLoadedCount));
    report.setActionExitCode(ExitCode.SUCCESS);
    return report;
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode)

Example 4 with TreeNode

use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.

the class StatsProviderManagerDelegateImpl method updateTreeNodes.

private void updateTreeNodes(StatsProviderRegistryElement spre, boolean enable) {
    // Enable/Disable the child TreeNodes
    String parentNodePath = spre.getParentTreeNodePath();
    List<String> childNodeNames = spre.getChildTreeNodeNames();
    TreeNode rootNode = mrdr.get(instanceName);
    if (rootNode != null) {
        // This has to return one node
        List<TreeNode> nodeList = rootNode.getNodes(parentNodePath, false, true);
        TreeNode parentNode = nodeList.get(0);
        // For each child Node, enable it
        Collection<TreeNode> childNodes = parentNode.getChildNodes();
        boolean hasUpdatedNode = false;
        for (TreeNode childNode : childNodes) {
            if (childNodeNames.contains(childNode.getName())) {
                // Enabling or Disabling the child node (based on enable flag)
                if (childNode.isEnabled() != enable) {
                    childNode.setEnabled(enable);
                    hasUpdatedNode = true;
                }
            }
        }
        if (!hasUpdatedNode)
            return;
        // Make sure the tree path is affected with the changes.
        if (enable) {
            enableTreeNode(parentNode);
        } else {
            disableTreeNode(parentNode);
        }
    }
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode)

Example 5 with TreeNode

use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.

the class StatsProviderManagerDelegateImpl method disableTreeNode.

private void disableTreeNode(TreeNode treeNode) {
    if (treeNode.isEnabled()) {
        boolean isAnyChildEnabled = false;
        Collection<TreeNode> childNodes = treeNode.getChildNodes();
        if (childNodes != null) {
            for (TreeNode childNode : childNodes) {
                if (childNode.isEnabled()) {
                    isAnyChildEnabled = true;
                    break;
                }
            }
        }
        // if none of the childs are enabled, disable the parent
        if (!isAnyChildEnabled) {
            treeNode.setEnabled(false);
            // recursevely call the disable on parent nodes
            if (treeNode.getParent() != null) {
                disableTreeNode(treeNode.getParent());
            }
        }
    }
}
Also used : TreeNode(org.glassfish.flashlight.datatree.TreeNode)

Aggregations

TreeNode (org.glassfish.flashlight.datatree.TreeNode)23 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 Pattern (java.util.regex.Pattern)2 StatsProviderRegistryElement (org.glassfish.admin.monitor.StatsProviderRegistry.StatsProviderRegistryElement)2 ProbeClientMethodHandle (org.glassfish.flashlight.client.ProbeClientMethodHandle)2 Domain (com.sun.enterprise.config.serverbeans.Domain)1 Server (com.sun.enterprise.config.serverbeans.Server)1 PropertyVetoException (java.beans.PropertyVetoException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Matcher (java.util.regex.Matcher)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 PathSegment (javax.ws.rs.core.PathSegment)1