/** * This is for debugging. It allows the remote server to log the address of clients. * <p> * @return String * @throws IOException */ @Override public synchronized String getLocalHostAddress() throws IOException { if ( localHostName == null ) { try { localHostName = HostNameUtil.getLocalHostAddress(); } catch ( UnknownHostException uhe ) { localHostName = "unknown"; } } return localHostName; }
/** * It's nearly impossible to unit test the getLocalHostLANAddress method. * <p> * @throws UnknownHostException */ public void testGetLocalHostAddress_Simple() throws UnknownHostException { // DO WORK String result = HostNameUtil.getLocalHostAddress(); // VERIFY //System.out.print( result ); assertNotNull( "Should have a host address.", result ); } }
/** * Gets the address for the local machine. * <p> * @return InetAddress.getLocalHost().getHostAddress() * @throws UnknownHostException */ public static String getLocalHostAddress() throws UnknownHostException { try { String hostAddress = getLocalHostLANAddress().getHostAddress(); if ( log.isDebugEnabled() ) { log.debug( "hostAddress = [" + hostAddress + "]" ); } return hostAddress; } catch ( UnknownHostException e1 ) { log.error( "Couldn't get localhost address", e1 ); throw e1; } }
/** * This is for debugging. It allows the remote server to log the address of clients. * <p> * @return String * @throws IOException */ @Override public synchronized String getLocalHostAddress() throws IOException { if ( localHostName == null ) { try { localHostName = HostNameUtil.getLocalHostAddress(); } catch ( UnknownHostException uhe ) { localHostName = "unknown"; } } return localHostName; }
/** * It's nearly impossible to unit test the getLocalHostLANAddress method. * <p> * @throws UnknownHostException */ public void testGetLocalHostAddress_Simple() throws UnknownHostException { // DO WORK String result = HostNameUtil.getLocalHostAddress(); // VERIFY //System.out.print( result ); assertNotNull( "Should have a host address.", result ); } }
/** * Gets the address for the local machine. * <p> * @return InetAddress.getLocalHost().getHostAddress() * @throws UnknownHostException */ public static String getLocalHostAddress() throws UnknownHostException { try { String hostAddress = getLocalHostLANAddress().getHostAddress(); if ( log.isDebugEnabled() ) { log.debug( "hostAddress = [" + hostAddress + "]" ); } return hostAddress; } catch ( UnknownHostException e1 ) { log.error( "Couldn't get localhost address", e1 ); throw e1; } }
registryHost = HostNameUtil.getLocalHostAddress();
@Test public void testLocalHost() throws Exception { final InetAddress byName = InetAddress.getByName("localhost"); assertTrue("Expected localhost (" + byName.getHostAddress() + ") to be a loopback address", byName.isLoopbackAddress()); final InetAddress localHost = HostNameUtil.getLocalHostLANAddress(); assertTrue("Expected getLocalHostLANAddress() (" + localHost + ") to return a site local address", localHost.isSiteLocalAddress()); } }
try registryHost = HostNameUtil.getLocalHostAddress();
@Test public void testLocalHost() throws Exception { final InetAddress byName = InetAddress.getByName("localhost"); assertTrue("Expected localhost (" + byName.getHostAddress() + ") to be a loopback address", byName.isLoopbackAddress()); final InetAddress localHost = HostNameUtil.getLocalHostLANAddress(); assertTrue("Expected getLocalHostLANAddress() (" + localHost + ") to return a site local address", localHost.isSiteLocalAddress()); } }
String registryHost = HostNameUtil.getLocalHostAddress();
String registryHost = HostNameUtil.getLocalHostAddress();
udpDiscoveryAttributes.setServiceAddress( HostNameUtil.getLocalHostAddress() );
/** * @param attributes */ public UDPDiscoveryService( UDPDiscoveryAttributes attributes) { udpDiscoveryAttributes = (UDPDiscoveryAttributes) attributes.clone(); try { // todo, you should be able to set this udpDiscoveryAttributes.setServiceAddress( HostNameUtil.getLocalHostAddress() ); } catch ( UnknownHostException e ) { log.error( "Couldn't get localhost address", e ); } try { // todo need some kind of recovery here. receiver = new UDPDiscoveryReceiver( this, getUdpDiscoveryAttributes().getUdpDiscoveryAddr(), getUdpDiscoveryAttributes().getUdpDiscoveryPort() ); } catch ( IOException e ) { log.error( "Problem creating UDPDiscoveryReceiver, address [" + getUdpDiscoveryAttributes().getUdpDiscoveryAddr() + "] port [" + getUdpDiscoveryAttributes().getUdpDiscoveryPort() + "] we won't be able to find any other caches", e ); } // create a sender thread sender = new UDPDiscoverySenderThread( getUdpDiscoveryAttributes(), getCacheNames() ); }