gedi-geode-extensions-core/src/main/java/gedi/solutions/geode/client/GemFireJmxClient.java
public static synchronized Pool getPoolForServer(String serverName, JMX jmx)
	throws InstanceNotFoundException
	{
		Pool pool = PoolManager.find(serverName);
		
		if(pool != null)
			return pool;
		
		PoolFactory poolFactory = PoolManager.createFactory();
		
		//LogWriter logWriter = getClientCache(jmx).getLogger();
		
		try
		{
			//get host name
			//ex: object GemFire:type=Member,member=server_1
			ObjectName objectName = new ObjectName(new StringBuilder("GemFire:type=Member,member=").append(serverName).toString());
			
			String host =  jmx.getAttribute(objectName, "Host");
			
			if(host == null || host.length() == 0)
				throw new IllegalArgumentException("host not found for serverName:"+serverName+" not found");
			
		    host = lookupNetworkHost(host);
		    
		    
				String findJmxPort = new StringBuilder("GemFire:service=CacheServer,port=*,type=Member,member=")
			.append(serverName).toString();
			
			//search ObjectNames
			Set<ObjectName> objectNames = jmx.searchObjectNames(findJmxPort);
			
			if(objectNames == null || objectNames.isEmpty())
				throw new IllegalArgumentException("Unable to to find port with server name:"+serverName);
			
			ObjectName portObjectName  = objectNames.iterator().next();
			Integer port = jmx.getAttribute(portObjectName, "Port");
			
			
			if(port == null)
				throw new IllegalArgumentException("Unable to obtain port for objectName:"+portObjectName+" for server:"+serverName);
			
			System.out.println("Found cache server host"+host+" port:"+port);
			
			poolFactory= poolFactory.addServer(host, port.intValue());
			
			return poolFactory.create(serverName);
		}
		catch(InstanceNotFoundException e)
		{
			throw e;
		}
		catch (Exception e)
		{
			throw new RuntimeException("Unable to create pool for servername:"+serverName+" error:"+e.getMessage(),e);
		}
		
	}
public static synchronized Pool getPoolForServer(String serverName, JMX jmx)
	throws InstanceNotFoundException
	{
		Pool pool = PoolManager.find(serverName);
		
		if(pool != null)
			return pool;
		
		PoolFactory poolFactory = PoolManager.createFactory();
		
		//LogWriter logWriter = getClientCache(jmx).getLogger();
		
		try
		{
			//get host name
			//ex: object GemFire:type=Member,member=server_1
			ObjectName objectName = new ObjectName(new StringBuilder("GemFire:type=Member,member=").append(serverName).toString());
			
			String host =  jmx.getAttribute(objectName, "Host");
			
			if(host == null || host.length() == 0)
				throw new IllegalArgumentException("host not found for serverName:"+serverName+" not found");
			
		    host = lookupNetworkHost(host);
		    
		    
				String findJmxPort = new StringBuilder("GemFire:service=CacheServer,port=*,type=Member,member=")
			.append(serverName).toString();
			
			//search ObjectNames
			Set<ObjectName> objectNames = jmx.searchObjectNames(findJmxPort);
			
			if(objectNames == null || objectNames.isEmpty())
				throw new IllegalArgumentException("Unable to to find port with server name:"+serverName);
			
			ObjectName portObjectName  = objectNames.iterator().next();
			Integer port = jmx.getAttribute(portObjectName, "Port");
			
			
			if(port == null)
				throw new IllegalArgumentException("Unable to obtain port for objectName:"+portObjectName+" for server:"+serverName);
			
			System.out.println("Found cache server host"+host+" port:"+port);
			
			poolFactory= poolFactory.addServer(host, port.intValue());
			
			return poolFactory.create(serverName);
		}
		catch(InstanceNotFoundException e)
		{
			throw e;
		}
		catch (Exception e)
		{
			throw new RuntimeException("Unable to create pool for servername:"+serverName+" error:"+e.getMessage(),e);
		}
		
	}
public static synchronized Pool getPoolForServer ( String serverName , JMX jmx ) throws InstanceNotFoundException { Pool pool = PoolManager . find ( serverName ) ; if ( pool != null ) return pool ; PoolFactory poolFactory = PoolManager . createFactory ( ) ; //LogWriter logWriter = getClientCache(jmx).getLogger(); try { //get host name //ex: object GemFire:type=Member,member=server_1 ObjectName objectName = new ObjectName ( new StringBuilder ( "GemFire:type=Member,member=" ) . append ( serverName ) . toString ( ) ) ; String host = jmx . getAttribute ( objectName , "Host" ) ; if ( host == null || host . length ( ) == 0 ) throw new IllegalArgumentException ( "host not found for serverName:" + serverName + " not found" ) ; host = lookupNetworkHost ( host ) ; String findJmxPort = new StringBuilder ( "GemFire:service=CacheServer,port=*,type=Member,member=" ) . append ( serverName ) . toString ( ) ; //search ObjectNames Set < ObjectName > objectNames = jmx . searchObjectNames ( findJmxPort ) ; if ( objectNames == null || objectNames . isEmpty ( ) ) throw new IllegalArgumentException ( "Unable to to find port with server name:" + serverName ) ; ObjectName portObjectName = objectNames . iterator ( ) . next ( ) ; Integer port = jmx . getAttribute ( portObjectName , "Port" ) ; if ( port == null ) throw new IllegalArgumentException ( "Unable to obtain port for objectName:" + portObjectName + " for server:" + serverName ) ; System . out . println ( "Found cache server host" + host + " port:" + port ) ; poolFactory = poolFactory . addServer ( host , port . intValue ( ) ) ; return poolFactory . create ( serverName ) ; } catch ( InstanceNotFoundException e ) { throw e ; } catch ( Exception e ) { throw new RuntimeException ( "Unable to create pool for servername:" + serverName + " error:" + e . getMessage ( ) , e ) ; } }
Dynamically create a GemFire pool with just the server
@param serverName the server name to create a pool for
@param jmx the JMX connection
@return the pool with the server name and its host/port configured
@throws InstanceNotFoundException when the server name does not exist
Dynamically create a GemFire pool with just the server