make optional flush parameter really optional
Original commit: elastic/x-pack-elasticsearch@6129023c49
This commit is contained in:
parent
372cb7c964
commit
e067008a21
|
@ -240,13 +240,20 @@ public class FlushJobAction extends Action<FlushJobAction.Request, FlushJobActio
|
||||||
protected final void doExecute(FlushJobAction.Request request, ActionListener<FlushJobAction.Response> listener) {
|
protected final void doExecute(FlushJobAction.Request request, ActionListener<FlushJobAction.Response> listener) {
|
||||||
threadPool.executor(PrelertPlugin.THREAD_POOL_NAME).execute(() -> {
|
threadPool.executor(PrelertPlugin.THREAD_POOL_NAME).execute(() -> {
|
||||||
try {
|
try {
|
||||||
TimeRange timeRange = TimeRange.builder().startTime(request.getStart()).endTime(request.getEnd()).build();
|
InterimResultsParams.Builder paramsBuilder = InterimResultsParams.builder();
|
||||||
InterimResultsParams params = InterimResultsParams.builder()
|
paramsBuilder.calcInterim(request.getCalcInterim());
|
||||||
.calcInterim(request.getCalcInterim())
|
if (request.getAdvanceTime() != null) {
|
||||||
.forTimeRange(timeRange)
|
paramsBuilder.advanceTime(request.getAdvanceTime());
|
||||||
.advanceTime(request.getAdvanceTime())
|
}
|
||||||
.build();
|
TimeRange.Builder timeRangeBuilder = TimeRange.builder();
|
||||||
processManager.flushJob(request.getJobId(), params);
|
if (request.getStart() != null) {
|
||||||
|
timeRangeBuilder.startTime(request.getStart());
|
||||||
|
}
|
||||||
|
if (request.getEnd() != null) {
|
||||||
|
timeRangeBuilder.endTime(request.getEnd());
|
||||||
|
}
|
||||||
|
paramsBuilder.forTimeRange(timeRangeBuilder.build());
|
||||||
|
processManager.flushJob(request.getJobId(), paramsBuilder.build());
|
||||||
listener.onResponse(new Response(true));
|
listener.onResponse(new Response(true));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
listener.onFailure(e);
|
listener.onFailure(e);
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.prelert.job.process.autodetect.params;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.xpack.prelert.job.messages.Messages;
|
import org.elasticsearch.xpack.prelert.job.messages.Messages;
|
||||||
|
import org.elasticsearch.xpack.prelert.utils.ExceptionsHelper;
|
||||||
import org.elasticsearch.xpack.prelert.utils.time.TimeUtils;
|
import org.elasticsearch.xpack.prelert.utils.time.TimeUtils;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -86,7 +87,7 @@ public class InterimResultsParams {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder advanceTime(String timestamp) {
|
public Builder advanceTime(String timestamp) {
|
||||||
advanceTime = timestamp;
|
advanceTime = ExceptionsHelper.requireNonNull(timestamp, "advance");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ package org.elasticsearch.xpack.prelert.job.process.autodetect.params;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.ElasticsearchStatusException;
|
import org.elasticsearch.ElasticsearchStatusException;
|
||||||
import org.elasticsearch.xpack.prelert.job.messages.Messages;
|
import org.elasticsearch.xpack.prelert.job.messages.Messages;
|
||||||
|
import org.elasticsearch.xpack.prelert.utils.ExceptionsHelper;
|
||||||
import org.elasticsearch.xpack.prelert.utils.time.TimeUtils;
|
import org.elasticsearch.xpack.prelert.utils.time.TimeUtils;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -62,12 +63,12 @@ public class TimeRange {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder startTime(String start) {
|
public Builder startTime(String start) {
|
||||||
this.start = start;
|
this.start = ExceptionsHelper.requireNonNull(start, "start");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder endTime(String end) {
|
public Builder endTime(String end) {
|
||||||
this.end = end;
|
this.end = ExceptionsHelper.requireNonNull(end, "end");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue