Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate more ML actions off of using Request suppliers #44462

Merged
merged 7 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Supplier;

import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;

Expand All @@ -62,8 +61,9 @@ public abstract class AbstractTransportGetResourcesAction<Resource extends ToXCo
private final NamedXContentRegistry xContentRegistry;

protected AbstractTransportGetResourcesAction(String actionName, TransportService transportService, ActionFilters actionFilters,
Supplier<Request> request, Client client, NamedXContentRegistry xContentRegistry) {
super(actionName, transportService, request, actionFilters);
Writeable.Reader<Request> request, Client client,
NamedXContentRegistry xContentRegistry) {
super(actionName, transportService, actionFilters, request);
this.client = Objects.requireNonNull(client);
this.xContentRegistry = Objects.requireNonNull(xContentRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public static class Request extends ActionRequest {

public Request() {}

public Request(StreamInput in) throws IOException {
super(in);
}

@Override
public ActionRequestValidationException validate() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public static class Request extends ActionRequest {
public Request() {
}

public Request(StreamInput in) throws IOException {
super(in);
jobId = in.readString();
snapshotId = in.readString();
}

public Request(String jobId, String snapshotId) {
this.jobId = ExceptionsHelper.requireNonNull(jobId, Job.ID.getPreferredName());
this.snapshotId = ExceptionsHelper.requireNonNull(snapshotId, ModelSnapshotField.SNAPSHOT_ID.getPreferredName());
Expand All @@ -62,9 +68,7 @@ public ActionRequestValidationException validate() {

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
jobId = in.readString();
snapshotId = in.readString();
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public Request(Detector detector) {
this.detector = detector;
}

public Request(StreamInput in) throws IOException {
super(in);
detector = new Detector(in);
}

public Detector getDetector() {
return detector;
}
Expand All @@ -78,8 +83,7 @@ public void writeTo(StreamOutput out) throws IOException {

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
detector = new Detector(in);
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public Request(Job job) {
this.job = job;
}

public Request(StreamInput in) throws IOException {
super(in);
job = new Job(in);
}

public Job getJob() {
return job;
}
Expand All @@ -95,8 +100,7 @@ public void writeTo(StreamOutput out) throws IOException {

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
job = new Job(in);
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class TransportDeleteCalendarAction extends HandledTransportAction<Delete
public TransportDeleteCalendarAction(TransportService transportService,
ActionFilters actionFilters, Client client, JobManager jobManager,
JobResultsProvider jobResultsProvider) {
super(DeleteCalendarAction.NAME, transportService, DeleteCalendarAction.Request::new, actionFilters);
super(DeleteCalendarAction.NAME, transportService, actionFilters, DeleteCalendarAction.Request::new);
this.client = client;
this.jobManager = jobManager;
this.jobResultsProvider = jobResultsProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class TransportDeleteCalendarEventAction extends HandledTransportAction<D
@Inject
public TransportDeleteCalendarEventAction(TransportService transportService, ActionFilters actionFilters,
Client client, JobResultsProvider jobResultsProvider, JobManager jobManager) {
super(DeleteCalendarEventAction.NAME, transportService, DeleteCalendarEventAction.Request::new, actionFilters);
super(DeleteCalendarEventAction.NAME, transportService, actionFilters, DeleteCalendarEventAction.Request::new);
this.client = client;
this.jobResultsProvider = jobResultsProvider;
this.jobManager = jobManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class TransportDeleteExpiredDataAction extends HandledTransportAction<Del
@Inject
public TransportDeleteExpiredDataAction(ThreadPool threadPool, TransportService transportService,
ActionFilters actionFilters, Client client, ClusterService clusterService) {
super(DeleteExpiredDataAction.NAME, transportService, DeleteExpiredDataAction.Request::new, actionFilters);
super(DeleteExpiredDataAction.NAME, transportService, actionFilters, DeleteExpiredDataAction.Request::new);
this.threadPool = threadPool;
this.client = ClientHelper.clientWithOrigin(client, ClientHelper.ML_ORIGIN);
this.clusterService = clusterService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class TransportDeleteFilterAction extends HandledTransportAction<DeleteFi
public TransportDeleteFilterAction(TransportService transportService,
ActionFilters actionFilters, Client client,
JobConfigProvider jobConfigProvider) {
super(DeleteFilterAction.NAME, transportService, DeleteFilterAction.Request::new, actionFilters);
super(DeleteFilterAction.NAME, transportService, actionFilters, DeleteFilterAction.Request::new);
this.client = client;
this.jobConfigProvider = jobConfigProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class TransportDeleteForecastAction extends HandledTransportAction<Delete

@Inject
public TransportDeleteForecastAction(TransportService transportService, ActionFilters actionFilters, Client client) {
super(DeleteForecastAction.NAME, transportService, DeleteForecastAction.Request::new, actionFilters);
super(DeleteForecastAction.NAME, transportService, actionFilters, DeleteForecastAction.Request::new);
this.client = client;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class TransportDeleteModelSnapshotAction extends HandledTransportAction<D
public TransportDeleteModelSnapshotAction(TransportService transportService, ActionFilters actionFilters,
JobResultsProvider jobResultsProvider, Client client, JobManager jobManager,
Auditor auditor) {
super(DeleteModelSnapshotAction.NAME, transportService, DeleteModelSnapshotAction.Request::new, actionFilters);
super(DeleteModelSnapshotAction.NAME, transportService, actionFilters, DeleteModelSnapshotAction.Request::new);
this.client = client;
this.jobManager = jobManager;
this.jobResultsProvider = jobResultsProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public class TransportGetCalendarEventsAction extends HandledTransportAction<Get
public TransportGetCalendarEventsAction(TransportService transportService,
ActionFilters actionFilters, JobResultsProvider jobResultsProvider,
JobConfigProvider jobConfigProvider) {
super(GetCalendarEventsAction.NAME, transportService, GetCalendarEventsAction.Request::new, actionFilters
);
super(GetCalendarEventsAction.NAME, transportService, actionFilters, GetCalendarEventsAction.Request::new);
this.jobResultsProvider = jobResultsProvider;
this.jobConfigProvider = jobConfigProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class TransportValidateDetectorAction extends HandledTransportAction<Vali

@Inject
public TransportValidateDetectorAction(TransportService transportService, ActionFilters actionFilters) {
super(ValidateDetectorAction.NAME, transportService, ValidateDetectorAction.Request::new, actionFilters);
super(ValidateDetectorAction.NAME, transportService, actionFilters, ValidateDetectorAction.Request::new);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public class TransportValidateJobConfigAction extends HandledTransportAction<Val

@Inject
public TransportValidateJobConfigAction(TransportService transportService, ActionFilters actionFilters) {
super(ValidateJobConfigAction.NAME, transportService, ValidateJobConfigAction.Request::new, actionFilters
);
super(ValidateJobConfigAction.NAME, transportService, actionFilters, ValidateJobConfigAction.Request::new);
}

@Override
Expand Down