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;
}
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);
}
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);
}
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);
}
}
Aggregations