Package org.glassfish.flashlight.datatree

Examples of org.glassfish.flashlight.datatree.TreeNode


            //Return the sub-resource list of root nodes

            //FIXME - No MonitoringRuntimeDataRegistry API available to get hold of
            //all the root nodes. We need this in case of clustering. We need to
            //get hold of root nodes for all the server instances.
            TreeNode serverNode = monitoringRegistry.get("server");
            if (serverNode != null) {
                //check to make sure we do not display empty server resource
                //    - http://host:port/monitoring/domain/server
                //When you turn monitoring levels HIGH and then turn them OFF,
                //you may see empty server resource. This is because server tree
                //node has children (disabled) even when all the monitoring
                //levels are turned OFF.
                //Issue: 9921
                if (!serverNode.getEnabledChildNodes().isEmpty()) {
                    list.add(serverNode);
                }
                return list;
            } else {
                //No root node available, so nothing to list
                //FIXME - Return appropriate message to the user
                ///return Response.status(404).entity("No monitoring data. Please check monitoring levels are configured").build();
                return list;
            }
        }

        //ignore the starting slash
        if (path.startsWith("/")) {
            path = path.substring(1);
        }

        //replace all . with \.
        path = path.replaceAll("\\.", "\\\\.");

        String dottedName = path.replace('/', '.');

        String root;
        int index =  dottedName.indexOf('.');
        if (index != -1) {
            root = dottedName.substring(0, dottedName.indexOf('.'));
            dottedName = dottedName.substring(dottedName.indexOf('.') + 1 );
        } else {
            root = dottedName;
            dottedName = "";
        }

        //TreeNode rootNode = monitoringRegistry.get("server");
        TreeNode rootNode = monitoringRegistry.get(root);
        if (rootNode == null) {
            //No monitoring data, so nothing to list
            //FIXME - Return appropriate message to the user
            ///return Response.status(404).entity("No monitoring data. Please check monitoring levels are configured").build();
            return list;
        }

        TreeNode  currentNode;
        if (dottedName.length() > 0) {
            currentNode = rootNode.getNode(dottedName);
        } else {
            currentNode = rootNode;
        }


        if (currentNode == null) {
            //No monitoring data, so nothing to list
            return list;
            ///return Response.status(404).entity("Monitoring object not found").build();
        }

        if (currentNode.hasChildNodes()) {
            //print(currentNode.getChildNodes());
            //TreeNode.getChildNodes() is returning disabled nodes too.
            //Switching to new api TreeNode.getEnabledChildNodes() which returns
            //only the enabled nodes. Reference Issue: 9921
            list.addAll(currentNode.getEnabledChildNodes());
        } else {
            Object result = currentNode.getValue();
            System.out.println("result: " + result);
            list.add(currentNode);
        }
        return list;
    }
View Full Code Here


    }


    private void print(java.util.Collection c) {
        java.util.Iterator it = c.iterator();
        TreeNode tn;
        while (it.hasNext()) {
            tn = (TreeNode) it.next();
            System.out.println("t: " + tn);
            System.out.println("Has children: " + tn.hasChildNodes());
        }
    }
View Full Code Here

            }

            // 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
View Full Code Here

        }

    }

    private void removeParentNode(TreeNode parentNode) {
        TreeNode superParentNode = parentNode.getParent();
        if (superParentNode != null) {
            superParentNode.removeChild(parentNode);
            if (!superParentNode.hasChildNodes())
                removeParentNode(superParentNode);
        }
    }
View Full Code Here

        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);
        }
View Full Code Here

    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) {
View Full Code Here

        }

    }

    private void resetChildNodeStatistics(String parentNodePath, List<String> childNodeNames, String statsProviderName) {
        TreeNode rootNode = mrdr.get(instanceName);
        if (rootNode != null) {
            List<TreeNode> nodeList = rootNode.getNodes(parentNodePath, false, true);
            if (nodeList.size() > 0) {
                TreeNode parentNode = nodeList.get(0);
                Collection<TreeNode> childNodes = parentNode.getChildNodes();
                for (TreeNode childNode : childNodes) {
                    if (childNodeNames.contains(childNode.getName())) {
                        invokeStatisticResetMethod(childNode.getValue());
                    }
                }
View Full Code Here

                    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;
    }
View Full Code Here

    // TODO TODO TODO
    // Here is where the slash meta-character is handled
    private TreeNode createSubTree(TreeNode parent, String subTreePath) {
        StringTokenizer st = new StringTokenizer(subTreePath, "/");
        TreeNode parentNode = parent;

        //enable the parent if not enabled
        enableTreeNode(parentNode);

        while (st.hasMoreTokens()) {
             TreeNode subTreeNode = createSubTreeNode(parentNode, st.nextToken());
            parentNode = subTreeNode;
        }
        return parentNode;
    }
View Full Code Here

        }
        return parentNode;
    }

    private TreeNode createSubTreeNode(TreeNode parent, String child) {
        TreeNode childNode = parent.getChild(child);
        if (childNode == null) {
            childNode = TreeNodeFactory.createTreeNode(child, null, child);
            parent.addChild(childNode);
        }
        else {
View Full Code Here

TOP

Related Classes of org.glassfish.flashlight.datatree.TreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.