use of javax.management.MalformedObjectNameException in project geode by apache.
the class ConnectionNotificationFilterImpl method stopRMIConnectorServer.
/** Stops the RMIConnectorServer and unregisters its MBean. */
private void stopRMIConnectorServer() {
if (!this.agentConfig.isRmiEnabled())
return;
// stop the RMI Connector server...
try {
this.rmiConnector.stop();
} catch (Exception e) {
logger.warn(e.getMessage(), e);
}
try {
ObjectName rmiRegistryNamingName = getRMIRegistryNamingName();
if (this.agentConfig.isRmiRegistryEnabled() && mBeanServer.isRegistered(rmiRegistryNamingName)) {
String[] empty = new String[0];
mBeanServer.invoke(rmiRegistryNamingName, "stop", empty, empty);
MBeanUtil.unregisterMBean(rmiRegistryNamingName);
}
} catch (MalformedObjectNameException e) {
logger.warn(e.getMessage(), e);
} catch (InstanceNotFoundException e) {
logger.warn(e.getMessage(), e);
} catch (ReflectionException e) {
logger.warn(e.getMessage(), e);
} catch (MBeanException e) {
logger.warn(e.getMessage(), e);
}
try {
ObjectName rmiConnectorServerName = getRMIConnectorServerName();
if (mBeanServer.isRegistered(rmiConnectorServerName)) {
MBeanUtil.unregisterMBean(rmiConnectorServerName);
}
} catch (MalformedObjectNameException e) {
logger.warn(e.getMessage(), e);
}
}
use of javax.management.MalformedObjectNameException in project geode by apache.
the class AbstractCommandsController method getMemberMXBean.
/**
* Gets the MemberMXBean from the JVM Platform MBeanServer for the specified member, identified by
* name or ID in the GemFire cluster.
*
* @param memberNameId a String indicating the name or ID of the GemFire member.
* @return a proxy to the GemFire member's MemberMXBean.
* @throws IllegalStateException if no MemberMXBean could be found for GemFire member with ID or
* name.
* @throws RuntimeException wrapping the MalformedObjectNameException if the ObjectName pattern is
* malformed.
* @see #getMBeanServer()
* @see #isMemberMXBeanFound(java.util.Collection)
* @see javax.management.ObjectName
* @see javax.management.QueryExp
* @see javax.management.MBeanServer#queryNames(javax.management.ObjectName,
* javax.management.QueryExp)
* @see javax.management.JMX#newMXBeanProxy(javax.management.MBeanServerConnection,
* javax.management.ObjectName, Class)
* @see org.apache.geode.management.MemberMXBean
*/
protected MemberMXBean getMemberMXBean(final String memberNameId) {
try {
final MBeanServer connection = getMBeanServer();
final String objectNamePattern = ManagementConstants.OBJECTNAME__PREFIX.concat("type=Member,*");
// NOTE throws a MalformedObjectNameException, but this should not happen since we constructed
// the ObjectName above
final ObjectName objectName = ObjectName.getInstance(objectNamePattern);
final QueryExp query = Query.or(Query.eq(Query.attr("Name"), Query.value(memberNameId)), Query.eq(Query.attr("Id"), Query.value(memberNameId)));
final Set<ObjectName> objectNames = connection.queryNames(objectName, query);
assertState(isMemberMXBeanFound(objectNames), "No MemberMXBean with ObjectName (%1$s) based on Query (%2$s) was found in the Platform MBeanServer for member (%3$s)!", objectName, query, memberNameId);
return JMX.newMXBeanProxy(connection, objectNames.iterator().next(), MemberMXBean.class);
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
}
}
use of javax.management.MalformedObjectNameException in project geode by apache.
the class MBeanJMXAdapter method isAttributeAvailable.
public static boolean isAttributeAvailable(String attributeName, String objectName) {
try {
ObjectName objName = new ObjectName(objectName);
mbeanServer.getAttribute(objName, attributeName);
} catch (MalformedObjectNameException e) {
return false;
} catch (NullPointerException e) {
return false;
} catch (AttributeNotFoundException e) {
return false;
} catch (InstanceNotFoundException e) {
return false;
} catch (MBeanException e) {
return false;
} catch (ReflectionException e) {
return false;
}
return true;
}
use of javax.management.MalformedObjectNameException in project geode by apache.
the class MBeanJMXAdapter method unregisterAll.
/**
* Method to unregister all the local GemFire MBeans
*
*/
public void unregisterAll() {
try {
ObjectName name = new ObjectName(OBJECTNAME__PREFIX + "*");
Set<ObjectName> gemFireObjects = mbeanServer.queryNames(name, null);
for (ObjectName objectName : gemFireObjects) {
unregisterMBean(objectName);
}
} catch (MalformedObjectNameException e) {
throw new ManagementException(e);
} catch (NullPointerException e) {
throw new ManagementException(e);
}
}
use of javax.management.MalformedObjectNameException in project geode by apache.
the class JMXDataUpdater method updateRegionOnMembers.
/**
* Add member specific region information on the region
*
* @param regionObjectName: used to construct the jmx objectname. For region name that has special
* characters in, it will have double quotes around it.
*/
private void updateRegionOnMembers(String regionObjectName, String regionFullPath, Cluster.Region region) throws IOException {
try {
List<String> memberNamesTemp = region.getMemberName();
ArrayList<String> memberNames = new ArrayList<String>(memberNamesTemp);
List<Cluster.RegionOnMember> regionOnMemberList = new ArrayList<Cluster.RegionOnMember>();
List<Cluster.RegionOnMember> regionOnMemberListNew = new ArrayList<Cluster.RegionOnMember>();
Cluster.RegionOnMember[] regionOnMemberNames = region.getRegionOnMembers();
if ((regionOnMemberNames != null) && (regionOnMemberNames.length > 0)) {
regionOnMemberList = new ArrayList<Cluster.RegionOnMember>(Arrays.asList(regionOnMemberNames));
}
logger.debug("updateRegionOnMembers : # regionOnMembers objects in region = {}", regionOnMemberList.size());
for (Cluster.RegionOnMember anRom : regionOnMemberList) {
for (String memberName : memberNames) {
if (anRom.getMemberName().equals(memberName)) {
// Add regionOnMember object in new list
regionOnMemberListNew.add(anRom);
logger.debug("updateRegionOnMembers : Processing existing Member name = {}", anRom.getMemberName());
String objectNameROM = PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_REGION + regionObjectName + PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_MEMBER + anRom.getMemberName();
ObjectName regionOnMemberMBean = new ObjectName(objectNameROM);
logger.debug("updateRegionOnMembers : Object name = {}", regionOnMemberMBean.getCanonicalName());
AttributeList attributeList = this.mbs.getAttributes(regionOnMemberMBean, PulseConstants.REGION_ON_MEMBER_MBEAN_ATTRIBUTES);
for (int i = 0; i < attributeList.size(); i++) {
Attribute attribute = (Attribute) attributeList.get(i);
String name = attribute.getName();
switch(name) {
case PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE:
anRom.setEntrySize(getLongAttribute(attribute.getValue(), attribute.getName()));
logger.debug("updateRegionOnMembers : anRom.getEntrySize() = {}", anRom.getEntrySize());
break;
case PulseConstants.MBEAN_ATTRIBUTE_ENTRYCOUNT:
anRom.setEntryCount(getLongAttribute(attribute.getValue(), attribute.getName()));
logger.debug("updateRegionOnMembers : anRom.getEntryCount() = {}", anRom.getEntryCount());
break;
case PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE:
anRom.setPutsRate(getDoubleAttribute(attribute.getValue(), attribute.getName()));
logger.debug("updateRegionOnMembers : anRom.getPutsRate() = {}", anRom.getPutsRate());
break;
case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE:
anRom.setGetsRate(getDoubleAttribute(attribute.getValue(), attribute.getName()));
logger.debug("updateRegionOnMembers : anRom.getGetsRate() = {}", anRom.getGetsRate());
break;
case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
anRom.setDiskGetsRate(getDoubleAttribute(attribute.getValue(), attribute.getName()));
logger.debug("updateRegionOnMembers : anRom.getDiskGetsRate() = {}", anRom.getDiskGetsRate());
break;
case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
anRom.setDiskPutsRate(getDoubleAttribute(attribute.getValue(), attribute.getName()));
logger.debug("updateRegionOnMembers : anRom.getDiskPutsRate() = {}", anRom.getDiskPutsRate());
break;
case PulseConstants.MBEAN_ATTRIBUTE_LOCALMAXMEMORY:
anRom.setLocalMaxMemory(getIntegerAttribute(attribute.getValue(), attribute.getName()));
logger.debug("updateRegionOnMembers : anRom.getLocalMaxMemory() = {}", anRom.getLocalMaxMemory());
break;
}
}
anRom.getGetsPerSecTrend().add(anRom.getGetsRate());
anRom.getPutsPerSecTrend().add(anRom.getPutsRate());
anRom.getDiskReadsPerSecTrend().add(anRom.getDiskGetsRate());
anRom.getDiskWritesPerSecTrend().add(anRom.getDiskPutsRate());
logger.debug("updateRegionOnMembers : Existing member on region : getGetsRate() = {}, getPutsRate() = {}, getDiskGetsRate() = {}, getDiskPutsRate() = {}", anRom.getGetsPerSecTrend().size(), anRom.getPutsPerSecTrend().size(), anRom.getDiskReadsPerSecTrend().size(), anRom.getDiskWritesPerSecTrend().size());
// remove existing member names from list so only new ones will remain
memberNames.remove(anRom.getMemberName());
break;
}
}
}
logger.debug("updateRegionOnMembers : Loop over remaining member names and adding new member in region. Existing count = {}", regionOnMemberList.size());
logger.debug("updateRegionOnMembers : Remaining new members in this region = {}", memberNames.size());
// loop over the remaining regions members and add new members for this region
for (String memberName : memberNames) {
String objectNameROM = PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_REGION + regionObjectName + PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_MEMBER + memberName;
ObjectName regionOnMemberMBean = new ObjectName(objectNameROM);
Cluster.RegionOnMember regionOnMember = new Cluster.RegionOnMember();
regionOnMember.setMemberName(memberName);
regionOnMember.setRegionFullPath(regionFullPath);
AttributeList attributeList = this.mbs.getAttributes(regionOnMemberMBean, PulseConstants.REGION_ON_MEMBER_MBEAN_ATTRIBUTES);
for (int i = 0; i < attributeList.size(); i++) {
Attribute attribute = (Attribute) attributeList.get(i);
String name = attribute.getName();
switch(name) {
case PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE:
regionOnMember.setEntrySize(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_ENTRYCOUNT:
regionOnMember.setEntryCount(getLongAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE:
regionOnMember.setPutsRate(getDoubleAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE:
regionOnMember.setGetsRate(getDoubleAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
regionOnMember.setDiskGetsRate(getDoubleAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
regionOnMember.setDiskPutsRate(getDoubleAttribute(attribute.getValue(), attribute.getName()));
break;
case PulseConstants.MBEAN_ATTRIBUTE_LOCALMAXMEMORY:
regionOnMember.setLocalMaxMemory(getIntegerAttribute(attribute.getValue(), attribute.getName()));
break;
}
}
regionOnMember.getGetsPerSecTrend().add(regionOnMember.getGetsRate());
regionOnMember.getPutsPerSecTrend().add(regionOnMember.getPutsRate());
regionOnMember.getDiskReadsPerSecTrend().add(regionOnMember.getDiskGetsRate());
regionOnMember.getDiskWritesPerSecTrend().add(regionOnMember.getDiskPutsRate());
logger.debug("updateRegionOnMembers : Adding New member on region : getGetsRate() = {}, getPutsRate() = {}, getDiskGetsRate() = {}, getDiskPutsRate() = {}", regionOnMember.getGetsRate(), regionOnMember.getPutsRate(), regionOnMember.getDiskGetsRate(), regionOnMember.getDiskPutsRate());
regionOnMemberListNew.add(regionOnMember);
}
// set region on member
region.setRegionOnMembers(regionOnMemberListNew);
logger.debug("updateRegionOnMembers : Total regions on member in region after update = {}", region.getFullPath(), region.getRegionOnMembers().length);
} catch (MalformedObjectNameException | InstanceNotFoundException | ReflectionException e) {
logger.warn(e);
}
}
Aggregations