From 7836bbf4d47028f94f7b30d4fe4968222f588131 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Mon, 10 Jul 2017 16:25:11 +0200 Subject: [PATCH] Fix tribe node cluster state version increments (#25629) With #24236, tribe nodes submit cluster state changes to their MasterService, making it unnecessary to explicitly update the cluster state version. This PR fixes the double-incrementing of cluster state versions on tribe nodes, which are not harmful, but unnecessary. --- core/src/main/java/org/elasticsearch/tribe/TribeService.java | 2 +- core/src/test/java/org/elasticsearch/tribe/TribeIT.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeService.java b/core/src/main/java/org/elasticsearch/tribe/TribeService.java index a85bda75931..b07e838653c 100644 --- a/core/src/main/java/org/elasticsearch/tribe/TribeService.java +++ b/core/src/main/java/org/elasticsearch/tribe/TribeService.java @@ -367,7 +367,7 @@ public class TribeService extends AbstractLifecycleComponent { @Override public ClusterTasksResult execute(ClusterState currentState, List tasks) throws Exception { ClusterTasksResult.Builder builder = ClusterTasksResult.builder(); - ClusterState.Builder newState = ClusterState.builder(currentState).incrementVersion(); + ClusterState.Builder newState = ClusterState.builder(currentState); boolean clusterStateChanged = updateNodes(currentState, tasks, newState); clusterStateChanged |= updateIndicesAndMetaData(currentState, tasks, newState); builder.successes(tasks); diff --git a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java index 62b4b3e9f2d..0307e69cfbe 100644 --- a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java +++ b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java @@ -496,8 +496,11 @@ public class TribeIT extends ESIntegTestCase { Collections.sort(customMetaDatas, (cm1, cm2) -> cm2.getData().compareTo(cm1.getData())); final MergableCustomMetaData1 tribeNodeCustomMetaData = customMetaDatas.get(0); try (Releasable tribeNode = startTribeNode()) { + ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); putCustomMetaData(cluster1, customMetaData1); assertCustomMetaDataUpdated(internalCluster(), customMetaData1); + // check that cluster state version is properly incremented + assertThat(client().admin().cluster().prepareState().get().getState().getVersion(), equalTo(clusterState.getVersion() + 1)); putCustomMetaData(cluster2, customMetaData2); assertCustomMetaDataUpdated(internalCluster(), tribeNodeCustomMetaData); }