Duplicate Protocol classes into Core

This is needed as with recent changes to master (see #32952), protocol
is no longer accessible from core, so these classes need to be
duplicated in both places.
This commit is contained in:
Gordon Brown 2018-08-23 13:50:15 -06:00
parent 191bd7c031
commit 650f12af1e
39 changed files with 1390 additions and 47 deletions

View File

@ -439,26 +439,29 @@ public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPl
new NamedXContentRegistry.Entry(Task.Status.class, new ParseField(RollupJobStatus.NAME),
RollupJobStatus::fromXContent),
new NamedXContentRegistry.Entry(PersistentTaskState.class, new ParseField(RollupJobStatus.NAME),
RollupJobStatus::fromXContent),
RollupJobStatus::fromXContent)
// ILM
new NamedXContentRegistry.Entry(org.elasticsearch.protocol.xpack.indexlifecycle.LifecycleAction.class,
new ParseField(org.elasticsearch.protocol.xpack.indexlifecycle.AllocateAction.NAME),
org.elasticsearch.protocol.xpack.indexlifecycle.AllocateAction::parse),
new NamedXContentRegistry.Entry(org.elasticsearch.protocol.xpack.indexlifecycle.LifecycleAction.class,
new ParseField(org.elasticsearch.protocol.xpack.indexlifecycle.DeleteAction.NAME),
org.elasticsearch.protocol.xpack.indexlifecycle.DeleteAction::parse),
new NamedXContentRegistry.Entry(org.elasticsearch.protocol.xpack.indexlifecycle.LifecycleAction.class,
new ParseField(org.elasticsearch.protocol.xpack.indexlifecycle.ForceMergeAction.NAME),
org.elasticsearch.protocol.xpack.indexlifecycle.ForceMergeAction::parse),
new NamedXContentRegistry.Entry(org.elasticsearch.protocol.xpack.indexlifecycle.LifecycleAction.class,
new ParseField(org.elasticsearch.protocol.xpack.indexlifecycle.ReadOnlyAction.NAME),
org.elasticsearch.protocol.xpack.indexlifecycle.ReadOnlyAction::parse),
new NamedXContentRegistry.Entry(org.elasticsearch.protocol.xpack.indexlifecycle.LifecycleAction.class,
new ParseField(org.elasticsearch.protocol.xpack.indexlifecycle.RolloverAction.NAME),
org.elasticsearch.protocol.xpack.indexlifecycle.RolloverAction::parse),
new NamedXContentRegistry.Entry(org.elasticsearch.protocol.xpack.indexlifecycle.LifecycleAction.class,
new ParseField(org.elasticsearch.protocol.xpack.indexlifecycle.ShrinkAction.NAME),
org.elasticsearch.protocol.xpack.indexlifecycle.ShrinkAction::parse)
// TODO NORELEASE: These lines may not be necessary, and they cause errors if present
// as they are duplicated in IndexLifecycle.
// Leaving this for now in case they are necessary as we move forward with the HLRC.
// new NamedXContentRegistry.Entry(LifecycleAction.class,
// new ParseField(org.elasticsearch.xpack.core.indexlifecycle.AllocateAction.NAME),
// org.elasticsearch.xpack.core.indexlifecycle.AllocateAction::parse),
// new NamedXContentRegistry.Entry(org.elasticsearch.xpack.core.indexlifecycle.LifecycleAction.class,
// new ParseField(org.elasticsearch.xpack.core.indexlifecycle.DeleteAction.NAME),
// org.elasticsearch.xpack.core.indexlifecycle.DeleteAction::parse),
// new NamedXContentRegistry.Entry(org.elasticsearch.xpack.core.indexlifecycle.LifecycleAction.class,
// new ParseField(org.elasticsearch.xpack.core.indexlifecycle.ForceMergeAction.NAME),
// org.elasticsearch.xpack.core.indexlifecycle.ForceMergeAction::parse),
// new NamedXContentRegistry.Entry(org.elasticsearch.xpack.core.indexlifecycle.LifecycleAction.class,
// new ParseField(org.elasticsearch.xpack.core.indexlifecycle.ReadOnlyAction.NAME),
// org.elasticsearch.xpack.core.indexlifecycle.ReadOnlyAction::parse),
// new NamedXContentRegistry.Entry(org.elasticsearch.xpack.core.indexlifecycle.LifecycleAction.class,
// new ParseField(org.elasticsearch.xpack.core.indexlifecycle.RolloverAction.NAME),
// org.elasticsearch.xpack.core.indexlifecycle.RolloverAction::parse),
// new NamedXContentRegistry.Entry(org.elasticsearch.xpack.core.indexlifecycle.LifecycleAction.class,
// new ParseField(org.elasticsearch.xpack.core.indexlifecycle.ShrinkAction.NAME),
// org.elasticsearch.xpack.core.indexlifecycle.ShrinkAction::parse)
);
}

View File

@ -0,0 +1,61 @@
/*
* 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;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.master.info.ClusterInfoRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
/**
* The request object used by the Explain Lifecycle API.
*
* Multiple indices may be queried in the same request using the
* {@link #indices(String...)} method
*/
public class ExplainLifecycleRequest extends ClusterInfoRequest<ExplainLifecycleRequest> {
public ExplainLifecycleRequest() {
super();
}
public ExplainLifecycleRequest(StreamInput in) throws IOException {
super(in);
}
@Override
public ActionRequestValidationException validate() {
return null;
}
@Override
public int hashCode() {
return Objects.hash(Arrays.hashCode(indices()), indicesOptions());
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj.getClass() != getClass()) {
return false;
}
ExplainLifecycleRequest other = (ExplainLifecycleRequest) obj;
return Objects.deepEquals(indices(), other.indices()) &&
Objects.equals(indicesOptions(), other.indicesOptions());
}
@Override
public String toString() {
return "ExplainLifecycleRequest [indices()=" + Arrays.toString(indices()) + ", indicesOptions()=" + indicesOptions() + "]";
}
}

View File

@ -0,0 +1,122 @@
/*
* 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;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
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.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* The response object returned by the Explain Lifecycle API.
*
* Since the API can be run over multiple indices the response provides a map of
* index to the explanation of the lifecycle status for that index.
*/
public class ExplainLifecycleResponse extends ActionResponse implements ToXContentObject {
public static final ParseField INDICES_FIELD = new ParseField("indices");
private Map<String, IndexLifecycleExplainResponse> indexResponses;
@SuppressWarnings("unchecked")
private static final ConstructingObjectParser<ExplainLifecycleResponse, Void> PARSER = new ConstructingObjectParser<>(
"explain_lifecycle_response", a -> new ExplainLifecycleResponse(((List<IndexLifecycleExplainResponse>) a[0]).stream()
.collect(Collectors.toMap(IndexLifecycleExplainResponse::getIndex, Function.identity()))));
static {
PARSER.declareNamedObjects(ConstructingObjectParser.constructorArg(), (p, c, n) -> IndexLifecycleExplainResponse.PARSER.apply(p, c),
INDICES_FIELD);
}
public static ExplainLifecycleResponse fromXContent(XContentParser parser) {
return PARSER.apply(parser, null);
}
public ExplainLifecycleResponse() {
}
public ExplainLifecycleResponse(Map<String, IndexLifecycleExplainResponse> indexResponses) {
this.indexResponses = indexResponses;
}
/**
* @return a map of the responses from each requested index. The maps key is
* the index name and the value is the
* {@link IndexLifecycleExplainResponse} describing the current
* lifecycle status of that index
*/
public Map<String, IndexLifecycleExplainResponse> getIndexResponses() {
return indexResponses;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.startObject(INDICES_FIELD.getPreferredName());
for (IndexLifecycleExplainResponse indexResponse : indexResponses.values()) {
builder.field(indexResponse.getIndex(), indexResponse);
}
builder.endObject();
builder.endObject();
return builder;
}
@Override
public void readFrom(StreamInput in) throws IOException {
int size = in.readVInt();
Map<String, IndexLifecycleExplainResponse> indexResponses = new HashMap<>(size);
for (int i = 0; i < size; i++) {
IndexLifecycleExplainResponse indexResponse = new IndexLifecycleExplainResponse(in);
indexResponses.put(indexResponse.getIndex(), indexResponse);
}
this.indexResponses = indexResponses;
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(indexResponses.size());
for (IndexLifecycleExplainResponse e : indexResponses.values()) {
e.writeTo(out);
}
}
@Override
public int hashCode() {
return Objects.hash(indexResponses);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj.getClass() != getClass()) {
return false;
}
ExplainLifecycleResponse other = (ExplainLifecycleResponse) obj;
return Objects.equals(indexResponses, other.indexResponses);
}
@Override
public String toString() {
return Strings.toString(this, true, true);
}
}

View File

@ -0,0 +1,312 @@
/*
* 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;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.joda.time.DateTime;
import org.joda.time.chrono.ISOChronology;
import java.io.IOException;
import java.util.Objects;
public class IndexLifecycleExplainResponse implements ToXContentObject, Writeable {
private static final ParseField INDEX_FIELD = new ParseField("index");
private static final ParseField MANAGED_BY_ILM_FIELD = new ParseField("managed");
private static final ParseField POLICY_NAME_FIELD = new ParseField("policy");
private static final ParseField SKIP_FIELD = new ParseField("skip");
private static final ParseField LIFECYCLE_DATE_FIELD = new ParseField("lifecycle_date");
private static final ParseField PHASE_FIELD = new ParseField("phase");
private static final ParseField ACTION_FIELD = new ParseField("action");
private static final ParseField STEP_FIELD = new ParseField("step");
private static final ParseField FAILED_STEP_FIELD = new ParseField("failed_step");
private static final ParseField PHASE_TIME_FIELD = new ParseField("phase_time");
private static final ParseField ACTION_TIME_FIELD = new ParseField("action_time");
private static final ParseField STEP_TIME_FIELD = new ParseField("step_time");
private static final ParseField STEP_INFO_FIELD = new ParseField("step_info");
public static final ConstructingObjectParser<IndexLifecycleExplainResponse, Void> PARSER = new ConstructingObjectParser<>(
"index_lifecycle_explain_response",
a -> new IndexLifecycleExplainResponse(
(String) a[0],
(boolean) a[1],
(String) a[2],
(boolean) (a[3] == null ? false: a[3]),
(long) (a[4] == null ? -1L: a[4]),
(String) a[5],
(String) a[6],
(String) a[7],
(String) a[8],
(long) (a[9] == null ? -1L: a[9]),
(long) (a[10] == null ? -1L: a[10]),
(long) (a[11] == null ? -1L: a[11]),
(BytesReference) a[12]));
static {
PARSER.declareString(ConstructingObjectParser.constructorArg(), INDEX_FIELD);
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), MANAGED_BY_ILM_FIELD);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), POLICY_NAME_FIELD);
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), SKIP_FIELD);
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), LIFECYCLE_DATE_FIELD);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), PHASE_FIELD);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), ACTION_FIELD);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), STEP_FIELD);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), FAILED_STEP_FIELD);
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), PHASE_TIME_FIELD);
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), ACTION_TIME_FIELD);
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), STEP_TIME_FIELD);
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), (p, c) -> {
XContentBuilder builder = JsonXContent.contentBuilder();
builder.copyCurrentStructure(p);
return BytesArray.bytes(builder);
}, STEP_INFO_FIELD);
}
private final String index;
private final String policyName;
private final String phase;
private final String action;
private final String step;
private final String failedStep;
private final long lifecycleDate;
private final long phaseTime;
private final long actionTime;
private final long stepTime;
private final boolean skip;
private final boolean managedByILM;
private final BytesReference stepInfo;
public static IndexLifecycleExplainResponse newManagedIndexResponse(String index, String policyName, boolean skip, long lifecycleDate,
String phase, String action, String step, String failedStep, long phaseTime, long actionTime, long stepTime,
BytesReference stepInfo) {
return new IndexLifecycleExplainResponse(index, true, policyName, skip, lifecycleDate, phase, action, step, failedStep, phaseTime,
actionTime, stepTime, stepInfo);
}
public static IndexLifecycleExplainResponse newUnmanagedIndexResponse(String index) {
return new IndexLifecycleExplainResponse(index, false, null, false, -1L, null, null, null, null, -1L, -1L, -1L, null);
}
private IndexLifecycleExplainResponse(String index, boolean managedByILM, String policyName, boolean skip, long lifecycleDate,
String phase, String action, String step, String failedStep, long phaseTime, long actionTime,
long stepTime, BytesReference stepInfo) {
if (managedByILM) {
if (policyName == null) {
throw new IllegalArgumentException("[" + POLICY_NAME_FIELD.getPreferredName() + "] cannot be null for managed index");
}
} else {
if (policyName != null || lifecycleDate >= 0 || phase != null || action != null || step != null || failedStep != null
|| phaseTime >= 0 || actionTime >= 0 || stepTime >= 0 || stepInfo != null) {
throw new IllegalArgumentException(
"Unmanaged index response must only contain fields: [" + MANAGED_BY_ILM_FIELD + ", " + INDEX_FIELD + "]");
}
}
this.index = index;
this.policyName = policyName;
this.managedByILM = managedByILM;
this.skip = skip;
this.lifecycleDate = lifecycleDate;
this.phase = phase;
this.action = action;
this.step = step;
this.phaseTime = phaseTime;
this.actionTime = actionTime;
this.stepTime = stepTime;
this.failedStep = failedStep;
this.stepInfo = stepInfo;
}
public IndexLifecycleExplainResponse(StreamInput in) throws IOException {
index = in.readString();
managedByILM = in.readBoolean();
if (managedByILM) {
policyName = in.readString();
skip = in.readBoolean();
lifecycleDate = in.readZLong();
phase = in.readString();
action = in.readString();
step = in.readString();
failedStep = in.readOptionalString();
phaseTime = in.readZLong();
actionTime = in.readZLong();
stepTime = in.readZLong();
stepInfo = in.readOptionalBytesReference();
} else {
policyName = null;
skip = false;
lifecycleDate = -1L;
phase = null;
action = null;
step = null;
failedStep = null;
phaseTime = -1L;
actionTime = -1L;
stepTime = -1L;
stepInfo = null;
}
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(index);
out.writeBoolean(managedByILM);
if (managedByILM) {
out.writeString(policyName);
out.writeBoolean(skip);
out.writeZLong(lifecycleDate);
out.writeString(phase);
out.writeString(action);
out.writeString(step);
out.writeOptionalString(failedStep);
out.writeZLong(phaseTime);
out.writeZLong(actionTime);
out.writeZLong(stepTime);
out.writeOptionalBytesReference(stepInfo);
}
}
public String getIndex() {
return index;
}
public boolean managedByILM() {
return managedByILM;
}
public String getPolicyName() {
return policyName;
}
public boolean skip() {
return skip;
}
public long getLifecycleDate() {
return lifecycleDate;
}
public String getPhase() {
return phase;
}
public long getPhaseTime() {
return phaseTime;
}
public String getAction() {
return action;
}
public long getActionTime() {
return actionTime;
}
public String getStep() {
return step;
}
public long getStepTime() {
return stepTime;
}
public String getFailedStep() {
return failedStep;
}
public BytesReference getStepInfo() {
return stepInfo;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(INDEX_FIELD.getPreferredName(), index);
builder.field(MANAGED_BY_ILM_FIELD.getPreferredName(), managedByILM);
if (managedByILM) {
builder.field(POLICY_NAME_FIELD.getPreferredName(), policyName);
builder.field(SKIP_FIELD.getPreferredName(), skip);
if (builder.humanReadable()) {
builder.field(LIFECYCLE_DATE_FIELD.getPreferredName(), new DateTime(lifecycleDate, ISOChronology.getInstanceUTC()));
} else {
builder.field(LIFECYCLE_DATE_FIELD.getPreferredName(), lifecycleDate);
}
builder.field(PHASE_FIELD.getPreferredName(), phase);
if (builder.humanReadable()) {
builder.field(PHASE_TIME_FIELD.getPreferredName(), new DateTime(phaseTime, ISOChronology.getInstanceUTC()));
} else {
builder.field(PHASE_TIME_FIELD.getPreferredName(), phaseTime);
}
builder.field(ACTION_FIELD.getPreferredName(), action);
if (builder.humanReadable()) {
builder.field(ACTION_TIME_FIELD.getPreferredName(), new DateTime(actionTime, ISOChronology.getInstanceUTC()));
} else {
builder.field(ACTION_TIME_FIELD.getPreferredName(), actionTime);
}
builder.field(STEP_FIELD.getPreferredName(), step);
if (builder.humanReadable()) {
builder.field(STEP_TIME_FIELD.getPreferredName(), new DateTime(stepTime, ISOChronology.getInstanceUTC()));
} else {
builder.field(STEP_TIME_FIELD.getPreferredName(), stepTime);
}
if (Strings.hasLength(failedStep)) {
builder.field(FAILED_STEP_FIELD.getPreferredName(), failedStep);
}
if (stepInfo != null && stepInfo.length() > 0) {
builder.rawField(STEP_INFO_FIELD.getPreferredName(), stepInfo.streamInput(), XContentType.JSON);
}
}
builder.endObject();
return builder;
}
@Override
public int hashCode() {
return Objects.hash(index, managedByILM, policyName, skip, lifecycleDate, phase, action, step, failedStep, phaseTime, actionTime,
stepTime, stepInfo);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj.getClass() != getClass()) {
return false;
}
IndexLifecycleExplainResponse other = (IndexLifecycleExplainResponse) obj;
return Objects.equals(index, other.index) &&
Objects.equals(managedByILM, other.managedByILM) &&
Objects.equals(policyName, other.policyName) &&
Objects.equals(skip, other.skip) &&
Objects.equals(lifecycleDate, other.lifecycleDate) &&
Objects.equals(phase, other.phase) &&
Objects.equals(action, other.action) &&
Objects.equals(step, other.step) &&
Objects.equals(failedStep, other.failedStep) &&
Objects.equals(phaseTime, other.phaseTime) &&
Objects.equals(actionTime, other.actionTime) &&
Objects.equals(stepTime, other.stepTime) &&
Objects.equals(stepInfo, other.stepInfo);
}
@Override
public String toString() {
return Strings.toString(this, true, true);
}
}

View File

@ -18,7 +18,6 @@ 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;

View File

@ -0,0 +1,47 @@
/*
* 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;
import org.elasticsearch.action.admin.indices.shrink.ShrinkAction;
/**
* Enum representing the different modes that Index Lifecycle Service can operate in.
*/
public enum OperationMode {
/**
* This represents a state where no policies are executed
*/
STOPPED {
@Override
public boolean isValidChange(OperationMode nextMode) {
return nextMode == RUNNING;
}
},
/**
* this represents a state where only sensitive actions (like {@link ShrinkAction}) will be executed
* until they finish, at which point the operation mode will move to <code>STOPPED</code>.
*/
STOPPING {
@Override
public boolean isValidChange(OperationMode nextMode) {
return nextMode == RUNNING || nextMode == STOPPED;
}
},
/**
* Normal operation where all policies are executed as normal.
*/
RUNNING {
@Override
public boolean isValidChange(OperationMode nextMode) {
return nextMode == STOPPING;
}
};
public abstract boolean isValidChange(OperationMode nextMode);
}

View File

@ -0,0 +1,109 @@
/*
* 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;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.master.AcknowledgedRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
public class SetIndexLifecyclePolicyRequest extends AcknowledgedRequest<SetIndexLifecyclePolicyRequest>
implements IndicesRequest.Replaceable {
private String[] indices;
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
private String policy;
public SetIndexLifecyclePolicyRequest() {
}
public SetIndexLifecyclePolicyRequest(String policy, String... indices) {
if (indices == null) {
throw new IllegalArgumentException("indices cannot be null");
}
if (policy == null) {
throw new IllegalArgumentException("policy cannot be null");
}
this.indices = indices;
this.policy = policy;
}
@Override
public SetIndexLifecyclePolicyRequest indices(String... indices) {
this.indices = indices;
return this;
}
@Override
public String[] indices() {
return indices;
}
public SetIndexLifecyclePolicyRequest policy(String policy) {
this.policy = policy;
return this;
}
public String policy() {
return policy;
}
public void indicesOptions(IndicesOptions indicesOptions) {
this.indicesOptions = indicesOptions;
}
public IndicesOptions indicesOptions() {
return indicesOptions;
}
@Override
public ActionRequestValidationException validate() {
return null;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
indices = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
policy = in.readString();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeStringArray(indices);
indicesOptions.writeIndicesOptions(out);
out.writeString(policy);
}
@Override
public int hashCode() {
return Objects.hash(Arrays.hashCode(indices), indicesOptions, policy);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
SetIndexLifecyclePolicyRequest other = (SetIndexLifecyclePolicyRequest) obj;
return Objects.deepEquals(indices, other.indices) &&
Objects.equals(indicesOptions, other.indicesOptions) &&
Objects.equals(policy, other.policy);
}
}

View File

@ -0,0 +1,98 @@
/*
* 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;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.ParseField;
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.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
public class SetIndexLifecyclePolicyResponse extends ActionResponse implements ToXContentObject {
public static final ParseField HAS_FAILURES_FIELD = new ParseField("has_failures");
public static final ParseField FAILED_INDEXES_FIELD = new ParseField("failed_indexes");
@SuppressWarnings("unchecked")
public static final ConstructingObjectParser<SetIndexLifecyclePolicyResponse, Void> PARSER = new ConstructingObjectParser<>(
"change_policy_for_index_response", a -> new SetIndexLifecyclePolicyResponse((List<String>) a[0]));
static {
PARSER.declareStringArray(ConstructingObjectParser.constructorArg(), FAILED_INDEXES_FIELD);
// Needs to be declared but not used in constructing the response object
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), HAS_FAILURES_FIELD);
}
private List<String> failedIndexes;
public SetIndexLifecyclePolicyResponse() {
}
public SetIndexLifecyclePolicyResponse(List<String> failedIndexes) {
if (failedIndexes == null) {
throw new IllegalArgumentException(FAILED_INDEXES_FIELD.getPreferredName() + " cannot be null");
}
this.failedIndexes = failedIndexes;
}
public List<String> getFailedIndexes() {
return failedIndexes;
}
public boolean hasFailures() {
return failedIndexes.isEmpty() == false;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(HAS_FAILURES_FIELD.getPreferredName(), hasFailures());
builder.field(FAILED_INDEXES_FIELD.getPreferredName(), failedIndexes);
builder.endObject();
return builder;
}
public static SetIndexLifecyclePolicyResponse fromXContent(XContentParser parser) {
return PARSER.apply(parser, null);
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
failedIndexes = in.readList(StreamInput::readString);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeStringList(failedIndexes);
}
@Override
public int hashCode() {
return Objects.hash(failedIndexes);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
SetIndexLifecyclePolicyResponse other = (SetIndexLifecyclePolicyResponse) obj;
return Objects.equals(failedIndexes, other.failedIndexes);
}
}

View File

@ -0,0 +1,37 @@
/*
* 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;
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;
}
}

View File

@ -0,0 +1,37 @@
/*
* 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;
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;
}
}

View File

@ -7,7 +7,7 @@
package org.elasticsearch.xpack.core.indexlifecycle.action;
import org.elasticsearch.action.Action;
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleResponse;
import org.elasticsearch.xpack.core.indexlifecycle.ExplainLifecycleResponse;
public class ExplainLifecycleAction extends Action<ExplainLifecycleResponse> {
public static final ExplainLifecycleAction INSTANCE = new ExplainLifecycleAction();

View File

@ -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.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import java.io.IOException;
import java.util.Objects;

View File

@ -7,7 +7,7 @@
package org.elasticsearch.xpack.core.indexlifecycle.action;
import org.elasticsearch.action.Action;
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyResponse;
import org.elasticsearch.xpack.core.indexlifecycle.SetIndexLifecyclePolicyResponse;
public class SetIndexLifecyclePolicyAction extends Action<SetIndexLifecyclePolicyResponse> {

View File

@ -0,0 +1,59 @@
/*
* 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;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.test.AbstractWireSerializingTestCase;
import java.io.IOException;
import java.util.Arrays;
public class ExplainLifecycleRequestTests extends AbstractWireSerializingTestCase<ExplainLifecycleRequest> {
@Override
protected ExplainLifecycleRequest createTestInstance() {
ExplainLifecycleRequest request = new ExplainLifecycleRequest();
if (randomBoolean()) {
request.indices(generateRandomStringArray(20, 20, false, true));
}
if (randomBoolean()) {
IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(),
randomBoolean(), randomBoolean(), randomBoolean());
request.indicesOptions(indicesOptions);
}
return request;
}
@Override
protected ExplainLifecycleRequest mutateInstance(ExplainLifecycleRequest instance) throws IOException {
String[] indices = instance.indices();
IndicesOptions indicesOptions = instance.indicesOptions();
switch (between(0, 1)) {
case 0:
indices = randomValueOtherThanMany(i -> Arrays.equals(i, instance.indices()),
() -> generateRandomStringArray(20, 10, false, true));
break;
case 1:
indicesOptions = randomValueOtherThan(indicesOptions, () -> IndicesOptions.fromOptions(randomBoolean(), randomBoolean(),
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()));
break;
default:
throw new AssertionError("Illegal randomisation branch");
}
ExplainLifecycleRequest newRequest = new ExplainLifecycleRequest();
newRequest.indices(indices);
newRequest.indicesOptions(indicesOptions);
return newRequest;
}
@Override
protected Reader<ExplainLifecycleRequest> instanceReader() {
return ExplainLifecycleRequest::new;
}
}

View File

@ -0,0 +1,50 @@
/*
* 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;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class ExplainLifecycleResponseTests extends AbstractStreamableXContentTestCase<ExplainLifecycleResponse> {
@Override
protected ExplainLifecycleResponse createTestInstance() {
Map<String, IndexLifecycleExplainResponse> indexResponses = new HashMap<>();
for (int i = 0; i < randomIntBetween(0, 2); i++) {
IndexLifecycleExplainResponse indexResponse = IndexExplainResponseTests.randomIndexExplainResponse();
indexResponses.put(indexResponse.getIndex(), indexResponse);
}
return new ExplainLifecycleResponse(indexResponses);
}
@Override
protected ExplainLifecycleResponse createBlankInstance() {
return new ExplainLifecycleResponse();
}
@Override
protected ExplainLifecycleResponse mutateInstance(ExplainLifecycleResponse response) {
Map<String, IndexLifecycleExplainResponse> indexResponses = new HashMap<>(response.getIndexResponses());
IndexLifecycleExplainResponse indexResponse = IndexExplainResponseTests.randomIndexExplainResponse();
indexResponses.put(indexResponse.getIndex(), indexResponse);
return new ExplainLifecycleResponse(indexResponses);
}
@Override
protected ExplainLifecycleResponse doParseInstance(XContentParser parser) throws IOException {
return ExplainLifecycleResponse.fromXContent(parser);
}
@Override
protected boolean supportsUnknownFields() {
return false;
}
}

View File

@ -0,0 +1,184 @@
/*
* 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;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.test.AbstractSerializingTestCase;
import java.io.IOException;
import java.util.Objects;
import java.util.function.Supplier;
public class IndexExplainResponseTests extends AbstractSerializingTestCase<IndexLifecycleExplainResponse> {
static IndexLifecycleExplainResponse randomIndexExplainResponse() {
if (frequently()) {
return randomManagedIndexExplainResponse();
} else {
return randomUnmanagedIndexExplainResponse();
}
}
private static IndexLifecycleExplainResponse randomUnmanagedIndexExplainResponse() {
return IndexLifecycleExplainResponse.newUnmanagedIndexResponse(randomAlphaOfLength(10));
}
private static IndexLifecycleExplainResponse randomManagedIndexExplainResponse() {
return IndexLifecycleExplainResponse.newManagedIndexResponse(randomAlphaOfLength(10), randomAlphaOfLength(10), randomBoolean(),
randomNonNegativeLong(), randomAlphaOfLength(10), randomAlphaOfLength(10), randomAlphaOfLength(10),
randomBoolean() ? null : randomAlphaOfLength(10), randomNonNegativeLong(), randomNonNegativeLong(), randomNonNegativeLong(),
randomBoolean() ? null : new BytesArray(new RandomStepInfo(() -> randomAlphaOfLength(10)).toString()));
}
@Override
protected IndexLifecycleExplainResponse createTestInstance() {
return randomIndexExplainResponse();
}
@Override
protected Reader<IndexLifecycleExplainResponse> instanceReader() {
return IndexLifecycleExplainResponse::new;
}
@Override
protected IndexLifecycleExplainResponse doParseInstance(XContentParser parser) throws IOException {
return IndexLifecycleExplainResponse.PARSER.apply(parser, null);
}
@Override
protected IndexLifecycleExplainResponse mutateInstance(IndexLifecycleExplainResponse instance) throws IOException {
String index = instance.getIndex();
String policy = instance.getPolicyName();
String phase = instance.getPhase();
String action = instance.getAction();
String step = instance.getStep();
String failedStep = instance.getFailedStep();
long policyTime = instance.getLifecycleDate();
long phaseTime = instance.getPhaseTime();
long actionTime = instance.getActionTime();
long stepTime = instance.getStepTime();
boolean managed = instance.managedByILM();
boolean skip = instance.skip();
BytesReference stepInfo = instance.getStepInfo();
if (managed) {
switch (between(0, 12)) {
case 0:
index = index + randomAlphaOfLengthBetween(1, 5);
break;
case 1:
policy = policy + randomAlphaOfLengthBetween(1, 5);
break;
case 2:
phase = phase + randomAlphaOfLengthBetween(1, 5);
break;
case 3:
action = action + randomAlphaOfLengthBetween(1, 5);
break;
case 4:
step = step + randomAlphaOfLengthBetween(1, 5);
break;
case 5:
if (Strings.hasLength(failedStep) == false) {
failedStep = randomAlphaOfLength(10);
} else if (randomBoolean()) {
failedStep = failedStep + randomAlphaOfLengthBetween(1, 5);
} else {
failedStep = null;
}
break;
case 6:
policyTime += randomLongBetween(0, 100000);
break;
case 7:
phaseTime += randomLongBetween(0, 100000);
break;
case 8:
actionTime += randomLongBetween(0, 100000);
break;
case 9:
stepTime += randomLongBetween(0, 100000);
break;
case 10:
if (Strings.hasLength(stepInfo) == false) {
stepInfo = new BytesArray(randomByteArrayOfLength(100));
} else if (randomBoolean()) {
stepInfo = randomValueOtherThan(stepInfo,
() -> new BytesArray(new RandomStepInfo(() -> randomAlphaOfLength(10)).toString()));
} else {
stepInfo = null;
}
break;
case 11:
skip = skip == false;
break;
case 12:
return IndexLifecycleExplainResponse.newUnmanagedIndexResponse(index);
default:
throw new AssertionError("Illegal randomisation branch");
}
return IndexLifecycleExplainResponse.newManagedIndexResponse(index, policy, skip, policyTime, phase, action, step, failedStep,
phaseTime, actionTime, stepTime, stepInfo);
} else {
switch (between(0, 1)) {
case 0:
return IndexLifecycleExplainResponse.newUnmanagedIndexResponse(index + randomAlphaOfLengthBetween(1, 5));
case 1:
return randomManagedIndexExplainResponse();
default:
throw new AssertionError("Illegal randomisation branch");
}
}
}
private static class RandomStepInfo implements ToXContentObject {
private final String key;
private final String value;
RandomStepInfo(Supplier<String> randomStringSupplier) {
this.key = randomStringSupplier.get();
this.value = randomStringSupplier.get();
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(key, value);
builder.endObject();
return builder;
}
@Override
public int hashCode() {
return Objects.hash(key, value);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
RandomStepInfo other = (RandomStepInfo) obj;
return Objects.equals(key, other.key) && Objects.equals(value, other.value);
}
@Override
public String toString() {
return Strings.toString(this);
}
}
}

View File

@ -0,0 +1,26 @@
/*
* 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;
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));
}
}

View File

@ -0,0 +1,75 @@
/*
* 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;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.test.AbstractStreamableTestCase;
import java.io.IOException;
import java.util.Arrays;
public class SetIndexLifecyclePolicyRequestTests extends AbstractStreamableTestCase<SetIndexLifecyclePolicyRequest> {
@Override
protected SetIndexLifecyclePolicyRequest createTestInstance() {
SetIndexLifecyclePolicyRequest request = new SetIndexLifecyclePolicyRequest(randomAlphaOfLength(20),
generateRandomStringArray(20, 20, false));
if (randomBoolean()) {
IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(),
randomBoolean(), randomBoolean(), randomBoolean());
request.indicesOptions(indicesOptions);
}
return request;
}
@Override
protected SetIndexLifecyclePolicyRequest createBlankInstance() {
return new SetIndexLifecyclePolicyRequest();
}
@Override
protected SetIndexLifecyclePolicyRequest mutateInstance(SetIndexLifecyclePolicyRequest instance) throws IOException {
String[] indices = instance.indices();
IndicesOptions indicesOptions = instance.indicesOptions();
String policy = instance.policy();
switch (between(0, 2)) {
case 0:
indices = randomValueOtherThanMany(i -> Arrays.equals(i, instance.indices()),
() -> generateRandomStringArray(20, 20, false));
break;
case 1:
indicesOptions = randomValueOtherThan(indicesOptions, () -> IndicesOptions.fromOptions(randomBoolean(), randomBoolean(),
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()));
break;
case 2:
policy = randomValueOtherThan(policy, () -> randomAlphaOfLength(20));
break;
default:
throw new AssertionError("Illegal randomisation branch");
}
SetIndexLifecyclePolicyRequest newRequest = new SetIndexLifecyclePolicyRequest(policy, indices);
newRequest.indicesOptions(indicesOptions);
return newRequest;
}
public void testNullIndices() {
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
() -> new SetIndexLifecyclePolicyRequest(randomAlphaOfLength(20), (String[]) null));
assertEquals("indices cannot be null", exception.getMessage());
}
public void testNullPolicy() {
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class,
() -> new SetIndexLifecyclePolicyRequest(null, generateRandomStringArray(20, 20, false)));
assertEquals("policy cannot be null", exception.getMessage());
}
public void testValidate() {
SetIndexLifecyclePolicyRequest request = createTestInstance();
assertNull(request.validate());
}
}

View File

@ -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.core.indexlifecycle;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class SetIndexLifecyclePolicyResponseTests extends AbstractStreamableXContentTestCase<SetIndexLifecyclePolicyResponse> {
@Override
protected SetIndexLifecyclePolicyResponse createBlankInstance() {
return new SetIndexLifecyclePolicyResponse();
}
@Override
protected SetIndexLifecyclePolicyResponse createTestInstance() {
List<String> failedIndexes = Arrays.asList(generateRandomStringArray(20, 20, false));
return new SetIndexLifecyclePolicyResponse(failedIndexes);
}
@Override
protected SetIndexLifecyclePolicyResponse mutateInstance(SetIndexLifecyclePolicyResponse instance) throws IOException {
List<String> failedIndices = randomValueOtherThan(instance.getFailedIndexes(),
() -> Arrays.asList(generateRandomStringArray(20, 20, false)));
return new SetIndexLifecyclePolicyResponse(failedIndices);
}
@Override
protected SetIndexLifecyclePolicyResponse doParseInstance(XContentParser parser) throws IOException {
return SetIndexLifecyclePolicyResponse.PARSER.apply(parser, null);
}
@Override
protected boolean supportsUnknownFields() {
return false;
}
public void testNullFailedIndices() {
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> new SetIndexLifecyclePolicyResponse(null));
assertEquals("failed_indexes cannot be null", exception.getMessage());
}
public void testHasFailures() {
SetIndexLifecyclePolicyResponse response = new SetIndexLifecyclePolicyResponse(new ArrayList<>());
assertFalse(response.hasFailures());
assertEquals(Collections.emptyList(), response.getFailedIndexes());
int size = randomIntBetween(1, 10);
List<String> failedIndexes = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
failedIndexes.add(randomAlphaOfLength(20));
}
response = new SetIndexLifecyclePolicyResponse(failedIndexes);
assertTrue(response.hasFailures());
assertEquals(failedIndexes, response.getFailedIndexes());
}
}

View File

@ -0,0 +1,28 @@
/*
* 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;
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());
}
}

View File

@ -0,0 +1,28 @@
/*
* 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;
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());
}
}

View File

@ -21,7 +21,7 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractComponent;
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.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleSettings;

View File

@ -10,7 +10,7 @@ import org.apache.logging.log4j.Logger;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateUpdateTask;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
public class OperationModeUpdateTask extends ClusterStateUpdateTask {

View File

@ -10,7 +10,7 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleRequest;
import org.elasticsearch.xpack.core.indexlifecycle.ExplainLifecycleRequest;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
@ -44,4 +44,4 @@ public class RestExplainLifecycleAction extends BaseRestHandler {
return channel -> client.execute(ExplainLifecycleAction.INSTANCE, explainLifecycleRequest, new RestToXContentListener<>(channel));
}
}
}

View File

@ -10,7 +10,7 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyRequest;
import org.elasticsearch.xpack.core.indexlifecycle.SetIndexLifecyclePolicyRequest;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;

View File

@ -8,7 +8,7 @@ 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.xpack.core.indexlifecycle.StartILMRequest;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;

View File

@ -8,7 +8,7 @@ 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.xpack.core.indexlifecycle.StopILMRequest;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;

View File

@ -19,9 +19,9 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.inject.Inject;
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.xpack.core.indexlifecycle.ExplainLifecycleRequest;
import org.elasticsearch.xpack.core.indexlifecycle.ExplainLifecycleResponse;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleExplainResponse;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleSettings;

View File

@ -16,7 +16,7 @@ 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.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;

View File

@ -19,7 +19,7 @@ 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.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.ClientHelper;

View File

@ -19,8 +19,8 @@ import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyRequest;
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyResponse;
import org.elasticsearch.xpack.core.indexlifecycle.SetIndexLifecyclePolicyRequest;
import org.elasticsearch.xpack.core.indexlifecycle.SetIndexLifecyclePolicyResponse;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;

View File

@ -18,8 +18,8 @@ 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.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.StartILMRequest;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.indexlifecycle.action.StartILMAction;

View File

@ -18,8 +18,8 @@ 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.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.StopILMRequest;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.indexlifecycle.action.StopILMAction;

View File

@ -20,7 +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.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;

View File

@ -16,7 +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.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.test.AbstractDiffableSerializationTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.AllocateAction;
import org.elasticsearch.xpack.core.indexlifecycle.DeleteAction;

View File

@ -22,7 +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.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.AbstractStepTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep;

View File

@ -24,7 +24,7 @@ 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.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;

View File

@ -10,7 +10,7 @@ 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.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;

View File

@ -22,7 +22,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.index.Index;
import org.elasticsearch.node.Node;
import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.ErrorStep;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;