protected InetAddress getLocalHost() { try { return InetAddress.getLocalHost(); } catch (UnknownHostException ex) { throw new IllegalArgumentException(ex.getMessage(), ex); } }
public static String getLocalhostNameOrRandomNameIfNotFound() { if (hostName != null) { return hostName; } try { hostName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { hostName = "unknown-host-" + Math.abs(new Random(System.currentTimeMillis()).nextInt()) % 1000; LOG.warn("Unable to resolve hostname: {}. Using: {}", e.getMessage(), hostName); } return hostName; }
/** * @return name of current host */ public static String hostname() { try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { LOG.error("Unable to resolve my host name " + e.getMessage()); throw new RuntimeException(e); } }
/** * @return name of current host */ public static String hostname() { try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { LOG.error("Unable to resolve my host name " + e.getMessage()); throw new RuntimeException(e); } }
private synchronized String createHostName() { String hostName = null; try { InetAddress host = InetAddress.getLocalHost(); hostName = host.getHostName(); } catch(UnknownHostException e) { logger.warn("Unable to obtain client hostname due to the following error:"); logger.warn(e.getMessage()); } return hostName; }
/** * Get the hostname that this worker is run on. Made static and public so that other classes * can use the same method to know what host their worker threads are running on. * @return hostname */ public static String hostname() { try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { LOG.error("Unable to resolve my host name " + e.getMessage()); throw new RuntimeException(e); } } //todo: this doesn;t check if compaction is already running (even though Initiator does but we
/** * Get the hostname that this worker is run on. Made static and public so that other classes * can use the same method to know what host their worker threads are running on. * @return hostname */ public static String hostname() { try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { LOG.error("Unable to resolve my host name " + e.getMessage()); throw new RuntimeException(e); } } //todo: this doesn;t check if compaction is already running (even though Initiator does but we
/** * @param address The address of the service * @return The {@link AbstractServiceEntry} instance */ public AbstractServiceEntry address(String address) { try { this.address = InetAddress.getByName(address); } catch (UnknownHostException e) { throw new HttpClientException(e.getMessage(), e); } return this; }
private static String getLocalHost() { try { return SocketCreator.getLocalHost().toString(); } catch (UnknownHostException e) { return e.getMessage(); } }
/** * Gets the underlying socket address * * @return socket address */ public InetSocketAddress getSocketAddress() { try { return new InetSocketAddress(InetAddress.getByName(host), port); } catch (UnknownHostException e) { throw new MongoSocketException(e.getMessage(), this, e); } }
protected static List<Address> resolveAEntries(String dnsQuery, String srcPort) { List<Address> addresses = new ArrayList<>(); try { InetAddress[] inetAddresses = InetAddress.getAllByName(dnsQuery); for (InetAddress address : inetAddresses) { addresses.add(new IpAddress(address, Integer.parseInt(srcPort))); } } catch (UnknownHostException ex) { log.trace("failed to resolve query %s, ex: %s", dnsQuery, ex.getMessage()); } return addresses; } }
public boolean isInternal(String ip) { try { return isInternal(InetAddress.getByName(ip).getAddress()); } catch (UnknownHostException e) { Logger.error(e.getMessage()); } return false; }
private void ensureNotLoopbackAddresses(Props props, String propertyKey) { stream(requireValue(props, propertyKey).split(",")) .filter(StringUtils::isNotBlank) .map(StringUtils::trim) .map(s -> StringUtils.substringBefore(s, ":")) .forEach(ip -> { try { if (network.isLoopbackInetAddress(network.toInetAddress(ip))) { throw new MessageException(format("Property %s must not be a loopback address: %s", propertyKey, ip)); } } catch (UnknownHostException e) { throw new MessageException(format("Property %s must not a valid address: %s [%s]", propertyKey, ip, e.getMessage())); } }); }
public static Target getTargetByAddress(String address) { try { return getTargetByAddress(InetAddress.getByName(address)); } catch (UnknownHostException e) { Logger.error("cannot convert '" + address + "' to InetAddress: " + e.getMessage()); } return null; }
/** * Resolves local host address so it can be included in event headers. * @throws FlumeException if local host address can not be resolved. */ protected void initializeClientAddress() throws FlumeException { try { clientAddress = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { String errormsg = "Failed to resolve local host address! " + e.getMessage(); LogLog.error(errormsg); if (unsafeMode) { return; } throw new FlumeException(e); } }
private void addDefaultHS2Hosts(Properties props) throws BeelineHS2ConnectionFileParseException { String hiveHost = System.getenv("HIVE_SERVER2_THRIFT_BIND_HOST"); if (hiveHost == null) { hiveHost = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST); } InetAddress serverIPAddress; try { serverIPAddress = ServerUtils.getHostAddress(hiveHost); } catch (UnknownHostException e) { throw new BeelineHS2ConnectionFileParseException(e.getMessage(), e); } int portNum = getPortNum( "http".equalsIgnoreCase(HiveConf.getVar(conf, ConfVars.HIVE_SERVER2_TRANSPORT_MODE))); props.setProperty("hosts", serverIPAddress.getHostName() + ":" + portNum); }
hostToBind = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { logger.warn(e.getMessage(), e);
hostToBind = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { logger.warn(e.getMessage(), e);
private void checkIpAddress() { try { String localhostIp = InetAddress.getByName(LOCAL_HOST).getHostAddress(); Assert.assertEquals(localhostIp, HMSHandler.getThreadLocalIpAddress()); } catch (UnknownHostException e) { Assert.assertTrue("InetAddress.getLocalHost threw an exception: " + e.getMessage(), false); } }
public void onCoreAttached() { if(haveGateway()) return; try { updateGateway(); } catch (UnknownHostException e) { Logger.warning(e.getMessage()); } if(!haveGateway()) return; Target gateway = new Target(getGatewayAddress(), getGatewayHardware()); gateway.setAlias(getSSID()); System.addOrderedTarget(gateway); }