Search in sources :

Example 91 with InstanceNotFoundException

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");
    }
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) ObjectInstance(javax.management.ObjectInstance)

Example 92 with InstanceNotFoundException

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);
        }
    }
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 93 with InstanceNotFoundException

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;
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ObjectInstance(javax.management.ObjectInstance) ObjectName(javax.management.ObjectName) MemberMXBean(org.apache.geode.management.MemberMXBean) ManagementException(org.apache.geode.management.ManagementException) Type(java.lang.reflect.Type) JMXNotificationType(org.apache.geode.management.JMXNotificationType) MBeanJMXAdapter(org.apache.geode.management.internal.MBeanJMXAdapter) FederationComponent(org.apache.geode.management.internal.FederationComponent)

Example 94 with InstanceNotFoundException

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;
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) ListenerNotFoundException(javax.management.ListenerNotFoundException) ObjectName(javax.management.ObjectName)

Example 95 with InstanceNotFoundException

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;
        }
    }
}
Also used : Entry(java.util.Map.Entry) InstanceNotFoundException(javax.management.InstanceNotFoundException) ManagementException(org.apache.geode.management.ManagementException) InstanceNotFoundException(javax.management.InstanceNotFoundException) IntrospectionException(java.beans.IntrospectionException) ObjectName(javax.management.ObjectName)

Aggregations

InstanceNotFoundException (javax.management.InstanceNotFoundException)102 ObjectName (javax.management.ObjectName)59 ReflectionException (javax.management.ReflectionException)44 MBeanException (javax.management.MBeanException)32 MalformedObjectNameException (javax.management.MalformedObjectNameException)28 MBeanRegistrationException (javax.management.MBeanRegistrationException)25 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)19 MBeanServer (javax.management.MBeanServer)17 IOException (java.io.IOException)16 AttributeNotFoundException (javax.management.AttributeNotFoundException)16 Attribute (javax.management.Attribute)15 IntrospectionException (javax.management.IntrospectionException)14 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)14 AttributeList (javax.management.AttributeList)12 ObjectInstance (javax.management.ObjectInstance)12 MBeanInfo (javax.management.MBeanInfo)11 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)10 RuntimeOperationsException (javax.management.RuntimeOperationsException)9 ArrayList (java.util.ArrayList)7 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)7