use of javax.management.InstanceNotFoundException in project aries by apache.
the class IntegrationTestBase method assertRegistered.
protected void assertRegistered(final MBeanServer server, final ObjectName objectName) {
try {
ObjectInstance instance = server.getObjectInstance(objectName);
TestCase.assertNotNull(instance);
TestCase.assertEquals(objectName, instance.getObjectName());
} catch (InstanceNotFoundException nfe) {
TestCase.fail("Expected instance of " + objectName + " registered with MBeanServer");
}
}
use of javax.management.InstanceNotFoundException in project deltaspike by apache.
the class ConfigurationExtension method unRegisterConfigMBean.
public static void unRegisterConfigMBean(String appName) {
if (appName != null && appName.length() > 0) {
try {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName("deltaspike.config." + appName + ":type=DeltaSpikeConfig");
mBeanServer.unregisterMBean(name);
} catch (InstanceNotFoundException infe) {
// all ok, nothing to de-register it seems
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
use of javax.management.InstanceNotFoundException in project geode by apache.
the class ManagementAdapter method handleManagerStop.
/**
* Handles all the clean up activities when a Manager is stopped It clears the distributed mbeans
* and underlying data structures
*/
public void handleManagerStop() throws ManagementException {
if (!isServiceInitialised("handleManagerStop")) {
return;
}
MBeanJMXAdapter jmxAdapter = service.getJMXAdapter();
Map<ObjectName, Object> registeredMBeans = jmxAdapter.getLocalGemFireMBean();
ObjectName aggregatemMBeanPattern;
try {
aggregatemMBeanPattern = new ObjectName(ManagementConstants.AGGREGATE_MBEAN_PATTERN);
} catch (MalformedObjectNameException | NullPointerException e1) {
throw new ManagementException(e1);
}
MemberMXBean localMember = service.getMemberMXBean();
ObjectName memberObjectName = MBeanJMXAdapter.getMemberMBeanName(InternalDistributedSystem.getConnectedInstance().getDistributedMember());
FederationComponent removedComp = service.getLocalManager().getFedComponents().get(memberObjectName);
service.afterRemoveProxy(memberObjectName, MemberMXBean.class, localMember, removedComp);
for (ObjectName objectName : registeredMBeans.keySet()) {
if (objectName.equals(memberObjectName)) {
continue;
}
if (aggregatemMBeanPattern.apply(objectName)) {
continue;
}
Object object = registeredMBeans.get(objectName);
ObjectInstance instance;
try {
instance = mbeanServer.getObjectInstance(objectName);
String className = instance.getClassName();
Class cls = ClassLoadUtil.classFromName(className);
Type[] intfTyps = cls.getGenericInterfaces();
FederationComponent oldObj = service.getLocalManager().getFedComponents().get(objectName);
for (Type intfTyp1 : intfTyps) {
Class intfTyp = (Class) intfTyp1;
service.afterRemoveProxy(objectName, intfTyp, object, oldObj);
}
} catch (InstanceNotFoundException | ClassNotFoundException e) {
logger.warn("Failed to invoke aggregator for {} with exception {}", objectName, e.getMessage(), e);
}
}
service.removeProxyListener(this.aggregator);
this.aggregator = null;
}
use of javax.management.InstanceNotFoundException in project geode by apache.
the class DistributedSystemBridge method removeMemberFromSystem.
/**
* Removed the proxy from the map.
*
* @param objectName name of the proxy to be removed.
* @param proxy actual reference to the proxy object
* @return whether all proxies have been removed or not. In this case it will always be false.
* Kept it for consistency for MBeanAggregator.
*/
public boolean removeMemberFromSystem(ObjectName objectName, MemberMXBean proxy, FederationComponent oldState) {
if (thisMemberName.equals(objectName)) {
ObjectName distrObjectName = MBeanJMXAdapter.getDistributedSystemName();
service.unregisterMBean(distrObjectName);
}
if (mapOfMembers != null) {
mapOfMembers.remove(objectName);
memberSetSize = mapOfMembers.values().size();
if (mapOfMembers.values().size() == 0) {
memberSetSize = 0;
return true;
}
}
updateMember(objectName, null, oldState);
try {
mbeanServer.removeNotificationListener(objectName, distListener);
} catch (ListenerNotFoundException e) {
logger.info(LocalizedMessage.create(ManagementStrings.LISTENER_NOT_FOUND_FOR_0, objectName));
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
} catch (InstanceNotFoundException e) {
logger.info(LocalizedMessage.create(ManagementStrings.INSTANCE_NOT_FOUND, objectName));
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
}
return false;
}
use of javax.management.InstanceNotFoundException in project geode by apache.
the class MBeanProxyFactory method removeAllProxies.
/**
* Removes all proxies for a given member
*
* @param member {@link org.apache.geode.distributed.DistributedMember}
* @param monitoringRegion monitoring region containing the proxies
*/
public void removeAllProxies(DistributedMember member, Region<String, Object> monitoringRegion) {
Set<Entry<String, Object>> entries = monitoringRegion.entrySet();
Iterator<Entry<String, Object>> entriesIt = entries.iterator();
if (logger.isDebugEnabled()) {
logger.debug("Removing {} proxies for member {}", entries.size(), member.getId());
}
while (entriesIt.hasNext()) {
String key = null;
Object val = null;
try {
Entry<String, Object> entry = entriesIt.next();
// MBean Name in String format.
key = entry.getKey();
// Federation Component
val = entry.getValue();
ObjectName mbeanName = ObjectName.getInstance(key);
removeProxy(member, mbeanName, val);
} catch (Exception e) {
if (!(e.getCause() instanceof InstanceNotFoundException)) {
logger.warn("Remove Proxy failed for {} due to {}", key, e.getMessage(), e);
}
continue;
}
}
}
Aggregations