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) {
|
||||
threadPool.executor(PrelertPlugin.THREAD_POOL_NAME).execute(() -> {
|
||||
try {
|
||||
TimeRange timeRange = TimeRange.builder().startTime(request.getStart()).endTime(request.getEnd()).build();
|
||||
InterimResultsParams params = InterimResultsParams.builder()
|
||||
.calcInterim(request.getCalcInterim())
|
||||
.forTimeRange(timeRange)
|
||||
.advanceTime(request.getAdvanceTime())
|
||||
.build();
|
||||
processManager.flushJob(request.getJobId(), params);
|
||||
InterimResultsParams.Builder paramsBuilder = InterimResultsParams.builder();
|
||||
paramsBuilder.calcInterim(request.getCalcInterim());
|
||||
if (request.getAdvanceTime() != null) {
|
||||
paramsBuilder.advanceTime(request.getAdvanceTime());
|
||||
}
|
||||
TimeRange.Builder timeRangeBuilder = TimeRange.builder();
|
||||
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));
|
||||
} catch (Exception e) {
|
||||
listener.onFailure(e);
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.prelert.job.process.autodetect.params;
|
|||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.xpack.prelert.job.messages.Messages;
|
||||
import org.elasticsearch.xpack.prelert.utils.ExceptionsHelper;
|
||||
import org.elasticsearch.xpack.prelert.utils.time.TimeUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -86,7 +87,7 @@ public class InterimResultsParams {
|
|||
}
|
||||
|
||||
public Builder advanceTime(String timestamp) {
|
||||
advanceTime = timestamp;
|
||||
advanceTime = ExceptionsHelper.requireNonNull(timestamp, "advance");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.elasticsearch.xpack.prelert.job.process.autodetect.params;
|
|||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.xpack.prelert.job.messages.Messages;
|
||||
import org.elasticsearch.xpack.prelert.utils.ExceptionsHelper;
|
||||
import org.elasticsearch.xpack.prelert.utils.time.TimeUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -62,12 +63,12 @@ public class TimeRange {
|
|||
}
|
||||
|
||||
public Builder startTime(String start) {
|
||||
this.start = start;
|
||||
this.start = ExceptionsHelper.requireNonNull(start, "start");
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder endTime(String end) {
|
||||
this.end = end;
|
||||
this.end = ExceptionsHelper.requireNonNull(end, "end");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue