From 97970b94cd6f0b925892fb13cf4a79606d21f236 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Tue, 31 Jan 2017 11:48:58 +0000 Subject: [PATCH] Remove the ignoreDowntime parameter from the _data endpoint (elastic/elasticsearch#834) The parameter only applies when a job is opened Original commit: elastic/x-pack-elasticsearch@37b902aa2a63b32ab5594c0a7c144d37d9fb3319 --- .../xpack/ml/action/OpenJobAction.java | 3 +++ .../xpack/ml/action/PostDataAction.java | 18 ++---------------- .../autodetect/params/DataLoadParams.java | 8 +------- .../xpack/ml/rest/job/RestOpenJobAction.java | 2 +- .../xpack/ml/rest/job/RestPostDataAction.java | 3 --- .../ml/action/PostDataActionRequestTests.java | 1 - .../AutodetectCommunicatorTests.java | 4 ++-- .../AutodetectProcessManagerTests.java | 4 ++-- .../NativeAutodetectProcessTests.java | 2 +- .../autodetect/params/DataLoadParamsTests.java | 12 ++++++------ .../writer/ControlMsgToProcessWriterTests.java | 2 +- 11 files changed, 19 insertions(+), 40 deletions(-) diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java index e6462e38c23..7844ce8bc6c 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java @@ -16,6 +16,7 @@ import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.ParseField; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -56,6 +57,8 @@ public class OpenJobAction extends Action { - public static final ParseField IGNORE_DOWNTIME = new ParseField("ignore_downtime"); public static final ParseField RESET_START = new ParseField("reset_start"); public static final ParseField RESET_END = new ParseField("reset_end"); - private boolean ignoreDowntime = false; private String resetStart = ""; private String resetEnd = ""; private DataDescription dataDescription; @@ -151,14 +149,6 @@ public class PostDataAction extends Action listener) { TimeRange timeRange = TimeRange.builder().startTime(request.getResetStart()).endTime(request.getResetEnd()).build(); - DataLoadParams params = new DataLoadParams(timeRange, request.isIgnoreDowntime(), - Optional.ofNullable(request.getDataDescription())); + DataLoadParams params = new DataLoadParams(timeRange, Optional.ofNullable(request.getDataDescription())); threadPool.executor(MlPlugin.THREAD_POOL_NAME).execute(() -> { try { DataCounts dataCounts = processManager.processData(request.getJobId(), request.content.streamInput(), params); diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParams.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParams.java index 5e2d9c6f464..a63f140f904 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParams.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParams.java @@ -12,12 +12,10 @@ import java.util.Optional; public class DataLoadParams { private final TimeRange resetTimeRange; - private final boolean ignoreDowntime; private final Optional dataDescription; - public DataLoadParams(TimeRange resetTimeRange, boolean ignoreDowntime, Optional dataDescription) { + public DataLoadParams(TimeRange resetTimeRange, Optional dataDescription) { this.resetTimeRange = Objects.requireNonNull(resetTimeRange); - this.ignoreDowntime = ignoreDowntime; this.dataDescription = Objects.requireNonNull(dataDescription); } @@ -33,10 +31,6 @@ public class DataLoadParams { return resetTimeRange.getEnd(); } - public boolean isIgnoreDowntime() { - return ignoreDowntime; - } - public Optional getDataDescription() { return dataDescription; } diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestOpenJobAction.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestOpenJobAction.java index 22e5061d763..f75e1c9c082 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestOpenJobAction.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestOpenJobAction.java @@ -30,7 +30,7 @@ public class RestOpenJobAction extends BaseRestHandler { @Override protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException { OpenJobAction.Request request = new OpenJobAction.Request(restRequest.param(Job.ID.getPreferredName())); - request.setIgnoreDowntime(restRequest.paramAsBoolean(PostDataAction.Request.IGNORE_DOWNTIME.getPreferredName(), false)); + request.setIgnoreDowntime(restRequest.paramAsBoolean(OpenJobAction.Request.IGNORE_DOWNTIME.getPreferredName(), false)); if (restRequest.hasParam("open_timeout")) { TimeValue openTimeout = restRequest.paramAsTime("open_timeout", TimeValue.timeValueSeconds(30)); request.setOpenTimeout(openTimeout); diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostDataAction.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostDataAction.java index 8265fb943a6..5d89dd1f56e 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostDataAction.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/ml/rest/job/RestPostDataAction.java @@ -19,7 +19,6 @@ import java.io.IOException; public class RestPostDataAction extends BaseRestHandler { - private static final boolean DEFAULT_IGNORE_DOWNTIME = false; private static final String DEFAULT_RESET_START = ""; private static final String DEFAULT_RESET_END = ""; @@ -32,8 +31,6 @@ public class RestPostDataAction extends BaseRestHandler { @Override protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException { PostDataAction.Request request = new PostDataAction.Request(restRequest.param(Job.ID.getPreferredName())); - request.setIgnoreDowntime( - restRequest.paramAsBoolean(PostDataAction.Request.IGNORE_DOWNTIME.getPreferredName(), DEFAULT_IGNORE_DOWNTIME)); request.setResetStart(restRequest.param(PostDataAction.Request.RESET_START.getPreferredName(), DEFAULT_RESET_START)); request.setResetEnd(restRequest.param(PostDataAction.Request.RESET_END.getPreferredName(), DEFAULT_RESET_END)); request.setContent(restRequest.content()); diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java index f5840793c61..0f4544214a8 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/action/PostDataActionRequestTests.java @@ -11,7 +11,6 @@ public class PostDataActionRequestTests extends AbstractStreamableTestCase communicator.writeToJob(in, mock(DataLoadParams.class))); communicator.inUse.set(null); - communicator.writeToJob(in, new DataLoadParams(TimeRange.builder().build(), false, Optional.empty())); + communicator.writeToJob(in, new DataLoadParams(TimeRange.builder().build(), Optional.empty())); } public void testFlushInUse() throws IOException { diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java index c5d5d89e02f..2f9cc2e0173 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java @@ -174,7 +174,7 @@ public class AutodetectProcessManagerTests extends ESTestCase { AutodetectProcessManager manager = createManager(communicator); assertEquals(0, manager.numberOfOpenJobs()); - DataLoadParams params = new DataLoadParams(TimeRange.builder().build(), false, Optional.empty()); + DataLoadParams params = new DataLoadParams(TimeRange.builder().build(), Optional.empty()); manager.openJob("foo", false, e -> {}); manager.processData("foo", createInputStream(""), params); assertEquals(1, manager.numberOfOpenJobs()); @@ -212,7 +212,7 @@ public class AutodetectProcessManagerTests extends ESTestCase { AutodetectCommunicator communicator = mock(AutodetectCommunicator.class); AutodetectProcessManager manager = createManager(communicator); - DataLoadParams params = new DataLoadParams(TimeRange.builder().startTime("1000").endTime("2000").build(), true, Optional.empty()); + DataLoadParams params = new DataLoadParams(TimeRange.builder().startTime("1000").endTime("2000").build(), Optional.empty()); InputStream inputStream = createInputStream(""); manager.openJob("foo", false, e -> {}); manager.processData("foo", inputStream, params); diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java index 30a69a41e5e..4df0e784fce 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessTests.java @@ -106,7 +106,7 @@ public class NativeAutodetectProcessTests extends ESTestCase { bos, Mockito.mock(InputStream.class), Mockito.mock(InputStream.class), NUMBER_ANALYSIS_FIELDS, Collections.emptyList(), EsExecutors.newDirectExecutorService())) { - DataLoadParams params = new DataLoadParams(TimeRange.builder().startTime("1").endTime("86400").build(), true, Optional.empty()); + DataLoadParams params = new DataLoadParams(TimeRange.builder().startTime("1").endTime("86400").build(), Optional.empty()); process.writeResetBucketsControlMessage(params); process.flushStream(); diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParamsTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParamsTests.java index c71b28bd37d..7e4dc216234 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParamsTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/DataLoadParamsTests.java @@ -11,17 +11,17 @@ import java.util.Optional; public class DataLoadParamsTests extends ESTestCase { public void testGetStart() { - assertEquals("", new DataLoadParams(TimeRange.builder().build(), false, Optional.empty()).getStart()); - assertEquals("3", new DataLoadParams(TimeRange.builder().startTime("3").build(), false, Optional.empty()).getStart()); + assertEquals("", new DataLoadParams(TimeRange.builder().build(), Optional.empty()).getStart()); + assertEquals("3", new DataLoadParams(TimeRange.builder().startTime("3").build(), Optional.empty()).getStart()); } public void testGetEnd() { - assertEquals("", new DataLoadParams(TimeRange.builder().build(), false, Optional.empty()).getEnd()); - assertEquals("1", new DataLoadParams(TimeRange.builder().endTime("1").build(), false, Optional.empty()).getEnd()); + assertEquals("", new DataLoadParams(TimeRange.builder().build(), Optional.empty()).getEnd()); + assertEquals("1", new DataLoadParams(TimeRange.builder().endTime("1").build(), Optional.empty()).getEnd()); } public void testIsResettingBuckets() { - assertFalse(new DataLoadParams(TimeRange.builder().build(), false, Optional.empty()).isResettingBuckets()); - assertTrue(new DataLoadParams(TimeRange.builder().startTime("5").build(), false, Optional.empty()).isResettingBuckets()); + assertFalse(new DataLoadParams(TimeRange.builder().build(), Optional.empty()).isResettingBuckets()); + assertTrue(new DataLoadParams(TimeRange.builder().startTime("5").build(), Optional.empty()).isResettingBuckets()); } } diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java index 968a9a240ac..22ac79c7c53 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriterTests.java @@ -129,7 +129,7 @@ public class ControlMsgToProcessWriterTests extends ESTestCase { ControlMsgToProcessWriter writer = new ControlMsgToProcessWriter(lengthEncodedWriter, 2); writer.writeResetBucketsMessage( - new DataLoadParams(TimeRange.builder().startTime("0").endTime("600").build(), false, Optional.empty())); + new DataLoadParams(TimeRange.builder().startTime("0").endTime("600").build(), Optional.empty())); InOrder inOrder = inOrder(lengthEncodedWriter); inOrder.verify(lengthEncodedWriter).writeNumFields(4);