|
@@ -6,27 +6,13 @@
|
|
package org.elasticsearch.xpack.core.upgrade.actions;
|
|
package org.elasticsearch.xpack.core.upgrade.actions;
|
|
|
|
|
|
import org.elasticsearch.action.Action;
|
|
import org.elasticsearch.action.Action;
|
|
-import org.elasticsearch.action.ActionRequestValidationException;
|
|
|
|
-import org.elasticsearch.action.ActionResponse;
|
|
|
|
-import org.elasticsearch.action.IndicesRequest;
|
|
|
|
import org.elasticsearch.action.support.IndicesOptions;
|
|
import org.elasticsearch.action.support.IndicesOptions;
|
|
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder;
|
|
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder;
|
|
-import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
|
|
|
import org.elasticsearch.client.ElasticsearchClient;
|
|
import org.elasticsearch.client.ElasticsearchClient;
|
|
-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.upgrade.UpgradeActionRequired;
|
|
|
|
|
|
+import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
|
|
|
|
+import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoResponse;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
-
|
|
|
|
-import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|
|
|
-
|
|
|
|
-public class IndexUpgradeInfoAction extends Action<IndexUpgradeInfoAction.Response> {
|
|
|
|
|
|
+public class IndexUpgradeInfoAction extends Action<IndexUpgradeInfoResponse> {
|
|
|
|
|
|
public static final IndexUpgradeInfoAction INSTANCE = new IndexUpgradeInfoAction();
|
|
public static final IndexUpgradeInfoAction INSTANCE = new IndexUpgradeInfoAction();
|
|
public static final String NAME = "cluster:admin/xpack/upgrade/info";
|
|
public static final String NAME = "cluster:admin/xpack/upgrade/info";
|
|
@@ -36,149 +22,15 @@ public class IndexUpgradeInfoAction extends Action<IndexUpgradeInfoAction.Respon
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Response newResponse() {
|
|
|
|
- return new Response();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static class Response extends ActionResponse implements ToXContentObject {
|
|
|
|
- private Map<String, UpgradeActionRequired> actions;
|
|
|
|
-
|
|
|
|
- public Response() {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public Response(Map<String, UpgradeActionRequired> actions) {
|
|
|
|
- this.actions = actions;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void readFrom(StreamInput in) throws IOException {
|
|
|
|
- super.readFrom(in);
|
|
|
|
- actions = in.readMap(StreamInput::readString, UpgradeActionRequired::readFromStream);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void writeTo(StreamOutput out) throws IOException {
|
|
|
|
- super.writeTo(out);
|
|
|
|
- out.writeMap(actions, StreamOutput::writeString, (out1, value) -> value.writeTo(out1));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public Map<String, UpgradeActionRequired> getActions() {
|
|
|
|
- return actions;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
|
|
- builder.startObject();
|
|
|
|
- {
|
|
|
|
- builder.startObject("indices");
|
|
|
|
- for (Map.Entry<String, UpgradeActionRequired> entry : actions.entrySet()) {
|
|
|
|
- builder.startObject(entry.getKey());
|
|
|
|
- {
|
|
|
|
- builder.field("action_required", entry.getValue().toString());
|
|
|
|
- }
|
|
|
|
- builder.endObject();
|
|
|
|
- }
|
|
|
|
- builder.endObject();
|
|
|
|
- }
|
|
|
|
- builder.endObject();
|
|
|
|
- return builder;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public boolean equals(Object o) {
|
|
|
|
- if (this == o) return true;
|
|
|
|
- if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
- Response response = (Response) o;
|
|
|
|
- return Objects.equals(actions, response.actions);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public int hashCode() {
|
|
|
|
- return Objects.hash(actions);
|
|
|
|
- }
|
|
|
|
|
|
+ public IndexUpgradeInfoResponse newResponse() {
|
|
|
|
+ return new IndexUpgradeInfoResponse();
|
|
}
|
|
}
|
|
|
|
|
|
- public static class Request extends MasterNodeReadRequest<Request> implements IndicesRequest.Replaceable {
|
|
|
|
-
|
|
|
|
- private String[] indices = null;
|
|
|
|
- private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true);
|
|
|
|
-
|
|
|
|
- // for serialization
|
|
|
|
- public Request() {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public Request(String... indices) {
|
|
|
|
- this.indices = indices;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public Request(StreamInput in) throws IOException {
|
|
|
|
- super(in);
|
|
|
|
- indices = in.readStringArray();
|
|
|
|
- indicesOptions = IndicesOptions.readIndicesOptions(in);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void writeTo(StreamOutput out) throws IOException {
|
|
|
|
- super.writeTo(out);
|
|
|
|
- out.writeStringArray(indices);
|
|
|
|
- indicesOptions.writeIndicesOptions(out);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public String[] indices() {
|
|
|
|
- return indices;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Request indices(String... indices) {
|
|
|
|
- this.indices = indices;
|
|
|
|
- return this;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public IndicesOptions indicesOptions() {
|
|
|
|
- return indicesOptions;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void indicesOptions(IndicesOptions indicesOptions) {
|
|
|
|
- this.indicesOptions = indicesOptions;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public ActionRequestValidationException validate() {
|
|
|
|
- ActionRequestValidationException validationException = null;
|
|
|
|
- if (indices == null) {
|
|
|
|
- validationException = addValidationError("index/indices is missing", validationException);
|
|
|
|
- }
|
|
|
|
- return validationException;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void readFrom(StreamInput in) throws IOException {
|
|
|
|
- throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public boolean equals(Object o) {
|
|
|
|
- if (this == o) return true;
|
|
|
|
- if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
- Request request = (Request) o;
|
|
|
|
- return Arrays.equals(indices, request.indices) &&
|
|
|
|
- Objects.equals(indicesOptions.toString(), request.indicesOptions.toString());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public int hashCode() {
|
|
|
|
- return Objects.hash(Arrays.hashCode(indices), indicesOptions.toString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static class RequestBuilder extends MasterNodeReadOperationRequestBuilder<Request, Response, RequestBuilder> {
|
|
|
|
|
|
+ public static class RequestBuilder
|
|
|
|
+ extends MasterNodeReadOperationRequestBuilder<IndexUpgradeInfoRequest, IndexUpgradeInfoResponse, RequestBuilder> {
|
|
|
|
|
|
public RequestBuilder(ElasticsearchClient client) {
|
|
public RequestBuilder(ElasticsearchClient client) {
|
|
- super(client, INSTANCE, new Request());
|
|
|
|
|
|
+ super(client, INSTANCE, new IndexUpgradeInfoRequest());
|
|
}
|
|
}
|
|
|
|
|
|
public RequestBuilder setIndices(String... indices) {
|
|
public RequestBuilder setIndices(String... indices) {
|
|
@@ -191,5 +43,4 @@ public class IndexUpgradeInfoAction extends Action<IndexUpgradeInfoAction.Respon
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-}
|
|
|
|
|
|
+}
|