|
@@ -20,44 +20,54 @@ import org.elasticsearch.xcontent.XContentParser;
|
|
|
import org.elasticsearch.xpack.core.transform.TransformField;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.time.Instant;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
public class TransformTaskParams implements SimpleDiffable<TransformTaskParams>, PersistentTaskParams {
|
|
|
|
|
|
public static final String NAME = TransformField.TASK_NAME;
|
|
|
+ public static final ParseField FROM = TransformField.FROM;
|
|
|
public static final ParseField FREQUENCY = TransformField.FREQUENCY;
|
|
|
public static final ParseField REQUIRES_REMOTE = new ParseField("requires_remote");
|
|
|
|
|
|
private final String transformId;
|
|
|
private final Version version;
|
|
|
+ private final Instant from;
|
|
|
private final TimeValue frequency;
|
|
|
private final Boolean requiresRemote;
|
|
|
|
|
|
public static final ConstructingObjectParser<TransformTaskParams, Void> PARSER = new ConstructingObjectParser<>(
|
|
|
NAME,
|
|
|
true,
|
|
|
- a -> new TransformTaskParams((String) a[0], (String) a[1], (String) a[2], (Boolean) a[3])
|
|
|
+ a -> new TransformTaskParams((String) a[0], (String) a[1], (Long) a[2], (String) a[3], (Boolean) a[4])
|
|
|
);
|
|
|
|
|
|
static {
|
|
|
PARSER.declareString(ConstructingObjectParser.constructorArg(), TransformField.ID);
|
|
|
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), TransformField.VERSION);
|
|
|
+ PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), FROM);
|
|
|
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), FREQUENCY);
|
|
|
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), REQUIRES_REMOTE);
|
|
|
}
|
|
|
|
|
|
- private TransformTaskParams(String transformId, String version, String frequency, Boolean remote) {
|
|
|
+ private TransformTaskParams(String transformId, String version, Long from, String frequency, Boolean remote) {
|
|
|
this(
|
|
|
transformId,
|
|
|
version == null ? null : Version.fromString(version),
|
|
|
+ from == null ? null : Instant.ofEpochMilli(from),
|
|
|
frequency == null ? null : TimeValue.parseTimeValue(frequency, FREQUENCY.getPreferredName()),
|
|
|
remote == null ? false : remote.booleanValue()
|
|
|
);
|
|
|
}
|
|
|
|
|
|
public TransformTaskParams(String transformId, Version version, TimeValue frequency, boolean remote) {
|
|
|
+ this(transformId, version, null, frequency, remote);
|
|
|
+ }
|
|
|
+
|
|
|
+ public TransformTaskParams(String transformId, Version version, Instant from, TimeValue frequency, boolean remote) {
|
|
|
this.transformId = transformId;
|
|
|
this.version = version == null ? Version.V_7_2_0 : version;
|
|
|
+ this.from = from;
|
|
|
this.frequency = frequency;
|
|
|
this.requiresRemote = remote;
|
|
|
}
|
|
@@ -65,6 +75,11 @@ public class TransformTaskParams implements SimpleDiffable<TransformTaskParams>,
|
|
|
public TransformTaskParams(StreamInput in) throws IOException {
|
|
|
this.transformId = in.readString();
|
|
|
this.version = Version.readVersion(in);
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_8_7_0)) {
|
|
|
+ this.from = in.readOptionalInstant();
|
|
|
+ } else {
|
|
|
+ this.from = null;
|
|
|
+ }
|
|
|
this.frequency = in.readOptionalTimeValue();
|
|
|
this.requiresRemote = in.readBoolean();
|
|
|
}
|
|
@@ -83,6 +98,9 @@ public class TransformTaskParams implements SimpleDiffable<TransformTaskParams>,
|
|
|
public void writeTo(StreamOutput out) throws IOException {
|
|
|
out.writeString(transformId);
|
|
|
Version.writeVersion(version, out);
|
|
|
+ if (out.getVersion().onOrAfter(Version.V_8_7_0)) {
|
|
|
+ out.writeOptionalInstant(from);
|
|
|
+ }
|
|
|
out.writeOptionalTimeValue(frequency);
|
|
|
out.writeBoolean(requiresRemote);
|
|
|
}
|
|
@@ -92,6 +110,9 @@ public class TransformTaskParams implements SimpleDiffable<TransformTaskParams>,
|
|
|
builder.startObject();
|
|
|
builder.field(TransformField.ID.getPreferredName(), transformId);
|
|
|
builder.field(TransformField.VERSION.getPreferredName(), version);
|
|
|
+ if (from != null) {
|
|
|
+ builder.field(FROM.getPreferredName(), from.toEpochMilli());
|
|
|
+ }
|
|
|
if (frequency != null) {
|
|
|
builder.field(FREQUENCY.getPreferredName(), frequency.getStringRep());
|
|
|
}
|
|
@@ -108,6 +129,10 @@ public class TransformTaskParams implements SimpleDiffable<TransformTaskParams>,
|
|
|
return version;
|
|
|
}
|
|
|
|
|
|
+ public Instant from() {
|
|
|
+ return from;
|
|
|
+ }
|
|
|
+
|
|
|
public TimeValue getFrequency() {
|
|
|
return frequency;
|
|
|
}
|
|
@@ -134,12 +159,13 @@ public class TransformTaskParams implements SimpleDiffable<TransformTaskParams>,
|
|
|
|
|
|
return Objects.equals(this.transformId, that.transformId)
|
|
|
&& Objects.equals(this.version, that.version)
|
|
|
+ && Objects.equals(this.from, that.from)
|
|
|
&& Objects.equals(this.frequency, that.frequency)
|
|
|
&& this.requiresRemote == that.requiresRemote;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
|
- return Objects.hash(transformId, version, frequency, requiresRemote);
|
|
|
+ return Objects.hash(transformId, version, from, frequency, requiresRemote);
|
|
|
}
|
|
|
}
|