[ML] Get Jobs/Datafeed Actions can run on local node (elastic/x-pack-elasticsearch#2095)

* No need to execute Get Jobs/Datafeed Actions on master node

Original commit: elastic/x-pack-elasticsearch@9d19010c5f
This commit is contained in:
David Kyle 2017-08-02 11:24:28 +01:00 committed by GitHub
parent 0125a332a1
commit 7795d70414
4 changed files with 22 additions and 16 deletions

View File

@ -71,10 +71,13 @@ public class GetDatafeedsAction extends Action<GetDatafeedsAction.Request, GetDa
private boolean allowNoDatafeeds = true;
public Request(String datafeedId) {
this();
this.datafeedId = ExceptionsHelper.requireNonNull(datafeedId, DatafeedConfig.ID.getPreferredName());
}
Request() {}
Request() {
local(true);
}
public String getDatafeedId() {
return datafeedId;

View File

@ -7,6 +7,8 @@ package org.elasticsearch.xpack.ml.action;
import org.elasticsearch.action.Action;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.get.GetRequest;
@ -17,8 +19,6 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.TransportSearchAction;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder;
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.common.Strings;
@ -64,7 +64,7 @@ public class GetFiltersAction extends Action<GetFiltersAction.Request, GetFilter
@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client, this);
return new RequestBuilder(client);
}
@Override
@ -72,7 +72,7 @@ public class GetFiltersAction extends Action<GetFiltersAction.Request, GetFilter
return new Response();
}
public static class Request extends MasterNodeReadRequest<Request> {
public static class Request extends ActionRequest {
private String filterId;
private PageParams pageParams;
@ -146,10 +146,10 @@ public class GetFiltersAction extends Action<GetFiltersAction.Request, GetFilter
}
}
public static class RequestBuilder extends MasterNodeReadOperationRequestBuilder<Request, Response, RequestBuilder> {
public static class RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder> {
public RequestBuilder(ElasticsearchClient client, GetFiltersAction action) {
super(client, action, new Request());
public RequestBuilder(ElasticsearchClient client) {
super(client, INSTANCE, new Request());
}
}

View File

@ -65,10 +65,13 @@ public class GetJobsAction extends Action<GetJobsAction.Request, GetJobsAction.R
private boolean allowNoJobs = true;
public Request(String jobId) {
this();
this.jobId = ExceptionsHelper.requireNonNull(jobId, Job.ID.getPreferredName());
}
Request() {}
Request() {
local(true);
}
public void setAllowNoJobs(boolean allowNoJobs) {
this.allowNoJobs = allowNoJobs;

View File

@ -8,6 +8,8 @@ package org.elasticsearch.xpack.ml.action;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.Action;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
@ -17,8 +19,6 @@ import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.common.Strings;
@ -55,7 +55,7 @@ public class PutFilterAction extends Action<PutFilterAction.Request, PutFilterAc
@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client, this);
return new RequestBuilder(client);
}
@Override
@ -63,7 +63,7 @@ public class PutFilterAction extends Action<PutFilterAction.Request, PutFilterAc
return new Response();
}
public static class Request extends MasterNodeReadRequest<Request> implements ToXContentObject {
public static class Request extends ActionRequest implements ToXContentObject {
public static Request parseRequest(String filterId, XContentParser parser) {
MlFilter.Builder filter = MlFilter.PARSER.apply(parser, null);
@ -132,10 +132,10 @@ public class PutFilterAction extends Action<PutFilterAction.Request, PutFilterAc
}
}
public static class RequestBuilder extends MasterNodeOperationRequestBuilder<Request, Response, RequestBuilder> {
public static class RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder> {
public RequestBuilder(ElasticsearchClient client, PutFilterAction action) {
super(client, action, new Request());
public RequestBuilder(ElasticsearchClient client) {
super(client, INSTANCE, new Request());
}
}