diff --git a/modules/kibana/build.gradle b/modules/kibana/build.gradle
deleted file mode 100644
index f9d11e5a6c58b..0000000000000
--- a/modules/kibana/build.gradle
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-esplugin {
- description 'Plugin exposing APIs for Kibana system indices'
- classname 'org.elasticsearch.kibana.KibanaPlugin'
-}
-
-dependencies {
- compile project(path: ':modules:reindex', configuration: 'runtime')
-}
-
-testClusters.integTest {
- module file(project(':modules:reindex').tasks.bundlePlugin.archiveFile)
-}
diff --git a/modules/kibana/src/main/java/org/elasticsearch/kibana/KibanaPlugin.java b/modules/kibana/src/main/java/org/elasticsearch/kibana/KibanaPlugin.java
deleted file mode 100644
index c8760f095fc29..0000000000000
--- a/modules/kibana/src/main/java/org/elasticsearch/kibana/KibanaPlugin.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.kibana;
-
-import org.elasticsearch.client.node.NodeClient;
-import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
-import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.common.settings.ClusterSettings;
-import org.elasticsearch.common.settings.IndexScopedSettings;
-import org.elasticsearch.common.settings.Setting;
-import org.elasticsearch.common.settings.Setting.Property;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.settings.SettingsFilter;
-import org.elasticsearch.index.reindex.RestDeleteByQueryAction;
-import org.elasticsearch.indices.SystemIndexDescriptor;
-import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.SystemIndexPlugin;
-import org.elasticsearch.rest.BaseRestHandler;
-import org.elasticsearch.rest.RestController;
-import org.elasticsearch.rest.RestHandler;
-import org.elasticsearch.rest.RestRequest;
-import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction;
-import org.elasticsearch.rest.action.admin.indices.RestGetAliasesAction;
-import org.elasticsearch.rest.action.admin.indices.RestGetIndicesAction;
-import org.elasticsearch.rest.action.admin.indices.RestIndexPutAliasAction;
-import org.elasticsearch.rest.action.admin.indices.RestRefreshAction;
-import org.elasticsearch.rest.action.admin.indices.RestUpdateSettingsAction;
-import org.elasticsearch.rest.action.document.RestBulkAction;
-import org.elasticsearch.rest.action.document.RestDeleteAction;
-import org.elasticsearch.rest.action.document.RestGetAction;
-import org.elasticsearch.rest.action.document.RestIndexAction;
-import org.elasticsearch.rest.action.document.RestIndexAction.AutoIdHandler;
-import org.elasticsearch.rest.action.document.RestIndexAction.CreateHandler;
-import org.elasticsearch.rest.action.document.RestMultiGetAction;
-import org.elasticsearch.rest.action.document.RestUpdateAction;
-import org.elasticsearch.rest.action.search.RestClearScrollAction;
-import org.elasticsearch.rest.action.search.RestSearchAction;
-import org.elasticsearch.rest.action.search.RestSearchScrollAction;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-
-public class KibanaPlugin extends Plugin implements SystemIndexPlugin {
-
- public static final Setting> KIBANA_INDEX_NAMES_SETTING = Setting.listSetting("kibana.system_indices",
- Collections.unmodifiableList(Arrays.asList(".kibana*", ".reporting")), Function.identity(), Property.NodeScope);
-
- @Override
- public Collection getSystemIndexDescriptors(Settings settings) {
- return Collections.unmodifiableList(KIBANA_INDEX_NAMES_SETTING.get(settings).stream()
- .map(pattern -> new SystemIndexDescriptor(pattern, "System index used by kibana"))
- .collect(Collectors.toList()));
- }
-
- @Override
- public List getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
- IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter,
- IndexNameExpressionResolver indexNameExpressionResolver,
- Supplier nodesInCluster) {
- // TODO need to figure out what subset of system indices Kibana should have access to via these APIs
- final List allowedIndexPatterns = Collections.emptyList();
- return Collections.unmodifiableList(Arrays.asList(
- // Based on https://github.com/elastic/kibana/issues/49764
- // apis needed to perform migrations... ideally these will go away
- new KibanaWrappedRestHandler(new RestCreateIndexAction(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestGetAliasesAction(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestIndexPutAliasAction(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestRefreshAction(), allowedIndexPatterns),
-
- // apis needed to access saved objects
- new KibanaWrappedRestHandler(new RestGetAction(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestMultiGetAction(settings), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestSearchAction(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestBulkAction(settings), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestDeleteAction(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestDeleteByQueryAction(), allowedIndexPatterns),
-
- // api used for testing
- new KibanaWrappedRestHandler(new RestUpdateSettingsAction(), allowedIndexPatterns),
-
- // apis used specifically by reporting
- new KibanaWrappedRestHandler(new RestGetIndicesAction(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestIndexAction(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new CreateHandler(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new AutoIdHandler(nodesInCluster), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestUpdateAction(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestSearchScrollAction(), allowedIndexPatterns),
- new KibanaWrappedRestHandler(new RestClearScrollAction(), allowedIndexPatterns)
- ));
-
- }
-
- @Override
- public List> getSettings() {
- return Collections.singletonList(KIBANA_INDEX_NAMES_SETTING);
- }
-
- static class KibanaWrappedRestHandler extends BaseRestHandler.Wrapper {
-
- private final List allowedIndexPatterns;
-
- KibanaWrappedRestHandler(BaseRestHandler delegate, List allowedIndexPatterns) {
- super(delegate);
- this.allowedIndexPatterns = allowedIndexPatterns;
- }
-
- @Override
- public String getName() {
- return "kibana_" + super.getName();
- }
-
- @Override
- public List routes() {
- return Collections.unmodifiableList(super.routes().stream()
- .map(route -> new Route(route.getMethod(), "/_kibana" + route.getPath()))
- .collect(Collectors.toList()));
- }
-
- @Override
- protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
- client.threadPool().getThreadContext().allowSystemIndexAccess(allowedIndexPatterns);
- return super.prepareRequest(request, client);
- }
- }
-}
diff --git a/modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaPluginTests.java b/modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaPluginTests.java
deleted file mode 100644
index 1ea24d2ff1675..0000000000000
--- a/modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaPluginTests.java
+++ /dev/null
@@ -1,47 +0,0 @@
-
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.kibana;
-
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.indices.SystemIndexDescriptor;
-import org.elasticsearch.test.ESTestCase;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.is;
-
-public class KibanaPluginTests extends ESTestCase {
-
- public void testKibanaIndexNames() {
- assertThat(new KibanaPlugin().getSettings(), contains(KibanaPlugin.KIBANA_INDEX_NAMES_SETTING));
- assertThat(new KibanaPlugin().getSystemIndexDescriptors(Settings.EMPTY).stream()
- .map(SystemIndexDescriptor::getIndexPattern).collect(Collectors.toList()),
- contains(".kibana*", ".reporting"));
- final List names = Arrays.asList("." + randomAlphaOfLength(4), "." + randomAlphaOfLength(6));
- final List namesFromDescriptors = new KibanaPlugin().getSystemIndexDescriptors(
- Settings.builder().putList(KibanaPlugin.KIBANA_INDEX_NAMES_SETTING.getKey(), names).build()
- ).stream().map(SystemIndexDescriptor::getIndexPattern).collect(Collectors.toList());
- assertThat(namesFromDescriptors, is(names));
- }
-}
diff --git a/modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaSystemIndexIT.java b/modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaSystemIndexIT.java
deleted file mode 100644
index f3901112e839f..0000000000000
--- a/modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaSystemIndexIT.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.kibana;
-
-import org.apache.http.util.EntityUtils;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.common.xcontent.XContentHelper;
-import org.elasticsearch.common.xcontent.json.JsonXContent;
-import org.elasticsearch.test.rest.ESRestTestCase;
-
-import java.io.IOException;
-import java.util.Map;
-
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-
-public class KibanaSystemIndexIT extends ESRestTestCase {
-
- public void testCreateIndex() throws IOException {
- Request request = new Request("PUT", "/_kibana/.kibana-1");
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
- }
-
- public void testAliases() throws IOException {
- Request request = new Request("PUT", "/_kibana/.kibana-1");
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- request = new Request("PUT", "/_kibana/.kibana-1/_alias/.kibana");
- response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- request = new Request("GET", "/_kibana/_aliases");
- response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
- assertThat(EntityUtils.toString(response.getEntity()), containsString(".kibana"));
- }
-
- public void testBulkToKibanaIndex() throws IOException {
- Request request = new Request("POST", "/_kibana/_bulk");
- request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n");
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
- }
-
- public void testRefresh() throws IOException {
- Request request = new Request("POST", "/_kibana/_bulk");
- request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n");
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- request = new Request("GET", "/_kibana/.kibana/_refresh");
- response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- Request getRequest = new Request("GET", "/_kibana/.kibana/_doc/1");
- Response getResponse = client().performRequest(getRequest);
- assertThat(getResponse.getStatusLine().getStatusCode(), is(200));
- String responseBody = EntityUtils.toString(getResponse.getEntity());
- assertThat(responseBody, containsString("foo"));
- assertThat(responseBody, containsString("bar"));
- }
-
- public void testGetFromKibanaIndex() throws IOException {
- Request request = new Request("POST", "/_kibana/_bulk");
- request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n");
- request.addParameter("refresh", "true");
-
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- Request getRequest = new Request("GET", "/_kibana/.kibana/_doc/1");
- Response getResponse = client().performRequest(getRequest);
- assertThat(getResponse.getStatusLine().getStatusCode(), is(200));
- String responseBody = EntityUtils.toString(getResponse.getEntity());
- assertThat(responseBody, containsString("foo"));
- assertThat(responseBody, containsString("bar"));
- }
-
- public void testMultiGetFromKibanaIndex() throws IOException {
- Request request = new Request("POST", "/_kibana/_bulk");
- request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n" +
- "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"2\" } }\n{ \"baz\" : \"tag\" }\n");
- request.addParameter("refresh", "true");
-
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- Request getRequest = new Request("GET", "/_kibana/_mget");
- getRequest.setJsonEntity("{ \"docs\" : [ { \"_index\" : \".kibana\", \"_id\" : \"1\" }, " +
- "{ \"_index\" : \".kibana\", \"_id\" : \"2\" } ] }\n");
- Response getResponse = client().performRequest(getRequest);
- assertThat(getResponse.getStatusLine().getStatusCode(), is(200));
- String responseBody = EntityUtils.toString(getResponse.getEntity());
- assertThat(responseBody, containsString("foo"));
- assertThat(responseBody, containsString("bar"));
- assertThat(responseBody, containsString("baz"));
- assertThat(responseBody, containsString("tag"));
- }
-
- public void testSearchFromKibanaIndex() throws IOException {
- Request request = new Request("POST", "/_kibana/_bulk");
- request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n" +
- "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"2\" } }\n{ \"baz\" : \"tag\" }\n");
- request.addParameter("refresh", "true");
-
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- Request searchRequest = new Request("GET", "/_kibana/.kibana/_search");
- searchRequest.setJsonEntity("{ \"query\" : { \"match_all\" : {} } }\n");
- Response getResponse = client().performRequest(searchRequest);
- assertThat(getResponse.getStatusLine().getStatusCode(), is(200));
- String responseBody = EntityUtils.toString(getResponse.getEntity());
- assertThat(responseBody, containsString("foo"));
- assertThat(responseBody, containsString("bar"));
- assertThat(responseBody, containsString("baz"));
- assertThat(responseBody, containsString("tag"));
- }
-
- public void testDeleteFromKibanaIndex() throws IOException {
- Request request = new Request("POST", "/_kibana/_bulk");
- request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n" +
- "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"2\" } }\n{ \"baz\" : \"tag\" }\n");
- request.addParameter("refresh", "true");
-
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- Request deleteRequest = new Request("DELETE", "/_kibana/.kibana/_doc/1");
- Response deleteResponse = client().performRequest(deleteRequest);
- assertThat(deleteResponse.getStatusLine().getStatusCode(), is(200));
- }
-
- public void testDeleteByQueryFromKibanaIndex() throws IOException {
- Request request = new Request("POST", "/_kibana/_bulk");
- request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n" +
- "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"2\" } }\n{ \"baz\" : \"tag\" }\n");
- request.addParameter("refresh", "true");
-
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- Request dbqRequest = new Request("POST", "/_kibana/.kibana/_delete_by_query");
- dbqRequest.setJsonEntity("{ \"query\" : { \"match_all\" : {} } }\n");
- Response dbqResponse = client().performRequest(dbqRequest);
- assertThat(dbqResponse.getStatusLine().getStatusCode(), is(200));
- }
-
- public void testUpdateIndexSettings() throws IOException {
- Request request = new Request("PUT", "/_kibana/.kibana-1");
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- request = new Request("PUT", "/_kibana/.kibana-1/_settings");
- request.setJsonEntity("{ \"index.blocks.read_only\" : false }");
- response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
- }
-
- public void testGetIndex() throws IOException {
- Request request = new Request("PUT", "/_kibana/.kibana-1");
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- request = new Request("GET", "/_kibana/.kibana-1");
- response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
- assertThat(EntityUtils.toString(response.getEntity()), containsString(".kibana-1"));
- }
-
- public void testIndexingAndUpdatingDocs() throws IOException {
- Request request = new Request("PUT", "/_kibana/.kibana-1/_doc/1");
- request.setJsonEntity("{ \"foo\" : \"bar\" }");
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(201));
-
- request = new Request("PUT", "/_kibana/.kibana-1/_create/2");
- request.setJsonEntity("{ \"foo\" : \"bar\" }");
- response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(201));
-
- request = new Request("POST", "/_kibana/.kibana-1/_doc");
- request.setJsonEntity("{ \"foo\" : \"bar\" }");
- response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(201));
-
- request = new Request("GET", "/_kibana/.kibana-1/_refresh");
- response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- request = new Request("POST", "/_kibana/.kibana-1/_update/1");
- request.setJsonEntity("{ \"doc\" : { \"foo\" : \"baz\" } }");
- response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
- }
-
- public void testScrollingDocs() throws IOException {
- Request request = new Request("POST", "/_kibana/_bulk");
- request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n" +
- "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"2\" } }\n{ \"baz\" : \"tag\" }\n" +
- "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"3\" } }\n{ \"baz\" : \"tag\" }\n");
- request.addParameter("refresh", "true");
- Response response = client().performRequest(request);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
-
- Request searchRequest = new Request("GET", "/_kibana/.kibana/_search");
- searchRequest.setJsonEntity("{ \"size\" : 1,\n\"query\" : { \"match_all\" : {} } }\n");
- searchRequest.addParameter("scroll", "1m");
- response = client().performRequest(searchRequest);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
- Map map = XContentHelper.convertToMap(JsonXContent.jsonXContent, EntityUtils.toString(response.getEntity()), false);
- assertNotNull(map.get("_scroll_id"));
- String scrollId = (String) map.get("_scroll_id");
-
- Request scrollRequest = new Request("POST", "/_kibana/_search/scroll");
- scrollRequest.addParameter("scroll_id", scrollId);
- scrollRequest.addParameter("scroll", "1m");
- response = client().performRequest(scrollRequest);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
- map = XContentHelper.convertToMap(JsonXContent.jsonXContent, EntityUtils.toString(response.getEntity()), false);
- assertNotNull(map.get("_scroll_id"));
- scrollId = (String) map.get("_scroll_id");
-
- Request clearScrollRequest = new Request("DELETE", "/_kibana/_search/scroll");
- clearScrollRequest.addParameter("scroll_id", scrollId);
- response = client().performRequest(clearScrollRequest);
- assertThat(response.getStatusLine().getStatusCode(), is(200));
- }
-}
diff --git a/modules/tasks/src/main/java/org/elasticsearch/tasksplugin/TasksPlugin.java b/modules/tasks/src/main/java/org/elasticsearch/tasksplugin/TasksPlugin.java
index 0467b9419c778..b7d63991877db 100644
--- a/modules/tasks/src/main/java/org/elasticsearch/tasksplugin/TasksPlugin.java
+++ b/modules/tasks/src/main/java/org/elasticsearch/tasksplugin/TasksPlugin.java
@@ -19,7 +19,6 @@
package org.elasticsearch.tasksplugin;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.SystemIndexDescriptor;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.SystemIndexPlugin;
@@ -35,7 +34,7 @@
public class TasksPlugin extends Plugin implements SystemIndexPlugin {
@Override
- public Collection getSystemIndexDescriptors(Settings settings) {
+ public Collection getSystemIndexDescriptors() {
return Collections.singletonList(new SystemIndexDescriptor(TASK_INDEX, this.getClass().getSimpleName()));
}
}
diff --git a/modules/tasks/src/test/java/org/elasticsearch/tasksplugin/TasksPluginTests.java b/modules/tasks/src/test/java/org/elasticsearch/tasksplugin/TasksPluginTests.java
index 23b873e377eb3..48ec1e06098f3 100644
--- a/modules/tasks/src/test/java/org/elasticsearch/tasksplugin/TasksPluginTests.java
+++ b/modules/tasks/src/test/java/org/elasticsearch/tasksplugin/TasksPluginTests.java
@@ -19,7 +19,6 @@
package org.elasticsearch.tasksplugin;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
@@ -28,6 +27,6 @@ public class TasksPluginTests extends ESTestCase {
public void testDummy() {
// This is a dummy test case to satisfy the conventions
TasksPlugin plugin = new TasksPlugin();
- assertThat(plugin.getSystemIndexDescriptors(Settings.EMPTY), Matchers.hasSize(1));
+ assertThat(plugin.getSystemIndexDescriptors(), Matchers.hasSize(1));
}
}
diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java
index 430271a76c9eb..736cefaa8a26d 100644
--- a/server/src/main/java/org/elasticsearch/action/ActionModule.java
+++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java
@@ -217,6 +217,7 @@
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNodes;
+import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.NamedRegistry;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.TypeLiteral;
@@ -401,11 +402,12 @@ public class ActionModule extends AbstractModule {
private final RestController restController;
private final RequestValidators mappingRequestValidators;
private final RequestValidators indicesAliasesRequestRequestValidators;
+ private final ClusterService clusterService;
public ActionModule(boolean transportClient, Settings settings, IndexNameExpressionResolver indexNameExpressionResolver,
IndexScopedSettings indexScopedSettings, ClusterSettings clusterSettings, SettingsFilter settingsFilter,
ThreadPool threadPool, List actionPlugins, NodeClient nodeClient,
- CircuitBreakerService circuitBreakerService, UsageService usageService) {
+ CircuitBreakerService circuitBreakerService, UsageService usageService, ClusterService clusterService) {
this.transportClient = transportClient;
this.settings = settings;
this.indexNameExpressionResolver = indexNameExpressionResolver;
@@ -413,6 +415,7 @@ public ActionModule(boolean transportClient, Settings settings, IndexNameExpress
this.clusterSettings = clusterSettings;
this.settingsFilter = settingsFilter;
this.actionPlugins = actionPlugins;
+ this.clusterService = clusterService;
actions = setupActions(actionPlugins);
actionFilters = setupActionFilters(actionPlugins);
autoCreateIndex = transportClient ? null : new AutoCreateIndex(settings, clusterSettings, indexNameExpressionResolver);
@@ -440,12 +443,11 @@ public ActionModule(boolean transportClient, Settings settings, IndexNameExpress
if (transportClient) {
restController = null;
} else {
- final boolean restrictSystemIndices = RestController.RESTRICT_SYSTEM_INDICES.get(settings);
- restController =
- new RestController(headers, restWrapper, nodeClient, circuitBreakerService, usageService, restrictSystemIndices);
+ restController = new RestController(headers, restWrapper, nodeClient, circuitBreakerService, usageService);
}
}
+
public Map> getActions() {
return actions;
}
@@ -674,7 +676,7 @@ public void initRestHandlers(Supplier nodesInCluster) {
registerHandler.accept(new RestIndexAction());
registerHandler.accept(new CreateHandler());
- registerHandler.accept(new AutoIdHandler(nodesInCluster));
+ registerHandler.accept(new AutoIdHandler(clusterService));
registerHandler.accept(new RestGetAction());
registerHandler.accept(new RestGetSourceAction());
registerHandler.accept(new RestMultiGetAction(settings));
diff --git a/server/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/server/src/main/java/org/elasticsearch/client/transport/TransportClient.java
index 8e92754b392db..8bb936aaceca7 100644
--- a/server/src/main/java/org/elasticsearch/client/transport/TransportClient.java
+++ b/server/src/main/java/org/elasticsearch/client/transport/TransportClient.java
@@ -187,7 +187,7 @@ private static ClientTemplate buildTemplate(Settings providedSettings, Settings
modules.add(b -> b.bind(ThreadPool.class).toInstance(threadPool));
ActionModule actionModule = new ActionModule(true, settings, null, settingsModule.getIndexScopedSettings(),
settingsModule.getClusterSettings(), settingsModule.getSettingsFilter(), threadPool,
- pluginsService.filterPlugins(ActionPlugin.class), null, null, null);
+ pluginsService.filterPlugins(ActionPlugin.class), null, null, null, null);
modules.add(actionModule);
CircuitBreakerService circuitBreakerService = Node.createCircuitBreakerService(settingsModule.getSettings(),
diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/PublicationTransportHandler.java b/server/src/main/java/org/elasticsearch/cluster/coordination/PublicationTransportHandler.java
index 87a52208e0757..eb46759df1807 100644
--- a/server/src/main/java/org/elasticsearch/cluster/coordination/PublicationTransportHandler.java
+++ b/server/src/main/java/org/elasticsearch/cluster/coordination/PublicationTransportHandler.java
@@ -366,8 +366,8 @@ private void sendClusterStateDiff(ClusterState clusterState,
public static BytesReference serializeFullClusterState(ClusterState clusterState, Version nodeVersion) throws IOException {
final BytesStreamOutput bStream = new BytesStreamOutput();
- bStream.setVersion(nodeVersion);
try (StreamOutput stream = CompressorFactory.COMPRESSOR.streamOutput(bStream)) {
+ stream.setVersion(nodeVersion);
stream.writeBoolean(true);
clusterState.writeTo(stream);
}
@@ -376,8 +376,8 @@ public static BytesReference serializeFullClusterState(ClusterState clusterState
public static BytesReference serializeDiffClusterState(Diff diff, Version nodeVersion) throws IOException {
final BytesStreamOutput bStream = new BytesStreamOutput();
- bStream.setVersion(nodeVersion);
try (StreamOutput stream = CompressorFactory.COMPRESSOR.streamOutput(bStream)) {
+ stream.setVersion(nodeVersion);
stream.writeBoolean(false);
diff.writeTo(stream);
}
@@ -387,12 +387,12 @@ public static BytesReference serializeDiffClusterState(Diff diff, Version nodeVe
private PublishWithJoinResponse handleIncomingPublishRequest(BytesTransportRequest request) throws IOException {
final Compressor compressor = CompressorFactory.compressor(request.bytes());
StreamInput in = request.bytes().streamInput();
- in.setVersion(request.version());
try {
if (compressor != null) {
in = compressor.streamInput(in);
}
in = new NamedWriteableAwareStreamInput(in, namedWriteableRegistry);
+ in.setVersion(request.version());
// If true we received full cluster state - otherwise diffs
if (in.readBoolean()) {
final ClusterState incomingState;
diff --git a/server/src/main/java/org/elasticsearch/common/compress/DeflateCompressor.java b/server/src/main/java/org/elasticsearch/common/compress/DeflateCompressor.java
index 646e6c6138230..794a8db4960c6 100644
--- a/server/src/main/java/org/elasticsearch/common/compress/DeflateCompressor.java
+++ b/server/src/main/java/org/elasticsearch/common/compress/DeflateCompressor.java
@@ -85,7 +85,7 @@ public StreamInput streamInput(StreamInput in) throws IOException {
final Inflater inflater = new Inflater(nowrap);
InputStream decompressedIn = new InflaterInputStream(in, inflater, BUFFER_SIZE);
decompressedIn = new BufferedInputStream(decompressedIn, BUFFER_SIZE);
- final InputStreamStreamInput inputStreamStreamInput = new InputStreamStreamInput(decompressedIn) {
+ return new InputStreamStreamInput(decompressedIn) {
final AtomicBoolean closed = new AtomicBoolean(false);
public void close() throws IOException {
@@ -99,9 +99,6 @@ public void close() throws IOException {
}
}
};
-
- inputStreamStreamInput.setVersion(in.getVersion());
- return inputStreamStreamInput;
}
@Override
@@ -112,7 +109,7 @@ public StreamOutput streamOutput(StreamOutput out) throws IOException {
final boolean syncFlush = true;
DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(out, deflater, BUFFER_SIZE, syncFlush);
OutputStream compressedOut = new BufferedOutputStream(deflaterOutputStream, BUFFER_SIZE);
- final OutputStreamStreamOutput outputStreamStreamOutput = new OutputStreamStreamOutput(compressedOut) {
+ return new OutputStreamStreamOutput(compressedOut) {
final AtomicBoolean closed = new AtomicBoolean(false);
public void close() throws IOException {
@@ -126,7 +123,5 @@ public void close() throws IOException {
}
}
};
- outputStreamStreamOutput.setVersion(out.getVersion());
- return outputStreamStreamOutput;
}
}
diff --git a/server/src/main/java/org/elasticsearch/common/io/Streams.java b/server/src/main/java/org/elasticsearch/common/io/Streams.java
index 3747c4d895a20..222f94e65ef6a 100644
--- a/server/src/main/java/org/elasticsearch/common/io/Streams.java
+++ b/server/src/main/java/org/elasticsearch/common/io/Streams.java
@@ -19,7 +19,6 @@
package org.elasticsearch.common.io;
-import org.elasticsearch.Version;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.BytesStream;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
@@ -297,15 +296,5 @@ public void reset() throws IOException {
public BytesReference bytes() {
return delegate.bytes();
}
-
- @Override
- public Version getVersion() {
- return delegate.getVersion();
- }
-
- @Override
- public void setVersion(Version version) {
- delegate.setVersion(version);
- }
}
}
diff --git a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
index a0524bf0c3494..fbc5ab8e91e34 100644
--- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
+++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
@@ -19,7 +19,6 @@
package org.elasticsearch.common.settings;
import org.apache.logging.log4j.LogManager;
-import org.elasticsearch.Build;
import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction;
import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction;
import org.elasticsearch.action.search.TransportSearchAction;
@@ -105,7 +104,6 @@
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.repositories.fs.FsRepository;
import org.elasticsearch.rest.BaseRestHandler;
-import org.elasticsearch.rest.RestController;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.search.SearchService;
@@ -191,10 +189,7 @@ public void apply(Settings value, Settings current, Settings previous) {
}
}
- public static final Set> BUILT_IN_CLUSTER_SETTINGS;
-
- static {
- final Set> settings = new HashSet<>(Arrays.asList(
+ public static Set> BUILT_IN_CLUSTER_SETTINGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING,
TransportClient.CLIENT_TRANSPORT_NODES_SAMPLER_INTERVAL,
TransportClient.CLIENT_TRANSPORT_PING_TIMEOUT,
@@ -544,16 +539,11 @@ public void apply(Settings value, Settings current, Settings previous) {
HandshakingTransportAddressConnector.PROBE_CONNECT_TIMEOUT_SETTING,
HandshakingTransportAddressConnector.PROBE_HANDSHAKE_TIMEOUT_SETTING,
DiscoveryUpgradeService.BWC_PING_TIMEOUT_SETTING,
- DiscoveryUpgradeService.ENABLE_UNSAFE_BOOTSTRAPPING_ON_UPGRADE_SETTING));
-
- if (Build.CURRENT.isSnapshot()) {
- settings.add(RestController.RESTRICT_SYSTEM_INDICES);
- }
- BUILT_IN_CLUSTER_SETTINGS = Collections.unmodifiableSet(settings);
- }
+ DiscoveryUpgradeService.ENABLE_UNSAFE_BOOTSTRAPPING_ON_UPGRADE_SETTING)));
public static List> BUILT_IN_SETTING_UPGRADERS = Collections.unmodifiableList(Arrays.asList(
- SniffConnectionStrategy.SEARCH_REMOTE_CLUSTER_SEEDS_UPGRADER,
- SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY_UPGRADER,
- RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE_UPGRADER));
+ SniffConnectionStrategy.SEARCH_REMOTE_CLUSTER_SEEDS_UPGRADER,
+ SniffConnectionStrategy.SEARCH_REMOTE_CLUSTERS_PROXY_UPGRADER,
+ RemoteClusterService.SEARCH_REMOTE_CLUSTER_SKIP_UNAVAILABLE_UPGRADER));
+
}
diff --git a/server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java b/server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java
index 1246d4ed2c035..5912cf792a985 100644
--- a/server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java
+++ b/server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java
@@ -20,11 +20,9 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.elasticsearch.Version;
import org.elasticsearch.action.support.ContextPreservingActionListener;
import org.elasticsearch.client.OriginSettingClient;
import org.elasticsearch.common.collect.MapBuilder;
-import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -52,7 +50,6 @@
import java.util.stream.Collector;
import java.util.stream.Stream;
-import static java.util.Collections.emptyList;
import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_MAX_WARNING_HEADER_COUNT;
import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_MAX_WARNING_HEADER_SIZE;
@@ -67,7 +64,7 @@
* Consumers of ThreadContext usually don't need to interact with adding or stashing contexts. Every elasticsearch thread is managed by
* a thread pool or executor being responsible for stashing and restoring the threads context. For instance if a network request is
* received, all headers are deserialized from the network and directly added as the headers of the threads {@link ThreadContext}
- * (see {@link #readFrom(StreamInput)}. In order to not modify the context that is currently active on this thread the network code
+ * (see {@link #readHeaders(StreamInput)}. In order to not modify the context that is currently active on this thread the network code
* uses a try/with pattern to stash it's current context, read headers into a fresh one and once the request is handled or a handler thread
* is forked (which in turn inherits the context) it restores the previous context. For instance:
*
@@ -237,18 +234,17 @@ public void writeTo(StreamOutput out) throws IOException {
}
/**
- * Reads the values from the stream into the current context
+ * Reads the headers from the stream into the current context
*/
- public void readFrom(StreamInput in) throws IOException {
+ public void readHeaders(StreamInput in) throws IOException {
final Tuple