List of usage examples for java.net UnknownHostException printStackTrace
public void printStackTrace()
From source file:com.example.MongoDBContainerDemo.java
@Override protected void init(VaadinRequest request) { this.setContent(tabSheet); try {/*from w ww . j a v a2 s. c o m*/ mongoOperations = new MongoTemplate(new MongoClient(), "scratch"); } catch (UnknownHostException e) { e.printStackTrace(); } // mongoOperations.remove(new Query(), Person.class); // generateRecords(); final AbstractMongoDemo basic = new BasicMongoDemo(mongoOperations).initLayout(); final AbstractMongoDemo buffered = new BufferedMongoDemo(mongoOperations).initLayout(); tabSheet.addTab(basic, "Basic"); tabSheet.addTab(buffered, "Buffered"); tabSheet.setSelectedTab(basic); tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() { @Override public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) { if (tabSheet.getSelectedTab().equals(buffered)) { buffered.mongoContainer.refresh(); buffered.table.refreshRowCache(); } else { basic.mongoContainer.refresh(); basic.table.refreshRowCache(); } } }); }
From source file:com.stratio.decision.configuration.MongoConfiguration.java
@Bean public MongoClient mongoClient() { List<ServerAddress> serverAddresses = new ArrayList(); MongoClient mongoClient = null;// w w w . j ava 2 s.com try { for (String mongoHost : configurationContext.getMongoHosts()) { String[] elements = mongoHost.split(":"); if (elements.length < 2) { //no port serverAddresses.add(new ServerAddress(elements[0])); } else { serverAddresses.add(new ServerAddress(elements[0], Integer.parseInt(elements[1]))); } } if (configurationContext.getMongoUsername() != null && configurationContext.getMongoPassword() != null) { mongoClient = new MongoClient(serverAddresses, Arrays.asList(MongoCredential.createPlainCredential(configurationContext.getMongoUsername(), "$external", configurationContext.getMongoPassword().toCharArray()))); } else { log.warn( "MongoDB user or password are not defined. User: [{}], Password: [{}]. trying anonymous connection.", configurationContext.getMongoUsername(), configurationContext.getMongoPassword()); mongoClient = new MongoClient(serverAddresses); } } catch (UnknownHostException e) { e.printStackTrace(); } log.debug("Creating Spring Bean for mongoclient"); return mongoClient; }
From source file:com.gemstone.gemfire.rest.internal.web.swagger.config.RestApiPathProvider.java
private String getBindAddressForHttpService() { DistributionConfig config = InternalDistributedSystem.getAnyInstance().getConfig(); java.lang.String bindAddress = config.getHttpServiceBindAddress(); if (org.apache.commons.lang.StringUtils.isBlank(bindAddress)) { if (org.apache.commons.lang.StringUtils.isBlank(config.getServerBindAddress())) { if (org.apache.commons.lang.StringUtils.isBlank(config.getBindAddress())) { try { bindAddress = SocketCreator.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { e.printStackTrace(); }//from w w w .j a v a2s . co m } else { bindAddress = config.getBindAddress(); } } else { bindAddress = config.getServerBindAddress(); } } return bindAddress; }
From source file:org.hazelcast.cloudfoundry.servicebroker.service.HazelcastServiceInstanceService.java
@Override public ServiceInstance createServiceInstance(CreateServiceInstanceRequest createServiceInstanceRequest) throws ServiceInstanceExistsException, ServiceBrokerException { String instanceId = createServiceInstanceRequest.getServiceInstanceId(); ServiceInstance serviceInstance = repository.findServiceInstance(instanceId); if (serviceInstance != null) { throw new ServiceInstanceExistsException(serviceInstance); }/*from w w w .j a va 2s .c om*/ serviceInstance = new HazelcastServiceInstance(createServiceInstanceRequest); HazelcastInstance hazelcastInstance = hazelcastAdmin .createHazelcastInstance(createServiceInstanceRequest.getServiceInstanceId()); if (hazelcastInstance == null) { throw new HazelcastServiceException("Failed to create new Hazelcast member hazelcastInstance: " + createServiceInstanceRequest.getServiceInstanceId()); } String hazelcastHost = hazelcastInstance.getCluster().getLocalMember().getAddress().getHost(); ((HazelcastServiceInstance) serviceInstance).setHazelcastIPAddress(hazelcastHost); int hazelcastPort = hazelcastInstance.getCluster().getLocalMember().getAddress().getPort(); ((HazelcastServiceInstance) serviceInstance).setHazelcastPort(hazelcastPort); try { InetAddress hazelcastInetAddress = hazelcastInstance.getCluster().getLocalMember().getAddress() .getInetAddress(); ((HazelcastServiceInstance) serviceInstance).setHazelcastInetAddress(hazelcastInetAddress); } catch (UnknownHostException e) { e.printStackTrace(); } repository.saveServiceInstance(serviceInstance); return serviceInstance; }
From source file:it.isislab.sof.core.engine.hadoop.sshclient.connection.SofManager.java
/** * //w ww.j a v a 2 s .co m * @return a unique filename. If there is execption, it will be return MD5(System.currentTimeMillis) */ public static String getMexID() { InetAddress addr; try { addr = InetAddress.getLocalHost(); Enumeration<NetworkInterface> networks = NetworkInterface.getNetworkInterfaces(); while (networks.hasMoreElements()) { NetworkInterface network = networks.nextElement(); byte[] mac = network.getHardwareAddress(); if (mac != null) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < mac.length; i++) { sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "")); } return DigestUtils.md5Hex(sb.toString() + (System.currentTimeMillis() + "")); } } return DigestUtils.md5Hex(System.currentTimeMillis() + ""); } catch (UnknownHostException e) { e.printStackTrace(); return DigestUtils.md5Hex(System.currentTimeMillis() + ""); } catch (SocketException e) { e.printStackTrace(); return DigestUtils.md5Hex(System.currentTimeMillis() + ""); } }
From source file:it.isislab.sof.core.engine.hadoop.sshclient.connection.SofManager.java
private static String getSimID() { InetAddress addr;//from ww w .j a v a 2s .co m try { addr = InetAddress.getLocalHost(); Enumeration<NetworkInterface> networks = NetworkInterface.getNetworkInterfaces(); while (networks.hasMoreElements()) { NetworkInterface network = networks.nextElement(); byte[] mac = network.getHardwareAddress(); if (mac != null) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < mac.length; i++) { sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "")); } return DigestUtils.md5Hex(sb.toString() + (System.currentTimeMillis() + "")); } } return null; } catch (UnknownHostException e) { e.printStackTrace(); return null; } catch (SocketException e) { e.printStackTrace(); return null; } //return System.currentTimeMillis()+""; }
From source file:ElasticSearchConnection.java
private void setupELK() { try {//from ww w. j a v a2 s. co m client = TransportClient.builder().build().addTransportAddress( new InetSocketTransportAddress(InetAddress.getByName(getHostname()), getPort())); connected = true; } catch (UnknownHostException e) { e.printStackTrace(); } if (isConnected()) { try { setIndex(); } catch (IOException | InterruptedException e) { e.printStackTrace(); } } else { System.out.println("unable to find elasticsearch server on host " + hostname + " on port " + port); } }
From source file:com.amazonaws.services.kinesis.flume.KinesisSource.java
@Override public void configure(Context context) { String endpoint = context.getString("endpoint", ConfigurationConstants.DEFAULT_KINESIS_ENDPOINT); String streamName = Preconditions.checkNotNull(context.getString("streamName"), "streamName is required"); String applicationName = Preconditions.checkNotNull(context.getString("applicationName"), "applicationName is required"); String initialPosition = context.getString("initialPosition", "TRIM_HORIZON"); String workerId = null;//from w ww .java2s . com if (initialPosition.equals("LATEST")) { DEFAULT_INITIAL_POSITION = InitialPositionInStream.LATEST; } String accessKeyId = context.getString("accessKeyId"); String secretAccessKey = context.getString("secretAccessKey"); AWSCredentialsProvider credentialsProvider; if (accessKeyId != null && secretAccessKey != null) { credentialsProvider = new MyAwsCredentials(accessKeyId, secretAccessKey); } else { credentialsProvider = new DefaultAWSCredentialsProviderChain(); } try { workerId = InetAddress.getLocalHost().getCanonicalHostName() + ":" + UUID.randomUUID(); } catch (UnknownHostException e) { e.printStackTrace(); } LOG.info("Using workerId: " + workerId); kinesisClientLibConfiguration = new KinesisClientLibConfiguration(applicationName, streamName, credentialsProvider, workerId).withKinesisEndpoint(endpoint) .withInitialPositionInStream(DEFAULT_INITIAL_POSITION); }
From source file:net.dfs.server.filespace.accessor.impl.WriteSpaceAccessorImpl.java
/** * writeToSPace will write a File object to the newly created local Space. It * makes sure the Space is not null before the File objects are been written to the * Space./*www. ja va 2s .c o m*/ * <p> * It returns no value and throws RemoteException or TransactionException on a failure. * * @param file is an object of the type {@link FileStorageModel} */ public void writeToSpace(FileToken token) { if (space == null) { try { if (space == null) { space = spaceCreator.getSpace(InetAddress.getByName(serverIP), InetAddress.getLocalHost()); } } catch (UnknownHostException e) { e.printStackTrace(); } } try { space.write((FileToken) token, null, Long.MAX_VALUE); log.info("Chunk " + token.fileName + " with Chunk No " + token.CHUNK_NO + " Written to the Space"); } catch (RemoteException e) { e.printStackTrace(); } catch (TransactionException e) { e.printStackTrace(); } }
From source file:org.openihs.seendroid.lib.Query.java
protected Document getXmlDocument(HttpRequestBase request) throws ParserException, UnknownHostException { HttpResponse response;//www. j a v a2 s .c o m try { response = this.connection.query(request); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); return builder.parse(response.getEntity().getContent()); } catch (UnknownHostException e) { throw e; } catch (Exception e) { e.printStackTrace(); throw new Query.ParserException(); } }