From 9972710e9e61d90ab1aceced57b54d1d17b30ddb Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Tue, 27 Mar 2018 12:14:38 +0100 Subject: [PATCH] Makes brnach compile Commented out toSteps implem,entations and other bits needed to get the branch to compile --- .../core/indexlifecycle/AllocateAction.java | 106 +++++++++--------- .../core/indexlifecycle/DeleteAction.java | 12 +- .../core/indexlifecycle/ForceMergeAction.java | 58 +++++----- .../core/indexlifecycle/ReplicasAction.java | 16 +-- .../core/indexlifecycle/RolloverAction.java | 10 +- .../core/indexlifecycle/ShrinkAction.java | 106 +++++++++--------- .../xpack/core/indexlifecycle/MockAction.java | 7 +- .../indexlifecycle/TestLifecycleType.java | 58 +++++----- 8 files changed, 184 insertions(+), 189 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/AllocateAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/AllocateAction.java index 19531f930bc..5f750db39d5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/AllocateAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/AllocateAction.java @@ -144,62 +144,62 @@ public class AllocateAction implements LifecycleAction { }).forEach(e -> newSettingsBuilder.put(settingPrefix + e.getKey(), e.getValue())); } - public static ConditionalWaitStep getAllocationCheck(AllocationDeciders allocationDeciders, String phase, String index) { - return new ConditionalWaitStep("wait_allocation", NAME, - phase, index, (clusterState) -> { - // We only want to make progress if all shards are active so check that first - if (ActiveShardCount.ALL.enoughShardsActive(clusterState, index) == false) { - logger.debug("[{}] lifecycle action for index [{}] cannot make progress because not all shards are active", NAME, - index); - return false; - } - - // All the allocation attributes are already set so just need to - // check if the allocation has happened - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, clusterState.getRoutingNodes(), clusterState, null, - System.nanoTime()); - int allocationPendingShards = 0; - List allShards = clusterState.getRoutingTable().allShards(index); - for (ShardRouting shardRouting : allShards) { - assert shardRouting.active() : "Shard not active, found " + shardRouting.state() + "for shard with id: " - + shardRouting.shardId(); - String currentNodeId = shardRouting.currentNodeId(); - boolean canRemainOnCurrentNode = allocationDeciders.canRemain(shardRouting, - clusterState.getRoutingNodes().node(currentNodeId), allocation).type() == Decision.Type.YES; - if (canRemainOnCurrentNode == false) { - allocationPendingShards++; - } - } - if (allocationPendingShards > 0) { - logger.debug("[{}] lifecycle action for index [{}] waiting for [{}] shards " - + "to be allocated to nodes matching the given filters", NAME, index, allocationPendingShards); - return false; - } else { - logger.debug("[{}] lifecycle action for index [{}] complete", NAME, index); - return true; - } - }); - } +// public static ConditionalWaitStep getAllocationCheck(AllocationDeciders allocationDeciders, String phase, String index) { +// return new ConditionalWaitStep("wait_allocation", NAME, +// phase, index, (clusterState) -> { +// // We only want to make progress if all shards are active so check that first +// if (ActiveShardCount.ALL.enoughShardsActive(clusterState, index) == false) { +// logger.debug("[{}] lifecycle action for index [{}] cannot make progress because not all shards are active", NAME, +// index); +// return false; +// } +// +// // All the allocation attributes are already set so just need to +// // check if the allocation has happened +// RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, clusterState.getRoutingNodes(), clusterState, null, +// System.nanoTime()); +// int allocationPendingShards = 0; +// List allShards = clusterState.getRoutingTable().allShards(index); +// for (ShardRouting shardRouting : allShards) { +// assert shardRouting.active() : "Shard not active, found " + shardRouting.state() + "for shard with id: " +// + shardRouting.shardId(); +// String currentNodeId = shardRouting.currentNodeId(); +// boolean canRemainOnCurrentNode = allocationDeciders.canRemain(shardRouting, +// clusterState.getRoutingNodes().node(currentNodeId), allocation).type() == Decision.Type.YES; +// if (canRemainOnCurrentNode == false) { +// allocationPendingShards++; +// } +// } +// if (allocationPendingShards > 0) { +// logger.debug("[{}] lifecycle action for index [{}] waiting for [{}] shards " +// + "to be allocated to nodes matching the given filters", NAME, index, allocationPendingShards); +// return false; +// } else { +// logger.debug("[{}] lifecycle action for index [{}] complete", NAME, index); +// return true; +// } +// }); +// } @Override - public List toSteps(String phase, Index index, Client client, ThreadPool threadPool, LongSupplier nowSupplier) { - ClusterStateUpdateStep updateAllocationSettings = new ClusterStateUpdateStep( - "update_allocation", NAME, phase, index.getName(), (clusterState) -> { - IndexMetaData idxMeta = clusterState.metaData().index(index); - if (idxMeta == null) { - return clusterState; - } - Settings existingSettings = idxMeta.getSettings(); - Settings.Builder newSettings = Settings.builder(); - addMissingAttrs(include, IndexMetaData.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey(), existingSettings, newSettings); - addMissingAttrs(exclude, IndexMetaData.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey(), existingSettings, newSettings); - addMissingAttrs(require, IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey(), existingSettings, newSettings); - return ClusterState.builder(clusterState) - .metaData(MetaData.builder(clusterState.metaData()) - .updateSettings(newSettings.build(), index.getName())).build(); - }); + public List toSteps(String phase) { +// ClusterStateUpdateStep updateAllocationSettings = new ClusterStateUpdateStep( +// "update_allocation", NAME, phase, index.getName(), (clusterState) -> { +// IndexMetaData idxMeta = clusterState.metaData().index(index); +// if (idxMeta == null) { +// return clusterState; +// } +// Settings existingSettings = idxMeta.getSettings(); +// Settings.Builder newSettings = Settings.builder(); +// addMissingAttrs(include, IndexMetaData.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey(), existingSettings, newSettings); +// addMissingAttrs(exclude, IndexMetaData.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey(), existingSettings, newSettings); +// addMissingAttrs(require, IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey(), existingSettings, newSettings); +// return ClusterState.builder(clusterState) +// .metaData(MetaData.builder(clusterState.metaData()) +// .updateSettings(newSettings.build(), index.getName())).build(); +// }); - return Arrays.asList(updateAllocationSettings, getAllocationCheck(allocationDeciders, phase, index.getName())); + return Arrays.asList(); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java index fd0e55c999a..84344d1d928 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.index.Index; import org.elasticsearch.threadpool.ThreadPool; import java.io.IOException; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.function.LongSupplier; @@ -67,11 +68,12 @@ public class DeleteAction implements LifecycleAction { } @Override - public List toSteps(String phase, Index index, Client client, ThreadPool threadPool, LongSupplier nowSupplier) { - String indexName = index.getName(); - return Collections.singletonList(new ClientStep( "delete", - NAME, phase, indexName, client.admin().indices().prepareDelete(indexName), - clusterState -> clusterState.metaData().hasIndex(indexName), response -> true)); + public List toSteps(String phase) { +// String indexName = index.getName(); +// return Collections.singletonList(new ClientStep( "delete", +// NAME, phase, indexName, client.admin().indices().prepareDelete(indexName), +// clusterState -> clusterState.metaData().hasIndex(indexName), response -> true)); + return Arrays.asList(); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ForceMergeAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ForceMergeAction.java index c3b0ccc398f..47460dfeea7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ForceMergeAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ForceMergeAction.java @@ -97,36 +97,36 @@ public class ForceMergeAction implements LifecycleAction { } @Override - public List toSteps(String phase, Index index, Client client, ThreadPool threadPool, LongSupplier nowSupplier) { - ClusterStateUpdateStep readOnlyStep = new ClusterStateUpdateStep( - "read_only", NAME, phase, index.getName(), (currentState) -> { - Settings readOnlySettings = Settings.builder().put(IndexMetaData.SETTING_BLOCKS_WRITE, true).build(); - return ClusterState.builder(currentState).metaData(MetaData.builder(currentState.metaData()) - .updateSettings(readOnlySettings, index.getName())).build(); - }); + public List toSteps(String phase) { +// ClusterStateUpdateStep readOnlyStep = new ClusterStateUpdateStep( +// "read_only", NAME, phase, index.getName(), (currentState) -> { +// Settings readOnlySettings = Settings.builder().put(IndexMetaData.SETTING_BLOCKS_WRITE, true).build(); +// return ClusterState.builder(currentState).metaData(MetaData.builder(currentState.metaData()) +// .updateSettings(readOnlySettings, index.getName())).build(); +// }); +// +// ClientStep segmentCount = new ClientStep<>( "segment_count", +// NAME, phase, index.getName(), +// client.admin().indices().prepareSegments(index.getName()), +// currentState -> false, response -> { +// // check if has too many segments +// return StreamSupport.stream(response.getIndices().get(index.getName()).spliterator(), false) +// .anyMatch(iss -> Arrays.stream(iss.getShards()).anyMatch(p -> p.getSegments().size() > maxNumSegments)); +// }); +// +// ClientStep forceMerge = new ClientStep( "force_merge", +// NAME, phase, index.getName(), +// client.admin().indices().prepareForceMerge(index.getName()).setMaxNumSegments(maxNumSegments), +// currentState -> false, response -> RestStatus.OK.equals(response.getStatus())); +// +// ClusterStateUpdateStep readWriteStep = new ClusterStateUpdateStep( +// "read_only", NAME, phase, index.getName(), (currentState) -> { +// Settings readOnlySettings = Settings.builder().put(IndexMetaData.SETTING_BLOCKS_WRITE, false).build(); +// return ClusterState.builder(currentState).metaData(MetaData.builder(currentState.metaData()) +// .updateSettings(readOnlySettings, index.getName())).build(); +// }); - ClientStep segmentCount = new ClientStep<>( "segment_count", - NAME, phase, index.getName(), - client.admin().indices().prepareSegments(index.getName()), - currentState -> false, response -> { - // check if has too many segments - return StreamSupport.stream(response.getIndices().get(index.getName()).spliterator(), false) - .anyMatch(iss -> Arrays.stream(iss.getShards()).anyMatch(p -> p.getSegments().size() > maxNumSegments)); - }); - - ClientStep forceMerge = new ClientStep( "force_merge", - NAME, phase, index.getName(), - client.admin().indices().prepareForceMerge(index.getName()).setMaxNumSegments(maxNumSegments), - currentState -> false, response -> RestStatus.OK.equals(response.getStatus())); - - ClusterStateUpdateStep readWriteStep = new ClusterStateUpdateStep( - "read_only", NAME, phase, index.getName(), (currentState) -> { - Settings readOnlySettings = Settings.builder().put(IndexMetaData.SETTING_BLOCKS_WRITE, false).build(); - return ClusterState.builder(currentState).metaData(MetaData.builder(currentState.metaData()) - .updateSettings(readOnlySettings, index.getName())).build(); - }); - - return Arrays.asList(readOnlyStep, segmentCount, forceMerge, readWriteStep); + return Arrays.asList(); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ReplicasAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ReplicasAction.java index 82ed6dc0ef2..f248c09d7d3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ReplicasAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ReplicasAction.java @@ -83,14 +83,14 @@ public class ReplicasAction implements LifecycleAction { } @Override - public List toSteps(String phase, Index index, Client client, ThreadPool threadPool, LongSupplier nowSupplier) { - ClusterStateUpdateStep updateAllocationSettings = new ClusterStateUpdateStep( - "update_replica_count", NAME, phase, index.getName(), (currentState) -> - ClusterState.builder(currentState).metaData(MetaData.builder(currentState.metaData()) - .updateNumberOfReplicas(numberOfReplicas, index.getName())).build()); - ConditionalWaitStep isReplicatedCheck = new ConditionalWaitStep("wait_replicas_allocated", NAME, - phase, index.getName(), (currentState) -> ActiveShardCount.ALL.enoughShardsActive(currentState, index.getName()) ); - return Arrays.asList(updateAllocationSettings, isReplicatedCheck); + public List toSteps(String phase) { +// ClusterStateUpdateStep updateAllocationSettings = new ClusterStateUpdateStep( +// "update_replica_count", NAME, phase, index.getName(), (currentState) -> +// ClusterState.builder(currentState).metaData(MetaData.builder(currentState.metaData()) +// .updateNumberOfReplicas(numberOfReplicas, index.getName())).build()); +// ConditionalWaitStep isReplicatedCheck = new ConditionalWaitStep("wait_replicas_allocated", NAME, +// phase, index.getName(), (currentState) -> ActiveShardCount.ALL.enoughShardsActive(currentState, index.getName()) ); + return Arrays.asList(); } public int getNumberOfReplicas() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/RolloverAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/RolloverAction.java index 93798c7fd14..a6da1dfd884 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/RolloverAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/RolloverAction.java @@ -6,11 +6,6 @@ package org.elasticsearch.xpack.core.indexlifecycle; import org.apache.logging.log4j.Logger; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.indices.rollover.RolloverRequest; -import org.elasticsearch.action.admin.indices.rollover.RolloverResponse; -import org.elasticsearch.client.Client; -import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; @@ -22,14 +17,11 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser; import org.elasticsearch.common.xcontent.ObjectParser.ValueType; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.Index; -import org.elasticsearch.threadpool.ThreadPool; import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.function.LongSupplier; /** * A {@link LifecycleAction} which deletes the index. @@ -153,7 +145,7 @@ public class RolloverAction implements LifecycleAction { } @Override - public List toSteps(String phase, Index index, Client client, ThreadPool threadPool, LongSupplier nowSupplier) { + public List toSteps(String phase) { return Collections.emptyList(); // ConditionalWaitStep wait = new ConditionalWaitStep(clusterService, "wait_for_rollover", index.getName(), phase, action, (clusterState) -> { // // TODO(talevy): actually, needs to RolloverRequest with dryrun to get the appropriate data; clusterState is not enough... diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ShrinkAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ShrinkAction.java index 2cd9dcc58b1..5afd035cb1b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ShrinkAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ShrinkAction.java @@ -104,24 +104,24 @@ public class ShrinkAction implements LifecycleAction { } @Override - public List toSteps(String phase, Index index, Client client, ThreadPool threadPool, LongSupplier nowSupplier) { - String shrunkenIndexName = SHRUNK_INDEX_NAME_PREFIX + index.getName(); - // TODO(talevy): magical node.name to allocate to - String nodeName = "MAGIC"; - ClusterStateUpdateStep updateAllocationToOneNode = new ClusterStateUpdateStep( - "move_to_single_node", NAME, phase, index.getName(), (clusterState) -> { - IndexMetaData idxMeta = clusterState.metaData().index(index); - if (idxMeta == null) { - return clusterState; - } - Settings.Builder newSettings = Settings.builder() - .put(IndexMetaData.INDEX_ROUTING_INCLUDE_GROUP_PREFIX, "") - .put(IndexMetaData.INDEX_ROUTING_EXCLUDE_GROUP_PREFIX, "") - .put(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "_name", nodeName); - return ClusterState.builder(clusterState) - .metaData(MetaData.builder(clusterState.metaData()) - .updateSettings(newSettings.build(), index.getName())).build(); - }); + public List toSteps(String phase) { +// String shrunkenIndexName = SHRUNK_INDEX_NAME_PREFIX + index.getName(); +// // TODO(talevy): magical node.name to allocate to +// String nodeName = "MAGIC"; +// ClusterStateUpdateStep updateAllocationToOneNode = new ClusterStateUpdateStep( +// "move_to_single_node", NAME, phase, index.getName(), (clusterState) -> { +// IndexMetaData idxMeta = clusterState.metaData().index(index); +// if (idxMeta == null) { +// return clusterState; +// } +// Settings.Builder newSettings = Settings.builder() +// .put(IndexMetaData.INDEX_ROUTING_INCLUDE_GROUP_PREFIX, "") +// .put(IndexMetaData.INDEX_ROUTING_EXCLUDE_GROUP_PREFIX, "") +// .put(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "_name", nodeName); +// return ClusterState.builder(clusterState) +// .metaData(MetaData.builder(clusterState.metaData()) +// .updateSettings(newSettings.build(), index.getName())).build(); +// }); // resizeRequest.getTargetIndexRequest().settings(Settings.builder() // .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numberOfShards) @@ -132,42 +132,42 @@ public class ShrinkAction implements LifecycleAction { // resizeRequest.getTargetIndexRequest().alias(new Alias(aliasMetaDataObjectCursor.value.alias())); // }); - // TODO(talevy): needs access to original index metadata, not just Index - int numReplicas = -1; - long lifecycleDate = -1L; - Settings targetIndexSettings = Settings.builder() - .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numberOfShards) - .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, numReplicas) - .put(LifecycleSettings.LIFECYCLE_INDEX_CREATION_DATE, lifecycleDate) - .build(); - CreateIndexRequest targetIndexRequest = new CreateIndexRequest(shrunkenIndexName, targetIndexSettings); +// // TODO(talevy): needs access to original index metadata, not just Index +// int numReplicas = -1; +// long lifecycleDate = -1L; +// Settings targetIndexSettings = Settings.builder() +// .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numberOfShards) +// .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, numReplicas) +// .put(LifecycleSettings.LIFECYCLE_INDEX_CREATION_DATE, lifecycleDate) +// .build(); +// CreateIndexRequest targetIndexRequest = new CreateIndexRequest(shrunkenIndexName, targetIndexSettings); // TODO(talevy): need access to indexmetadata // indexMetaData.getAliases().values().spliterator().forEachRemaining(aliasMetaDataObjectCursor -> { // resizeRequest.getTargetIndexRequest().alias(new Alias(aliasMetaDataObjectCursor.value.alias())); // }); - ClientStep shrinkStep = new ClientStep<>( "segment_count", - NAME, phase, index.getName(), - - client.admin().indices().prepareResizeIndex(index.getName(), shrunkenIndexName).setTargetIndex(targetIndexRequest), - currentState -> { - // check that shrunken index was already created, if so, no need to both client - IndexMetaData shrunkMetaData = currentState.metaData().index(shrunkenIndexName); - return shrunkMetaData != null && shrunkenIndexName.equals(IndexMetaData.INDEX_SHRINK_SOURCE_NAME - .get(shrunkMetaData.getSettings())); - - }, ResizeResponse::isAcknowledged); - - - ConditionalWaitStep shrunkenIndexIsAllocated = new ConditionalWaitStep("wait_replicas_allocated", NAME, - phase, index.getName(), (currentState) -> ActiveShardCount.ALL.enoughShardsActive(currentState, index.getName()) ); - - ClusterStateUpdateStep deleteAndUpdateAliases = new ClusterStateUpdateStep( - "delete_this_index_set_aliases_on_shrunken", NAME, phase, index.getName(), (clusterState) -> { - IndexMetaData idxMeta = clusterState.metaData().index(index); - if (idxMeta == null) { - return clusterState; - } +// ClientStep shrinkStep = new ClientStep<>( "segment_count", +// NAME, phase, index.getName(), +// +// client.admin().indices().prepareResizeIndex(index.getName(), shrunkenIndexName).setTargetIndex(targetIndexRequest), +// currentState -> { +// // check that shrunken index was already created, if so, no need to both client +// IndexMetaData shrunkMetaData = currentState.metaData().index(shrunkenIndexName); +// return shrunkMetaData != null && shrunkenIndexName.equals(IndexMetaData.INDEX_SHRINK_SOURCE_NAME +// .get(shrunkMetaData.getSettings())); +// +// }, ResizeResponse::isAcknowledged); +// +// +// ConditionalWaitStep shrunkenIndexIsAllocated = new ConditionalWaitStep("wait_replicas_allocated", NAME, +// phase, index.getName(), (currentState) -> ActiveShardCount.ALL.enoughShardsActive(currentState, index.getName()) ); +// +// ClusterStateUpdateStep deleteAndUpdateAliases = new ClusterStateUpdateStep( +// "delete_this_index_set_aliases_on_shrunken", NAME, phase, index.getName(), (clusterState) -> { +// IndexMetaData idxMeta = clusterState.metaData().index(index); +// if (idxMeta == null) { +// return clusterState; +// } // TODO(talevy): expose - MetadataDeleteIndexService.deleteIndices(clusterState, Set.of(index.getName())) // also, looks like deletes are special CS tasks @@ -176,12 +176,10 @@ public class ShrinkAction implements LifecycleAction { // 1. delete index // 2. assign alias to shrunken index // 3. assign index.lifecycle settings to shrunken index - return clusterState; - }); +// return clusterState; +// }); - return Arrays.asList(updateAllocationToOneNode, - AllocateAction.getAllocationCheck(allocationDeciders, phase, index.getName()), - shrinkStep, shrunkenIndexIsAllocated, deleteAndUpdateAliases); + return Arrays.asList(); } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/MockAction.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/MockAction.java index 6293400abfd..492302a9c0d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/MockAction.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/MockAction.java @@ -6,8 +6,6 @@ package org.elasticsearch.xpack.core.indexlifecycle; import org.apache.lucene.util.SetOnce; -import org.elasticsearch.client.Client; -import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; @@ -15,15 +13,12 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ConstructingObjectParser; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.Index; -import org.elasticsearch.threadpool.ThreadPool; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicLong; -import java.util.function.LongSupplier; public class MockAction implements LifecycleAction { public static final ParseField COMPLETED_FIELD = new ParseField("completed"); @@ -89,7 +84,7 @@ public class MockAction implements LifecycleAction { } @Override - public List toSteps(String phase, Index index, Client client, ThreadPool threadPool, LongSupplier nowSupplier) { + public List toSteps(String phase) { return steps; } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/TestLifecycleType.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/TestLifecycleType.java index b181c77cd86..87ba8cafc33 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/TestLifecycleType.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/TestLifecycleType.java @@ -5,14 +5,12 @@ */ package org.elasticsearch.xpack.core.indexlifecycle; -import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy.NextActionProvider; import java.io.IOException; import java.util.Collection; +import java.util.List; import java.util.Map; -import java.util.Optional; public class TestLifecycleType implements LifecycleType { public static final TestLifecycleType INSTANCE = new TestLifecycleType(); @@ -41,31 +39,41 @@ public class TestLifecycleType implements LifecycleType { // return a -> Optional.ofNullable(phase.getActions().entrySet().iterator().next()).map(Map.Entry::getValue).orElse(null); // } - @Override - public Phase getFirstPhase(Map phases) { - return phases.values().iterator().next(); - } - - @Override - public Phase nextPhase(Map phases, @Nullable Phase currentPhase) { - if (currentPhase == null) { - return getFirstPhase(phases); - } - - boolean foundPhase = false; - for (Phase phase : phases.values()) { - if (foundPhase) { - return phase; - } else if (phase.equals(currentPhase)) { - foundPhase = true; - } - } - - return null; - } +// @Override +// public Phase getFirstPhase(Map phases) { +// return phases.values().iterator().next(); +// } +// +// @Override +// public Phase nextPhase(Map phases, @Nullable Phase currentPhase) { +// if (currentPhase == null) { +// return getFirstPhase(phases); +// } +// +// boolean foundPhase = false; +// for (Phase phase : phases.values()) { +// if (foundPhase) { +// return phase; +// } else if (phase.equals(currentPhase)) { +// foundPhase = true; +// } +// } +// +// return null; +// } @Override public void validate(Collection phases) { // always valid } + + @Override + public List getOrderedPhases(Map phases) { + return null; + } + + @Override + public List getOrderedActions(Phase phase) { + return null; + } }