@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()); }
@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; }
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; }
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; }
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); }
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; }
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); }
@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); }
@Override protected void configure() { bind(Headers.class).asEagerSingleton(); bind(TransportProxyClient.class).asEagerSingleton(); bind(TransportClientNodesService.class).asEagerSingleton(); }
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); }
@Inject public NodeClient(Settings settings, ThreadPool threadPool, Headers headers, Map<GenericAction, TransportAction> actions) { super(settings, threadPool, headers); this.actions = ImmutableMap.copyOf(actions); }
@Override protected void configure() { bind(Headers.class).asEagerSingleton(); bind(Client.class).to(NodeClient.class).asEagerSingleton(); }
Headers headers();