public static Set < String > listHosts ( JMX jmx ) { Set < ObjectName > memberObjects = jmx . searchObjectNames ( "GemFire:type=Member,member=*" ) ; if ( memberObjects == null || memberObjects . isEmpty ( ) ) { return null ; } HashSet < String > hostList = new HashSet < String > ( memberObjects . size ( ) ) ; MemberMXBean bean = null ; for ( ObjectName objectName : memberObjects ) { bean = jmx . newBean ( MemberMXBean . class , objectName ) ; try { hostList . add ( bean . getHost ( ) ) ; } catch ( UndeclaredThrowableException e ) { //will not be added } } return hostList ; }
List the unique set of host name