/** * Utility method to get the host for the currently running NSS. * If {@link NicUtil} returns a null pointer, it is set to the * value of {@link Config#DEFAULT_HOST}. * * @return The hostname for the running instance. * * @throws SocketException * @throws IOException */ protected static String getHost() throws SocketException, IOException { String hostAddr = NicUtil.getIpAddress("default.nic", "default", true/* loopbackOk */); if (hostAddr == null) { hostAddr = Config.DEFAULT_HOST; } return hostAddr; }
return getIpAddress(nicName, 0, loopbackOk); } else {//system property not set, try default and/or fallback if(defaultNic != null) { if( defaultNic.equals("default") ) { return getDefaultIpv4Address(loopbackOk); } else { return getIpAddress(defaultNic, 0, loopbackOk); if(defaultNic != null) { if( defaultNic.equals("default") ) { return getDefaultIpv4Address(loopbackOk); } else { return getIpAddress(defaultNic, 0, loopbackOk); return getIpAddress(null, loopbackOk);
public static String getIpAddress(String name, int index) { InetAddress inetAddr = getInetAddress(name, index, name, false); if(inetAddr != null) return inetAddr.getHostAddress(); return null; }
try { if(args.length == 0) { ipAddress = getIpAddressByLocalHost(); } else { if( args[0].equals("getIpAddressByLocalHost") ) { ipAddress = getIpAddressByLocalHost(); } else if( args[0].equals("getIpAddress") ) { if(args.length == 2) { String tmpIpAddress = NicUtil.getIpAddress(args[1]); if(tmpIpAddress != null) ipAddress = tmpIpAddress; } else if(args.length == 3) { String tmpIpAddress = NicUtil.getIpAddress(args[1],0,args[2],false); if(tmpIpAddress != null) ipAddress = tmpIpAddress;
NetworkInterface nic = NicUtil.getNetworkInterface(name); byte[] hwAddr = nic.getHardwareAddress(); if( (hwAddr != null) && (hwAddr.length > 0) ) {
public static String getDefaultIpv4Address() throws SocketException, IOException { return getDefaultIpv4Address(false);//localhost NOT ok }
try { if(args.length == 0) { ipAddress = getIpAddressByLocalHost(); } else { if( args[0].equals("getIpAddressByLocalHost") ) { ipAddress = getIpAddressByLocalHost(); } else if( args[0].equals("getIpAddress") ) { if(args.length == 2) { String tmpIpAddress = NicUtil.getIpAddress(args[1]); if(tmpIpAddress != null) ipAddress = tmpIpAddress; } else if(args.length == 3) { String tmpIpAddress = NicUtil.getIpAddress(args[1],0,args[2],false); if(tmpIpAddress != null) ipAddress = tmpIpAddress;
NetworkInterface nic = NicUtil.getNetworkInterface(name); byte[] hwAddr = nic.getHardwareAddress(); if( (hwAddr != null) && (hwAddr.length > 0) ) {
public static String getDefaultIpv4Address() throws SocketException, IOException { return getDefaultIpv4Address(false);//localhost NOT ok }
/** * Utility method to get the host for the currently running NSS. * If {@link NicUtil} returns a null pointer, it is set to the * value of {@link Config#DEFAULT_HOST}. * * @return The hostname for the running instance. * * @throws SocketException * @throws IOException */ protected static String getHost() throws SocketException, IOException { String hostAddr = NicUtil.getIpAddress("default.nic", "default", true/* loopbackOk */); if (hostAddr == null) { hostAddr = Config.DEFAULT_HOST; } return hostAddr; }
return getIpAddress(nicName, 0, loopbackOk); } else {//system property not set, try default and/or fallback if(defaultNic != null) { if( defaultNic.equals("default") ) { return getDefaultIpv4Address(loopbackOk); } else { return getIpAddress(defaultNic, 0, loopbackOk); if(defaultNic != null) { if( defaultNic.equals("default") ) { return getDefaultIpv4Address(loopbackOk); } else { return getIpAddress(defaultNic, 0, loopbackOk); return getIpAddress(null, loopbackOk);
public static String getIpAddress(String name, int index, boolean localHost) { InetAddress inetAddr = getInetAddress(name, index, name, localHost); if(inetAddr != null) return inetAddr.getHostAddress(); return null; }
nic = getNetworkInterface(name); } catch(Exception e) {/* swallow and try fallback */} if(nic != null) {
@Override public void setUp() throws Exception { resourceService = new ManagedResourceService(new InetSocketAddress( InetAddress.getByName(NicUtil.getIpAddress("default.nic", "default", true/* loopbackOk */)), 0/* port */ ), 0/* requestServicePoolSize */) { @Override protected File getResource(UUID uuid) throws Exception { throw new UnsupportedOperationException(); } }; }
public static String getIpAddressByHost(String host, boolean localHost) { InetAddress inetAddr = getInetAddress(null, 0, host, localHost); if(inetAddr != null) return inetAddr.getHostAddress(); return null; }
nic = getNetworkInterface(name); } catch(Exception e) {/* swallow and try fallback */} if(nic != null) {
@Override public void setUp() throws Exception { resourceService = new ManagedResourceService(new InetSocketAddress( InetAddress.getByName(NicUtil.getIpAddress("default.nic", "default", true/* loopbackOk */)), 0/* port */ ), 0/* requestServicePoolSize */) { @Override protected File getResource(UUID uuid) throws Exception { throw new UnsupportedOperationException(); } }; }
public static String getIpAddress(String name, boolean localHost) { InetAddress inetAddr = getInetAddress(name, 0, name, localHost); if(inetAddr != null) return inetAddr.getHostAddress(); return null; }
public AbstractEmbeddedLoadBalancerService(UUID serviceUUID, Properties properties) { super( properties ); // if (serviceUUID == null) // throw new IllegalArgumentException(); // this.serviceUUID = serviceUUID; setServiceUUID(serviceUUID); try { this.hostname = NicUtil.getIpAddress("default.nic", "default", false); } catch(Throwable t) { t.printStackTrace(); } }
public static String getIpAddressByHost(String host) { InetAddress inetAddr = getInetAddress(null, 0, host, false); if(inetAddr != null) return inetAddr.getHostAddress(); return null; }