From 6ef657c5ad60da054b7fa3ec1bd3e7fcb10d0010 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Thu, 28 Mar 2019 12:27:46 +0000 Subject: [PATCH] [ML] Data Frame minor tidy ups (#40580) Remove Xlint-rawtypes option and remove unused request builders. Not all requests need to implement ToXContent. --- .../DeleteDataFrameTransformAction.java | 22 +----------------- .../action/GetDataFrameTransformsAction.java | 18 +-------------- .../GetDataFrameTransformsStatsAction.java | 20 +--------------- .../action/PutDataFrameTransformAction.java | 9 -------- .../action/StartDataFrameTransformAction.java | 18 +-------------- .../StartDataFrameTransformTaskAction.java | 18 +-------------- .../action/StopDataFrameTransformAction.java | 23 +------------------ ...aFrameTransformTaskActionRequestTests.java | 23 +++++++++++++++++++ ...FrameTransformTaskActionResponseTests.java | 23 +++++++++++++++++++ x-pack/plugin/data-frame/build.gradle | 3 --- ...ansportDeleteDataFrameTransformAction.java | 7 ++---- .../util/BatchedDataIteratorTests.java | 3 +-- 12 files changed, 55 insertions(+), 132 deletions(-) create mode 100644 x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskActionRequestTests.java create mode 100644 x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskActionResponseTests.java diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/DeleteDataFrameTransformAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/DeleteDataFrameTransformAction.java index 13e62da090c..0316153fbc8 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/DeleteDataFrameTransformAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/DeleteDataFrameTransformAction.java @@ -6,17 +6,14 @@ package org.elasticsearch.xpack.core.dataframe.action; import org.elasticsearch.action.Action; -import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.TaskOperationFailure; import org.elasticsearch.action.support.tasks.BaseTasksRequest; import org.elasticsearch.action.support.tasks.BaseTasksResponse; -import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.tasks.Task; @@ -42,16 +39,13 @@ public class DeleteDataFrameTransformAction extends Action implements ToXContentFragment { + public static class Request extends BaseTasksRequest { private String id; public Request(String id) { this.id = ExceptionsHelper.requireNonNull(id, DataFrameField.ID.getPreferredName()); } - private Request() { - } - public Request(StreamInput in) throws IOException { super(in); id = in.readString(); @@ -77,12 +71,6 @@ public class DeleteDataFrameTransformAction extends Action { - - protected RequestBuilder(ElasticsearchClient client, DeleteDataFrameTransformAction action) { - super(client, action, new DeleteDataFrameTransformAction.Request()); - } - } - public static class Response extends BaseTasksResponse implements Writeable, ToXContentObject { private boolean acknowledged; public Response(StreamInput in) throws IOException { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/GetDataFrameTransformsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/GetDataFrameTransformsAction.java index ca6bf9d16e6..ac1498c72a6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/GetDataFrameTransformsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/GetDataFrameTransformsAction.java @@ -8,14 +8,11 @@ package org.elasticsearch.xpack.core.dataframe.action; import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.Action; -import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.logging.DeprecationLogger; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.xpack.core.action.AbstractGetResourcesRequest; @@ -48,7 +45,7 @@ public class GetDataFrameTransformsAction extends Action { - - protected RequestBuilder(ElasticsearchClient client, GetDataFrameTransformsAction action) { - super(client, action, new Request()); - } - } - public static class Response extends AbstractGetResourcesResponse implements Writeable, ToXContentObject { public static final String INVALID_TRANSFORMS_DEPRECATION_WARNING = "Found [{}] invalid transforms"; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/GetDataFrameTransformsStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/GetDataFrameTransformsStatsAction.java index 47e92203307..f0e92aa36db 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/GetDataFrameTransformsStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/GetDataFrameTransformsStatsAction.java @@ -7,19 +7,16 @@ package org.elasticsearch.xpack.core.dataframe.action; import org.elasticsearch.action.Action; -import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.TaskOperationFailure; import org.elasticsearch.action.support.tasks.BaseTasksRequest; import org.elasticsearch.action.support.tasks.BaseTasksResponse; -import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.tasks.Task; @@ -44,7 +41,7 @@ public class GetDataFrameTransformsStatsAction extends Action implements ToXContent { + public static class Request extends BaseTasksRequest { private String id; public Request(String id) { @@ -55,8 +52,6 @@ public class GetDataFrameTransformsStatsAction extends Action { - - protected RequestBuilder(ElasticsearchClient client, GetDataFrameTransformsStatsAction action) { - super(client, action, new Request()); - } - } - public static class Response extends BaseTasksResponse implements Writeable, ToXContentObject { private List transformsStateAndStats; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/PutDataFrameTransformAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/PutDataFrameTransformAction.java index 6c226003f66..51b5e0d4ec1 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/PutDataFrameTransformAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/PutDataFrameTransformAction.java @@ -10,8 +10,6 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder; -import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ToXContentObject; @@ -100,13 +98,6 @@ public class PutDataFrameTransformAction extends Action { - - protected RequestBuilder(ElasticsearchClient client, PutDataFrameTransformAction action) { - super(client, action, new Request()); - } - } - public static class Response extends AcknowledgedResponse { public Response() { super(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformAction.java index 161c4d7d258..b86a2339faa 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformAction.java @@ -7,15 +7,12 @@ package org.elasticsearch.xpack.core.dataframe.action; import org.elasticsearch.action.Action; -import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.action.support.tasks.BaseTasksResponse; -import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.xpack.core.dataframe.DataFrameField; @@ -39,7 +36,7 @@ public class StartDataFrameTransformAction extends Action implements ToXContent { + public static class Request extends AcknowledgedRequest { private String id; private boolean force; @@ -76,12 +73,6 @@ public class StartDataFrameTransformAction extends Action { - - protected RequestBuilder(ElasticsearchClient client, StartDataFrameTransformAction action) { - super(client, action, new Request()); - } - } - public static class Response extends BaseTasksResponse implements Writeable, ToXContentObject { private boolean started; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskAction.java index a51b9243c3d..d3c96fb9cf1 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskAction.java @@ -7,15 +7,12 @@ package org.elasticsearch.xpack.core.dataframe.action; import org.elasticsearch.action.Action; -import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.tasks.BaseTasksRequest; import org.elasticsearch.action.support.tasks.BaseTasksResponse; -import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.xpack.core.dataframe.DataFrameField; @@ -39,7 +36,7 @@ public class StartDataFrameTransformTaskAction extends Action implements ToXContent { + public static class Request extends BaseTasksRequest { private String id; @@ -70,12 +67,6 @@ public class StartDataFrameTransformTaskAction extends Action { - - protected RequestBuilder(ElasticsearchClient client, StartDataFrameTransformTaskAction action) { - super(client, action, new Request()); - } - } - public static class Response extends BaseTasksResponse implements Writeable, ToXContentObject { private boolean started; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StopDataFrameTransformAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StopDataFrameTransformAction.java index 2fb14ddd013..7fa437bd156 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StopDataFrameTransformAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/StopDataFrameTransformAction.java @@ -6,17 +6,14 @@ package org.elasticsearch.xpack.core.dataframe.action; import org.elasticsearch.action.Action; -import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.tasks.BaseTasksRequest; import org.elasticsearch.action.support.tasks.BaseTasksResponse; -import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.tasks.Task; @@ -44,7 +41,7 @@ public class StopDataFrameTransformAction extends Action implements ToXContent { + public static class Request extends BaseTasksRequest { private String id; private final boolean waitForCompletion; private final boolean force; @@ -98,17 +95,6 @@ public class StopDataFrameTransformAction extends Action { - - protected RequestBuilder(ElasticsearchClient client, StopDataFrameTransformAction action) { - super(client, action, new Request()); - } - } - public static class Response extends BaseTasksResponse implements Writeable, ToXContentObject { private boolean stopped; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskActionRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskActionRequestTests.java new file mode 100644 index 00000000000..8d3d8e3ac78 --- /dev/null +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskActionRequestTests.java @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.core.dataframe.action; + +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.test.AbstractWireSerializingTestCase; + +public class StartDataFrameTransformTaskActionRequestTests extends + AbstractWireSerializingTestCase { + @Override + protected StartDataFrameTransformTaskAction.Request createTestInstance() { + return new StartDataFrameTransformTaskAction.Request(randomAlphaOfLength(4)); + } + + @Override + protected Writeable.Reader instanceReader() { + return StartDataFrameTransformTaskAction.Request::new; + } +} diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskActionResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskActionResponseTests.java new file mode 100644 index 00000000000..62165f87968 --- /dev/null +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/dataframe/action/StartDataFrameTransformTaskActionResponseTests.java @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.core.dataframe.action; + +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.test.AbstractWireSerializingTestCase; + +public class StartDataFrameTransformTaskActionResponseTests extends + AbstractWireSerializingTestCase { + @Override + protected StartDataFrameTransformTaskAction.Response createTestInstance() { + return new StartDataFrameTransformTaskAction.Response(randomBoolean()); + } + + @Override + protected Writeable.Reader instanceReader() { + return StartDataFrameTransformTaskAction.Response::new; + } +} diff --git a/x-pack/plugin/data-frame/build.gradle b/x-pack/plugin/data-frame/build.gradle index bff8118bfc4..ad4d846fd16 100644 --- a/x-pack/plugin/data-frame/build.gradle +++ b/x-pack/plugin/data-frame/build.gradle @@ -8,9 +8,6 @@ esplugin { extendedPlugins = ['x-pack-core'] } -compileJava.options.compilerArgs << "-Xlint:-rawtypes" -compileTestJava.options.compilerArgs << "-Xlint:-rawtypes" - dependencies { compileOnly "org.elasticsearch:elasticsearch:${version}" diff --git a/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportDeleteDataFrameTransformAction.java b/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportDeleteDataFrameTransformAction.java index 131ad690d2b..2cdc4009e78 100644 --- a/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportDeleteDataFrameTransformAction.java +++ b/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportDeleteDataFrameTransformAction.java @@ -12,20 +12,18 @@ import org.elasticsearch.action.TaskOperationFailure; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.tasks.TransportTasksAction; import org.elasticsearch.cluster.ClusterState; -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.discovery.MasterNotDiscoveredException; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; -import org.elasticsearch.persistent.PersistentTasksService; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.dataframe.action.DeleteDataFrameTransformAction; -import org.elasticsearch.xpack.core.indexing.IndexerState; import org.elasticsearch.xpack.core.dataframe.action.DeleteDataFrameTransformAction.Request; import org.elasticsearch.xpack.core.dataframe.action.DeleteDataFrameTransformAction.Response; +import org.elasticsearch.xpack.core.indexing.IndexerState; import org.elasticsearch.xpack.dataframe.persistence.DataFrameTransformsConfigManager; import org.elasticsearch.xpack.dataframe.transforms.DataFrameTransformTask; @@ -36,8 +34,7 @@ public class TransportDeleteDataFrameTransformAction extends TransportTasksActio private final DataFrameTransformsConfigManager transformsConfigManager; @Inject - public TransportDeleteDataFrameTransformAction(TransportService transportService, ThreadPool threadPool, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver, PersistentTasksService persistentTasksService, + public TransportDeleteDataFrameTransformAction(TransportService transportService, ActionFilters actionFilters, ClusterService clusterService, DataFrameTransformsConfigManager transformsConfigManager) { super(DeleteDataFrameTransformAction.NAME, clusterService, transportService, actionFilters, Request::new, Response::new, Response::new, ThreadPool.Names.SAME); diff --git a/x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/util/BatchedDataIteratorTests.java b/x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/util/BatchedDataIteratorTests.java index 6a0714076a3..4ca60acac37 100644 --- a/x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/util/BatchedDataIteratorTests.java +++ b/x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/util/BatchedDataIteratorTests.java @@ -146,7 +146,7 @@ public class BatchedDataIteratorTests extends ESTestCase { testIterator.next(future); batch = future.get(); assertEquals(1, batch.size()); - assertTrue(batch.containsAll(Collections.singletonList(createJsonDoc("f")))); + assertTrue(batch.contains(createJsonDoc("f"))); assertFalse(testIterator.hasNext()); assertTrue(wasScrollCleared); @@ -183,7 +183,6 @@ public class BatchedDataIteratorTests extends ESTestCase { SearchRequest searchRequest = searchRequests.get(0); assertThat(searchRequest.indices(), equalTo(new String[] {INDEX_NAME})); assertThat(searchRequest.scroll().keepAlive(), equalTo(TimeValue.timeValueMinutes(5))); - assertThat(searchRequest.types().length, equalTo(0)); assertThat(searchRequest.source().query(), equalTo(QueryBuilders.matchAllQuery())); assertThat(searchRequest.source().trackTotalHitsUpTo(), is(SearchContext.TRACK_TOTAL_HITS_ACCURATE)); }