HostProxyProvider { public HostProxy getHostProxy( ServiceServerNode node ) throws HmsException { if ( node != null ) { HostIdentifier hostIdentifier = new HostIdentifier( node.getNodeID(), node.getIbIpAddress(), node.getOsUserName(), node.getOsPassword() ); synchronized ( this ) { if ( !hostProxyMap.containsKey( hostIdentifier ) ) { if ( !locksMap.containsKey( node.getNodeID() ) ) { locksMap.put( node.getNodeID(), new Object() ); } } } Object lockObj = locksMap.get( node.getNodeID() ); synchronized ( lockObj ) { if ( hostProxyMap.containsKey( hostIdentifier ) ) { HostProxy cachedHostProxy = hostProxyMap.get( hostIdentifier ); if ( isHostProxyValid( cachedHostProxy ) ) { return cachedHostProxy; } } else { removeStaleProxy( hostIdentifier ); } HostProxy hostProxy = createHostProxy( node ); hostProxyMap.put( hostIdentifier, hostProxy ); return hostProxy; } } else { String err = "Cannot get HostProxy for Null Node: " + node; logger.error( err ); throw new HmsException( err ); } } private  HostProxyProvider(); static HostProxyProvider getInstance(); HostProxy getHostProxy( ServiceServerNode node ); void removeHostProxy( HostIdentifier id ); void removeAllHostProxies(); static boolean isHostProxyValid( HostProxy hostProxy ); boolean setHostProxyforNode( ServiceServerNode node, HostProxy hostProxy );  }
@Test public void getHostProxyTest() throws HmsException { ServiceServerNode node = new ServiceServerNode(); node.setNodeID( properties.getProperty( HMS_NODE_ID ) ); node.setIbIpAddress( properties.getProperty( HMS_IB_IP_ADDRESS ) ); node.setOsUserName( properties.getProperty( HMS_IB_USERNAME ) ); node.setOsPassword( properties.getProperty( HMS_IB_PASSWORD ) ); HostProxy hostProxy = HostProxyProvider.getInstance().getHostProxy( node ); assertTrue( hostProxy.getHostSystem() != null ); assertTrue( hostProxy.getHostSystem().getHardware() != null ); assertTrue( hostProxy.getHostSystem().getHardware().getCpuPkg().length > 0 ); }