|
@@ -9,7 +9,6 @@ import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.action.ActionRequestValidationException;
|
|
|
import org.elasticsearch.action.ActionType;
|
|
|
import org.elasticsearch.action.support.master.MasterNodeRequest;
|
|
|
-import org.elasticsearch.common.Nullable;
|
|
|
import org.elasticsearch.common.ParseField;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
@@ -30,7 +29,6 @@ import org.elasticsearch.xpack.core.ml.utils.PhaseProgress;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -147,17 +145,13 @@ public class StartDataFrameAnalyticsAction extends ActionType<NodeAcknowledgedRe
|
|
|
public static final Version VERSION_INTRODUCED = Version.V_7_3_0;
|
|
|
public static final Version VERSION_DESTINATION_INDEX_MAPPINGS_CHANGED = Version.V_7_10_0;
|
|
|
|
|
|
- private static final ParseField PROGRESS_ON_START = new ParseField("progress_on_start");
|
|
|
-
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
public static final ConstructingObjectParser<TaskParams, Void> PARSER = new ConstructingObjectParser<>(
|
|
|
MlTasks.DATA_FRAME_ANALYTICS_TASK_NAME, true,
|
|
|
- a -> new TaskParams((String) a[0], (String) a[1], (List<PhaseProgress>) a[2], (Boolean) a[3]));
|
|
|
+ a -> new TaskParams((String) a[0], (String) a[1], (Boolean) a[2]));
|
|
|
|
|
|
static {
|
|
|
PARSER.declareString(ConstructingObjectParser.constructorArg(), DataFrameAnalyticsConfig.ID);
|
|
|
PARSER.declareString(ConstructingObjectParser.constructorArg(), DataFrameAnalyticsConfig.VERSION);
|
|
|
- PARSER.declareObjectArray(ConstructingObjectParser.optionalConstructorArg(), PhaseProgress.PARSER, PROGRESS_ON_START);
|
|
|
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), DataFrameAnalyticsConfig.ALLOW_LAZY_START);
|
|
|
}
|
|
|
|
|
@@ -167,25 +161,24 @@ public class StartDataFrameAnalyticsAction extends ActionType<NodeAcknowledgedRe
|
|
|
|
|
|
private final String id;
|
|
|
private final Version version;
|
|
|
- private final List<PhaseProgress> progressOnStart;
|
|
|
private final boolean allowLazyStart;
|
|
|
|
|
|
- public TaskParams(String id, Version version, List<PhaseProgress> progressOnStart, boolean allowLazyStart) {
|
|
|
+ public TaskParams(String id, Version version, boolean allowLazyStart) {
|
|
|
this.id = Objects.requireNonNull(id);
|
|
|
this.version = Objects.requireNonNull(version);
|
|
|
- this.progressOnStart = Collections.unmodifiableList(progressOnStart);
|
|
|
this.allowLazyStart = allowLazyStart;
|
|
|
}
|
|
|
|
|
|
- private TaskParams(String id, String version, @Nullable List<PhaseProgress> progressOnStart, Boolean allowLazyStart) {
|
|
|
- this(id, Version.fromString(version), progressOnStart == null ? Collections.emptyList() : progressOnStart,
|
|
|
- allowLazyStart != null && allowLazyStart);
|
|
|
+ private TaskParams(String id, String version, Boolean allowLazyStart) {
|
|
|
+ this(id, Version.fromString(version), allowLazyStart != null && allowLazyStart);
|
|
|
}
|
|
|
|
|
|
public TaskParams(StreamInput in) throws IOException {
|
|
|
this.id = in.readString();
|
|
|
this.version = Version.readVersion(in);
|
|
|
- this.progressOnStart = in.readList(PhaseProgress::new);
|
|
|
+ if (in.getVersion().before(Version.V_8_0_0)) {
|
|
|
+ in.readList(PhaseProgress::new);
|
|
|
+ }
|
|
|
this.allowLazyStart = in.readBoolean();
|
|
|
}
|
|
|
|
|
@@ -197,10 +190,6 @@ public class StartDataFrameAnalyticsAction extends ActionType<NodeAcknowledgedRe
|
|
|
return version;
|
|
|
}
|
|
|
|
|
|
- public List<PhaseProgress> getProgressOnStart() {
|
|
|
- return progressOnStart;
|
|
|
- }
|
|
|
-
|
|
|
public boolean isAllowLazyStart() {
|
|
|
return allowLazyStart;
|
|
|
}
|
|
@@ -219,7 +208,10 @@ public class StartDataFrameAnalyticsAction extends ActionType<NodeAcknowledgedRe
|
|
|
public void writeTo(StreamOutput out) throws IOException {
|
|
|
out.writeString(id);
|
|
|
Version.writeVersion(version, out);
|
|
|
- out.writeList(progressOnStart);
|
|
|
+ if (out.getVersion().before(Version.V_8_0_0)) {
|
|
|
+ // Previous versions expect a list of phase progress objects.
|
|
|
+ out.writeList(Collections.emptyList());
|
|
|
+ }
|
|
|
out.writeBoolean(allowLazyStart);
|
|
|
}
|
|
|
|
|
@@ -228,7 +220,6 @@ public class StartDataFrameAnalyticsAction extends ActionType<NodeAcknowledgedRe
|
|
|
builder.startObject();
|
|
|
builder.field(DataFrameAnalyticsConfig.ID.getPreferredName(), id);
|
|
|
builder.field(DataFrameAnalyticsConfig.VERSION.getPreferredName(), version);
|
|
|
- builder.field(PROGRESS_ON_START.getPreferredName(), progressOnStart);
|
|
|
builder.field(DataFrameAnalyticsConfig.ALLOW_LAZY_START.getPreferredName(), allowLazyStart);
|
|
|
builder.endObject();
|
|
|
return builder;
|
|
@@ -236,7 +227,7 @@ public class StartDataFrameAnalyticsAction extends ActionType<NodeAcknowledgedRe
|
|
|
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
|
- return Objects.hash(id, version, progressOnStart, allowLazyStart);
|
|
|
+ return Objects.hash(id, version, allowLazyStart);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -247,7 +238,6 @@ public class StartDataFrameAnalyticsAction extends ActionType<NodeAcknowledgedRe
|
|
|
TaskParams other = (TaskParams) o;
|
|
|
return Objects.equals(id, other.id)
|
|
|
&& Objects.equals(version, other.version)
|
|
|
- && Objects.equals(progressOnStart, other.progressOnStart)
|
|
|
&& Objects.equals(allowLazyStart, other.allowLazyStart);
|
|
|
}
|
|
|
}
|