public static MemberMXBean getMemberMXBean(final String serviceName, final String member)
      throws IOException {
    assertState(Gfsh.isCurrentInstanceConnectedAndReady(),
        "Gfsh must be connected in order to get proxy to a GemFire Member MBean.");

    MemberMXBean memberBean = null;

    try {
      String objectNamePattern = ManagementConstants.OBJECTNAME__PREFIX;

      objectNamePattern += (isBlank(serviceName)
          ? ""
          : "service=" + serviceName + ",");
      objectNamePattern += "type=Member,*";

      // NOTE throws a MalformedObjectNameException, however, this should not happen since the
      // ObjectName is constructed
      // here in a conforming pattern
      final ObjectName objectName = ObjectName.getInstance(objectNamePattern);

      final QueryExp query = Query.or(Query.eq(Query.attr("Name"), Query.value(member)),
          Query.eq(Query.attr("Id"), Query.value(member)));

      final Set<ObjectName> memberObjectNames =
          Gfsh.getCurrentInstance().getOperationInvoker().queryNames(objectName, query);

      if (!memberObjectNames.isEmpty()) {
        memberBean = Gfsh.getCurrentInstance().getOperationInvoker()
            .getMBeanProxy(memberObjectNames.iterator().next(), MemberMXBean.class);
      }
    } catch (MalformedObjectNameException e) {
      Gfsh.getCurrentInstance().logSevere(e.getMessage(), e);
    }

    return memberBean;
  }
Gets a proxy to the MemberMXBean for the GemFire member specified by member name or ID from the
GemFire Manager's MBeanServer.
<p>

@param member a String indicating the GemFire member's name or ID.
@return a proxy to the MemberMXBean having the specified GemFire member's name or ID from the
        GemFire Manager's MBeanServer, or null if no GemFire member could be found with the
        specified member name or ID.
@see #getMemberMXBean(String, String)
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/MXBeanProvider.java