Java 类org.elasticsearch.client.support.Headers 实例源码

项目:Elasticsearch    文件:TransportClientNodesService.java   
@Inject
public TransportClientNodesService(Settings settings, ClusterName clusterName, TransportService transportService,
                                   ThreadPool threadPool, Headers headers, Version version) {
    super(settings);
    this.clusterName = clusterName;
    this.transportService = transportService;
    this.threadPool = threadPool;
    this.minCompatibilityVersion = version.minimumCompatibilityVersion();
    this.headers = headers;

    this.nodesSamplerInterval = this.settings.getAsTime("client.transport.nodes_sampler_interval", timeValueSeconds(5));
    this.pingTimeout = this.settings.getAsTime("client.transport.ping_timeout", timeValueSeconds(5)).millis();
    this.ignoreClusterName = this.settings.getAsBoolean("client.transport.ignore_cluster_name", false);

    if (logger.isDebugEnabled()) {
        logger.debug("node_sampler_interval[" + nodesSamplerInterval + "]");
    }

    if (this.settings.getAsBoolean("client.transport.sniff", false)) {
        this.nodesSampler = new SniffNodesSampler();
    } else {
        this.nodesSampler = new SimpleNodeSampler();
    }
    this.nodesSamplerFuture = threadPool.schedule(nodesSamplerInterval, ThreadPool.Names.GENERIC, new ScheduledNodeSampler());
}
项目:elasticsearch-client-http    文件:HttpClient.java   
@SuppressWarnings({"unchecked", "rawtypes"})
public  HttpClient build() {
    try {
        this.url = settings.get("url") != null ? new URL(settings.get("url")) : url;
        if (url == null) {
            this.host = settings.get("host", "localhost");
            this.port = settings.getAsInt("port", 9200);
        }
        if (url == null && host != null && port != null) {
            url = new URL("http://" + host + ":" + port);
        }
    } catch (MalformedURLException e) {
        throw new IllegalArgumentException("malformed url: " + host + ":" + port);
    }
    if (url == null) {
        throw new IllegalArgumentException("no base URL given");
    }
    ThreadPool threadpool = new ThreadPool("http_client_pool");
    HttpClient client = new HttpClient(settings, threadpool, Headers.EMPTY, url);
    ServiceLoader<HttpAction> httpActionServiceLoader = ServiceLoader.load(HttpAction.class, classLoader);
    for (HttpAction httpAction : httpActionServiceLoader) {
        httpAction.setSettings(settings);
        client.actionMap.put(httpAction.getActionInstance(), httpAction);
    }
    return client;
}
项目:elasticsearch-helper    文件:HttpInvoker.java   
public HttpInvoker(Settings settings, ThreadPool threadPool, Headers headers, URL url) {
    super(settings, threadPool, headers);
    this.contexts = new HashMap<>();
    this.bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(
            Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool()));
    bootstrap.setPipelineFactory(new HttpInvoker.HttpClientPipelineFactory());
    bootstrap.setOption("tcpNoDelay", true);

    registerAction(BulkAction.INSTANCE, HttpBulkAction.class);
    registerAction(CreateIndexAction.INSTANCE, HttpCreateIndexAction.class);
    registerAction(RefreshAction.INSTANCE, HttpRefreshIndexAction.class);
    registerAction(ClusterUpdateSettingsAction.INSTANCE, HttpClusterUpdateSettingsAction.class);
    registerAction(UpdateSettingsAction.INSTANCE, HttpUpdateSettingsAction.class);
    registerAction(SearchAction.INSTANCE, HttpSearchAction.class);

    this.url = url;
}
项目:elasticsearch-helper    文件:HttpElasticsearchClient.java   
public HttpElasticsearchClient build() {
    if (url == null && host != null && port != null) {
        try {
            url = new URL("http://" + host + ":" + port);
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("malformed url: " + host + ":" + port);
        }
    }
    if (url == null) {
        throw new IllegalArgumentException("no base URL given");
    }
    ThreadPool threadpool = new ThreadPool("http_client_pool");
    client = new HttpElasticsearchClient(settings, threadpool, Headers.EMPTY, url);

    client.registerAction(BulkAction.INSTANCE, HttpBulkAction.class);
    client.registerAction(CreateIndexAction.INSTANCE, HttpCreateIndexAction.class);
    client.registerAction(RefreshAction.INSTANCE, HttpRefreshIndexAction.class);
    client.registerAction(ClusterUpdateSettingsAction.INSTANCE, HttpClusterUpdateSettingsAction.class);
    client.registerAction(UpdateSettingsAction.INSTANCE, HttpUpdateSettingsAction.class);
    client.registerAction(SearchAction.INSTANCE, HttpSearchAction.class);

    return client;
}
项目:elasticsearch-client-http    文件:HttpClient.java   
private HttpClient(Settings settings, ThreadPool threadPool, Headers headers, URL url) {
    super(settings, threadPool, headers);
    this.url = url;
    this.actionMap = new HashMap<>();
    this.httpContextMap = new HashMap<>();
    this.bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(
            Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool()));
    bootstrap.setPipelineFactory(new HttpClientPipelineFactory());
    bootstrap.setOption("tcpNoDelay", true);
}
项目:elasticsearch-helper    文件:HttpElasticsearchClient.java   
private HttpElasticsearchClient(Settings settings, ThreadPool threadPool, Headers headers, URL url) {
    super(settings, threadPool, headers);
    this.contextMap = Maps.newHashMap();
    this.bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(
            Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool()));
    bootstrap.setPipelineFactory(new HttpClientPipelineFactory());
    bootstrap.setOption("tcpNoDelay", true);
    this.url = url;
}
项目:elasticsearch-helper    文件:TransportClient.java   
private TransportClient(Injector injector) {
    super(injector.getInstance(Settings.class), injector.getInstance(ThreadPool.class),
            injector.getInstance(Headers.class));
    this.injector = injector;
    this.clusterName = injector.getInstance(ClusterName.class);
    this.transportService = injector.getInstance(TransportService.class);
    this.minCompatibilityVersion = injector.getInstance(Version.class).minimumCompatibilityVersion();
    this.headers = injector.getInstance(Headers.class);
    this.pingTimeout = this.settings.getAsTime("client.transport.ping_timeout", timeValueSeconds(5)).millis();
    this.proxyActionMap = injector.getInstance(ProxyActionMap.class);
}
项目:elasticsearch-helper    文件:ClientBuilder.java   
@SuppressWarnings("unchecked")
public <T> T build(URL url, Class<T> interfaceClass) {
    Settings settings = settingsBuilder.build();
    ThreadPool threadpool = new ThreadPool("http_client_pool");
    Headers headers = Headers.EMPTY;
    final RemoteInvoker remoteInvoker = new HttpInvoker(settings, threadpool, headers, url);
    final InvocationHandler handler =
            new ClientInvocationHandler(remoteInvoker, interfaceClass, settings);
    return (T) Proxy.newProxyInstance(interfaceClass.getClassLoader(),
            new Class[]{ interfaceClass }, handler);
}
项目:Elasticsearch    文件:ClientTransportModule.java   
@Override
protected void configure() {
    bind(Headers.class).asEagerSingleton();
    bind(TransportProxyClient.class).asEagerSingleton();
    bind(TransportClientNodesService.class).asEagerSingleton();
}
项目:Elasticsearch    文件:TransportClient.java   
private TransportClient(Injector injector) {
    super(injector.getInstance(Settings.class), injector.getInstance(ThreadPool.class), injector.getInstance(Headers.class));
    this.injector = injector;
    nodesService = injector.getInstance(TransportClientNodesService.class);
    proxy = injector.getInstance(TransportProxyClient.class);
}
项目:Elasticsearch    文件:NodeClient.java   
@Inject
public NodeClient(Settings settings, ThreadPool threadPool, Headers headers, Map<GenericAction, TransportAction> actions) {
    super(settings, threadPool, headers);
    this.actions = ImmutableMap.copyOf(actions);
}
项目:Elasticsearch    文件:NodeClientModule.java   
@Override
protected void configure() {
    bind(Headers.class).asEagerSingleton();
    bind(Client.class).to(NodeClient.class).asEagerSingleton();
}
项目:Elasticsearch    文件:Client.java   
Headers headers();