use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.
the class AbstractTreeNode method getNodesInternal.
private List<TreeNode> getNodesInternal(String pattern, boolean ignoreDisabled, boolean gfv2Compatible) {
List<TreeNode> regexMatchedTree = new ArrayList<TreeNode>();
try {
if (gfv2Compatible)
pattern = convertGFv2PatternToRegex(pattern);
Pattern mPattern = Pattern.compile(pattern);
List<TreeNode> completeTree = traverse(ignoreDisabled);
for (TreeNode node : completeTree) {
String path = node.getCompletePathName();
String path2 = null;
if (path.indexOf("\\") >= 0)
path2 = path.replace("\\", "");
Matcher matcher = mPattern.matcher(path);
if (matcher.matches()) {
regexMatchedTree.add(node);
} else if (path2 != null) {
Matcher matcher2 = mPattern.matcher(path2);
if (matcher2.matches()) {
regexMatchedTree.add(node);
}
}
}
} catch (java.util.regex.PatternSyntaxException e) {
// log this
// e.printStackTrace ();
}
return regexMatchedTree;
}
use of org.glassfish.flashlight.datatree.TreeNode 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);
}
use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.
the class StatsProviderManagerDelegateImpl method createSubTree.
// 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;
}
use of org.glassfish.flashlight.datatree.TreeNode 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);
}
}
use of org.glassfish.flashlight.datatree.TreeNode in project Payara by payara.
the class StatsProviderManagerDelegateImpl method resetChildNodeStatistics.
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());
}
}
} else {
logger.log(Level.WARNING, nodeNotFound, new Object[] { parentNodePath, statsProviderName });
}
}
}
Aggregations