Makes brnach compile
Commented out toSteps implem,entations and other bits needed to get the branch to compile
This commit is contained in:
parent
f429fc0b3e
commit
9972710e9e
|
@ -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<ShardRouting> 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<ShardRouting> 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<Step> 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<Step> 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
|
||||
|
|
|
@ -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<Step> toSteps(String phase, Index index, Client client, ThreadPool threadPool, LongSupplier nowSupplier) {
|
||||
String indexName = index.getName();
|
||||
return Collections.singletonList(new ClientStep<DeleteIndexRequestBuilder, DeleteIndexResponse>( "delete",
|
||||
NAME, phase, indexName, client.admin().indices().prepareDelete(indexName),
|
||||
clusterState -> clusterState.metaData().hasIndex(indexName), response -> true));
|
||||
public List<Step> toSteps(String phase) {
|
||||
// String indexName = index.getName();
|
||||
// return Collections.singletonList(new ClientStep<DeleteIndexRequestBuilder, DeleteIndexResponse>( "delete",
|
||||
// NAME, phase, indexName, client.admin().indices().prepareDelete(indexName),
|
||||
// clusterState -> clusterState.metaData().hasIndex(indexName), response -> true));
|
||||
return Arrays.asList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -97,36 +97,36 @@ public class ForceMergeAction implements LifecycleAction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Step> 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<Step> 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<IndicesSegmentsRequestBuilder, IndicesSegmentResponse> 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<ForceMergeRequestBuilder, ForceMergeResponse>( "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<IndicesSegmentsRequestBuilder, IndicesSegmentResponse> 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<ForceMergeRequestBuilder, ForceMergeResponse>( "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
|
||||
|
|
|
@ -83,14 +83,14 @@ public class ReplicasAction implements LifecycleAction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Step> 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<Step> 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() {
|
||||
|
|
|
@ -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<Step> toSteps(String phase, Index index, Client client, ThreadPool threadPool, LongSupplier nowSupplier) {
|
||||
public List<Step> 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...
|
||||
|
|
|
@ -104,24 +104,24 @@ public class ShrinkAction implements LifecycleAction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Step> 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<Step> 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<ResizeRequestBuilder, ResizeResponse> 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<ResizeRequestBuilder, ResizeResponse> 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
|
||||
|
|
|
@ -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<Step> toSteps(String phase, Index index, Client client, ThreadPool threadPool, LongSupplier nowSupplier) {
|
||||
public List<Step> toSteps(String phase) {
|
||||
return steps;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String, Phase> phases) {
|
||||
return phases.values().iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Phase nextPhase(Map<String, Phase> 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<String, Phase> phases) {
|
||||
// return phases.values().iterator().next();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Phase nextPhase(Map<String, Phase> 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<Phase> phases) {
|
||||
// always valid
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Phase> getOrderedPhases(Map<String, Phase> phases) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LifecycleAction> getOrderedActions(Phase phase) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue