use of javax.management.JMException in project geode by apache.
the class MBeanUtil method registerServerNotificationListener.
static void registerServerNotificationListener() {
if (mbeanServer == null) {
return;
}
try {
// the MBeanServerDelegate name is spec'ed as the following...
ObjectName delegate = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate");
mbeanServer.addNotificationListener(delegate, new NotificationListener() {
public void handleNotification(Notification notification, Object handback) {
MBeanServerNotification serverNotification = (MBeanServerNotification) notification;
if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(serverNotification.getType())) {
ObjectName objectName = serverNotification.getMBeanName();
synchronized (MBeanUtil.managedResources) {
Object entry = MBeanUtil.managedResources.get(objectName);
if (entry == null)
return;
if (!(entry instanceof ManagedResource)) {
throw new ClassCastException(LocalizedStrings.MBeanUtil_0_IS_NOT_A_MANAGEDRESOURCE.toLocalizedString(new Object[] { entry.getClass().getName() }));
}
ManagedResource resource = (ManagedResource) entry;
{
// call cleanup on managedResource
cleanupResource(resource);
}
}
}
}
}, null, null);
} catch (JMException e) {
logStackTrace(Level.WARN, e, LocalizedStrings.MBeanUtil_FAILED_TO_REGISTER_SERVERNOTIFICATIONLISTENER.toLocalizedString());
} catch (JMRuntimeException e) {
logStackTrace(Level.WARN, e, LocalizedStrings.MBeanUtil_FAILED_TO_REGISTER_SERVERNOTIFICATIONLISTENER.toLocalizedString());
}
}
use of javax.management.JMException in project ignite by apache.
the class GridCacheProcessor method unregisterMbean.
/**
* Unregisters MBean for cache components.
*
* @param o Cache component.
* @param cacheName Cache name.
* @param near Near flag.
*/
private void unregisterMbean(Object o, @Nullable String cacheName, boolean near) {
assert o != null;
MBeanServer srvr = ctx.config().getMBeanServer();
assert srvr != null;
cacheName = U.maskName(cacheName);
cacheName = near ? cacheName + "-near" : cacheName;
boolean needToUnregister = o instanceof IgniteMBeanAware;
if (!needToUnregister) {
for (Class<?> itf : o.getClass().getInterfaces()) {
if (itf.getName().endsWith("MBean") || itf.getName().endsWith("MXBean")) {
needToUnregister = true;
break;
}
}
}
if (needToUnregister) {
try {
srvr.unregisterMBean(U.makeCacheMBeanName(ctx.igniteInstanceName(), cacheName, o.getClass().getName()));
} catch (JMException e) {
U.error(log, "Failed to unregister MBean for component: " + o, e);
}
}
}
use of javax.management.JMException in project ignite by apache.
the class IgniteCacheDatabaseSharedManager method stop0.
/** {@inheritDoc} */
@Override
protected void stop0(boolean cancel) {
if (memPlcMap != null) {
for (MemoryPolicy memPlc : memPlcMap.values()) {
memPlc.pageMemory().stop();
memPlc.evictionTracker().stop();
IgniteConfiguration cfg = cctx.gridConfig();
try {
cfg.getMBeanServer().unregisterMBean(U.makeMBeanName(cfg.getIgniteInstanceName(), "MemoryMetrics", memPlc.memoryMetrics().getName()));
} catch (JMException e) {
U.error(log, "Failed to unregister MBean for memory metrics: " + memPlc.memoryMetrics().getName(), e);
}
}
}
}
use of javax.management.JMException in project ignite by apache.
the class IgniteUtils method jmException.
/**
* Utility method creating {@link JMException} with given cause.
*
* @param e Cause exception.
* @return Newly created {@link JMException}.
*/
public static JMException jmException(Throwable e) {
JMException x = new JMException();
x.initCause(e);
return x;
}
Aggregations