Skip to content

Commit 9e87a4e

Browse files
authored
Add Snapshot Lifecycle Management Package Docs (#43535)
1 parent 9a3b0db commit 9e87a4e

File tree

5 files changed

+129
-0
lines changed

5 files changed

+129
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
/**
8+
* Contains the action definitions for SLM. For the transport and rest action implementations, please see the <tt>ilm</tt> module's
9+
* <tt>org.elasticsearch.xpack.snapshotlifecycle</tt> package.
10+
*/
11+
package org.elasticsearch.xpack.core.snapshotlifecycle.action;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
/**
8+
* This package contains the utility classes used to persist SLM policy execution results to an internal index.
9+
*
10+
* <p>The {@link org.elasticsearch.xpack.core.snapshotlifecycle.history.SnapshotLifecycleTemplateRegistry} class is registered as a
11+
* cluster state listener when the ILM plugin starts up. It executes only on the elected master node, and ensures that a template is
12+
* configured for the SLM history index, as well as an ILM policy (since the two are always enabled in lock step).
13+
*
14+
* <p>The {@link org.elasticsearch.xpack.core.snapshotlifecycle.history.SnapshotHistoryItem} is used to encapsulate historical
15+
* information about a snapshot policy execution. This contains more data than the
16+
* {@link org.elasticsearch.xpack.core.snapshotlifecycle.SnapshotInvocationRecord} since it is a more complete history record
17+
* stored on disk instead of a low surface area status entry.
18+
*
19+
* <p>The {@link org.elasticsearch.xpack.core.snapshotlifecycle.history.SnapshotHistoryStore} manages the persistence of the previously
20+
* mentioned {@link org.elasticsearch.xpack.core.snapshotlifecycle.history.SnapshotHistoryItem}. It simply does an asynchronous put
21+
* operation against the SLM history internal index.
22+
*/
23+
package org.elasticsearch.xpack.core.snapshotlifecycle.history;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
/**
8+
* This is the Snapshot Lifecycle Management (SLM) core package. This package contains the core classes for SLM, including all of the
9+
* custom cluster state metadata objects, execution history storage facilities, and the action definitions. For the main SLM service
10+
* implementation classes, please see the <tt>ilm</tt> module's <tt>org.elasticsearch.xpack.snapshotlifecycle</tt> package.
11+
*
12+
* <p>Contained within this specific package are the custom metadata objects and models used through out the SLM service. The names can
13+
* be confusing, so it's important to know the differences between each metadata object.
14+
*
15+
* <p>The {@link org.elasticsearch.xpack.core.snapshotlifecycle.SnapshotLifecyclePolicy} object is the user provided definition of the
16+
* SLM policy. This is what a user provides when creating a snapshot policy, and acts as the blueprint for the create snapshot request
17+
* that the service launches. It additionally surfaces the next point in time a policy should be executed.
18+
*
19+
* <p>Lateral to the policy, the {@link org.elasticsearch.xpack.core.snapshotlifecycle.SnapshotInvocationRecord} represents an execution
20+
* of a policy. It includes within it the policy name and details about its execution, success or failure.
21+
*
22+
* <p>Next is the {@link org.elasticsearch.xpack.core.snapshotlifecycle.SnapshotLifecyclePolicyMetadata} object, which not only contains
23+
* the {@link org.elasticsearch.xpack.core.snapshotlifecycle.SnapshotLifecyclePolicy} blueprint, but also any contextual information about
24+
* that policy, like the user information of who created it so that it may be used during execution, as well as the version of the policy,
25+
* and both the last failed and successful runs as {@link org.elasticsearch.xpack.core.snapshotlifecycle.SnapshotInvocationRecord}s. This
26+
* is the living representation of a policy within the cluster state.
27+
*
28+
* <p>When a "Get Policy" action is executed, the {@link org.elasticsearch.xpack.core.snapshotlifecycle.SnapshotLifecyclePolicyItem} is
29+
* returned instead. This is a thin wrapper around the internal
30+
* {@link org.elasticsearch.xpack.core.snapshotlifecycle.SnapshotLifecyclePolicyMetadata} object so that we do not expose any sensitive
31+
* internal headers or user information in the Get API.
32+
*
33+
* <p>Finally, the {@link org.elasticsearch.xpack.core.snapshotlifecycle.SnapshotLifecycleMetadata} class contains all living SLM
34+
* policies and their metadata, acting as the SLM specific root object within the cluster state.
35+
*/
36+
package org.elasticsearch.xpack.core.snapshotlifecycle;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
/**
8+
* This package contains all the SLM Rest and Transport actions.
9+
*
10+
* <p>The {@link org.elasticsearch.xpack.snapshotlifecycle.action.TransportPutSnapshotLifecycleAction} creates or updates a snapshot
11+
* lifecycle policy in the cluster state. The {@link org.elasticsearch.xpack.snapshotlifecycle.action.TransportGetSnapshotLifecycleAction}
12+
* simply retrieves a policy by id. The {@link org.elasticsearch.xpack.snapshotlifecycle.action.TransportDeleteSnapshotLifecycleAction}
13+
* removes a policy from the cluster state. These actions only interact with the cluster state. Most of the logic that take place in
14+
* response to these actions happens on the master node in the {@link org.elasticsearch.xpack.snapshotlifecycle.SnapshotLifecycleService}.
15+
*
16+
* <p>The {@link org.elasticsearch.xpack.snapshotlifecycle.action.TransportExecuteSnapshotLifecycleAction} operates as if the snapshot
17+
* policy given was immediately triggered by the scheduler. It does not interfere with any currently scheduled operations, it just runs
18+
* the snapshot operation ad hoc.
19+
*/
20+
package org.elasticsearch.xpack.snapshotlifecycle.action;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
/**
8+
* This is the Snapshot Lifecycle Management (SLM) main package. SLM is part of the wider ILM feature, reusing quite a bit of the
9+
* functionality for itself in some places, which is why the two features are contained in the same plugin.
10+
*
11+
* This package contains the {@link org.elasticsearch.xpack.snapshotlifecycle.SnapshotLifecycleService} and
12+
* {@link org.elasticsearch.xpack.snapshotlifecycle.SnapshotLifecycleTask}, as well as the Rest and Transport actions for the
13+
* feature set.
14+
* This package contains the primary execution logic and most of the user facing
15+
* surface area for the plugin, but not everything. The model objects for the cluster state as well as several supporting classes are
16+
* contained in the {@link org.elasticsearch.xpack.core.snapshotlifecycle} package.
17+
*
18+
* <p>{@link org.elasticsearch.xpack.snapshotlifecycle.SnapshotLifecycleService} maintains an internal
19+
* {@link org.elasticsearch.xpack.core.scheduler.SchedulerEngine SchedulerEngine} that handles scheduling snapshots. The service
20+
* executes on the currently elected master node. It listens to the cluster state, detecting new policies to schedule, and unscheduling
21+
* policies when they are deleted or if ILM is stopped. The bulk of this scheduling management is handled within
22+
* {@link org.elasticsearch.xpack.snapshotlifecycle.SnapshotLifecycleService#maybeScheduleSnapshot(SnapshotLifecyclePolicyMetadata)}
23+
* which is executed on all snapshot policies each update.
24+
*
25+
* <p>The {@link org.elasticsearch.xpack.snapshotlifecycle.SnapshotLifecycleTask} object is what receives an event when a scheduled policy
26+
* is triggered for execution. It constructs a snapshot request and runs it as the user who originally set up the policy. The bulk of this
27+
* logic is contained in the
28+
* {@link org.elasticsearch.xpack.snapshotlifecycle.SnapshotLifecycleTask#maybeTakeSnapshot(String, Client, ClusterService,
29+
* SnapshotHistoryStore)} method. After a snapshot request has been submitted, it persists the result (success or failure) in a history
30+
* store (an index), caching the latest success and failure information in the cluster state. It is important to note that this task
31+
* fires the snapshot request off and forgets it; It does not wait until the entire snapshot completes. Any success or failure that this
32+
* task sees will be from the initial submission of the snapshot request only.
33+
*/
34+
package org.elasticsearch.xpack.snapshotlifecycle;
35+
36+
import org.elasticsearch.client.Client;
37+
import org.elasticsearch.cluster.service.ClusterService;
38+
import org.elasticsearch.xpack.core.snapshotlifecycle.SnapshotLifecyclePolicyMetadata;
39+
import org.elasticsearch.xpack.core.snapshotlifecycle.history.SnapshotHistoryStore;

0 commit comments

Comments
 (0)