AbstractCommandsController.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:gemfirexd-oss 作者:
/**
 * Gets the MemberMXBean from the JVM Platform MBeanServer for the specified member, identified by name or ID,
 * in the GemFire cluster.
 * <p/>
 * @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 javax.management.JMX
 * @see com.gemstone.gemfire.management.MemberMXBean
 * @see com.gemstone.gemfire.management.internal.ManagementConstants
 */
protected MemberMXBean getMemberMXBean(final String memberNameId) {
  try {
    final MBeanServer connection = getMBeanServer();

    final String objectNamePattern = ManagementConstants.OBJECTNAME__PREFIX.concat("type=Member,*");

    // NOTE possibly throws a MalformedObjectNameException, but this should not happen
    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) was found in the Platform MBeanServer for member (%2$s)!",
        objectName, memberNameId);

    return JMX.newMXBeanProxy(connection, objectNames.iterator().next(), MemberMXBean.class);
  }
  catch (MalformedObjectNameException e) {
    throw new RuntimeException(e);
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号