Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Snapshot Lifecycle Management #43934

Merged
merged 75 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
960041e
Add SnapshotLifecycleService and related CRUD APIs
dakrone Feb 25, 2019
acb8135
Make scheduledJobIds return an immutable set
dakrone Mar 12, 2019
d7b41e0
Use Object.equals for SnapshotLifecyclePolicy
dakrone Mar 12, 2019
0043de4
Remove unneeded TODO
dakrone Mar 12, 2019
54ac17c
Implement ToXContentFragment on SnapshotLifecyclePolicyItem
dakrone Mar 12, 2019
c5f7738
Copy contents of the scheduledJobIds
dakrone Mar 12, 2019
06a6a13
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Mar 13, 2019
25ebdf3
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Mar 14, 2019
6d0aad5
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Mar 15, 2019
4ba731a
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Mar 18, 2019
1738b9b
Handle snapshot lifecycle policy updates and deletions (#40062)
dakrone Mar 18, 2019
6837354
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Mar 21, 2019
817dd41
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Mar 22, 2019
8095a32
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Mar 26, 2019
5b97fff
Take a snapshot for the policy when the SLM policy is triggered (#40383)
dakrone Mar 26, 2019
1f5811b
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Mar 28, 2019
4321b24
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 1, 2019
c0b2a70
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 2, 2019
51d7f0e
Record most recent snapshot policy success/failure (#40619)
gwbrown Apr 2, 2019
a53da7d
Validate snapshot lifecycle policies (#40654)
dakrone Apr 3, 2019
3a19a30
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 4, 2019
68b4387
Hook SLM into ILM's start and stop APIs (#40871)
dakrone Apr 8, 2019
9074c08
Add tests for SnapshotLifecyclePolicyItem (#40912)
gwbrown Apr 8, 2019
06e616a
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 8, 2019
e8d40d8
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 9, 2019
bddbd00
Fix improper import in build.gradle after master merge
dakrone Apr 9, 2019
d4fab06
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 10, 2019
e564b48
Add human readable version of modified date for snapshot lifecycle po…
dakrone Apr 11, 2019
1b4574a
Add API to execute SLM policy on demand (#41038)
dakrone Apr 12, 2019
5797aaa
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 12, 2019
ead7146
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 15, 2019
7ea37fe
Add next_execution to SLM policy metadata (#41221)
dakrone Apr 16, 2019
d6de587
Change SLM endpoint from /_ilm/* to /_slm/* (#41320)
dakrone Apr 22, 2019
a7d18da
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 22, 2019
5736be6
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 24, 2019
e13ebd1
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 26, 2019
47b5655
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Apr 29, 2019
d63d521
Add initial documentation for SLM (#41510)
dakrone Apr 29, 2019
acc3749
Add `manage_slm` and `read_slm` roles (#41607)
dakrone Apr 29, 2019
1adcd6d
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone May 2, 2019
f316925
Merge branch 'master' into snapshot-lifecycle-management
gwbrown May 8, 2019
1684aaa
Merge branch 'master' into snapshot-lifecycle-management
gwbrown May 9, 2019
d0973fc
Record SLM history into an index (#41707)
gwbrown May 10, 2019
8216a3c
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone May 20, 2019
ce945a8
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone May 21, 2019
dc973a5
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone May 28, 2019
e6ce229
High Level Rest Client support for SLM (#41767)
dakrone May 28, 2019
7427724
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone May 29, 2019
ce649f4
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone May 31, 2019
7fe4d05
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Jun 3, 2019
0adf14d
Add security test testing SLM cluster privileges (#42678)
dakrone Jun 4, 2019
f452ecd
Add Getting Started Guide for SLM (#42878)
gwbrown Jun 5, 2019
c89a5bc
Merge branch 'master' into snapshot-lifecycle-management
gwbrown Jun 6, 2019
27173fa
Merge branch 'master' into snapshot-lifecycle-management
gwbrown Jun 10, 2019
c7669b3
Include SLM policy name in Snapshot metadata (#43132)
gwbrown Jun 13, 2019
6baaa39
Merge branch 'master' into snapshot-lifecycle-management
gwbrown Jun 14, 2019
9bd7de5
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Jun 20, 2019
1232e05
Fix compilation after master merge
dakrone Jun 20, 2019
0138f52
[TEST] Move exception wrapping for devious exception throwing
dakrone Jun 20, 2019
404be63
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Jun 25, 2019
9a3b0db
Fix SLM for the change to AcknowledgedResponse
dakrone Jun 25, 2019
9e87a4e
Add Snapshot Lifecycle Management Package Docs (#43535)
jbaiera Jun 25, 2019
a26e302
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Jun 26, 2019
6393ac8
Fix compilation for transport actions now that task is required
dakrone Jun 26, 2019
88d915e
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Jul 1, 2019
1a9988e
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Jul 2, 2019
91fdcb5
Add a note mentioning the privileges needed for SLM (#43708)
dakrone Jul 3, 2019
1055836
Merge remote-tracking branch 'origin/master' into snapshot-lifecycle-…
dakrone Jul 3, 2019
1af1f8d
Fix REST tests for new number of cluster privileges
dakrone Jul 3, 2019
dc3a284
Mute testThatNonExistingTemplatesAreAddedImmediately (#43951)
gwbrown Jul 3, 2019
8f25b3c
Merge branch 'master' into snapshot-lifecycle-management
gwbrown Jul 5, 2019
8806125
Merge branch 'master' into snapshot-lifecycle-management
gwbrown Jul 10, 2019
74b4e75
Fix SnapshotHistoryStoreTests after merge
gwbrown Jul 10, 2019
6aa24fa
Merge branch 'master' into snapshot-lifecycle-management
elasticmachine Jul 15, 2019
aacd841
Remove overridden newResponse functions that have been removed
dakrone Jul 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
import org.elasticsearch.client.indexlifecycle.RetryLifecyclePolicyRequest;
import org.elasticsearch.client.indexlifecycle.StartILMRequest;
import org.elasticsearch.client.indexlifecycle.StopILMRequest;
import org.elasticsearch.client.snapshotlifecycle.DeleteSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.snapshotlifecycle.ExecuteSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.snapshotlifecycle.ExecuteSnapshotLifecyclePolicyResponse;
import org.elasticsearch.client.snapshotlifecycle.GetSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.snapshotlifecycle.GetSnapshotLifecyclePolicyResponse;
import org.elasticsearch.client.snapshotlifecycle.PutSnapshotLifecyclePolicyRequest;

import java.io.IOException;

Expand Down Expand Up @@ -300,4 +306,144 @@ public void retryLifecyclePolicyAsync(RetryLifecyclePolicyRequest request, Reque
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::retryLifecycle, options,
AcknowledgedResponse::fromXContent, listener, emptySet());
}

/**
* Retrieve one or more snapshot lifecycle policy definitions.
* See <pre>
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
* java-rest-high-ilm-slm-get-snapshot-lifecycle-policy.html
* </pre>
* for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public GetSnapshotLifecyclePolicyResponse getSnapshotLifecyclePolicy(GetSnapshotLifecyclePolicyRequest request,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecyclePolicy,
options, GetSnapshotLifecyclePolicyResponse::fromXContent, emptySet());
}

/**
* Asynchronously retrieve one or more snapshot lifecycle policy definition.
* See <pre>
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
* java-rest-high-ilm-slm-get-snapshot-lifecycle-policy.html
* </pre>
* for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
*/
public void getSnapshotLifecyclePolicyAsync(GetSnapshotLifecyclePolicyRequest request, RequestOptions options,
ActionListener<GetSnapshotLifecyclePolicyResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecyclePolicy,
options, GetSnapshotLifecyclePolicyResponse::fromXContent, listener, emptySet());
}

/**
* Create or modify a snapshot lifecycle definition.
* See <pre>
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
* java-rest-high-ilm-slm-put-snapshot-lifecycle-policy.html
* </pre>
* for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public AcknowledgedResponse putSnapshotLifecyclePolicy(PutSnapshotLifecyclePolicyRequest request,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::putSnapshotLifecyclePolicy,
options, AcknowledgedResponse::fromXContent, emptySet());
}

/**
* Asynchronously create or modify a snapshot lifecycle definition.
* See <pre>
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
* java-rest-high-ilm-slm-put-snapshot-lifecycle-policy.html
* </pre>
* for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
*/
public void putSnapshotLifecyclePolicyAsync(PutSnapshotLifecyclePolicyRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::putSnapshotLifecyclePolicy,
options, AcknowledgedResponse::fromXContent, listener, emptySet());
}

/**
* Delete a snapshot lifecycle definition
* See <pre>
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
* java-rest-high-ilm-slm-delete-snapshot-lifecycle-policy.html
* </pre>
* for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public AcknowledgedResponse deleteSnapshotLifecyclePolicy(DeleteSnapshotLifecyclePolicyRequest request,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::deleteSnapshotLifecyclePolicy,
options, AcknowledgedResponse::fromXContent, emptySet());
}

/**
* Asynchronously delete a snapshot lifecycle definition
* See <pre>
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
* java-rest-high-ilm-slm-delete-snapshot-lifecycle-policy.html
* </pre>
* for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
*/
public void deleteSnapshotLifecyclePolicyAsync(DeleteSnapshotLifecyclePolicyRequest request, RequestOptions options,
ActionListener<AcknowledgedResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::deleteSnapshotLifecyclePolicy,
options, AcknowledgedResponse::fromXContent, listener, emptySet());
}

/**
* Execute a snapshot lifecycle definition
* See <pre>
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
* java-rest-high-ilm-slm-execute-snapshot-lifecycle-policy.html
* </pre>
* for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public ExecuteSnapshotLifecyclePolicyResponse executeSnapshotLifecyclePolicy(ExecuteSnapshotLifecyclePolicyRequest request,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(request, IndexLifecycleRequestConverters::executeSnapshotLifecyclePolicy,
options, ExecuteSnapshotLifecyclePolicyResponse::fromXContent, emptySet());
}

/**
* Asynchronously execute a snapshot lifecycle definition
* See <pre>
* https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/
* java-rest-high-ilm-slm-execute-snapshot-lifecycle-policy.html
* </pre>
* for more.
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
*/
public void executeSnapshotLifecyclePolicyAsync(ExecuteSnapshotLifecyclePolicyRequest request, RequestOptions options,
ActionListener<ExecuteSnapshotLifecyclePolicyResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::executeSnapshotLifecyclePolicy,
options, ExecuteSnapshotLifecyclePolicyResponse::fromXContent, listener, emptySet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
import org.elasticsearch.client.indexlifecycle.RetryLifecyclePolicyRequest;
import org.elasticsearch.client.indexlifecycle.StartILMRequest;
import org.elasticsearch.client.indexlifecycle.StopILMRequest;
import org.elasticsearch.client.snapshotlifecycle.DeleteSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.snapshotlifecycle.ExecuteSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.snapshotlifecycle.GetSnapshotLifecyclePolicyRequest;
import org.elasticsearch.client.snapshotlifecycle.PutSnapshotLifecyclePolicyRequest;
import org.elasticsearch.common.Strings;

import java.io.IOException;
Expand Down Expand Up @@ -159,4 +163,56 @@ static Request retryLifecycle(RetryLifecyclePolicyRequest retryLifecyclePolicyRe
request.addParameters(params.asMap());
return request;
}

static Request getSnapshotLifecyclePolicy(GetSnapshotLifecyclePolicyRequest getSnapshotLifecyclePolicyRequest) {
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_slm/policy")
.addCommaSeparatedPathParts(getSnapshotLifecyclePolicyRequest.getPolicyIds()).build();
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
RequestConverters.Params params = new RequestConverters.Params();
params.withMasterTimeout(getSnapshotLifecyclePolicyRequest.masterNodeTimeout());
params.withTimeout(getSnapshotLifecyclePolicyRequest.timeout());
request.addParameters(params.asMap());
return request;
}

static Request putSnapshotLifecyclePolicy(PutSnapshotLifecyclePolicyRequest putSnapshotLifecyclePolicyRequest) throws IOException {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_slm/policy")
.addPathPartAsIs(putSnapshotLifecyclePolicyRequest.getPolicy().getId())
.build();
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
RequestConverters.Params params = new RequestConverters.Params();
params.withMasterTimeout(putSnapshotLifecyclePolicyRequest.masterNodeTimeout());
params.withTimeout(putSnapshotLifecyclePolicyRequest.timeout());
request.addParameters(params.asMap());
request.setEntity(RequestConverters.createEntity(putSnapshotLifecyclePolicyRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
}

static Request deleteSnapshotLifecyclePolicy(DeleteSnapshotLifecyclePolicyRequest deleteSnapshotLifecyclePolicyRequest) {
Request request = new Request(HttpDelete.METHOD_NAME,
new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_slm/policy")
.addPathPartAsIs(deleteSnapshotLifecyclePolicyRequest.getPolicyId())
.build());
RequestConverters.Params params = new RequestConverters.Params();
params.withMasterTimeout(deleteSnapshotLifecyclePolicyRequest.masterNodeTimeout());
params.withTimeout(deleteSnapshotLifecyclePolicyRequest.timeout());
request.addParameters(params.asMap());
return request;
}

static Request executeSnapshotLifecyclePolicy(ExecuteSnapshotLifecyclePolicyRequest executeSnapshotLifecyclePolicyRequest) {
Request request = new Request(HttpPut.METHOD_NAME,
new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_slm/policy")
.addPathPartAsIs(executeSnapshotLifecyclePolicyRequest.getPolicyId())
.addPathPartAsIs("_execute")
.build());
RequestConverters.Params params = new RequestConverters.Params();
params.withMasterTimeout(executeSnapshotLifecyclePolicyRequest.masterNodeTimeout());
params.withTimeout(executeSnapshotLifecyclePolicyRequest.timeout());
request.addParameters(params.asMap());
return request;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.client.snapshotlifecycle;

import org.elasticsearch.client.TimedRequest;

import java.util.Objects;

public class DeleteSnapshotLifecyclePolicyRequest extends TimedRequest {
private final String policyId;

public DeleteSnapshotLifecyclePolicyRequest(String policyId) {
this.policyId = policyId;
}

public String getPolicyId() {
return this.policyId;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DeleteSnapshotLifecyclePolicyRequest other = (DeleteSnapshotLifecyclePolicyRequest) o;
return this.policyId.equals(other.policyId);
}

@Override
public int hashCode() {
return Objects.hash(this.policyId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.client.snapshotlifecycle;

import org.elasticsearch.client.TimedRequest;

import java.util.Objects;

public class ExecuteSnapshotLifecyclePolicyRequest extends TimedRequest {
private final String policyId;

public ExecuteSnapshotLifecyclePolicyRequest(String policyId) {
this.policyId = policyId;
}

public String getPolicyId() {
return this.policyId;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ExecuteSnapshotLifecyclePolicyRequest other = (ExecuteSnapshotLifecyclePolicyRequest) o;
return this.policyId.equals(other.policyId);
}

@Override
public int hashCode() {
return Objects.hash(this.policyId);
}
}
Loading