@Override public InetAddress[] resolve(String host) throws UnknownHostException { return SystemDefaultDnsResolver.INSTANCE.resolve(host); } }
public PoolingClientConnectionManager( final SchemeRegistry schemeRegistry, final long timeToLive, final TimeUnit tunit) { this(schemeRegistry, timeToLive, tunit, new SystemDefaultDnsResolver()); }
SystemDefaultDnsResolver r = new SystemDefaultDnsResolver(); InetAddress[] resolve = r.resolve("google.com");
public PoolingClientConnectionManager( final SchemeRegistry schemeRegistry, final long timeToLive, final TimeUnit tunit) { this(schemeRegistry, timeToLive, tunit, new SystemDefaultDnsResolver()); }
@Override public InetAddress[] resolve(final String host) throws UnknownHostException { if (host.equalsIgnoreCase("myhost")) { return new InetAddress[]{InetAddress .getByAddress(new byte[]{127, 0, 0, 1})}; } else { return super.resolve(host); } }
public PoolingClientConnectionManager( final SchemeRegistry schemeRegistry, final long timeToLive, final TimeUnit tunit) { this(schemeRegistry, timeToLive, tunit, new SystemDefaultDnsResolver()); }
@Override public InetAddress[] resolve(final String host) throws UnknownHostException { if (host.equalsIgnoreCase("localhost")) { return new InetAddress[]{InetAddress.getByAddress(new byte[]{127, 0, 0, 1})}; } else { return super.resolve(host); } }
public PoolingClientConnectionManager( final SchemeRegistry schemeRegistry, final long timeToLive, final TimeUnit tunit) { this(schemeRegistry, timeToLive, tunit, new SystemDefaultDnsResolver()); }
/** * {@inheritDoc} */ @Override public InetAddress[] resolve(final String host) throws UnknownHostException { InetAddress[] resolvedAddresses = dnsMap.get(host); if (LOG.isInfoEnabled()) { LOG.info("Resolving {} to {}", host, Arrays.deepToString(resolvedAddresses)); } if (resolvedAddresses == null) { resolvedAddresses = super.resolve(host); } return resolvedAddresses; }
public InstrumentedClientConnManager(MetricsRegistry metricsRegistry, SchemeRegistry registry, long connTTL, TimeUnit connTTLTimeUnit) { this(metricsRegistry, registry, connTTL, connTTLTimeUnit, new SystemDefaultDnsResolver()); }
@Override public InetAddress[] resolve(String host) throws UnknownHostException { try { return inMemoryResolver.resolve(host); } catch (UnknownHostException e) { return sysDefaultResolver.resolve(host); } }
/** * Creates a new client connection operator for the given scheme registry. * * @param schemes the scheme registry * * @since 4.2 */ public DefaultClientConnectionOperator(final SchemeRegistry schemes) { Args.notNull(schemes, "Scheme registry"); this.schemeRegistry = schemes; this.dnsResolver = new SystemDefaultDnsResolver(); }
@Override public void configure(IServiceContext serviceCtx, Map<String, String> configuration) throws AsterixException { try { this.serviceCtx = serviceCtx; this.sockets = new ArrayList<>(); String socketsValue = configuration.get(ExternalDataConstants.KEY_SOCKETS); if (socketsValue == null) { throw new IllegalArgumentException( "\'sockets\' parameter not specified as part of adapter configuration"); } String[] socketsArray = socketsValue.split(","); for (String socket : socketsArray) { String[] socketTokens = socket.split(":"); String host = socketTokens[0].trim(); int port = Integer.parseInt(socketTokens[1].trim()); InetAddress[] resolved; resolved = SystemDefaultDnsResolver.INSTANCE.resolve(host); Pair<String, Integer> p = new Pair<>(resolved[0].getHostAddress(), port); sockets.add(p); } } catch (UnknownHostException e) { throw new AsterixException(e); } }
/** * Creates a new client connection operator for the given scheme registry. * * @param schemes the scheme registry * * @since 4.2 */ public DefaultClientConnectionOperator(final SchemeRegistry schemes) { Args.notNull(schemes, "Scheme registry"); this.schemeRegistry = schemes; this.dnsResolver = new SystemDefaultDnsResolver(); }
addresses = systemDefaultDnsResolver.resolve(host); if (log.isDebugEnabled()) { log.debug("Cache miss: {} Thread #{}, resolved with system resolver into {}", host,
/** * Creates a new client connection operator for the given scheme registry. * * @param schemes the scheme registry * * @since 4.2 */ public DefaultClientConnectionOperator(final SchemeRegistry schemes) { Args.notNull(schemes, "Scheme registry"); this.schemeRegistry = schemes; this.dnsResolver = new SystemDefaultDnsResolver(); }
/** * Creates a new client connection operator for the given scheme registry. * * @param schemes the scheme registry * * @since 4.2 */ public DefaultClientConnectionOperator(final SchemeRegistry schemes) { Args.notNull(schemes, "Scheme registry"); this.schemeRegistry = schemes; this.dnsResolver = new SystemDefaultDnsResolver(); }
DnsResolver dnsResolver = new SystemDefaultDnsResolver() { @Override public InetAddress[] resolve(final String host) throws UnknownHostException {
public static void main(String[] args) throws ClientProtocolException, IOException { String s = "http://google.com"; PoolingHttpClientConnectionManager m = new PoolingHttpClientConnectionManager( RegistryBuilder.<ConnectionSocketFactory> create() .register("http", new PlainConnectionSocketFactory() { @Override public Socket connectSocket(int connectTimeout, Socket socket, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context) throws IOException { context.setAttribute("sock-address", remoteAddress); return super.connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, context); } }).build(), new SystemDefaultDnsResolver()); CloseableHttpClient minimal = HttpClients.custom() .setConnectionManager(m).build(); HttpGet get = new HttpGet(s); HttpClientContext context = HttpClientContext.create(); CloseableHttpResponse response = minimal.execute(get, context); InetSocketAddress addr = (InetSocketAddress) context .getAttribute("sock-address"); System.out.println(addr.getAddress().getHostAddress()); }
public DNSCacheManager() { setProperty(new CollectionProperty(SERVERS, new ArrayList<String>())); this.systemDefaultDnsResolver = new SystemDefaultDnsResolver(); this.cache = new LinkedHashMap<>(); //disabling cache lookupCache = new Cache(); lookupCache.setMaxCache(0); lookupCache.setMaxEntries(0); }