diff --git a/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java b/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java index 9c5c642df6b..8362198a12c 100644 --- a/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java +++ b/server/src/main/java/org/elasticsearch/cluster/ClusterModule.java @@ -116,23 +116,6 @@ public class ClusterModule extends AbstractModule { this.allocationService = new AllocationService(settings, allocationDeciders, shardsAllocator, clusterInfoService); } - public static Map> getClusterStateCustomSuppliers(List clusterPlugins) { - final Map> customSupplier = new HashMap<>(); - customSupplier.put(SnapshotDeletionsInProgress.TYPE, SnapshotDeletionsInProgress::new); - customSupplier.put(RestoreInProgress.TYPE, RestoreInProgress::new); - customSupplier.put(SnapshotsInProgress.TYPE, SnapshotsInProgress::new); - for (ClusterPlugin plugin : clusterPlugins) { - Map> initialCustomSupplier = plugin.getInitialClusterStateCustomSupplier(); - for (String key : initialCustomSupplier.keySet()) { - if (customSupplier.containsKey(key)) { - throw new IllegalStateException("custom supplier key [" + key + "] is registered more than once"); - } - } - customSupplier.putAll(initialCustomSupplier); - } - return Collections.unmodifiableMap(customSupplier); - } - public static List getNamedWriteables() { List entries = new ArrayList<>(); // Cluster State diff --git a/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplier.java b/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplier.java index c587ab272e9..781adb3742a 100644 --- a/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplier.java +++ b/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplier.java @@ -39,11 +39,6 @@ public interface ClusterApplier { */ void onNewClusterState(String source, Supplier clusterStateSupplier, ClusterApplyListener listener); - /** - * Creates a new cluster state builder that is initialized with the cluster name and all initial cluster state customs. - */ - ClusterState.Builder newClusterStateBuilder(); - /** * Listener for results of cluster state application */ diff --git a/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java b/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java index 2fb7c25671c..5dd36b9b1bc 100644 --- a/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java +++ b/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java @@ -96,17 +96,14 @@ public class ClusterApplierService extends AbstractLifecycleComponent implements private final AtomicReference state; // last applied state private NodeConnectionsService nodeConnectionsService; - private Supplier stateBuilderSupplier; - public ClusterApplierService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool, Supplier stateBuilderSupplier) { + public ClusterApplierService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool) { super(settings); this.clusterSettings = clusterSettings; this.threadPool = threadPool; this.state = new AtomicReference<>(); this.slowTaskLoggingThreshold = CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings); this.localNodeMasterListeners = new LocalNodeMasterListeners(threadPool); - this.stateBuilderSupplier = stateBuilderSupplier; } public void setSlowTaskLoggingThreshold(TimeValue slowTaskLoggingThreshold) { @@ -652,8 +649,4 @@ public class ClusterApplierService extends AbstractLifecycleComponent implements return System.nanoTime(); } - @Override - public ClusterState.Builder newClusterStateBuilder() { - return stateBuilderSupplier.get(); - } } diff --git a/server/src/main/java/org/elasticsearch/cluster/service/ClusterService.java b/server/src/main/java/org/elasticsearch/cluster/service/ClusterService.java index 7610d75f677..fc5dc678bd0 100644 --- a/server/src/main/java/org/elasticsearch/cluster/service/ClusterService.java +++ b/server/src/main/java/org/elasticsearch/cluster/service/ClusterService.java @@ -42,7 +42,6 @@ import org.elasticsearch.threadpool.ThreadPool; import java.util.Collections; import java.util.Map; -import java.util.function.Supplier; public class ClusterService extends AbstractLifecycleComponent { @@ -59,10 +58,8 @@ public class ClusterService extends AbstractLifecycleComponent { private final OperationRouting operationRouting; private final ClusterSettings clusterSettings; - private final Map> initialClusterStateCustoms; - public ClusterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool, - Map> initialClusterStateCustoms) { + public ClusterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool) { super(settings); this.masterService = new MasterService(settings, threadPool); this.operationRouting = new OperationRouting(settings, clusterSettings); @@ -70,19 +67,7 @@ public class ClusterService extends AbstractLifecycleComponent { this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings); this.clusterSettings.addSettingsUpdateConsumer(CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, this::setSlowTaskLoggingThreshold); - this.initialClusterStateCustoms = initialClusterStateCustoms; - this.clusterApplierService = new ClusterApplierService(settings, clusterSettings, threadPool, this::newClusterStateBuilder); - } - - /** - * Creates a new cluster state builder that is initialized with the cluster name and all initial cluster state customs. - */ - public ClusterState.Builder newClusterStateBuilder() { - ClusterState.Builder builder = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings)); - for (Map.Entry> entry : initialClusterStateCustoms.entrySet()) { - builder.putCustom(entry.getKey(), entry.getValue().get()); - } - return builder; + this.clusterApplierService = new ClusterApplierService(settings, clusterSettings, threadPool); } private void setSlowTaskLoggingThreshold(TimeValue slowTaskLoggingThreshold) { diff --git a/server/src/main/java/org/elasticsearch/discovery/single/SingleNodeDiscovery.java b/server/src/main/java/org/elasticsearch/discovery/single/SingleNodeDiscovery.java index d7c37febb5d..462136a22fe 100644 --- a/server/src/main/java/org/elasticsearch/discovery/single/SingleNodeDiscovery.java +++ b/server/src/main/java/org/elasticsearch/discovery/single/SingleNodeDiscovery.java @@ -21,6 +21,7 @@ package org.elasticsearch.discovery.single; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.cluster.ClusterChangedEvent; +import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -113,7 +114,7 @@ public class SingleNodeDiscovery extends AbstractLifecycleComponent implements D } protected ClusterState createInitialState(DiscoveryNode localNode) { - ClusterState.Builder builder = clusterApplier.newClusterStateBuilder(); + ClusterState.Builder builder = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings)); return builder.nodes(DiscoveryNodes.builder().add(localNode) .localNodeId(localNode.getId()) .masterNodeId(localNode.getId()) diff --git a/server/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java b/server/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java index eb9a9f8d488..a68557adb9d 100644 --- a/server/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/server/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -252,7 +252,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implements Discover // set initial state assert committedState.get() == null; assert localNode != null; - ClusterState.Builder builder = clusterApplier.newClusterStateBuilder(); + ClusterState.Builder builder = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings)); ClusterState initialState = builder .blocks(ClusterBlocks.builder() .addGlobalBlock(STATE_NOT_RECOVERED_BLOCK) diff --git a/server/src/main/java/org/elasticsearch/gateway/Gateway.java b/server/src/main/java/org/elasticsearch/gateway/Gateway.java index ae8f5a85def..d2261e5d1b4 100644 --- a/server/src/main/java/org/elasticsearch/gateway/Gateway.java +++ b/server/src/main/java/org/elasticsearch/gateway/Gateway.java @@ -23,6 +23,7 @@ import com.carrotsearch.hppc.ObjectFloatHashMap; import com.carrotsearch.hppc.cursors.ObjectCursor; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.action.FailedNodeException; +import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; @@ -147,7 +148,7 @@ public class Gateway extends AbstractComponent { metaDataBuilder.transientSettings(), e -> logUnknownSetting("transient", e), (e, ex) -> logInvalidSetting("transient", e, ex))); - ClusterState.Builder builder = clusterService.newClusterStateBuilder(); + ClusterState.Builder builder = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings)); builder.metaData(metaDataBuilder); listener.onSuccess(builder.build()); } diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index b5cc7964085..c65488bd08e 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -349,8 +349,7 @@ public class Node implements Closeable { getCustomNameResolvers(pluginsService.filterPlugins(DiscoveryPlugin.class))); List clusterPlugins = pluginsService.filterPlugins(ClusterPlugin.class); - final ClusterService clusterService = new ClusterService(settings, settingsModule.getClusterSettings(), threadPool, - ClusterModule.getClusterStateCustomSuppliers(clusterPlugins)); + final ClusterService clusterService = new ClusterService(settings, settingsModule.getClusterSettings(), threadPool); clusterService.addStateApplier(scriptModule.getScriptService()); resourcesToClose.add(clusterService); final IngestService ingestService = new IngestService(settings, threadPool, this.environment, diff --git a/server/src/main/java/org/elasticsearch/plugins/ClusterPlugin.java b/server/src/main/java/org/elasticsearch/plugins/ClusterPlugin.java index 61145c7a1d7..a1274b9346c 100644 --- a/server/src/main/java/org/elasticsearch/plugins/ClusterPlugin.java +++ b/server/src/main/java/org/elasticsearch/plugins/ClusterPlugin.java @@ -24,7 +24,6 @@ import java.util.Collections; import java.util.Map; import java.util.function.Supplier; -import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocator; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider; import org.elasticsearch.common.settings.ClusterSettings; @@ -66,12 +65,4 @@ public interface ClusterPlugin { default void onNodeStarted() { } - /** - * Returns a map of {@link ClusterState.Custom} supplier that should be invoked to initialize the initial clusterstate. - * This allows custom clusterstate extensions to be always present and prevents invariants where clusterstates are published - * but customs are not initialized. - * - * TODO: Remove this whole concept of InitialClusterStateCustomSupplier, it's not used anymore - */ - default Map> getInitialClusterStateCustomSupplier() { return Collections.emptyMap(); } } diff --git a/server/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java b/server/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java index 4c7a42de2ee..af3807226a9 100644 --- a/server/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java @@ -63,7 +63,7 @@ import java.util.function.Supplier; public class ClusterModuleTests extends ModuleTestCase { private ClusterInfoService clusterInfoService = EmptyClusterInfoService.INSTANCE; private ClusterService clusterService = new ClusterService(Settings.EMPTY, - new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), null, Collections.emptyMap()); + new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), null); static class FakeAllocationDecider extends AllocationDecider { protected FakeAllocationDecider(Settings settings) { super(settings); @@ -202,57 +202,6 @@ public class ClusterModuleTests extends ModuleTestCase { } } - public void testCustomSuppliers() { - Map> customSuppliers = ClusterModule.getClusterStateCustomSuppliers(Collections.emptyList()); - assertEquals(3, customSuppliers.size()); - assertTrue(customSuppliers.containsKey(SnapshotsInProgress.TYPE)); - assertTrue(customSuppliers.containsKey(SnapshotDeletionsInProgress.TYPE)); - assertTrue(customSuppliers.containsKey(RestoreInProgress.TYPE)); - - customSuppliers = ClusterModule.getClusterStateCustomSuppliers(Collections.singletonList(new ClusterPlugin() { - @Override - public Map> getInitialClusterStateCustomSupplier() { - return Collections.singletonMap("foo", () -> null); - } - })); - assertEquals(4, customSuppliers.size()); - assertTrue(customSuppliers.containsKey(SnapshotsInProgress.TYPE)); - assertTrue(customSuppliers.containsKey(SnapshotDeletionsInProgress.TYPE)); - assertTrue(customSuppliers.containsKey(RestoreInProgress.TYPE)); - assertTrue(customSuppliers.containsKey("foo")); - - { - // Eclipse Neon 2 didn't compile the plugins definition inside the lambda expression, - // probably due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=511750, which is - // fixed in Eclipse Oxygon. Pulled out the plugins definition to make it work in older versions - List plugins = Collections.singletonList(new ClusterPlugin() { - @Override - public Map> getInitialClusterStateCustomSupplier() { - return Collections.singletonMap(SnapshotsInProgress.TYPE, () -> null); - } - }); - IllegalStateException ise = expectThrows(IllegalStateException.class, - () -> ClusterModule.getClusterStateCustomSuppliers(plugins)); - assertEquals(ise.getMessage(), "custom supplier key [snapshots] is registered more than once"); - } - { - List plugins = Arrays.asList(new ClusterPlugin() { - @Override - public Map> getInitialClusterStateCustomSupplier() { - return Collections.singletonMap("foo", () -> null); - } - }, new ClusterPlugin() { - @Override - public Map> getInitialClusterStateCustomSupplier() { - return Collections.singletonMap("foo", () -> null); - } - }); - IllegalStateException ise = expectThrows(IllegalStateException.class, - () -> ClusterModule.getClusterStateCustomSuppliers(plugins)); - assertEquals(ise.getMessage(), "custom supplier key [foo] is registered more than once"); - } - } - public void testPre63CustomsFiltering() { final String whiteListedClusterCustom = randomFrom(ClusterModule.PRE_6_3_CLUSTER_CUSTOMS_WHITE_LIST); final String whiteListedMetaDataCustom = randomFrom(ClusterModule.PRE_6_3_METADATA_CUSTOMS_WHITE_LIST); diff --git a/server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java b/server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java index 0ba3de43818..606e716d210 100644 --- a/server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java @@ -30,6 +30,7 @@ import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.Priority; import org.elasticsearch.common.Strings; import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.collect.ImmutableOpenMap; @@ -38,14 +39,20 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; +import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.env.Environment; +import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.plugins.ClusterPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.script.ScriptService; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.hamcrest.CollectionAssertions; +import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.watcher.ResourceWatcherService; import org.junit.Before; import java.io.IOException; @@ -53,9 +60,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.function.Supplier; +import java.util.concurrent.atomic.AtomicBoolean; +import static org.elasticsearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertIndexTemplateExists; import static org.hamcrest.Matchers.equalTo; @@ -279,13 +286,11 @@ public class SimpleClusterStateIT extends ESIntegTestCase { } } - public void testPrivateCustomsAreExcluded() { + public void testPrivateCustomsAreExcluded() throws Exception { + // ensure that the custom is injected into the cluster state + assertBusy(() -> assertTrue(clusterService().state().customs().containsKey("test"))); ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().setCustoms(true).get(); assertFalse(clusterStateResponse.getState().customs().containsKey("test")); - // just to make sure there is something - assertTrue(clusterStateResponse.getState().customs().containsKey(SnapshotDeletionsInProgress.TYPE)); - ClusterState state = internalCluster().getInstance(ClusterService.class).state(); - assertTrue(state.customs().containsKey("test")); } private static class TestCustom extends AbstractNamedDiffable implements ClusterState.Custom { @@ -333,11 +338,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase { public PrivateCustomPlugin() {} - @Override - public Map> getInitialClusterStateCustomSupplier() { - return Collections.singletonMap("test", () -> new TestCustom(1)); - } - @Override public List getNamedWriteables() { List entries = new ArrayList<>(); @@ -345,5 +345,54 @@ public class SimpleClusterStateIT extends ESIntegTestCase { entries.add(new NamedWriteableRegistry.Entry(NamedDiff.class, "test", TestCustom::readDiffFrom)); return entries; } + + private final AtomicBoolean installed = new AtomicBoolean(); + + @Override + public Collection createComponents( + final Client client, + final ClusterService clusterService, + final ThreadPool threadPool, + final ResourceWatcherService resourceWatcherService, + final ScriptService scriptService, + final NamedXContentRegistry xContentRegistry, + final Environment environment, + final NodeEnvironment nodeEnvironment, + final NamedWriteableRegistry namedWriteableRegistry) { + clusterService.addListener(event -> { + final ClusterState state = event.state(); + if (state.getBlocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK)) { + return; + } + + if (state.nodes().isLocalNodeElectedMaster()) { + if (state.custom("test") == null) { + if (installed.compareAndSet(false, true)) { + clusterService.submitStateUpdateTask("install-metadata-custom", new ClusterStateUpdateTask(Priority.URGENT) { + + @Override + public ClusterState execute(ClusterState currentState) { + if (currentState.custom("test") == null) { + final ClusterState.Builder builder = ClusterState.builder(currentState); + builder.putCustom("test", new TestCustom(42)); + return builder.build(); + } else { + return currentState; + } + } + + @Override + public void onFailure(String source, Exception e) { + throw new AssertionError(e); + } + + }); + } + } + } + + }); + return Collections.emptyList(); + } } } diff --git a/server/src/test/java/org/elasticsearch/cluster/service/ClusterApplierServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/service/ClusterApplierServiceTests.java index cbf8a7eda2b..0ca47377bdd 100644 --- a/server/src/test/java/org/elasticsearch/cluster/service/ClusterApplierServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/service/ClusterApplierServiceTests.java @@ -412,7 +412,7 @@ public class ClusterApplierServiceTests extends ESTestCase { public volatile Long currentTimeOverride = null; TimedClusterApplierService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool) { - super(settings, clusterSettings, threadPool, () -> ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings))); + super(settings, clusterSettings, threadPool); } @Override diff --git a/server/src/test/java/org/elasticsearch/cluster/service/ClusterSerivceTests.java b/server/src/test/java/org/elasticsearch/cluster/service/ClusterSerivceTests.java deleted file mode 100644 index 2cebd41a52c..00000000000 --- a/server/src/test/java/org/elasticsearch/cluster/service/ClusterSerivceTests.java +++ /dev/null @@ -1,68 +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.cluster.service; - -import org.elasticsearch.Version; -import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.Diff; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.test.ESTestCase; - -import java.io.IOException; -import java.util.Collections; - -public class ClusterSerivceTests extends ESTestCase { - - public void testNewBuilderContainsCustoms() { - ClusterState.Custom custom = new ClusterState.Custom() { - @Override - public Diff diff(ClusterState.Custom previousState) { - return null; - } - - @Override - public String getWriteableName() { - return null; - } - - @Override - public Version getMinimalSupportedVersion() { - return Version.CURRENT; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - return null; - } - }; - ClusterService service = new ClusterService(Settings.EMPTY, - new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), null, Collections.singletonMap("foo", () -> - custom)); - ClusterState.Builder builder = service.newClusterStateBuilder(); - assertSame(builder.build().custom("foo"), custom); - } -} diff --git a/server/src/test/java/org/elasticsearch/discovery/single/SingleNodeDiscoveryTests.java b/server/src/test/java/org/elasticsearch/discovery/single/SingleNodeDiscoveryTests.java index d045adcaead..57f7bfec6ef 100644 --- a/server/src/test/java/org/elasticsearch/discovery/single/SingleNodeDiscoveryTests.java +++ b/server/src/test/java/org/elasticsearch/discovery/single/SingleNodeDiscoveryTests.java @@ -21,7 +21,6 @@ package org.elasticsearch.discovery.single; import org.elasticsearch.core.internal.io.IOUtils; import org.elasticsearch.Version; -import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; @@ -64,11 +63,6 @@ public class SingleNodeDiscoveryTests extends ESTestCase { clusterState.set(initialState); } - @Override - public ClusterState.Builder newClusterStateBuilder() { - return ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings)); - } - @Override public void onNewClusterState(String source, Supplier clusterStateSupplier, ClusterApplyListener listener) { diff --git a/server/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryUnitTests.java b/server/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryUnitTests.java index 6dbf80d9be6..2c4fb0c7e8d 100644 --- a/server/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryUnitTests.java +++ b/server/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryUnitTests.java @@ -306,11 +306,6 @@ public class ZenDiscoveryUnitTests extends ESTestCase { } - @Override - public ClusterState.Builder newClusterStateBuilder() { - return ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings)); - } - @Override public void onNewClusterState(String source, Supplier clusterStateSupplier, ClusterApplyListener listener) { listener.onSuccess(source); diff --git a/server/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java b/server/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java index bd3d5beeaf5..3e4a3dce091 100644 --- a/server/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java +++ b/server/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java @@ -27,14 +27,13 @@ import org.elasticsearch.test.ESTestCase; import org.hamcrest.Matchers; import java.io.IOException; -import java.util.Collections; public class GatewayServiceTests extends ESTestCase { private GatewayService createService(Settings.Builder settings) { ClusterService clusterService = new ClusterService(Settings.builder().put("cluster.name", "GatewayServiceTests").build(), new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), - null, Collections.emptyMap()); + null); return new GatewayService(settings.build(), null, clusterService, null, null, null, null); } diff --git a/server/src/test/java/org/elasticsearch/node/ResponseCollectorServiceTests.java b/server/src/test/java/org/elasticsearch/node/ResponseCollectorServiceTests.java index d86d7b46cc7..8aa0f3ec5ba 100644 --- a/server/src/test/java/org/elasticsearch/node/ResponseCollectorServiceTests.java +++ b/server/src/test/java/org/elasticsearch/node/ResponseCollectorServiceTests.java @@ -34,7 +34,6 @@ import org.elasticsearch.threadpool.ThreadPool; import org.junit.After; import org.junit.Before; -import java.util.Collections; import java.util.Map; import java.util.concurrent.CountDownLatch; @@ -53,7 +52,7 @@ public class ResponseCollectorServiceTests extends ESTestCase { threadpool = new TestThreadPool("response_collector_tests"); clusterService = new ClusterService(Settings.EMPTY, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), - threadpool, Collections.emptyMap()); + threadpool); collector = new ResponseCollectorService(Settings.EMPTY, clusterService); } diff --git a/server/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/server/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java index 5d2abdd1492..a008846e2d3 100644 --- a/server/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java +++ b/server/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java @@ -31,7 +31,6 @@ import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotR import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStats; import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus; import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse; -import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.AdminClient; @@ -40,8 +39,6 @@ import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateUpdateTask; import org.elasticsearch.cluster.NamedDiff; -import org.elasticsearch.cluster.RestoreInProgress; -import org.elasticsearch.cluster.SnapshotDeletionsInProgress; import org.elasticsearch.cluster.SnapshotsInProgress; import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; @@ -165,24 +162,6 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest return Arrays.asList(MockRepository.Plugin.class, TestCustomMetaDataPlugin.class); } - public void testClusterStateHasCustoms() throws Exception { - ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().all().get(); - assertNotNull(clusterStateResponse.getState().custom(SnapshotsInProgress.TYPE)); - assertNotNull(clusterStateResponse.getState().custom(RestoreInProgress.TYPE)); - assertNotNull(clusterStateResponse.getState().custom(SnapshotDeletionsInProgress.TYPE)); - internalCluster().ensureAtLeastNumDataNodes(2); - if (randomBoolean()) { - internalCluster().fullRestart(); - } else { - internalCluster().rollingRestart(); - } - - clusterStateResponse = client().admin().cluster().prepareState().all().get(); - assertNotNull(clusterStateResponse.getState().custom(SnapshotsInProgress.TYPE)); - assertNotNull(clusterStateResponse.getState().custom(RestoreInProgress.TYPE)); - assertNotNull(clusterStateResponse.getState().custom(SnapshotDeletionsInProgress.TYPE)); - } - public void testRestorePersistentSettings() throws Exception { logger.info("--> start 2 nodes"); internalCluster().startNode(); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java b/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java index 8c4076e327d..fff29dff3f6 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java @@ -132,7 +132,7 @@ public class ClusterServiceUtils { public static ClusterService createClusterService(ThreadPool threadPool, DiscoveryNode localNode, ClusterSettings clusterSettings) { ClusterService clusterService = new ClusterService(Settings.builder().put("cluster.name", "ClusterServiceTests").build(), - clusterSettings, threadPool, Collections.emptyMap()); + clusterSettings, threadPool); clusterService.setNodeConnectionsService(new NodeConnectionsService(Settings.EMPTY, null, null) { @Override public void connectToNodes(DiscoveryNodes discoveryNodes) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java index 796cae375e3..e0029362003 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/LocalStateCompositeXPackPlugin.java @@ -349,13 +349,6 @@ public class LocalStateCompositeXPackPlugin extends XPackPlugin implements Scrip filterPlugins(Plugin.class).stream().forEach(p -> p.onIndexModule(indexModule)); } - @Override - public Map> getInitialClusterStateCustomSupplier() { - Map> suppliers = new HashMap<>(); - filterPlugins(ClusterPlugin.class).stream().forEach(p -> suppliers.putAll(p.getInitialClusterStateCustomSupplier())); - return suppliers; - } - @Override public Function> getFieldFilter() { List>> items = filterPlugins(MapperPlugin.class).stream().map(p ->