use of javax.management.MBeanRegistrationException in project uPortal by Jasig.
the class RequestCacheAspect method getCacheStatistics.
protected final CacheStatistics getCacheStatistics(ProceedingJoinPoint pjp, RequestCache requestCache) {
final Signature signature = pjp.getSignature();
final String signatureString = signature.toString();
CacheStatistics cacheStatistics = this.methodStats.get(signatureString);
if (cacheStatistics == null) {
final CacheStatistics newStats = new CacheStatistics();
cacheStatistics = ConcurrentMapUtils.putIfAbsent(this.methodStats, signatureString, newStats);
if (this.mBeanExportOperations != null && cacheStatistics == newStats) {
final String nameString = "uPortal:section=Cache,RequestCache=RequestCache,name=" + EhcacheHibernateMbeanNames.mbeanSafe(signatureString);
try {
final ObjectName name = new ObjectName(nameString);
registerMbean(cacheStatistics, name);
} catch (MalformedObjectNameException e) {
logger.warn("Failed to create ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
} catch (NullPointerException e) {
logger.warn("Failed to create ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
} catch (InstanceAlreadyExistsException e) {
logger.warn("ObjectName {} is already registered, the corresponding CacheStatistics will not be registered with JMX", nameString, e);
} catch (MBeanRegistrationException e) {
logger.warn("Failed to register ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
} catch (NotCompliantMBeanException e) {
logger.warn("Failed to register ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e);
}
}
}
return cacheStatistics;
}
use of javax.management.MBeanRegistrationException in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method unregisterMBean.
public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException {
if (name == null) {
final RuntimeException wrapped = new IllegalArgumentException("Object name cannot be null");
throw new RuntimeOperationsException(wrapped, "Exception occurred trying to unregister the MBean");
}
name = nonDefaultDomain(name);
synchronized (beingUnregistered) {
while (beingUnregistered.contains(name)) {
try {
beingUnregistered.wait();
} catch (InterruptedException e) {
throw new MBeanRegistrationException(e, e.toString());
// pretend the exception came from preDeregister;
// in another execution sequence it could have
}
}
beingUnregistered.add(name);
}
try {
exclusiveUnregisterMBean(name);
} finally {
synchronized (beingUnregistered) {
beingUnregistered.remove(name);
beingUnregistered.notifyAll();
}
}
}
use of javax.management.MBeanRegistrationException in project jdk8u_jdk by JetBrains.
the class ManagementFactoryHelper method addMBean.
/**
* Registers a given MBean if not registered in the MBeanServer;
* otherwise, just return.
*/
private static void addMBean(MBeanServer mbs, Object mbean, String mbeanName) {
try {
final ObjectName objName = Util.newObjectName(mbeanName);
// inner class requires these fields to be final
final MBeanServer mbs0 = mbs;
final Object mbean0 = mbean;
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
public Void run() throws MBeanRegistrationException, NotCompliantMBeanException {
try {
mbs0.registerMBean(mbean0, objName);
return null;
} catch (InstanceAlreadyExistsException e) {
// if an instance with the object name exists in
// the MBeanServer ignore the exception
}
return null;
}
});
} catch (PrivilegedActionException e) {
throw Util.newException(e.getException());
}
}
use of javax.management.MBeanRegistrationException in project cdap by caskdata.
the class OperationalStatsService method shutDown.
@Override
protected void shutDown() throws Exception {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
for (Map.Entry<OperationalExtensionId, OperationalStats> entry : operationalStatsLoader.getAll().entrySet()) {
OperationalStats operationalStats = entry.getValue();
ObjectName objectName = getObjectName(operationalStats);
if (objectName == null) {
LOG.warn("Found an operational extension with null service name and stat type while unregistering - {}. " + "Ignoring this extension.", operationalStats.getClass().getName());
continue;
}
try {
mbs.unregisterMBean(objectName);
} catch (InstanceNotFoundException e) {
LOG.warn("MBean {} not found while un-registering. Ignoring.", objectName);
} catch (MBeanRegistrationException e) {
LOG.warn("Error while un-registering MBean {}.", e);
}
operationalStats.destroy();
}
LOG.info("Successfully shutdown operational stats service.");
}
use of javax.management.MBeanRegistrationException in project ddf by codice.
the class QueryMonitor method registerMbean.
private void registerMbean() {
try {
objectName = new ObjectName(QueryMonitor.class.getName() + ":service=querymonitor");
mBeanServer = ManagementFactory.getPlatformMBeanServer();
} catch (MalformedObjectNameException e) {
LOGGER.info("Unable to create Query Monitor Configuration MBean.", e);
}
if (mBeanServer == null) {
return;
}
try {
try {
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Registered Query Monitor Configuration MBean under object name: {}", objectName.toString());
} catch (InstanceAlreadyExistsException e) {
// Try to remove and re-register
mBeanServer.unregisterMBean(objectName);
mBeanServer.registerMBean(this, objectName);
LOGGER.debug("Re-registered Query Monitor Configuration MBean");
}
} catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
LOGGER.info("Could not register MBean [{}].", objectName.toString(), e);
}
}
Aggregations