[ML] Data Frame minor tidy ups (#40580)

Remove Xlint-rawtypes option and remove unused request builders.
Not all requests need to implement ToXContent.
This commit is contained in:
David Kyle 2019-03-28 12:27:46 +00:00 committed by GitHub
parent 073b13f5b0
commit 6ef657c5ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 55 additions and 132 deletions

View File

@ -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<DeleteDataFrameTransf
return new Response();
}
public static class Request extends BaseTasksRequest<Request> implements ToXContentFragment {
public static class Request extends BaseTasksRequest<Request> {
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<DeleteDataFrameTransf
return null;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(DataFrameField.ID.getPreferredName(), id);
return builder;
}
@Override
public int hashCode() {
return Objects.hash(id);
@ -102,14 +90,6 @@ public class DeleteDataFrameTransformAction extends Action<DeleteDataFrameTransf
}
}
public static class RequestBuilder
extends ActionRequestBuilder<DeleteDataFrameTransformAction.Request, DeleteDataFrameTransformAction.Response> {
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 {

View File

@ -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<GetDataFrameTransformsA
return new Response();
}
public static class Request extends AbstractGetResourcesRequest implements ToXContent {
public static class Request extends AbstractGetResourcesRequest {
private static final int MAX_SIZE_RETURN = 1000;
@ -78,25 +75,12 @@ public class GetDataFrameTransformsAction extends Action<GetDataFrameTransformsA
return exception;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(DataFrameField.ID.getPreferredName(), getResourceId());
return builder;
}
@Override
public String getResourceIdField() {
return DataFrameField.ID.getPreferredName();
}
}
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {
protected RequestBuilder(ElasticsearchClient client, GetDataFrameTransformsAction action) {
super(client, action, new Request());
}
}
public static class Response extends AbstractGetResourcesResponse<DataFrameTransformConfig> implements Writeable, ToXContentObject {
public static final String INVALID_TRANSFORMS_DEPRECATION_WARNING = "Found [{}] invalid transforms";

View File

@ -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<GetDataFrameTransf
return new Response();
}
public static class Request extends BaseTasksRequest<Request> implements ToXContent {
public static class Request extends BaseTasksRequest<Request> {
private String id;
public Request(String id) {
@ -55,8 +52,6 @@ public class GetDataFrameTransformsStatsAction extends Action<GetDataFrameTransf
}
}
private Request() {}
public Request(StreamInput in) throws IOException {
super(in);
id = in.readString();
@ -87,12 +82,6 @@ public class GetDataFrameTransformsStatsAction extends Action<GetDataFrameTransf
return null;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(DataFrameField.ID.getPreferredName(), id);
return builder;
}
@Override
public int hashCode() {
return Objects.hash(id);
@ -111,13 +100,6 @@ public class GetDataFrameTransformsStatsAction extends Action<GetDataFrameTransf
}
}
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {
protected RequestBuilder(ElasticsearchClient client, GetDataFrameTransformsStatsAction action) {
super(client, action, new Request());
}
}
public static class Response extends BaseTasksResponse implements Writeable, ToXContentObject {
private List<DataFrameTransformStateAndStats> transformsStateAndStats;

View File

@ -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<PutDataFrameTransformAct
}
}
public static class RequestBuilder extends MasterNodeOperationRequestBuilder<Request, Response, RequestBuilder> {
protected RequestBuilder(ElasticsearchClient client, PutDataFrameTransformAction action) {
super(client, action, new Request());
}
}
public static class Response extends AcknowledgedResponse {
public Response() {
super();

View File

@ -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<StartDataFrameTransfor
return new Response();
}
public static class Request extends AcknowledgedRequest<Request> implements ToXContent {
public static class Request extends AcknowledgedRequest<Request> {
private String id;
private boolean force;
@ -76,12 +73,6 @@ public class StartDataFrameTransformAction extends Action<StartDataFrameTransfor
return null;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(DataFrameField.ID.getPreferredName(), id);
return builder;
}
@Override
public int hashCode() {
return Objects.hash(id);
@ -100,13 +91,6 @@ public class StartDataFrameTransformAction extends Action<StartDataFrameTransfor
}
}
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {
protected RequestBuilder(ElasticsearchClient client, StartDataFrameTransformAction action) {
super(client, action, new Request());
}
}
public static class Response extends BaseTasksResponse implements Writeable, ToXContentObject {
private boolean started;

View File

@ -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<StartDataFrameTran
return new Response();
}
public static class Request extends BaseTasksRequest<Request> implements ToXContent {
public static class Request extends BaseTasksRequest<Request> {
private String id;
@ -70,12 +67,6 @@ public class StartDataFrameTransformTaskAction extends Action<StartDataFrameTran
return null;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(DataFrameField.ID.getPreferredName(), id);
return builder;
}
@Override
public int hashCode() {
return Objects.hash(id);
@ -94,13 +85,6 @@ public class StartDataFrameTransformTaskAction extends Action<StartDataFrameTran
}
}
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {
protected RequestBuilder(ElasticsearchClient client, StartDataFrameTransformTaskAction action) {
super(client, action, new Request());
}
}
public static class Response extends BaseTasksResponse implements Writeable, ToXContentObject {
private boolean started;

View File

@ -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<StopDataFrameTransformA
return new Response();
}
public static class Request extends BaseTasksRequest<Request> implements ToXContent {
public static class Request extends BaseTasksRequest<Request> {
private String id;
private final boolean waitForCompletion;
private final boolean force;
@ -98,17 +95,6 @@ public class StopDataFrameTransformAction extends Action<StopDataFrameTransformA
return null;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(DataFrameField.ID.getPreferredName(), id);
builder.field(DataFrameField.WAIT_FOR_COMPLETION.getPreferredName(), waitForCompletion);
builder.field(DataFrameField.FORCE.getPreferredName(), force);
if (this.getTimeout() != null) {
builder.field(DataFrameField.TIMEOUT.getPreferredName(), this.getTimeout());
}
return builder;
}
@Override
public int hashCode() {
// the base class does not implement hashCode, therefore we need to hash timeout ourselves
@ -144,13 +130,6 @@ public class StopDataFrameTransformAction extends Action<StopDataFrameTransformA
}
}
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {
protected RequestBuilder(ElasticsearchClient client, StopDataFrameTransformAction action) {
super(client, action, new Request());
}
}
public static class Response extends BaseTasksResponse implements Writeable, ToXContentObject {
private boolean stopped;

View File

@ -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<StartDataFrameTransformTaskAction.Request> {
@Override
protected StartDataFrameTransformTaskAction.Request createTestInstance() {
return new StartDataFrameTransformTaskAction.Request(randomAlphaOfLength(4));
}
@Override
protected Writeable.Reader<StartDataFrameTransformTaskAction.Request> instanceReader() {
return StartDataFrameTransformTaskAction.Request::new;
}
}

View File

@ -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<StartDataFrameTransformTaskAction.Response> {
@Override
protected StartDataFrameTransformTaskAction.Response createTestInstance() {
return new StartDataFrameTransformTaskAction.Response(randomBoolean());
}
@Override
protected Writeable.Reader<StartDataFrameTransformTaskAction.Response> instanceReader() {
return StartDataFrameTransformTaskAction.Response::new;
}
}

View File

@ -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}"

View File

@ -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);

View File

@ -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));
}