Java 类org.apache.http.conn.DnsResolver 实例源码

项目:lams    文件:DefaultClientConnectionOperator.java   
/**
* Creates a new client connection operator for the given scheme registry
* and the given custom DNS lookup mechanism.
*
* @param schemes
*            the scheme registry
* @param dnsResolver
*            the custom DNS lookup mechanism
*/
public DefaultClientConnectionOperator(final SchemeRegistry schemes,final DnsResolver dnsResolver) {
    if (schemes == null) {
        throw new IllegalArgumentException(
                 "Scheme registry may not be null");
    }

    if(dnsResolver == null){
        throw new IllegalArgumentException("DNS resolver may not be null");
    }

    this.schemeRegistry = schemes;
    this.dnsResolver = dnsResolver;
}
项目:lams    文件:PoolingClientConnectionManager.java   
public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry,
            final long timeToLive, final TimeUnit tunit,
            final DnsResolver dnsResolver) {
    super();
    if (schemeRegistry == null) {
        throw new IllegalArgumentException("Scheme registry may not be null");
    }
    if (dnsResolver == null) {
        throw new IllegalArgumentException("DNS resolver may not be null");
    }
    this.schemeRegistry = schemeRegistry;
    this.dnsResolver  = dnsResolver;
    this.operator = createConnectionOperator(schemeRegistry);
    this.pool = new HttpConnPool(this.log, 2, 20, timeToLive, tunit);
}
项目:netcrusher-java    文件:HttpClientTest.java   
@Before
public void setUp() throws Exception {
    reactor = new NioReactor();

    crusher = TcpCrusherBuilder.builder()
            .withReactor(reactor)
            .withBindAddress("127.0.0.1", CRUSHER_PORT)
            .withConnectAddress(REMOTE_HOST, REMOTE_PORT)
            .buildAndOpen();

    DnsResolver dnsResolver = new SystemDefaultDnsResolver() {
        @Override
        public InetAddress[] resolve(final String host) throws UnknownHostException {
            if (host.equalsIgnoreCase(REMOTE_HOST)) {
                return new InetAddress[] { InetAddress.getByAddress(new byte[] {127, 0, 0, 1}) };
            } else {
                return super.resolve(host);
            }
        }
    };

    HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> httpConnectionFactory =
            new ManagedHttpClientConnectionFactory();

    Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", PlainConnectionSocketFactory.INSTANCE)
            .build();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(
            socketFactoryRegistry, httpConnectionFactory, dnsResolver);

    http = HttpClients.createMinimal(connectionManager);
}
项目:remote-files-sync    文件:HttpClientConnectionOperator.java   
HttpClientConnectionOperator(
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    Args.notNull(socketFactoryRegistry, "Socket factory registry");
    this.socketFactoryRegistry = socketFactoryRegistry;
    this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
        DefaultSchemePortResolver.INSTANCE;
    this.dnsResolver = dnsResolver != null ? dnsResolver :
        SystemDefaultDnsResolver.INSTANCE;
}
项目:remote-files-sync    文件:BasicHttpClientConnectionManager.java   
public BasicHttpClientConnectionManager(
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
    this.expiry = Long.MAX_VALUE;
    this.socketConfig = SocketConfig.DEFAULT;
    this.connConfig = ConnectionConfig.DEFAULT;
    this.isShutdown = new AtomicBoolean(false);
}
项目:remote-files-sync    文件:PoolingHttpClientConnectionManager.java   
public PoolingHttpClientConnectionManager(
        final Registry<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver,
        final long timeToLive, final TimeUnit tunit) {
    super();
    this.configData = new ConfigData();
    this.pool = new CPool(
            new InternalConnectionFactory(this.configData, connFactory), 2, 20, timeToLive, tunit);
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.isShutDown = new AtomicBoolean(false);
}
项目:remote-files-sync    文件:PoolingHttpClientConnectionManager.java   
PoolingHttpClientConnectionManager(
        final CPool pool,
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    this.configData = new ConfigData();
    this.pool = pool;
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.isShutDown = new AtomicBoolean(false);
}
项目:Bastion    文件:TestWithProxiedEmbeddedServer.java   
@BeforeClass
public static void setupProxying() {
    DnsResolver dnsResolver = prepareProxiedDnsResolver();
    DefaultSchemePortResolver schemePortResolver = prepareSchemePortResolver();
    BasicHttpClientConnectionManager connManager = prepareConnectionManager(dnsResolver, schemePortResolver);
    HttpClient httpClient = prepareHttpClient(connManager);
    originalHttpClient = (HttpClient) Options.getOption(Option.HTTPCLIENT);
    Unirest.setHttpClient(httpClient);
}
项目:Bastion    文件:TestWithProxiedEmbeddedServer.java   
private static BasicHttpClientConnectionManager prepareConnectionManager(DnsResolver dnsResolver, DefaultSchemePortResolver schemePortResolver) {
    return new BasicHttpClientConnectionManager(
            RegistryBuilder.<ConnectionSocketFactory>create()
                    .register("http", PlainConnectionSocketFactory.getSocketFactory())
                    .register("https", SSLConnectionSocketFactory.getSocketFactory())
                    .build(),
            null,
            schemePortResolver,
            dnsResolver
    );
}
项目:Bastion    文件:TestWithProxiedEmbeddedServer.java   
private static DnsResolver prepareProxiedDnsResolver() {
    return new SystemDefaultDnsResolver() {
        @Override
        public InetAddress[] resolve(String host) throws UnknownHostException {
            if (host.equalsIgnoreCase("sushi-shop.test")) {
                return new InetAddress[]{InetAddress.getByName("127.0.0.1")};
            } else {
                return super.resolve(host);
            }
        }
    };
}
项目:cloud-meter    文件:JMeterPoolingClientConnectionManager.java   
public JMeterPoolingClientConnectionManager(final SchemeRegistry schemeRegistry,
            final long timeToLive, final TimeUnit tunit,
            final DnsResolver dnsResolver,
            int validateAfterInactivity) {
    super();
    Args.notNull(schemeRegistry, "Scheme registry");
    Args.notNull(dnsResolver, "DNS resolver");
    this.schemeRegistry = schemeRegistry;
    this.dnsResolver  = dnsResolver;
    this.operator = createConnectionOperator(schemeRegistry);
    this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, tunit);
    pool.setValidateAfterInactivity(validateAfterInactivity);
}
项目:purecloud-iot    文件:PoolingClientConnectionManager.java   
public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry,
            final long timeToLive, final TimeUnit tunit,
            final DnsResolver dnsResolver) {
    super();
    Args.notNull(schemeRegistry, "Scheme registry");
    Args.notNull(dnsResolver, "DNS resolver");
    this.schemeRegistry = schemeRegistry;
    this.dnsResolver  = dnsResolver;
    this.operator = createConnectionOperator(schemeRegistry);
    this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, tunit);
}
项目:purecloud-iot    文件:BasicHttpClientConnectionManager.java   
public BasicHttpClientConnectionManager(
    final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
    final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
    final SchemePortResolver schemePortResolver,
    final DnsResolver dnsResolver) {
  this(
      new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver),
      connFactory
  );
}
项目:purecloud-iot    文件:PoolingHttpClientConnectionManager.java   
public PoolingHttpClientConnectionManager(
        final Registry<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver,
        final long timeToLive, final TimeUnit tunit) {
    this(
        new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver),
        connFactory,
        timeToLive, tunit
    );
}
项目:purecloud-iot    文件:PoolingHttpClientConnectionManager.java   
/**
 * Visible for test.
 */
PoolingHttpClientConnectionManager(
        final CPool pool,
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    this.configData = new ConfigData();
    this.pool = pool;
    this.connectionOperator = new DefaultHttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.isShutDown = new AtomicBoolean(false);
}
项目:purecloud-iot    文件:DefaultHttpClientConnectionOperator.java   
public DefaultHttpClientConnectionOperator(
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    Args.notNull(socketFactoryRegistry, "Socket factory registry");
    this.socketFactoryRegistry = socketFactoryRegistry;
    this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
        DefaultSchemePortResolver.INSTANCE;
    this.dnsResolver = dnsResolver != null ? dnsResolver :
        SystemDefaultDnsResolver.INSTANCE;
}
项目:purecloud-iot    文件:TestHttpClientConnectionOperator.java   
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
    conn = Mockito.mock(ManagedHttpClientConnection.class);
    socket = Mockito.mock(Socket.class);
    plainSocketFactory = Mockito.mock(ConnectionSocketFactory.class);
    sslSocketFactory = Mockito.mock(LayeredConnectionSocketFactory.class);
    socketFactoryRegistry = Mockito.mock(Lookup.class);
    schemePortResolver = Mockito.mock(SchemePortResolver.class);
    dnsResolver = Mockito.mock(DnsResolver.class);
    connectionOperator = new DefaultHttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
}
项目:Visit    文件:HttpClientConnectionOperator.java   
HttpClientConnectionOperator(
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    Args.notNull(socketFactoryRegistry, "Socket factory registry");
    this.socketFactoryRegistry = socketFactoryRegistry;
    this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
        DefaultSchemePortResolver.INSTANCE;
    this.dnsResolver = dnsResolver != null ? dnsResolver :
        SystemDefaultDnsResolver.INSTANCE;
}
项目:Visit    文件:BasicHttpClientConnectionManager.java   
public BasicHttpClientConnectionManager(
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
    this.expiry = Long.MAX_VALUE;
    this.socketConfig = SocketConfig.DEFAULT;
    this.connConfig = ConnectionConfig.DEFAULT;
    this.isShutdown = new AtomicBoolean(false);
}
项目:Visit    文件:PoolingHttpClientConnectionManager.java   
public PoolingHttpClientConnectionManager(
        final Registry<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver,
        final long timeToLive, final TimeUnit tunit) {
    super();
    this.configData = new ConfigData();
    this.pool = new CPool(
            new InternalConnectionFactory(this.configData, connFactory), 2, 20, timeToLive, tunit);
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.isShutDown = new AtomicBoolean(false);
}
项目:Visit    文件:PoolingHttpClientConnectionManager.java   
PoolingHttpClientConnectionManager(
        final CPool pool,
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    this.configData = new ConfigData();
    this.pool = pool;
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.isShutDown = new AtomicBoolean(false);
}
项目:galaxy-fds-sdk-java    文件:GalaxyFDSClient.java   
public GalaxyFDSClient(GalaxyFDSCredential credential,
    FDSClientConfiguration fdsConfig,
    DnsResolver dnsResolver) {
  this.credential = credential;
  this.fdsConfig = fdsConfig;
  this.dnsResolver = dnsResolver;
  init();
}
项目:galaxy-fds-sdk-java    文件:TestHttpClientDNSBlackList.java   
public TestHttpClientDNSBlackList() {

    super(new BasicFDSCredential("AUTH_AK", "AUTH_SK"), defaultFdsConfig,
        new DnsResolver() {
          @Override
          public InetAddress[] resolve(String host) throws UnknownHostException {
            ++dnsResolvedCnt;
            return localIpAddress;
          }
        });

  }
项目:ZTLib    文件:HttpClientConnectionOperator.java   
HttpClientConnectionOperator(
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    Args.notNull(socketFactoryRegistry, "Socket factory registry");
    this.socketFactoryRegistry = socketFactoryRegistry;
    this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
        DefaultSchemePortResolver.INSTANCE;
    this.dnsResolver = dnsResolver != null ? dnsResolver :
        SystemDefaultDnsResolver.INSTANCE;
}
项目:ZTLib    文件:BasicHttpClientConnectionManager.java   
public BasicHttpClientConnectionManager(
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
    this.expiry = Long.MAX_VALUE;
    this.socketConfig = SocketConfig.DEFAULT;
    this.connConfig = ConnectionConfig.DEFAULT;
    this.isShutdown = new AtomicBoolean(false);
}
项目:ZTLib    文件:PoolingHttpClientConnectionManager.java   
public PoolingHttpClientConnectionManager(
        final Registry<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver,
        final long timeToLive, final TimeUnit tunit) {
    super();
    this.configData = new ConfigData();
    this.pool = new CPool(
            new InternalConnectionFactory(this.configData, connFactory), 2, 20, timeToLive, tunit);
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.isShutDown = new AtomicBoolean(false);
}
项目:ZTLib    文件:PoolingHttpClientConnectionManager.java   
PoolingHttpClientConnectionManager(
        final CPool pool,
        final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
        final SchemePortResolver schemePortResolver,
        final DnsResolver dnsResolver) {
    super();
    this.configData = new ConfigData();
    this.pool = pool;
    this.connectionOperator = new HttpClientConnectionOperator(
            socketFactoryRegistry, schemePortResolver, dnsResolver);
    this.isShutDown = new AtomicBoolean(false);
}
项目:lams    文件:PoolingClientConnectionManager.java   
public PoolingClientConnectionManager(final SchemeRegistry schreg,final DnsResolver dnsResolver) {
    this(schreg, -1, TimeUnit.MILLISECONDS,dnsResolver);
}
项目:raven    文件:HttpConnectionAdaptor.java   
private CloseableHttpClient createHttpClient() throws NSPException {
    try {
        initSocketFactory();

        DnsResolver dnsResolver = new SystemDefaultDnsResolver() {
            public InetAddress[] resolve(String host)
                    throws UnknownHostException {
                if (host.equalsIgnoreCase("localhost")) {
                    return new InetAddress[] { InetAddress
                            .getByAddress(new byte[] { 127, 0, 0, 1 }) };
                }

                return super.resolve(host);
            }
        };
        PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(
                this.socketFactoryRegistry, dnsResolver);

        SocketConfig socketConfig = SocketConfig.custom()
                .setTcpNoDelay(true).setSoKeepAlive(true).setSoLinger(0)
                .setSoReuseAddress(true).build();

        connManager.setDefaultSocketConfig(socketConfig);

        ConnectionConfig connectionConfig = ConnectionConfig.custom()
                .setCharset(Consts.UTF_8).build();
        connManager.setDefaultConnectionConfig(connectionConfig);
        connManager.setConnectionConfig(new HttpHost("localhost", 80),
                ConnectionConfig.DEFAULT);

        connManager.setMaxTotal(this.mMaxConnections);

        if ((this.mMaxConnections <= this.mConnectionsPerRoute)
                && (this.mMaxConnections > 0)) {
            this.mConnectionsPerRoute = this.mMaxConnections;
        }

        connManager.setDefaultMaxPerRoute(this.mConnectionsPerRoute);

        connManager.setMaxPerRoute(new HttpRoute(new HttpHost("localhost",
                80)), 100);

        CloseableHttpClient httpclient = HttpClients
                .custom()
                .setConnectionManager(connManager)
                .setDefaultRequestConfig(
                        RequestConfig.copy(defaultRequestConfig).build())
                .build();

        return ((CloseableHttpClient) new WeakReference(httpclient).get());
    } catch (Exception e) {
        throw new NSPException(2, "Service unavailable.", e);
    }
}
项目:ibm-cos-sdk-java    文件:DelegatingDnsResolver.java   
public DelegatingDnsResolver(com.amazonaws.DnsResolver delegate) {
    this.delegate = delegate;
}
项目:BUbiNG    文件:FetchingThread.java   
public BasicHttpClientConnectionManagerWithAlternateDNS(final DnsResolver dnsResolver) {
    super(getDefaultRegistry(), null, null, dnsResolver);
}
项目:weixin-java-tools    文件:ApacheHttpDnsClientBuilder.java   
public DnsResolver getDnsResover() {
  return dnsResover;
}
项目:weixin-java-tools    文件:ApacheHttpDnsClientBuilder.java   
public void setDnsResover(DnsResolver dnsResover) {
  this.dnsResover = dnsResover;
}
项目:remote-files-sync    文件:PoolingHttpClientConnectionManager.java   
public PoolingHttpClientConnectionManager(
        final Registry<ConnectionSocketFactory> socketFactoryRegistry,
        final DnsResolver dnsResolver) {
    this(socketFactoryRegistry, null, dnsResolver);
}
项目:remote-files-sync    文件:PoolingHttpClientConnectionManager.java   
public PoolingHttpClientConnectionManager(
        final Registry<ConnectionSocketFactory> socketFactoryRegistry,
        final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
        final DnsResolver dnsResolver) {
    this(socketFactoryRegistry, connFactory, null, dnsResolver, -1, TimeUnit.MILLISECONDS);
}
项目:cloud-meter    文件:JMeterPoolingClientConnectionManager.java   
public JMeterPoolingClientConnectionManager(final SchemeRegistry schreg,final DnsResolver dnsResolver) {
    this(schreg, -1, TimeUnit.MILLISECONDS,dnsResolver);
}
项目:cloud-meter    文件:JMeterPoolingClientConnectionManager.java   
public JMeterPoolingClientConnectionManager(
        final SchemeRegistry schemeRegistry,
        final long timeToLive, final TimeUnit tunit,
        final DnsResolver dnsResolver) {
    this(schemeRegistry, timeToLive, tunit, dnsResolver, VALIDATE_AFTER_INACTIVITY_DEFAULT);
}
项目:cloud-meter    文件:MeasuringConnectionManager.java   
public MeasuringConnectionManager(SchemeRegistry schemeRegistry, 
        DnsResolver resolver, 
        int timeToLiveMs,
        int validateAfterInactivityMs) {
    super(schemeRegistry, timeToLiveMs, TimeUnit.MILLISECONDS, resolver, validateAfterInactivityMs);
}
项目:purecloud-iot    文件:PoolingClientConnectionManager.java   
public PoolingClientConnectionManager(final SchemeRegistry schreg,final DnsResolver dnsResolver) {
    this(schreg, -1, TimeUnit.MILLISECONDS,dnsResolver);
}
项目:purecloud-iot    文件:PoolingHttpClientConnectionManager.java   
public PoolingHttpClientConnectionManager(
        final Registry<ConnectionSocketFactory> socketFactoryRegistry,
        final DnsResolver dnsResolver) {
    this(socketFactoryRegistry, null, dnsResolver);
}