From 865b951b7d5ba0acfa51bae2c12416044642338d Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 29 Jun 2016 15:35:55 -0700 Subject: [PATCH] Internal: Changed rest handler interface to take NodeClient Previously all rest handlers would take Client in their injected ctor. However, it was only to hold the client around for runtime. Instead, this can be done just once in the HttpService which handles rest requests, and passed along through the handleRequest method. It also should always be a NodeClient, and other types of Clients (eg a TransportClient) would not work anyways (and some handlers can be simplified in follow ups like reindex by taking NodeClient). --- .../org/elasticsearch/http/HttpServer.java | 18 +++++--- .../java/org/elasticsearch/node/Node.java | 1 + .../elasticsearch/rest/BaseRestHandler.java | 12 +---- .../elasticsearch/rest/RestController.java | 21 ++++----- .../org/elasticsearch/rest/RestFilter.java | 4 +- .../elasticsearch/rest/RestFilterChain.java | 4 +- .../org/elasticsearch/rest/RestHandler.java | 11 ++++- .../RestClusterAllocationExplainAction.java | 13 +++--- .../health/RestClusterHealthAction.java | 8 ++-- .../hotthreads/RestNodesHotThreadsAction.java | 8 ++-- .../node/info/RestNodesInfoAction.java | 8 ++-- .../node/stats/RestNodesStatsAction.java | 8 ++-- .../node/tasks/RestCancelTasksAction.java | 8 ++-- .../cluster/node/tasks/RestGetTaskAction.java | 8 ++-- .../node/tasks/RestListTasksAction.java | 8 ++-- .../delete/RestDeleteRepositoryAction.java | 8 ++-- .../get/RestGetRepositoriesAction.java | 8 ++-- .../put/RestPutRepositoryAction.java | 8 ++-- .../verify/RestVerifyRepositoryAction.java | 8 ++-- .../reroute/RestClusterRerouteAction.java | 8 ++-- .../RestClusterGetSettingsAction.java | 8 ++-- .../RestClusterUpdateSettingsAction.java | 8 ++-- .../shards/RestClusterSearchShardsAction.java | 8 ++-- .../create/RestCreateSnapshotAction.java | 8 ++-- .../delete/RestDeleteSnapshotAction.java | 8 ++-- .../snapshots/get/RestGetSnapshotsAction.java | 8 ++-- .../restore/RestRestoreSnapshotAction.java | 8 ++-- .../status/RestSnapshotsStatusAction.java | 8 ++-- .../cluster/state/RestClusterStateAction.java | 8 ++-- .../cluster/stats/RestClusterStatsAction.java | 8 ++-- .../RestDeleteStoredScriptAction.java | 12 ++--- .../RestGetStoredScriptAction.java | 12 ++--- .../RestPutStoredScriptAction.java | 12 ++--- .../tasks/RestPendingClusterTasksAction.java | 8 ++-- .../indices/RestRolloverIndexAction.java | 8 ++-- .../admin/indices/RestShrinkIndexAction.java | 8 ++-- .../alias/RestIndicesAliasesAction.java | 8 ++-- .../delete/RestIndexDeleteAliasesAction.java | 8 ++-- .../alias/get/RestGetAliasesAction.java | 8 ++-- .../alias/head/RestAliasesExistAction.java | 8 ++-- .../alias/put/RestIndexPutAliasAction.java | 8 ++-- .../indices/analyze/RestAnalyzeAction.java | 8 ++-- .../clear/RestClearIndicesCacheAction.java | 8 ++-- .../indices/close/RestCloseIndexAction.java | 8 ++-- .../indices/create/RestCreateIndexAction.java | 8 ++-- .../indices/delete/RestDeleteIndexAction.java | 8 ++-- .../indices/RestIndicesExistsAction.java | 8 ++-- .../exists/types/RestTypesExistsAction.java | 8 ++-- .../admin/indices/flush/RestFlushAction.java | 8 ++-- .../indices/flush/RestSyncedFlushAction.java | 8 ++-- .../forcemerge/RestForceMergeAction.java | 8 ++-- .../indices/get/RestGetIndicesAction.java | 8 ++-- .../get/RestGetFieldMappingAction.java | 8 ++-- .../mapping/get/RestGetMappingAction.java | 8 ++-- .../mapping/put/RestPutMappingAction.java | 8 ++-- .../indices/open/RestOpenIndexAction.java | 8 ++-- .../indices/recovery/RestRecoveryAction.java | 8 ++-- .../indices/refresh/RestRefreshAction.java | 8 ++-- .../segments/RestIndicesSegmentsAction.java | 8 ++-- .../settings/RestGetSettingsAction.java | 8 ++-- .../settings/RestUpdateSettingsAction.java | 8 ++-- .../shards/RestIndicesShardStoresAction.java | 8 ++-- .../indices/stats/RestIndicesStatsAction.java | 8 ++-- .../delete/RestDeleteIndexTemplateAction.java | 8 ++-- .../get/RestGetIndexTemplateAction.java | 8 ++-- .../head/RestHeadIndexTemplateAction.java | 8 ++-- .../put/RestPutIndexTemplateAction.java | 8 ++-- .../indices/upgrade/RestUpgradeAction.java | 13 +++--- .../query/RestValidateQueryAction.java | 8 ++-- .../rest/action/bulk/RestBulkAction.java | 8 ++-- .../rest/action/cat/AbstractCatAction.java | 10 ++--- .../rest/action/cat/RestAliasAction.java | 8 ++-- .../rest/action/cat/RestAllocationAction.java | 8 ++-- .../rest/action/cat/RestCatAction.java | 8 ++-- .../rest/action/cat/RestCountAction.java | 8 ++-- .../rest/action/cat/RestFielddataAction.java | 8 ++-- .../rest/action/cat/RestHealthAction.java | 8 ++-- .../rest/action/cat/RestIndicesAction.java | 8 ++-- .../rest/action/cat/RestMasterAction.java | 8 ++-- .../rest/action/cat/RestNodeAttrsAction.java | 8 ++-- .../rest/action/cat/RestNodesAction.java | 8 ++-- .../cat/RestPendingClusterTasksAction.java | 8 ++-- .../rest/action/cat/RestPluginsAction.java | 8 ++-- .../rest/action/cat/RestRecoveryAction.java | 8 ++-- .../action/cat/RestRepositoriesAction.java | 8 ++-- .../rest/action/cat/RestSegmentsAction.java | 8 ++-- .../rest/action/cat/RestShardsAction.java | 8 ++-- .../rest/action/cat/RestSnapshotAction.java | 8 ++-- .../rest/action/cat/RestTasksAction.java | 8 ++-- .../rest/action/cat/RestThreadPoolAction.java | 8 ++-- .../rest/action/count/RestCountAction.java | 8 ++-- .../rest/action/delete/RestDeleteAction.java | 8 ++-- .../action/explain/RestExplainAction.java | 8 ++-- .../fieldstats/RestFieldStatsAction.java | 8 ++-- .../rest/action/get/RestGetAction.java | 8 ++-- .../rest/action/get/RestGetSourceAction.java | 8 ++-- .../rest/action/get/RestHeadAction.java | 17 ++++--- .../rest/action/get/RestMultiGetAction.java | 8 ++-- .../rest/action/index/RestIndexAction.java | 16 +++---- .../ingest/RestDeletePipelineAction.java | 8 ++-- .../action/ingest/RestGetPipelineAction.java | 8 ++-- .../action/ingest/RestPutPipelineAction.java | 8 ++-- .../ingest/RestSimulatePipelineAction.java | 8 ++-- .../rest/action/main/RestMainAction.java | 8 ++-- .../action/search/RestClearScrollAction.java | 8 ++-- .../action/search/RestMultiSearchAction.java | 8 ++-- .../rest/action/search/RestSearchAction.java | 8 ++-- .../action/search/RestSearchScrollAction.java | 8 ++-- .../action/suggest/RestSuggestAction.java | 8 ++-- .../RestMultiTermVectorsAction.java | 8 ++-- .../termvectors/RestTermVectorsAction.java | 8 ++-- .../rest/action/update/RestUpdateAction.java | 8 ++-- .../action/ActionModuleTests.java | 3 +- .../common/network/NetworkModuleTests.java | 10 ++--- .../elasticsearch/http/HttpServerTests.java | 6 +-- .../TestResponseHeaderRestAction.java | 8 ++-- .../rest/RestControllerTests.java | 7 +-- .../rest/RestFilterChainTests.java | 35 +++++++-------- .../action/cat/RestRecoveryActionTests.java | 2 +- .../DedicatedClusterSnapshotRestoreIT.java | 6 ++- .../RestDeleteSearchTemplateAction.java | 6 +-- .../template/RestGetSearchTemplateAction.java | 6 +-- .../RestMultiSearchTemplateAction.java | 8 ++-- .../template/RestPutSearchTemplateAction.java | 6 +-- .../RestRenderSearchTemplateAction.java | 8 ++-- .../template/RestSearchTemplateAction.java | 8 ++-- .../percolator/RestMultiPercolateAction.java | 8 ++-- .../percolator/RestPercolateAction.java | 44 +++++++++---------- .../AbstractBaseReindexRestHandler.java | 10 ++--- .../AbstractBulkByQueryRestHandler.java | 4 +- .../reindex/RestDeleteByQueryAction.java | 8 ++-- .../index/reindex/RestReindexAction.java | 8 ++-- .../index/reindex/RestRethrottleAction.java | 8 ++-- .../reindex/RestUpdateByQueryAction.java | 8 ++-- .../plugin/example/ExampleCatAction.java | 8 ++-- 135 files changed, 592 insertions(+), 585 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/http/HttpServer.java b/core/src/main/java/org/elasticsearch/http/HttpServer.java index 31bbd235009..f44b839b2a3 100644 --- a/core/src/main/java/org/elasticsearch/http/HttpServer.java +++ b/core/src/main/java/org/elasticsearch/http/HttpServer.java @@ -19,6 +19,12 @@ package org.elasticsearch.http; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.breaker.CircuitBreaker; import org.elasticsearch.common.bytes.BytesArray; @@ -39,11 +45,6 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.RestStatus; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.concurrent.atomic.AtomicBoolean; - import static org.elasticsearch.rest.RestStatus.FORBIDDEN; import static org.elasticsearch.rest.RestStatus.INTERNAL_SERVER_ERROR; @@ -57,15 +58,18 @@ public class HttpServer extends AbstractLifecycleComponent implement private final NodeService nodeService; + private final NodeClient client; + private final CircuitBreakerService circuitBreakerService; @Inject public HttpServer(Settings settings, HttpServerTransport transport, RestController restController, NodeService nodeService, - CircuitBreakerService circuitBreakerService) { + NodeClient client, CircuitBreakerService circuitBreakerService) { super(settings); this.transport = transport; this.restController = restController; this.nodeService = nodeService; + this.client = client; this.circuitBreakerService = circuitBreakerService; nodeService.setHttpServer(this); transport.httpServerAdapter(this); @@ -115,7 +119,7 @@ public class HttpServer extends AbstractLifecycleComponent implement } // iff we could reserve bytes for the request we need to send the response also over this channel responseChannel = new ResourceHandlingHttpChannel(channel, circuitBreakerService, contentLength); - restController.dispatchRequest(request, responseChannel, threadContext); + restController.dispatchRequest(request, responseChannel, client, threadContext); } catch (Throwable t) { restController.sendErrorResponse(request, responseChannel, t); } diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index 1d18f696163..e12a5f552ff 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -283,6 +283,7 @@ public class Node implements Closeable { modules.add(b -> { b.bind(PluginsService.class).toInstance(pluginsService); b.bind(Client.class).toInstance(client); + b.bind(NodeClient.class).toInstance(client); b.bind(Environment.class).toInstance(environment); b.bind(ThreadPool.class).toInstance(threadPool); b.bind(NodeEnvironment.class).toInstance(nodeEnvironment); diff --git a/core/src/main/java/org/elasticsearch/rest/BaseRestHandler.java b/core/src/main/java/org/elasticsearch/rest/BaseRestHandler.java index b406dfca545..cfa46eab514 100644 --- a/core/src/main/java/org/elasticsearch/rest/BaseRestHandler.java +++ b/core/src/main/java/org/elasticsearch/rest/BaseRestHandler.java @@ -19,7 +19,6 @@ package org.elasticsearch.rest; -import org.elasticsearch.client.Client; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Setting; @@ -37,19 +36,10 @@ import org.elasticsearch.common.settings.Settings; public abstract class BaseRestHandler extends AbstractComponent implements RestHandler { public static final Setting MULTI_ALLOW_EXPLICIT_INDEX = Setting.boolSetting("rest.action.multi.allow_explicit_index", true, Property.NodeScope); - private final Client client; protected final ParseFieldMatcher parseFieldMatcher; - protected BaseRestHandler(Settings settings, Client client) { + protected BaseRestHandler(Settings settings) { super(settings); - this.client = client; this.parseFieldMatcher = new ParseFieldMatcher(settings); } - - @Override - public final void handleRequest(RestRequest request, RestChannel channel) throws Exception { - handleRequest(request, channel, client); - } - - protected abstract void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception; } diff --git a/core/src/main/java/org/elasticsearch/rest/RestController.java b/core/src/main/java/org/elasticsearch/rest/RestController.java index e8212ff09c6..8059dfd7ea5 100644 --- a/core/src/main/java/org/elasticsearch/rest/RestController.java +++ b/core/src/main/java/org/elasticsearch/rest/RestController.java @@ -19,6 +19,7 @@ package org.elasticsearch.rest; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.component.AbstractLifecycleComponent; @@ -150,7 +151,7 @@ public class RestController extends AbstractLifecycleComponent { return (handler != null) ? handler.canTripCircuitBreaker() : true; } - public void dispatchRequest(final RestRequest request, final RestChannel channel, ThreadContext threadContext) throws Exception { + public void dispatchRequest(final RestRequest request, final RestChannel channel, final NodeClient client, ThreadContext threadContext) throws Exception { if (!checkRequestParameters(request, channel)) { return; } @@ -162,10 +163,10 @@ public class RestController extends AbstractLifecycleComponent { } } if (filters.length == 0) { - executeHandler(request, channel); + executeHandler(request, channel, client); } else { ControllerFilterChain filterChain = new ControllerFilterChain(handlerFilter); - filterChain.continueProcessing(request, channel); + filterChain.continueProcessing(request, channel, client); } } } @@ -200,10 +201,10 @@ public class RestController extends AbstractLifecycleComponent { return true; } - void executeHandler(RestRequest request, RestChannel channel) throws Exception { + void executeHandler(RestRequest request, RestChannel channel, NodeClient client) throws Exception { final RestHandler handler = getHandler(request); if (handler != null) { - handler.handleRequest(request, channel); + handler.handleRequest(request, channel, client); } else { if (request.method() == RestRequest.Method.OPTIONS) { // when we have OPTIONS request, simply send OK by default (with the Access Control Origin header which gets automatically added) @@ -261,16 +262,16 @@ public class RestController extends AbstractLifecycleComponent { } @Override - public void continueProcessing(RestRequest request, RestChannel channel) { + public void continueProcessing(RestRequest request, RestChannel channel, NodeClient client) { try { int loc = index.getAndIncrement(); if (loc > filters.length) { throw new IllegalStateException("filter continueProcessing was called more than expected"); } else if (loc == filters.length) { - executionFilter.process(request, channel, this); + executionFilter.process(request, channel, client, this); } else { RestFilter preProcessor = filters[loc]; - preProcessor.process(request, channel, this); + preProcessor.process(request, channel, client, this); } } catch (Exception e) { try { @@ -285,8 +286,8 @@ public class RestController extends AbstractLifecycleComponent { class RestHandlerFilter extends RestFilter { @Override - public void process(RestRequest request, RestChannel channel, RestFilterChain filterChain) throws Exception { - executeHandler(request, channel); + public void process(RestRequest request, RestChannel channel, NodeClient client, RestFilterChain filterChain) throws Exception { + executeHandler(request, channel, client); } } } diff --git a/core/src/main/java/org/elasticsearch/rest/RestFilter.java b/core/src/main/java/org/elasticsearch/rest/RestFilter.java index e3ff44ff1fc..276e99fc7e5 100644 --- a/core/src/main/java/org/elasticsearch/rest/RestFilter.java +++ b/core/src/main/java/org/elasticsearch/rest/RestFilter.java @@ -21,6 +21,8 @@ package org.elasticsearch.rest; import java.io.Closeable; +import org.elasticsearch.client.node.NodeClient; + /** * A filter allowing to filter rest operations. */ @@ -43,5 +45,5 @@ public abstract class RestFilter implements Closeable { * Process the rest request. Using the channel to send a response, or the filter chain to continue * processing the request. */ - public abstract void process(RestRequest request, RestChannel channel, RestFilterChain filterChain) throws Exception; + public abstract void process(RestRequest request, RestChannel channel, NodeClient client, RestFilterChain filterChain) throws Exception; } diff --git a/core/src/main/java/org/elasticsearch/rest/RestFilterChain.java b/core/src/main/java/org/elasticsearch/rest/RestFilterChain.java index be14d252b74..239a6c6b1bb 100644 --- a/core/src/main/java/org/elasticsearch/rest/RestFilterChain.java +++ b/core/src/main/java/org/elasticsearch/rest/RestFilterChain.java @@ -19,6 +19,8 @@ package org.elasticsearch.rest; +import org.elasticsearch.client.node.NodeClient; + /** * A filter chain allowing to continue and process the rest request. */ @@ -28,5 +30,5 @@ public interface RestFilterChain { * Continue processing the request. Should only be called if a response has not been sent * through the channel. */ - void continueProcessing(RestRequest request, RestChannel channel); + void continueProcessing(RestRequest request, RestChannel channel, NodeClient client); } diff --git a/core/src/main/java/org/elasticsearch/rest/RestHandler.java b/core/src/main/java/org/elasticsearch/rest/RestHandler.java index 31970441493..393e425baf9 100644 --- a/core/src/main/java/org/elasticsearch/rest/RestHandler.java +++ b/core/src/main/java/org/elasticsearch/rest/RestHandler.java @@ -19,12 +19,21 @@ package org.elasticsearch.rest; +import org.elasticsearch.client.node.NodeClient; + /** * Handler for REST requests */ public interface RestHandler { - void handleRequest(RestRequest request, RestChannel channel) throws Exception; + /** + * Handles a rest request. + * + * @param request The request to handle + * @param channel The channel to write the request response to + * @param client A client to use to make internal requests on behalf of the original request + */ + void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception; default boolean canTripCircuitBreaker() { return true; diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/allocation/RestClusterAllocationExplainAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/allocation/RestClusterAllocationExplainAction.java index 0785151e8d7..e802e9e2b7f 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/allocation/RestClusterAllocationExplainAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/allocation/RestClusterAllocationExplainAction.java @@ -19,11 +19,12 @@ package org.elasticsearch.rest.action.admin.cluster.allocation; +import java.io.IOException; + import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest; import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainResponse; -import org.elasticsearch.client.Client; -import org.elasticsearch.client.Requests; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.inject.Inject; @@ -42,22 +43,20 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestBuilderListener; -import java.io.IOException; - /** * Class handling cluster allocation explanation at the REST level */ public class RestClusterAllocationExplainAction extends BaseRestHandler { @Inject - public RestClusterAllocationExplainAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestClusterAllocationExplainAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.GET, "/_cluster/allocation/explain", this); controller.registerHandler(RestRequest.Method.POST, "/_cluster/allocation/explain", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { ClusterAllocationExplainRequest req; if (RestActions.hasBodyContent(request) == false) { // Empty request signals "explain the first unassigned shard you find" diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/health/RestClusterHealthAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/health/RestClusterHealthAction.java index a2c6ffeaf14..d43d75ea5e7 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/health/RestClusterHealthAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/health/RestClusterHealthAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.health; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -42,15 +42,15 @@ import static org.elasticsearch.client.Requests.clusterHealthRequest; public class RestClusterHealthAction extends BaseRestHandler { @Inject - public RestClusterHealthAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestClusterHealthAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.GET, "/_cluster/health", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/health/{index}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { ClusterHealthRequest clusterHealthRequest = clusterHealthRequest(Strings.splitStringByCommaToArray(request.param("index"))); clusterHealthRequest.local(request.paramAsBoolean("local", clusterHealthRequest.local())); clusterHealthRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterHealthRequest.masterNodeTimeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/hotthreads/RestNodesHotThreadsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/hotthreads/RestNodesHotThreadsAction.java index 2030d5e7d92..1d0daa3e7d6 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/hotthreads/RestNodesHotThreadsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/hotthreads/RestNodesHotThreadsAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.cluster.node.hotthreads; import org.elasticsearch.action.admin.cluster.node.hotthreads.NodeHotThreads; import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsRequest; import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -42,8 +42,8 @@ import org.elasticsearch.rest.action.support.RestResponseListener; public class RestNodesHotThreadsAction extends BaseRestHandler { @Inject - public RestNodesHotThreadsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestNodesHotThreadsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.GET, "/_cluster/nodes/hotthreads", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/nodes/hot_threads", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/nodes/{nodeId}/hotthreads", this); @@ -56,7 +56,7 @@ public class RestNodesHotThreadsAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String[] nodesIds = Strings.splitStringByCommaToArray(request.param("nodeId")); NodesHotThreadsRequest nodesHotThreadsRequest = new NodesHotThreadsRequest(nodesIds); nodesHotThreadsRequest.threads(request.paramAsInt("threads", nodesHotThreadsRequest.threads())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/info/RestNodesInfoAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/info/RestNodesInfoAction.java index 312fd0b0b7a..3df457efb9d 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/info/RestNodesInfoAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/info/RestNodesInfoAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.cluster.node.info; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -46,8 +46,8 @@ public class RestNodesInfoAction extends BaseRestHandler { private final static Set ALLOWED_METRICS = Sets.newHashSet("http", "jvm", "os", "plugins", "process", "settings", "thread_pool", "transport", "ingest", "indices"); @Inject - public RestNodesInfoAction(Settings settings, RestController controller, Client client, SettingsFilter settingsFilter) { - super(settings, client); + public RestNodesInfoAction(Settings settings, RestController controller, SettingsFilter settingsFilter) { + super(settings); controller.registerHandler(GET, "/_nodes", this); // this endpoint is used for metrics, not for nodeIds, like /_nodes/fs controller.registerHandler(GET, "/_nodes/{nodeId}", this); @@ -59,7 +59,7 @@ public class RestNodesInfoAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String[] nodeIds; Set metrics; diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java index 8019de0b4e5..1b0e434ef5c 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.cluster.node.stats; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -43,8 +43,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestNodesStatsAction extends BaseRestHandler { @Inject - public RestNodesStatsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestNodesStatsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_nodes/stats", this); controller.registerHandler(GET, "/_nodes/{nodeId}/stats", this); @@ -57,7 +57,7 @@ public class RestNodesStatsAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String[] nodesIds = Strings.splitStringByCommaToArray(request.param("nodeId")); Set metrics = Strings.splitStringByCommaToSet(request.param("metric", "_all")); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestCancelTasksAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestCancelTasksAction.java index 0602abe651f..b9eec1ba98a 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestCancelTasksAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestCancelTasksAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.cluster.node.tasks; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -42,15 +42,15 @@ public class RestCancelTasksAction extends BaseRestHandler { private final ClusterService clusterService; @Inject - public RestCancelTasksAction(Settings settings, RestController controller, Client client, ClusterService clusterService) { - super(settings, client); + public RestCancelTasksAction(Settings settings, RestController controller, ClusterService clusterService) { + super(settings); this.clusterService = clusterService; controller.registerHandler(POST, "/_tasks/_cancel", this); controller.registerHandler(POST, "/_tasks/{taskId}/_cancel", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String[] nodesIds = Strings.splitStringByCommaToArray(request.param("nodeId")); TaskId taskId = new TaskId(request.param("taskId")); String[] actions = Strings.splitStringByCommaToArray(request.param("actions")); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestGetTaskAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestGetTaskAction.java index e5617711014..501e96857fd 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestGetTaskAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestGetTaskAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.cluster.node.tasks; import org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; @@ -35,13 +35,13 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetTaskAction extends BaseRestHandler { @Inject - public RestGetTaskAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestGetTaskAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_tasks/{taskId}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { TaskId taskId = new TaskId(request.param("taskId")); boolean waitForCompletion = request.paramAsBoolean("wait_for_completion", false); TimeValue timeout = request.paramAsTime("timeout", null); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestListTasksAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestListTasksAction.java index 8fa13e808ac..5d1c617e8e3 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestListTasksAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/tasks/RestListTasksAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.cluster.node.tasks; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -42,8 +42,8 @@ public class RestListTasksAction extends BaseRestHandler { private final ClusterService clusterService; @Inject - public RestListTasksAction(Settings settings, RestController controller, Client client, ClusterService clusterService) { - super(settings, client); + public RestListTasksAction(Settings settings, RestController controller, ClusterService clusterService) { + super(settings); this.clusterService = clusterService; controller.registerHandler(GET, "/_tasks", this); } @@ -67,7 +67,7 @@ public class RestListTasksAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { ActionListener listener = nodeSettingListener(clusterService, new RestToXContentListener<>(channel)); client.admin().cluster().listTasks(generateListTasksRequest(request), listener); } diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/delete/RestDeleteRepositoryAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/delete/RestDeleteRepositoryAction.java index 136c1cfae3f..c2dce1cae36 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/delete/RestDeleteRepositoryAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/delete/RestDeleteRepositoryAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.repositories.delete; import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest; import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -39,13 +39,13 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteRepositoryAction extends BaseRestHandler { @Inject - public RestDeleteRepositoryAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestDeleteRepositoryAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(DELETE, "/_snapshot/{repository}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { DeleteRepositoryRequest deleteRepositoryRequest = deleteRepositoryRequest(request.param("repository")); deleteRepositoryRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteRepositoryRequest.masterNodeTimeout())); deleteRepositoryRequest.timeout(request.paramAsTime("timeout", deleteRepositoryRequest.timeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/get/RestGetRepositoriesAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/get/RestGetRepositoriesAction.java index 09422481cf3..34004156d5b 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/get/RestGetRepositoriesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/get/RestGetRepositoriesAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.repositories.get; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.RepositoriesMetaData; import org.elasticsearch.cluster.metadata.RepositoryMetaData; import org.elasticsearch.common.Strings; @@ -49,15 +49,15 @@ public class RestGetRepositoriesAction extends BaseRestHandler { private final SettingsFilter settingsFilter; @Inject - public RestGetRepositoriesAction(Settings settings, RestController controller, Client client, SettingsFilter settingsFilter) { - super(settings, client); + public RestGetRepositoriesAction(Settings settings, RestController controller, SettingsFilter settingsFilter) { + super(settings); controller.registerHandler(GET, "/_snapshot", this); controller.registerHandler(GET, "/_snapshot/{repository}", this); this.settingsFilter = settingsFilter; } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] repositories = request.paramAsStringArray("repository", Strings.EMPTY_ARRAY); GetRepositoriesRequest getRepositoriesRequest = getRepositoryRequest(repositories); getRepositoriesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRepositoriesRequest.masterNodeTimeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/put/RestPutRepositoryAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/put/RestPutRepositoryAction.java index 878eb2915bc..745dd7e0b9f 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/put/RestPutRepositoryAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/put/RestPutRepositoryAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.repositories.put; import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest; import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -40,15 +40,15 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestPutRepositoryAction extends BaseRestHandler { @Inject - public RestPutRepositoryAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestPutRepositoryAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(PUT, "/_snapshot/{repository}", this); controller.registerHandler(POST, "/_snapshot/{repository}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { PutRepositoryRequest putRepositoryRequest = putRepositoryRequest(request.param("repository")); putRepositoryRequest.source(request.content().toUtf8()); putRepositoryRequest.verify(request.paramAsBoolean("verify", true)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/verify/RestVerifyRepositoryAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/verify/RestVerifyRepositoryAction.java index 306dcbb21b9..b3f6fe776fe 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/verify/RestVerifyRepositoryAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/repositories/verify/RestVerifyRepositoryAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.cluster.repositories.verify; import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -35,13 +35,13 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestVerifyRepositoryAction extends BaseRestHandler { @Inject - public RestVerifyRepositoryAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestVerifyRepositoryAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/_snapshot/{repository}/_verify", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { VerifyRepositoryRequest verifyRepositoryRequest = verifyRepositoryRequest(request.param("repository")); verifyRepositoryRequest.masterNodeTimeout(request.paramAsTime("master_timeout", verifyRepositoryRequest.masterNodeTimeout())); verifyRepositoryRequest.timeout(request.paramAsTime("timeout", verifyRepositoryRequest.timeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/reroute/RestClusterRerouteAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/reroute/RestClusterRerouteAction.java index a06466137a5..ad4abaf10c4 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/reroute/RestClusterRerouteAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/reroute/RestClusterRerouteAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.reroute; import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequest; import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.allocation.command.AllocationCommandRegistry; @@ -65,16 +65,16 @@ public class RestClusterRerouteAction extends BaseRestHandler { private final AllocationCommandRegistry registry; @Inject - public RestClusterRerouteAction(Settings settings, RestController controller, Client client, SettingsFilter settingsFilter, + public RestClusterRerouteAction(Settings settings, RestController controller, SettingsFilter settingsFilter, AllocationCommandRegistry registry) { - super(settings, client); + super(settings); this.settingsFilter = settingsFilter; this.registry = registry; controller.registerHandler(RestRequest.Method.POST, "/_cluster/reroute", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { ClusterRerouteRequest clusterRerouteRequest = createRequest(request, registry, parseFieldMatcher); client.admin().cluster().reroute(clusterRerouteRequest, new AcknowledgedRestListener(channel) { @Override diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterGetSettingsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterGetSettingsAction.java index 44a7f2f714b..a1e85c5d298 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterGetSettingsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterGetSettingsAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.settings; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.common.inject.Inject; @@ -50,15 +50,15 @@ public class RestClusterGetSettingsAction extends BaseRestHandler { private final SettingsFilter settingsFilter; @Inject - public RestClusterGetSettingsAction(Settings settings, RestController controller, Client client, ClusterSettings clusterSettings, SettingsFilter settingsFilter) { - super(settings, client); + public RestClusterGetSettingsAction(Settings settings, RestController controller, ClusterSettings clusterSettings, SettingsFilter settingsFilter) { + super(settings); this.clusterSettings = clusterSettings; controller.registerHandler(RestRequest.Method.GET, "/_cluster/settings", this); this.settingsFilter = settingsFilter; } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest() .routingTable(false) .nodes(false); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterUpdateSettingsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterUpdateSettingsAction.java index b25866d4520..055bcc4df60 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterUpdateSettingsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/settings/RestClusterUpdateSettingsAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.settings; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.Requests; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -42,13 +42,13 @@ import java.util.Map; public class RestClusterUpdateSettingsAction extends BaseRestHandler { @Inject - public RestClusterUpdateSettingsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestClusterUpdateSettingsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.PUT, "/_cluster/settings", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { final ClusterUpdateSettingsRequest clusterUpdateSettingsRequest = Requests.clusterUpdateSettingsRequest(); clusterUpdateSettingsRequest.timeout(request.paramAsTime("timeout", clusterUpdateSettingsRequest.timeout())); clusterUpdateSettingsRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterUpdateSettingsRequest.masterNodeTimeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/shards/RestClusterSearchShardsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/shards/RestClusterSearchShardsAction.java index 860e110b2d6..82edb74c7e6 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/shards/RestClusterSearchShardsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/shards/RestClusterSearchShardsAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.cluster.shards; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsRequest; import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.Requests; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -41,8 +41,8 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestClusterSearchShardsAction extends BaseRestHandler { @Inject - public RestClusterSearchShardsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestClusterSearchShardsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_search_shards", this); controller.registerHandler(POST, "/_search_shards", this); controller.registerHandler(GET, "/{index}/_search_shards", this); @@ -52,7 +52,7 @@ public class RestClusterSearchShardsAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final ClusterSearchShardsRequest clusterSearchShardsRequest = Requests.clusterSearchShardsRequest(indices); clusterSearchShardsRequest.local(request.paramAsBoolean("local", clusterSearchShardsRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/create/RestCreateSnapshotAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/create/RestCreateSnapshotAction.java index 9d6be664d48..3be27d286e2 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/create/RestCreateSnapshotAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/create/RestCreateSnapshotAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.snapshots.create; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -40,14 +40,14 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestCreateSnapshotAction extends BaseRestHandler { @Inject - public RestCreateSnapshotAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestCreateSnapshotAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(PUT, "/_snapshot/{repository}/{snapshot}", this); controller.registerHandler(POST, "/_snapshot/{repository}/{snapshot}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { CreateSnapshotRequest createSnapshotRequest = createSnapshotRequest(request.param("repository"), request.param("snapshot")); createSnapshotRequest.source(request.content().toUtf8()); createSnapshotRequest.masterNodeTimeout(request.paramAsTime("master_timeout", createSnapshotRequest.masterNodeTimeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/delete/RestDeleteSnapshotAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/delete/RestDeleteSnapshotAction.java index 38c78bd5d88..5b99cb3a5ee 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/delete/RestDeleteSnapshotAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/delete/RestDeleteSnapshotAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.snapshots.delete; import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest; import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -39,13 +39,13 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteSnapshotAction extends BaseRestHandler { @Inject - public RestDeleteSnapshotAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestDeleteSnapshotAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(DELETE, "/_snapshot/{repository}/{snapshot}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { DeleteSnapshotRequest deleteSnapshotRequest = deleteSnapshotRequest(request.param("repository"), request.param("snapshot")); deleteSnapshotRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteSnapshotRequest.masterNodeTimeout())); client.admin().cluster().deleteSnapshot(deleteSnapshotRequest, new AcknowledgedRestListener(channel)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/get/RestGetSnapshotsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/get/RestGetSnapshotsAction.java index 1151fed8f23..835c23ac191 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/get/RestGetSnapshotsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/get/RestGetSnapshotsAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.snapshots.get; import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest; import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -40,14 +40,14 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetSnapshotsAction extends BaseRestHandler { @Inject - public RestGetSnapshotsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestGetSnapshotsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_snapshot/{repository}/{snapshot}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String repository = request.param("repository"); String[] snapshots = request.paramAsStringArray("snapshot", Strings.EMPTY_ARRAY); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/restore/RestRestoreSnapshotAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/restore/RestRestoreSnapshotAction.java index e2a16bd4b46..6a1eb0eaa50 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/restore/RestRestoreSnapshotAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/restore/RestRestoreSnapshotAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.snapshots.restore; import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -39,13 +39,13 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestRestoreSnapshotAction extends BaseRestHandler { @Inject - public RestRestoreSnapshotAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestRestoreSnapshotAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/_snapshot/{repository}/{snapshot}/_restore", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { RestoreSnapshotRequest restoreSnapshotRequest = restoreSnapshotRequest(request.param("repository"), request.param("snapshot")); restoreSnapshotRequest.masterNodeTimeout(request.paramAsTime("master_timeout", restoreSnapshotRequest.masterNodeTimeout())); restoreSnapshotRequest.waitForCompletion(request.paramAsBoolean("wait_for_completion", false)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/status/RestSnapshotsStatusAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/status/RestSnapshotsStatusAction.java index 2e8810e2ba7..484ee4e5120 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/status/RestSnapshotsStatusAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/snapshots/status/RestSnapshotsStatusAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.snapshots.status; import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest; import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -40,15 +40,15 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestSnapshotsStatusAction extends BaseRestHandler { @Inject - public RestSnapshotsStatusAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestSnapshotsStatusAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_snapshot/{repository}/{snapshot}/_status", this); controller.registerHandler(GET, "/_snapshot/{repository}/_status", this); controller.registerHandler(GET, "/_snapshot/_status", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String repository = request.param("repository", "_all"); String[] snapshots = request.paramAsStringArray("snapshot", Strings.EMPTY_ARRAY); if (snapshots.length == 1 && "_all".equalsIgnoreCase(snapshots[0])) { diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java index c756796446e..b3f5a407d91 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/state/RestClusterStateAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.cluster.state; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.common.Strings; @@ -50,8 +50,8 @@ public class RestClusterStateAction extends BaseRestHandler { private final SettingsFilter settingsFilter; @Inject - public RestClusterStateAction(Settings settings, RestController controller, Client client, SettingsFilter settingsFilter) { - super(settings, client); + public RestClusterStateAction(Settings settings, RestController controller, SettingsFilter settingsFilter) { + super(settings); controller.registerHandler(RestRequest.Method.GET, "/_cluster/state", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/state/{metric}", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/state/{metric}/{indices}", this); @@ -60,7 +60,7 @@ public class RestClusterStateAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest(); clusterStateRequest.indicesOptions(IndicesOptions.fromRequest(request, clusterStateRequest.indicesOptions())); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/stats/RestClusterStatsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/stats/RestClusterStatsAction.java index c83a5b7ae1b..a43b428ae9c 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/stats/RestClusterStatsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/stats/RestClusterStatsAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.cluster.stats; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -35,14 +35,14 @@ import org.elasticsearch.rest.action.support.RestActions.NodesResponseRestListen public class RestClusterStatsAction extends BaseRestHandler { @Inject - public RestClusterStatsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestClusterStatsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.GET, "/_cluster/stats", this); controller.registerHandler(RestRequest.Method.GET, "/_cluster/stats/nodes/{nodeId}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { ClusterStatsRequest clusterStatsRequest = new ClusterStatsRequest().nodesIds(request.paramAsStringArray("nodeId", null)); clusterStatsRequest.timeout(request.param("timeout")); client.admin().cluster().clusterStats(clusterStatsRequest, new NodesResponseRestListener<>(channel)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestDeleteStoredScriptAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestDeleteStoredScriptAction.java index a8190d30278..6416a693550 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestDeleteStoredScriptAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestDeleteStoredScriptAction.java @@ -19,7 +19,7 @@ package org.elasticsearch.rest.action.admin.cluster.storedscripts; import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -33,12 +33,12 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteStoredScriptAction extends BaseRestHandler { @Inject - public RestDeleteStoredScriptAction(Settings settings, RestController controller, Client client) { - this(settings, controller, true, client); + public RestDeleteStoredScriptAction(Settings settings, RestController controller) { + this(settings, controller, true); } - protected RestDeleteStoredScriptAction(Settings settings, RestController controller, boolean registerDefaultHandlers, Client client) { - super(settings, client); + protected RestDeleteStoredScriptAction(Settings settings, RestController controller, boolean registerDefaultHandlers) { + super(settings); if (registerDefaultHandlers) { controller.registerHandler(DELETE, "/_scripts/{lang}/{id}", this); } @@ -49,7 +49,7 @@ public class RestDeleteStoredScriptAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, NodeClient client) { DeleteStoredScriptRequest deleteStoredScriptRequest = new DeleteStoredScriptRequest(getScriptLang(request), request.param("id")); client.admin().cluster().deleteStoredScript(deleteStoredScriptRequest, new AcknowledgedRestListener<>(channel)); } diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestGetStoredScriptAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestGetStoredScriptAction.java index bf286f623fb..fb6fd0ca7c9 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestGetStoredScriptAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestGetStoredScriptAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.cluster.storedscripts; import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest; import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -38,12 +38,12 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestGetStoredScriptAction extends BaseRestHandler { @Inject - public RestGetStoredScriptAction(Settings settings, RestController controller, Client client) { - this(settings, controller, true, client); + public RestGetStoredScriptAction(Settings settings, RestController controller) { + this(settings, controller, true); } - protected RestGetStoredScriptAction(Settings settings, RestController controller, boolean registerDefaultHandlers, Client client) { - super(settings, client); + protected RestGetStoredScriptAction(Settings settings, RestController controller, boolean registerDefaultHandlers) { + super(settings); if (registerDefaultHandlers) { controller.registerHandler(GET, "/_scripts/{lang}/{id}", this); } @@ -58,7 +58,7 @@ public class RestGetStoredScriptAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, NodeClient client) { final GetStoredScriptRequest getRequest = new GetStoredScriptRequest(getScriptLang(request), request.param("id")); client.admin().cluster().getStoredScript(getRequest, new RestBuilderListener(channel) { @Override diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestPutStoredScriptAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestPutStoredScriptAction.java index 0ecb27b8d1e..bb62528fc17 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestPutStoredScriptAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/storedscripts/RestPutStoredScriptAction.java @@ -19,7 +19,7 @@ package org.elasticsearch.rest.action.admin.cluster.storedscripts; import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -34,12 +34,12 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestPutStoredScriptAction extends BaseRestHandler { @Inject - public RestPutStoredScriptAction(Settings settings, RestController controller, Client client) { - this(settings, controller, true, client); + public RestPutStoredScriptAction(Settings settings, RestController controller) { + this(settings, controller, true); } - protected RestPutStoredScriptAction(Settings settings, RestController controller, boolean registerDefaultHandlers, Client client) { - super(settings, client); + protected RestPutStoredScriptAction(Settings settings, RestController controller, boolean registerDefaultHandlers) { + super(settings); if (registerDefaultHandlers) { controller.registerHandler(POST, "/_scripts/{lang}/{id}", this); controller.registerHandler(PUT, "/_scripts/{lang}/{id}", this); @@ -51,7 +51,7 @@ public class RestPutStoredScriptAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, NodeClient client) { PutStoredScriptRequest putRequest = new PutStoredScriptRequest(getScriptLang(request), request.param("id")); putRequest.script(request.content()); client.admin().cluster().putStoredScript(putRequest, new AcknowledgedRestListener<>(channel)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/tasks/RestPendingClusterTasksAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/tasks/RestPendingClusterTasksAction.java index 333b6d64491..e106dd1f980 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/tasks/RestPendingClusterTasksAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/cluster/tasks/RestPendingClusterTasksAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.cluster.tasks; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -35,13 +35,13 @@ import org.elasticsearch.rest.action.support.RestToXContentListener; public class RestPendingClusterTasksAction extends BaseRestHandler { @Inject - public RestPendingClusterTasksAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestPendingClusterTasksAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.GET, "/_cluster/pending_tasks", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { PendingClusterTasksRequest pendingClusterTasksRequest = new PendingClusterTasksRequest(); pendingClusterTasksRequest.masterNodeTimeout(request.paramAsTime("master_timeout", pendingClusterTasksRequest.masterNodeTimeout())); pendingClusterTasksRequest.local(request.paramAsBoolean("local", pendingClusterTasksRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java index 7eecaaa738c..a922edff484 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.indices; import org.elasticsearch.action.admin.indices.rollover.RolloverRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -35,15 +35,15 @@ import org.elasticsearch.rest.action.support.RestToXContentListener; public class RestRolloverIndexAction extends BaseRestHandler { @Inject - public RestRolloverIndexAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestRolloverIndexAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.POST, "/{index}/_rollover", this); controller.registerHandler(RestRequest.Method.POST, "/{index}/_rollover/{new_index}", this); } @SuppressWarnings({"unchecked"}) @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { RolloverRequest rolloverIndexRequest = new RolloverRequest(request.param("index"), request.param("new_index")); if (request.hasContent()) { rolloverIndexRequest.source(request.content()); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestShrinkIndexAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestShrinkIndexAction.java index f145bcbf02a..96b4abbe063 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestShrinkIndexAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestShrinkIndexAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.indices; import org.elasticsearch.action.admin.indices.shrink.ShrinkRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -35,15 +35,15 @@ import org.elasticsearch.rest.action.support.AcknowledgedRestListener; public class RestShrinkIndexAction extends BaseRestHandler { @Inject - public RestShrinkIndexAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestShrinkIndexAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.PUT, "/{index}/_shrink/{target}", this); controller.registerHandler(RestRequest.Method.POST, "/{index}/_shrink/{target}", this); } @SuppressWarnings({"unchecked"}) @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { if (request.param("target") == null) { throw new IllegalArgumentException("no target index"); } diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestIndicesAliasesAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestIndicesAliasesAction.java index 74982133f71..dff4c492f17 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestIndicesAliasesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/RestIndicesAliasesAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.alias; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.AliasAction; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -46,13 +46,13 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestIndicesAliasesAction extends BaseRestHandler { @Inject - public RestIndicesAliasesAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestIndicesAliasesAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/_aliases", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest(); indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout())); try (XContentParser parser = XContentFactory.xContent(request.content()).createParser(request.content())) { diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/delete/RestIndexDeleteAliasesAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/delete/RestIndexDeleteAliasesAction.java index 7fcaadc3d8b..eedac4d8eea 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/delete/RestIndexDeleteAliasesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/delete/RestIndexDeleteAliasesAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.indices.alias.delete; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -37,14 +37,14 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestIndexDeleteAliasesAction extends BaseRestHandler { @Inject - public RestIndexDeleteAliasesAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestIndexDeleteAliasesAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(DELETE, "/{index}/_alias/{name}", this); controller.registerHandler(DELETE, "/{index}/_aliases/{name}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final String[] aliases = Strings.splitStringByCommaToArray(request.param("name")); IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest(); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetAliasesAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetAliasesAction.java index cbebf08516d..8ecbc64b27f 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetAliasesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/get/RestGetAliasesAction.java @@ -23,7 +23,7 @@ import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.AliasMetaData; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -50,14 +50,14 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestGetAliasesAction extends BaseRestHandler { @Inject - public RestGetAliasesAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestGetAliasesAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_alias/{name}", this); controller.registerHandler(GET, "/{index}/_alias/{name}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] aliases = request.paramAsStringArrayOrEmptyIfAll("name"); final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final GetAliasesRequest getAliasesRequest = new GetAliasesRequest(aliases); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/head/RestAliasesExistAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/head/RestAliasesExistAction.java index 65f8fd363ea..7c539e1be48 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/head/RestAliasesExistAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/head/RestAliasesExistAction.java @@ -24,7 +24,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.alias.exists.AliasesExistResponse; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.inject.Inject; @@ -44,15 +44,15 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestAliasesExistAction extends BaseRestHandler { @Inject - public RestAliasesExistAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestAliasesExistAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(HEAD, "/_alias/{name}", this); controller.registerHandler(HEAD, "/{index}/_alias/{name}", this); controller.registerHandler(HEAD, "/{index}/_alias", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String[] aliases = request.paramAsStringArray("name", Strings.EMPTY_ARRAY); final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); GetAliasesRequest getAliasesRequest = new GetAliasesRequest(aliases); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/put/RestIndexPutAliasAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/put/RestIndexPutAliasAction.java index 7a0c2ad466f..e9f5e294db4 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/put/RestIndexPutAliasAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/alias/put/RestIndexPutAliasAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.indices.alias.put; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.AliasAction; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -44,8 +44,8 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestIndexPutAliasAction extends BaseRestHandler { @Inject - public RestIndexPutAliasAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestIndexPutAliasAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(PUT, "/{index}/_alias/{name}", this); controller.registerHandler(PUT, "/_alias/{name}", this); controller.registerHandler(PUT, "/{index}/_aliases/{name}", this); @@ -62,7 +62,7 @@ public class RestIndexPutAliasAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { String[] indices = Strings.splitStringByCommaToArray(request.param("index")); String alias = request.param("name"); Map filter = null; diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java index 75caea19856..588771ae1c8 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/analyze/RestAnalyzeAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.indices.analyze; import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest; import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.bytes.BytesReference; @@ -60,8 +60,8 @@ public class RestAnalyzeAction extends BaseRestHandler { } @Inject - public RestAnalyzeAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestAnalyzeAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_analyze", this); controller.registerHandler(GET, "/{index}/_analyze", this); controller.registerHandler(POST, "/_analyze", this); @@ -69,7 +69,7 @@ public class RestAnalyzeAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String[] texts = request.paramAsStringArrayOrEmptyIfAll("text"); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/cache/clear/RestClearIndicesCacheAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/cache/clear/RestClearIndicesCacheAction.java index 97e424445d8..454e18cb2d7 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/cache/clear/RestClearIndicesCacheAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/cache/clear/RestClearIndicesCacheAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.cache.clear; import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest; import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.Strings; @@ -50,8 +50,8 @@ import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastSh public class RestClearIndicesCacheAction extends BaseRestHandler { @Inject - public RestClearIndicesCacheAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestClearIndicesCacheAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/_cache/clear", this); controller.registerHandler(POST, "/{index}/_cache/clear", this); @@ -60,7 +60,7 @@ public class RestClearIndicesCacheAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { ClearIndicesCacheRequest clearIndicesCacheRequest = new ClearIndicesCacheRequest(Strings.splitStringByCommaToArray(request.param("index"))); clearIndicesCacheRequest.indicesOptions(IndicesOptions.fromRequest(request, clearIndicesCacheRequest.indicesOptions())); fromRequest(request, clearIndicesCacheRequest, parseFieldMatcher); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/close/RestCloseIndexAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/close/RestCloseIndexAction.java index 5f211b88d11..1022310a350 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/close/RestCloseIndexAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/close/RestCloseIndexAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.close; import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; import org.elasticsearch.action.admin.indices.close.CloseIndexResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -38,14 +38,14 @@ import org.elasticsearch.rest.action.support.AcknowledgedRestListener; public class RestCloseIndexAction extends BaseRestHandler { @Inject - public RestCloseIndexAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestCloseIndexAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.POST, "/_close", this); controller.registerHandler(RestRequest.Method.POST, "/{index}/_close", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { CloseIndexRequest closeIndexRequest = new CloseIndexRequest(Strings.splitStringByCommaToArray(request.param("index"))); closeIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", closeIndexRequest.masterNodeTimeout())); closeIndexRequest.timeout(request.paramAsTime("timeout", closeIndexRequest.timeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java index 46bc9388972..46ee596286e 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/create/RestCreateIndexAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.indices.create; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -36,15 +36,15 @@ import org.elasticsearch.rest.action.support.AcknowledgedRestListener; public class RestCreateIndexAction extends BaseRestHandler { @Inject - public RestCreateIndexAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestCreateIndexAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.PUT, "/{index}", this); controller.registerHandler(RestRequest.Method.POST, "/{index}", this); } @SuppressWarnings({"unchecked"}) @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { CreateIndexRequest createIndexRequest = new CreateIndexRequest(request.param("index")); if (request.hasContent()) { createIndexRequest.source(request.content()); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java index 4953842c54a..75564021a3b 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/delete/RestDeleteIndexAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.delete; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -38,14 +38,14 @@ import org.elasticsearch.rest.action.support.AcknowledgedRestListener; public class RestDeleteIndexAction extends BaseRestHandler { @Inject - public RestDeleteIndexAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestDeleteIndexAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.DELETE, "/", this); controller.registerHandler(RestRequest.Method.DELETE, "/{index}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(Strings.splitStringByCommaToArray(request.param("index"))); deleteIndexRequest.timeout(request.paramAsTime("timeout", deleteIndexRequest.timeout())); deleteIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexRequest.masterNodeTimeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/indices/RestIndicesExistsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/indices/RestIndicesExistsAction.java index 0e240352a73..f45f607356e 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/indices/RestIndicesExistsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/indices/RestIndicesExistsAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.exists.indices; import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.inject.Inject; @@ -45,13 +45,13 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestIndicesExistsAction extends BaseRestHandler { @Inject - public RestIndicesExistsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestIndicesExistsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(HEAD, "/{index}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { IndicesExistsRequest indicesExistsRequest = new IndicesExistsRequest(Strings.splitStringByCommaToArray(request.param("index"))); indicesExistsRequest.indicesOptions(IndicesOptions.fromRequest(request, indicesExistsRequest.indicesOptions())); indicesExistsRequest.local(request.paramAsBoolean("local", indicesExistsRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/types/RestTypesExistsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/types/RestTypesExistsAction.java index 7a55be7e3af..2ac0d1354f1 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/types/RestTypesExistsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/exists/types/RestTypesExistsAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.indices.exists.types; import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest; import org.elasticsearch.action.admin.indices.exists.types.TypesExistsResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.inject.Inject; @@ -44,13 +44,13 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestTypesExistsAction extends BaseRestHandler { @Inject - public RestTypesExistsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestTypesExistsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(HEAD, "/{index}/{type}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { TypesExistsRequest typesExistsRequest = new TypesExistsRequest( Strings.splitStringByCommaToArray(request.param("index")), Strings.splitStringByCommaToArray(request.param("type")) ); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestFlushAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestFlushAction.java index f3b3304bcf9..5156a95c0cc 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestFlushAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestFlushAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.flush; import org.elasticsearch.action.admin.indices.flush.FlushRequest; import org.elasticsearch.action.admin.indices.flush.FlushResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -46,8 +46,8 @@ import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastSh public class RestFlushAction extends BaseRestHandler { @Inject - public RestFlushAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestFlushAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/_flush", this); controller.registerHandler(POST, "/{index}/_flush", this); @@ -56,7 +56,7 @@ public class RestFlushAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { FlushRequest flushRequest = new FlushRequest(Strings.splitStringByCommaToArray(request.param("index"))); flushRequest.indicesOptions(IndicesOptions.fromRequest(request, flushRequest.indicesOptions())); flushRequest.force(request.paramAsBoolean("force", flushRequest.force())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestSyncedFlushAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestSyncedFlushAction.java index 9bb36f03d65..70d311c6e04 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestSyncedFlushAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/flush/RestSyncedFlushAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.flush; import org.elasticsearch.action.admin.indices.flush.SyncedFlushRequest; import org.elasticsearch.action.admin.indices.flush.SyncedFlushResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -44,8 +44,8 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestSyncedFlushAction extends BaseRestHandler { @Inject - public RestSyncedFlushAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestSyncedFlushAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/_flush/synced", this); controller.registerHandler(POST, "/{index}/_flush/synced", this); @@ -54,7 +54,7 @@ public class RestSyncedFlushAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, IndicesOptions.lenientExpandOpen()); SyncedFlushRequest syncedFlushRequest = new SyncedFlushRequest(Strings.splitStringByCommaToArray(request.param("index"))); syncedFlushRequest.indicesOptions(indicesOptions); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/forcemerge/RestForceMergeAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/forcemerge/RestForceMergeAction.java index 8aa2683be5e..ecdbdeae14c 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/forcemerge/RestForceMergeAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/forcemerge/RestForceMergeAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.forcemerge; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -45,14 +45,14 @@ import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastSh public class RestForceMergeAction extends BaseRestHandler { @Inject - public RestForceMergeAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestForceMergeAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/_forcemerge", this); controller.registerHandler(POST, "/{index}/_forcemerge", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { ForceMergeRequest mergeRequest = new ForceMergeRequest(Strings.splitStringByCommaToArray(request.param("index"))); mergeRequest.indicesOptions(IndicesOptions.fromRequest(request, mergeRequest.indicesOptions())); mergeRequest.maxNumSegments(request.paramAsInt("max_num_segments", mergeRequest.maxNumSegments())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/get/RestGetIndicesAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/get/RestGetIndicesAction.java index f31c17d8b6e..578cd2e4a62 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/get/RestGetIndicesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/get/RestGetIndicesAction.java @@ -23,7 +23,7 @@ import org.elasticsearch.action.admin.indices.get.GetIndexRequest; import org.elasticsearch.action.admin.indices.get.GetIndexRequest.Feature; import org.elasticsearch.action.admin.indices.get.GetIndexResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.AliasMetaData; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.common.Strings; @@ -57,8 +57,8 @@ public class RestGetIndicesAction extends BaseRestHandler { private final SettingsFilter settingsFilter; @Inject - public RestGetIndicesAction(Settings settings, RestController controller, Client client, IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter) { - super(settings, client); + public RestGetIndicesAction(Settings settings, RestController controller, IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter) { + super(settings); this.indexScopedSettings = indexScopedSettings; controller.registerHandler(GET, "/{index}", this); controller.registerHandler(GET, "/{index}/{type}", this); @@ -66,7 +66,7 @@ public class RestGetIndicesAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String[] indices = Strings.splitStringByCommaToArray(request.param("index")); String[] featureParams = request.paramAsStringArray("type", null); // Work out if the indices is a list of features diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetFieldMappingAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetFieldMappingAction.java index 0db931d0a7a..d2f77e95f52 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetFieldMappingAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetFieldMappingAction.java @@ -23,7 +23,7 @@ import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsReques import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse; import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -50,8 +50,8 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestGetFieldMappingAction extends BaseRestHandler { @Inject - public RestGetFieldMappingAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestGetFieldMappingAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_mapping/field/{fields}", this); controller.registerHandler(GET, "/_mapping/{type}/field/{fields}", this); controller.registerHandler(GET, "/{index}/_mapping/field/{fields}", this); @@ -60,7 +60,7 @@ public class RestGetFieldMappingAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final String[] types = request.paramAsStringArrayOrEmptyIfAll("type"); final String[] fields = Strings.splitStringByCommaToArray(request.param("fields")); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java index 0da54bc4e75..c4f9dbf2333 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java @@ -23,7 +23,7 @@ import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest; import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.ImmutableOpenMap; @@ -50,8 +50,8 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestGetMappingAction extends BaseRestHandler { @Inject - public RestGetMappingAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestGetMappingAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/{index}/{type}/_mapping", this); controller.registerHandler(GET, "/{index}/_mappings/{type}", this); controller.registerHandler(GET, "/{index}/_mapping/{type}", this); @@ -59,7 +59,7 @@ public class RestGetMappingAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final String[] types = request.paramAsStringArrayOrEmptyIfAll("type"); GetMappingsRequest getMappingsRequest = new GetMappingsRequest(); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/put/RestPutMappingAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/put/RestPutMappingAction.java index fdb16d2fb8f..cb2493f4e33 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/put/RestPutMappingAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/put/RestPutMappingAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.mapping.put; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -43,8 +43,8 @@ public class RestPutMappingAction extends BaseRestHandler { @Inject - public RestPutMappingAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestPutMappingAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(PUT, "/{index}/_mapping/", this); controller.registerHandler(PUT, "/{index}/{type}/_mapping", this); controller.registerHandler(PUT, "/{index}/_mapping/{type}", this); @@ -68,7 +68,7 @@ public class RestPutMappingAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index"))); putMappingRequest.type(request.param("type")); putMappingRequest.source(request.content().toUtf8()); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/open/RestOpenIndexAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/open/RestOpenIndexAction.java index 58bda9d3a3d..9f27d8e3666 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/open/RestOpenIndexAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/open/RestOpenIndexAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.open; import org.elasticsearch.action.admin.indices.open.OpenIndexRequest; import org.elasticsearch.action.admin.indices.open.OpenIndexResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -38,14 +38,14 @@ import org.elasticsearch.rest.action.support.AcknowledgedRestListener; public class RestOpenIndexAction extends BaseRestHandler { @Inject - public RestOpenIndexAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestOpenIndexAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.POST, "/_open", this); controller.registerHandler(RestRequest.Method.POST, "/{index}/_open", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { OpenIndexRequest openIndexRequest = new OpenIndexRequest(Strings.splitStringByCommaToArray(request.param("index"))); openIndexRequest.timeout(request.paramAsTime("timeout", openIndexRequest.timeout())); openIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", openIndexRequest.masterNodeTimeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/recovery/RestRecoveryAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/recovery/RestRecoveryAction.java index 88bc9fb8c9f..6178d2559b5 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/recovery/RestRecoveryAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/recovery/RestRecoveryAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.recovery; import org.elasticsearch.action.admin.indices.recovery.RecoveryRequest; import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -44,14 +44,14 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestRecoveryAction extends BaseRestHandler { @Inject - public RestRecoveryAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestRecoveryAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_recovery", this); controller.registerHandler(GET, "/{index}/_recovery", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final RecoveryRequest recoveryRequest = new RecoveryRequest(Strings.splitStringByCommaToArray(request.param("index"))); recoveryRequest.detailed(request.paramAsBoolean("detailed", false)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/refresh/RestRefreshAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/refresh/RestRefreshAction.java index fcc6d240b34..6e2fcec3f51 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/refresh/RestRefreshAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/refresh/RestRefreshAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.refresh; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -46,8 +46,8 @@ import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastSh public class RestRefreshAction extends BaseRestHandler { @Inject - public RestRefreshAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestRefreshAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/_refresh", this); controller.registerHandler(POST, "/{index}/_refresh", this); @@ -56,7 +56,7 @@ public class RestRefreshAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { RefreshRequest refreshRequest = new RefreshRequest(Strings.splitStringByCommaToArray(request.param("index"))); refreshRequest.indicesOptions(IndicesOptions.fromRequest(request, refreshRequest.indicesOptions())); client.admin().indices().refresh(refreshRequest, new RestBuilderListener(channel) { diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/segments/RestIndicesSegmentsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/segments/RestIndicesSegmentsAction.java index da76a769ce4..a1d5560e674 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/segments/RestIndicesSegmentsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/segments/RestIndicesSegmentsAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.segments; import org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse; import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -44,14 +44,14 @@ import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastSh public class RestIndicesSegmentsAction extends BaseRestHandler { @Inject - public RestIndicesSegmentsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestIndicesSegmentsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_segments", this); controller.registerHandler(GET, "/{index}/_segments", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { IndicesSegmentsRequest indicesSegmentsRequest = new IndicesSegmentsRequest(Strings.splitStringByCommaToArray(request.param("index"))); indicesSegmentsRequest.verbose(request.paramAsBoolean("verbose", false)); indicesSegmentsRequest.indicesOptions(IndicesOptions.fromRequest(request, indicesSegmentsRequest.indicesOptions())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestGetSettingsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestGetSettingsAction.java index 8c24e2c68e3..46a101161b6 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestGetSettingsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestGetSettingsAction.java @@ -23,7 +23,7 @@ import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest; import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.IndexScopedSettings; @@ -47,8 +47,8 @@ public class RestGetSettingsAction extends BaseRestHandler { private final SettingsFilter settingsFilter; @Inject - public RestGetSettingsAction(Settings settings, RestController controller, Client client, IndexScopedSettings indexScopedSettings, final SettingsFilter settingsFilter) { - super(settings, client); + public RestGetSettingsAction(Settings settings, RestController controller, IndexScopedSettings indexScopedSettings, final SettingsFilter settingsFilter) { + super(settings); this.indexScopedSettings = indexScopedSettings; controller.registerHandler(GET, "/{index}/_settings/{name}", this); controller.registerHandler(GET, "/_settings/{name}", this); @@ -57,7 +57,7 @@ public class RestGetSettingsAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] names = request.paramAsStringArrayOrEmptyIfAll("name"); final boolean renderDefaults = request.paramAsBoolean("include_defaults", false); GetSettingsRequest getSettingsRequest = new GetSettingsRequest() diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java index 5bd102594d7..70608930917 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/settings/RestUpdateSettingsAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.admin.indices.settings; import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -53,14 +53,14 @@ public class RestUpdateSettingsAction extends BaseRestHandler { "allow_no_indices")); @Inject - public RestUpdateSettingsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestUpdateSettingsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.PUT, "/{index}/_settings", this); controller.registerHandler(RestRequest.Method.PUT, "/_settings", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { UpdateSettingsRequest updateSettingsRequest = updateSettingsRequest(Strings.splitStringByCommaToArray(request.param("index"))); updateSettingsRequest.timeout(request.paramAsTime("timeout", updateSettingsRequest.timeout())); updateSettingsRequest.setPreserveExisting(request.paramAsBoolean("preserve_existing", updateSettingsRequest.isPreserveExisting())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/shards/RestIndicesShardStoresAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/shards/RestIndicesShardStoresAction.java index 586599c1a1e..8a0d61c933c 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/shards/RestIndicesShardStoresAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/shards/RestIndicesShardStoresAction.java @@ -23,7 +23,7 @@ import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresAction; import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresRequest; import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -45,14 +45,14 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestIndicesShardStoresAction extends BaseRestHandler { @Inject - public RestIndicesShardStoresAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestIndicesShardStoresAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_shard_stores", this); controller.registerHandler(GET, "/{index}/_shard_stores", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { IndicesShardStoresRequest indicesShardStoresRequest = new IndicesShardStoresRequest(Strings.splitStringByCommaToArray(request.param("index"))); if (request.hasParam("status")) { indicesShardStoresRequest.shardStatuses(Strings.splitStringByCommaToArray(request.param("status"))); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java index 623e60cb4b9..93a1dea9b5e 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.admin.indices.stats; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -46,8 +46,8 @@ import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastSh public class RestIndicesStatsAction extends BaseRestHandler { @Inject - public RestIndicesStatsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestIndicesStatsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_stats", this); controller.registerHandler(GET, "/_stats/{metric}", this); controller.registerHandler(GET, "/_stats/{metric}/{indexMetric}", this); @@ -56,7 +56,7 @@ public class RestIndicesStatsAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.indicesOptions(IndicesOptions.fromRequest(request, indicesStatsRequest.indicesOptions())); indicesStatsRequest.indices(Strings.splitStringByCommaToArray(request.param("index"))); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java index a59ab9ac704..00a029c34b9 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/delete/RestDeleteIndexTemplateAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.indices.template.delete; import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest; import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -35,13 +35,13 @@ import org.elasticsearch.rest.action.support.AcknowledgedRestListener; public class RestDeleteIndexTemplateAction extends BaseRestHandler { @Inject - public RestDeleteIndexTemplateAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestDeleteIndexTemplateAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.DELETE, "/_template/{name}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(request.param("name")); deleteIndexTemplateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexTemplateRequest.masterNodeTimeout())); client.admin().indices().deleteTemplate(deleteIndexTemplateRequest, new AcknowledgedRestListener(channel)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java index d62d97400c5..de4a0f00442 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/get/RestGetIndexTemplateAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.indices.template.get; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesRequest; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.IndexTemplateMetaData; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -49,15 +49,15 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestGetIndexTemplateAction extends BaseRestHandler { @Inject - public RestGetIndexTemplateAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestGetIndexTemplateAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_template", this); controller.registerHandler(GET, "/_template/{name}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] names = Strings.splitStringByCommaToArray(request.param("name")); GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(names); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/head/RestHeadIndexTemplateAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/head/RestHeadIndexTemplateAction.java index 2a40de984b9..b790782a01a 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/head/RestHeadIndexTemplateAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/head/RestHeadIndexTemplateAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.indices.template.head; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesRequest; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -42,14 +42,14 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestHeadIndexTemplateAction extends BaseRestHandler { @Inject - public RestHeadIndexTemplateAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestHeadIndexTemplateAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(HEAD, "/_template/{name}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(request.param("name")); getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local())); getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java index 0b08b64e89b..77f91cebdf7 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/template/put/RestPutIndexTemplateAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.admin.indices.template.put; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -35,15 +35,15 @@ import org.elasticsearch.rest.action.support.AcknowledgedRestListener; public class RestPutIndexTemplateAction extends BaseRestHandler { @Inject - public RestPutIndexTemplateAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestPutIndexTemplateAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.PUT, "/_template/{name}", this); controller.registerHandler(RestRequest.Method.POST, "/_template/{name}", this); } @SuppressWarnings({"unchecked"}) @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name")); putRequest.template(request.param("template", putRequest.template())); putRequest.order(request.paramAsInt("order", putRequest.order())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/upgrade/RestUpgradeAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/upgrade/RestUpgradeAction.java index 7c4c0f51b8e..ee2aa156adc 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/upgrade/RestUpgradeAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/upgrade/RestUpgradeAction.java @@ -23,7 +23,8 @@ import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusResponse; import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest; import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.inject.Inject; @@ -48,8 +49,8 @@ import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastSh public class RestUpgradeAction extends BaseRestHandler { @Inject - public RestUpgradeAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestUpgradeAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/_upgrade", this); controller.registerHandler(POST, "/{index}/_upgrade", this); @@ -58,7 +59,7 @@ public class RestUpgradeAction extends BaseRestHandler { } @Override - protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception { + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { if (request.method().equals(RestRequest.Method.GET)) { handleGet(request, channel, client); } else if (request.method().equals(RestRequest.Method.POST)) { @@ -66,7 +67,7 @@ public class RestUpgradeAction extends BaseRestHandler { } } - void handleGet(final RestRequest request, RestChannel channel, Client client) { + void handleGet(final RestRequest request, RestChannel channel, NodeClient client) { client.admin().indices().prepareUpgradeStatus(Strings.splitStringByCommaToArray(request.param("index"))) .execute(new RestBuilderListener(channel) { @Override @@ -79,7 +80,7 @@ public class RestUpgradeAction extends BaseRestHandler { }); } - void handlePost(final RestRequest request, RestChannel channel, Client client) { + void handlePost(final RestRequest request, RestChannel channel, NodeClient client) { UpgradeRequest upgradeReq = new UpgradeRequest(Strings.splitStringByCommaToArray(request.param("index"))); upgradeReq.upgradeOnlyAncientSegments(request.paramAsBoolean("only_ancient_segments", false)); client.admin().indices().upgrade(upgradeReq, new RestBuilderListener(channel) { diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java index 6ac71708e32..2000078e011 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java @@ -23,7 +23,7 @@ import org.elasticsearch.action.admin.indices.validate.query.QueryExplanation; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -55,8 +55,8 @@ public class RestValidateQueryAction extends BaseRestHandler { private final IndicesQueriesRegistry indicesQueriesRegistry; @Inject - public RestValidateQueryAction(Settings settings, RestController controller, Client client, IndicesQueriesRegistry indicesQueriesRegistry) { - super(settings, client); + public RestValidateQueryAction(Settings settings, RestController controller, IndicesQueriesRegistry indicesQueriesRegistry) { + super(settings); controller.registerHandler(GET, "/_validate/query", this); controller.registerHandler(POST, "/_validate/query", this); controller.registerHandler(GET, "/{index}/_validate/query", this); @@ -67,7 +67,7 @@ public class RestValidateQueryAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { ValidateQueryRequest validateQueryRequest = new ValidateQueryRequest(Strings.splitStringByCommaToArray(request.param("index"))); validateQueryRequest.indicesOptions(IndicesOptions.fromRequest(request, validateQueryRequest.indicesOptions())); validateQueryRequest.explain(request.paramAsBoolean("explain", false)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java b/core/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java index d9dbb21e804..623af6d2f47 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/bulk/RestBulkAction.java @@ -24,7 +24,7 @@ import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.BulkShardRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.Requests; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -56,8 +56,8 @@ public class RestBulkAction extends BaseRestHandler { private final boolean allowExplicitIndex; @Inject - public RestBulkAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestBulkAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/_bulk", this); controller.registerHandler(PUT, "/_bulk", this); @@ -70,7 +70,7 @@ public class RestBulkAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { BulkRequest bulkRequest = Requests.bulkRequest(); String defaultIndex = request.param("index"); String defaultType = request.param("type"); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/AbstractCatAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/AbstractCatAction.java index 12393f58007..a40463e3e27 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/AbstractCatAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/AbstractCatAction.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.rest.action.cat; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Table; import org.elasticsearch.common.io.UTF8StreamWriter; import org.elasticsearch.common.io.stream.BytesStreamOutput; @@ -38,18 +38,18 @@ import static org.elasticsearch.rest.action.support.RestTable.pad; */ public abstract class AbstractCatAction extends BaseRestHandler { - public AbstractCatAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public AbstractCatAction(Settings settings, RestController controller) { + super(settings); } - protected abstract void doRequest(final RestRequest request, final RestChannel channel, final Client client); + protected abstract void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client); protected abstract void documentation(StringBuilder sb); protected abstract Table getTableWithHeader(final RestRequest request); @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { boolean helpWanted = request.paramAsBoolean("help", false); if (helpWanted) { Table table = getTableWithHeader(request); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java index b322fef9f30..9c68d0abbc7 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestAliasAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.cat; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.AliasMetaData; import org.elasticsearch.common.Strings; import org.elasticsearch.common.Table; @@ -44,15 +44,15 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestAliasAction extends AbstractCatAction { @Inject - public RestAliasAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestAliasAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/aliases", this); controller.registerHandler(GET, "/_cat/aliases/{alias}", this); } @Override - protected void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + protected void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final GetAliasesRequest getAliasesRequest = request.hasParam("alias") ? new GetAliasesRequest(request.param("alias")) : new GetAliasesRequest(); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java index 4a64ef409db..146b52a63a0 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java @@ -26,7 +26,7 @@ import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.Strings; @@ -48,8 +48,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestAllocationAction extends AbstractCatAction { @Inject - public RestAllocationAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestAllocationAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/allocation", this); controller.registerHandler(GET, "/_cat/allocation/{nodes}", this); } @@ -60,7 +60,7 @@ public class RestAllocationAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] nodes = Strings.splitStringByCommaToArray(request.param("nodes", "data:true")); final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().routingTable(true); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestCatAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestCatAction.java index 23229540b96..b9cc5011a81 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestCatAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestCatAction.java @@ -19,7 +19,7 @@ package org.elasticsearch.rest.action.cat; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -40,8 +40,8 @@ public class RestCatAction extends BaseRestHandler { private final String HELP; @Inject - public RestCatAction(Settings settings, RestController controller, Set catActions, Client client) { - super(settings, client); + public RestCatAction(Settings settings, RestController controller, Set catActions) { + super(settings); controller.registerHandler(GET, "/_cat", this); StringBuilder sb = new StringBuilder(); sb.append(CAT_NL); @@ -52,7 +52,7 @@ public class RestCatAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { channel.sendResponse(new BytesRestResponse(RestStatus.OK, HELP)); } } diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestCountAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestCountAction.java index 46e8fadd05a..032fd5c3aba 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestCountAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestCountAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.cat; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.Table; import org.elasticsearch.common.bytes.BytesArray; @@ -45,8 +45,8 @@ public class RestCountAction extends AbstractCatAction { private final IndicesQueriesRegistry indicesQueriesRegistry; @Inject - public RestCountAction(Settings settings, RestController restController, RestController controller, Client client, IndicesQueriesRegistry indicesQueriesRegistry) { - super(settings, controller, client); + public RestCountAction(Settings settings, RestController restController, RestController controller, IndicesQueriesRegistry indicesQueriesRegistry) { + super(settings, controller); restController.registerHandler(GET, "/_cat/count", this); restController.registerHandler(GET, "/_cat/count/{index}", this); this.indicesQueriesRegistry = indicesQueriesRegistry; @@ -59,7 +59,7 @@ public class RestCountAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String[] indices = Strings.splitStringByCommaToArray(request.param("index")); SearchRequest countRequest = new SearchRequest(indices); String source = request.param("source"); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java index 8febf04e892..d3458b40d77 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java @@ -23,7 +23,7 @@ import com.carrotsearch.hppc.cursors.ObjectLongCursor; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Table; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -43,14 +43,14 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestFielddataAction extends AbstractCatAction { @Inject - public RestFielddataAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestFielddataAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/fielddata", this); controller.registerHandler(GET, "/_cat/fielddata/{fields}", this); } @Override - protected void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + protected void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final NodesStatsRequest nodesStatsRequest = new NodesStatsRequest("data:true"); nodesStatsRequest.clear(); nodesStatsRequest.indices(true); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestHealthAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestHealthAction.java index 7dc7954a3a4..07f36cc2f6d 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestHealthAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestHealthAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.cat; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Table; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -39,8 +39,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestHealthAction extends AbstractCatAction { @Inject - public RestHealthAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestHealthAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/health", this); } @@ -50,7 +50,7 @@ public class RestHealthAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { ClusterHealthRequest clusterHealthRequest = new ClusterHealthRequest(); client.admin().cluster().health(clusterHealthRequest, new RestResponseListener(channel) { diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java index 38cbba6fd5a..fcdfe009e18 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java @@ -27,7 +27,7 @@ import org.elasticsearch.action.admin.indices.stats.IndexStats; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.health.ClusterIndexHealth; @@ -57,8 +57,8 @@ public class RestIndicesAction extends AbstractCatAction { private final IndexNameExpressionResolver indexNameExpressionResolver; @Inject - public RestIndicesAction(Settings settings, RestController controller, Client client, IndexNameExpressionResolver indexNameExpressionResolver) { - super(settings, controller, client); + public RestIndicesAction(Settings settings, RestController controller, IndexNameExpressionResolver indexNameExpressionResolver) { + super(settings, controller); this.indexNameExpressionResolver = indexNameExpressionResolver; controller.registerHandler(GET, "/_cat/indices", this); controller.registerHandler(GET, "/_cat/indices/{index}", this); @@ -71,7 +71,7 @@ public class RestIndicesAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().indices(indices).metaData(true); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java index e7a7d7afc96..164c2f79dac 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestMasterAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.cat; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Table; @@ -39,8 +39,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestMasterAction extends AbstractCatAction { @Inject - public RestMasterAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestMasterAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/master", this); } @@ -50,7 +50,7 @@ public class RestMasterAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().nodes(true); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java index 2190e1e2993..815895a2679 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodeAttrsAction.java @@ -24,7 +24,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Strings; @@ -47,8 +47,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestNodeAttrsAction extends AbstractCatAction { @Inject - public RestNodeAttrsAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestNodeAttrsAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/nodeattrs", this); } @@ -58,7 +58,7 @@ public class RestNodeAttrsAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().nodes(true); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java index 1069a879d94..cb7bd59be3c 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java @@ -27,7 +27,7 @@ import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Strings; @@ -72,8 +72,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestNodesAction extends AbstractCatAction { @Inject - public RestNodesAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestNodesAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/nodes", this); } @@ -83,7 +83,7 @@ public class RestNodesAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().nodes(true); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestPendingClusterTasksAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestPendingClusterTasksAction.java index b563450f8f6..b85906e25b4 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestPendingClusterTasksAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestPendingClusterTasksAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.cat; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest; import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.service.PendingClusterTask; import org.elasticsearch.common.Table; import org.elasticsearch.common.inject.Inject; @@ -37,8 +37,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestPendingClusterTasksAction extends AbstractCatAction { @Inject - public RestPendingClusterTasksAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestPendingClusterTasksAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/pending_tasks", this); } @@ -48,7 +48,7 @@ public class RestPendingClusterTasksAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { PendingClusterTasksRequest pendingClusterTasksRequest = new PendingClusterTasksRequest(); pendingClusterTasksRequest.masterNodeTimeout(request.paramAsTime("master_timeout", pendingClusterTasksRequest.masterNodeTimeout())); pendingClusterTasksRequest.local(request.paramAsBoolean("local", pendingClusterTasksRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java index 189273a7722..13e1f2176d7 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestPluginsAction.java @@ -24,7 +24,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Table; @@ -44,8 +44,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestPluginsAction extends AbstractCatAction { @Inject - public RestPluginsAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestPluginsAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/plugins", this); } @@ -55,7 +55,7 @@ public class RestPluginsAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().nodes(true); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestRecoveryAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestRecoveryAction.java index 07c2611f2ce..6308ce7e689 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestRecoveryAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestRecoveryAction.java @@ -23,7 +23,7 @@ import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.action.admin.indices.recovery.RecoveryRequest; import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.Table; import org.elasticsearch.common.inject.Inject; @@ -51,8 +51,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestRecoveryAction extends AbstractCatAction { @Inject - public RestRecoveryAction(Settings settings, RestController restController, RestController controller, Client client) { - super(settings, controller, client); + public RestRecoveryAction(Settings settings, RestController restController, RestController controller) { + super(settings, controller); restController.registerHandler(GET, "/_cat/recovery", this); restController.registerHandler(GET, "/_cat/recovery/{index}", this); } @@ -64,7 +64,7 @@ public class RestRecoveryAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final RecoveryRequest recoveryRequest = new RecoveryRequest(Strings.splitStringByCommaToArray(request.param("index"))); recoveryRequest.detailed(request.paramAsBoolean("detailed", false)); recoveryRequest.activeOnly(request.paramAsBoolean("active_only", false)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestRepositoriesAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestRepositoriesAction.java index d19e2b19ca0..ee53e1241c7 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestRepositoriesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestRepositoriesAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.cat; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest; import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.RepositoryMetaData; import org.elasticsearch.common.Table; import org.elasticsearch.common.inject.Inject; @@ -40,13 +40,13 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; */ public class RestRepositoriesAction extends AbstractCatAction { @Inject - public RestRepositoriesAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestRepositoriesAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/repositories", this); } @Override - protected void doRequest(RestRequest request, RestChannel channel, Client client) { + protected void doRequest(RestRequest request, RestChannel channel, NodeClient client) { GetRepositoriesRequest getRepositoriesRequest = new GetRepositoriesRequest(); getRepositoriesRequest.local(request.paramAsBoolean("local", getRepositoriesRequest.local())); getRepositoriesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRepositoriesRequest.masterNodeTimeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestSegmentsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestSegmentsAction.java index e5a1b4b49a3..2540e194d84 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestSegmentsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestSegmentsAction.java @@ -26,7 +26,7 @@ import org.elasticsearch.action.admin.indices.segments.IndexShardSegments; import org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse; import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest; import org.elasticsearch.action.admin.indices.segments.ShardSegments; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Strings; import org.elasticsearch.common.Table; @@ -49,14 +49,14 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestSegmentsAction extends AbstractCatAction { @Inject - public RestSegmentsAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestSegmentsAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/segments", this); controller.registerHandler(GET, "/_cat/segments/{index}", this); } @Override - protected void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + protected void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java index 0f6bec367d5..214979aef66 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java @@ -25,7 +25,7 @@ import org.elasticsearch.action.admin.indices.stats.CommonStats; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; import org.elasticsearch.action.admin.indices.stats.ShardStats; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.UnassignedInfo; @@ -49,8 +49,8 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; public class RestShardsAction extends AbstractCatAction { @Inject - public RestShardsAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestShardsAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/shards", this); controller.registerHandler(GET, "/_cat/shards/{index}", this); } @@ -62,7 +62,7 @@ public class RestShardsAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestSnapshotAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestSnapshotAction.java index 94d178e4db9..e503118fbab 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestSnapshotAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestSnapshotAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.cat; import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest; import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Table; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -47,13 +47,13 @@ import static org.elasticsearch.rest.RestRequest.Method.GET; */ public class RestSnapshotAction extends AbstractCatAction { @Inject - public RestSnapshotAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestSnapshotAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/snapshots/{repository}", this); } @Override - protected void doRequest(final RestRequest request, RestChannel channel, Client client) { + protected void doRequest(final RestRequest request, RestChannel channel, NodeClient client) { GetSnapshotsRequest getSnapshotsRequest = new GetSnapshotsRequest() .repository(request.param("repository")) .snapshots(new String[]{GetSnapshotsRequest.ALL_SNAPSHOTS}); diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java index 9bb01a7b166..7486acfbb80 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestTasksAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.cat; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse; import org.elasticsearch.action.admin.cluster.node.tasks.list.TaskGroup; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; @@ -51,8 +51,8 @@ public class RestTasksAction extends AbstractCatAction { private final ClusterService clusterService; @Inject - public RestTasksAction(Settings settings, RestController controller, Client client, ClusterService clusterService) { - super(settings, controller, client); + public RestTasksAction(Settings settings, RestController controller, ClusterService clusterService) { + super(settings, controller); controller.registerHandler(GET, "/_cat/tasks", this); this.clusterService = clusterService; } @@ -63,7 +63,7 @@ public class RestTasksAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { client.admin().cluster().listTasks(generateListTasksRequest(request), new RestResponseListener(channel) { @Override public RestResponse buildResponse(ListTasksResponse listTasksResponse) throws Exception { diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java index 2ade4a1db39..caf28a9b018 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java @@ -27,7 +27,7 @@ import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Strings; @@ -108,8 +108,8 @@ public class RestThreadPoolAction extends AbstractCatAction { } @Inject - public RestThreadPoolAction(Settings settings, RestController controller, Client client) { - super(settings, controller, client); + public RestThreadPoolAction(Settings settings, RestController controller) { + super(settings, controller); controller.registerHandler(GET, "/_cat/thread_pool", this); } @@ -119,7 +119,7 @@ public class RestThreadPoolAction extends AbstractCatAction { } @Override - public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().nodes(true); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java b/core/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java index 71e5832071c..d75bb7a0bac 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/count/RestCountAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.count; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.inject.Inject; @@ -53,8 +53,8 @@ public class RestCountAction extends BaseRestHandler { private final IndicesQueriesRegistry indicesQueriesRegistry; @Inject - public RestCountAction(Settings settings, RestController controller, Client client, IndicesQueriesRegistry indicesQueriesRegistry) { - super(settings, client); + public RestCountAction(Settings settings, RestController controller, IndicesQueriesRegistry indicesQueriesRegistry) { + super(settings); controller.registerHandler(POST, "/_count", this); controller.registerHandler(GET, "/_count", this); controller.registerHandler(POST, "/{index}/_count", this); @@ -65,7 +65,7 @@ public class RestCountAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { SearchRequest countRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index"))); countRequest.indicesOptions(IndicesOptions.fromRequest(request, countRequest.indicesOptions())); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0); diff --git a/core/src/main/java/org/elasticsearch/rest/action/delete/RestDeleteAction.java b/core/src/main/java/org/elasticsearch/rest/action/delete/RestDeleteAction.java index 29316893504..2f9b10096cc 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/delete/RestDeleteAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/delete/RestDeleteAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.delete; import org.elasticsearch.action.WriteConsistencyLevel; import org.elasticsearch.action.delete.DeleteRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.VersionType; @@ -40,13 +40,13 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteAction extends BaseRestHandler { @Inject - public RestDeleteAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestDeleteAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(DELETE, "/{index}/{type}/{id}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id")); deleteRequest.routing(request.param("routing")); deleteRequest.parent(request.param("parent")); // order is important, set it after routing, so it will set the routing diff --git a/core/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java b/core/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java index 47f5e7da19b..19f55f4cd46 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.explain; import org.apache.lucene.search.Explanation; import org.elasticsearch.action.explain.ExplainRequest; import org.elasticsearch.action.explain.ExplainResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.inject.Inject; @@ -56,15 +56,15 @@ public class RestExplainAction extends BaseRestHandler { private final IndicesQueriesRegistry indicesQueriesRegistry; @Inject - public RestExplainAction(Settings settings, RestController controller, Client client, IndicesQueriesRegistry indicesQueriesRegistry) { - super(settings, client); + public RestExplainAction(Settings settings, RestController controller, IndicesQueriesRegistry indicesQueriesRegistry) { + super(settings); this.indicesQueriesRegistry = indicesQueriesRegistry; controller.registerHandler(GET, "/{index}/{type}/{id}/_explain", this); controller.registerHandler(POST, "/{index}/{type}/{id}/_explain", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final ExplainRequest explainRequest = new ExplainRequest(request.param("index"), request.param("type"), request.param("id")); explainRequest.parent(request.param("parent")); explainRequest.routing(request.param("routing")); diff --git a/core/src/main/java/org/elasticsearch/rest/action/fieldstats/RestFieldStatsAction.java b/core/src/main/java/org/elasticsearch/rest/action/fieldstats/RestFieldStatsAction.java index 744a76e7352..9f62024ab80 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/fieldstats/RestFieldStatsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/fieldstats/RestFieldStatsAction.java @@ -23,7 +23,7 @@ import org.elasticsearch.action.fieldstats.FieldStats; import org.elasticsearch.action.fieldstats.FieldStatsRequest; import org.elasticsearch.action.fieldstats.FieldStatsResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -49,8 +49,8 @@ import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastSh public class RestFieldStatsAction extends BaseRestHandler { @Inject - public RestFieldStatsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestFieldStatsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_field_stats", this); controller.registerHandler(POST, "/_field_stats", this); controller.registerHandler(GET, "/{index}/_field_stats", this); @@ -59,7 +59,7 @@ public class RestFieldStatsAction extends BaseRestHandler { @Override public void handleRequest(final RestRequest request, - final RestChannel channel, final Client client) throws Exception { + final RestChannel channel, final NodeClient client) throws Exception { if (RestActions.hasBodyContent(request) && request.hasParam("fields")) { throw new IllegalArgumentException("can't specify a request body and [fields] request parameter, " + "either specify a request body or the [fields] request parameter"); diff --git a/core/src/main/java/org/elasticsearch/rest/action/get/RestGetAction.java b/core/src/main/java/org/elasticsearch/rest/action/get/RestGetAction.java index 193fdd2e747..3cc7d8fd1ae 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/get/RestGetAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/get/RestGetAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.get; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -47,13 +47,13 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestGetAction extends BaseRestHandler { @Inject - public RestGetAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestGetAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/{index}/{type}/{id}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final GetRequest getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); getRequest.operationThreaded(true); getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/get/RestGetSourceAction.java b/core/src/main/java/org/elasticsearch/rest/action/get/RestGetSourceAction.java index 7d8a39b02b9..9e9b54b5b0c 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/get/RestGetSourceAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/get/RestGetSourceAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.get; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -47,13 +47,13 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestGetSourceAction extends BaseRestHandler { @Inject - public RestGetSourceAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestGetSourceAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/{index}/{type}/{id}/_source", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final GetRequest getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); getRequest.operationThreaded(true); getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/get/RestHeadAction.java b/core/src/main/java/org/elasticsearch/rest/action/get/RestHeadAction.java index 01f3be435e7..ca8900ab77f 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/get/RestHeadAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/get/RestHeadAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.get; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.inject.Inject; @@ -49,8 +49,8 @@ public abstract class RestHeadAction extends BaseRestHandler { public static class Document extends RestHeadAction { @Inject - public Document(Settings settings, RestController controller, Client client) { - super(settings, client, false); + public Document(Settings settings, RestController controller) { + super(settings, false); controller.registerHandler(HEAD, "/{index}/{type}/{id}", this); } } @@ -61,8 +61,8 @@ public abstract class RestHeadAction extends BaseRestHandler { public static class Source extends RestHeadAction { @Inject - public Source(Settings settings, RestController controller, Client client) { - super(settings, client, true); + public Source(Settings settings, RestController controller) { + super(settings, true); controller.registerHandler(HEAD, "/{index}/{type}/{id}/_source", this); } } @@ -73,17 +73,16 @@ public abstract class RestHeadAction extends BaseRestHandler { * All subclasses must be registered in {@link org.elasticsearch.common.network.NetworkModule}. * * @param settings injected settings - * @param client injected client * @param source {@code false} to check for {@link GetResponse#isExists()}. * {@code true} to also check for {@link GetResponse#isSourceEmpty()}. */ - public RestHeadAction(Settings settings, Client client, boolean source) { - super(settings, client); + public RestHeadAction(Settings settings, boolean source) { + super(settings); this.source = source; } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { final GetRequest getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); getRequest.operationThreaded(true); getRequest.refresh(request.paramAsBoolean("refresh", getRequest.refresh())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/get/RestMultiGetAction.java b/core/src/main/java/org/elasticsearch/rest/action/get/RestMultiGetAction.java index 1722daa4445..de4f433dcbf 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/get/RestMultiGetAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/get/RestMultiGetAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.get; import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.action.get.MultiGetResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -41,8 +41,8 @@ public class RestMultiGetAction extends BaseRestHandler { private final boolean allowExplicitIndex; @Inject - public RestMultiGetAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestMultiGetAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_mget", this); controller.registerHandler(POST, "/_mget", this); controller.registerHandler(GET, "/{index}/_mget", this); @@ -54,7 +54,7 @@ public class RestMultiGetAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { MultiGetRequest multiGetRequest = new MultiGetRequest(); multiGetRequest.refresh(request.paramAsBoolean("refresh", multiGetRequest.refresh())); multiGetRequest.preference(request.param("preference")); diff --git a/core/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java b/core/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java index f807e68088a..884adcf0d81 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/index/RestIndexAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.index; import org.elasticsearch.action.WriteConsistencyLevel; import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -46,30 +46,30 @@ import static org.elasticsearch.rest.RestStatus.BAD_REQUEST; public class RestIndexAction extends BaseRestHandler { @Inject - public RestIndexAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestIndexAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/{index}/{type}", this); // auto id creation controller.registerHandler(PUT, "/{index}/{type}/{id}", this); controller.registerHandler(POST, "/{index}/{type}/{id}", this); - CreateHandler createHandler = new CreateHandler(settings, controller, client); + CreateHandler createHandler = new CreateHandler(settings, controller); controller.registerHandler(PUT, "/{index}/{type}/{id}/_create", createHandler); controller.registerHandler(POST, "/{index}/{type}/{id}/_create", createHandler); } final class CreateHandler extends BaseRestHandler { - protected CreateHandler(Settings settings, RestController controller, Client client) { - super(settings, client); + protected CreateHandler(Settings settings, RestController controller) { + super(settings); } @Override - public void handleRequest(RestRequest request, RestChannel channel, final Client client) { + public void handleRequest(RestRequest request, RestChannel channel, final NodeClient client) { request.params().put("op_type", "create"); RestIndexAction.this.handleRequest(request, channel, client); } } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { IndexRequest indexRequest = new IndexRequest(request.param("index"), request.param("type"), request.param("id")); indexRequest.routing(request.param("routing")); indexRequest.parent(request.param("parent")); // order is important, set it after routing, so it will set the routing diff --git a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestDeletePipelineAction.java b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestDeletePipelineAction.java index 6559e32817f..7c6200ee97c 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestDeletePipelineAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestDeletePipelineAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.ingest; import org.elasticsearch.action.ingest.DeletePipelineRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -32,13 +32,13 @@ import org.elasticsearch.rest.action.support.AcknowledgedRestListener; public class RestDeletePipelineAction extends BaseRestHandler { @Inject - public RestDeletePipelineAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestDeletePipelineAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.DELETE, "/_ingest/pipeline/{id}", this); } @Override - protected void handleRequest(RestRequest restRequest, RestChannel channel, Client client) throws Exception { + public void handleRequest(RestRequest restRequest, RestChannel channel, NodeClient client) throws Exception { DeletePipelineRequest request = new DeletePipelineRequest(restRequest.param("id")); request.masterNodeTimeout(restRequest.paramAsTime("master_timeout", request.masterNodeTimeout())); request.timeout(restRequest.paramAsTime("timeout", request.timeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestGetPipelineAction.java b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestGetPipelineAction.java index c11290329b3..55f14cfaa84 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestGetPipelineAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestGetPipelineAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.ingest; import org.elasticsearch.action.ingest.GetPipelineRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -33,13 +33,13 @@ import org.elasticsearch.rest.action.support.RestStatusToXContentListener; public class RestGetPipelineAction extends BaseRestHandler { @Inject - public RestGetPipelineAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestGetPipelineAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.GET, "/_ingest/pipeline/{id}", this); } @Override - protected void handleRequest(RestRequest restRequest, RestChannel channel, Client client) throws Exception { + public void handleRequest(RestRequest restRequest, RestChannel channel, NodeClient client) throws Exception { GetPipelineRequest request = new GetPipelineRequest(Strings.splitStringByCommaToArray(restRequest.param("id"))); request.masterNodeTimeout(restRequest.paramAsTime("master_timeout", request.masterNodeTimeout())); client.admin().cluster().getPipeline(request, new RestStatusToXContentListener<>(channel)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java index a96ed3d6424..7d7080e8775 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.ingest; import org.elasticsearch.action.ingest.PutPipelineRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -34,13 +34,13 @@ import org.elasticsearch.rest.action.support.RestActions; public class RestPutPipelineAction extends BaseRestHandler { @Inject - public RestPutPipelineAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestPutPipelineAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.PUT, "/_ingest/pipeline/{id}", this); } @Override - protected void handleRequest(RestRequest restRequest, RestChannel channel, Client client) throws Exception { + public void handleRequest(RestRequest restRequest, RestChannel channel, NodeClient client) throws Exception { PutPipelineRequest request = new PutPipelineRequest(restRequest.param("id"), RestActions.getRestContent(restRequest)); request.masterNodeTimeout(restRequest.paramAsTime("master_timeout", request.masterNodeTimeout())); request.timeout(restRequest.paramAsTime("timeout", request.timeout())); diff --git a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java index fc2e834ea75..35ba1367e63 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.rest.action.ingest; import org.elasticsearch.action.ingest.SimulatePipelineRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -34,8 +34,8 @@ import org.elasticsearch.rest.action.support.RestToXContentListener; public class RestSimulatePipelineAction extends BaseRestHandler { @Inject - public RestSimulatePipelineAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestSimulatePipelineAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.POST, "/_ingest/pipeline/{id}/_simulate", this); controller.registerHandler(RestRequest.Method.GET, "/_ingest/pipeline/{id}/_simulate", this); controller.registerHandler(RestRequest.Method.POST, "/_ingest/pipeline/_simulate", this); @@ -43,7 +43,7 @@ public class RestSimulatePipelineAction extends BaseRestHandler { } @Override - protected void handleRequest(RestRequest restRequest, RestChannel channel, Client client) throws Exception { + public void handleRequest(RestRequest restRequest, RestChannel channel, NodeClient client) throws Exception { SimulatePipelineRequest request = new SimulatePipelineRequest(RestActions.getRestContent(restRequest)); request.setId(restRequest.param("id")); request.setVerbose(restRequest.paramAsBoolean("verbose", false)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/main/RestMainAction.java b/core/src/main/java/org/elasticsearch/rest/action/main/RestMainAction.java index e57bb790e5e..24f4e66e7db 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/main/RestMainAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/main/RestMainAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.main; import org.elasticsearch.action.main.MainAction; import org.elasticsearch.action.main.MainRequest; import org.elasticsearch.action.main.MainResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -46,14 +46,14 @@ import static org.elasticsearch.rest.RestRequest.Method.HEAD; public class RestMainAction extends BaseRestHandler { @Inject - public RestMainAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestMainAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/", this); controller.registerHandler(HEAD, "/", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { client.execute(MainAction.INSTANCE, new MainRequest(), new RestBuilderListener(channel) { @Override public RestResponse buildResponse(MainResponse mainResponse, XContentBuilder builder) throws Exception { diff --git a/core/src/main/java/org/elasticsearch/rest/action/search/RestClearScrollAction.java b/core/src/main/java/org/elasticsearch/rest/action/search/RestClearScrollAction.java index 0dce23bf3b1..a189a58a3ae 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/search/RestClearScrollAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/search/RestClearScrollAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.search; import org.elasticsearch.action.search.ClearScrollRequest; import org.elasticsearch.action.search.ClearScrollResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.inject.Inject; @@ -46,15 +46,15 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestClearScrollAction extends BaseRestHandler { @Inject - public RestClearScrollAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestClearScrollAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(DELETE, "/_search/scroll", this); controller.registerHandler(DELETE, "/_search/scroll/{scroll_id}", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String scrollIds = request.param("scroll_id"); ClearScrollRequest clearRequest = new ClearScrollRequest(); clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds))); diff --git a/core/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java b/core/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java index 2935c88dab2..52965193a2e 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java @@ -23,7 +23,7 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.search.MultiSearchRequest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; @@ -64,9 +64,9 @@ public class RestMultiSearchAction extends BaseRestHandler { private final Suggesters suggesters; @Inject - public RestMultiSearchAction(Settings settings, RestController controller, Client client, IndicesQueriesRegistry indicesQueriesRegistry, + public RestMultiSearchAction(Settings settings, RestController controller, IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, Suggesters suggesters) { - super(settings, client); + super(settings); this.aggParsers = aggParsers; this.suggesters = suggesters; @@ -82,7 +82,7 @@ public class RestMultiSearchAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { MultiSearchRequest multiSearchRequest = parseRequest(request, allowExplicitIndex, indicesQueriesRegistry, parseFieldMatcher, aggParsers, suggesters); client.multiSearch(multiSearchRequest, new RestToXContentListener<>(channel)); diff --git a/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index 5f5fe84d573..870d4a9eb20 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.search; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; @@ -67,9 +67,9 @@ public class RestSearchAction extends BaseRestHandler { private final Suggesters suggesters; @Inject - public RestSearchAction(Settings settings, RestController controller, Client client, IndicesQueriesRegistry queryRegistry, + public RestSearchAction(Settings settings, RestController controller, IndicesQueriesRegistry queryRegistry, AggregatorParsers aggParsers, Suggesters suggesters) { - super(settings, client); + super(settings); this.queryRegistry = queryRegistry; this.aggParsers = aggParsers; this.suggesters = suggesters; @@ -82,7 +82,7 @@ public class RestSearchAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws IOException { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws IOException { SearchRequest searchRequest = new SearchRequest(); BytesReference restContent = RestActions.hasBodyContent(request) ? RestActions.getRestContent(request) : null; parseSearchRequest(searchRequest, queryRegistry, request, parseFieldMatcher, aggParsers, suggesters, restContent); diff --git a/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java b/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java index 3a10db38ee1..6b9b09545ad 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/search/RestSearchScrollAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.search; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -50,8 +50,8 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestSearchScrollAction extends BaseRestHandler { @Inject - public RestSearchScrollAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestSearchScrollAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_search/scroll", this); controller.registerHandler(POST, "/_search/scroll", this); @@ -60,7 +60,7 @@ public class RestSearchScrollAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { String scrollId = request.param("scroll_id"); SearchScrollRequest searchScrollRequest = new SearchScrollRequest(); searchScrollRequest.scrollId(scrollId); diff --git a/core/src/main/java/org/elasticsearch/rest/action/suggest/RestSuggestAction.java b/core/src/main/java/org/elasticsearch/rest/action/suggest/RestSuggestAction.java index c5c6174b02b..f6acfc6daf5 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/suggest/RestSuggestAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/suggest/RestSuggestAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.suggest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.inject.Inject; @@ -61,9 +61,9 @@ public class RestSuggestAction extends BaseRestHandler { private final Suggesters suggesters; @Inject - public RestSuggestAction(Settings settings, RestController controller, Client client, + public RestSuggestAction(Settings settings, RestController controller, IndicesQueriesRegistry queryRegistry, Suggesters suggesters) { - super(settings, client); + super(settings); this.queryRegistry = queryRegistry; this.suggesters = suggesters; controller.registerHandler(POST, "/_suggest", this); @@ -73,7 +73,7 @@ public class RestSuggestAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws IOException { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws IOException { final SearchRequest searchRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index")), new SearchSourceBuilder()); searchRequest.indicesOptions(IndicesOptions.fromRequest(request, searchRequest.indicesOptions())); if (RestActions.hasBodyContent(request)) { diff --git a/core/src/main/java/org/elasticsearch/rest/action/termvectors/RestMultiTermVectorsAction.java b/core/src/main/java/org/elasticsearch/rest/action/termvectors/RestMultiTermVectorsAction.java index dfcbeef171c..888d854f40c 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/termvectors/RestMultiTermVectorsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/termvectors/RestMultiTermVectorsAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.termvectors; import org.elasticsearch.action.termvectors.MultiTermVectorsRequest; import org.elasticsearch.action.termvectors.MultiTermVectorsResponse; import org.elasticsearch.action.termvectors.TermVectorsRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -39,8 +39,8 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestMultiTermVectorsAction extends BaseRestHandler { @Inject - public RestMultiTermVectorsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestMultiTermVectorsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_mtermvectors", this); controller.registerHandler(POST, "/_mtermvectors", this); controller.registerHandler(GET, "/{index}/_mtermvectors", this); @@ -50,7 +50,7 @@ public class RestMultiTermVectorsAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { MultiTermVectorsRequest multiTermVectorsRequest = new MultiTermVectorsRequest(); TermVectorsRequest template = new TermVectorsRequest(); template.index(request.param("index")); diff --git a/core/src/main/java/org/elasticsearch/rest/action/termvectors/RestTermVectorsAction.java b/core/src/main/java/org/elasticsearch/rest/action/termvectors/RestTermVectorsAction.java index d22afa615d8..6aa2d1bdb14 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/termvectors/RestTermVectorsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/termvectors/RestTermVectorsAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.termvectors; import org.elasticsearch.action.termvectors.TermVectorsRequest; import org.elasticsearch.action.termvectors.TermVectorsResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -48,8 +48,8 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestTermVectorsAction extends BaseRestHandler { @Inject - public RestTermVectorsAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestTermVectorsAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/{index}/{type}/_termvectors", this); controller.registerHandler(POST, "/{index}/{type}/_termvectors", this); controller.registerHandler(GET, "/{index}/{type}/{id}/_termvectors", this); @@ -63,7 +63,7 @@ public class RestTermVectorsAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { TermVectorsRequest termVectorsRequest = new TermVectorsRequest(request.param("index"), request.param("type"), request.param("id")); if (RestActions.hasBodyContent(request)) { try (XContentParser parser = XContentFactory.xContent(RestActions.guessBodyContentType(request)).createParser(RestActions.getRestContent(request))){ diff --git a/core/src/main/java/org/elasticsearch/rest/action/update/RestUpdateAction.java b/core/src/main/java/org/elasticsearch/rest/action/update/RestUpdateAction.java index bdea4e33e6d..7d739983bf4 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/update/RestUpdateAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/update/RestUpdateAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.rest.action.update; import org.elasticsearch.action.WriteConsistencyLevel; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.update.UpdateRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -47,13 +47,13 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestUpdateAction extends BaseRestHandler { @Inject - public RestUpdateAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestUpdateAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(POST, "/{index}/{type}/{id}/_update", this); } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { + public void handleRequest(final RestRequest request, final RestChannel channel, final NodeClient client) throws Exception { UpdateRequest updateRequest = new UpdateRequest(request.param("index"), request.param("type"), request.param("id")); updateRequest.routing(request.param("routing")); updateRequest.parent(request.param("parent")); diff --git a/core/src/test/java/org/elasticsearch/action/ActionModuleTests.java b/core/src/test/java/org/elasticsearch/action/ActionModuleTests.java index 4b9a833e8c4..87c1a227328 100644 --- a/core/src/test/java/org/elasticsearch/action/ActionModuleTests.java +++ b/core/src/test/java/org/elasticsearch/action/ActionModuleTests.java @@ -23,6 +23,7 @@ import org.elasticsearch.action.main.MainAction; import org.elasticsearch.action.main.TransportMainAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.TransportAction; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.ActionPlugin; @@ -115,7 +116,7 @@ public class ActionModuleTests extends ESTestCase { public void testPluginCanRegisterRestHandler() { class FakeHandler implements RestHandler { @Override - public void handleRequest(RestRequest request, RestChannel channel) throws Exception { + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { } } ActionPlugin registersFakeHandler = new ActionPlugin() { diff --git a/core/src/test/java/org/elasticsearch/common/network/NetworkModuleTests.java b/core/src/test/java/org/elasticsearch/common/network/NetworkModuleTests.java index 749ffa3c9d9..9ae0beadf59 100644 --- a/core/src/test/java/org/elasticsearch/common/network/NetworkModuleTests.java +++ b/core/src/test/java/org/elasticsearch/common/network/NetworkModuleTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.common.network; import org.elasticsearch.action.support.replication.ReplicationTask; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Table; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.ModuleTestCase; @@ -87,18 +87,18 @@ public class NetworkModuleTests extends ModuleTestCase { static class FakeRestHandler extends BaseRestHandler { public FakeRestHandler() { - super(null, null); + super(null); } @Override - protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception {} + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {} } static class FakeCatRestHandler extends AbstractCatAction { public FakeCatRestHandler() { - super(null, null, null); + super(null, null); } @Override - protected void doRequest(RestRequest request, RestChannel channel, Client client) {} + protected void doRequest(RestRequest request, RestChannel channel, NodeClient client) {} @Override protected void documentation(StringBuilder sb) {} @Override diff --git a/core/src/test/java/org/elasticsearch/http/HttpServerTests.java b/core/src/test/java/org/elasticsearch/http/HttpServerTests.java index 2ba7da84c14..ce0c78c1c92 100644 --- a/core/src/test/java/org/elasticsearch/http/HttpServerTests.java +++ b/core/src/test/java/org/elasticsearch/http/HttpServerTests.java @@ -66,9 +66,9 @@ public class HttpServerTests extends ESTestCase { HttpServerTransport httpServerTransport = new TestHttpServerTransport(); RestController restController = new RestController(settings); restController.registerHandler(RestRequest.Method.GET, "/", - (request, channel) -> channel.sendResponse( + (request, channel, client) -> channel.sendResponse( new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY))); - restController.registerHandler(RestRequest.Method.GET, "/error", (request, channel) -> { + restController.registerHandler(RestRequest.Method.GET, "/error", (request, channel, client) -> { throw new IllegalArgumentException("test error"); }); @@ -76,7 +76,7 @@ public class HttpServerTests extends ESTestCase { new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), null); NodeService nodeService = new NodeService(Settings.EMPTY, null, null, null, null, null, null, null, null, clusterService, null); - httpServer = new HttpServer(settings, httpServerTransport, restController, nodeService, circuitBreakerService); + httpServer = new HttpServer(settings, httpServerTransport, restController, nodeService, null, circuitBreakerService); httpServer.start(); } diff --git a/core/src/test/java/org/elasticsearch/plugins/responseheader/TestResponseHeaderRestAction.java b/core/src/test/java/org/elasticsearch/plugins/responseheader/TestResponseHeaderRestAction.java index 39432bd01ea..499b6fadc93 100644 --- a/core/src/test/java/org/elasticsearch/plugins/responseheader/TestResponseHeaderRestAction.java +++ b/core/src/test/java/org/elasticsearch/plugins/responseheader/TestResponseHeaderRestAction.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.plugins.responseheader; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -32,13 +32,13 @@ import org.elasticsearch.rest.RestStatus; public class TestResponseHeaderRestAction extends BaseRestHandler { @Inject - public TestResponseHeaderRestAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public TestResponseHeaderRestAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(RestRequest.Method.GET, "/_protected", this); } @Override - public void handleRequest(RestRequest request, RestChannel channel, Client client) { + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) { if ("password".equals(request.header("Secret"))) { RestResponse response = new BytesRestResponse(RestStatus.OK, "Access granted"); response.addHeader("Secret", "granted"); diff --git a/core/src/test/java/org/elasticsearch/rest/RestControllerTests.java b/core/src/test/java/org/elasticsearch/rest/RestControllerTests.java index 9cade7aa513..834afe5d5cd 100644 --- a/core/src/test/java/org/elasticsearch/rest/RestControllerTests.java +++ b/core/src/test/java/org/elasticsearch/rest/RestControllerTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.rest; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.test.ESTestCase; @@ -78,7 +79,7 @@ public class RestControllerTests extends ESTestCase { } @Override - void executeHandler(RestRequest request, RestChannel channel) throws Exception { + void executeHandler(RestRequest request, RestChannel channel, NodeClient client) throws Exception { assertEquals("true", threadContext.getHeader("header.1")); assertEquals("true", threadContext.getHeader("header.2")); assertNull(threadContext.getHeader("header.3")); @@ -91,7 +92,7 @@ public class RestControllerTests extends ESTestCase { restHeaders.put("header.1", "true"); restHeaders.put("header.2", "true"); restHeaders.put("header.3", "false"); - restController.dispatchRequest(new FakeRestRequest.Builder().withHeaders(restHeaders).build(), null, threadContext); + restController.dispatchRequest(new FakeRestRequest.Builder().withHeaders(restHeaders).build(), null, null, threadContext); assertNull(threadContext.getHeader("header.1")); assertNull(threadContext.getHeader("header.2")); assertEquals("true", threadContext.getHeader("header.3")); @@ -117,7 +118,7 @@ public class RestControllerTests extends ESTestCase { } @Override - public void handleRequest(RestRequest request, RestChannel channel) throws Exception { + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { //no op } diff --git a/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java b/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java index 51f36d1e25f..dd6d1dac47b 100644 --- a/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java +++ b/core/src/test/java/org/elasticsearch/rest/RestFilterChainTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.rest; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; @@ -71,16 +72,13 @@ public class RestFilterChainTests extends ESTestCase { } } - restController.registerHandler(RestRequest.Method.GET, "/", new RestHandler() { - @Override - public void handleRequest(RestRequest request, RestChannel channel) throws Exception { - channel.sendResponse(new TestResponse()); - } + restController.registerHandler(RestRequest.Method.GET, "/", (request, channel, client) -> { + channel.sendResponse(new TestResponse()); }); FakeRestRequest fakeRestRequest = new FakeRestRequest(); FakeRestChannel fakeRestChannel = new FakeRestChannel(fakeRestRequest, randomBoolean(), 1); - restController.dispatchRequest(fakeRestRequest, fakeRestChannel, new ThreadContext(Settings.EMPTY)); + restController.dispatchRequest(fakeRestRequest, fakeRestChannel, null, new ThreadContext(Settings.EMPTY)); assertThat(fakeRestChannel.await(), equalTo(true)); @@ -117,12 +115,9 @@ public class RestFilterChainTests extends ESTestCase { final int additionalContinueCount = randomInt(10); - TestFilter testFilter = new TestFilter(randomInt(), new Callback() { - @Override - public void execute(final RestRequest request, final RestChannel channel, final RestFilterChain filterChain) throws Exception { - for (int i = 0; i <= additionalContinueCount; i++) { - filterChain.continueProcessing(request, channel); - } + TestFilter testFilter = new TestFilter(randomInt(), (request, channel, client, filterChain) -> { + for (int i = 0; i <= additionalContinueCount; i++) { + filterChain.continueProcessing(request, channel, null); } }); @@ -131,14 +126,14 @@ public class RestFilterChainTests extends ESTestCase { restController.registerHandler(RestRequest.Method.GET, "/", new RestHandler() { @Override - public void handleRequest(RestRequest request, RestChannel channel) throws Exception { + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { channel.sendResponse(new TestResponse()); } }); FakeRestRequest fakeRestRequest = new FakeRestRequest(); FakeRestChannel fakeRestChannel = new FakeRestChannel(fakeRestRequest, randomBoolean(), additionalContinueCount + 1); - restController.dispatchRequest(fakeRestRequest, fakeRestChannel, new ThreadContext(Settings.EMPTY)); + restController.dispatchRequest(fakeRestRequest, fakeRestChannel, null, new ThreadContext(Settings.EMPTY)); fakeRestChannel.await(); assertThat(testFilter.runs.get(), equalTo(1)); @@ -150,20 +145,20 @@ public class RestFilterChainTests extends ESTestCase { private static enum Operation implements Callback { CONTINUE_PROCESSING { @Override - public void execute(RestRequest request, RestChannel channel, RestFilterChain filterChain) throws Exception { - filterChain.continueProcessing(request, channel); + public void execute(RestRequest request, RestChannel channel, NodeClient client, RestFilterChain filterChain) throws Exception { + filterChain.continueProcessing(request, channel, client); } }, CHANNEL_RESPONSE { @Override - public void execute(RestRequest request, RestChannel channel, RestFilterChain filterChain) throws Exception { + public void execute(RestRequest request, RestChannel channel, NodeClient client, RestFilterChain filterChain) throws Exception { channel.sendResponse(new TestResponse()); } } } private static interface Callback { - void execute(RestRequest request, RestChannel channel, RestFilterChain filterChain) throws Exception; + void execute(RestRequest request, RestChannel channel, NodeClient client, RestFilterChain filterChain) throws Exception; } private final AtomicInteger counter = new AtomicInteger(); @@ -180,10 +175,10 @@ public class RestFilterChainTests extends ESTestCase { } @Override - public void process(RestRequest request, RestChannel channel, RestFilterChain filterChain) throws Exception { + public void process(RestRequest request, RestChannel channel, NodeClient client, RestFilterChain filterChain) throws Exception { this.runs.incrementAndGet(); this.executionToken = counter.incrementAndGet(); - this.callback.execute(request, channel, filterChain); + this.callback.execute(request, channel, client, filterChain); } @Override diff --git a/core/src/test/java/org/elasticsearch/rest/action/cat/RestRecoveryActionTests.java b/core/src/test/java/org/elasticsearch/rest/action/cat/RestRecoveryActionTests.java index b603ded8697..34275d78d7b 100644 --- a/core/src/test/java/org/elasticsearch/rest/action/cat/RestRecoveryActionTests.java +++ b/core/src/test/java/org/elasticsearch/rest/action/cat/RestRecoveryActionTests.java @@ -51,7 +51,7 @@ public class RestRecoveryActionTests extends ESTestCase { public void testRestRecoveryAction() { final Settings settings = Settings.EMPTY; final RestController restController = new RestController(settings); - final RestRecoveryAction action = new RestRecoveryAction(settings, restController, restController, null); + final RestRecoveryAction action = new RestRecoveryAction(settings, restController, restController); final int totalShards = randomIntBetween(1, 32); final int successfulShards = Math.max(0, totalShards - randomIntBetween(1, 2)); final int failedShards = totalShards - successfulShards; diff --git a/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java index 3ba6c875b68..19c508e2bb1 100644 --- a/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java +++ b/core/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java @@ -31,6 +31,7 @@ import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus; import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateUpdateTask; import org.elasticsearch.cluster.metadata.MetaData; @@ -635,6 +636,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest .put(MockRepository.Plugin.PASSWORD_SETTING.getKey(), "verysecretpassword") ).get(); + NodeClient nodeClient = internalCluster().getInstance(NodeClient.class); RestGetRepositoriesAction getRepoAction = internalCluster().getInstance(RestGetRepositoriesAction.class); RestRequest getRepoRequest = new FakeRestRequest(); getRepoRequest.params().put("repository", "test-repo"); @@ -651,7 +653,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest } getRepoLatch.countDown(); } - }); + }, nodeClient); assertTrue(getRepoLatch.await(1, TimeUnit.SECONDS)); if (getRepoError.get() != null) { throw getRepoError.get(); @@ -672,7 +674,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest } clusterStateLatch.countDown(); } - }); + }, nodeClient); assertTrue(clusterStateLatch.await(1, TimeUnit.SECONDS)); if (clusterStateError.get() != null) { throw clusterStateError.get(); diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestDeleteSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestDeleteSearchTemplateAction.java index 46bad569933..22adfe13ac4 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestDeleteSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestDeleteSearchTemplateAction.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.rest.action.search.template; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.RestController; @@ -31,8 +31,8 @@ import static org.elasticsearch.rest.RestRequest.Method.DELETE; public class RestDeleteSearchTemplateAction extends RestDeleteStoredScriptAction { @Inject - public RestDeleteSearchTemplateAction(Settings settings, RestController controller, Client client) { - super(settings, controller, false, client); + public RestDeleteSearchTemplateAction(Settings settings, RestController controller) { + super(settings, controller, false); controller.registerHandler(DELETE, "/_search/template/{id}", this); } diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestGetSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestGetSearchTemplateAction.java index 61fcaf1ccec..f92cdc02a67 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestGetSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestGetSearchTemplateAction.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.rest.action.search.template; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.RestController; @@ -33,8 +33,8 @@ public class RestGetSearchTemplateAction extends RestGetStoredScriptAction { private static final String TEMPLATE = "template"; @Inject - public RestGetSearchTemplateAction(Settings settings, RestController controller, Client client) { - super(settings, controller, false, client); + public RestGetSearchTemplateAction(Settings settings, RestController controller) { + super(settings, controller, false); controller.registerHandler(GET, "/_search/template/{id}", this); } diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestMultiSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestMultiSearchTemplateAction.java index 48f69dda50f..add4719ad93 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestMultiSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestMultiSearchTemplateAction.java @@ -24,7 +24,7 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.search.template.MultiSearchTemplateAction; import org.elasticsearch.action.search.template.MultiSearchTemplateRequest; import org.elasticsearch.action.search.template.SearchTemplateRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -45,8 +45,8 @@ public class RestMultiSearchTemplateAction extends BaseRestHandler { private final boolean allowExplicitIndex; @Inject - public RestMultiSearchTemplateAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestMultiSearchTemplateAction(Settings settings, RestController controller) { + super(settings); this.allowExplicitIndex = MULTI_ALLOW_EXPLICIT_INDEX.get(settings); controller.registerHandler(GET, "/_msearch/template", this); @@ -58,7 +58,7 @@ public class RestMultiSearchTemplateAction extends BaseRestHandler { } @Override - protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception { + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { if (RestActions.hasBodyContent(request) == false) { throw new ElasticsearchException("request body is required"); } diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestPutSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestPutSearchTemplateAction.java index 90854bee01c..48e98bc9237 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestPutSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestPutSearchTemplateAction.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.rest.action.search.template; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.RestController; @@ -32,8 +32,8 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT; public class RestPutSearchTemplateAction extends RestPutStoredScriptAction { @Inject - public RestPutSearchTemplateAction(Settings settings, RestController controller, Client client) { - super(settings, controller, false, client); + public RestPutSearchTemplateAction(Settings settings, RestController controller) { + super(settings, controller, false); controller.registerHandler(POST, "/_search/template/{id}", this); controller.registerHandler(PUT, "/_search/template/{id}", this); } diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestRenderSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestRenderSearchTemplateAction.java index 388837962c5..5e7e75e9c81 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestRenderSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestRenderSearchTemplateAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.rest.action.search.template; import org.elasticsearch.action.search.template.SearchTemplateAction; import org.elasticsearch.action.search.template.SearchTemplateRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -38,8 +38,8 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestRenderSearchTemplateAction extends BaseRestHandler { @Inject - public RestRenderSearchTemplateAction(Settings settings, RestController controller, Client client) { - super(settings, client); + public RestRenderSearchTemplateAction(Settings settings, RestController controller) { + super(settings); controller.registerHandler(GET, "/_render/template", this); controller.registerHandler(POST, "/_render/template", this); controller.registerHandler(GET, "/_render/template/{id}", this); @@ -47,7 +47,7 @@ public class RestRenderSearchTemplateAction extends BaseRestHandler { } @Override - protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception { + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { // Creates the render template request SearchTemplateRequest renderRequest = RestSearchTemplateAction.parse(RestActions.getRestContent(request)); renderRequest.setSimulate(true); diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestSearchTemplateAction.java index b15efa74420..131443da887 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/rest/action/search/template/RestSearchTemplateAction.java @@ -23,7 +23,7 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.template.SearchTemplateAction; import org.elasticsearch.action.search.template.SearchTemplateRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.ParseFieldMatcherSupplier; @@ -88,9 +88,9 @@ public class RestSearchTemplateAction extends BaseRestHandler { private final Suggesters suggesters; @Inject - public RestSearchTemplateAction(Settings settings, RestController controller, Client client, IndicesQueriesRegistry queryRegistry, + public RestSearchTemplateAction(Settings settings, RestController controller, IndicesQueriesRegistry queryRegistry, AggregatorParsers aggregatorParsers, Suggesters suggesters) { - super(settings, client); + super(settings); this.queryRegistry = queryRegistry; this.aggParsers = aggregatorParsers; this.suggesters = suggesters; @@ -104,7 +104,7 @@ public class RestSearchTemplateAction extends BaseRestHandler { } @Override - protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception { + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { if (RestActions.hasBodyContent(request) == false) { throw new ElasticsearchException("request body is required"); } diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/RestMultiPercolateAction.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/RestMultiPercolateAction.java index a2902a9a7c2..6461ab3028d 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/RestMultiPercolateAction.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/RestMultiPercolateAction.java @@ -19,7 +19,7 @@ package org.elasticsearch.percolator; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -39,9 +39,9 @@ public class RestMultiPercolateAction extends BaseRestHandler { private final TransportMultiPercolateAction action; @Inject - public RestMultiPercolateAction(Settings settings, RestController controller, Client client, + public RestMultiPercolateAction(Settings settings, RestController controller, TransportMultiPercolateAction action) { - super(settings, client); + super(settings); this.action = action; controller.registerHandler(POST, "/_mpercolate", this); controller.registerHandler(POST, "/{index}/_mpercolate", this); @@ -55,7 +55,7 @@ public class RestMultiPercolateAction extends BaseRestHandler { } @Override - public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, final Client client) throws Exception { + public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, final NodeClient client) throws Exception { MultiPercolateRequest multiPercolateRequest = new MultiPercolateRequest(); multiPercolateRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, multiPercolateRequest.indicesOptions())); multiPercolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("index"))); diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/RestPercolateAction.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/RestPercolateAction.java index b752cc55f6c..a09107eedda 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/RestPercolateAction.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/RestPercolateAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.percolator; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -40,26 +40,26 @@ public class RestPercolateAction extends BaseRestHandler { private final TransportPercolateAction action; @Inject - public RestPercolateAction(Settings settings, RestController controller, Client client, TransportPercolateAction action) { - super(settings, client); + public RestPercolateAction(Settings settings, RestController controller, TransportPercolateAction action) { + super(settings); this.action = action; controller.registerHandler(GET, "/{index}/{type}/_percolate", this); controller.registerHandler(POST, "/{index}/{type}/_percolate", this); - RestPercolateExistingDocHandler existingDocHandler = new RestPercolateExistingDocHandler(settings, controller, client); + RestPercolateExistingDocHandler existingDocHandler = new RestPercolateExistingDocHandler(settings, controller); controller.registerHandler(GET, "/{index}/{type}/{id}/_percolate", existingDocHandler); controller.registerHandler(POST, "/{index}/{type}/{id}/_percolate", existingDocHandler); - RestCountPercolateDocHandler countHandler = new RestCountPercolateDocHandler(settings, controller, client); + RestCountPercolateDocHandler countHandler = new RestCountPercolateDocHandler(settings, controller); controller.registerHandler(GET, "/{index}/{type}/_percolate/count", countHandler); controller.registerHandler(POST, "/{index}/{type}/_percolate/count", countHandler); - RestCountPercolateExistingDocHandler countExistingDocHandler = new RestCountPercolateExistingDocHandler(settings, controller, client); + RestCountPercolateExistingDocHandler countExistingDocHandler = new RestCountPercolateExistingDocHandler(settings, controller); controller.registerHandler(GET, "/{index}/{type}/{id}/_percolate/count", countExistingDocHandler); controller.registerHandler(POST, "/{index}/{type}/{id}/_percolate/count", countExistingDocHandler); } - void parseDocPercolate(PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel, final Client client) { + void parseDocPercolate(PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel) { percolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("index"))); percolateRequest.documentType(restRequest.param("type")); percolateRequest.routing(restRequest.param("routing")); @@ -70,7 +70,7 @@ public class RestPercolateAction extends BaseRestHandler { executePercolate(percolateRequest, restChannel); } - void parseExistingDocPercolate(PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel, final Client client) { + void parseExistingDocPercolate(PercolateRequest percolateRequest, RestRequest restRequest, RestChannel restChannel) { String index = restRequest.param("index"); String type = restRequest.param("type"); percolateRequest.indices(Strings.splitStringByCommaToArray(restRequest.param("percolate_index", index))); @@ -99,49 +99,49 @@ public class RestPercolateAction extends BaseRestHandler { } @Override - public void handleRequest(RestRequest restRequest, RestChannel restChannel, final Client client) { + public void handleRequest(RestRequest restRequest, RestChannel restChannel, final NodeClient client) { PercolateRequest percolateRequest = new PercolateRequest(); - parseDocPercolate(percolateRequest, restRequest, restChannel, client); + parseDocPercolate(percolateRequest, restRequest, restChannel); } final class RestCountPercolateDocHandler extends BaseRestHandler { - private RestCountPercolateDocHandler(Settings settings, final RestController controller, Client client) { - super(settings, client); + private RestCountPercolateDocHandler(Settings settings, final RestController controller) { + super(settings); } @Override - public void handleRequest(RestRequest restRequest, RestChannel restChannel, final Client client) { + public void handleRequest(RestRequest restRequest, RestChannel restChannel, final NodeClient client) { PercolateRequest percolateRequest = new PercolateRequest(); percolateRequest.onlyCount(true); - parseDocPercolate(percolateRequest, restRequest, restChannel, client); + parseDocPercolate(percolateRequest, restRequest, restChannel); } } final class RestPercolateExistingDocHandler extends BaseRestHandler { - protected RestPercolateExistingDocHandler(Settings settings, final RestController controller, Client client) { - super(settings, client); + protected RestPercolateExistingDocHandler(Settings settings, final RestController controller) { + super(settings); } @Override - public void handleRequest(RestRequest restRequest, RestChannel restChannel, final Client client) { + public void handleRequest(RestRequest restRequest, RestChannel restChannel, final NodeClient client) { PercolateRequest percolateRequest = new PercolateRequest(); - parseExistingDocPercolate(percolateRequest, restRequest, restChannel, client); + parseExistingDocPercolate(percolateRequest, restRequest, restChannel); } } final class RestCountPercolateExistingDocHandler extends BaseRestHandler { - protected RestCountPercolateExistingDocHandler(Settings settings, final RestController controller, Client client) { - super(settings, client); + protected RestCountPercolateExistingDocHandler(Settings settings, final RestController controller) { + super(settings); } @Override - public void handleRequest(RestRequest restRequest, RestChannel restChannel, final Client client) { + public void handleRequest(RestRequest restRequest, RestChannel restChannel, final NodeClient client) { PercolateRequest percolateRequest = new PercolateRequest(); percolateRequest.onlyCount(true); - parseExistingDocPercolate(percolateRequest, restRequest, restChannel, client); + parseExistingDocPercolate(percolateRequest, restRequest, restChannel); } } } diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBaseReindexRestHandler.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBaseReindexRestHandler.java index 284e51e054f..048e4208fea 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBaseReindexRestHandler.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBaseReindexRestHandler.java @@ -52,10 +52,10 @@ public abstract class AbstractBaseReindexRestHandler< private final ClusterService clusterService; private final TA action; - protected AbstractBaseReindexRestHandler(Settings settings, Client client, - IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, Suggesters suggesters, - ClusterService clusterService, TA action) { - super(settings, client); + protected AbstractBaseReindexRestHandler(Settings settings, IndicesQueriesRegistry indicesQueriesRegistry, + AggregatorParsers aggParsers, Suggesters suggesters, + ClusterService clusterService, TA action) { + super(settings); this.indicesQueriesRegistry = indicesQueriesRegistry; this.aggParsers = aggParsers; this.suggesters = suggesters; @@ -63,7 +63,7 @@ public abstract class AbstractBaseReindexRestHandler< this.action = action; } - protected void handleRequest(RestRequest request, RestChannel channel, + public void handleRequest(RestRequest request, RestChannel channel, boolean includeCreated, boolean includeUpdated) throws IOException { // Build the internal request diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByQueryRestHandler.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByQueryRestHandler.java index 926da3befdd..9e4d8fc6d4e 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByQueryRestHandler.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByQueryRestHandler.java @@ -50,10 +50,10 @@ public abstract class AbstractBulkByQueryRestHandler< Request extends AbstractBulkByScrollRequest, TA extends TransportAction> extends AbstractBaseReindexRestHandler { - protected AbstractBulkByQueryRestHandler(Settings settings, Client client, IndicesQueriesRegistry indicesQueriesRegistry, + protected AbstractBulkByQueryRestHandler(Settings settings, IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, Suggesters suggesters, ClusterService clusterService, TA action) { - super(settings, client, indicesQueriesRegistry, aggParsers, suggesters, clusterService, action); + super(settings, indicesQueriesRegistry, aggParsers, suggesters, clusterService, action); } protected void parseInternalRequest(Request internal, RestRequest restRequest, diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java index bb894584c8b..7a1f466c3c0 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.index.reindex; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -42,16 +42,16 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; public class RestDeleteByQueryAction extends AbstractBulkByQueryRestHandler { @Inject - public RestDeleteByQueryAction(Settings settings, RestController controller, Client client, + public RestDeleteByQueryAction(Settings settings, RestController controller, IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, Suggesters suggesters, ClusterService clusterService, TransportDeleteByQueryAction action) { - super(settings, client, indicesQueriesRegistry, aggParsers, suggesters, clusterService, action); + super(settings, indicesQueriesRegistry, aggParsers, suggesters, clusterService, action); controller.registerHandler(POST, "/{index}/_delete_by_query", this); controller.registerHandler(POST, "/{index}/{type}/_delete_by_query", this); } @Override - protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception { + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { if (false == request.hasContent()) { throw new ElasticsearchException("_delete_by_query requires a request body"); } diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java index 22fcd390430..af0bd168ff0 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestReindexAction.java @@ -22,7 +22,7 @@ package org.elasticsearch.index.reindex; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.search.SearchRequest; -import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseFieldMatcher; @@ -103,15 +103,15 @@ public class RestReindexAction extends AbstractBaseReindexRestHandler { @Inject - public RestUpdateByQueryAction(Settings settings, RestController controller, Client client, + public RestUpdateByQueryAction(Settings settings, RestController controller, IndicesQueriesRegistry indicesQueriesRegistry, AggregatorParsers aggParsers, Suggesters suggesters, ClusterService clusterService, TransportUpdateByQueryAction action) { - super(settings, client, indicesQueriesRegistry, aggParsers, suggesters, clusterService, action); + super(settings, indicesQueriesRegistry, aggParsers, suggesters, clusterService, action); controller.registerHandler(POST, "/{index}/_update_by_query", this); controller.registerHandler(POST, "/{index}/{type}/_update_by_query", this); } @Override - protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception { + public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { handleRequest(request, channel, false, true); } diff --git a/plugins/jvm-example/src/main/java/org/elasticsearch/plugin/example/ExampleCatAction.java b/plugins/jvm-example/src/main/java/org/elasticsearch/plugin/example/ExampleCatAction.java index d5e0a62ecb5..75ae79d5f7d 100644 --- a/plugins/jvm-example/src/main/java/org/elasticsearch/plugin/example/ExampleCatAction.java +++ b/plugins/jvm-example/src/main/java/org/elasticsearch/plugin/example/ExampleCatAction.java @@ -19,6 +19,7 @@ package org.elasticsearch.plugin.example; import org.elasticsearch.client.Client; +import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Table; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -38,15 +39,14 @@ public class ExampleCatAction extends AbstractCatAction { private final ExamplePluginConfiguration config; @Inject - public ExampleCatAction(Settings settings, RestController controller, - Client client, ExamplePluginConfiguration config) { - super(settings, controller, client); + public ExampleCatAction(Settings settings, RestController controller, ExamplePluginConfiguration config) { + super(settings, controller); this.config = config; controller.registerHandler(GET, "/_cat/configured_example", this); } @Override - protected void doRequest(final RestRequest request, final RestChannel channel, final Client client) { + protected void doRequest(final RestRequest request, final RestChannel channel, final NodeClient client) { Table table = getTableWithHeader(request); table.startRow(); table.addCell(config.getTestConfig());