From b6aa7fd08a9f75a83f307b91e5ce628b3018e5fd Mon Sep 17 00:00:00 2001 From: Andrei Dan Date: Fri, 20 Dec 2019 16:29:37 +0000 Subject: [PATCH] Make the TransportRolloverAction execute in one cluster state update (#50388) This commit makes the TransportRolloverAction more resilient, by having it execute only one cluster state update that creates the new (rollover index), rolls over the alias from the source to the target index and set the RolloverInfo on the source index. Before these 3 steps were represented as 3 chained cluster state updates, which would've seen the user manually intervene if, say, the alias rollover cluster state update (second in the chain) failed but the creation of the rollover index (first in the chain) update succeeded * Rename innerExecute to applyAliasActions (cherry picked from commit 1ba4339a0c73ef3354b8c8b44b628fc55f1dbc78) Signed-off-by: Andrei Dan --- .../rollover/TransportRolloverAction.java | 116 ++++++++---------- .../metadata/MetaDataCreateIndexService.java | 2 +- .../metadata/MetaDataIndexAliasesService.java | 7 +- .../TransportRolloverActionTests.java | 13 +- .../MetaDataIndexAliasesServiceTests.java | 46 +++---- 5 files changed, 82 insertions(+), 102 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java index ee01584f664b1..ff6845dd6a93a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java @@ -20,7 +20,6 @@ package org.elasticsearch.action.admin.indices.rollover; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesClusterStateUpdateRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction; @@ -150,56 +149,44 @@ public void onResponse(IndicesStatsResponse statsResponse) { new RolloverResponse(sourceIndexName, rolloverIndexName, conditionResults, true, false, false, false)); return; } - List> metConditions = rolloverRequest.getConditions().values().stream() + List> metConditions = rolloverRequest.getConditions().values().stream() .filter(condition -> conditionResults.get(condition.toString())).collect(Collectors.toList()); if (conditionResults.size() == 0 || metConditions.size() > 0) { - CreateIndexClusterStateUpdateRequest updateRequest = prepareCreateIndexRequest(unresolvedName, rolloverIndexName, - rolloverRequest); - createIndexService.createIndex(updateRequest, ActionListener.wrap(createIndexClusterStateUpdateResponse -> { - final IndicesAliasesClusterStateUpdateRequest aliasesUpdateRequest; - if (explicitWriteIndex) { - aliasesUpdateRequest = prepareRolloverAliasesWriteIndexUpdateRequest(sourceIndexName, - rolloverIndexName, rolloverRequest); - } else { - aliasesUpdateRequest = prepareRolloverAliasesUpdateRequest(sourceIndexName, - rolloverIndexName, rolloverRequest); + CreateIndexClusterStateUpdateRequest createIndexRequest = prepareCreateIndexRequest(unresolvedName, + rolloverIndexName, rolloverRequest); + clusterService.submitStateUpdateTask("rollover_index source [" + sourceIndexName + "] to target [" + + rolloverIndexName + "]", new ClusterStateUpdateTask() { + @Override + public ClusterState execute(ClusterState currentState) throws Exception { + ClusterState newState = createIndexService.applyCreateIndexRequest(currentState, createIndexRequest); + newState = indexAliasesService.applyAliasActions(newState, + rolloverAliasToNewIndex(sourceIndexName, rolloverIndexName, rolloverRequest, explicitWriteIndex)); + RolloverInfo rolloverInfo = new RolloverInfo(rolloverRequest.getAlias(), metConditions, + threadPool.absoluteTimeInMillis()); + return ClusterState.builder(newState) + .metaData(MetaData.builder(newState.metaData()) + .put(IndexMetaData.builder(newState.metaData().index(sourceIndexName)) + .putRolloverInfo(rolloverInfo))).build(); } - indexAliasesService.indicesAliases(aliasesUpdateRequest, - ActionListener.wrap(aliasClusterStateUpdateResponse -> { - if (aliasClusterStateUpdateResponse.isAcknowledged()) { - clusterService.submitStateUpdateTask("update_rollover_info", new ClusterStateUpdateTask() { - @Override - public ClusterState execute(ClusterState currentState) { - RolloverInfo rolloverInfo = new RolloverInfo(rolloverRequest.getAlias(), metConditions, - threadPool.absoluteTimeInMillis()); - return ClusterState.builder(currentState) - .metaData(MetaData.builder(currentState.metaData()) - .put(IndexMetaData.builder(currentState.metaData().index(sourceIndexName)) - .putRolloverInfo(rolloverInfo))).build(); - } - @Override - public void onFailure(String source, Exception e) { - listener.onFailure(e); - } + @Override + public void onFailure(String source, Exception e) { + listener.onFailure(e); + } - @Override - public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { - activeShardsObserver.waitForActiveShards(new String[]{rolloverIndexName}, - rolloverRequest.getCreateIndexRequest().waitForActiveShards(), - rolloverRequest.masterNodeTimeout(), - isShardsAcknowledged -> listener.onResponse(new RolloverResponse( - sourceIndexName, rolloverIndexName, conditionResults, false, true, true, - isShardsAcknowledged)), - listener::onFailure); - } - }); - } else { - listener.onResponse(new RolloverResponse(sourceIndexName, rolloverIndexName, conditionResults, - false, true, false, false)); - } - }, listener::onFailure)); - }, listener::onFailure)); + @Override + public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { + if (newState.equals(oldState) == false) { + activeShardsObserver.waitForActiveShards(new String[]{rolloverIndexName}, + rolloverRequest.getCreateIndexRequest().waitForActiveShards(), + rolloverRequest.masterNodeTimeout(), + isShardsAcknowledged -> listener.onResponse(new RolloverResponse( + sourceIndexName, rolloverIndexName, conditionResults, false, true, true, + isShardsAcknowledged)), + listener::onFailure); + } + } + }); } else { // conditions not met listener.onResponse( @@ -216,29 +203,24 @@ public void onFailure(Exception e) { ); } - static IndicesAliasesClusterStateUpdateRequest prepareRolloverAliasesUpdateRequest(String oldIndex, String newIndex, - RolloverRequest request) { - List actions = unmodifiableList(Arrays.asList( - new AliasAction.Add(newIndex, request.getAlias(), null, null, null, null), - new AliasAction.Remove(oldIndex, request.getAlias()))); - final IndicesAliasesClusterStateUpdateRequest updateRequest = new IndicesAliasesClusterStateUpdateRequest(actions) - .ackTimeout(request.ackTimeout()) - .masterNodeTimeout(request.masterNodeTimeout()); - return updateRequest; - } - - static IndicesAliasesClusterStateUpdateRequest prepareRolloverAliasesWriteIndexUpdateRequest(String oldIndex, String newIndex, - RolloverRequest request) { - List actions = unmodifiableList(Arrays.asList( - new AliasAction.Add(newIndex, request.getAlias(), null, null, null, true), - new AliasAction.Add(oldIndex, request.getAlias(), null, null, null, false))); - final IndicesAliasesClusterStateUpdateRequest updateRequest = new IndicesAliasesClusterStateUpdateRequest(actions) - .ackTimeout(request.ackTimeout()) - .masterNodeTimeout(request.masterNodeTimeout()); - return updateRequest; + /** + * Creates the alias actions to reflect the alias rollover from the old (source) index to the new (target/rolled over) index. An + * alias pointing to multiple indices will have to be an explicit write index (ie. the old index alias has is_write_index set to true) + * in which case, after the rollover, the new index will need to be the explicit write index. + */ + static List rolloverAliasToNewIndex(String oldIndex, String newIndex, RolloverRequest request, + boolean explicitWriteIndex) { + if (explicitWriteIndex) { + return unmodifiableList(Arrays.asList( + new AliasAction.Add(newIndex, request.getAlias(), null, null, null, true), + new AliasAction.Add(oldIndex, request.getAlias(), null, null, null, false))); + } else { + return unmodifiableList(Arrays.asList( + new AliasAction.Add(newIndex, request.getAlias(), null, null, null, null), + new AliasAction.Remove(oldIndex, request.getAlias()))); + } } - static String generateRolloverIndexName(String sourceIndexName, IndexNameExpressionResolver indexNameExpressionResolver) { String resolvedName = indexNameExpressionResolver.resolveDateMathExpression(sourceIndexName); final boolean isDateMath = sourceIndexName.equals(resolvedName) == false; diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index 5d25c1fa40e51..5cebacc7b5f03 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -258,7 +258,7 @@ public void onFailure(String source, Exception e) { * Handles the cluster state transition to a version that reflects the {@link CreateIndexClusterStateUpdateRequest}. * All the requested changes are firstly validated before mutating the {@link ClusterState}. */ - ClusterState applyCreateIndexRequest(ClusterState currentState, CreateIndexClusterStateUpdateRequest request) throws Exception { + public ClusterState applyCreateIndexRequest(ClusterState currentState, CreateIndexClusterStateUpdateRequest request) throws Exception { logger.trace("executing IndexCreationTask for [{}] against cluster state version [{}]", request, currentState.version()); Index createdIndex = null; String removalExtraInfo = null; diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java index 84e2f512e569f..5efd4b6eae8bc 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java @@ -85,12 +85,15 @@ protected ClusterStateUpdateResponse newResponse(boolean acknowledged) { @Override public ClusterState execute(ClusterState currentState) { - return innerExecute(currentState, request.actions()); + return applyAliasActions(currentState, request.actions()); } }); } - ClusterState innerExecute(ClusterState currentState, Iterable actions) { + /** + * Handles the cluster state transition to a version that reflects the provided {@link AliasAction}s. + */ + public ClusterState applyAliasActions(ClusterState currentState, Iterable actions) { List indicesToClose = new ArrayList<>(); Map indices = new HashMap<>(); try { diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java index ae3dcc819e335..79634f3610a7b 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverActionTests.java @@ -22,7 +22,6 @@ import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; -import org.elasticsearch.action.admin.indices.alias.IndicesAliasesClusterStateUpdateRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest; import org.elasticsearch.action.admin.indices.stats.CommonStats; import org.elasticsearch.action.admin.indices.stats.IndexStats; @@ -219,15 +218,13 @@ public void testEvaluateWithoutMetaData() { results2.forEach((k, v) -> assertFalse(v)); } - public void testCreateUpdateAliasRequest() { + public void testRolloverAliasActions() { String sourceAlias = randomAlphaOfLength(10); String sourceIndex = randomAlphaOfLength(10); String targetIndex = randomAlphaOfLength(10); final RolloverRequest rolloverRequest = new RolloverRequest(sourceAlias, targetIndex); - final IndicesAliasesClusterStateUpdateRequest updateRequest = - TransportRolloverAction.prepareRolloverAliasesUpdateRequest(sourceIndex, targetIndex, rolloverRequest); - List actions = updateRequest.actions(); + List actions = TransportRolloverAction.rolloverAliasToNewIndex(sourceIndex, targetIndex, rolloverRequest, false); assertThat(actions, hasSize(2)); boolean foundAdd = false; boolean foundRemove = false; @@ -246,15 +243,13 @@ public void testCreateUpdateAliasRequest() { assertTrue(foundRemove); } - public void testCreateUpdateAliasRequestWithExplicitWriteIndex() { + public void testRolloverAliasActionsWithExplicitWriteIndex() { String sourceAlias = randomAlphaOfLength(10); String sourceIndex = randomAlphaOfLength(10); String targetIndex = randomAlphaOfLength(10); final RolloverRequest rolloverRequest = new RolloverRequest(sourceAlias, targetIndex); - final IndicesAliasesClusterStateUpdateRequest updateRequest = - TransportRolloverAction.prepareRolloverAliasesWriteIndexUpdateRequest(sourceIndex, targetIndex, rolloverRequest); + List actions = TransportRolloverAction.rolloverAliasToNewIndex(sourceIndex, targetIndex, rolloverRequest, true); - List actions = updateRequest.actions(); assertThat(actions, hasSize(2)); boolean foundAddWrite = false; boolean foundRemoveWrite = false; diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesServiceTests.java index 193e3e579db47..63884e5312f7d 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesServiceTests.java @@ -73,7 +73,7 @@ public void testAddAndRemove() { ClusterState before = createIndex(ClusterState.builder(ClusterName.DEFAULT).build(), index); // Add an alias to it - ClusterState after = service.innerExecute(before, singletonList(new AliasAction.Add(index, "test", null, null, null, null))); + ClusterState after = service.applyAliasActions(before, singletonList(new AliasAction.Add(index, "test", null, null, null, null))); AliasOrIndex alias = after.metaData().getAliasAndIndexLookup().get("test"); assertNotNull(alias); assertTrue(alias.isAlias()); @@ -82,7 +82,7 @@ public void testAddAndRemove() { // Remove the alias from it while adding another one before = after; - after = service.innerExecute(before, Arrays.asList( + after = service.applyAliasActions(before, Arrays.asList( new AliasAction.Remove(index, "test"), new AliasAction.Add(index, "test_2", null, null, null, null))); assertNull(after.metaData().getAliasAndIndexLookup().get("test")); @@ -94,7 +94,7 @@ public void testAddAndRemove() { // Now just remove on its own before = after; - after = service.innerExecute(before, singletonList(new AliasAction.Remove(index, "test_2"))); + after = service.applyAliasActions(before, singletonList(new AliasAction.Remove(index, "test_2"))); assertNull(after.metaData().getAliasAndIndexLookup().get("test")); assertNull(after.metaData().getAliasAndIndexLookup().get("test_2")); assertAliasesVersionIncreased(index, before, after); @@ -110,7 +110,7 @@ public void testMultipleIndices() { before = createIndex(before, index); addActions.add(new AliasAction.Add(index, "alias-" + index, null, null, null, null)); } - final ClusterState afterAddingAliasesToAll = service.innerExecute(before, addActions); + final ClusterState afterAddingAliasesToAll = service.applyAliasActions(before, addActions); assertAliasesVersionIncreased(indices.toArray(new String[0]), before, afterAddingAliasesToAll); // now add some aliases randomly @@ -122,7 +122,7 @@ public void testMultipleIndices() { randomIndices.add(index); } } - final ClusterState afterAddingRandomAliases = service.innerExecute(afterAddingAliasesToAll, randomAddActions); + final ClusterState afterAddingRandomAliases = service.applyAliasActions(afterAddingAliasesToAll, randomAddActions); assertAliasesVersionIncreased(randomIndices.toArray(new String[0]), afterAddingAliasesToAll, afterAddingRandomAliases); assertAliasesVersionUnchanged( Sets.difference(indices, randomIndices).toArray(new String[0]), @@ -135,15 +135,15 @@ public void testChangingWriteAliasStateIncreasesAliasesVersion() { final ClusterState before = createIndex(ClusterState.builder(ClusterName.DEFAULT).build(), index); final ClusterState afterAddWriteAlias = - service.innerExecute(before, singletonList(new AliasAction.Add(index, "test", null, null, null, true))); + service.applyAliasActions(before, singletonList(new AliasAction.Add(index, "test", null, null, null, true))); assertAliasesVersionIncreased(index, before, afterAddWriteAlias); final ClusterState afterChangeWriteAliasToNonWriteAlias = - service.innerExecute(afterAddWriteAlias, singletonList(new AliasAction.Add(index, "test", null, null, null, false))); + service.applyAliasActions(afterAddWriteAlias, singletonList(new AliasAction.Add(index, "test", null, null, null, false))); assertAliasesVersionIncreased(index, afterAddWriteAlias, afterChangeWriteAliasToNonWriteAlias); final ClusterState afterChangeNonWriteAliasToWriteAlias = - service.innerExecute( + service.applyAliasActions( afterChangeWriteAliasToNonWriteAlias, singletonList(new AliasAction.Add(index, "test", null, null, null, true))); assertAliasesVersionIncreased(index, afterChangeWriteAliasToNonWriteAlias, afterChangeNonWriteAliasToWriteAlias); @@ -159,7 +159,7 @@ public void testAddingAliasMoreThanOnceShouldOnlyIncreaseAliasesVersionByOne() { for (int i = 0; i < length; i++) { addActions.add(new AliasAction.Add(index, "test", null, null, null, null)); } - final ClusterState afterAddingAliases = service.innerExecute(before, addActions); + final ClusterState afterAddingAliases = service.applyAliasActions(before, addActions); assertAliasesVersionIncreased(index, before, afterAddingAliases); } @@ -176,7 +176,7 @@ public void testAliasesVersionUnchangedWhenActionsAreIdempotent() { final String aliasName = randomValueOtherThanMany(v -> aliasNames.add(v) == false, () -> randomAlphaOfLength(8)); addActions.add(new AliasAction.Add(index, aliasName, null, null, null, null)); } - final ClusterState afterAddingAlias = service.innerExecute(before, addActions); + final ClusterState afterAddingAlias = service.applyAliasActions(before, addActions); // now perform a remove and add for each alias which is idempotent, the resulting aliases are unchanged final List removeAndAddActions = new ArrayList<>(2 * length); @@ -184,7 +184,7 @@ public void testAliasesVersionUnchangedWhenActionsAreIdempotent() { removeAndAddActions.add(new AliasAction.Remove(index, aliasName)); removeAndAddActions.add(new AliasAction.Add(index, aliasName, null, null, null, null)); } - final ClusterState afterRemoveAndAddAlias = service.innerExecute(afterAddingAlias, removeAndAddActions); + final ClusterState afterRemoveAndAddAlias = service.applyAliasActions(afterAddingAlias, removeAndAddActions); assertAliasesVersionUnchanged(index, afterAddingAlias, afterRemoveAndAddAlias); } @@ -194,7 +194,7 @@ public void testSwapIndexWithAlias() { before = createIndex(before, "test_2"); // Now remove "test" and add an alias to "test" to "test_2" in one go - ClusterState after = service.innerExecute(before, Arrays.asList( + ClusterState after = service.applyAliasActions(before, Arrays.asList( new AliasAction.Add("test_2", "test", null, null, null, null), new AliasAction.RemoveIndex("test"))); AliasOrIndex alias = after.metaData().getAliasAndIndexLookup().get("test"); @@ -209,7 +209,7 @@ public void testAddAliasToRemovedIndex() { ClusterState before = createIndex(ClusterState.builder(ClusterName.DEFAULT).build(), "test"); // Attempt to add an alias to "test" at the same time as we remove it - IndexNotFoundException e = expectThrows(IndexNotFoundException.class, () -> service.innerExecute(before, Arrays.asList( + IndexNotFoundException e = expectThrows(IndexNotFoundException.class, () -> service.applyAliasActions(before, Arrays.asList( new AliasAction.Add("test", "alias", null, null, null, null), new AliasAction.RemoveIndex("test")))); assertEquals("test", e.getIndex().getName()); @@ -220,7 +220,7 @@ public void testRemoveIndexTwice() { ClusterState before = createIndex(ClusterState.builder(ClusterName.DEFAULT).build(), "test"); // Try to remove an index twice. This should just remove the index once.... - ClusterState after = service.innerExecute(before, Arrays.asList( + ClusterState after = service.applyAliasActions(before, Arrays.asList( new AliasAction.RemoveIndex("test"), new AliasAction.RemoveIndex("test"))); assertNull(after.metaData().getAliasAndIndexLookup().get("test")); @@ -229,20 +229,20 @@ public void testRemoveIndexTwice() { public void testAddWriteOnlyWithNoExistingAliases() { ClusterState before = createIndex(ClusterState.builder(ClusterName.DEFAULT).build(), "test"); - ClusterState after = service.innerExecute(before, Arrays.asList( + ClusterState after = service.applyAliasActions(before, Arrays.asList( new AliasAction.Add("test", "alias", null, null, null, false))); assertFalse(after.metaData().index("test").getAliases().get("alias").writeIndex()); assertNull(((AliasOrIndex.Alias) after.metaData().getAliasAndIndexLookup().get("alias")).getWriteIndex()); assertAliasesVersionIncreased("test", before, after); - after = service.innerExecute(before, Arrays.asList( + after = service.applyAliasActions(before, Arrays.asList( new AliasAction.Add("test", "alias", null, null, null, null))); assertNull(after.metaData().index("test").getAliases().get("alias").writeIndex()); assertThat(((AliasOrIndex.Alias) after.metaData().getAliasAndIndexLookup().get("alias")).getWriteIndex(), equalTo(after.metaData().index("test"))); assertAliasesVersionIncreased("test", before, after); - after = service.innerExecute(before, Arrays.asList( + after = service.applyAliasActions(before, Arrays.asList( new AliasAction.Add("test", "alias", null, null, null, true))); assertTrue(after.metaData().index("test").getAliases().get("alias").writeIndex()); assertThat(((AliasOrIndex.Alias) after.metaData().getAliasAndIndexLookup().get("alias")).getWriteIndex(), @@ -259,7 +259,7 @@ public void testAddWriteOnlyWithExistingWriteIndex() { ClusterState before = ClusterState.builder(ClusterName.DEFAULT) .metaData(MetaData.builder().put(indexMetaData).put(indexMetaData2)).build(); - ClusterState after = service.innerExecute(before, Arrays.asList( + ClusterState after = service.applyAliasActions(before, Arrays.asList( new AliasAction.Add("test", "alias", null, null, null, null))); assertNull(after.metaData().index("test").getAliases().get("alias").writeIndex()); assertThat(((AliasOrIndex.Alias) after.metaData().getAliasAndIndexLookup().get("alias")).getWriteIndex(), @@ -267,7 +267,7 @@ public void testAddWriteOnlyWithExistingWriteIndex() { assertAliasesVersionIncreased("test", before, after); assertAliasesVersionUnchanged("test2", before, after); - Exception exception = expectThrows(IllegalStateException.class, () -> service.innerExecute(before, Arrays.asList( + Exception exception = expectThrows(IllegalStateException.class, () -> service.applyAliasActions(before, Arrays.asList( new AliasAction.Add("test", "alias", null, null, null, true)))); assertThat(exception.getMessage(), startsWith("alias [alias] has more than one write index [")); } @@ -287,7 +287,7 @@ public void testSwapWriteOnlyIndex() { new AliasAction.Add("test2", "alias", null, null, null, true) ); Collections.shuffle(swapActions, random()); - ClusterState after = service.innerExecute(before, swapActions); + ClusterState after = service.applyAliasActions(before, swapActions); assertThat(after.metaData().index("test").getAliases().get("alias").writeIndex(), equalTo(unsetValue)); assertTrue(after.metaData().index("test2").getAliases().get("alias").writeIndex()); assertThat(((AliasOrIndex.Alias) after.metaData().getAliasAndIndexLookup().get("alias")).getWriteIndex(), @@ -310,7 +310,7 @@ public void testAddWriteOnlyWithExistingNonWriteIndices() { assertNull(((AliasOrIndex.Alias) before.metaData().getAliasAndIndexLookup().get("alias")).getWriteIndex()); - ClusterState after = service.innerExecute(before, Arrays.asList( + ClusterState after = service.applyAliasActions(before, Arrays.asList( new AliasAction.Add("test3", "alias", null, null, null, true))); assertTrue(after.metaData().index("test3").getAliases().get("alias").writeIndex()); assertThat(((AliasOrIndex.Alias) after.metaData().getAliasAndIndexLookup().get("alias")).getWriteIndex(), @@ -334,7 +334,7 @@ public void testAddWriteOnlyWithIndexRemoved() { assertNull(before.metaData().index("test2").getAliases().get("alias").writeIndex()); assertNull(((AliasOrIndex.Alias) before.metaData().getAliasAndIndexLookup().get("alias")).getWriteIndex()); - ClusterState after = service.innerExecute(before, Collections.singletonList(new AliasAction.RemoveIndex("test"))); + ClusterState after = service.applyAliasActions(before, Collections.singletonList(new AliasAction.RemoveIndex("test"))); assertNull(after.metaData().index("test2").getAliases().get("alias").writeIndex()); assertThat(((AliasOrIndex.Alias) after.metaData().getAliasAndIndexLookup().get("alias")).getWriteIndex(), equalTo(after.metaData().index("test2"))); @@ -349,7 +349,7 @@ public void testAddWriteOnlyValidatesAgainstMetaDataBuilder() { ClusterState before = ClusterState.builder(ClusterName.DEFAULT) .metaData(MetaData.builder().put(indexMetaData).put(indexMetaData2)).build(); - Exception exception = expectThrows(IllegalStateException.class, () -> service.innerExecute(before, Arrays.asList( + Exception exception = expectThrows(IllegalStateException.class, () -> service.applyAliasActions(before, Arrays.asList( new AliasAction.Add("test", "alias", null, null, null, true), new AliasAction.Add("test2", "alias", null, null, null, true) )));