List of usage examples for java.net UnknownHostException getMessage
public String getMessage()
From source file:com.indeed.imhotep.builder.tsv.KerberosUtils.java
@Nullable private static String getCanonicalHostNameSafe() { try {// w w w. j av a 2 s . c om return InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException e) { log.error("Unable to lookup hostname of machine " + e.getMessage()); return null; } }
From source file:org.squidy.manager.util.CommanderUtils.java
/** * @param host// w w w . ja v a 2 s . c om * @param port * @return */ public static ControlClient getCommanderClient(String host, int port) { InetAddress address = null; try { address = InetAddress.getByName(host); } catch (UnknownHostException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getMessage(), e); } } try { return new ControlClient(address, port); } catch (IOException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getMessage(), e); } return null; } }
From source file:com.axibase.tsd.collector.AtsdUtil.java
public static String resolveHostname() { try {// w w w . jav a2 s . c o m return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { AtsdUtil.logInfo("Could not resolve hostname. " + e.getMessage()); return DEFAULT_ENTITY; } }
From source file:org.encuestame.core.util.InternetUtils.java
/** * Ping hostname./* w ww .j a v a 2 s. c o m*/ * @param domain * @return */ public static boolean hostReachable(final String domain) { InetAddress host; boolean reachable = false; try { // Try to reach the specified address within the timeout // periode. If during this periode the address cannot be // reach then the method returns false. host = InetAddress.getByName(domain); reachable = host.isReachable(InternetUtils.TIMEOUT); } catch (UnknownHostException e) { log.error("hostReachable " + e.getMessage()); } catch (IOException e) { log.error("hostReachable " + e.getMessage()); } return reachable; }
From source file:com.notonthehighstreet.ratel.internal.model.Server.java
public static Server toServer(final String environment) { String hostName;/*from w w w. j a v a 2s . c o m*/ try { hostName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { LOG.log(Level.WARNING, "Unable to work out host name for localhost!", e); hostName = "Unable to work out host name " + e.getMessage(); } return new Server(environment, hostName, ProjectRoot.projectRoot()); }
From source file:org.ofbiz.passport.util.PassportUtil.java
public static String getEnvPrefixByHost(HttpServletRequest request) { String prefix = "test"; try {//from w w w . ja v a 2s. c om InetAddress[] addresses = InetAddress.getAllByName(request.getServerName()); for (InetAddress address : addresses) { if (address.isAnyLocalAddress() || address.isLinkLocalAddress() || address.isLoopbackAddress()) { return prefix; } } prefix = "live"; } catch (UnknownHostException e) { Debug.logError(e.getMessage(), module); } return prefix; }
From source file:org.picketlink.test.integration.federation.saml.util.JBoss7Util.java
/** * Set ${hostname} variable from system property: node0 * * @return Value of hostname/*from w w w . j a v a 2 s .c o m*/ */ public static String getHostname() { String hostname = System.getProperty("node0"); //expand possible IPv6 address try { hostname = NetworkUtils.formatPossibleIpv6Address(InetAddress.getByName(hostname).getHostAddress()); } catch (UnknownHostException ex) { String message = "Cannot resolve host address: " + hostname + " , error : " + ex.getMessage(); throw new RuntimeException(ex); } if ("127.0.0.1".equals(hostname)) { return "localhost"; } return hostname; }
From source file:org.apache.hadoop.hbase.AuthUtil.java
/** * Checks if security is enabled and if so, launches chore for refreshing kerberos ticket. *///from ww w .ja v a 2 s.c o m public static ScheduledChore getAuthChore(Configuration conf) throws IOException { UserProvider userProvider = UserProvider.instantiate(conf); // login the principal (if using secure Hadoop) boolean securityEnabled = userProvider.isHadoopSecurityEnabled() && userProvider.isHBaseSecurityEnabled(); if (!securityEnabled) return null; String host = null; try { host = Strings.domainNamePointerToHostName( DNS.getDefaultHost(conf.get("hbase.client.dns.interface", "default"), conf.get("hbase.client.dns.nameserver", "default"))); userProvider.login("hbase.client.keytab.file", "hbase.client.kerberos.principal", host); } catch (UnknownHostException e) { LOG.error("Error resolving host name: " + e.getMessage(), e); throw e; } catch (IOException e) { LOG.error("Error while trying to perform the initial login: " + e.getMessage(), e); throw e; } final UserGroupInformation ugi = userProvider.getCurrent().getUGI(); Stoppable stoppable = new Stoppable() { private volatile boolean isStopped = false; @Override public void stop(String why) { isStopped = true; } @Override public boolean isStopped() { return isStopped; } }; // if you're in debug mode this is useful to avoid getting spammed by the getTGT() // you can increase this, keeping in mind that the default refresh window is 0.8 // e.g. 5min tgt * 0.8 = 4min refresh so interval is better be way less than 1min final int CHECK_TGT_INTERVAL = 30 * 1000; // 30sec ScheduledChore refreshCredentials = new ScheduledChore("RefreshCredentials", stoppable, CHECK_TGT_INTERVAL) { @Override protected void chore() { try { ugi.checkTGTAndReloginFromKeytab(); } catch (IOException e) { LOG.error("Got exception while trying to refresh credentials: " + e.getMessage(), e); } } }; return refreshCredentials; }
From source file:com.stacksync.desktop.Stacksync.java
private static boolean isAlreadyRunning() { try {/*from ww w . ja v a2 s .c om*/ Socket clientSocket = new Socket("localhost", Constants.COMMANDSERVER_PORT); clientSocket.close(); return true; } catch (UnknownHostException ex) { System.out.println("Error not found localhost. Exception: " + ex.getMessage()); return false; } catch (IOException ex) { //System.out.println("Error with socket. Exception: " + ex.getMessage()); return false; } }
From source file:net.ftb.util.AppUtils.java
/** * Reads XML from a stream//from w ww . j a v a 2s . co m * @param stream the stream to read the document from * @return The document * @throws IOException, SAXException if an error occurs when reading from the stream */ public static Document getXML(InputStream stream) throws IOException, SAXException { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); try { return docFactory.newDocumentBuilder().parse(stream); } catch (ParserConfigurationException ignored) { Logger.logError(ignored.getMessage(), ignored); } catch (UnknownHostException e) { Logger.logError(e.getMessage(), e); } return null; }