use of org.glassfish.gmbal.ManagedObjectManager in project Payara by payara.
the class StatsProviderManagerDelegateImpl method unregisterGmbal.
private void unregisterGmbal(StatsProviderRegistryElement spre) {
// unregister the statsProvider from Gmbal
ManagedObjectManager mom = spre.getManagedObjectManager();
if (mom != null) {
mom.unregister(spre.getStatsProvider());
try {
mom.close();
} catch (IOException ioe) {
logger.log(Level.SEVERE, gmbalUnRegistrationFailed, ioe);
}
spre.setManagedObjectManager(null);
}
}
use of org.glassfish.gmbal.ManagedObjectManager 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.gmbal.ManagedObjectManager in project Payara by payara.
the class StatsProviderManagerDelegateImpl method mbeanRegistered.
// Called when AMX DomainRoot is loaded (when jconsole or gui is started)
// Register statsProviders with gmbal whose configElement is enabled
// Save mom in the spre. Used in unregister with gmbal later for config change to OFF or undeploy
// Set AMXReady flag to true
@Override
public void mbeanRegistered(final ObjectName objectName, final MBeanListener listener) {
super.mbeanRegistered(objectName, listener);
AMXReady = true;
statsProviderRegistry.setAMXReady(true);
if (this.getMbeanEnabledValue()) {
for (StatsProviderRegistry.StatsProviderRegistryElement spre : statsProviderRegistry.getSpreList()) {
if (spre.isEnabled()) {
ManagedObjectManager mom = spre.getManagedObjectManager();
if (mom == null) {
mom = registerGmbal(spre.getStatsProvider(), spre.getMBeanName());
spre.setManagedObjectManager(mom);
}
}
}
}
}
use of org.glassfish.gmbal.ManagedObjectManager in project Payara by payara.
the class StatsProviderManagerDelegateImpl method registerGmbal.
private ManagedObjectManager registerGmbal(Object statsProvider, String mbeanName) {
ManagedObjectManager mom = null;
try {
// 1 mom per statsProvider
mom = ManagedObjectManagerFactory.createFederated(MONITORING_SERVER);
if (mom != null) {
mom.setJMXRegistrationDebug(false);
if (mom.isManagedObject(statsProvider)) {
mom.stripPackagePrefix();
if (mbeanName != null && !mbeanName.isEmpty()) {
if (mbeanName.indexOf('\\') > 0) {
mbeanName = StringUtils.removeChar(mbeanName, '\\');
}
mbeanName = mbeanName.replaceAll(SystemPropertyConstants.SLASH, "/");
mom.createRoot(statsProvider, mbeanName);
} else {
mom.createRoot(statsProvider);
}
} else {
String spName = statsProvider.getClass().getName();
logger.log(Level.INFO, notaManagedObject, new Object[] { spName });
}
}
// To register hierarchy in mom specify parent ManagedObject, and the ManagedObject itself
// DynamicMBean mbean = (DynamicMBean)mom.register(parent, obj);
} catch (IllegalArgumentException ex) {
// full stack trace
if (ex.getCause().getCause() instanceof InstanceAlreadyExistsException) {
// createRoot failed - need to return a null mom so we know not
// to unregister an mbean that does not exist
mom = null;
logger.log(Level.INFO, "Could not register MBean - " + "MBean already exists: {0}", ex.getCause().getCause().getMessage());
} else {
// createRoot failed - need to return a null mom so we know not
// to unregister an mbean that does not exist
mom = null;
logger.log(Level.SEVERE, gmbalRegistrationFailed, ex);
}
} catch (Exception e) {
// createRoot failed - need to return a null mom so we know not to unregister an mbean that does not exist
mom = null;
logger.log(Level.SEVERE, gmbalRegistrationFailed, e);
}
return mom;
}
use of org.glassfish.gmbal.ManagedObjectManager in project Payara by payara.
the class StatsProviderManagerDelegateImpl method registerAllGmbal.
public void registerAllGmbal() {
if (logger.isLoggable(Level.FINE))
logger.fine("Registering all the statsProviders whose enabled flag is 'on' with Gmbal");
for (StatsProviderRegistryElement spre : statsProviderRegistry.getSpreList()) {
if (spre.isEnabled()) {
ManagedObjectManager mom = spre.getManagedObjectManager();
if (mom == null) {
mom = registerGmbal(spre.getStatsProvider(), spre.getMBeanName());
spre.setManagedObjectManager(mom);
}
}
}
}
Aggregations