List of usage examples for java.net InetSocketAddress InetSocketAddress
private InetSocketAddress(int port, String hostname)
From source file:io.github.jhipster.config.metrics.GraphiteRegistry.java
public GraphiteRegistry(MetricRegistry metricRegistry, JHipsterProperties jHipsterProperties) { this.jHipsterProperties = jHipsterProperties; if (this.jHipsterProperties.getMetrics().getGraphite().isEnabled()) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost(); Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort(); String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix(); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix).build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); }// ww w . j a v a 2 s . c om }
From source file:net.firejack.platform.web.cache.MemcachedClientFactory.java
@Override public MemcachedClient makeObject() throws Exception { MemcachedClient client;/*from w w w. j a va 2 s. co m*/ if (StringUtils.isNotBlank(memcachedServerUrl) && port != null) { logger.info("Adding new memcached client to pool."); try { InetSocketAddress inetSocketAddress = new InetSocketAddress(memcachedServerUrl, port); if (inetSocketAddress.isUnresolved()) { client = null; logger.error("Memcached server hostname [" + memcachedServerUrl + "] is unresolved."); } else { List<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>(); addresses.add(inetSocketAddress); client = new MemcachedClient(new OpenFlameMemcachedConnectionFactory(), addresses); } } catch (IOException e) { logger.error("Application failed to obtain connection to memcached server."); throw new OpenFlameRuntimeException(e.getMessage(), e); } } else { logger.warn("Memcached server url or port is not set."); client = null; } return client; }
From source file:com.acmemotors.rest.Main.java
@Bean PoolFactoryBean poolFactoryBean(@Value("${gf.server.port}") int serverPort, @Value("${gf.server.host}") String serverHost) throws Exception { PoolFactoryBean factoryBean = new PoolFactoryBean(); factoryBean.setName("my-pool"); factoryBean.setServers(Collections.singletonList(new InetSocketAddress(serverHost, serverPort))); factoryBean.afterPropertiesSet();//from w w w . j av a 2 s .c o m return factoryBean; }
From source file:jails.http.client.support.ProxyFactoryBean.java
public void afterPropertiesSet() throws IllegalArgumentException { Assert.notNull(type, "'type' must not be null"); Assert.hasLength(hostname, "'hostname' must not be empty"); Assert.isTrue(port >= 0 && port <= 65535, "'port' out of range: " + port); SocketAddress socketAddress = new InetSocketAddress(hostname, port); this.proxy = new Proxy(type, socketAddress); }
From source file:br.com.autonomiccs.autonomic.plugin.common.utils.HostUtils.java
private boolean isHostReachableOnPort(String addr, int openPort, int timeOutMillis) { if (StringUtils.isBlank(addr)) { return false; }//ww w . j a va 2 s.c o m try { try (Socket soc = new Socket()) { soc.connect(new InetSocketAddress(addr, openPort), timeOutMillis); } return true; } catch (IOException ex) { logger.debug( String.format("Error while checking if host[%s] on port [%d] is reacheable", addr, openPort), ex); return false; } }
From source file:com.intuit.tank.rest.BaseRestClient.java
/** * /* w w w. j ava 2 s .c o m*/ * @param serviceUrl */ public BaseRestClient(String serviceUrl, final String proxyServer, final Integer proxyPort) { setBaseUrl(serviceUrl); if (StringUtils.isNotEmpty(proxyServer)) { ConnectorProvider connectorprovider = new HttpUrlConnectorProvider() { private Proxy proxy; private void initializeProxy() { int port = proxyPort != null ? proxyPort : 80; proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyServer, port)); } public HttpURLConnection getHttpURLConnection(URL url) throws IOException { initializeProxy(); return (HttpURLConnection) url.openConnection(proxy); } }; client = ClientBuilder.newBuilder().register(connectorprovider).build(); } else { client = ClientBuilder.newClient(); } // client.setConnectTimeout(5000); // client.setFollowRedirects(true); LOG.info("client for url " + baseUrl + ": proxy=" + (proxyServer != null ? proxyServer + ":" + proxyPort : "none")); }
From source file:com.kurento.kmf.media.MediaPipelineFactory.java
@PostConstruct private void init() { JsonRpcClient client = new JsonRpcClientThrift(clientPool, executorService, new InetSocketAddress(config.getHandlerAddress(), config.getHandlerPort())); factory = new RemoteObjectTypedFactory(new RemoteObjectFactory(new RomClientJsonRpcClient(client))); }
From source file:interactivespaces.service.control.opensoundcontrol.internal.InteractiveSpacesOpenSoundControlClientCommunicationEndpointService.java
@Override public OpenSoundControlClientCommunicationEndpoint newUdpEndpoint(String remoteHost, int remotePort, Log log) { UdpClientNetworkCommunicationEndpointService udpEndpointService = getSpaceEnvironment().getServiceRegistry() .getRequiredService(UdpClientNetworkCommunicationEndpointService.SERVICE_NAME); return new InteractiveSpacesUdpOpenSoundControlClientCommunicationsEndpoint( new InetSocketAddress(remoteHost, remotePort), udpEndpointService.newClient(OpenSoundControlConstants.OPEN_SOUND_CONTROL_BYTE_ORDER, log), log); }
From source file:edu.umass.cs.gigapaxos.PaxosServer.java
protected static Set<InetSocketAddress> getDefaultServers() { Set<InetSocketAddress> servers = new HashSet<InetSocketAddress>(); NodeConfig<String> nodeConfig = PaxosConfig.getDefaultNodeConfig(); for (String id : nodeConfig.getNodeIDs()) servers.add(new InetSocketAddress(nodeConfig.getNodeAddress(id), nodeConfig.getNodePort(id))); return servers; }
From source file:gobblin.tunnel.MockServer.java
public MockServer start() throws IOException { _server = new ServerSocket(); _server.setSoTimeout(5000);/*from ww w . ja va 2 s. co m*/ _server.bind(new InetSocketAddress("localhost", 0)); _serverSocketPort = _server.getLocalPort(); _threads.add(new EasyThread() { @Override void runQuietly() throws Exception { runServer(); } }.startThread()); return this; }