List of usage examples for java.net UnknownHostException getMessage
public String getMessage()
From source file:com.mubaloo.proxy.cache.HTTPProxyRequest.java
public HTTPProxyResponse httpGET() { HttpClient client = new DefaultHttpClient(); HttpGet request;/*from w w w . java 2 s . c om*/ try { //can add more logic such time out and so on request = new HttpGet(url); // add request header request.addHeader("User-Agent", USER_AGENT); HttpResponse response = client.execute(request); Logger.d(Mubaloo.TAG.toString(), "\nSending 'GET' request to URL : " + url); Logger.d(Mubaloo.TAG.toString(), "Response Code : " + response.getStatusLine().getStatusCode()); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { buffer.append(line); } return new HTTPProxyResponse(200, buffer.toString()); } catch (UnknownHostException e) { Logger.d(Mubaloo.TAG.toString(), e + "UnknownHostException ", e.getMessage()); } catch (SocketTimeoutException e) { Logger.d(Mubaloo.TAG.toString(), e + "SocketTimeoutException ", e.getMessage()); } catch (SocketException e) { Logger.d(Mubaloo.TAG.toString(), e + "SocketException ", e.getMessage()); } catch (IOException ex) { Logger.d(Mubaloo.TAG.toString(), ex + "IOException ", ex.getMessage()); } return null; }
From source file:io.micrometer.spring.export.prometheus.PrometheusPushGatewayManager.java
private void push() { try {//from w ww .ja v a2 s . c o m this.pushGateway.pushAdd(this.registry, this.job, this.groupingKey); } catch (UnknownHostException ex) { String host = ex.getMessage(); String message = "Unable to locate prometheus push gateway host" + (StringUtils.hasLength(host) ? " '" + host + "'" : "") + ". No longer attempting metrics publication to this host"; logger.error(message, ex); shutdown(ShutdownOperation.NONE); } catch (Throwable ex) { logger.error("Unable to push metrics to Prometheus Pushgateway", ex); } }
From source file:netflow.NetworkDefinition.java
public NetworkDefinition(Integer nid, String network, String netmask) { try {/*from w w w . j a v a2 s . c o m*/ this.networkId = nid; this.networkAddress = InetAddress.getByName(network); this.netmask = InetAddress.getByName(netmask); this.saddress = network; this.snetmask = netmask; } catch (UnknownHostException e) { throw new IllegalArgumentException(e.getMessage()); } }
From source file:netflow.NetworkDefinition.java
public NetworkDefinition(Integer nid, String network, String netmask, String returnAd) { try {//from w w w .java2s .c o m this.networkId = nid; this.networkAddress = InetAddress.getByName(network); this.netmask = InetAddress.getByName(netmask); this.snetmask = netmask; this.saddress = network; this.returnAddress = InetAddress.getByName(returnAd); } catch (UnknownHostException e) { throw new IllegalArgumentException(e.getMessage()); } }
From source file:de.codecentric.boot.admin.config.AdminClientProperties.java
private InetAddress getHostAddress() { try {/*from w w w . java 2 s .c o m*/ return InetAddress.getLocalHost(); } catch (UnknownHostException ex) { throw new IllegalArgumentException(ex.getMessage(), ex); } }
From source file:org.hyperic.plugin.vrealize.automation.DiscoveryVRAManagerServer.java
private Resource getCommonModel(ServerResource server, String vraApplicationEndPointFqdn, String vraManagerDatabaseServerFqdn) { ObjectFactory factory = new ObjectFactory(); Resource vraApplication = factory.createApplicationResource(TYPE_VRA_APPLICATION, vraApplicationEndPointFqdn); vraApplication.addProperty(factory.createProperty(KEY_APPLICATION_NAME, vraApplicationEndPointFqdn)); Resource vraManagerServersGroup = factory.createLogicalResource(TYPE_VRA_MANAGER_SERVER_TAG, vraApplicationEndPointFqdn); Resource vraManagerServer = factory.createResource(!CREATE_IF_NOT_EXIST, server.getType(), server.getName(), ResourceTier.SERVER);/*w w w . ja va2 s .c om*/ Resource vraDatabasesGroup = factory.createLogicalResource(TYPE_VRA_DATABASES_GROUP, vraApplicationEndPointFqdn); vraDatabasesGroup.addRelations(factory.createRelation(vraApplication, RelationType.PARENT)); // If database server resides on this machine then skip it to avoid cyclic reference Resource databaseServerHost = factory.createResource(!CREATE_IF_NOT_EXIST, VraConstants.TYPE_WINDOWS, vraManagerDatabaseServerFqdn, ResourceTier.PLATFORM); databaseServerHost.addRelations(factory.createRelation(vraDatabasesGroup, RelationType.PARENT)); InetAddress addr = null; String hostname = null; try { addr = InetAddress.getLocalHost(); hostname = addr.getCanonicalHostName(); } catch (UnknownHostException e) { log.error(e.getMessage(), e); hostname = getFqdn("localhost"); log.debug(String.format("[getCommonModel] hostname is: '%s'", hostname)); } if (!VRAUtils.areFqdnsEquivalent(hostname, vraManagerDatabaseServerFqdn)) { vraManagerServer.addRelations(factory.createRelation(databaseServerHost, VRAUtils.getDataBaseRalationType(vraManagerDatabaseServerFqdn))); } else { log.debug(String.format("not mapping DB server because '%s' is equivalent to '%s", hostname, vraManagerDatabaseServerFqdn)); } vraManagerServer.addRelations(factory.createRelation(vraManagerServersGroup, RelationType.PARENT)); vraManagerServersGroup.addRelations(factory.createRelation(vraApplication, RelationType.PARENT)); return vraManagerServer; }
From source file:org.jasig.cas.adaptors.generic.remote.RemoteAddressAuthenticationHandler.java
/** * Sets ip network range./*from w ww . ja va 2 s. c om*/ * * @param ipAddressRange the IP address range that should be allowed trusted logins */ @Autowired public void setIpNetworkRange(@Value("${ip.address.range:}") final String ipAddressRange) { if (StringUtils.isNotBlank(ipAddressRange)) { final String[] splitAddress = ipAddressRange.split("/"); if (splitAddress.length == 2) { // A valid ip address/netmask was supplied parse values final String network = splitAddress[0].trim(); final String netmask = splitAddress[1].trim(); try { this.inetNetwork = InetAddress.getByName(network); logger.debug("InetAddress network: {}", this.inetNetwork.toString()); } catch (final UnknownHostException e) { logger.error("The network address was not valid: {}", e.getMessage()); } try { this.inetNetmask = InetAddress.getByName(netmask); logger.debug("InetAddress netmask: {}", this.inetNetmask.toString()); } catch (final UnknownHostException e) { logger.error("The network netmask was not valid: {}", e.getMessage()); } } } }
From source file:org.jasig.cas.adaptors.ldap.remote.RemoteAddressAuthenticationHandler.java
/** * @param ipAddressRange the IP address range that should be allowed trusted logins * *//*from w w w . j a va2 s. c o m*/ public void setIpNetworkRange(final String ipAddressRange) { if (ipAddressRange != null) { final String[] splitAddress = ipAddressRange.split("/"); if (splitAddress.length == 2) { // A valid ip address/netmask was supplied parse values final String network = splitAddress[0].trim(); final String netmask = splitAddress[1].trim(); try { this.inetNetwork = InetAddress.getByName(network); if (log.isDebugEnabled()) { log.debug("InetAddress network: " + this.inetNetwork.toString()); } } catch (final UnknownHostException e) { log.error("The network address was not valid: " + e.getMessage()); } try { this.inetNetmask = InetAddress.getByName(netmask); if (log.isDebugEnabled()) { log.debug("InetAddress netmask: " + this.inetNetmask.toString()); } } catch (final UnknownHostException e) { log.error("The network netmask was not valid: " + e.getMessage()); } } } }
From source file:net.praqma.jenkins.rqm.request.RQMGetRequest.java
@Override public Tuple<Integer, String> executeRequest() throws LoginException, RequestException { Tuple<Integer, String> result = new Tuple<Integer, String>(); try {//from w ww . ja v a 2 s.c o m try { log.finest("ExecuteRequest"); client.login(); } catch (HttpException ex) { log.finest("HttpException: " + ex.getMessage()); throw new LoginException(client.getUsr(), client.getPassword(), ex); } catch (GeneralSecurityException ex) { log.finest("GeneraSecurityException: " + ex.getMessage()); throw new LoginException(client.getUsr(), client.getPassword(), ex); } int response = client.executeMethod(method); BufferedReader reader = new BufferedReader( new InputStreamReader(method.getResponseBodyAsStream(), Charset.forName("utf8"))); StringBuilder builder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { builder.append(line); } reader.close(); result.t1 = response; result.t2 = builder.toString(); } catch (HTTPException ex) { log.severe(ex.getMessage()); result.t1 = ex.getStatusCode(); result.t2 = ex.getMessage() != null ? ex.getMessage() : "No message"; throw new RequestException(result, ex); } catch (UnknownHostException ioex) { throw new RequestException(String.format("Host %s is unreachable", ioex.getMessage()), result); } catch (IOException ioex) { result.t1 = -1; result.t2 = ioex.getMessage() != null ? ioex.getMessage() : "No message"; throw new RequestException(result, ioex); } finally { client.logout(); } return result; }
From source file:ch.aonyx.broker.ib.api.NeoIbApiClient.java
public void connect(final ConnectionParameters connectionParameters, final ConnectionCallback callback) { Validate.notNull(connectionParameters); Validate.notNull(callback);//from w w w .j av a2 s . co m try { socket = new Socket(connectionParameters.getHost(), connectionParameters.getPort()); callback.onSuccess(new SocketSession(socket, connectionParameters.getClientId(), clientCallback)); } catch (final UnknownHostException e) { LOGGER.error("", e); callback.onFailure( new ConnectionException(ClientMessageCode.CONNECTION_ERROR, "Unknown host " + e.getMessage())); } catch (final IOException e) { LOGGER.error("", e); callback.onFailure(new ConnectionException(ClientMessageCode.CONNECTION_FAILURE, e.getMessage())); } }