Adds REST client support for starting and stopping ILM (#32609)
* Adds REST client support for PutOperationMode in ILM * Corrects licence headers * iter * add request converter test * Fixes tests * Creates start and stop actions for controlling ILM operation * Addresses review comments
This commit is contained in:
parent
2305cb8a6b
commit
8750d622fc
|
@ -20,10 +20,13 @@
|
|||
package org.elasticsearch.client;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleResponse;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyResponse;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -65,6 +68,60 @@ public class IndexLifecycleClient {
|
|||
SetIndexLifecyclePolicyResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Index Lifecycle Management feature.
|
||||
* See <a href="https://fix-me-when-we-have-docs.com">
|
||||
* the docs</a> 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 startILM(StartILMRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::startILM, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously start the Index Lifecycle Management feature.
|
||||
* See <a href="https://fix-me-when-we-have-docs.com">
|
||||
* the docs</a> 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 startILMAsync(StartILMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::startILM, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the Index Lifecycle Management feature.
|
||||
* See <a href="https://fix-me-when-we-have-docs.com">
|
||||
* the docs</a> 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 stopILM(StopILMRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::stopILM, options,
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously stop the Index Lifecycle Management feature.
|
||||
* See <a href="https://fix-me-when-we-have-docs.com">
|
||||
* the docs</a> 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 stopILMAsync(StopILMRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::stopILM, options,
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Explain the lifecycle state for an index
|
||||
* See <a href="https://fix-me-when-we-have-docs.com">
|
||||
|
|
|
@ -107,10 +107,12 @@ import org.elasticsearch.common.xcontent.XContentType;
|
|||
import org.elasticsearch.index.VersionType;
|
||||
import org.elasticsearch.index.rankeval.RankEvalRequest;
|
||||
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
|
||||
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
|
||||
import org.elasticsearch.protocol.xpack.XPackUsageRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
|
||||
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
|
||||
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
|
||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
|
||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
||||
|
@ -1170,6 +1172,30 @@ final class RequestConverters {
|
|||
return request;
|
||||
}
|
||||
|
||||
static Request startILM(StartILMRequest startILMRequest) {
|
||||
Request request = new Request(HttpPost.METHOD_NAME,
|
||||
new EndpointBuilder()
|
||||
.addPathPartAsIs("_ilm")
|
||||
.addPathPartAsIs("start")
|
||||
.build());
|
||||
Params params = new Params(request);
|
||||
params.withMasterTimeout(startILMRequest.masterNodeTimeout());
|
||||
params.withTimeout(startILMRequest.timeout());
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request stopILM(StopILMRequest stopILMRequest) {
|
||||
Request request = new Request(HttpPost.METHOD_NAME,
|
||||
new EndpointBuilder()
|
||||
.addPathPartAsIs("_ilm")
|
||||
.addPathPartAsIs("stop")
|
||||
.build());
|
||||
Params params = new Params(request);
|
||||
params.withMasterTimeout(stopILMRequest.masterNodeTimeout());
|
||||
params.withTimeout(stopILMRequest.timeout());
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request explainLifecycle(ExplainLifecycleRequest explainLifecycleRequest) {
|
||||
String[] indices = explainLifecycleRequest.indices() == null ? Strings.EMPTY_ARRAY : explainLifecycleRequest.indices();
|
||||
Request request = new Request(HttpGet.METHOD_NAME,
|
||||
|
|
|
@ -22,14 +22,19 @@ package org.elasticsearch.client;
|
|||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.nio.entity.NStringEntity;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
|
||||
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleResponse;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.IndexLifecycleExplainResponse;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyResponse;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
|
||||
import org.hamcrest.Matchers;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -106,6 +111,94 @@ public class IndexLifecycleIT extends ESRestHighLevelClientTestCase {
|
|||
assertThat(settingsResponse.getSetting("baz", "index.lifecycle.name"), equalTo(policy));
|
||||
}
|
||||
|
||||
public void testStartStopILM() throws Exception {
|
||||
String policy = randomAlphaOfLength(10);
|
||||
|
||||
// TODO: NORELEASE convert this to using the high level client once there are APIs for it
|
||||
String jsonString = "{\n" +
|
||||
" \"policy\": {\n" +
|
||||
" \"type\": \"timeseries\",\n" +
|
||||
" \"phases\": {\n" +
|
||||
" \"hot\": {\n" +
|
||||
" \"actions\": {\n" +
|
||||
" \"rollover\": {\n" +
|
||||
" \"max_age\": \"50d\"\n" +
|
||||
" } \n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"warm\": {\n" +
|
||||
" \"after\": \"1000s\",\n" +
|
||||
" \"actions\": {\n" +
|
||||
" \"allocate\": {\n" +
|
||||
" \"require\": { \"_name\": \"node-1\" },\n" +
|
||||
" \"include\": {},\n" +
|
||||
" \"exclude\": {}\n" +
|
||||
" },\n" +
|
||||
" \"shrink\": {\n" +
|
||||
" \"number_of_shards\": 1\n" +
|
||||
" },\n" +
|
||||
" \"forcemerge\": {\n" +
|
||||
" \"max_num_segments\": 1000\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"cold\": {\n" +
|
||||
" \"after\": \"2000s\",\n" +
|
||||
" \"actions\": {\n" +
|
||||
" \"allocate\": {\n" +
|
||||
" \"number_of_replicas\": 0\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"delete\": {\n" +
|
||||
" \"after\": \"3000s\",\n" +
|
||||
" \"actions\": {\n" +
|
||||
" \"delete\": {}\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
HttpEntity entity = new NStringEntity(jsonString, ContentType.APPLICATION_JSON);
|
||||
Request request = new Request("PUT", "/_ilm/" + policy);
|
||||
request.setEntity(entity);
|
||||
client().performRequest(request);
|
||||
|
||||
createIndex("foo", Settings.builder().put("index.lifecycle.name", "bar").build());
|
||||
createIndex("baz", Settings.builder().put("index.lifecycle.name", "eggplant").build());
|
||||
createIndex("squash", Settings.EMPTY);
|
||||
|
||||
// TODO: NORELEASE convert this to using the high level client once
|
||||
// there are APIs for it
|
||||
Request statusReq = new Request("GET", "/_ilm/status");
|
||||
Response statusResponse = client().performRequest(statusReq);
|
||||
String statusResponseString = EntityUtils.toString(statusResponse.getEntity());
|
||||
assertEquals("{\"operation_mode\":\"RUNNING\"}", statusResponseString);
|
||||
|
||||
StopILMRequest stopReq = new StopILMRequest();
|
||||
AcknowledgedResponse stopResponse = execute(stopReq, highLevelClient().indexLifecycle()::stopILM,
|
||||
highLevelClient().indexLifecycle()::stopILMAsync);
|
||||
assertTrue(stopResponse.isAcknowledged());
|
||||
|
||||
// TODO: NORELEASE convert this to using the high level client once there are APIs for it
|
||||
statusReq = new Request("GET", "/_ilm/status");
|
||||
statusResponse = client().performRequest(statusReq);
|
||||
statusResponseString = EntityUtils.toString(statusResponse.getEntity());
|
||||
assertThat(statusResponseString,
|
||||
Matchers.anyOf(equalTo("{\"operation_mode\":\"STOPPING\"}"), equalTo("{\"operation_mode\":\"STOPPED\"}")));
|
||||
|
||||
StartILMRequest startReq = new StartILMRequest();
|
||||
AcknowledgedResponse startResponse = execute(startReq, highLevelClient().indexLifecycle()::startILM,
|
||||
highLevelClient().indexLifecycle()::startILMAsync);
|
||||
assertTrue(startResponse.isAcknowledged());
|
||||
|
||||
// TODO: NORELEASE convert this to using the high level client once there are APIs for it
|
||||
statusReq = new Request("GET", "/_ilm/status");
|
||||
statusResponse = client().performRequest(statusReq);
|
||||
statusResponseString = EntityUtils.toString(statusResponse.getEntity());
|
||||
assertEquals("{\"operation_mode\":\"RUNNING\"}", statusResponseString);
|
||||
}
|
||||
|
||||
public void testExplainLifecycle() throws Exception {
|
||||
String policy = randomAlphaOfLength(10);
|
||||
|
||||
|
|
|
@ -128,6 +128,8 @@ import org.elasticsearch.index.rankeval.RestRankEvalAction;
|
|||
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
|
||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
|
||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
||||
import org.elasticsearch.repositories.fs.FsRepository;
|
||||
|
@ -2602,6 +2604,30 @@ public class RequestConvertersTests extends ESTestCase {
|
|||
assertThat(request.getParameters(), equalTo(expectedParams));
|
||||
}
|
||||
|
||||
public void testStartILM() throws Exception {
|
||||
StartILMRequest req = new StartILMRequest();
|
||||
Map<String, String> expectedParams = new HashMap<>();
|
||||
setRandomMasterTimeout(req, expectedParams);
|
||||
setRandomTimeout(req::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
|
||||
|
||||
Request request = RequestConverters.startILM(req);
|
||||
assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
|
||||
assertThat(request.getEndpoint(), equalTo("/_ilm/start"));
|
||||
assertThat(request.getParameters(), equalTo(expectedParams));
|
||||
}
|
||||
|
||||
public void testStopILM() throws Exception {
|
||||
StopILMRequest req = new StopILMRequest();
|
||||
Map<String, String> expectedParams = new HashMap<>();
|
||||
setRandomMasterTimeout(req, expectedParams);
|
||||
setRandomTimeout(req::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
|
||||
|
||||
Request request = RequestConverters.stopILM(req);
|
||||
assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
|
||||
assertThat(request.getEndpoint(), equalTo("/_ilm/stop"));
|
||||
assertThat(request.getParameters(), equalTo(expectedParams));
|
||||
}
|
||||
|
||||
public void testExplainLifecycle() throws Exception {
|
||||
ExplainLifecycleRequest req = new ExplainLifecycleRequest();
|
||||
String[] indices = rarely() ? null : randomIndicesNames(0, 10);
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.XPackPlugin.XPackMetaDataCustom;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.xpack.core.indexlifecycle.action;
|
||||
|
||||
import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedRequest;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PutOperationModeAction extends Action<PutOperationModeAction.Response> {
|
||||
public static final PutOperationModeAction INSTANCE = new PutOperationModeAction();
|
||||
public static final String NAME = "cluster:admin/ilm/operation_mode/set";
|
||||
|
||||
protected PutOperationModeAction() {
|
||||
super(NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response newResponse() {
|
||||
return new Response();
|
||||
}
|
||||
|
||||
public static class Response extends AcknowledgedResponse implements ToXContentObject {
|
||||
|
||||
public Response() {
|
||||
}
|
||||
|
||||
public Response(boolean acknowledged) {
|
||||
super(acknowledged);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Request extends AcknowledgedRequest<Request> {
|
||||
|
||||
private OperationMode mode;
|
||||
|
||||
public Request(OperationMode mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public Request() {
|
||||
}
|
||||
|
||||
public OperationMode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
if (mode == OperationMode.STOPPED) {
|
||||
ActionRequestValidationException exception = new ActionRequestValidationException();
|
||||
exception.addValidationError("cannot directly stop index-lifecycle");
|
||||
return exception;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
mode = in.readEnum(OperationMode.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeEnum(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (obj.getClass() != getClass()) {
|
||||
return false;
|
||||
}
|
||||
Request other = (Request) obj;
|
||||
return Objects.equals(mode, other.mode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.xpack.core.indexlifecycle.action;
|
||||
|
||||
import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
|
||||
public class StartILMAction extends Action<AcknowledgedResponse> {
|
||||
public static final StartILMAction INSTANCE = new StartILMAction();
|
||||
public static final String NAME = "cluster:admin/ilm/start";
|
||||
|
||||
protected StartILMAction() {
|
||||
super(NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AcknowledgedResponse newResponse() {
|
||||
return new AcknowledgedResponse();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.xpack.core.indexlifecycle.action;
|
||||
|
||||
import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
|
||||
public class StopILMAction extends Action<AcknowledgedResponse> {
|
||||
public static final StopILMAction INSTANCE = new StopILMAction();
|
||||
public static final String NAME = "cluster:admin/ilm/stop";
|
||||
|
||||
protected StopILMAction() {
|
||||
super(NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AcknowledgedResponse newResponse() {
|
||||
return new AcknowledgedResponse();
|
||||
}
|
||||
|
||||
}
|
|
@ -40,10 +40,11 @@ import org.elasticsearch.xpack.core.indexlifecycle.action.GetLifecycleAction;
|
|||
import org.elasticsearch.xpack.core.indexlifecycle.action.GetStatusAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.MoveToStepAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.RemovePolicyForIndexAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.SetIndexLifecyclePolicyAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.StartILMAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.StopILMAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.RestDeleteLifecycleAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.RestExplainLifecycleAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.RestGetLifecycleAction;
|
||||
|
@ -53,7 +54,7 @@ import org.elasticsearch.xpack.indexlifecycle.action.RestPutLifecycleAction;
|
|||
import org.elasticsearch.xpack.indexlifecycle.action.RestRemovePolicyForIndexAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.RestRetryAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.RestSetIndexLifecyclePolicyAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.RestStartAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.RestStartILMAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.RestStopAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.TransportDeleteLifecycleAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.TransportExplainLifecycleAction;
|
||||
|
@ -61,10 +62,11 @@ import org.elasticsearch.xpack.indexlifecycle.action.TransportGetLifecycleAction
|
|||
import org.elasticsearch.xpack.indexlifecycle.action.TransportGetStatusAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.TransportMoveToStepAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.TransportPutLifecycleAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.TransportPutOperationModeAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.TransportRemovePolicyForIndexAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.TransportRetryAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.TransportSetIndexLifecyclePolicyAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.TransportStartILMAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.action.TransportStopILMAction;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.util.ArrayList;
|
||||
|
@ -164,7 +166,7 @@ public class IndexLifecycle extends Plugin implements ActionPlugin {
|
|||
new RestMoveToStepAction(settings, restController),
|
||||
new RestRetryAction(settings, restController),
|
||||
new RestStopAction(settings, restController),
|
||||
new RestStartAction(settings, restController),
|
||||
new RestStartILMAction(settings, restController),
|
||||
new RestGetStatusAction(settings, restController)
|
||||
);
|
||||
}
|
||||
|
@ -183,7 +185,8 @@ public class IndexLifecycle extends Plugin implements ActionPlugin {
|
|||
new ActionHandler<>(RemovePolicyForIndexAction.INSTANCE, TransportRemovePolicyForIndexAction.class),
|
||||
new ActionHandler<>(MoveToStepAction.INSTANCE, TransportMoveToStepAction.class),
|
||||
new ActionHandler<>(RetryAction.INSTANCE, TransportRetryAction.class),
|
||||
new ActionHandler<>(PutOperationModeAction.INSTANCE, TransportPutOperationModeAction.class),
|
||||
new ActionHandler<>(StartILMAction.INSTANCE, TransportStartILMAction.class),
|
||||
new ActionHandler<>(StopILMAction.INSTANCE, TransportStopILMAction.class),
|
||||
new ActionHandler<>(GetStatusAction.INSTANCE, TransportGetStatusAction.class));
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ import org.elasticsearch.common.component.AbstractComponent;
|
|||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleSettings;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.ShrinkAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||
import org.elasticsearch.xpack.core.scheduler.SchedulerEngine;
|
||||
|
|
|
@ -10,8 +10,8 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.ClusterStateUpdateTask;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
|
||||
public class OperationModeUpdateTask extends ClusterStateUpdateTask {
|
||||
private static final Logger logger = ESLoggerFactory.getLogger(OperationModeUpdateTask.class);
|
||||
|
|
|
@ -8,16 +8,16 @@ package org.elasticsearch.xpack.indexlifecycle.action;
|
|||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.StartILMAction;
|
||||
|
||||
public class RestStartAction extends BaseRestHandler {
|
||||
public class RestStartILMAction extends BaseRestHandler {
|
||||
|
||||
public RestStartAction(Settings settings, RestController controller) {
|
||||
public RestStartILMAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST, "/_ilm/start", this);
|
||||
}
|
||||
|
@ -29,9 +29,9 @@ public class RestStartAction extends BaseRestHandler {
|
|||
|
||||
@Override
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) {
|
||||
PutOperationModeAction.Request request = new PutOperationModeAction.Request(OperationMode.RUNNING);
|
||||
StartILMRequest request = new StartILMRequest();
|
||||
request.timeout(restRequest.paramAsTime("timeout", request.timeout()));
|
||||
request.masterNodeTimeout(restRequest.paramAsTime("master_timeout", request.masterNodeTimeout()));
|
||||
return channel -> client.execute(PutOperationModeAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(StartILMAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
|
@ -8,12 +8,12 @@ package org.elasticsearch.xpack.indexlifecycle.action;
|
|||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.StopILMAction;
|
||||
|
||||
public class RestStopAction extends BaseRestHandler {
|
||||
|
||||
|
@ -29,9 +29,9 @@ public class RestStopAction extends BaseRestHandler {
|
|||
|
||||
@Override
|
||||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) {
|
||||
PutOperationModeAction.Request request = new PutOperationModeAction.Request(OperationMode.STOPPING);
|
||||
StopILMRequest request = new StopILMRequest();
|
||||
request.timeout(restRequest.paramAsTime("timeout", request.timeout()));
|
||||
request.masterNodeTimeout(restRequest.paramAsTime("master_timeout", request.masterNodeTimeout()));
|
||||
return channel -> client.execute(PutOperationModeAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(StopILMAction.INSTANCE, request, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.GetStatusAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.GetStatusAction.Request;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.GetStatusAction.Response;
|
||||
|
|
|
@ -19,12 +19,12 @@ import org.elasticsearch.cluster.metadata.MetaData;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.core.ClientHelper;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction.Request;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction.Response;
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.xpack.indexlifecycle.action;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
|
||||
import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.StartILMAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.OperationModeUpdateTask;
|
||||
|
||||
public class TransportStartILMAction extends TransportMasterNodeAction<StartILMRequest, AcknowledgedResponse> {
|
||||
|
||||
@Inject
|
||||
public TransportStartILMAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, StartILMAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver,
|
||||
StartILMRequest::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.SAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AcknowledgedResponse newResponse() {
|
||||
return new AcknowledgedResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(StartILMRequest request, ClusterState state, ActionListener<AcknowledgedResponse> listener) {
|
||||
clusterService.submitStateUpdateTask("ilm_operation_mode_update",
|
||||
new AckedClusterStateUpdateTask<AcknowledgedResponse>(request, listener) {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
return (new OperationModeUpdateTask(OperationMode.RUNNING)).execute(currentState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AcknowledgedResponse newResponse(boolean acknowledged) {
|
||||
return new AcknowledgedResponse(acknowledged);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(StartILMRequest request, ClusterState state) {
|
||||
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ package org.elasticsearch.xpack.indexlifecycle.action;
|
|||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
|
||||
import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
|
@ -17,21 +18,21 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction.Request;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction.Response;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.action.StopILMAction;
|
||||
import org.elasticsearch.xpack.indexlifecycle.OperationModeUpdateTask;
|
||||
|
||||
public class TransportPutOperationModeAction extends TransportMasterNodeAction<Request, Response> {
|
||||
public class TransportStopILMAction extends TransportMasterNodeAction<StopILMRequest, AcknowledgedResponse> {
|
||||
|
||||
@Inject
|
||||
public TransportPutOperationModeAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, PutOperationModeAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
indexNameExpressionResolver, Request::new);
|
||||
public TransportStopILMAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, StopILMAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver,
|
||||
StopILMRequest::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,28 +41,28 @@ public class TransportPutOperationModeAction extends TransportMasterNodeAction<R
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Response newResponse() {
|
||||
return new Response();
|
||||
protected AcknowledgedResponse newResponse() {
|
||||
return new AcknowledgedResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(Request request, ClusterState state, ActionListener<Response> listener) {
|
||||
protected void masterOperation(StopILMRequest request, ClusterState state, ActionListener<AcknowledgedResponse> listener) {
|
||||
clusterService.submitStateUpdateTask("ilm_operation_mode_update",
|
||||
new AckedClusterStateUpdateTask<Response>(request, listener) {
|
||||
new AckedClusterStateUpdateTask<AcknowledgedResponse>(request, listener) {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
return (new OperationModeUpdateTask(request.getMode())).execute(currentState);
|
||||
return (new OperationModeUpdateTask(OperationMode.STOPPING)).execute(currentState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Response newResponse(boolean acknowledged) {
|
||||
return new Response(acknowledged);
|
||||
protected AcknowledgedResponse newResponse(boolean acknowledged) {
|
||||
return new AcknowledgedResponse(acknowledged);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(Request request, ClusterState state) {
|
||||
protected ClusterBlockException checkBlock(StopILMRequest request, ClusterState state) {
|
||||
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import org.elasticsearch.common.transport.TransportAddress;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
|
||||
|
@ -27,7 +28,6 @@ import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyMetadata;
|
|||
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleSettings;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.MockAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.MockStep;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.Phase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.Step;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.elasticsearch.common.io.stream.Writeable.Reader;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.test.AbstractDiffableSerializationTestCase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.DeleteAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
|
||||
|
@ -24,7 +25,6 @@ import org.elasticsearch.xpack.core.indexlifecycle.LifecycleAction;
|
|||
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleType;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.Phase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.TestLifecycleType;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.elasticsearch.common.xcontent.ToXContentObject;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.AbstractStepTestCase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep;
|
||||
|
@ -36,7 +37,6 @@ import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyMetadata;
|
|||
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleSettings;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.MockAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.MockStep;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.Phase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.RolloverAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.Step;
|
||||
|
|
|
@ -24,13 +24,13 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleSettings;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.MockAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.Phase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.ShrinkAction;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.Step;
|
||||
|
|
|
@ -10,9 +10,9 @@ import org.elasticsearch.cluster.ClusterName;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.ErrorStep;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
|
||||
|
@ -22,7 +23,6 @@ import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
|
|||
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyMetadata;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyTests;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.MockStep;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
|
||||
import org.elasticsearch.xpack.core.indexlifecycle.Step;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
* 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.xpack.core.indexlifecycle;
|
||||
package org.elasticsearch.protocol.xpack.indexlifecycle;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.shrink.ShrinkAction;
|
||||
|
||||
/**
|
||||
* Enum representing the different modes that Index Lifecycle Service can operate in.
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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.protocol.xpack.indexlifecycle;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedRequest;
|
||||
|
||||
public class StartILMRequest extends AcknowledgedRequest<StartILMRequest> {
|
||||
|
||||
public StartILMRequest() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (obj.getClass() != getClass()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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.protocol.xpack.indexlifecycle;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedRequest;
|
||||
|
||||
public class StopILMRequest extends AcknowledgedRequest<StopILMRequest> {
|
||||
|
||||
public StopILMRequest() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 75;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (obj.getClass() != getClass()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.protocol.xpack.indexlifecycle;
|
||||
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
public class OperationModeTests extends ESTestCase {
|
||||
|
||||
public void testIsValidChange() {
|
||||
assertFalse(OperationMode.RUNNING.isValidChange(OperationMode.RUNNING));
|
||||
assertTrue(OperationMode.RUNNING.isValidChange(OperationMode.STOPPING));
|
||||
assertFalse(OperationMode.RUNNING.isValidChange(OperationMode.STOPPED));
|
||||
|
||||
assertTrue(OperationMode.STOPPING.isValidChange(OperationMode.RUNNING));
|
||||
assertFalse(OperationMode.STOPPING.isValidChange(OperationMode.STOPPING));
|
||||
assertTrue(OperationMode.STOPPING.isValidChange(OperationMode.STOPPED));
|
||||
|
||||
assertTrue(OperationMode.STOPPED.isValidChange(OperationMode.RUNNING));
|
||||
assertFalse(OperationMode.STOPPED.isValidChange(OperationMode.STOPPING));
|
||||
assertFalse(OperationMode.STOPPED.isValidChange(OperationMode.STOPPED));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.protocol.xpack.indexlifecycle;
|
||||
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
|
||||
public class StartILMRequestTests extends AbstractStreamableTestCase<StartILMRequest> {
|
||||
|
||||
@Override
|
||||
protected StartILMRequest createBlankInstance() {
|
||||
return new StartILMRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StartILMRequest createTestInstance() {
|
||||
return new StartILMRequest();
|
||||
}
|
||||
|
||||
public void testValidate() {
|
||||
StartILMRequest request = createTestInstance();
|
||||
assertNull(request.validate());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.protocol.xpack.indexlifecycle;
|
||||
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
|
||||
public class StopILMRequestTests extends AbstractStreamableTestCase<StopILMRequest> {
|
||||
|
||||
@Override
|
||||
protected StopILMRequest createBlankInstance() {
|
||||
return new StopILMRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StopILMRequest createTestInstance() {
|
||||
return new StopILMRequest();
|
||||
}
|
||||
|
||||
public void testValidate() {
|
||||
StopILMRequest request = createTestInstance();
|
||||
assertNull(request.validate());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue