introduce TransportRequest (with optional headers)
introduce a new class, TransportRequest, which includes headers. This class can be used when sending requests over the transport layer, and ActionRequest also extends it now. This is the first phase of the refactoring part in the transport layer and action layer to allow for simpler implementations of those as well as simpler "filtering" capabilities in the future
This commit is contained in:
parent
15fbbd43ce
commit
cfe7504d1c
|
@ -24,7 +24,7 @@ import org.elasticsearch.client.Client;
|
|||
/**
|
||||
* Main action (used with {@link Client} API.
|
||||
*/
|
||||
public abstract class Action<Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response>>
|
||||
public abstract class Action<Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>>
|
||||
extends GenericAction<Request, Response> {
|
||||
|
||||
protected Action(String name) {
|
||||
|
|
|
@ -19,14 +19,29 @@
|
|||
|
||||
package org.elasticsearch.action;
|
||||
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.transport.TransportRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface ActionRequest extends Streamable {
|
||||
public abstract class ActionRequest<T extends ActionRequest> extends TransportRequest {
|
||||
|
||||
ActionRequestValidationException validate();
|
||||
private boolean listenerThreaded = false;
|
||||
|
||||
protected ActionRequest() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected ActionRequest(ActionRequest request) {
|
||||
super(request);
|
||||
// this does not set the listenerThreaded API, if needed, its up to the caller to set it
|
||||
// since most times, we actually want it to not be threaded...
|
||||
//this.listenerThreaded = request.listenerThreaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the response listener be executed on a thread or not.
|
||||
|
@ -34,10 +49,28 @@ public interface ActionRequest extends Streamable {
|
|||
* <p>When not executing on a thread, it will either be executed on the calling thread, or
|
||||
* on an expensive, IO based, thread.
|
||||
*/
|
||||
boolean listenerThreaded();
|
||||
public final boolean listenerThreaded() {
|
||||
return this.listenerThreaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the response listener be executed on a thread or not.
|
||||
*/
|
||||
ActionRequest listenerThreaded(boolean listenerThreaded);
|
||||
@SuppressWarnings("unchecked")
|
||||
public final T listenerThreaded(boolean listenerThreaded) {
|
||||
this.listenerThreaded = listenerThreaded;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public abstract ActionRequestValidationException validate();
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,14 +19,48 @@
|
|||
|
||||
package org.elasticsearch.action;
|
||||
|
||||
import org.elasticsearch.action.support.PlainListenableActionFuture;
|
||||
import org.elasticsearch.client.internal.InternalGenericClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface ActionRequestBuilder<Request extends ActionRequest, Response extends ActionResponse> {
|
||||
public abstract class ActionRequestBuilder<Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder> {
|
||||
|
||||
Request request();
|
||||
protected final Request request;
|
||||
|
||||
ListenableActionFuture<Response> execute();
|
||||
protected final InternalGenericClient client;
|
||||
|
||||
void execute(ActionListener<Response> listener);
|
||||
protected ActionRequestBuilder(InternalGenericClient client, Request request) {
|
||||
this.client = client;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public Request request() {
|
||||
return this.request;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final RequestBuilder setListenerThreaded(boolean listenerThreaded) {
|
||||
request.listenerThreaded(listenerThreaded);
|
||||
return (RequestBuilder) this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final RequestBuilder putHeader(String key, Object value) {
|
||||
request.putHeader(key, value);
|
||||
return (RequestBuilder) this;
|
||||
}
|
||||
|
||||
public ListenableActionFuture<Response> execute() {
|
||||
PlainListenableActionFuture<Response> future = new PlainListenableActionFuture<Response>(request.listenerThreaded(), client.threadPool());
|
||||
execute(future);
|
||||
return future;
|
||||
}
|
||||
|
||||
public void execute(ActionListener<Response> listener) {
|
||||
doExecute(listener);
|
||||
}
|
||||
|
||||
protected abstract void doExecute(ActionListener<Response> listener);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.elasticsearch.client.ClusterAdminClient;
|
|||
/**
|
||||
* Cluster action (used with {@link ClusterAdminClient} API.
|
||||
*/
|
||||
public abstract class ClusterAction<Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response>>
|
||||
public abstract class ClusterAction<Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>>
|
||||
extends GenericAction<Request, Response> {
|
||||
|
||||
protected ClusterAction(String name) {
|
||||
|
|
|
@ -34,7 +34,7 @@ import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class ClusterHealthRequest extends MasterNodeOperationRequest {
|
||||
public class ClusterHealthRequest extends MasterNodeOperationRequest<ClusterHealthRequest> {
|
||||
|
||||
private String[] indices;
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class ClusterHealthRequest extends MasterNodeOperationRequest {
|
|||
} else {
|
||||
indices = new String[size];
|
||||
for (int i = 0; i < indices.length; i++) {
|
||||
indices[i] = in.readUTF();
|
||||
indices[i] = in.readString();
|
||||
}
|
||||
}
|
||||
timeout = readTimeValue(in);
|
||||
|
@ -150,7 +150,7 @@ public class ClusterHealthRequest extends MasterNodeOperationRequest {
|
|||
}
|
||||
waitForRelocatingShards = in.readInt();
|
||||
waitForActiveShards = in.readInt();
|
||||
waitForNodes = in.readUTF();
|
||||
waitForNodes = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -161,7 +161,7 @@ public class ClusterHealthRequest extends MasterNodeOperationRequest {
|
|||
} else {
|
||||
out.writeVInt(indices.length);
|
||||
for (String index : indices) {
|
||||
out.writeUTF(index);
|
||||
out.writeString(index);
|
||||
}
|
||||
}
|
||||
timeout.writeTo(out);
|
||||
|
@ -173,6 +173,6 @@ public class ClusterHealthRequest extends MasterNodeOperationRequest {
|
|||
}
|
||||
out.writeInt(waitForRelocatingShards);
|
||||
out.writeInt(waitForActiveShards);
|
||||
out.writeUTF(waitForNodes);
|
||||
out.writeString(waitForNodes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,17 +20,18 @@
|
|||
package org.elasticsearch.action.admin.cluster.health;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.cluster.support.BaseClusterRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalClusterAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ClusterHealthRequestBuilder extends BaseClusterRequestBuilder<ClusterHealthRequest, ClusterHealthResponse> {
|
||||
public class ClusterHealthRequestBuilder extends MasterNodeOperationRequestBuilder<ClusterHealthRequest, ClusterHealthResponse, ClusterHealthRequestBuilder> {
|
||||
|
||||
public ClusterHealthRequestBuilder(ClusterAdminClient clusterClient) {
|
||||
super(clusterClient, new ClusterHealthRequest());
|
||||
super((InternalClusterAdminClient) clusterClient, new ClusterHealthRequest());
|
||||
}
|
||||
|
||||
public ClusterHealthRequestBuilder setIndices(String... indices) {
|
||||
|
@ -38,14 +39,6 @@ public class ClusterHealthRequestBuilder extends BaseClusterRequestBuilder<Clust
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public ClusterHealthRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClusterHealthRequestBuilder setTimeout(TimeValue timeout) {
|
||||
request.timeout(timeout);
|
||||
return this;
|
||||
|
@ -91,6 +84,6 @@ public class ClusterHealthRequestBuilder extends BaseClusterRequestBuilder<Clust
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<ClusterHealthResponse> listener) {
|
||||
client.health(request, listener);
|
||||
((ClusterAdminClient) client).health(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class NodesHotThreadsRequest extends NodesOperationRequest {
|
||||
public class NodesHotThreadsRequest extends NodesOperationRequest<NodesHotThreadsRequest> {
|
||||
|
||||
int threads = 3;
|
||||
String type = "cpu";
|
||||
|
|
|
@ -20,21 +20,17 @@
|
|||
package org.elasticsearch.action.admin.cluster.node.hotthreads;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.cluster.support.BaseClusterRequestBuilder;
|
||||
import org.elasticsearch.action.support.nodes.NodesOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalClusterAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class NodesHotThreadsRequestBuilder extends BaseClusterRequestBuilder<NodesHotThreadsRequest, NodesHotThreadsResponse> {
|
||||
public class NodesHotThreadsRequestBuilder extends NodesOperationRequestBuilder<NodesHotThreadsRequest, NodesHotThreadsResponse, NodesHotThreadsRequestBuilder> {
|
||||
|
||||
public NodesHotThreadsRequestBuilder(ClusterAdminClient clusterClient) {
|
||||
super(clusterClient, new NodesHotThreadsRequest());
|
||||
}
|
||||
|
||||
public NodesHotThreadsRequestBuilder setNodesIds(String... nodesIds) {
|
||||
request.nodesIds(nodesIds);
|
||||
return this;
|
||||
super((InternalClusterAdminClient) clusterClient, new NodesHotThreadsRequest());
|
||||
}
|
||||
|
||||
public NodesHotThreadsRequestBuilder setThreads(int threads) {
|
||||
|
@ -54,6 +50,6 @@ public class NodesHotThreadsRequestBuilder extends BaseClusterRequestBuilder<Nod
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<NodesHotThreadsResponse> listener) {
|
||||
client.nodesHotThreads(request, listener);
|
||||
((ClusterAdminClient) client).nodesHotThreads(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ public class TransportNodesHotThreadsAction extends TransportNodesOperationActio
|
|||
}
|
||||
|
||||
NodeRequest(String nodeId, NodesHotThreadsRequest request) {
|
||||
super(nodeId);
|
||||
super(request, nodeId);
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* A request to get node (cluster) level information.
|
||||
*/
|
||||
public class NodesInfoRequest extends NodesOperationRequest {
|
||||
public class NodesInfoRequest extends NodesOperationRequest<NodesInfoRequest> {
|
||||
|
||||
private boolean settings = false;
|
||||
private boolean os = false;
|
||||
|
|
|
@ -20,21 +20,17 @@
|
|||
package org.elasticsearch.action.admin.cluster.node.info;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.cluster.support.BaseClusterRequestBuilder;
|
||||
import org.elasticsearch.action.support.nodes.NodesOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalClusterAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class NodesInfoRequestBuilder extends BaseClusterRequestBuilder<NodesInfoRequest, NodesInfoResponse> {
|
||||
public class NodesInfoRequestBuilder extends NodesOperationRequestBuilder<NodesInfoRequest, NodesInfoResponse, NodesInfoRequestBuilder> {
|
||||
|
||||
public NodesInfoRequestBuilder(ClusterAdminClient clusterClient) {
|
||||
super(clusterClient, new NodesInfoRequest());
|
||||
}
|
||||
|
||||
public NodesInfoRequestBuilder setNodesIds(String... nodesIds) {
|
||||
request.nodesIds(nodesIds);
|
||||
return this;
|
||||
super((InternalClusterAdminClient) clusterClient, new NodesInfoRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,6 +116,6 @@ public class NodesInfoRequestBuilder extends BaseClusterRequestBuilder<NodesInfo
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<NodesInfoResponse> listener) {
|
||||
client.nodesInfo(request, listener);
|
||||
((ClusterAdminClient) client).nodesInfo(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public class TransportNodesInfoAction extends TransportNodesOperationAction<Node
|
|||
}
|
||||
|
||||
NodeInfoRequest(String nodeId, NodesInfoRequest request) {
|
||||
super(nodeId);
|
||||
super(request, nodeId);
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,8 @@ import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
|||
|
||||
/**
|
||||
* A request to restart one ore more nodes (or the whole cluster).
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class NodesRestartRequest extends NodesOperationRequest {
|
||||
public class NodesRestartRequest extends NodesOperationRequest<NodesRestartRequest> {
|
||||
|
||||
TimeValue delay = TimeValue.timeValueSeconds(1);
|
||||
|
||||
|
|
|
@ -20,25 +20,18 @@
|
|||
package org.elasticsearch.action.admin.cluster.node.restart;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.cluster.support.BaseClusterRequestBuilder;
|
||||
import org.elasticsearch.action.support.nodes.NodesOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalClusterAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class NodesRestartRequestBuilder extends BaseClusterRequestBuilder<NodesRestartRequest, NodesRestartResponse> {
|
||||
public class NodesRestartRequestBuilder extends NodesOperationRequestBuilder<NodesRestartRequest, NodesRestartResponse, NodesRestartRequestBuilder> {
|
||||
|
||||
public NodesRestartRequestBuilder(ClusterAdminClient clusterClient) {
|
||||
super(clusterClient, new NodesRestartRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* The nodes ids to restart.
|
||||
*/
|
||||
public NodesRestartRequestBuilder setNodesIds(String... nodesIds) {
|
||||
request.nodesIds(nodesIds);
|
||||
return this;
|
||||
super((InternalClusterAdminClient) clusterClient, new NodesRestartRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,6 +52,6 @@ public class NodesRestartRequestBuilder extends BaseClusterRequestBuilder<NodesR
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<NodesRestartResponse> listener) {
|
||||
client.nodesRestart(request, listener);
|
||||
((ClusterAdminClient) client).nodesRestart(request, listener);
|
||||
}
|
||||
}
|
|
@ -102,7 +102,7 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction<N
|
|||
|
||||
@Override
|
||||
protected NodeRestartRequest newNodeRequest(String nodeId, NodesRestartRequest request) {
|
||||
return new NodeRestartRequest(nodeId, request.delay);
|
||||
return new NodeRestartRequest(nodeId, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -161,9 +161,9 @@ public class TransportNodesRestartAction extends TransportNodesOperationAction<N
|
|||
private NodeRestartRequest() {
|
||||
}
|
||||
|
||||
private NodeRestartRequest(String nodeId, TimeValue delay) {
|
||||
super(nodeId);
|
||||
this.delay = delay;
|
||||
private NodeRestartRequest(String nodeId, NodesRestartRequest request) {
|
||||
super(request, nodeId);
|
||||
this.delay = request.delay;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class NodesShutdownRequest extends MasterNodeOperationRequest {
|
||||
public class NodesShutdownRequest extends MasterNodeOperationRequest<NodesShutdownRequest> {
|
||||
|
||||
String[] nodesIds = Strings.EMPTY_ARRAY;
|
||||
|
||||
|
@ -96,13 +96,7 @@ public class NodesShutdownRequest extends MasterNodeOperationRequest {
|
|||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
delay = readTimeValue(in);
|
||||
int size = in.readVInt();
|
||||
if (size > 0) {
|
||||
nodesIds = new String[size];
|
||||
for (int i = 0; i < nodesIds.length; i++) {
|
||||
nodesIds[i] = in.readUTF();
|
||||
}
|
||||
}
|
||||
nodesIds = in.readStringArray();
|
||||
exit = in.readBoolean();
|
||||
}
|
||||
|
||||
|
@ -110,14 +104,7 @@ public class NodesShutdownRequest extends MasterNodeOperationRequest {
|
|||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
delay.writeTo(out);
|
||||
if (nodesIds == null) {
|
||||
out.writeVInt(0);
|
||||
} else {
|
||||
out.writeVInt(nodesIds.length);
|
||||
for (String nodeId : nodesIds) {
|
||||
out.writeUTF(nodeId);
|
||||
}
|
||||
}
|
||||
out.writeStringArrayNullable(nodesIds);
|
||||
out.writeBoolean(exit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,17 +20,18 @@
|
|||
package org.elasticsearch.action.admin.cluster.node.shutdown;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.cluster.support.BaseClusterRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalClusterAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class NodesShutdownRequestBuilder extends BaseClusterRequestBuilder<NodesShutdownRequest, NodesShutdownResponse> {
|
||||
public class NodesShutdownRequestBuilder extends MasterNodeOperationRequestBuilder<NodesShutdownRequest, NodesShutdownResponse, NodesShutdownRequestBuilder> {
|
||||
|
||||
public NodesShutdownRequestBuilder(ClusterAdminClient clusterClient) {
|
||||
super(clusterClient, new NodesShutdownRequest());
|
||||
super((InternalClusterAdminClient) clusterClient, new NodesShutdownRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,17 +66,8 @@ public class NodesShutdownRequestBuilder extends BaseClusterRequestBuilder<Nodes
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public NodesShutdownRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<NodesShutdownResponse> listener) {
|
||||
client.nodesShutdown(request, listener);
|
||||
((ClusterAdminClient) client).nodesShutdown(request, listener);
|
||||
}
|
||||
}
|
|
@ -30,7 +30,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.io.stream.VoidStreamable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
@ -129,7 +128,7 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
latch.countDown();
|
||||
} else {
|
||||
logger.trace("[cluster_shutdown]: sending shutdown request to [{}]", node);
|
||||
transportService.sendRequest(node, NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request.exit), new VoidTransportResponseHandler(ThreadPool.Names.SAME) {
|
||||
transportService.sendRequest(node, NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request), new VoidTransportResponseHandler(ThreadPool.Names.SAME) {
|
||||
@Override
|
||||
public void handleResponse(VoidStreamable response) {
|
||||
logger.trace("[cluster_shutdown]: received shutdown response from [{}]", node);
|
||||
|
@ -153,7 +152,7 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
|
||||
// now, kill the master
|
||||
logger.trace("[cluster_shutdown]: shutting down the master [{}]", state.nodes().masterNode());
|
||||
transportService.sendRequest(state.nodes().masterNode(), NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request.exit), new VoidTransportResponseHandler(ThreadPool.Names.SAME) {
|
||||
transportService.sendRequest(state.nodes().masterNode(), NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request), new VoidTransportResponseHandler(ThreadPool.Names.SAME) {
|
||||
@Override
|
||||
public void handleResponse(VoidStreamable response) {
|
||||
logger.trace("[cluster_shutdown]: received shutdown response from master");
|
||||
|
@ -197,7 +196,7 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
}
|
||||
|
||||
logger.trace("[partial_cluster_shutdown]: sending shutdown request to [{}]", node);
|
||||
transportService.sendRequest(node, NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request.exit), new VoidTransportResponseHandler(ThreadPool.Names.SAME) {
|
||||
transportService.sendRequest(node, NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request), new VoidTransportResponseHandler(ThreadPool.Names.SAME) {
|
||||
@Override
|
||||
public void handleResponse(VoidStreamable response) {
|
||||
logger.trace("[partial_cluster_shutdown]: received shutdown response from [{}]", node);
|
||||
|
@ -293,24 +292,27 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
|
|||
}
|
||||
}
|
||||
|
||||
static class NodeShutdownRequest implements Streamable {
|
||||
static class NodeShutdownRequest extends TransportRequest {
|
||||
|
||||
boolean exit;
|
||||
|
||||
NodeShutdownRequest() {
|
||||
}
|
||||
|
||||
NodeShutdownRequest(boolean exit) {
|
||||
this.exit = exit;
|
||||
NodeShutdownRequest(NodesShutdownRequest request) {
|
||||
super(request);
|
||||
this.exit = request.exit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
exit = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeBoolean(exit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* A request to get node (cluster) level stats.
|
||||
*/
|
||||
public class NodesStatsRequest extends NodesOperationRequest {
|
||||
public class NodesStatsRequest extends NodesOperationRequest<NodesStatsRequest> {
|
||||
|
||||
private boolean indices = true;
|
||||
private boolean os;
|
||||
|
|
|
@ -20,21 +20,17 @@
|
|||
package org.elasticsearch.action.admin.cluster.node.stats;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.cluster.support.BaseClusterRequestBuilder;
|
||||
import org.elasticsearch.action.support.nodes.NodesOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalClusterAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class NodesStatsRequestBuilder extends BaseClusterRequestBuilder<NodesStatsRequest, NodesStatsResponse> {
|
||||
public class NodesStatsRequestBuilder extends NodesOperationRequestBuilder<NodesStatsRequest, NodesStatsResponse, NodesStatsRequestBuilder> {
|
||||
|
||||
public NodesStatsRequestBuilder(ClusterAdminClient clusterClient) {
|
||||
super(clusterClient, new NodesStatsRequest());
|
||||
}
|
||||
|
||||
public NodesStatsRequestBuilder setNodesIds(String... nodesIds) {
|
||||
request.nodesIds(nodesIds);
|
||||
return this;
|
||||
super((InternalClusterAdminClient) clusterClient, new NodesStatsRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,6 +123,6 @@ public class NodesStatsRequestBuilder extends BaseClusterRequestBuilder<NodesSta
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<NodesStatsResponse> listener) {
|
||||
client.nodesStats(request, listener);
|
||||
((ClusterAdminClient) client).nodesStats(request, listener);
|
||||
}
|
||||
}
|
|
@ -113,7 +113,7 @@ public class TransportNodesStatsAction extends TransportNodesOperationAction<Nod
|
|||
}
|
||||
|
||||
NodeStatsRequest(String nodeId, NodesStatsRequest request) {
|
||||
super(nodeId);
|
||||
super(request, nodeId);
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.io.IOException;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class ClusterRerouteRequest extends MasterNodeOperationRequest {
|
||||
public class ClusterRerouteRequest extends MasterNodeOperationRequest<ClusterRerouteRequest> {
|
||||
|
||||
AllocationCommands commands = new AllocationCommands();
|
||||
boolean dryRun;
|
||||
|
|
|
@ -20,18 +20,18 @@
|
|||
package org.elasticsearch.action.admin.cluster.reroute;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.cluster.support.BaseClusterRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalClusterAdminClient;
|
||||
import org.elasticsearch.cluster.routing.allocation.command.AllocationCommand;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ClusterRerouteRequestBuilder extends BaseClusterRequestBuilder<ClusterRerouteRequest, ClusterRerouteResponse> {
|
||||
public class ClusterRerouteRequestBuilder extends MasterNodeOperationRequestBuilder<ClusterRerouteRequest, ClusterRerouteResponse, ClusterRerouteRequestBuilder> {
|
||||
|
||||
public ClusterRerouteRequestBuilder(ClusterAdminClient clusterClient) {
|
||||
super(clusterClient, new ClusterRerouteRequest());
|
||||
super((InternalClusterAdminClient) clusterClient, new ClusterRerouteRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,24 +57,8 @@ public class ClusterRerouteRequestBuilder extends BaseClusterRequestBuilder<Clus
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public ClusterRerouteRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public ClusterRerouteRequestBuilder setMasterNodeTimeout(String timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<ClusterRerouteResponse> listener) {
|
||||
client.reroute(request, listener);
|
||||
((ClusterAdminClient) client).reroute(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import static org.elasticsearch.common.settings.ImmutableSettings.writeSettingsT
|
|||
|
||||
/**
|
||||
*/
|
||||
public class ClusterUpdateSettingsRequest extends MasterNodeOperationRequest {
|
||||
public class ClusterUpdateSettingsRequest extends MasterNodeOperationRequest<ClusterUpdateSettingsRequest> {
|
||||
|
||||
private Settings transientSettings = EMPTY_SETTINGS;
|
||||
private Settings persistentSettings = EMPTY_SETTINGS;
|
||||
|
|
|
@ -20,19 +20,19 @@
|
|||
package org.elasticsearch.action.admin.cluster.settings;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.cluster.support.BaseClusterRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalClusterAdminClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ClusterUpdateSettingsRequestBuilder extends BaseClusterRequestBuilder<ClusterUpdateSettingsRequest, ClusterUpdateSettingsResponse> {
|
||||
public class ClusterUpdateSettingsRequestBuilder extends MasterNodeOperationRequestBuilder<ClusterUpdateSettingsRequest, ClusterUpdateSettingsResponse, ClusterUpdateSettingsRequestBuilder> {
|
||||
|
||||
public ClusterUpdateSettingsRequestBuilder(ClusterAdminClient clusterClient) {
|
||||
super(clusterClient, new ClusterUpdateSettingsRequest());
|
||||
super((InternalClusterAdminClient) clusterClient, new ClusterUpdateSettingsRequest());
|
||||
}
|
||||
|
||||
public ClusterUpdateSettingsRequestBuilder setTransientSettings(Settings settings) {
|
||||
|
@ -75,24 +75,8 @@ public class ClusterUpdateSettingsRequestBuilder extends BaseClusterRequestBuild
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public ClusterUpdateSettingsRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public ClusterUpdateSettingsRequestBuilder setMasterNodeTimeout(String timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<ClusterUpdateSettingsResponse> listener) {
|
||||
client.updateSettings(request, listener);
|
||||
((ClusterAdminClient) client).updateSettings(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.io.IOException;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class ClusterStateRequest extends MasterNodeOperationRequest {
|
||||
public class ClusterStateRequest extends MasterNodeOperationRequest<ClusterStateRequest> {
|
||||
|
||||
private boolean filterRoutingTable = false;
|
||||
|
||||
|
@ -127,12 +127,6 @@ public class ClusterStateRequest extends MasterNodeOperationRequest {
|
|||
return this.local;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClusterStateRequest listenerThreaded(boolean listenerThreaded) {
|
||||
super.listenerThreaded(listenerThreaded);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
|
@ -140,20 +134,8 @@ public class ClusterStateRequest extends MasterNodeOperationRequest {
|
|||
filterNodes = in.readBoolean();
|
||||
filterMetaData = in.readBoolean();
|
||||
filterBlocks = in.readBoolean();
|
||||
int size = in.readVInt();
|
||||
if (size > 0) {
|
||||
filteredIndices = new String[size];
|
||||
for (int i = 0; i < filteredIndices.length; i++) {
|
||||
filteredIndices[i] = in.readUTF();
|
||||
}
|
||||
}
|
||||
size = in.readVInt();
|
||||
if (size > 0) {
|
||||
filteredIndexTemplates = new String[size];
|
||||
for (int i = 0; i < filteredIndexTemplates.length; i++) {
|
||||
filteredIndexTemplates[i] = in.readUTF();
|
||||
}
|
||||
}
|
||||
filteredIndices = in.readStringArray();
|
||||
filteredIndexTemplates = in.readStringArray();
|
||||
local = in.readBoolean();
|
||||
}
|
||||
|
||||
|
@ -164,14 +146,8 @@ public class ClusterStateRequest extends MasterNodeOperationRequest {
|
|||
out.writeBoolean(filterNodes);
|
||||
out.writeBoolean(filterMetaData);
|
||||
out.writeBoolean(filterBlocks);
|
||||
out.writeVInt(filteredIndices.length);
|
||||
for (String filteredIndex : filteredIndices) {
|
||||
out.writeUTF(filteredIndex);
|
||||
}
|
||||
out.writeVInt(filteredIndexTemplates.length);
|
||||
for (String filteredIndexTemplate : filteredIndexTemplates) {
|
||||
out.writeUTF(filteredIndexTemplate);
|
||||
}
|
||||
out.writeStringArray(filteredIndices);
|
||||
out.writeStringArray(filteredIndexTemplates);
|
||||
out.writeBoolean(local);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,17 +20,17 @@
|
|||
package org.elasticsearch.action.admin.cluster.state;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.cluster.support.BaseClusterRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.client.internal.InternalClusterAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ClusterStateRequestBuilder extends BaseClusterRequestBuilder<ClusterStateRequest, ClusterStateResponse> {
|
||||
public class ClusterStateRequestBuilder extends MasterNodeOperationRequestBuilder<ClusterStateRequest, ClusterStateResponse, ClusterStateRequestBuilder> {
|
||||
|
||||
public ClusterStateRequestBuilder(ClusterAdminClient clusterClient) {
|
||||
super(clusterClient, new ClusterStateRequest());
|
||||
super((InternalClusterAdminClient) clusterClient, new ClusterStateRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,22 +87,6 @@ public class ClusterStateRequestBuilder extends BaseClusterRequestBuilder<Cluste
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public ClusterStateRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public ClusterStateRequestBuilder setMasterNodeTimeout(String timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the cluster state request should be executed locally on the node, and not go to the master.
|
||||
*/
|
||||
|
@ -113,6 +97,6 @@ public class ClusterStateRequestBuilder extends BaseClusterRequestBuilder<Cluste
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<ClusterStateResponse> listener) {
|
||||
client.state(request, listener);
|
||||
((ClusterAdminClient) client).state(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.cluster.support;
|
||||
|
||||
import org.elasticsearch.action.*;
|
||||
import org.elasticsearch.action.support.PlainListenableActionFuture;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalClusterAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class BaseClusterRequestBuilder<Request extends ActionRequest, Response extends ActionResponse> implements ActionRequestBuilder<Request, Response> {
|
||||
|
||||
protected final InternalClusterAdminClient client;
|
||||
|
||||
protected final Request request;
|
||||
|
||||
protected BaseClusterRequestBuilder(ClusterAdminClient client, Request request) {
|
||||
this.client = (InternalClusterAdminClient) client;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Request request() {
|
||||
return request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableActionFuture<Response> execute() {
|
||||
PlainListenableActionFuture<Response> future = new PlainListenableActionFuture<Response>(request.listenerThreaded(), client.threadPool());
|
||||
execute(future);
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ActionListener<Response> listener) {
|
||||
doExecute(listener);
|
||||
}
|
||||
|
||||
protected abstract void doExecute(ActionListener<Response> listener);
|
||||
}
|
|
@ -28,7 +28,7 @@ import org.elasticsearch.client.IndicesAdminClient;
|
|||
/**
|
||||
* Indices action (used with {@link IndicesAdminClient} API.
|
||||
*/
|
||||
public abstract class IndicesAction<Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response>>
|
||||
public abstract class IndicesAction<Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>>
|
||||
extends GenericAction<Request, Response> {
|
||||
|
||||
protected IndicesAction(String name) {
|
||||
|
|
|
@ -44,7 +44,7 @@ import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
|||
/**
|
||||
* A request to add/remove aliases for one or more indices.
|
||||
*/
|
||||
public class IndicesAliasesRequest extends MasterNodeOperationRequest {
|
||||
public class IndicesAliasesRequest extends MasterNodeOperationRequest<IndicesAliasesRequest> {
|
||||
|
||||
private List<AliasAction> aliasActions = Lists.newArrayList();
|
||||
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
package org.elasticsearch.action.admin.indices.alias;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.cluster.metadata.AliasAction;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.query.FilterBuilder;
|
||||
|
@ -31,10 +32,10 @@ import java.util.Map;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class IndicesAliasesRequestBuilder extends BaseIndicesRequestBuilder<IndicesAliasesRequest, IndicesAliasesResponse> {
|
||||
public class IndicesAliasesRequestBuilder extends MasterNodeOperationRequestBuilder<IndicesAliasesRequest, IndicesAliasesResponse, IndicesAliasesRequestBuilder> {
|
||||
|
||||
public IndicesAliasesRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new IndicesAliasesRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new IndicesAliasesRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,14 +106,6 @@ public class IndicesAliasesRequestBuilder extends BaseIndicesRequestBuilder<Indi
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public IndicesAliasesRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets operation timeout.
|
||||
*
|
||||
|
@ -125,6 +118,6 @@ public class IndicesAliasesRequestBuilder extends BaseIndicesRequestBuilder<Indi
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<IndicesAliasesResponse> listener) {
|
||||
client.aliases(request, listener);
|
||||
((IndicesAdminClient) client).aliases(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|||
* A request to analyze a text associated with a specific index. Allow to provide
|
||||
* the actual analyzer name to perform the analysis with.
|
||||
*/
|
||||
public class AnalyzeRequest extends SingleCustomOperationRequest {
|
||||
public class AnalyzeRequest extends SingleCustomOperationRequest<AnalyzeRequest> {
|
||||
|
||||
private String index;
|
||||
|
||||
|
@ -120,16 +120,6 @@ public class AnalyzeRequest extends SingleCustomOperationRequest {
|
|||
return this.field;
|
||||
}
|
||||
|
||||
/**
|
||||
* if this operation hits a node with a local relevant shard, should it be preferred
|
||||
* to be executed on, or just do plain round robin. Defaults to <tt>true</tt>
|
||||
*/
|
||||
@Override
|
||||
public AnalyzeRequest preferLocal(boolean preferLocal) {
|
||||
super.preferLocal(preferLocal);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = super.validate();
|
||||
|
@ -142,35 +132,35 @@ public class AnalyzeRequest extends SingleCustomOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
index = in.readOptionalUTF();
|
||||
text = in.readUTF();
|
||||
analyzer = in.readOptionalUTF();
|
||||
tokenizer = in.readOptionalUTF();
|
||||
index = in.readOptionalString();
|
||||
text = in.readString();
|
||||
analyzer = in.readOptionalString();
|
||||
tokenizer = in.readOptionalString();
|
||||
int size = in.readVInt();
|
||||
if (size > 0) {
|
||||
tokenFilters = new String[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
tokenFilters[i] = in.readUTF();
|
||||
tokenFilters[i] = in.readString();
|
||||
}
|
||||
}
|
||||
field = in.readOptionalUTF();
|
||||
field = in.readOptionalString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeOptionalUTF(index);
|
||||
out.writeUTF(text);
|
||||
out.writeOptionalUTF(analyzer);
|
||||
out.writeOptionalUTF(tokenizer);
|
||||
out.writeOptionalString(index);
|
||||
out.writeString(text);
|
||||
out.writeOptionalString(analyzer);
|
||||
out.writeOptionalString(tokenizer);
|
||||
if (tokenFilters == null) {
|
||||
out.writeVInt(0);
|
||||
} else {
|
||||
out.writeVInt(tokenFilters.length);
|
||||
for (String tokenFilter : tokenFilters) {
|
||||
out.writeUTF(tokenFilter);
|
||||
out.writeString(tokenFilter);
|
||||
}
|
||||
}
|
||||
out.writeOptionalUTF(field);
|
||||
out.writeOptionalString(field);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,20 +20,21 @@
|
|||
package org.elasticsearch.action.admin.indices.analyze;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.single.custom.SingleCustomOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AnalyzeRequestBuilder extends BaseIndicesRequestBuilder<AnalyzeRequest, AnalyzeResponse> {
|
||||
public class AnalyzeRequestBuilder extends SingleCustomOperationRequestBuilder<AnalyzeRequest, AnalyzeResponse, AnalyzeRequestBuilder> {
|
||||
|
||||
public AnalyzeRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new AnalyzeRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new AnalyzeRequest());
|
||||
}
|
||||
|
||||
public AnalyzeRequestBuilder(IndicesAdminClient indicesClient, String index, String text) {
|
||||
super(indicesClient, new AnalyzeRequest(index, text));
|
||||
super((InternalIndicesAdminClient) indicesClient, new AnalyzeRequest(index, text));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,17 +82,8 @@ public class AnalyzeRequestBuilder extends BaseIndicesRequestBuilder<AnalyzeRequ
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* if this operation hits a node with a local relevant shard, should it be preferred
|
||||
* to be executed on, or just do plain round robin. Defaults to <tt>true</tt>
|
||||
*/
|
||||
public AnalyzeRequestBuilder setPreferLocal(boolean preferLocal) {
|
||||
request.preferLocal(preferLocal);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<AnalyzeResponse> listener) {
|
||||
client.analyze(request, listener);
|
||||
((IndicesAdminClient) client).analyze(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.io.IOException;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class ClearIndicesCacheRequest extends BroadcastOperationRequest {
|
||||
public class ClearIndicesCacheRequest extends BroadcastOperationRequest<ClearIndicesCacheRequest> {
|
||||
|
||||
private boolean filterCache = false;
|
||||
private boolean fieldDataCache = false;
|
||||
|
@ -46,24 +46,6 @@ public class ClearIndicesCacheRequest extends BroadcastOperationRequest {
|
|||
operationThreading(BroadcastOperationThreading.THREAD_PER_SHARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override
|
||||
public ClearIndicesCacheRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
@Override
|
||||
public ClearIndicesCacheRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
super.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean filterCache() {
|
||||
return filterCache;
|
||||
}
|
||||
|
|
|
@ -20,23 +20,17 @@
|
|||
package org.elasticsearch.action.admin.indices.cache.clear;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ClearIndicesCacheRequestBuilder extends BaseIndicesRequestBuilder<ClearIndicesCacheRequest, ClearIndicesCacheResponse> {
|
||||
public class ClearIndicesCacheRequestBuilder extends BroadcastOperationRequestBuilder<ClearIndicesCacheRequest, ClearIndicesCacheResponse, ClearIndicesCacheRequestBuilder> {
|
||||
|
||||
public ClearIndicesCacheRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new ClearIndicesCacheRequest());
|
||||
}
|
||||
|
||||
public ClearIndicesCacheRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
super((InternalIndicesAdminClient) indicesClient, new ClearIndicesCacheRequest());
|
||||
}
|
||||
|
||||
public ClearIndicesCacheRequestBuilder setFilterCache(boolean filterCache) {
|
||||
|
@ -64,32 +58,8 @@ public class ClearIndicesCacheRequestBuilder extends BaseIndicesRequestBuilder<C
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
public ClearIndicesCacheRequestBuilder setListenerThreaded(boolean threadedListener) {
|
||||
request.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
public ClearIndicesCacheRequestBuilder setOperationThreading(BroadcastOperationThreading operationThreading) {
|
||||
request.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore. For example indices that don't exist.
|
||||
*/
|
||||
public ClearIndicesCacheRequestBuilder setIgnoreIndices(IgnoreIndices ignoreIndices) {
|
||||
request().ignoreIndices(ignoreIndices);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<ClearIndicesCacheResponse> listener) {
|
||||
client.clearCache(request, listener);
|
||||
((IndicesAdminClient) client).clearCache(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class ShardClearIndicesCacheRequest extends BroadcastShardOperationRequest {
|
|||
}
|
||||
|
||||
public ShardClearIndicesCacheRequest(String index, int shardId, ClearIndicesCacheRequest request) {
|
||||
super(index, shardId);
|
||||
super(index, shardId, request);
|
||||
filterCache = request.filterCache();
|
||||
fieldDataCache = request.fieldDataCache();
|
||||
idCache = request.idCache();
|
||||
|
|
|
@ -34,7 +34,7 @@ import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
|||
/**
|
||||
* A request to close an index.
|
||||
*/
|
||||
public class CloseIndexRequest extends MasterNodeOperationRequest {
|
||||
public class CloseIndexRequest extends MasterNodeOperationRequest<CloseIndexRequest> {
|
||||
|
||||
private String index;
|
||||
|
||||
|
@ -99,14 +99,14 @@ public class CloseIndexRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
index = in.readUTF();
|
||||
index = in.readString();
|
||||
timeout = readTimeValue(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeUTF(index);
|
||||
out.writeString(index);
|
||||
timeout.writeTo(out);
|
||||
}
|
||||
}
|
|
@ -20,21 +20,22 @@
|
|||
package org.elasticsearch.action.admin.indices.close;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class CloseIndexRequestBuilder extends BaseIndicesRequestBuilder<CloseIndexRequest, CloseIndexResponse> {
|
||||
public class CloseIndexRequestBuilder extends MasterNodeOperationRequestBuilder<CloseIndexRequest, CloseIndexResponse, CloseIndexRequestBuilder> {
|
||||
|
||||
public CloseIndexRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new CloseIndexRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new CloseIndexRequest());
|
||||
}
|
||||
|
||||
public CloseIndexRequestBuilder(IndicesAdminClient indicesClient, String index) {
|
||||
super(indicesClient, new CloseIndexRequest(index));
|
||||
super((InternalIndicesAdminClient) indicesClient, new CloseIndexRequest(index));
|
||||
}
|
||||
|
||||
public CloseIndexRequestBuilder setIndex(String index) {
|
||||
|
@ -60,24 +61,8 @@ public class CloseIndexRequestBuilder extends BaseIndicesRequestBuilder<CloseInd
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public CloseIndexRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public CloseIndexRequestBuilder setMasterNodeTimeout(String timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<CloseIndexResponse> listener) {
|
||||
client.close(request, listener);
|
||||
((IndicesAdminClient) client).close(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
|||
* @see org.elasticsearch.client.Requests#createIndexRequest(String)
|
||||
* @see CreateIndexResponse
|
||||
*/
|
||||
public class CreateIndexRequest extends MasterNodeOperationRequest {
|
||||
public class CreateIndexRequest extends MasterNodeOperationRequest<CreateIndexRequest> {
|
||||
|
||||
private String cause = "";
|
||||
|
||||
|
@ -345,29 +345,20 @@ public class CreateIndexRequest extends MasterNodeOperationRequest {
|
|||
return timeout(TimeValue.parseTimeValue(timeout, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* A timeout value in case the master has not been discovered yet or disconnected.
|
||||
*/
|
||||
@Override
|
||||
public CreateIndexRequest masterNodeTimeout(TimeValue timeout) {
|
||||
this.masterNodeTimeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
cause = in.readUTF();
|
||||
index = in.readUTF();
|
||||
cause = in.readString();
|
||||
index = in.readString();
|
||||
settings = readSettingsFromStream(in);
|
||||
timeout = readTimeValue(in);
|
||||
int size = in.readVInt();
|
||||
for (int i = 0; i < size; i++) {
|
||||
mappings.put(in.readUTF(), in.readUTF());
|
||||
mappings.put(in.readString(), in.readString());
|
||||
}
|
||||
int customSize = in.readVInt();
|
||||
for (int i = 0; i < customSize; i++) {
|
||||
String type = in.readUTF();
|
||||
String type = in.readString();
|
||||
IndexMetaData.Custom customIndexMetaData = IndexMetaData.lookupFactorySafe(type).readFrom(in);
|
||||
customs.put(type, customIndexMetaData);
|
||||
}
|
||||
|
@ -376,18 +367,18 @@ public class CreateIndexRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeUTF(cause);
|
||||
out.writeUTF(index);
|
||||
out.writeString(cause);
|
||||
out.writeString(index);
|
||||
writeSettingsToStream(settings, out);
|
||||
timeout.writeTo(out);
|
||||
out.writeVInt(mappings.size());
|
||||
for (Map.Entry<String, String> entry : mappings.entrySet()) {
|
||||
out.writeUTF(entry.getKey());
|
||||
out.writeUTF(entry.getValue());
|
||||
out.writeString(entry.getKey());
|
||||
out.writeString(entry.getValue());
|
||||
}
|
||||
out.writeVInt(customs.size());
|
||||
for (Map.Entry<String, IndexMetaData.Custom> entry : customs.entrySet()) {
|
||||
out.writeUTF(entry.getKey());
|
||||
out.writeString(entry.getKey());
|
||||
IndexMetaData.lookupFactorySafe(entry.getKey()).writeTo(entry.getValue(), out);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
package org.elasticsearch.action.admin.indices.create;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -33,14 +34,14 @@ import java.util.Map;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class CreateIndexRequestBuilder extends BaseIndicesRequestBuilder<CreateIndexRequest, CreateIndexResponse> {
|
||||
public class CreateIndexRequestBuilder extends MasterNodeOperationRequestBuilder<CreateIndexRequest, CreateIndexResponse, CreateIndexRequestBuilder> {
|
||||
|
||||
public CreateIndexRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new CreateIndexRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new CreateIndexRequest());
|
||||
}
|
||||
|
||||
public CreateIndexRequestBuilder(IndicesAdminClient indicesClient, String index) {
|
||||
super(indicesClient, new CreateIndexRequest(index));
|
||||
super((InternalIndicesAdminClient) indicesClient, new CreateIndexRequest(index));
|
||||
}
|
||||
|
||||
public CreateIndexRequestBuilder setIndex(String index) {
|
||||
|
@ -200,24 +201,8 @@ public class CreateIndexRequestBuilder extends BaseIndicesRequestBuilder<CreateI
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public CreateIndexRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public CreateIndexRequestBuilder setMasterNodeTimeout(String timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<CreateIndexResponse> listener) {
|
||||
client.create(request, listener);
|
||||
((IndicesAdminClient) client).create(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
|||
/**
|
||||
* A request to delete an index. Best created with {@link org.elasticsearch.client.Requests#deleteIndexRequest(String)}.
|
||||
*/
|
||||
public class DeleteIndexRequest extends MasterNodeOperationRequest {
|
||||
public class DeleteIndexRequest extends MasterNodeOperationRequest<DeleteIndexRequest> {
|
||||
|
||||
private String[] indices;
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class DeleteIndexRequest extends MasterNodeOperationRequest {
|
|||
super.readFrom(in);
|
||||
indices = new String[in.readVInt()];
|
||||
for (int i = 0; i < indices.length; i++) {
|
||||
indices[i] = in.readUTF();
|
||||
indices[i] = in.readString();
|
||||
}
|
||||
timeout = readTimeValue(in);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ public class DeleteIndexRequest extends MasterNodeOperationRequest {
|
|||
} else {
|
||||
out.writeVInt(indices.length);
|
||||
for (String index : indices) {
|
||||
out.writeUTF(index);
|
||||
out.writeString(index);
|
||||
}
|
||||
}
|
||||
timeout.writeTo(out);
|
||||
|
|
|
@ -20,17 +20,18 @@
|
|||
package org.elasticsearch.action.admin.indices.delete;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DeleteIndexRequestBuilder extends BaseIndicesRequestBuilder<DeleteIndexRequest, DeleteIndexResponse> {
|
||||
public class DeleteIndexRequestBuilder extends MasterNodeOperationRequestBuilder<DeleteIndexRequest, DeleteIndexResponse, DeleteIndexRequestBuilder> {
|
||||
|
||||
public DeleteIndexRequestBuilder(IndicesAdminClient indicesClient, String... indices) {
|
||||
super(indicesClient, new DeleteIndexRequest(indices));
|
||||
super((InternalIndicesAdminClient) indicesClient, new DeleteIndexRequest(indices));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,24 +52,8 @@ public class DeleteIndexRequestBuilder extends BaseIndicesRequestBuilder<DeleteI
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public DeleteIndexRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public DeleteIndexRequestBuilder setMasterNodeTimeout(String timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<DeleteIndexResponse> listener) {
|
||||
client.delete(request, listener);
|
||||
((IndicesAdminClient) client).delete(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.action.admin.indices.exists.indices;
|
|||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequest;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
||||
|
@ -28,9 +29,9 @@ import java.io.IOException;
|
|||
|
||||
import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||
|
||||
public class IndicesExistsRequest extends MasterNodeOperationRequest {
|
||||
public class IndicesExistsRequest extends MasterNodeOperationRequest<IndicesExistsRequest> {
|
||||
|
||||
private String[] indices;
|
||||
private String[] indices = Strings.EMPTY_ARRAY;
|
||||
|
||||
public IndicesExistsRequest(String... indices) {
|
||||
this.indices = indices;
|
||||
|
@ -56,18 +57,12 @@ public class IndicesExistsRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
indices = new String[in.readVInt()];
|
||||
for (int i = 0; i < indices.length; i++) {
|
||||
indices[i] = in.readUTF();
|
||||
}
|
||||
indices = in.readStringArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeVInt(indices.length);
|
||||
for (String index : indices) {
|
||||
out.writeUTF(index);
|
||||
}
|
||||
out.writeStringArray(indices);
|
||||
}
|
||||
}
|
|
@ -20,16 +20,17 @@
|
|||
package org.elasticsearch.action.admin.indices.exists.indices;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class IndicesExistsRequestBuilder extends BaseIndicesRequestBuilder<IndicesExistsRequest, IndicesExistsResponse> {
|
||||
public class IndicesExistsRequestBuilder extends MasterNodeOperationRequestBuilder<IndicesExistsRequest, IndicesExistsResponse, IndicesExistsRequestBuilder> {
|
||||
|
||||
public IndicesExistsRequestBuilder(IndicesAdminClient indicesClient, String... indices) {
|
||||
super(indicesClient, new IndicesExistsRequest(indices));
|
||||
super((InternalIndicesAdminClient) indicesClient, new IndicesExistsRequest(indices));
|
||||
}
|
||||
|
||||
public IndicesExistsRequestBuilder setIndices(String... indices) {
|
||||
|
@ -39,6 +40,6 @@ public class IndicesExistsRequestBuilder extends BaseIndicesRequestBuilder<Indic
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<IndicesExistsResponse> listener) {
|
||||
client.exists(request, listener);
|
||||
((IndicesAdminClient) client).exists(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class TypesExistsRequest extends MasterNodeOperationRequest {
|
||||
public class TypesExistsRequest extends MasterNodeOperationRequest<TypesExistsRequest> {
|
||||
|
||||
private String[] indices;
|
||||
private String[] types;
|
||||
|
|
|
@ -20,25 +20,26 @@
|
|||
package org.elasticsearch.action.admin.indices.exists.types;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
||||
/**
|
||||
* A builder for {@link TypesExistsRequest}.
|
||||
*/
|
||||
public class TypesExistsRequestBuilder extends BaseIndicesRequestBuilder<TypesExistsRequest, TypesExistsResponse> {
|
||||
public class TypesExistsRequestBuilder extends MasterNodeOperationRequestBuilder<TypesExistsRequest, TypesExistsResponse, TypesExistsRequestBuilder> {
|
||||
|
||||
/**
|
||||
* @param indices What indices to check for types
|
||||
*/
|
||||
public TypesExistsRequestBuilder(IndicesAdminClient indicesClient, String... indices) {
|
||||
super(indicesClient, new TypesExistsRequest(indices, Strings.EMPTY_ARRAY));
|
||||
super((InternalIndicesAdminClient) indicesClient, new TypesExistsRequest(indices, Strings.EMPTY_ARRAY));
|
||||
}
|
||||
|
||||
TypesExistsRequestBuilder(IndicesAdminClient client) {
|
||||
super(client, new TypesExistsRequest());
|
||||
super((InternalIndicesAdminClient) client, new TypesExistsRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,6 +67,6 @@ public class TypesExistsRequestBuilder extends BaseIndicesRequestBuilder<TypesEx
|
|||
}
|
||||
|
||||
protected void doExecute(ActionListener<TypesExistsResponse> listener) {
|
||||
client.typesExists(request, listener);
|
||||
((IndicesAdminClient) client).typesExists(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,12 +33,11 @@ import java.io.IOException;
|
|||
* <p/>
|
||||
* <p>Best created with {@link org.elasticsearch.client.Requests#flushRequest(String...)}.
|
||||
*
|
||||
*
|
||||
* @see org.elasticsearch.client.Requests#flushRequest(String...)
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#flush(FlushRequest)
|
||||
* @see FlushResponse
|
||||
*/
|
||||
public class FlushRequest extends BroadcastOperationRequest {
|
||||
public class FlushRequest extends BroadcastOperationRequest<FlushRequest> {
|
||||
|
||||
private boolean refresh = false;
|
||||
|
||||
|
@ -105,24 +104,6 @@ public class FlushRequest extends BroadcastOperationRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override
|
||||
public FlushRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
@Override
|
||||
public FlushRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
super.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
|
|
|
@ -20,22 +20,17 @@
|
|||
package org.elasticsearch.action.admin.indices.flush;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class FlushRequestBuilder extends BaseIndicesRequestBuilder<FlushRequest, FlushResponse> {
|
||||
public class FlushRequestBuilder extends BroadcastOperationRequestBuilder<FlushRequest, FlushResponse, FlushRequestBuilder> {
|
||||
|
||||
public FlushRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new FlushRequest());
|
||||
}
|
||||
|
||||
public FlushRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
super((InternalIndicesAdminClient) indicesClient, new FlushRequest());
|
||||
}
|
||||
|
||||
public FlushRequestBuilder setRefresh(boolean refresh) {
|
||||
|
@ -48,16 +43,8 @@ public class FlushRequestBuilder extends BaseIndicesRequestBuilder<FlushRequest,
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore. For example indices that don't exist.
|
||||
*/
|
||||
public FlushRequestBuilder setIgnoreIndices(IgnoreIndices ignoreIndices) {
|
||||
request().ignoreIndices(ignoreIndices);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<FlushResponse> listener) {
|
||||
client.flush(request, listener);
|
||||
((IndicesAdminClient) client).flush(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class ShardFlushRequest extends BroadcastShardOperationRequest {
|
|||
}
|
||||
|
||||
public ShardFlushRequest(String index, int shardId, FlushRequest request) {
|
||||
super(index, shardId);
|
||||
super(index, shardId, request);
|
||||
this.refresh = request.refresh();
|
||||
this.full = request.full();
|
||||
this.force = request.force();
|
||||
|
|
|
@ -26,12 +26,11 @@ import org.elasticsearch.action.support.broadcast.BroadcastOperationRequest;
|
|||
* By default, each index gateway periodically snapshot changes, though it can be disabled and be controlled completely
|
||||
* through this API. Best created using {@link org.elasticsearch.client.Requests#gatewaySnapshotRequest(String...)}.
|
||||
*
|
||||
*
|
||||
* @see org.elasticsearch.client.Requests#gatewaySnapshotRequest(String...)
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#gatewaySnapshot(GatewaySnapshotRequest)
|
||||
* @see GatewaySnapshotResponse
|
||||
*/
|
||||
public class GatewaySnapshotRequest extends BroadcastOperationRequest {
|
||||
public class GatewaySnapshotRequest extends BroadcastOperationRequest<GatewaySnapshotRequest> {
|
||||
|
||||
GatewaySnapshotRequest() {
|
||||
|
||||
|
@ -44,13 +43,4 @@ public class GatewaySnapshotRequest extends BroadcastOperationRequest {
|
|||
public GatewaySnapshotRequest(String... indices) {
|
||||
this.indices = indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override
|
||||
public GatewaySnapshotRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -20,34 +20,21 @@
|
|||
package org.elasticsearch.action.admin.indices.gateway.snapshot;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class GatewaySnapshotRequestBuilder extends BaseIndicesRequestBuilder<GatewaySnapshotRequest, GatewaySnapshotResponse> {
|
||||
public class GatewaySnapshotRequestBuilder extends BroadcastOperationRequestBuilder<GatewaySnapshotRequest, GatewaySnapshotResponse, GatewaySnapshotRequestBuilder> {
|
||||
|
||||
public GatewaySnapshotRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new GatewaySnapshotRequest());
|
||||
}
|
||||
|
||||
public GatewaySnapshotRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore. For example indices that don't exist.
|
||||
*/
|
||||
public GatewaySnapshotRequestBuilder setIgnoreIndices(IgnoreIndices ignoreIndices) {
|
||||
request().ignoreIndices(ignoreIndices);
|
||||
return this;
|
||||
super((InternalIndicesAdminClient) indicesClient, new GatewaySnapshotRequest());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<GatewaySnapshotResponse> listener) {
|
||||
client.gatewaySnapshot(request, listener);
|
||||
((IndicesAdminClient) client).gatewaySnapshot(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ class ShardGatewaySnapshotRequest extends BroadcastShardOperationRequest {
|
|||
ShardGatewaySnapshotRequest() {
|
||||
}
|
||||
|
||||
public ShardGatewaySnapshotRequest(String index, int shardId) {
|
||||
super(index, shardId);
|
||||
public ShardGatewaySnapshotRequest(String index, int shardId, GatewaySnapshotRequest request) {
|
||||
super(index, shardId, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -104,7 +104,7 @@ public class TransportGatewaySnapshotAction extends TransportBroadcastOperationA
|
|||
|
||||
@Override
|
||||
protected ShardGatewaySnapshotRequest newShardRequest(ShardRouting shard, GatewaySnapshotRequest request) {
|
||||
return new ShardGatewaySnapshotRequest(shard.index(), shard.id());
|
||||
return new ShardGatewaySnapshotRequest(shard.index(), shard.id(), request);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class DeleteMappingRequest extends MasterNodeOperationRequest {
|
||||
public class DeleteMappingRequest extends MasterNodeOperationRequest<DeleteMappingRequest> {
|
||||
|
||||
private String[] indices;
|
||||
|
||||
|
@ -92,10 +92,10 @@ public class DeleteMappingRequest extends MasterNodeOperationRequest {
|
|||
super.readFrom(in);
|
||||
indices = new String[in.readVInt()];
|
||||
for (int i = 0; i < indices.length; i++) {
|
||||
indices[i] = in.readUTF();
|
||||
indices[i] = in.readString();
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
mappingType = in.readUTF();
|
||||
mappingType = in.readString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,14 +107,14 @@ public class DeleteMappingRequest extends MasterNodeOperationRequest {
|
|||
} else {
|
||||
out.writeVInt(indices.length);
|
||||
for (String index : indices) {
|
||||
out.writeUTF(index);
|
||||
out.writeString(index);
|
||||
}
|
||||
}
|
||||
if (mappingType == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
out.writeUTF(mappingType);
|
||||
out.writeString(mappingType);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,17 +20,17 @@
|
|||
package org.elasticsearch.action.admin.indices.mapping.delete;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DeleteMappingRequestBuilder extends BaseIndicesRequestBuilder<DeleteMappingRequest, DeleteMappingResponse> {
|
||||
public class DeleteMappingRequestBuilder extends MasterNodeOperationRequestBuilder<DeleteMappingRequest, DeleteMappingResponse, DeleteMappingRequestBuilder> {
|
||||
|
||||
public DeleteMappingRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new DeleteMappingRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new DeleteMappingRequest());
|
||||
}
|
||||
|
||||
public DeleteMappingRequestBuilder setIndices(String... indices) {
|
||||
|
@ -46,16 +46,8 @@ public class DeleteMappingRequestBuilder extends BaseIndicesRequestBuilder<Delet
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public DeleteMappingRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<DeleteMappingResponse> listener) {
|
||||
client.deleteMapping(request, listener);
|
||||
((IndicesAdminClient) client).deleteMapping(request, listener);
|
||||
}
|
||||
}
|
|
@ -50,7 +50,7 @@ import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
|||
* @see org.elasticsearch.client.IndicesAdminClient#putMapping(PutMappingRequest)
|
||||
* @see PutMappingResponse
|
||||
*/
|
||||
public class PutMappingRequest extends MasterNodeOperationRequest {
|
||||
public class PutMappingRequest extends MasterNodeOperationRequest<PutMappingRequest> {
|
||||
|
||||
private String[] indices;
|
||||
|
||||
|
@ -205,14 +205,9 @@ public class PutMappingRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
indices = new String[in.readVInt()];
|
||||
for (int i = 0; i < indices.length; i++) {
|
||||
indices[i] = in.readUTF();
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
mappingType = in.readUTF();
|
||||
}
|
||||
mappingSource = in.readUTF();
|
||||
indices = in.readStringArray();
|
||||
mappingType = in.readOptionalString();
|
||||
mappingSource = in.readString();
|
||||
timeout = readTimeValue(in);
|
||||
ignoreConflicts = in.readBoolean();
|
||||
}
|
||||
|
@ -220,21 +215,9 @@ public class PutMappingRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
if (indices == null) {
|
||||
out.writeVInt(0);
|
||||
} else {
|
||||
out.writeVInt(indices.length);
|
||||
for (String index : indices) {
|
||||
out.writeUTF(index);
|
||||
}
|
||||
}
|
||||
if (mappingType == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
out.writeUTF(mappingType);
|
||||
}
|
||||
out.writeUTF(mappingSource);
|
||||
out.writeStringArrayNullable(indices);
|
||||
out.writeOptionalString(mappingType);
|
||||
out.writeString(mappingSource);
|
||||
timeout.writeTo(out);
|
||||
out.writeBoolean(ignoreConflicts);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
package org.elasticsearch.action.admin.indices.mapping.put;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.common.Required;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -31,10 +32,10 @@ import java.util.Map;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class PutMappingRequestBuilder extends BaseIndicesRequestBuilder<PutMappingRequest, PutMappingResponse> {
|
||||
public class PutMappingRequestBuilder extends MasterNodeOperationRequestBuilder<PutMappingRequest, PutMappingResponse, PutMappingRequestBuilder> {
|
||||
|
||||
public PutMappingRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new PutMappingRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new PutMappingRequest());
|
||||
}
|
||||
|
||||
public PutMappingRequestBuilder setIndices(String... indices) {
|
||||
|
@ -93,14 +94,6 @@ public class PutMappingRequestBuilder extends BaseIndicesRequestBuilder<PutMappi
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public PutMappingRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If there is already a mapping definition registered against the type, then it will be merged. If there are
|
||||
* elements that can't be merged are detected, the request will be rejected unless the
|
||||
|
@ -113,6 +106,6 @@ public class PutMappingRequestBuilder extends BaseIndicesRequestBuilder<PutMappi
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<PutMappingResponse> listener) {
|
||||
client.putMapping(request, listener);
|
||||
((IndicesAdminClient) client).putMapping(request, listener);
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
|||
/**
|
||||
* A request to open an index.
|
||||
*/
|
||||
public class OpenIndexRequest extends MasterNodeOperationRequest {
|
||||
public class OpenIndexRequest extends MasterNodeOperationRequest<OpenIndexRequest> {
|
||||
|
||||
private String index;
|
||||
|
||||
|
@ -99,14 +99,14 @@ public class OpenIndexRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
index = in.readUTF();
|
||||
index = in.readString();
|
||||
timeout = readTimeValue(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeUTF(index);
|
||||
out.writeString(index);
|
||||
timeout.writeTo(out);
|
||||
}
|
||||
}
|
|
@ -20,21 +20,22 @@
|
|||
package org.elasticsearch.action.admin.indices.open;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class OpenIndexRequestBuilder extends BaseIndicesRequestBuilder<OpenIndexRequest, OpenIndexResponse> {
|
||||
public class OpenIndexRequestBuilder extends MasterNodeOperationRequestBuilder<OpenIndexRequest, OpenIndexResponse, OpenIndexRequestBuilder> {
|
||||
|
||||
public OpenIndexRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new OpenIndexRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new OpenIndexRequest());
|
||||
}
|
||||
|
||||
public OpenIndexRequestBuilder(IndicesAdminClient indicesClient, String index) {
|
||||
super(indicesClient, new OpenIndexRequest(index));
|
||||
super((InternalIndicesAdminClient) indicesClient, new OpenIndexRequest(index));
|
||||
}
|
||||
|
||||
public OpenIndexRequestBuilder setIndex(String index) {
|
||||
|
@ -60,24 +61,8 @@ public class OpenIndexRequestBuilder extends BaseIndicesRequestBuilder<OpenIndex
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public OpenIndexRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public OpenIndexRequestBuilder setMasterNodeTimeout(String timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<OpenIndexResponse> listener) {
|
||||
client.open(request, listener);
|
||||
((IndicesAdminClient) client).open(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,12 +36,11 @@ import java.io.IOException;
|
|||
* <p>{@link #maxNumSegments(int)} allows to control the number of segments to optimize down to. By default, will
|
||||
* cause the optimize process to optimize down to half the configured number of segments.
|
||||
*
|
||||
*
|
||||
* @see org.elasticsearch.client.Requests#optimizeRequest(String...)
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#optimize(OptimizeRequest)
|
||||
* @see OptimizeResponse
|
||||
*/
|
||||
public class OptimizeRequest extends BroadcastOperationRequest {
|
||||
public class OptimizeRequest extends BroadcastOperationRequest<OptimizeRequest> {
|
||||
|
||||
public static final class Defaults {
|
||||
public static final boolean WAIT_FOR_MERGE = true;
|
||||
|
@ -76,18 +75,6 @@ public class OptimizeRequest extends BroadcastOperationRequest {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptimizeRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptimizeRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
super.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the call block until the optimize completes. Defaults to <tt>true</tt>.
|
||||
*/
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
package org.elasticsearch.action.admin.indices.optimize;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
* A request to optimize one or more indices. In order to optimize on all the indices, pass an empty array or
|
||||
|
@ -35,15 +34,10 @@ import org.elasticsearch.client.IndicesAdminClient;
|
|||
* <p>{@link #setMaxNumSegments(int)} allows to control the number of segments to optimize down to. By default, will
|
||||
* cause the optimize process to optimize down to half the configured number of segments.
|
||||
*/
|
||||
public class OptimizeRequestBuilder extends BaseIndicesRequestBuilder<OptimizeRequest, OptimizeResponse> {
|
||||
public class OptimizeRequestBuilder extends BroadcastOperationRequestBuilder<OptimizeRequest, OptimizeResponse, OptimizeRequestBuilder> {
|
||||
|
||||
public OptimizeRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new OptimizeRequest());
|
||||
}
|
||||
|
||||
public OptimizeRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
super((InternalIndicesAdminClient) indicesClient, new OptimizeRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,32 +82,8 @@ public class OptimizeRequestBuilder extends BaseIndicesRequestBuilder<OptimizeRe
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
public OptimizeRequestBuilder setListenerThreaded(boolean threadedListener) {
|
||||
request.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
public OptimizeRequestBuilder setOperationThreading(BroadcastOperationThreading operationThreading) {
|
||||
request.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore. For example indices that don't exist.
|
||||
*/
|
||||
public OptimizeRequestBuilder setIgnoreIndices(IgnoreIndices ignoreIndices) {
|
||||
request().ignoreIndices(ignoreIndices);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<OptimizeResponse> listener) {
|
||||
client.optimize(request, listener);
|
||||
((IndicesAdminClient) client).optimize(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,20 +31,16 @@ import java.io.IOException;
|
|||
class ShardOptimizeRequest extends BroadcastShardOperationRequest {
|
||||
|
||||
private boolean waitForMerge = OptimizeRequest.Defaults.WAIT_FOR_MERGE;
|
||||
|
||||
private int maxNumSegments = OptimizeRequest.Defaults.MAX_NUM_SEGMENTS;
|
||||
|
||||
private boolean onlyExpungeDeletes = OptimizeRequest.Defaults.ONLY_EXPUNGE_DELETES;
|
||||
|
||||
private boolean flush = OptimizeRequest.Defaults.FLUSH;
|
||||
|
||||
private boolean refresh = OptimizeRequest.Defaults.REFRESH;
|
||||
|
||||
ShardOptimizeRequest() {
|
||||
}
|
||||
|
||||
public ShardOptimizeRequest(String index, int shardId, OptimizeRequest request) {
|
||||
super(index, shardId);
|
||||
super(index, shardId, request);
|
||||
waitForMerge = request.waitForMerge();
|
||||
maxNumSegments = request.maxNumSegments();
|
||||
onlyExpungeDeletes = request.onlyExpungeDeletes();
|
||||
|
|
|
@ -31,12 +31,11 @@ import java.io.IOException;
|
|||
* capabilities depends on the index engine used. For example, the robin one requires refresh to be called, but by
|
||||
* default a refresh is scheduled periodically.
|
||||
*
|
||||
*
|
||||
* @see org.elasticsearch.client.Requests#refreshRequest(String...)
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#refresh(RefreshRequest)
|
||||
* @see RefreshResponse
|
||||
*/
|
||||
public class RefreshRequest extends BroadcastOperationRequest {
|
||||
public class RefreshRequest extends BroadcastOperationRequest<RefreshRequest> {
|
||||
|
||||
private boolean waitForOperations = true;
|
||||
|
||||
|
@ -49,24 +48,6 @@ public class RefreshRequest extends BroadcastOperationRequest {
|
|||
operationThreading(BroadcastOperationThreading.THREAD_PER_SHARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override
|
||||
public RefreshRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
@Override
|
||||
public RefreshRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
super.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean waitForOperations() {
|
||||
return waitForOperations;
|
||||
}
|
||||
|
|
|
@ -20,25 +20,19 @@
|
|||
package org.elasticsearch.action.admin.indices.refresh;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
* A refresh request making all operations performed since the last refresh available for search. The (near) real-time
|
||||
* capabilities depends on the index engine used. For example, the robin one requires refresh to be called, but by
|
||||
* default a refresh is scheduled periodically.
|
||||
*/
|
||||
public class RefreshRequestBuilder extends BaseIndicesRequestBuilder<RefreshRequest, RefreshResponse> {
|
||||
public class RefreshRequestBuilder extends BroadcastOperationRequestBuilder<RefreshRequest, RefreshResponse, RefreshRequestBuilder> {
|
||||
|
||||
public RefreshRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new RefreshRequest());
|
||||
}
|
||||
|
||||
public RefreshRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
super((InternalIndicesAdminClient) indicesClient, new RefreshRequest());
|
||||
}
|
||||
|
||||
public RefreshRequestBuilder setWaitForOperations(boolean waitForOperations) {
|
||||
|
@ -46,32 +40,8 @@ public class RefreshRequestBuilder extends BaseIndicesRequestBuilder<RefreshRequ
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
public RefreshRequestBuilder setListenerThreaded(boolean threadedListener) {
|
||||
request.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
public RefreshRequestBuilder setOperationThreading(BroadcastOperationThreading operationThreading) {
|
||||
request.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore. For example indices that don't exist.
|
||||
*/
|
||||
public RefreshRequestBuilder setIgnoreIndices(IgnoreIndices ignoreIndices) {
|
||||
request().ignoreIndices(ignoreIndices);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<RefreshResponse> listener) {
|
||||
client.refresh(request, listener);
|
||||
((IndicesAdminClient) client).refresh(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class ShardRefreshRequest extends BroadcastShardOperationRequest {
|
|||
}
|
||||
|
||||
public ShardRefreshRequest(String index, int shardId, RefreshRequest request) {
|
||||
super(index, shardId);
|
||||
super(index, shardId, request);
|
||||
waitForOperations = request.waitForOperations();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.elasticsearch.action.admin.indices.segments;
|
|||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequest;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
||||
public class IndicesSegmentsRequest extends BroadcastOperationRequest {
|
||||
public class IndicesSegmentsRequest extends BroadcastOperationRequest<IndicesSegmentsRequest> {
|
||||
|
||||
public IndicesSegmentsRequest() {
|
||||
this(Strings.EMPTY_ARRAY);
|
||||
|
|
|
@ -20,34 +20,21 @@
|
|||
package org.elasticsearch.action.admin.indices.segments;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class IndicesSegmentsRequestBuilder extends BaseIndicesRequestBuilder<IndicesSegmentsRequest, IndicesSegmentResponse> {
|
||||
public class IndicesSegmentsRequestBuilder extends BroadcastOperationRequestBuilder<IndicesSegmentsRequest, IndicesSegmentResponse, IndicesSegmentsRequestBuilder> {
|
||||
|
||||
public IndicesSegmentsRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new IndicesSegmentsRequest());
|
||||
}
|
||||
|
||||
public IndicesSegmentsRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore. For example indices that don't exist.
|
||||
*/
|
||||
public IndicesSegmentsRequestBuilder setIgnoreIndices(IgnoreIndices ignoreIndices) {
|
||||
request().ignoreIndices(ignoreIndices);
|
||||
return this;
|
||||
super((InternalIndicesAdminClient) indicesClient, new IndicesSegmentsRequest());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<IndicesSegmentResponse> listener) {
|
||||
client.segments(request, listener);
|
||||
((IndicesAdminClient) client).segments(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastOperationA
|
|||
}
|
||||
|
||||
IndexShardSegmentRequest(String index, int shardId, IndicesSegmentsRequest request) {
|
||||
super(index, shardId);
|
||||
super(index, shardId, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,7 +41,7 @@ import static org.elasticsearch.common.settings.ImmutableSettings.writeSettingsT
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class UpdateSettingsRequest extends MasterNodeOperationRequest {
|
||||
public class UpdateSettingsRequest extends MasterNodeOperationRequest<UpdateSettingsRequest> {
|
||||
|
||||
private String[] indices;
|
||||
|
||||
|
@ -128,24 +128,14 @@ public class UpdateSettingsRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
indices = new String[in.readVInt()];
|
||||
for (int i = 0; i < indices.length; i++) {
|
||||
indices[i] = in.readUTF();
|
||||
}
|
||||
indices = in.readStringArray();
|
||||
settings = readSettingsFromStream(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
if (indices == null) {
|
||||
out.writeVInt(0);
|
||||
} else {
|
||||
out.writeVInt(indices.length);
|
||||
for (String index : indices) {
|
||||
out.writeUTF(index);
|
||||
}
|
||||
}
|
||||
out.writeStringArrayNullable(indices);
|
||||
writeSettingsToStream(settings, out);
|
||||
}
|
||||
}
|
|
@ -20,8 +20,9 @@
|
|||
package org.elasticsearch.action.admin.indices.settings;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -29,10 +30,10 @@ import java.util.Map;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class UpdateSettingsRequestBuilder extends BaseIndicesRequestBuilder<UpdateSettingsRequest, UpdateSettingsResponse> {
|
||||
public class UpdateSettingsRequestBuilder extends MasterNodeOperationRequestBuilder<UpdateSettingsRequest, UpdateSettingsResponse, UpdateSettingsRequestBuilder> {
|
||||
|
||||
public UpdateSettingsRequestBuilder(IndicesAdminClient indicesClient, String... indices) {
|
||||
super(indicesClient, new UpdateSettingsRequest(indices));
|
||||
super((InternalIndicesAdminClient) indicesClient, new UpdateSettingsRequest(indices));
|
||||
}
|
||||
|
||||
public UpdateSettingsRequestBuilder setIndices(String... indices) {
|
||||
|
@ -74,6 +75,6 @@ public class UpdateSettingsRequestBuilder extends BaseIndicesRequestBuilder<Upda
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<UpdateSettingsResponse> listener) {
|
||||
client.updateSettings(request, listener);
|
||||
((IndicesAdminClient) client).updateSettings(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.io.IOException;
|
|||
* <p>All the stats to be returned can be cleared using {@link #clear()}, at which point, specific
|
||||
* stats can be enabled.
|
||||
*/
|
||||
public class IndicesStatsRequest extends BroadcastOperationRequest {
|
||||
public class IndicesStatsRequest extends BroadcastOperationRequest<IndicesStatsRequest> {
|
||||
|
||||
private boolean docs = true;
|
||||
private boolean store = true;
|
||||
|
@ -48,11 +48,6 @@ public class IndicesStatsRequest extends BroadcastOperationRequest {
|
|||
private String[] types = null;
|
||||
private String[] groups = null;
|
||||
|
||||
public IndicesStatsRequest indices(String... indices) {
|
||||
this.indices = indices;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all flags to return all stats.
|
||||
*/
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
package org.elasticsearch.action.admin.indices.stats;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
* A request to get indices level stats. Allow to enable different stats to be returned.
|
||||
|
@ -33,10 +33,10 @@ import org.elasticsearch.client.IndicesAdminClient;
|
|||
* <p>All the stats to be returned can be cleared using {@link #clear()}, at which point, specific
|
||||
* stats can be enabled.
|
||||
*/
|
||||
public class IndicesStatsRequestBuilder extends BaseIndicesRequestBuilder<IndicesStatsRequest, IndicesStats> {
|
||||
public class IndicesStatsRequestBuilder extends BroadcastOperationRequestBuilder<IndicesStatsRequest, IndicesStats, IndicesStatsRequestBuilder> {
|
||||
|
||||
public IndicesStatsRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new IndicesStatsRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new IndicesStatsRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,14 +55,6 @@ public class IndicesStatsRequestBuilder extends BaseIndicesRequestBuilder<Indice
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets specific indices to return the stats for.
|
||||
*/
|
||||
public IndicesStatsRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Document types to return stats for. Mainly affects {@link #setIndexing(boolean)} when
|
||||
* enabled, returning specific indexing stats for those types.
|
||||
|
@ -122,16 +114,8 @@ public class IndicesStatsRequestBuilder extends BaseIndicesRequestBuilder<Indice
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore. For example indices that don't exist.
|
||||
*/
|
||||
public IndicesStatsRequestBuilder setIgnoreIndices(IgnoreIndices ignoreIndices) {
|
||||
request().ignoreIndices(ignoreIndices);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<IndicesStats> listener) {
|
||||
client.stats(request, listener);
|
||||
((IndicesAdminClient) client).stats(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,13 +178,14 @@ public class TransportIndicesStatsAction extends TransportBroadcastOperationActi
|
|||
|
||||
public static class IndexShardStatsRequest extends BroadcastShardOperationRequest {
|
||||
|
||||
// TODO if there are many indices, the request might hold a large indices array..., we don't really need to serialize it
|
||||
IndicesStatsRequest request;
|
||||
|
||||
IndexShardStatsRequest() {
|
||||
}
|
||||
|
||||
IndexShardStatsRequest(String index, int shardId, IndicesStatsRequest request) {
|
||||
super(index, shardId);
|
||||
super(index, shardId, request);
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.action.admin.indices.status;
|
||||
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequest;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
@ -30,7 +29,7 @@ import java.io.IOException;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class IndicesStatusRequest extends BroadcastOperationRequest {
|
||||
public class IndicesStatusRequest extends BroadcastOperationRequest<IndicesStatusRequest> {
|
||||
|
||||
private boolean recovery = false;
|
||||
|
||||
|
@ -68,17 +67,6 @@ public class IndicesStatusRequest extends BroadcastOperationRequest {
|
|||
return this.snapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndicesStatusRequest listenerThreaded(boolean listenerThreaded) {
|
||||
super.listenerThreaded(listenerThreaded);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BroadcastOperationRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
return super.operationThreading(operationThreading);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
|
|
|
@ -20,25 +20,17 @@
|
|||
package org.elasticsearch.action.admin.indices.status;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class IndicesStatusRequestBuilder extends BaseIndicesRequestBuilder<IndicesStatusRequest, IndicesStatusResponse> {
|
||||
public class IndicesStatusRequestBuilder extends BroadcastOperationRequestBuilder<IndicesStatusRequest, IndicesStatusResponse, IndicesStatusRequestBuilder> {
|
||||
|
||||
public IndicesStatusRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new IndicesStatusRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets specific indices to return the status for.
|
||||
*/
|
||||
public IndicesStatusRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
super((InternalIndicesAdminClient) indicesClient, new IndicesStatusRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,16 +49,8 @@ public class IndicesStatusRequestBuilder extends BaseIndicesRequestBuilder<Indic
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore. For example indices that don't exist.
|
||||
*/
|
||||
public IndicesStatusRequestBuilder setIgnoreIndices(IgnoreIndices ignoreIndices) {
|
||||
request().ignoreIndices(ignoreIndices);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<IndicesStatusResponse> listener) {
|
||||
client.status(request, listener);
|
||||
((IndicesAdminClient) client).status(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,7 +277,7 @@ public class TransportIndicesStatusAction extends TransportBroadcastOperationAct
|
|||
}
|
||||
|
||||
IndexShardStatusRequest(String index, int shardId, IndicesStatusRequest request) {
|
||||
super(index, shardId);
|
||||
super(index, shardId, request);
|
||||
recovery = request.recovery();
|
||||
snapshot = request.snapshot();
|
||||
}
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.indices.support;
|
||||
|
||||
import org.elasticsearch.action.*;
|
||||
import org.elasticsearch.action.support.PlainListenableActionFuture;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class BaseIndicesRequestBuilder<Request extends ActionRequest, Response extends ActionResponse> implements ActionRequestBuilder<Request, Response> {
|
||||
|
||||
protected final InternalIndicesAdminClient client;
|
||||
|
||||
protected final Request request;
|
||||
|
||||
protected BaseIndicesRequestBuilder(IndicesAdminClient client, Request request) {
|
||||
this.client = (InternalIndicesAdminClient) client;
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Request request() {
|
||||
return request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableActionFuture<Response> execute() {
|
||||
PlainListenableActionFuture<Response> future = new PlainListenableActionFuture<Response>(request.listenerThreaded(), client.threadPool());
|
||||
execute(future);
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ActionListener<Response> listener) {
|
||||
doExecute(listener);
|
||||
}
|
||||
|
||||
protected abstract void doExecute(ActionListener<Response> listener);
|
||||
}
|
|
@ -34,7 +34,7 @@ import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
|||
/**
|
||||
* A request to delete an index template.
|
||||
*/
|
||||
public class DeleteIndexTemplateRequest extends MasterNodeOperationRequest {
|
||||
public class DeleteIndexTemplateRequest extends MasterNodeOperationRequest<DeleteIndexTemplateRequest> {
|
||||
|
||||
private String name;
|
||||
|
||||
|
@ -94,14 +94,14 @@ public class DeleteIndexTemplateRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
name = in.readUTF();
|
||||
name = in.readString();
|
||||
timeout = readTimeValue(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeUTF(name);
|
||||
out.writeString(name);
|
||||
timeout.writeTo(out);
|
||||
}
|
||||
}
|
|
@ -20,21 +20,22 @@
|
|||
package org.elasticsearch.action.admin.indices.template.delete;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DeleteIndexTemplateRequestBuilder extends BaseIndicesRequestBuilder<DeleteIndexTemplateRequest, DeleteIndexTemplateResponse> {
|
||||
public class DeleteIndexTemplateRequestBuilder extends MasterNodeOperationRequestBuilder<DeleteIndexTemplateRequest, DeleteIndexTemplateResponse, DeleteIndexTemplateRequestBuilder> {
|
||||
|
||||
public DeleteIndexTemplateRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new DeleteIndexTemplateRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new DeleteIndexTemplateRequest());
|
||||
}
|
||||
|
||||
public DeleteIndexTemplateRequestBuilder(IndicesAdminClient indicesClient, String name) {
|
||||
super(indicesClient, new DeleteIndexTemplateRequest(name));
|
||||
super((InternalIndicesAdminClient) indicesClient, new DeleteIndexTemplateRequest(name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,24 +56,8 @@ public class DeleteIndexTemplateRequestBuilder extends BaseIndicesRequestBuilder
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public DeleteIndexTemplateRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public DeleteIndexTemplateRequestBuilder setMasterNodeTimeout(String timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<DeleteIndexTemplateResponse> listener) {
|
||||
client.deleteTemplate(request, listener);
|
||||
((IndicesAdminClient) client).deleteTemplate(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ import static org.elasticsearch.common.unit.TimeValue.readTimeValue;
|
|||
/**
|
||||
* A request to create an index template.
|
||||
*/
|
||||
public class PutIndexTemplateRequest extends MasterNodeOperationRequest {
|
||||
public class PutIndexTemplateRequest extends MasterNodeOperationRequest<PutIndexTemplateRequest> {
|
||||
|
||||
private String name;
|
||||
|
||||
|
@ -370,20 +370,20 @@ public class PutIndexTemplateRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
cause = in.readUTF();
|
||||
name = in.readUTF();
|
||||
template = in.readUTF();
|
||||
cause = in.readString();
|
||||
name = in.readString();
|
||||
template = in.readString();
|
||||
order = in.readInt();
|
||||
create = in.readBoolean();
|
||||
settings = readSettingsFromStream(in);
|
||||
timeout = readTimeValue(in);
|
||||
int size = in.readVInt();
|
||||
for (int i = 0; i < size; i++) {
|
||||
mappings.put(in.readUTF(), in.readUTF());
|
||||
mappings.put(in.readString(), in.readString());
|
||||
}
|
||||
int customSize = in.readVInt();
|
||||
for (int i = 0; i < customSize; i++) {
|
||||
String type = in.readUTF();
|
||||
String type = in.readString();
|
||||
IndexMetaData.Custom customIndexMetaData = IndexMetaData.lookupFactorySafe(type).readFrom(in);
|
||||
customs.put(type, customIndexMetaData);
|
||||
}
|
||||
|
@ -392,21 +392,21 @@ public class PutIndexTemplateRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeUTF(cause);
|
||||
out.writeUTF(name);
|
||||
out.writeUTF(template);
|
||||
out.writeString(cause);
|
||||
out.writeString(name);
|
||||
out.writeString(template);
|
||||
out.writeInt(order);
|
||||
out.writeBoolean(create);
|
||||
writeSettingsToStream(settings, out);
|
||||
timeout.writeTo(out);
|
||||
out.writeVInt(mappings.size());
|
||||
for (Map.Entry<String, String> entry : mappings.entrySet()) {
|
||||
out.writeUTF(entry.getKey());
|
||||
out.writeUTF(entry.getValue());
|
||||
out.writeString(entry.getKey());
|
||||
out.writeString(entry.getValue());
|
||||
}
|
||||
out.writeVInt(customs.size());
|
||||
for (Map.Entry<String, IndexMetaData.Custom> entry : customs.entrySet()) {
|
||||
out.writeUTF(entry.getKey());
|
||||
out.writeString(entry.getKey());
|
||||
IndexMetaData.lookupFactorySafe(entry.getKey()).writeTo(entry.getValue(), out);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
package org.elasticsearch.action.admin.indices.template.put;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
@ -32,14 +33,14 @@ import java.util.Map;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class PutIndexTemplateRequestBuilder extends BaseIndicesRequestBuilder<PutIndexTemplateRequest, PutIndexTemplateResponse> {
|
||||
public class PutIndexTemplateRequestBuilder extends MasterNodeOperationRequestBuilder<PutIndexTemplateRequest, PutIndexTemplateResponse, PutIndexTemplateRequestBuilder> {
|
||||
|
||||
public PutIndexTemplateRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new PutIndexTemplateRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new PutIndexTemplateRequest());
|
||||
}
|
||||
|
||||
public PutIndexTemplateRequestBuilder(IndicesAdminClient indicesClient, String name) {
|
||||
super(indicesClient, new PutIndexTemplateRequest(name));
|
||||
super((InternalIndicesAdminClient) indicesClient, new PutIndexTemplateRequest(name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -206,24 +207,8 @@ public class PutIndexTemplateRequestBuilder extends BaseIndicesRequestBuilder<Pu
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public PutIndexTemplateRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public PutIndexTemplateRequestBuilder setMasterNodeTimeout(String timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<PutIndexTemplateResponse> listener) {
|
||||
client.putTemplate(request, listener);
|
||||
((IndicesAdminClient) client).putTemplate(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,9 +34,7 @@ import java.io.IOException;
|
|||
class ShardValidateQueryRequest extends BroadcastShardOperationRequest {
|
||||
|
||||
private BytesReference querySource;
|
||||
|
||||
private String[] types = Strings.EMPTY_ARRAY;
|
||||
|
||||
private boolean explain;
|
||||
|
||||
@Nullable
|
||||
|
@ -47,7 +45,7 @@ class ShardValidateQueryRequest extends BroadcastShardOperationRequest {
|
|||
}
|
||||
|
||||
public ShardValidateQueryRequest(String index, int shardId, @Nullable String[] filteringAliases, ValidateQueryRequest request) {
|
||||
super(index, shardId);
|
||||
super(index, shardId, request);
|
||||
this.querySource = request.querySource();
|
||||
this.types = request.types();
|
||||
this.explain = request.explain();
|
||||
|
@ -79,14 +77,14 @@ class ShardValidateQueryRequest extends BroadcastShardOperationRequest {
|
|||
if (typesSize > 0) {
|
||||
types = new String[typesSize];
|
||||
for (int i = 0; i < typesSize; i++) {
|
||||
types[i] = in.readUTF();
|
||||
types[i] = in.readString();
|
||||
}
|
||||
}
|
||||
int aliasesSize = in.readVInt();
|
||||
if (aliasesSize > 0) {
|
||||
filteringAliases = new String[aliasesSize];
|
||||
for (int i = 0; i < aliasesSize; i++) {
|
||||
filteringAliases[i] = in.readUTF();
|
||||
filteringAliases[i] = in.readString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,12 +98,12 @@ class ShardValidateQueryRequest extends BroadcastShardOperationRequest {
|
|||
|
||||
out.writeVInt(types.length);
|
||||
for (String type : types) {
|
||||
out.writeUTF(type);
|
||||
out.writeString(type);
|
||||
}
|
||||
if (filteringAliases != null) {
|
||||
out.writeVInt(filteringAliases.length);
|
||||
for (String alias : filteringAliases) {
|
||||
out.writeUTF(alias);
|
||||
out.writeString(alias);
|
||||
}
|
||||
} else {
|
||||
out.writeVInt(0);
|
||||
|
|
|
@ -40,8 +40,8 @@ import org.elasticsearch.index.service.IndexService;
|
|||
import org.elasticsearch.index.shard.service.IndexShard;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.internal.InternalSearchRequest;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.elasticsearch.search.internal.ShardSearchRequest;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
|
@ -166,7 +166,7 @@ public class TransportValidateQueryAction extends TransportBroadcastOperationAct
|
|||
valid = true;
|
||||
} else {
|
||||
SearchContext.setCurrent(new SearchContext(0,
|
||||
new InternalSearchRequest().types(request.types()),
|
||||
new ShardSearchRequest().types(request.types()),
|
||||
null, indexShard.searcher(), indexService, indexShard,
|
||||
scriptService));
|
||||
try {
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.action.admin.indices.validate.query;
|
|||
import org.elasticsearch.ElasticSearchGenerationException;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequest;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.client.Requests;
|
||||
import org.elasticsearch.common.Required;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -46,7 +45,7 @@ import java.util.Map;
|
|||
* <p>The request requires the query source to be set either using {@link #query(org.elasticsearch.index.query.QueryBuilder)},
|
||||
* or {@link #query(byte[])}.
|
||||
*/
|
||||
public class ValidateQueryRequest extends BroadcastOperationRequest {
|
||||
public class ValidateQueryRequest extends BroadcastOperationRequest<ValidateQueryRequest> {
|
||||
|
||||
private static final XContentType contentType = Requests.CONTENT_TYPE;
|
||||
|
||||
|
@ -74,15 +73,6 @@ public class ValidateQueryRequest extends BroadcastOperationRequest {
|
|||
return validationException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
@Override
|
||||
public ValidateQueryRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
super.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeStart() {
|
||||
if (querySourceUnsafe) {
|
||||
|
@ -91,20 +81,6 @@ public class ValidateQueryRequest extends BroadcastOperationRequest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override
|
||||
public ValidateQueryRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValidateQueryRequest indices(String... indices) {
|
||||
this.indices = indices;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The query source to execute.
|
||||
*/
|
||||
|
|
|
@ -1,27 +1,38 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.indices.validate.query;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ValidateQueryRequestBuilder extends BaseIndicesRequestBuilder<ValidateQueryRequest, ValidateQueryResponse> {
|
||||
public ValidateQueryRequestBuilder(IndicesAdminClient client) {
|
||||
super(client, new ValidateQueryRequest());
|
||||
}
|
||||
public class ValidateQueryRequestBuilder extends BroadcastOperationRequestBuilder<ValidateQueryRequest, ValidateQueryResponse, ValidateQueryRequestBuilder> {
|
||||
|
||||
/**
|
||||
* Sets the indices the query validation will run against.
|
||||
*/
|
||||
public ValidateQueryRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
public ValidateQueryRequestBuilder(IndicesAdminClient client) {
|
||||
super((InternalIndicesAdminClient) client, new ValidateQueryRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,32 +93,8 @@ public class ValidateQueryRequestBuilder extends BaseIndicesRequestBuilder<Valid
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
public ValidateQueryRequestBuilder setOperationThreading(BroadcastOperationThreading operationThreading) {
|
||||
request.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
public ValidateQueryRequestBuilder setListenerThreaded(boolean threadedListener) {
|
||||
request.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore. For example indices that don't exist.
|
||||
*/
|
||||
public ValidateQueryRequestBuilder setIgnoreIndices(IgnoreIndices ignoreIndices) {
|
||||
request().ignoreIndices(ignoreIndices);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<ValidateQueryResponse> listener) {
|
||||
client.validateQuery(request, listener);
|
||||
((IndicesAdminClient) client).validateQuery(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.action.admin.indices.warmer.delete;
|
|||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequest;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
||||
|
@ -30,11 +31,11 @@ import java.io.IOException;
|
|||
/**
|
||||
* A request to delete an index warmer.
|
||||
*/
|
||||
public class DeleteWarmerRequest extends MasterNodeOperationRequest {
|
||||
public class DeleteWarmerRequest extends MasterNodeOperationRequest<DeleteWarmerRequest> {
|
||||
|
||||
private String name;
|
||||
|
||||
private String[] indices;
|
||||
private String[] indices = Strings.EMPTY_ARRAY;
|
||||
|
||||
DeleteWarmerRequest() {
|
||||
}
|
||||
|
@ -89,24 +90,14 @@ public class DeleteWarmerRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
name = in.readOptionalUTF();
|
||||
indices = new String[in.readVInt()];
|
||||
for (int i = 0; i < indices.length; i++) {
|
||||
indices[i] = in.readUTF();
|
||||
}
|
||||
name = in.readOptionalString();
|
||||
indices = in.readStringArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeOptionalUTF(name);
|
||||
if (indices == null) {
|
||||
out.writeVInt(0);
|
||||
} else {
|
||||
out.writeVInt(indices.length);
|
||||
for (String index : indices) {
|
||||
out.writeUTF(index);
|
||||
}
|
||||
}
|
||||
out.writeOptionalString(name);
|
||||
out.writeStringArrayNullable(indices);
|
||||
}
|
||||
}
|
|
@ -20,17 +20,17 @@
|
|||
package org.elasticsearch.action.admin.indices.warmer.delete;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DeleteWarmerRequestBuilder extends BaseIndicesRequestBuilder<DeleteWarmerRequest, DeleteWarmerResponse> {
|
||||
public class DeleteWarmerRequestBuilder extends MasterNodeOperationRequestBuilder<DeleteWarmerRequest, DeleteWarmerResponse, DeleteWarmerRequestBuilder> {
|
||||
|
||||
public DeleteWarmerRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new DeleteWarmerRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new DeleteWarmerRequest());
|
||||
}
|
||||
|
||||
public DeleteWarmerRequestBuilder setIndices(String... indices) {
|
||||
|
@ -47,16 +47,8 @@ public class DeleteWarmerRequestBuilder extends BaseIndicesRequestBuilder<Delete
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public DeleteWarmerRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<DeleteWarmerResponse> listener) {
|
||||
client.deleteWarmer(request, listener);
|
||||
((IndicesAdminClient) client).deleteWarmer(request, listener);
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|||
/**
|
||||
* A request to put a search warmer.
|
||||
*/
|
||||
public class PutWarmerRequest extends MasterNodeOperationRequest {
|
||||
public class PutWarmerRequest extends MasterNodeOperationRequest<PutWarmerRequest> {
|
||||
|
||||
private String name;
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class PutWarmerRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
name = in.readUTF();
|
||||
name = in.readString();
|
||||
if (in.readBoolean()) {
|
||||
searchRequest = new SearchRequest();
|
||||
searchRequest.readFrom(in);
|
||||
|
@ -108,7 +108,7 @@ public class PutWarmerRequest extends MasterNodeOperationRequest {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeUTF(name);
|
||||
out.writeString(name);
|
||||
if (searchRequest == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
|
|
|
@ -20,23 +20,23 @@
|
|||
package org.elasticsearch.action.admin.indices.warmer.put;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.client.internal.InternalIndicesAdminClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PutWarmerRequestBuilder extends BaseIndicesRequestBuilder<PutWarmerRequest, PutWarmerResponse> {
|
||||
public class PutWarmerRequestBuilder extends MasterNodeOperationRequestBuilder<PutWarmerRequest, PutWarmerResponse, PutWarmerRequestBuilder> {
|
||||
|
||||
public PutWarmerRequestBuilder(IndicesAdminClient indicesClient, String name) {
|
||||
super(indicesClient, new PutWarmerRequest().name(name));
|
||||
super((InternalIndicesAdminClient) indicesClient, new PutWarmerRequest().name(name));
|
||||
}
|
||||
|
||||
public PutWarmerRequestBuilder(IndicesAdminClient indicesClient) {
|
||||
super(indicesClient, new PutWarmerRequest());
|
||||
super((InternalIndicesAdminClient) indicesClient, new PutWarmerRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,16 +63,8 @@ public class PutWarmerRequestBuilder extends BaseIndicesRequestBuilder<PutWarmer
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the master node timeout in case the master has not yet been discovered.
|
||||
*/
|
||||
public PutWarmerRequestBuilder setMasterNodeTimeout(TimeValue timeout) {
|
||||
request.masterNodeTimeout(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<PutWarmerResponse> listener) {
|
||||
client.putWarmer(request, listener);
|
||||
((IndicesAdminClient) client).putWarmer(request, listener);
|
||||
}
|
||||
}
|
|
@ -49,14 +49,12 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|||
*
|
||||
* @see org.elasticsearch.client.Client#bulk(BulkRequest)
|
||||
*/
|
||||
public class BulkRequest implements ActionRequest {
|
||||
public class BulkRequest extends ActionRequest<BulkRequest> {
|
||||
|
||||
private static final int REQUEST_OVERHEAD = 50;
|
||||
|
||||
final List<ActionRequest> requests = Lists.newArrayList();
|
||||
|
||||
private boolean listenerThreaded = false;
|
||||
|
||||
private ReplicationType replicationType = ReplicationType.DEFAULT;
|
||||
private WriteConsistencyLevel consistencyLevel = WriteConsistencyLevel.DEFAULT;
|
||||
private boolean refresh = false;
|
||||
|
@ -329,19 +327,9 @@ public class BulkRequest implements ActionRequest {
|
|||
return validationException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean listenerThreaded() {
|
||||
return listenerThreaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BulkRequest listenerThreaded(boolean listenerThreaded) {
|
||||
this.listenerThreaded = listenerThreaded;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
replicationType = ReplicationType.fromId(in.readByte());
|
||||
consistencyLevel = WriteConsistencyLevel.fromId(in.readByte());
|
||||
int size = in.readVInt();
|
||||
|
@ -362,6 +350,7 @@ public class BulkRequest implements ActionRequest {
|
|||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeByte(replicationType.id());
|
||||
out.writeByte(consistencyLevel.id());
|
||||
out.writeVInt(requests.size());
|
||||
|
|
|
@ -20,24 +20,25 @@
|
|||
package org.elasticsearch.action.bulk;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionRequestBuilder;
|
||||
import org.elasticsearch.action.WriteConsistencyLevel;
|
||||
import org.elasticsearch.action.delete.DeleteRequest;
|
||||
import org.elasticsearch.action.delete.DeleteRequestBuilder;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.support.BaseRequestBuilder;
|
||||
import org.elasticsearch.action.support.replication.ReplicationType;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.internal.InternalClient;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
|
||||
/**
|
||||
* A bulk request holds an ordered {@link IndexRequest}s and {@link DeleteRequest}s and allows to executes
|
||||
* it in a single batch.
|
||||
*/
|
||||
public class BulkRequestBuilder extends BaseRequestBuilder<BulkRequest, BulkResponse> {
|
||||
public class BulkRequestBuilder extends ActionRequestBuilder<BulkRequest, BulkResponse, BulkRequestBuilder> {
|
||||
|
||||
public BulkRequestBuilder(Client client) {
|
||||
super(client, new BulkRequest());
|
||||
super((InternalClient) client, new BulkRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,6 +126,6 @@ public class BulkRequestBuilder extends BaseRequestBuilder<BulkRequest, BulkResp
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<BulkResponse> listener) {
|
||||
client.bulk(request, listener);
|
||||
((Client) client).bulk(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.io.IOException;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class BulkShardRequest extends ShardReplicationOperationRequest {
|
||||
public class BulkShardRequest extends ShardReplicationOperationRequest<BulkShardRequest> {
|
||||
|
||||
private int shardId;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.action.count;
|
|||
import org.elasticsearch.ElasticSearchGenerationException;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequest;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.client.Requests;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Required;
|
||||
|
@ -52,7 +51,7 @@ import java.util.Map;
|
|||
* @see org.elasticsearch.client.Client#count(CountRequest)
|
||||
* @see org.elasticsearch.client.Requests#countRequest(String...)
|
||||
*/
|
||||
public class CountRequest extends BroadcastOperationRequest {
|
||||
public class CountRequest extends BroadcastOperationRequest<CountRequest> {
|
||||
|
||||
private static final XContentType contentType = Requests.CONTENT_TYPE;
|
||||
|
||||
|
@ -92,15 +91,6 @@ public class CountRequest extends BroadcastOperationRequest {
|
|||
return queryHint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
@Override
|
||||
public CountRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
super.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeStart() {
|
||||
if (querySourceUnsafe) {
|
||||
|
@ -109,20 +99,6 @@ public class CountRequest extends BroadcastOperationRequest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override
|
||||
public CountRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CountRequest indices(String... indices) {
|
||||
this.indices = indices;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A query hint to optionally later be used when routing the request.
|
||||
*/
|
||||
|
|
|
@ -20,28 +20,19 @@
|
|||
package org.elasticsearch.action.count;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.BaseRequestBuilder;
|
||||
import org.elasticsearch.action.support.IgnoreIndices;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.internal.InternalClient;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
|
||||
/**
|
||||
* A count action request builder.
|
||||
*/
|
||||
public class CountRequestBuilder extends BaseRequestBuilder<CountRequest, CountResponse> {
|
||||
public class CountRequestBuilder extends BroadcastOperationRequestBuilder<CountRequest, CountResponse, CountRequestBuilder> {
|
||||
|
||||
public CountRequestBuilder(Client client) {
|
||||
super(client, new CountRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the indices the count query will run against.
|
||||
*/
|
||||
public CountRequestBuilder setIndices(String... indices) {
|
||||
request.indices(indices);
|
||||
return this;
|
||||
super((InternalClient) client, new CountRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,32 +116,8 @@ public class CountRequestBuilder extends BaseRequestBuilder<CountRequest, CountR
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
public CountRequestBuilder setOperationThreading(BroadcastOperationThreading operationThreading) {
|
||||
request.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
public CountRequestBuilder setListenerThreaded(boolean threadedListener) {
|
||||
request.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore. For example indices that don't exist.
|
||||
*/
|
||||
public CountRequestBuilder setIgnoreIndices(IgnoreIndices ignoreIndices) {
|
||||
request().ignoreIndices(ignoreIndices);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<CountResponse> listener) {
|
||||
client.count(request, listener);
|
||||
((InternalClient) client).count(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ class ShardCountRequest extends BroadcastShardOperationRequest {
|
|||
private float minScore;
|
||||
|
||||
private BytesReference querySource;
|
||||
private int querySourceOffset;
|
||||
private int querySourceLength;
|
||||
|
||||
private String[] types = Strings.EMPTY_ARRAY;
|
||||
|
||||
|
@ -49,7 +47,7 @@ class ShardCountRequest extends BroadcastShardOperationRequest {
|
|||
}
|
||||
|
||||
public ShardCountRequest(String index, int shardId, @Nullable String[] filteringAliases, CountRequest request) {
|
||||
super(index, shardId);
|
||||
super(index, shardId, request);
|
||||
this.minScore = request.minScore();
|
||||
this.querySource = request.querySource();
|
||||
this.types = request.types();
|
||||
|
|
|
@ -40,8 +40,8 @@ import org.elasticsearch.index.shard.service.IndexShard;
|
|||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchShardTarget;
|
||||
import org.elasticsearch.search.internal.InternalSearchRequest;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.elasticsearch.search.internal.ShardSearchRequest;
|
||||
import org.elasticsearch.search.query.QueryPhaseExecutionException;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
@ -148,7 +148,7 @@ public class TransportCountAction extends TransportBroadcastOperationAction<Coun
|
|||
|
||||
SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().id(), request.index(), request.shardId());
|
||||
SearchContext context = new SearchContext(0,
|
||||
new InternalSearchRequest().types(request.types()).filteringAliases(request.filteringAliases()),
|
||||
new ShardSearchRequest().types(request.types()).filteringAliases(request.filteringAliases()),
|
||||
shardTarget, indexShard.searcher(), indexService, indexShard,
|
||||
scriptService);
|
||||
SearchContext.setCurrent(context);
|
||||
|
|
|
@ -20,14 +20,11 @@
|
|||
package org.elasticsearch.action.delete;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.WriteConsistencyLevel;
|
||||
import org.elasticsearch.action.support.replication.ReplicationType;
|
||||
import org.elasticsearch.action.support.replication.ShardReplicationOperationRequest;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Required;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.VersionType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -45,7 +42,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|||
* @see org.elasticsearch.client.Client#delete(DeleteRequest)
|
||||
* @see org.elasticsearch.client.Requests#deleteRequest(String)
|
||||
*/
|
||||
public class DeleteRequest extends ShardReplicationOperationRequest {
|
||||
public class DeleteRequest extends ShardReplicationOperationRequest<DeleteRequest> {
|
||||
|
||||
private String type;
|
||||
private String id;
|
||||
|
@ -101,52 +98,6 @@ public class DeleteRequest extends ShardReplicationOperationRequest {
|
|||
return validationException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the index the delete will happen on.
|
||||
*/
|
||||
@Override
|
||||
public DeleteRequest index(String index) {
|
||||
super.index(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override
|
||||
public DeleteRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls if the operation will be executed on a separate thread when executed locally. Defaults
|
||||
* to <tt>true</tt> when running in embedded mode.
|
||||
*/
|
||||
@Override
|
||||
public DeleteRequest operationThreaded(boolean threadedOperation) {
|
||||
super.operationThreaded(threadedOperation);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the replication type for this operation.
|
||||
*/
|
||||
@Override
|
||||
public DeleteRequest replicationType(ReplicationType replicationType) {
|
||||
super.replicationType(replicationType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the consistency level of write. Defaults to {@link org.elasticsearch.action.WriteConsistencyLevel#DEFAULT}
|
||||
*/
|
||||
@Override
|
||||
public DeleteRequest consistencyLevel(WriteConsistencyLevel consistencyLevel) {
|
||||
super.consistencyLevel(consistencyLevel);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the document to delete.
|
||||
*/
|
||||
|
@ -179,14 +130,6 @@ public class DeleteRequest extends ShardReplicationOperationRequest {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A timeout to wait if the index operation can't be performed immediately. Defaults to <tt>1m</tt>.
|
||||
*/
|
||||
public DeleteRequest timeout(TimeValue timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent id of this document. Will simply set the routing to this value, as it is only
|
||||
* used for routing with delete requests.
|
||||
|
@ -258,11 +201,9 @@ public class DeleteRequest extends ShardReplicationOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
type = in.readUTF();
|
||||
id = in.readUTF();
|
||||
if (in.readBoolean()) {
|
||||
routing = in.readUTF();
|
||||
}
|
||||
type = in.readString();
|
||||
id = in.readString();
|
||||
routing = in.readOptionalString();
|
||||
refresh = in.readBoolean();
|
||||
version = in.readLong();
|
||||
versionType = VersionType.fromValue(in.readByte());
|
||||
|
@ -271,14 +212,9 @@ public class DeleteRequest extends ShardReplicationOperationRequest {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeUTF(type);
|
||||
out.writeUTF(id);
|
||||
if (routing == null) {
|
||||
out.writeBoolean(false);
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
out.writeUTF(routing);
|
||||
}
|
||||
out.writeString(type);
|
||||
out.writeString(id);
|
||||
out.writeOptionalString(routing());
|
||||
out.writeBoolean(refresh);
|
||||
out.writeLong(version);
|
||||
out.writeByte(versionType.getValue());
|
||||
|
|
|
@ -21,31 +21,24 @@ package org.elasticsearch.action.delete;
|
|||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.WriteConsistencyLevel;
|
||||
import org.elasticsearch.action.support.BaseRequestBuilder;
|
||||
import org.elasticsearch.action.support.replication.ReplicationType;
|
||||
import org.elasticsearch.action.support.replication.ShardReplicationOperationRequestBuilder;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.internal.InternalClient;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.index.VersionType;
|
||||
|
||||
/**
|
||||
* A delete document action request builder.
|
||||
*/
|
||||
public class DeleteRequestBuilder extends BaseRequestBuilder<DeleteRequest, DeleteResponse> {
|
||||
public class DeleteRequestBuilder extends ShardReplicationOperationRequestBuilder<DeleteRequest, DeleteResponse, DeleteRequestBuilder> {
|
||||
|
||||
public DeleteRequestBuilder(Client client) {
|
||||
super(client, new DeleteRequest());
|
||||
super((InternalClient) client, new DeleteRequest());
|
||||
}
|
||||
|
||||
public DeleteRequestBuilder(Client client, @Nullable String index) {
|
||||
super(client, new DeleteRequest(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the index the delete will happen on.
|
||||
*/
|
||||
public DeleteRequestBuilder setIndex(String index) {
|
||||
request.index(index);
|
||||
return this;
|
||||
super((InternalClient) client, new DeleteRequest(index));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,23 +102,6 @@ public class DeleteRequestBuilder extends BaseRequestBuilder<DeleteRequest, Dele
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
public DeleteRequestBuilder setListenerThreaded(boolean threadedListener) {
|
||||
request.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls if the operation will be executed on a separate thread when executed locally. Defaults
|
||||
* to <tt>true</tt> when running in embedded mode.
|
||||
*/
|
||||
public DeleteRequestBuilder setOperationThreaded(boolean threadedOperation) {
|
||||
request.operationThreaded(threadedOperation);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the replication type for this operation.
|
||||
*/
|
||||
|
@ -144,6 +120,6 @@ public class DeleteRequestBuilder extends BaseRequestBuilder<DeleteRequest, Dele
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<DeleteResponse> listener) {
|
||||
client.delete(request, listener);
|
||||
((Client) client).delete(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,14 +29,11 @@ import java.io.IOException;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class IndexDeleteRequest extends IndexReplicationOperationRequest {
|
||||
public class IndexDeleteRequest extends IndexReplicationOperationRequest<IndexDeleteRequest> {
|
||||
|
||||
private String type;
|
||||
|
||||
private String id;
|
||||
|
||||
private boolean refresh = false;
|
||||
|
||||
private long version;
|
||||
|
||||
IndexDeleteRequest() {
|
||||
|
@ -72,8 +69,8 @@ public class IndexDeleteRequest extends IndexReplicationOperationRequest {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
type = in.readUTF();
|
||||
id = in.readUTF();
|
||||
type = in.readString();
|
||||
id = in.readString();
|
||||
refresh = in.readBoolean();
|
||||
version = in.readLong();
|
||||
}
|
||||
|
@ -81,8 +78,8 @@ public class IndexDeleteRequest extends IndexReplicationOperationRequest {
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeUTF(type);
|
||||
out.writeUTF(id);
|
||||
out.writeString(type);
|
||||
out.writeString(id);
|
||||
out.writeBoolean(refresh);
|
||||
out.writeLong(version);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|||
/**
|
||||
* Delete by query request to execute on a specific shard.
|
||||
*/
|
||||
public class ShardDeleteRequest extends ShardReplicationOperationRequest {
|
||||
public class ShardDeleteRequest extends ShardReplicationOperationRequest<ShardDeleteRequest> {
|
||||
|
||||
private int shardId;
|
||||
private String type;
|
||||
|
@ -40,6 +40,7 @@ public class ShardDeleteRequest extends ShardReplicationOperationRequest {
|
|||
private long version;
|
||||
|
||||
ShardDeleteRequest(IndexDeleteRequest request, int shardId) {
|
||||
super(request);
|
||||
this.index = request.index();
|
||||
this.shardId = shardId;
|
||||
this.type = request.type();
|
||||
|
@ -94,8 +95,8 @@ public class ShardDeleteRequest extends ShardReplicationOperationRequest {
|
|||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
shardId = in.readVInt();
|
||||
type = in.readUTF();
|
||||
id = in.readUTF();
|
||||
type = in.readString();
|
||||
id = in.readString();
|
||||
refresh = in.readBoolean();
|
||||
version = in.readLong();
|
||||
}
|
||||
|
@ -104,8 +105,8 @@ public class ShardDeleteRequest extends ShardReplicationOperationRequest {
|
|||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeVInt(shardId);
|
||||
out.writeUTF(type);
|
||||
out.writeUTF(id);
|
||||
out.writeString(type);
|
||||
out.writeString(id);
|
||||
out.writeBoolean(refresh);
|
||||
out.writeLong(version);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue