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

Replace Streamable w/ Writable for MultiSearchRequest #44057

Merged
merged 2 commits into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -20,19 +20,13 @@
package org.elasticsearch.action.search;

import org.elasticsearch.action.ActionType;
import org.elasticsearch.common.io.stream.Writeable;

public class MultiSearchAction extends ActionType<MultiSearchResponse> {

public static final MultiSearchAction INSTANCE = new MultiSearchAction();
public static final String NAME = "indices:data/read/msearch";

private MultiSearchAction() {
super(NAME);
}

@Override
public Writeable.Reader<MultiSearchResponse> getResponseReader() {
return MultiSearchResponse::new;
super(NAME, MultiSearchResponse::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ public class MultiSearchRequest extends ActionRequest implements CompositeIndice
public static final int MAX_CONCURRENT_SEARCH_REQUESTS_DEFAULT = 0;

private int maxConcurrentSearchRequests = 0;
private List<SearchRequest> requests = new ArrayList<>();
private final List<SearchRequest> requests = new ArrayList<>();

private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpenAndForbidClosedIgnoreThrottled();

public MultiSearchRequest() {}

/**
* Add a search request to execute. Note, the order is important, the search response will be returned in the
* same order as the search requests.
Expand Down Expand Up @@ -129,9 +131,9 @@ public MultiSearchRequest indicesOptions(IndicesOptions indicesOptions) {
return this;
}

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);

public MultiSearchRequest(StreamInput in) throws IOException {
super(in);
maxConcurrentSearchRequests = in.readVInt();
int size = in.readVInt();
for (int i = 0; i < size; i++) {
Expand All @@ -140,6 +142,11 @@ public void readFrom(StreamInput in) throws IOException {
}
}

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

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.AtomicArray;
import org.elasticsearch.common.util.concurrent.EsExecutors;
Expand All @@ -51,7 +52,7 @@ public class TransportMultiSearchAction extends HandledTransportAction<MultiSear
@Inject
public TransportMultiSearchAction(Settings settings, ThreadPool threadPool, TransportService transportService,
ClusterService clusterService, ActionFilters actionFilters, NodeClient client) {
super(MultiSearchAction.NAME, transportService, actionFilters, MultiSearchRequest::new);
super(MultiSearchAction.NAME, transportService, actionFilters, (Writeable.Reader<MultiSearchRequest>) MultiSearchRequest::new);
this.threadPool = threadPool;
this.clusterService = clusterService;
this.availableProcessors = EsExecutors.numberOfProcessors(settings);
Expand All @@ -62,7 +63,7 @@ public TransportMultiSearchAction(Settings settings, ThreadPool threadPool, Tran
TransportMultiSearchAction(ThreadPool threadPool, ActionFilters actionFilters, TransportService transportService,
ClusterService clusterService, int availableProcessors,
LongSupplier relativeTimeProvider, NodeClient client) {
super(MultiSearchAction.NAME, transportService, actionFilters, MultiSearchRequest::new);
super(MultiSearchAction.NAME, transportService, actionFilters, (Writeable.Reader<MultiSearchRequest>) MultiSearchRequest::new);
this.threadPool = threadPool;
this.clusterService = clusterService;
this.availableProcessors = availableProcessors;
Expand Down