List of usage examples for java.net UnknownHostException toString
public String toString()
From source file:org.alfresco.util.remote.server.socket.HostConfigurableSocketFactory.java
public void setHost(String host) { try {/*from w w w.ja v a 2 s . c o m*/ InetAddress hostAddress = InetAddress.getByName(host); if (!hostAddress.isAnyLocalAddress()) { this.host = hostAddress; } } catch (UnknownHostException e) { throw new RuntimeException(e.toString()); } }
From source file:org.auraframework.integration.test.configuration.JettyTestServletConfig.java
public JettyTestServletConfig() throws Exception { String host;/* w w w. j ava2 s . c o m*/ int port; boolean spawnJetty = Boolean.parseBoolean(System.getProperty("jetty.spawn", "false")); if (spawnJetty) { Server server = AuraJettyServer.getInstance(); Connector connector = server.getConnectors()[0]; port = connector.getPort(); host = connector.getHost(); if (host == null) { try { host = getHost(); } catch (UnknownHostException e) { LOG.log(Level.WARNING, e.toString(), e); host = "localhost"; } } LOG.info(String.format("Starting Jetty on %s:%s", host, port)); server.start(); } else { port = Integer.parseInt(System.getProperty("jetty.port", "9090")); host = System.getProperty("jetty.host"); if (host == null) { try { host = getHost(); } catch (UnknownHostException e) { LOG.log(Level.WARNING, e.toString(), e); host = "localhost"; } } } baseUrl = new URL("http", host, port, "/"); LOG.info("BaseUrl: " + baseUrl); }
From source file:org.apache.hive.hcatalog.templeton.Server.java
/** * Returns canonical host name from which the request is made; used for doAs validation *///from w w w .j av a 2s.co m private static String getRequestingHost(String requestingUser, HttpServletRequest request) { final String unkHost = "???"; if (request == null) { LOG.warn("request is null; cannot determine hostname"); return unkHost; } try { String address = request.getRemoteAddr();//returns IP addr if (address == null) { LOG.warn(MessageFormat.format("Request remote address is NULL for user [{0}]", requestingUser)); return unkHost; } //Inet4Address/Inet6Address String hostName = InetAddress.getByName(address).getCanonicalHostName(); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Resolved remote hostname: [{0}]", hostName)); } return hostName; } catch (UnknownHostException ex) { LOG.warn(MessageFormat.format("Request remote address could not be resolved, {0}", ex.toString(), ex)); return unkHost; } }
From source file:net.vivekiyer.GAL.ConnectionChecker.java
@Override protected Boolean doInBackground(ActiveSyncManager... params) { try {//from www .j a va 2 s.c o m ActiveSyncManager syncMgr = params[0]; // Let's try to connect to the server statusCode = syncMgr.getExchangeServerVersion(); requestStatus = syncMgr.getRequestStatus(); return ((statusCode == 200) && ((requestStatus == Parser.STATUS_NOT_SET) || (requestStatus == Parser.STATUS_OK))); } catch (javax.net.ssl.SSLPeerUnverifiedException spue) { statusCode = SSL_PEER_UNVERIFIED; errorString = spue.toString(); Debug.Log(errorString); } catch (UnknownHostException e) { statusCode = UNKNOWN_HOST; errorString = e.toString(); Debug.Log(errorString); } catch (ConnectTimeoutException e) { statusCode = TIMEOUT; errorString = e.toString(); Debug.Log(errorString); } catch (SocketTimeoutException e) { statusCode = TIMEOUT; errorString = e.toString(); Debug.Log(errorString); } catch (Exception e) { statusCode = UNDEFINED; errorString = e.toString(); Debug.Log(errorString); } return false; }
From source file:com.dropbox.presto.kafka.KafkaSplit.java
@JsonCreator public KafkaSplit(@JsonProperty("clientId") String clientId, @JsonProperty("topicName") String topicName, @JsonProperty("partitionId") int partitionId, @JsonProperty("brokerHost") String brokerHost, @JsonProperty("brokerPort") int brokerPort, @JsonProperty("sampleRate") int sampleRate, @JsonProperty("startTs") long startTs, @JsonProperty("endTs") long endTs, @JsonProperty("zookeeper") String zookeeper, @JsonProperty("zkSessionTimeout") int zkSessionTimeout, @JsonProperty("zkConnectTimeout") int zkConnectTimeout) { checkNotNull(clientId, "clientId is null"); checkNotNull(topicName, "topicName is null"); checkNotNull(partitionId, "partitionId is null"); checkNotNull(startTs, "startTs is null"); checkNotNull(endTs, "endTs is null"); this.clientId = clientId; this.topicName = topicName; this.partitionId = partitionId; this.brokerHost = brokerHost; this.brokerPort = brokerPort; this.sampleRate = sampleRate; this.startTs = startTs; this.endTs = endTs; this.zookeeper = zookeeper; this.zkSessionTimeout = zkSessionTimeout; this.zkConnectTimeout = zkConnectTimeout; try {/*from w ww . jav a 2 s. c om*/ InetAddress address = InetAddress.getByName(brokerHost); this.address = HostAddress.fromParts(address.getHostAddress(), 8080); } catch (UnknownHostException ex) { throw new RuntimeException(ex.toString()); } }
From source file:org.jshybugger.proxy.DebugService.java
@Override public void onCreate() { Log.d(TAG, "onCreate()"); try {// w ww . ja v a 2s.c om debugServer = new DebugServer(8888); debugServer.addHandler("/jshybugger/.*", new JSHybuggerResourceHandler()); debugSession = new ProxyDebugSession(this); browserInterface = new JSDInterface(); debugSession.setBrowserInterface(browserInterface); debugServer.exportSession(debugSession); LogActivity.addMessage("DebugServer listening on port 8888"); } catch (UnknownHostException e) { LogActivity.addMessage("Starting DebugServer failed: " + e.toString()); Log.d(TAG, "onCreate() failed", e); } catch (InterruptedException e) { LogActivity.addMessage("Starting DebugServer failed: " + e.toString()); Log.d(TAG, "onCreate() failed", e); } }
From source file:org.privatenotes.sync.web.SyncServer.java
/** * @return new revision if successful, -1 if not */// w w w .j a va2 s . com protected int upload(JSONObject data) { int revision = -1; try { JSONObject response = new JSONObject(authConnection.put(getNotesUri(), data.toString())); revision = response.getInt("latest-sync-revision"); } catch (UnknownHostException e) { if (Tomdroid.LOGGING_ENABLED) Log.e(TAG, e.toString()); } catch (JSONException e) { if (Tomdroid.LOGGING_ENABLED) Log.e(TAG, e.toString()); } return revision; }
From source file:de.unidue.inf.is.ezdl.dlservices.library.manager.referencesystems.bibsonomy.BibsonomyUtils.java
/** send DELETE REQUEST */ String sendDeleteRequest(String url) throws Exception { String sresponse;/*from ww w . j a v a 2 s . c o m*/ try { HttpClient httpclient = new DefaultHttpClient(); HttpDelete httpdelete = new HttpDelete(url); // add authorization header httpdelete.addHeader("Authorization", authHeader); HttpResponse response = httpclient.execute(httpdelete); // Check status code if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK || response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { sresponse = ""; } else { HttpEntity entity = response.getEntity(); sresponse = readResponseStream(entity.getContent()); } httpclient.getConnectionManager().shutdown(); } else { HttpEntity entity = response.getEntity(); sresponse = readResponseStream(entity.getContent()); String httpcode = Integer.toString(response.getStatusLine().getStatusCode()); httpclient.getConnectionManager().shutdown(); throw new ReferenceSystemException(httpcode, "Bibsonomy Error", JSONUtils.parseError(sresponse)); } } catch (UnknownHostException e) { throw new ReferenceSystemException("", "Unknow Host Exception", e.toString()); } return sresponse; }
From source file:integration.MongoDbSeedRule.java
@Override public Statement apply(Statement base, FrameworkMethod method, Object target) { final MongoDbSeed annotation = firstNonNull(method.getAnnotation(MongoDbSeed.class), method.getDeclaringClass().getAnnotation(MongoDbSeed.class)); if (annotation != null) { final String databaseName = firstNonNull(emptyToNull(annotation.database()), IntegrationTestsConfig.getMongodbDatabase()); final MongodbSeed mongodbSeed; try {/*from ww w . jav a 2 s . c o m*/ mongodbSeed = new MongodbSeed(databaseName); } catch (UnknownHostException e) { final String msg = "Unable to seed database: "; log.error(msg, e); return new IgnoreStatement(msg + e.toString()); } final ServerHelper graylogController = new ServerHelper(); final String nodeId; try { nodeId = graylogController.getNodeId(); } catch (MalformedURLException | URISyntaxException e) { final String msg = "Unable to determine Graylog node id for seeding: "; log.error(msg, e); return new IgnoreStatement(msg + e.toString()); } if (annotation.locations().length > 0) { for (String location : annotation.locations()) { final URL seedUrl = findFirstInSearchPath(location, method.getDeclaringClass()); if (seedUrl == null) { throw new RuntimeException( "Unable to find seed data " + location + " for " + method.toString()); } try { log.debug("Using seed data from {}", seedUrl); mongodbSeed.loadDataset(seedUrl, nodeId); } catch (IOException | URISyntaxException e) { throw new RuntimeException("Unable to read seed data: ", e); } } } else { final URL seedUrl = findFirstInSearchPath(method.getName(), method.getDeclaringClass()); try { if (seedUrl != null) { log.debug("Using seed data from {}", seedUrl); mongodbSeed.loadDataset(seedUrl, nodeId); } } catch (IOException | URISyntaxException e) { log.debug( "MongoDB seed annotation present, but neither explicit location passed, nor inferenced location available, just cleaning databse. Exception was: ", e); } } } return base; }