use of javax.management.InstanceNotFoundException in project geode by apache.
the class MBeanProcessController method invokeOperationOnTargetMBean.
/**
* Connects to the process and use its MBean to stop it.
*
* @param namePattern the name pattern of the MBean to use for stopping
* @param pidAttribute the name of the MBean attribute with the process id to compare against
* @param methodName the name of the MBean operation to invoke
* @param attributes the names of the MBean attributes to compare with expected values
* @param values the expected values of the specified MBean attributes
*
* @throws ConnectionFailedException if there was a failure to connect to the local JMX connector
* in the process
* @throws IOException if a communication problem occurred when talking to the MBean server
* @throws MBeanInvocationFailedException if failed to invoke stop on the MBean for any reason
*/
private Object invokeOperationOnTargetMBean(final ObjectName namePattern, final String pidAttribute, final String methodName, final String[] attributes, final Object[] values) throws ConnectionFailedException, IOException, MBeanInvocationFailedException {
ObjectName objectName = namePattern;
connect();
try {
final QueryExp constraint = buildQueryExp(pidAttribute, attributes, values);
final Set<ObjectName> mbeanNames = this.server.queryNames(namePattern, constraint);
if (mbeanNames.isEmpty()) {
throw new MBeanInvocationFailedException("Failed to find mbean matching '" + namePattern + "' with attribute '" + pidAttribute + "' of value '" + this.pid + "'");
}
if (mbeanNames.size() > 1) {
throw new MBeanInvocationFailedException("Found more than one mbean matching '" + namePattern + "' with attribute '" + pidAttribute + "' of value '" + this.pid + "'");
}
objectName = mbeanNames.iterator().next();
return invoke(objectName, methodName);
} catch (InstanceNotFoundException e) {
throw new MBeanInvocationFailedException("Failed to invoke " + methodName + " on " + objectName, e);
} catch (MBeanException e) {
throw new MBeanInvocationFailedException("Failed to invoke " + methodName + " on " + objectName, e);
} catch (ReflectionException e) {
throw new MBeanInvocationFailedException("Failed to invoke " + methodName + " on " + objectName, e);
} finally {
disconnect();
}
}
use of javax.management.InstanceNotFoundException in project geode by apache.
the class LocalProcessController method invokeOperationOnTargetMBean.
/**
* Connects to the process and use its MBean to stop it.
*
* @param namePattern the name pattern of the MBean to use for stopping
* @param pidAttribute the name of the MBean attribute with the process id to compare against
* @param methodName the name of the MBean operation to invoke
* @param attributes the names of the MBean attributes to compare with expected values
* @param values the expected values of the specified MBean attributes
*
* @throws ConnectionFailedException if there was a failure to connect to the local JMX connector
* in the process
* @throws IOException if a communication problem occurred when talking to the MBean server
* @throws MBeanInvocationFailedException if failed to invoke stop on the MBean for any reason
* @throws PidUnavailableException if parsing the pid from the RuntimeMXBean name fails
*/
private Object invokeOperationOnTargetMBean(final ObjectName namePattern, final String pidAttribute, final String methodName, final String[] attributes, final Object[] values) throws ConnectionFailedException, IOException, MBeanInvocationFailedException, PidUnavailableException {
ObjectName objectName = namePattern;
connect();
try {
final QueryExp constraint = buildQueryExp(pidAttribute, attributes, values);
final Set<ObjectName> mbeanNames = this.server.queryNames(namePattern, constraint);
if (mbeanNames.isEmpty()) {
throw new MBeanInvocationFailedException("Failed to find mbean matching '" + namePattern + "' with attribute '" + pidAttribute + "' of value '" + this.pid + "'");
}
if (mbeanNames.size() > 1) {
throw new MBeanInvocationFailedException("Found more than one mbean matching '" + namePattern + "' with attribute '" + pidAttribute + "' of value '" + this.pid + "'");
}
objectName = mbeanNames.iterator().next();
return invoke(objectName, methodName);
} catch (InstanceNotFoundException e) {
throw new MBeanInvocationFailedException("Failed to invoke " + methodName + " on " + objectName, e);
} catch (MBeanException e) {
throw new MBeanInvocationFailedException("Failed to invoke " + methodName + " on " + objectName, e);
} catch (ReflectionException e) {
throw new MBeanInvocationFailedException("Failed to invoke " + methodName + " on " + objectName, e);
} finally {
disconnect();
}
}
use of javax.management.InstanceNotFoundException in project geode by apache.
the class DistributedSystemBridge method addMemberToSystem.
/**
* Add a proxy to the map to be used by bridge.
*
* @param objectName object name of the proxy
* @param proxy actual proxy instance
*/
public void addMemberToSystem(ObjectName objectName, MemberMXBean proxy, FederationComponent newState) {
if (objectName.equals(thisMemberName)) {
ObjectName distrObjectName = MBeanJMXAdapter.getDistributedSystemName();
DistributedSystemMXBean systemMBean = new DistributedSystemMBean(this);
service.registerInternalMBean(systemMBean, distrObjectName);
this.systemLevelNotifEmitter = (DistributedSystemMBean) service.getDistributedSystemMXBean();
this.distListener = new DistributedSystemNotifListener();
}
if (mapOfMembers != null) {
mapOfMembers.put(objectName, proxy);
memberSetSize = mapOfMembers.values().size();
}
updateMember(objectName, newState, null);
try {
mbeanServer.addNotificationListener(objectName, distListener, null, null);
} catch (InstanceNotFoundException e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage());
}
logger.info(LocalizedMessage.create(ManagementStrings.INSTANCE_NOT_FOUND, objectName));
}
}
use of javax.management.InstanceNotFoundException in project geode by apache.
the class ManagementAdapter method handleManagerStart.
/**
* Handles all the distributed mbean creation part when a Manager is started
*/
public void handleManagerStart() throws ManagementException {
if (!isServiceInitialised("handleManagerStart")) {
return;
}
MBeanJMXAdapter jmxAdapter = service.getJMXAdapter();
Map<ObjectName, Object> registeredMBeans = jmxAdapter.getLocalGemFireMBean();
DistributedSystemBridge dsBridge = new DistributedSystemBridge(service);
this.aggregator = new MBeanAggregator(dsBridge);
// register the aggregator for Federation framework to use
service.addProxyListener(aggregator);
/*
* get the local member mbean as it need to be provided to aggregator first
*/
MemberMXBean localMember = service.getMemberMXBean();
ObjectName memberObjectName = MBeanJMXAdapter.getMemberMBeanName(InternalDistributedSystem.getConnectedInstance().getDistributedMember());
FederationComponent addedComp = service.getLocalManager().getFedComponents().get(memberObjectName);
service.afterCreateProxy(memberObjectName, MemberMXBean.class, localMember, addedComp);
for (ObjectName objectName : registeredMBeans.keySet()) {
if (objectName.equals(memberObjectName)) {
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 newObj = service.getLocalManager().getFedComponents().get(objectName);
for (Type intfTyp1 : intfTyps) {
Class intfTyp = (Class) intfTyp1;
service.afterCreateProxy(objectName, intfTyp, object, newObj);
}
} catch (InstanceNotFoundException e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed in Registering distributed mbean ");
}
throw new ManagementException(e);
} catch (ClassNotFoundException e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed in Registering distributed mbean");
}
throw new ManagementException(e);
}
}
}
use of javax.management.InstanceNotFoundException in project geode by apache.
the class MBeanServerWrapper method getAttributes.
@Override
public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException {
AttributeList results = new AttributeList();
for (String attribute : attributes) {
try {
Object value = getAttribute(name, attribute);
Attribute att = new Attribute(attribute, value);
results.add(att);
} catch (Exception e) {
throw new GemFireSecurityException("error getting value of " + attribute + " from " + name, e);
}
}
return results;
}
Aggregations