Skip to content

Commit

Permalink
ILM: add frozen phase (#60983) (#61035)
Browse files Browse the repository at this point in the history
This adds a frozen phase to ILM that will allow the execution of the
set_priority, unfollow, allocate, freeze and searchable_snapshot actions.

The frozen phase will be executed after the cold and before the delete phase.

(cherry picked from commit 6d01480)
Signed-off-by: Andrei Dan <andrei.dan@elastic.co>
  • Loading branch information
andreidan authored Aug 12, 2020
1 parent 25404cb commit 32173a8
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/reference/ilm/actions/ilm-allocate.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[[ilm-allocate]]
=== Allocate

Phases allowed: warm, cold.
Phases allowed: warm, cold, frozen.

Updates the index settings to change which nodes are allowed to host the index shards
and change the number of replicas.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ilm/actions/ilm-freeze.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[[ilm-freeze]]
=== Freeze

Phases allowed: cold.
Phases allowed: cold, frozen.

<<frozen-indices, Freezes>> an index to minimize its memory footprint.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[[ilm-searchable-snapshot]]
=== Searchable snapshot

Phases allowed: cold.
Phases allowed: cold, frozen.

Takes a snapshot of the managed index in the configured repository
and mounts it as a searchable snapshot.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ilm/actions/ilm-set-priority.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[[ilm-set-priority]]
=== Set priority

Phases allowed: hot, warm, cold.
Phases allowed: hot, warm, cold, frozen.

Sets the <<recovery-prioritization, priority>> of the index as
soon as the policy enters the hot, warm, or cold phase.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ilm/actions/ilm-unfollow.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[[ilm-unfollow]]
=== Unfollow

Phases allowed: hot, warm, cold.
Phases allowed: hot, warm, cold, frozen.

Converts a {ref}/ccr-apis.html[{ccr-init}] follower index into a regular index.
This enables the shrink, rollover, and searchable snapshot actions
Expand Down
13 changes: 12 additions & 1 deletion docs/reference/ilm/ilm-index-lifecycle.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
<titleabbrev>Index lifecycle</titleabbrev>
++++

{ilm-init} defines four index lifecycle _phases_:
{ilm-init} defines five index lifecycle _phases_:

* **Hot**: The index is actively being updated and queried.
* **Warm**: The index is no longer being updated but is still being queried.
* **Cold**: The index is no longer being updated and is seldom queried. The
information still needs to be searchable, but it's okay if those queries are
slower.
* **Frozen**: The index is no longer being updated and is seldom queried. The
queries are performing longer-term analyses for which a slower response is
acceptable.
* **Delete**: The index is no longer needed and can safely be removed.

An index's _lifecycle policy_ specifies which phases
Expand Down Expand Up @@ -93,6 +96,14 @@ the rollover criteria, it could be 20 minutes before the rollover is complete.
ifdef::permanently-unreleased-branch[]
- <<ilm-searchable-snapshot, Searchable Snapshot>>
endif::[]
* Frozen
- <<ilm-set-priority-action,Set Priority>>
- <<ilm-unfollow-action,Unfollow>>
- <<ilm-allocate,Allocate>>
- <<ilm-freeze,Freeze>>
ifdef::permanently-unreleased-branch[]
- <<ilm-searchable-snapshot, Searchable Snapshot>>
endif::[]
* Delete
- <<ilm-wait-for-snapshot-action,Wait For Snapshot>>
- <<ilm-delete,Delete>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,30 @@ public class TimeseriesLifecycleType implements LifecycleType {
static final String HOT_PHASE = "hot";
static final String WARM_PHASE = "warm";
static final String COLD_PHASE = "cold";
static final String FROZEN_PHASE = "frozen";
static final String DELETE_PHASE = "delete";
static final List<String> VALID_PHASES = Arrays.asList(HOT_PHASE, WARM_PHASE, COLD_PHASE, DELETE_PHASE);
static final List<String> VALID_PHASES = Arrays.asList(HOT_PHASE, WARM_PHASE, COLD_PHASE, FROZEN_PHASE, DELETE_PHASE);
static final List<String> ORDERED_VALID_HOT_ACTIONS = Arrays.asList(SetPriorityAction.NAME, UnfollowAction.NAME, RolloverAction.NAME,
ForceMergeAction.NAME);
static final List<String> ORDERED_VALID_WARM_ACTIONS = Arrays.asList(SetPriorityAction.NAME, UnfollowAction.NAME, ReadOnlyAction.NAME,
AllocateAction.NAME, ShrinkAction.NAME, ForceMergeAction.NAME);
static final List<String> ORDERED_VALID_COLD_ACTIONS = Arrays.asList(SetPriorityAction.NAME, UnfollowAction.NAME, AllocateAction.NAME,
FreezeAction.NAME, SearchableSnapshotAction.NAME);
static final List<String> ORDERED_VALID_FROZEN_ACTIONS = Arrays.asList(SetPriorityAction.NAME, UnfollowAction.NAME, AllocateAction.NAME,
FreezeAction.NAME, SearchableSnapshotAction.NAME);
static final List<String> ORDERED_VALID_DELETE_ACTIONS = Arrays.asList(WaitForSnapshotAction.NAME, DeleteAction.NAME);
static final Set<String> VALID_HOT_ACTIONS = Sets.newHashSet(ORDERED_VALID_HOT_ACTIONS);
static final Set<String> VALID_WARM_ACTIONS = Sets.newHashSet(ORDERED_VALID_WARM_ACTIONS);
static final Set<String> VALID_COLD_ACTIONS = Sets.newHashSet(ORDERED_VALID_COLD_ACTIONS);
static final Set<String> VALID_FROZEN_ACTIONS = Sets.newHashSet(ORDERED_VALID_FROZEN_ACTIONS);
static final Set<String> VALID_DELETE_ACTIONS = Sets.newHashSet(ORDERED_VALID_DELETE_ACTIONS);
private static Map<String, Set<String>> ALLOWED_ACTIONS = new HashMap<>();

static {
ALLOWED_ACTIONS.put(HOT_PHASE, VALID_HOT_ACTIONS);
ALLOWED_ACTIONS.put(WARM_PHASE, VALID_WARM_ACTIONS);
ALLOWED_ACTIONS.put(COLD_PHASE, VALID_COLD_ACTIONS);
ALLOWED_ACTIONS.put(FROZEN_PHASE, VALID_FROZEN_ACTIONS);
ALLOWED_ACTIONS.put(DELETE_PHASE, VALID_DELETE_ACTIONS);
}

Expand Down Expand Up @@ -141,6 +146,9 @@ public List<LifecycleAction> getOrderedActions(Phase phase) {
case COLD_PHASE:
return ORDERED_VALID_COLD_ACTIONS.stream().map(a -> actions.getOrDefault(a, null))
.filter(Objects::nonNull).collect(Collectors.toList());
case FROZEN_PHASE:
return ORDERED_VALID_FROZEN_ACTIONS.stream().map(a -> actions.getOrDefault(a, null))
.filter(Objects::nonNull).collect(Collectors.toList());
case DELETE_PHASE:
return ORDERED_VALID_DELETE_ACTIONS.stream().map(a -> actions.getOrDefault(a, null))
.filter(Objects::nonNull).collect(Collectors.toList());
Expand All @@ -162,6 +170,9 @@ public String getNextActionName(String currentActionName, Phase phase) {
case COLD_PHASE:
orderedActionNames = ORDERED_VALID_COLD_ACTIONS;
break;
case FROZEN_PHASE:
orderedActionNames = ORDERED_VALID_FROZEN_ACTIONS;
break;
case DELETE_PHASE:
orderedActionNames = ORDERED_VALID_DELETE_ACTIONS;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public static LifecyclePolicy randomTimeseriesLifecyclePolicyWithAllPhases(@Null
return TimeseriesLifecycleType.VALID_WARM_ACTIONS;
case "cold":
return TimeseriesLifecycleType.VALID_COLD_ACTIONS;
case "frozen":
return TimeseriesLifecycleType.VALID_FROZEN_ACTIONS;
case "delete":
return TimeseriesLifecycleType.VALID_DELETE_ACTIONS;
default:
Expand Down Expand Up @@ -161,6 +163,8 @@ public static LifecyclePolicy randomTimeseriesLifecyclePolicy(@Nullable String l
return TimeseriesLifecycleType.VALID_WARM_ACTIONS;
case "cold":
return TimeseriesLifecycleType.VALID_COLD_ACTIONS;
case "frozen":
return TimeseriesLifecycleType.VALID_FROZEN_ACTIONS;
case "delete":
return TimeseriesLifecycleType.VALID_DELETE_ACTIONS;
default:
Expand Down
Loading

0 comments on commit 32173a8

Please sign in to comment.