List of usage examples for java.net UnknownHostException printStackTrace
public void printStackTrace()
From source file:at.ac.tuwien.infosys.Balancer.java
@RequestMapping(value = "/ip", method = RequestMethod.GET) public String getIp() { InetAddress ip;/*from ww w. j a va2s . co m*/ String hostname; try { ip = InetAddress.getLocalHost(); hostname = ip.getHostName(); return "{\"ip\":\"" + ip + "\", \"hostname\":\"" + hostname + "\"}"; } catch (UnknownHostException e) { e.printStackTrace(); return "Error: " + e.getMessage(); } }
From source file:edu.berkeley.sparrow.examples.BBackend.java
private void launchBatching() { try {/* www. ja va 2 s. c o m*/ Socket toClient = new Socket(appClientAdress, appClientPortNumber); batchingPr = new Batching(batchingDelay, toClient, LOG); batchingTh = new Thread(batchingPr); batchingTh.start(); } catch (UnknownHostException e) { LOG.error("LaunchBatching - Unknown Host"); e.printStackTrace(); } catch (IOException e) { LOG.error("LaunchBatching - IOException"); e.printStackTrace(); } }
From source file:runtime.starter.MPJYarnWrapper.java
public void run() { try {/* w ww . j a v a2 s .co m*/ clientSock = new Socket(serverName, ioServerPort); } catch (UnknownHostException exp) { System.err.println("Unknown Host Exception, Host not found"); exp.printStackTrace(); } catch (IOException exp) { exp.printStackTrace(); } // Redirecting Output Stream try { System.setOut(new PrintStream(clientSock.getOutputStream(), true)); System.setErr(new PrintStream(clientSock.getOutputStream(), true)); } catch (IOException e) { e.printStackTrace(); } try { c = Class.forName(className); } catch (ClassNotFoundException exp) { exp.printStackTrace(); } try { String[] arvs = new String[3]; if (appArgs != null) { arvs = new String[3 + appArgs.length]; } arvs[0] = rank; arvs[1] = portInfo; arvs[2] = deviceName; if (appArgs != null) { for (int i = 0; i < appArgs.length; i++) { arvs[3 + i] = appArgs[i]; } } InetAddress localaddr = InetAddress.getLocalHost(); String hostName = localaddr.getHostName(); System.out.println("Starting process <" + rank + "> on <" + hostName + ">"); Method m = c.getMethod("main", new Class[] { arvs.getClass() }); m.setAccessible(true); int mods = m.getModifiers(); if (m.getReturnType() != void.class || !Modifier.isStatic(mods) || !Modifier.isPublic(mods)) { throw new NoSuchMethodException("main"); } m.invoke(null, new Object[] { arvs }); System.out.println("Stopping process <" + rank + "> on <" + hostName + ">"); System.out.println("EXIT");//Stopping IOThread try { clientSock.close(); } catch (IOException e) { e.printStackTrace(); } } catch (Exception ioe) { ioe.printStackTrace(); } }
From source file:com.roncoo.controller.BaseController.java
/** * ?IP?//from www. j av a2 s . co m * * @return */ public String getIpAddr(HttpServletRequest request) { String ipAddress = null; ipAddress = request.getHeader("x-forwarded-for"); if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { ipAddress = request.getHeader("Proxy-Client-IP"); } if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { ipAddress = request.getHeader("WL-Proxy-Client-IP"); } if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { ipAddress = request.getRemoteAddr(); if (ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")) { // ????IP InetAddress inet = null; try { inet = InetAddress.getLocalHost(); } catch (UnknownHostException e) { e.printStackTrace(); } ipAddress = inet.getHostAddress(); } } // ?IPIP,IP',' if (ipAddress != null && ipAddress.length() > 15) { if (ipAddress.indexOf(",") > 0) { ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); } } return ipAddress; }
From source file:org.datacleaner.util.VFSUtilsTest.java
public void test2HttpAccess() throws Exception { // first check if we have a connection try {// w ww . ja v a2s. c om InetAddress.getByName("eobjects.org"); } catch (UnknownHostException e) { System.err.println("Skipping test " + getClass().getSimpleName() + "." + getName() + " since we don't seem to be able to reach eobjects.org"); e.printStackTrace(); return; } FileObject file = VFSUtils.getFileSystemManager().resolveFile("http://eobjects.org"); try (InputStream in = file.getContent().getInputStream()) { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String readLine = reader.readLine(); assertNotNull(readLine); } }
From source file:org.onecmdb.core.internal.update.CheckForUpdate.java
private String getCMDB_ID() { String id = "unkown"; try {/*from ww w . java 2 s . c o m*/ InetAddress localhost = InetAddress.getLocalHost(); id = localhost.getHostAddress(); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ("" + id.hashCode()); }
From source file:org.eobjects.analyzer.util.VFSUtilsTest.java
public void test2HttpAccess() throws Exception { // first check if we have a connection try {/*w ww . ja v a 2s . c o m*/ InetAddress.getByName("eobjects.org"); } catch (UnknownHostException e) { System.err.println("Skipping test " + getClass().getSimpleName() + "." + getName() + " since we don't seem to be able to reach eobjects.org"); e.printStackTrace(); return; } FileObject file = VFSUtils.getFileSystemManager().resolveFile("http://eobjects.org"); InputStream in = file.getContent().getInputStream(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String readLine = reader.readLine(); assertNotNull(readLine); } finally { in.close(); } }
From source file:com.melusyn.sendgrid.SendGridMod.java
@Override public void start() { super.start(); EventBus eb = vertx.eventBus();/*from w w w . j a va2s .c om*/ String address = getOptionalStringConfig("address", "melusyn.sendgrid"); String sendgridUsername = getMandatoryStringConfig("sendgrid_username"); String sendgridPassword = getMandatoryStringConfig("sendgrid_password"); JsonObject suppressionJson = container.config().getObject("suppressions", new JsonObject()); for (String templateId : suppressionJson.getFieldNames()) { templateSuppressionGroup.put(templateId, suppressionJson.getInteger(templateId)); } try { InetAddress ip = InetAddress.getLocalHost(); hostname = ip.getHostName(); } catch (UnknownHostException e) { e.printStackTrace(); } sendgrid = new SendGrid(sendgridUsername, sendgridPassword); eb.registerHandler(address + ".send", this::sendEmail); eb.registerHandler(address + ".sendv2", this::sendEmailV2); }
From source file:edu.umass.cs.nio.nioutils.SampleNodeConfig.java
@SuppressWarnings("unchecked") @Override/*from ww w .j a va 2s . c om*/ public NodeIDType valueOf(String nodeAsString) { NodeIDType node = null; Iterator<NodeIDType> nodeIter = this.nmap.keySet().iterator(); if (nodeIter.hasNext() && (node = nodeIter.next()) != null) { if (node instanceof String && this.nmap.containsKey(nodeAsString)) { return (NodeIDType) nodeAsString; } else if (node instanceof Integer) { return (NodeIDType) (Integer.valueOf(nodeAsString.trim())); } else if (node instanceof InetAddress) { try { return (NodeIDType) (InetAddress.getByName(nodeAsString.trim())); } catch (UnknownHostException e) { e.printStackTrace(); } } } return null; }
From source file:mvm.rya.mongodb.MongoDBRyaDAO.java
public void init() throws RyaDAOException { try {/*from w w w . j a v a 2 s . c o m*/ secondaryIndexers = conf.getAdditionalIndexers(); for (RyaSecondaryIndexer index : secondaryIndexers) { index.setConf(conf); } db = mongoClient.getDB(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME)); coll = db.getCollection(conf.getTriplesCollectionName()); nameSpaceManager = new SimpleMongoDBNamespaceManager( db.getCollection(conf.getNameSpacesCollectionName())); queryEngine = new MongoDBQueryEngine(conf); storageStrategy = new SimpleMongoDBStorageStrategy(); storageStrategy.createIndices(coll); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }