Merge branch 'master' into put_me_in_coach

This commit is contained in:
Robert Muir 2015-04-24 09:45:19 -04:00
commit 2d778df4b4
242 changed files with 3250 additions and 3855 deletions

View File

@ -78,3 +78,9 @@ Advance settings include:
# see http://en.wikipedia.org/wiki/Zero-width_joiner
\\u200D => ALPHANUM
--------------------------------------------------
NOTE: Using a tokenizer like the `standard` tokenizer may interfere with
the `catenate_*` and `preserve_original` parameters, as the original
string may already have lost punctuation during tokenization. Instead,
you may want to use the `whitespace` tokenizer.

View File

@ -302,6 +302,10 @@ the user-friendly representation of boolean fields: `false`/`true`:
]
---------------
=== Murmur3 Fields
Fields of type `murmur3` can no longer change `doc_values` or `index` setting.
They are always stored with doc values, and not indexed.
=== Codecs
It is no longer possible to specify per-field postings and doc values formats
@ -389,3 +393,10 @@ favour or `bool`.
The `execution` option of the `terms` filter is now deprecated and ignored if
provided.
=== Snapshot and Restore
The obsolete parameters `expand_wildcards_open` and `expand_wildcards_close` are no longer
supported by the snapshot and restore operations. These parameters have been replaced by
a single `expand_wildcards` parameter. See <<multi-index,the multi-index docs>> for more.

View File

@ -14,7 +14,7 @@
wait_for_status: yellow
- do:
catch: /RoutingMissingException/
catch: /routing_missing_exception/
create:
index: test_1
type: test

View File

@ -89,7 +89,7 @@
type: test
id: 1
- do:
catch: /AlreadyExpiredException/
catch: /already_expired_exception/
create:
index: test_1
type: test

View File

@ -21,7 +21,7 @@
body: { foo: bar }
- do:
catch: /RoutingMissingException/
catch: /routing_missing_exception/
delete:
index: test_1
type: test

View File

@ -13,7 +13,7 @@
wait_for_status: yellow
- do:
catch: /RoutingMissingException/
catch: /routing_missing_exception/
index:
index: test_1
type: test

View File

@ -74,7 +74,7 @@
# with timestamp
- do:
catch: /AlreadyExpiredException/
catch: /already_expired_exception/
index:
index: test_1
type: test

View File

@ -13,27 +13,27 @@
wait_for_status: yellow
- do:
catch: /ActionRequestValidationException.+ id is missing/
catch: /action_request_validation_exception.+ id is missing/
mget:
body:
docs:
- { _index: test_1, _type: test}
- do:
catch: /ActionRequestValidationException.+ index is missing/
catch: /action_request_validation_exception.+ index is missing/
mget:
body:
docs:
- { _type: test, _id: 1}
- do:
catch: /ActionRequestValidationException.+ no documents to get/
catch: /action_request_validation_exception.+ no documents to get/
mget:
body:
docs: []
- do:
catch: /ActionRequestValidationException.+ no documents to get/
catch: /action_request_validation_exception.+ no documents to get/
mget:
body: {}

View File

@ -59,14 +59,14 @@
- do:
catch: /ActionRequestValidationException.+ no documents to get/
catch: /action_request_validation_exception.+ no documents to get/
mget:
index: test_1
body:
ids: []
- do:
catch: /ActionRequestValidationException.+ no documents to get/
catch: /action_request_validation_exception.+ no documents to get/
mget:
index: test_1
body: {}

View File

@ -37,5 +37,5 @@
foo: bar
- match: { responses.0.total: 1 }
- match: { responses.1.error: "IndexMissingException[[percolator_index1] missing]" }
- match: { responses.1.error: "/IndexMissingException.no.such.index./" }
- match: { responses.2.total: 1 }

View File

@ -39,7 +39,7 @@
match: {foo: bar}
- match: { responses.0.hits.total: 3 }
- match: { responses.1.error: "IndexMissingException[[test_2] missing]" }
- match: { responses.1.error: "/IndexMissingException.no.such.index./" }
- match: { responses.2.hits.total: 1 }

View File

@ -60,7 +60,7 @@
- do:
catch: /ElasticsearchIllegalArgumentException.Unable.to.parse.*/
catch: /Unable.to.parse.*/
put_script:
id: "1"
lang: "groovy"
@ -74,7 +74,7 @@
body: { "script" : "_score * doc[\"myParent.weight\"].value" }
- do:
catch: /ElasticsearchIllegalArgumentException.script_lang.not.supported/
catch: /script_lang.not.supported/
put_script:
id: "1"
lang: "foobar"

View File

@ -50,7 +50,7 @@
body: { "template": { "query": { "match{{}}_all": {}}, "size": "{{my_size}}" } }
- do:
catch: /ElasticsearchIllegalArgumentException\SUnable\sto\sparse.*/
catch: /Unable\sto\sparse.*/
put_template:
id: "1"
body: { "template": { "query": { "match{{}}_all": {}}, "size": "{{my_size}}" } }

View File

@ -37,7 +37,7 @@
- match: { hits.total: 1 }
- do:
catch: /ElasticsearchIllegalArgumentException.Unable.to.find.on.disk.script.simple1/
catch: /Unable.to.find.on.disk.script.simple1/
search_template:
body: { "template" : "simple1" }

View File

@ -15,7 +15,7 @@ setup:
"Parent":
- do:
catch: /RoutingMissingException/
catch: /routing_missing_exception/
update:
index: test_1
type: test

View File

@ -81,7 +81,7 @@
# with timestamp
- do:
catch: /AlreadyExpiredException/
catch: /already_expired_exception/
index:
index: test_1
type: test

View File

@ -22,18 +22,23 @@ package org.elasticsearch;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.HasRestHeaders;
import org.elasticsearch.rest.RestStatus;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* A base class for all elasticsearch exceptions.
*/
public class ElasticsearchException extends RuntimeException {
public class ElasticsearchException extends RuntimeException implements ToXContent {
public static final String REST_EXCEPTION_SKIP_CAUSE = "rest.exception.skip_cause";
/**
* Construct a <code>ElasticsearchException</code> with the specified detail message.
@ -62,12 +67,8 @@ public class ElasticsearchException extends RuntimeException {
Throwable cause = unwrapCause();
if (cause == this) {
return RestStatus.INTERNAL_SERVER_ERROR;
} else if (cause instanceof ElasticsearchException) {
return ((ElasticsearchException) cause).status();
} else if (cause instanceof IllegalArgumentException) {
return RestStatus.BAD_REQUEST;
} else {
return RestStatus.INTERNAL_SERVER_ERROR;
return ExceptionsHelper.status(cause);
}
}
@ -114,19 +115,6 @@ public class ElasticsearchException extends RuntimeException {
return rootCause;
}
/**
* Retrieve the most specific cause of this exception, that is,
* either the innermost cause (root cause) or this exception itself.
* <p>Differs from {@link #getRootCause()} in that it falls back
* to the present exception if there is no root cause.
*
* @return the most specific cause (never <code>null</code>)
*/
public Throwable getMostSpecificCause() {
Throwable rootCause = getRootCause();
return (rootCause != null ? rootCause : this);
}
/**
* Check whether this exception contains an exception of the given type:
* either it is of the given class itself or it contains a nested cause
@ -175,21 +163,6 @@ public class ElasticsearchException extends RuntimeException {
this.headers = headers(headers);
}
public WithRestHeaders(String msg, @Nullable ImmutableMap<String, List<String>> headers) {
super(msg);
this.headers = headers != null ? headers : ImmutableMap.<String, List<String>>of();
}
public WithRestHeaders(String msg, Throwable cause, Tuple<String, String[]>... headers) {
super(msg, cause);
this.headers = headers(headers);
}
public WithRestHeaders(String msg, Throwable cause, @Nullable ImmutableMap<String, List<String>> headers) {
super(msg, cause);
this.headers = headers != null ? headers : ImmutableMap.<String, List<String>>of();
}
@Override
public ImmutableMap<String, List<String>> getHeaders() {
return headers;
@ -215,4 +188,97 @@ public class ElasticsearchException extends RuntimeException {
return ImmutableMap.copyOf(map);
}
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (this instanceof ElasticsearchWrapperException) {
toXContent(builder, params, this);
} else {
builder.field("type", getExceptionName(this));
builder.field("reason", getMessage());
innerToXContent(builder, params);
}
return builder;
}
/**
* Renders additional per exception information into the xcontent
*/
protected void innerToXContent(XContentBuilder builder, Params params) throws IOException {
causeToXContent(builder, params);
}
/**
* Renders a cause exception as xcontent
*/
protected final void causeToXContent(XContentBuilder builder, Params params) throws IOException {
final Throwable cause = getCause();
if (cause != null && params.paramAsBoolean(REST_EXCEPTION_SKIP_CAUSE, false) == false) {
builder.field("caused_by");
builder.startObject();
toXContent(builder, params, cause);
builder.endObject();
}
}
/**
* Statis toXContent helper method that also renders non {@link org.elasticsearch.ElasticsearchException} instances as XContent.
*/
public static void toXContent(XContentBuilder builder, Params params, Throwable ex) throws IOException {
ex = ExceptionsHelper.unwrapCause(ex);
if (ex instanceof ElasticsearchException) {
((ElasticsearchException) ex).toXContent(builder, params);
} else {
builder.field("type", getExceptionName(ex));
builder.field("reason", ex.getMessage());
if (ex.getCause() != null) {
builder.field("caused_by");
builder.startObject();
toXContent(builder, params, ex.getCause());
builder.endObject();
}
}
}
/**
* Returns the root cause of this exception or mupltiple if different shards caused different exceptions
*/
public ElasticsearchException[] guessRootCauses() {
final Throwable cause = getCause();
if (cause != null && cause instanceof ElasticsearchException) {
return ((ElasticsearchException) cause).guessRootCauses();
}
return new ElasticsearchException[] {this};
}
/**
* Returns the root cause of this exception or mupltiple if different shards caused different exceptions.
* If the given exception is not an instance of {@link org.elasticsearch.ElasticsearchException} an empty array
* is returned.
*/
public static ElasticsearchException[] guessRootCauses(Throwable t) {
Throwable ex = ExceptionsHelper.unwrapCause(t);
if (ex instanceof ElasticsearchException) {
return ((ElasticsearchException) ex).guessRootCauses();
}
return new ElasticsearchException[0];
}
/**
* Returns a underscore case name for the given exception. This method strips <tt>Elasticsearch</tt> prefixes from exception names.
*/
public static String getExceptionName(Throwable ex) {
String simpleName = ex.getClass().getSimpleName();
if (simpleName.startsWith("Elasticsearch")) {
simpleName = simpleName.substring("Elasticsearch".length());
}
return Strings.toUnderscoreCase(simpleName);
}
@Override
public String toString() {
return ExceptionsHelper.detailedMessage(this).trim();
}
}

View File

@ -54,8 +54,12 @@ public final class ExceptionsHelper {
}
public static RestStatus status(Throwable t) {
if (t != null) {
if (t instanceof ElasticsearchException) {
return ((ElasticsearchException) t).status();
} else if (t instanceof IllegalArgumentException) {
return RestStatus.BAD_REQUEST;
}
}
return RestStatus.INTERNAL_SERVER_ERROR;
}

View File

@ -19,6 +19,9 @@
package org.elasticsearch.action;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.bootstrap.Elasticsearch;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@ -164,15 +167,15 @@ public abstract class ActionWriteResponse extends ActionResponse {
private String index;
private int shardId;
private String nodeId;
private String reason;
private Throwable cause;
private RestStatus status;
private boolean primary;
public Failure(String index, int shardId, @Nullable String nodeId, String reason, RestStatus status, boolean primary) {
public Failure(String index, int shardId, @Nullable String nodeId, Throwable cause, RestStatus status, boolean primary) {
this.index = index;
this.shardId = shardId;
this.nodeId = nodeId;
this.reason = reason;
this.cause = cause;
this.status = status;
this.primary = primary;
}
@ -209,7 +212,7 @@ public abstract class ActionWriteResponse extends ActionResponse {
*/
@Override
public String reason() {
return reason;
return ExceptionsHelper.detailedMessage(cause);
}
/**
@ -233,7 +236,7 @@ public abstract class ActionWriteResponse extends ActionResponse {
index = in.readString();
shardId = in.readVInt();
nodeId = in.readOptionalString();
reason = in.readString();
cause = in.readThrowable();
status = RestStatus.readFrom(in);
primary = in.readBoolean();
}
@ -243,7 +246,7 @@ public abstract class ActionWriteResponse extends ActionResponse {
out.writeString(index);
out.writeVInt(shardId);
out.writeOptionalString(nodeId);
out.writeString(reason);
out.writeThrowable(cause);
RestStatus.writeTo(out, status);
out.writeBoolean(primary);
}
@ -254,7 +257,10 @@ public abstract class ActionWriteResponse extends ActionResponse {
builder.field(Fields._INDEX, index);
builder.field(Fields._SHARD, shardId);
builder.field(Fields._NODE, nodeId);
builder.field(Fields.REASON, reason);
builder.field(Fields.REASON);
builder.startObject();
ElasticsearchException.toXContent(builder, params, cause);
builder.endObject();
builder.field(Fields.STATUS, status);
builder.field(Fields.PRIMARY, primary);
builder.endObject();

View File

@ -45,7 +45,7 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadOperati
@Inject
public TransportClusterHealthAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
ClusterName clusterName, ActionFilters actionFilters) {
super(settings, ClusterHealthAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, ClusterHealthAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterHealthRequest.class);
this.clusterName = clusterName;
}
@ -60,11 +60,6 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadOperati
return null; // we want users to be able to call this even when there are global blocks, just to check the health (are there blocks?)
}
@Override
protected ClusterHealthRequest newRequest() {
return new ClusterHealthRequest();
}
@Override
protected ClusterHealthResponse newResponse() {
return new ClusterHealthResponse();

View File

@ -38,6 +38,11 @@ public class NodesHotThreadsRequest extends NodesOperationRequest<NodesHotThread
int snapshots = 10;
boolean ignoreIdleThreads = true;
// for serialization
NodesHotThreadsRequest() {
}
/**
* Get hot threads from nodes based on the nodes ids specified. If none are passed, hot
* threads for all nodes is used.

View File

@ -46,12 +46,8 @@ public class TransportNodesHotThreadsAction extends TransportNodesOperationActio
@Inject
public TransportNodesHotThreadsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService, ActionFilters actionFilters) {
super(settings, NodesHotThreadsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters);
}
@Override
protected String executor() {
return ThreadPool.Names.GENERIC;
super(settings, NodesHotThreadsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
NodesHotThreadsRequest.class, NodeRequest.class, ThreadPool.Names.GENERIC);
}
@Override
@ -66,16 +62,6 @@ public class TransportNodesHotThreadsAction extends TransportNodesOperationActio
return new NodesHotThreadsResponse(clusterName, nodes.toArray(new NodeHotThreads[nodes.size()]));
}
@Override
protected NodesHotThreadsRequest newRequestInstance() {
return new NodesHotThreadsRequest();
}
@Override
protected NodeRequest newNodeRequest() {
return new NodeRequest();
}
@Override
protected NodeRequest newNodeRequest(String nodeId, NodesHotThreadsRequest request) {
return new NodeRequest(nodeId, request);

View File

@ -49,15 +49,11 @@ public class TransportNodesInfoAction extends TransportNodesOperationAction<Node
public TransportNodesInfoAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService,
NodeService nodeService, ActionFilters actionFilters) {
super(settings, NodesInfoAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters);
super(settings, NodesInfoAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
NodesInfoRequest.class, NodeInfoRequest.class, ThreadPool.Names.MANAGEMENT);
this.nodeService = nodeService;
}
@Override
protected String executor() {
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected NodesInfoResponse newResponse(NodesInfoRequest nodesInfoRequest, AtomicReferenceArray responses) {
final List<NodeInfo> nodesInfos = new ArrayList<>();
@ -70,16 +66,6 @@ public class TransportNodesInfoAction extends TransportNodesOperationAction<Node
return new NodesInfoResponse(clusterName, nodesInfos.toArray(new NodeInfo[nodesInfos.size()]));
}
@Override
protected NodesInfoRequest newRequestInstance() {
return new NodesInfoRequest();
}
@Override
protected NodeInfoRequest newNodeRequest() {
return new NodeInfoRequest();
}
@Override
protected NodeInfoRequest newNodeRequest(String nodeId, NodesInfoRequest request) {
return new NodeInfoRequest(nodeId, request);

View File

@ -26,7 +26,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.*;
public final class TransportLivenessAction extends BaseTransportRequestHandler<LivenessRequest> {
public final class TransportLivenessAction implements TransportRequestHandler<LivenessRequest> {
private final ClusterService clusterService;
private final ClusterName clusterName;
@ -37,21 +37,11 @@ public final class TransportLivenessAction extends BaseTransportRequestHandler<L
ClusterService clusterService, TransportService transportService) {
this.clusterService = clusterService;
this.clusterName = clusterName;
transportService.registerHandler(NAME, this);
}
@Override
public LivenessRequest newInstance() {
return new LivenessRequest();
transportService.registerRequestHandler(NAME, LivenessRequest.class, ThreadPool.Names.SAME, this);
}
@Override
public void messageReceived(LivenessRequest request, TransportChannel channel) throws Exception {
channel.sendResponse(new LivenessResponse(clusterName, clusterService.localNode()));
}
@Override
public String executor() {
return ThreadPool.Names.SAME;
}
}

View File

@ -59,13 +59,13 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
@Inject
public TransportNodesShutdownAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
Node node, ClusterName clusterName, ActionFilters actionFilters) {
super(settings, NodesShutdownAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, NodesShutdownAction.NAME, transportService, clusterService, threadPool, actionFilters, NodesShutdownRequest.class);
this.node = node;
this.clusterName = clusterName;
this.disabled = settings.getAsBoolean("action.disable_shutdown", this.settings.getAsBoolean("action.admin.cluster.node.shutdown.disabled", false));
this.delay = this.settings.getAsTime("action.admin.cluster.node.shutdown.delay", TimeValue.timeValueMillis(200));
this.transportService.registerHandler(SHUTDOWN_NODE_ACTION_NAME, new NodeShutdownRequestHandler());
this.transportService.registerRequestHandler(SHUTDOWN_NODE_ACTION_NAME, NodeShutdownRequest.class, ThreadPool.Names.SAME, new NodeShutdownRequestHandler());
}
@Override
@ -79,11 +79,6 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
}
@Override
protected NodesShutdownRequest newRequest() {
return new NodesShutdownRequest();
}
@Override
protected NodesShutdownResponse newResponse() {
return new NodesShutdownResponse();
@ -229,17 +224,7 @@ public class TransportNodesShutdownAction extends TransportMasterNodeOperationAc
listener.onResponse(new NodesShutdownResponse(clusterName, nodes.toArray(DiscoveryNode.class)));
}
private class NodeShutdownRequestHandler extends BaseTransportRequestHandler<NodeShutdownRequest> {
@Override
public NodeShutdownRequest newInstance() {
return new NodeShutdownRequest();
}
@Override
public String executor() {
return ThreadPool.Names.SAME;
}
private class NodeShutdownRequestHandler implements TransportRequestHandler<NodeShutdownRequest> {
@Override
public void messageReceived(final NodeShutdownRequest request, TransportChannel channel) throws Exception {

View File

@ -49,15 +49,11 @@ public class TransportNodesStatsAction extends TransportNodesOperationAction<Nod
public TransportNodesStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService,
NodeService nodeService, ActionFilters actionFilters) {
super(settings, NodesStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters);
super(settings, NodesStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
NodesStatsRequest.class, NodeStatsRequest.class, ThreadPool.Names.MANAGEMENT);
this.nodeService = nodeService;
}
@Override
protected String executor() {
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected NodesStatsResponse newResponse(NodesStatsRequest nodesInfoRequest, AtomicReferenceArray responses) {
final List<NodeStats> nodeStats = Lists.newArrayList();
@ -70,16 +66,6 @@ public class TransportNodesStatsAction extends TransportNodesOperationAction<Nod
return new NodesStatsResponse(clusterName, nodeStats.toArray(new NodeStats[nodeStats.size()]));
}
@Override
protected NodesStatsRequest newRequestInstance() {
return new NodesStatsRequest();
}
@Override
protected NodeStatsRequest newNodeRequest() {
return new NodeStatsRequest();
}
@Override
protected NodeStatsRequest newNodeRequest(String nodeId, NodesStatsRequest request) {
return new NodeStatsRequest(nodeId, request);

View File

@ -44,7 +44,7 @@ public class TransportDeleteRepositoryAction extends TransportMasterNodeOperatio
@Inject
public TransportDeleteRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, DeleteRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, DeleteRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteRepositoryRequest.class);
this.repositoriesService = repositoriesService;
}
@ -53,11 +53,6 @@ public class TransportDeleteRepositoryAction extends TransportMasterNodeOperatio
return ThreadPool.Names.SAME;
}
@Override
protected DeleteRepositoryRequest newRequest() {
return new DeleteRepositoryRequest();
}
@Override
protected DeleteRepositoryResponse newResponse() {
return new DeleteRepositoryResponse();

View File

@ -45,7 +45,7 @@ public class TransportGetRepositoriesAction extends TransportMasterNodeReadOpera
@Inject
public TransportGetRepositoriesAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, GetRepositoriesAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, GetRepositoriesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetRepositoriesRequest.class);
}
@Override
@ -53,11 +53,6 @@ public class TransportGetRepositoriesAction extends TransportMasterNodeReadOpera
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected GetRepositoriesRequest newRequest() {
return new GetRepositoriesRequest();
}
@Override
protected GetRepositoriesResponse newResponse() {
return new GetRepositoriesResponse();

View File

@ -44,7 +44,7 @@ public class TransportPutRepositoryAction extends TransportMasterNodeOperationAc
@Inject
public TransportPutRepositoryAction(Settings settings, TransportService transportService, ClusterService clusterService,
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, PutRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, PutRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, PutRepositoryRequest.class);
this.repositoriesService = repositoriesService;
}
@ -53,11 +53,6 @@ public class TransportPutRepositoryAction extends TransportMasterNodeOperationAc
return ThreadPool.Names.SAME;
}
@Override
protected PutRepositoryRequest newRequest() {
return new PutRepositoryRequest();
}
@Override
protected PutRepositoryResponse newResponse() {
return new PutRepositoryResponse();

View File

@ -47,7 +47,7 @@ public class TransportVerifyRepositoryAction extends TransportMasterNodeOperatio
@Inject
public TransportVerifyRepositoryAction(Settings settings, ClusterName clusterName, TransportService transportService, ClusterService clusterService,
RepositoriesService repositoriesService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, VerifyRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, VerifyRepositoryAction.NAME, transportService, clusterService, threadPool, actionFilters, VerifyRepositoryRequest.class);
this.repositoriesService = repositoriesService;
this.clusterName = clusterName;
}
@ -57,11 +57,6 @@ public class TransportVerifyRepositoryAction extends TransportMasterNodeOperatio
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected VerifyRepositoryRequest newRequest() {
return new VerifyRepositoryRequest();
}
@Override
protected VerifyRepositoryResponse newResponse() {
return new VerifyRepositoryResponse();

View File

@ -46,7 +46,7 @@ public class TransportClusterRerouteAction extends TransportMasterNodeOperationA
@Inject
public TransportClusterRerouteAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
AllocationService allocationService, ActionFilters actionFilters) {
super(settings, ClusterRerouteAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, ClusterRerouteAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterRerouteRequest.class);
this.allocationService = allocationService;
}
@ -61,11 +61,6 @@ public class TransportClusterRerouteAction extends TransportMasterNodeOperationA
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
}
@Override
protected ClusterRerouteRequest newRequest() {
return new ClusterRerouteRequest();
}
@Override
protected ClusterRerouteResponse newResponse() {
return new ClusterRerouteResponse();

View File

@ -59,7 +59,7 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeOpe
@Inject
public TransportClusterUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
AllocationService allocationService, @ClusterDynamicSettings DynamicSettings dynamicSettings, ActionFilters actionFilters) {
super(settings, ClusterUpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, ClusterUpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterUpdateSettingsRequest.class);
this.allocationService = allocationService;
this.dynamicSettings = dynamicSettings;
}
@ -80,11 +80,6 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeOpe
}
@Override
protected ClusterUpdateSettingsRequest newRequest() {
return new ClusterUpdateSettingsRequest();
}
@Override
protected ClusterUpdateSettingsResponse newResponse() {
return new ClusterUpdateSettingsResponse();

View File

@ -47,7 +47,7 @@ public class TransportClusterSearchShardsAction extends TransportMasterNodeReadO
@Inject
public TransportClusterSearchShardsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, ClusterSearchShardsAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, ClusterSearchShardsAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterSearchShardsRequest.class);
}
@Override
@ -61,11 +61,6 @@ public class TransportClusterSearchShardsAction extends TransportMasterNodeReadO
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
}
@Override
protected ClusterSearchShardsRequest newRequest() {
return new ClusterSearchShardsRequest();
}
@Override
protected ClusterSearchShardsResponse newResponse() {
return new ClusterSearchShardsResponse();

View File

@ -371,10 +371,6 @@ public class CreateSnapshotRequest extends MasterNodeOperationRequest<CreateSnap
* @return this request
*/
public CreateSnapshotRequest source(Map source) {
boolean ignoreUnavailable = IndicesOptions.lenientExpandOpen().ignoreUnavailable();
boolean allowNoIndices = IndicesOptions.lenientExpandOpen().allowNoIndices();
boolean expandWildcardsOpen = IndicesOptions.lenientExpandOpen().expandWildcardsOpen();
boolean expandWildcardsClosed = IndicesOptions.lenientExpandOpen().expandWildcardsClosed();
for (Map.Entry<String, Object> entry : ((Map<String, Object>) source).entrySet()) {
String name = entry.getKey();
if (name.equals("indices")) {
@ -385,10 +381,6 @@ public class CreateSnapshotRequest extends MasterNodeOperationRequest<CreateSnap
} else {
throw new ElasticsearchIllegalArgumentException("malformed indices section, should be an array of strings");
}
} else if (name.equals("expand_wildcards_open") || name.equals("expandWildcardsOpen")) {
expandWildcardsOpen = nodeBooleanValue(entry.getValue());
} else if (name.equals("expand_wildcards_closed") || name.equals("expandWildcardsClosed")) {
expandWildcardsClosed = nodeBooleanValue(entry.getValue());
} else if (name.equals("partial")) {
partial(nodeBooleanValue(entry.getValue()));
} else if (name.equals("settings")) {
@ -400,7 +392,7 @@ public class CreateSnapshotRequest extends MasterNodeOperationRequest<CreateSnap
includeGlobalState = nodeBooleanValue(entry.getValue());
}
}
indicesOptions(IndicesOptions.fromMap((Map<String, Object>) source, IndicesOptions.fromOptions(ignoreUnavailable, allowNoIndices, expandWildcardsOpen, expandWildcardsClosed)));
indicesOptions(IndicesOptions.fromMap((Map<String, Object>) source, IndicesOptions.lenientExpandOpen()));
return this;
}

View File

@ -44,7 +44,7 @@ public class TransportCreateSnapshotAction extends TransportMasterNodeOperationA
@Inject
public TransportCreateSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters) {
super(settings, CreateSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, CreateSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, CreateSnapshotRequest.class);
this.snapshotsService = snapshotsService;
}
@ -53,11 +53,6 @@ public class TransportCreateSnapshotAction extends TransportMasterNodeOperationA
return ThreadPool.Names.SNAPSHOT;
}
@Override
protected CreateSnapshotRequest newRequest() {
return new CreateSnapshotRequest();
}
@Override
protected CreateSnapshotResponse newResponse() {
return new CreateSnapshotResponse();

View File

@ -43,7 +43,7 @@ public class TransportDeleteSnapshotAction extends TransportMasterNodeOperationA
@Inject
public TransportDeleteSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters) {
super(settings, DeleteSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, DeleteSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteSnapshotRequest.class);
this.snapshotsService = snapshotsService;
}
@ -52,11 +52,6 @@ public class TransportDeleteSnapshotAction extends TransportMasterNodeOperationA
return ThreadPool.Names.GENERIC;
}
@Override
protected DeleteSnapshotRequest newRequest() {
return new DeleteSnapshotRequest();
}
@Override
protected DeleteSnapshotResponse newResponse() {
return new DeleteSnapshotResponse();

View File

@ -46,7 +46,7 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeOperationAct
@Inject
public TransportGetSnapshotsAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, SnapshotsService snapshotsService, ActionFilters actionFilters) {
super(settings, GetSnapshotsAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, GetSnapshotsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetSnapshotsRequest.class);
this.snapshotsService = snapshotsService;
}
@ -55,11 +55,6 @@ public class TransportGetSnapshotsAction extends TransportMasterNodeOperationAct
return ThreadPool.Names.GENERIC;
}
@Override
protected GetSnapshotsRequest newRequest() {
return new GetSnapshotsRequest();
}
@Override
protected GetSnapshotsResponse newResponse() {
return new GetSnapshotsResponse();

View File

@ -504,11 +504,6 @@ public class RestoreSnapshotRequest extends MasterNodeOperationRequest<RestoreSn
* @return this request
*/
public RestoreSnapshotRequest source(Map source) {
boolean ignoreUnavailable = IndicesOptions.lenientExpandOpen().ignoreUnavailable();
boolean allowNoIndices = IndicesOptions.lenientExpandOpen().allowNoIndices();
boolean expandWildcardsOpen = IndicesOptions.lenientExpandOpen().expandWildcardsOpen();
boolean expandWildcardsClosed = IndicesOptions.lenientExpandOpen().expandWildcardsClosed();
for (Map.Entry<String, Object> entry : ((Map<String, Object>) source).entrySet()) {
String name = entry.getKey();
if (name.equals("indices")) {
@ -519,10 +514,6 @@ public class RestoreSnapshotRequest extends MasterNodeOperationRequest<RestoreSn
} else {
throw new ElasticsearchIllegalArgumentException("malformed indices section, should be an array of strings");
}
} else if (name.equals("expand_wildcards_open") || name.equals("expandWildcardsOpen")) {
expandWildcardsOpen = nodeBooleanValue(entry.getValue());
} else if (name.equals("expand_wildcards_closed") || name.equals("expandWildcardsClosed")) {
expandWildcardsClosed = nodeBooleanValue(entry.getValue());
} else if (name.equals("partial")) {
partial(nodeBooleanValue(entry.getValue()));
} else if (name.equals("settings")) {
@ -563,7 +554,7 @@ public class RestoreSnapshotRequest extends MasterNodeOperationRequest<RestoreSn
throw new ElasticsearchIllegalArgumentException("Unknown parameter " + name);
}
}
indicesOptions(IndicesOptions.fromMap((Map<String, Object>) source, IndicesOptions.fromOptions(ignoreUnavailable, allowNoIndices, expandWildcardsOpen, expandWildcardsClosed)));
indicesOptions(IndicesOptions.fromMap((Map<String, Object>) source, IndicesOptions.lenientExpandOpen()));
return this;
}

View File

@ -44,7 +44,7 @@ public class TransportRestoreSnapshotAction extends TransportMasterNodeOperation
@Inject
public TransportRestoreSnapshotAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, RestoreService restoreService, ActionFilters actionFilters) {
super(settings, RestoreSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, RestoreSnapshotAction.NAME, transportService, clusterService, threadPool, actionFilters, RestoreSnapshotRequest.class);
this.restoreService = restoreService;
}
@ -53,11 +53,6 @@ public class TransportRestoreSnapshotAction extends TransportMasterNodeOperation
return ThreadPool.Names.SNAPSHOT;
}
@Override
protected RestoreSnapshotRequest newRequest() {
return new RestoreSnapshotRequest();
}
@Override
protected RestoreSnapshotResponse newResponse() {
return new RestoreSnapshotResponse();

View File

@ -55,30 +55,16 @@ public class TransportNodesSnapshotsStatus extends TransportNodesOperationAction
@Inject
public TransportNodesSnapshotsStatus(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, SnapshotsService snapshotsService, ActionFilters actionFilters) {
super(settings, ACTION_NAME, clusterName, threadPool, clusterService, transportService, actionFilters);
super(settings, ACTION_NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
Request.class, NodeRequest.class, ThreadPool.Names.GENERIC);
this.snapshotsService = snapshotsService;
}
@Override
protected String executor() {
return ThreadPool.Names.GENERIC;
}
@Override
protected boolean transportCompress() {
return true; // compress since the metadata can become large
}
@Override
protected Request newRequestInstance() {
return new Request();
}
@Override
protected NodeRequest newNodeRequest() {
return new NodeRequest();
}
@Override
protected NodeRequest newNodeRequest(String nodeId, Request request) {
return new NodeRequest(nodeId, request);

View File

@ -58,7 +58,7 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeOperation
@Inject
public TransportSnapshotsStatusAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, SnapshotsService snapshotsService, TransportNodesSnapshotsStatus transportNodesSnapshotsStatus, ActionFilters actionFilters) {
super(settings, SnapshotsStatusAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, SnapshotsStatusAction.NAME, transportService, clusterService, threadPool, actionFilters, SnapshotsStatusRequest.class);
this.snapshotsService = snapshotsService;
this.transportNodesSnapshotsStatus = transportNodesSnapshotsStatus;
}
@ -73,11 +73,6 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeOperation
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
}
@Override
protected SnapshotsStatusRequest newRequest() {
return new SnapshotsStatusRequest();
}
@Override
protected SnapshotsStatusResponse newResponse() {
return new SnapshotsStatusResponse();

View File

@ -54,7 +54,7 @@ public class TransportClusterStateAction extends TransportMasterNodeReadOperatio
@Inject
public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
ClusterName clusterName, ActionFilters actionFilters) {
super(settings, ClusterStateAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, ClusterStateAction.NAME, transportService, clusterService, threadPool, actionFilters, ClusterStateRequest.class);
this.clusterName = clusterName;
}
@ -73,11 +73,6 @@ public class TransportClusterStateAction extends TransportMasterNodeReadOperatio
return null;
}
@Override
protected ClusterStateRequest newRequest() {
return new ClusterStateRequest();
}
@Override
protected ClusterStateResponse newResponse() {
return new ClusterStateResponse();

View File

@ -30,6 +30,9 @@ import java.io.IOException;
*/
public class ClusterStatsRequest extends NodesOperationRequest<ClusterStatsRequest> {
ClusterStatsRequest() {
}
/**
* Get stats from nodes based on the nodes ids specified. If none are passed, stats
* based on all nodes will be returned.

View File

@ -67,16 +67,12 @@ public class TransportClusterStatsAction extends TransportNodesOperationAction<C
public TransportClusterStatsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
ClusterService clusterService, TransportService transportService,
NodeService nodeService, IndicesService indicesService, ActionFilters actionFilters) {
super(settings, ClusterStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters);
super(settings, ClusterStatsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
ClusterStatsRequest.class, ClusterStatsNodeRequest.class, ThreadPool.Names.MANAGEMENT);
this.nodeService = nodeService;
this.indicesService = indicesService;
}
@Override
protected String executor() {
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected ClusterStatsResponse newResponse(ClusterStatsRequest clusterStatsRequest, AtomicReferenceArray responses) {
final List<ClusterStatsNodeResponse> nodeStats = new ArrayList<>(responses.length());
@ -90,16 +86,6 @@ public class TransportClusterStatsAction extends TransportNodesOperationAction<C
clusterService.state().metaData().uuid(), nodeStats.toArray(new ClusterStatsNodeResponse[nodeStats.size()]));
}
@Override
protected ClusterStatsRequest newRequestInstance() {
return new ClusterStatsRequest();
}
@Override
protected ClusterStatsNodeRequest newNodeRequest() {
return new ClusterStatsNodeRequest();
}
@Override
protected ClusterStatsNodeRequest newNodeRequest(String nodeId, ClusterStatsRequest request) {
return new ClusterStatsNodeRequest(nodeId, request);

View File

@ -41,7 +41,7 @@ public class TransportPendingClusterTasksAction extends TransportMasterNodeReadO
@Inject
public TransportPendingClusterTasksAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters, PendingClusterTasksRequest.class);
this.clusterService = clusterService;
}
@ -56,11 +56,6 @@ public class TransportPendingClusterTasksAction extends TransportMasterNodeReadO
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
}
@Override
protected PendingClusterTasksRequest newRequest() {
return new PendingClusterTasksRequest();
}
@Override
protected PendingClusterTasksResponse newResponse() {
return new PendingClusterTasksResponse();

View File

@ -50,7 +50,7 @@ public class TransportIndicesAliasesAction extends TransportMasterNodeOperationA
@Inject
public TransportIndicesAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataIndexAliasesService indexAliasesService, ActionFilters actionFilters) {
super(settings, IndicesAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, IndicesAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, IndicesAliasesRequest.class);
this.indexAliasesService = indexAliasesService;
}
@ -60,11 +60,6 @@ public class TransportIndicesAliasesAction extends TransportMasterNodeOperationA
return ThreadPool.Names.SAME;
}
@Override
protected IndicesAliasesRequest newRequest() {
return new IndicesAliasesRequest();
}
@Override
protected IndicesAliasesResponse newResponse() {
return new IndicesAliasesResponse();

View File

@ -38,7 +38,7 @@ public class TransportAliasesExistAction extends TransportMasterNodeReadOperatio
@Inject
public TransportAliasesExistAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, AliasesExistAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, AliasesExistAction.NAME, transportService, clusterService, threadPool, actionFilters, GetAliasesRequest.class);
}
@Override
@ -52,11 +52,6 @@ public class TransportAliasesExistAction extends TransportMasterNodeReadOperatio
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
}
@Override
protected GetAliasesRequest newRequest() {
return new GetAliasesRequest();
}
@Override
protected AliasesExistResponse newResponse() {
return new AliasesExistResponse();

View File

@ -41,7 +41,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadOperationA
@Inject
public TransportGetAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, GetAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, GetAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetAliasesRequest.class);
}
@Override
@ -55,11 +55,6 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadOperationA
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
}
@Override
protected GetAliasesRequest newRequest() {
return new GetAliasesRequest();
}
@Override
protected GetAliasesResponse newResponse() {
return new GetAliasesResponse();

View File

@ -47,8 +47,6 @@ import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.BaseTransportRequestHandler;
import org.elasticsearch.transport.TransportChannel;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
@ -60,7 +58,6 @@ import java.util.List;
public class TransportAnalyzeAction extends TransportSingleCustomOperationAction<AnalyzeRequest, AnalyzeResponse> {
private final IndicesService indicesService;
private final IndicesAnalysisService indicesAnalysisService;
private static final Settings DEFAULT_SETTINGS = ImmutableSettings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
@ -68,20 +65,9 @@ public class TransportAnalyzeAction extends TransportSingleCustomOperationAction
@Inject
public TransportAnalyzeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
IndicesService indicesService, IndicesAnalysisService indicesAnalysisService, ActionFilters actionFilters) {
super(settings, AnalyzeAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, AnalyzeAction.NAME, threadPool, clusterService, transportService, actionFilters, AnalyzeRequest.class, ThreadPool.Names.INDEX);
this.indicesService = indicesService;
this.indicesAnalysisService = indicesAnalysisService;
transportService.registerHandler(AnalyzeAction.NAME, new TransportHandler());
}
@Override
protected String executor() {
return ThreadPool.Names.INDEX;
}
@Override
protected AnalyzeRequest newRequest() {
return new AnalyzeRequest();
}
@Override
@ -260,44 +246,4 @@ public class TransportAnalyzeAction extends TransportSingleCustomOperationAction
return new AnalyzeResponse(tokens);
}
private class TransportHandler extends BaseTransportRequestHandler<AnalyzeRequest> {
@Override
public AnalyzeRequest newInstance() {
return newRequest();
}
@Override
public void messageReceived(AnalyzeRequest request, final TransportChannel channel) throws Exception {
// no need to have a threaded listener since we just send back a response
request.listenerThreaded(false);
// if we have a local operation, execute it on a thread since we don't spawn
request.operationThreaded(true);
execute(request, new ActionListener<AnalyzeResponse>() {
@Override
public void onResponse(AnalyzeResponse result) {
try {
channel.sendResponse(result);
} catch (Throwable e) {
onFailure(e);
}
}
@Override
public void onFailure(Throwable e) {
try {
channel.sendResponse(e);
} catch (Exception e1) {
logger.warn("Failed to send response for get", e1);
}
}
});
}
@Override
public String executor() {
return ThreadPool.Names.SAME;
}
}
}

View File

@ -58,21 +58,12 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastOperatio
public TransportClearIndicesCacheAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
TransportService transportService, IndicesService indicesService,
IndicesQueryCache indicesQueryCache, ActionFilters actionFilters) {
super(settings, ClearIndicesCacheAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, ClearIndicesCacheAction.NAME, threadPool, clusterService, transportService, actionFilters,
ClearIndicesCacheRequest.class, ShardClearIndicesCacheRequest.class, ThreadPool.Names.MANAGEMENT);
this.indicesService = indicesService;
this.indicesQueryCache = indicesQueryCache;
}
@Override
protected String executor() {
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected ClearIndicesCacheRequest newRequestInstance() {
return new ClearIndicesCacheRequest();
}
@Override
protected ClearIndicesCacheResponse newResponse(ClearIndicesCacheRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
int successfulShards = 0;
@ -95,11 +86,6 @@ public class TransportClearIndicesCacheAction extends TransportBroadcastOperatio
return new ClearIndicesCacheResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures);
}
@Override
protected ShardClearIndicesCacheRequest newShardRequest() {
return new ShardClearIndicesCacheRequest();
}
@Override
protected ShardClearIndicesCacheRequest newShardRequest(int numShards, ShardRouting shard, ClearIndicesCacheRequest request) {
return new ShardClearIndicesCacheRequest(shard.shardId(), request);

View File

@ -47,7 +47,7 @@ public class TransportCloseIndexAction extends TransportMasterNodeOperationActio
@Inject
public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataIndexStateService indexStateService, NodeSettingsService nodeSettingsService, ActionFilters actionFilters) {
super(settings, CloseIndexAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, CloseIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, CloseIndexRequest.class);
this.indexStateService = indexStateService;
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
}
@ -58,11 +58,6 @@ public class TransportCloseIndexAction extends TransportMasterNodeOperationActio
return ThreadPool.Names.SAME;
}
@Override
protected CloseIndexRequest newRequest() {
return new CloseIndexRequest();
}
@Override
protected CloseIndexResponse newResponse() {
return new CloseIndexResponse();

View File

@ -45,7 +45,7 @@ public class TransportCreateIndexAction extends TransportMasterNodeOperationActi
@Inject
public TransportCreateIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataCreateIndexService createIndexService, ActionFilters actionFilters) {
super(settings, CreateIndexAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, CreateIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, CreateIndexRequest.class);
this.createIndexService = createIndexService;
}
@ -55,11 +55,6 @@ public class TransportCreateIndexAction extends TransportMasterNodeOperationActi
return ThreadPool.Names.SAME;
}
@Override
protected CreateIndexRequest newRequest() {
return new CreateIndexRequest();
}
@Override
protected CreateIndexResponse newResponse() {
return new CreateIndexResponse();

View File

@ -48,7 +48,7 @@ public class TransportDeleteIndexAction extends TransportMasterNodeOperationActi
public TransportDeleteIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataDeleteIndexService deleteIndexService,
NodeSettingsService nodeSettingsService, ActionFilters actionFilters) {
super(settings, DeleteIndexAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, DeleteIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteIndexRequest.class);
this.deleteIndexService = deleteIndexService;
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
}
@ -58,11 +58,6 @@ public class TransportDeleteIndexAction extends TransportMasterNodeOperationActi
return ThreadPool.Names.SAME;
}
@Override
protected DeleteIndexRequest newRequest() {
return new DeleteIndexRequest();
}
@Override
protected DeleteIndexResponse newResponse() {
return new DeleteIndexResponse();

View File

@ -37,6 +37,11 @@ public class IndicesExistsRequest extends MasterNodeReadOperationRequest<Indices
private String[] indices = Strings.EMPTY_ARRAY;
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, true);
// for serialization
IndicesExistsRequest() {
}
public IndicesExistsRequest(String... indices) {
this.indices = indices;
}

View File

@ -42,7 +42,7 @@ public class TransportIndicesExistsAction extends TransportMasterNodeReadOperati
@Inject
public TransportIndicesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, IndicesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, IndicesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, IndicesExistsRequest.class);
}
@Override
@ -51,11 +51,6 @@ public class TransportIndicesExistsAction extends TransportMasterNodeReadOperati
return ThreadPool.Names.SAME;
}
@Override
protected IndicesExistsRequest newRequest() {
return new IndicesExistsRequest();
}
@Override
protected IndicesExistsResponse newResponse() {
return new IndicesExistsResponse();

View File

@ -41,7 +41,7 @@ public class TransportTypesExistsAction extends TransportMasterNodeReadOperation
@Inject
public TransportTypesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, TypesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, TypesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, TypesExistsRequest.class);
}
@Override
@ -50,11 +50,6 @@ public class TransportTypesExistsAction extends TransportMasterNodeReadOperation
return ThreadPool.Names.SAME;
}
@Override
protected TypesExistsRequest newRequest() {
return new TypesExistsRequest();
}
@Override
protected TypesExistsResponse newResponse() {
return new TypesExistsResponse();

View File

@ -52,20 +52,11 @@ public class TransportFlushAction extends TransportBroadcastOperationAction<Flus
@Inject
public TransportFlushAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
super(settings, FlushAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, FlushAction.NAME, threadPool, clusterService, transportService, actionFilters,
FlushRequest.class, ShardFlushRequest.class, ThreadPool.Names.FLUSH);
this.indicesService = indicesService;
}
@Override
protected String executor() {
return ThreadPool.Names.FLUSH;
}
@Override
protected FlushRequest newRequestInstance() {
return new FlushRequest();
}
@Override
protected FlushResponse newResponse(FlushRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
int successfulShards = 0;
@ -88,11 +79,6 @@ public class TransportFlushAction extends TransportBroadcastOperationAction<Flus
return new FlushResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures);
}
@Override
protected ShardFlushRequest newShardRequest() {
return new ShardFlushRequest();
}
@Override
protected ShardFlushRequest newShardRequest(int numShards, ShardRouting shard, FlushRequest request) {
return new ShardFlushRequest(shard.shardId(), request);

View File

@ -49,7 +49,7 @@ public class TransportGetIndexAction extends TransportClusterInfoAction<GetIndex
@Inject
public TransportGetIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, GetIndexAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, GetIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, GetIndexRequest.class);
}
@Override
@ -63,11 +63,6 @@ public class TransportGetIndexAction extends TransportClusterInfoAction<GetIndex
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
}
@Override
protected GetIndexRequest newRequest() {
return new GetIndexRequest();
}
@Override
protected GetIndexResponse newResponse() {
return new GetIndexResponse();

View File

@ -30,7 +30,6 @@ import org.elasticsearch.common.collect.MapBuilder;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.BaseTransportRequestHandler;
import org.elasticsearch.transport.TransportChannel;
import org.elasticsearch.transport.TransportService;
@ -46,7 +45,7 @@ public class TransportGetFieldMappingsAction extends HandledTransportAction<GetF
@Inject
public TransportGetFieldMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, TransportGetFieldMappingsIndexAction shardAction, ActionFilters actionFilters) {
super(settings, GetFieldMappingsAction.NAME, threadPool, transportService, actionFilters);
super(settings, GetFieldMappingsAction.NAME, threadPool, transportService, actionFilters, GetFieldMappingsRequest.class);
this.clusterService = clusterService;
this.shardAction = shardAction;
}
@ -100,9 +99,4 @@ public class TransportGetFieldMappingsAction extends HandledTransportAction<GetF
}
return new GetFieldMappingsResponse(mergedResponses.immutableMap());
}
@Override
public GetFieldMappingsRequest newRequestInstance() {
return new GetFieldMappingsRequest();
}
}

View File

@ -53,7 +53,6 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
/**
* Transport action used to retrieve the mappings related to fields that belong to a specific index
@ -70,16 +69,11 @@ public class TransportGetFieldMappingsIndexAction extends TransportSingleCustomO
TransportService transportService,
IndicesService indicesService,
ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, GetFieldMappingsIndexRequest.class, ThreadPool.Names.MANAGEMENT);
this.clusterService = clusterService;
this.indicesService = indicesService;
}
@Override
protected String executor() {
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected boolean resolveIndex(GetFieldMappingsIndexRequest request) {
//internal action, index already resolved
@ -126,11 +120,6 @@ public class TransportGetFieldMappingsIndexAction extends TransportSingleCustomO
return new GetFieldMappingsResponse(ImmutableMap.of(shardId.getIndex(), typeMappings.immutableMap()));
}
@Override
protected GetFieldMappingsIndexRequest newRequest() {
return new GetFieldMappingsIndexRequest();
}
@Override
protected GetFieldMappingsResponse newResponse() {
return new GetFieldMappingsResponse();

View File

@ -40,7 +40,7 @@ public class TransportGetMappingsAction extends TransportClusterInfoAction<GetMa
@Inject
public TransportGetMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, GetMappingsAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, GetMappingsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetMappingsRequest.class);
}
@Override
@ -54,11 +54,6 @@ public class TransportGetMappingsAction extends TransportClusterInfoAction<GetMa
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
}
@Override
protected GetMappingsRequest newRequest() {
return new GetMappingsRequest();
}
@Override
protected GetMappingsResponse newResponse() {
return new GetMappingsResponse();

View File

@ -44,7 +44,7 @@ public class TransportPutMappingAction extends TransportMasterNodeOperationActio
@Inject
public TransportPutMappingAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataMappingService metaDataMappingService, ActionFilters actionFilters) {
super(settings, PutMappingAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, PutMappingAction.NAME, transportService, clusterService, threadPool, actionFilters, PutMappingRequest.class);
this.metaDataMappingService = metaDataMappingService;
}
@ -54,11 +54,6 @@ public class TransportPutMappingAction extends TransportMasterNodeOperationActio
return ThreadPool.Names.SAME;
}
@Override
protected PutMappingRequest newRequest() {
return new PutMappingRequest();
}
@Override
protected PutMappingResponse newResponse() {
return new PutMappingResponse();

View File

@ -47,7 +47,7 @@ public class TransportOpenIndexAction extends TransportMasterNodeOperationAction
@Inject
public TransportOpenIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataIndexStateService indexStateService, NodeSettingsService nodeSettingsService, ActionFilters actionFilters) {
super(settings, OpenIndexAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, OpenIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, OpenIndexRequest.class);
this.indexStateService = indexStateService;
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
}
@ -58,11 +58,6 @@ public class TransportOpenIndexAction extends TransportMasterNodeOperationAction
return ThreadPool.Names.SAME;
}
@Override
protected OpenIndexRequest newRequest() {
return new OpenIndexRequest();
}
@Override
protected OpenIndexResponse newResponse() {
return new OpenIndexResponse();

View File

@ -53,20 +53,11 @@ public class TransportOptimizeAction extends TransportBroadcastOperationAction<O
@Inject
public TransportOptimizeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
super(settings, OptimizeAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, OptimizeAction.NAME, threadPool, clusterService, transportService, actionFilters,
OptimizeRequest.class, ShardOptimizeRequest.class, ThreadPool.Names.OPTIMIZE);
this.indicesService = indicesService;
}
@Override
protected String executor() {
return ThreadPool.Names.OPTIMIZE;
}
@Override
protected OptimizeRequest newRequestInstance() {
return new OptimizeRequest();
}
@Override
protected OptimizeResponse newResponse(OptimizeRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
int successfulShards = 0;
@ -89,11 +80,6 @@ public class TransportOptimizeAction extends TransportBroadcastOperationAction<O
return new OptimizeResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures);
}
@Override
protected ShardOptimizeRequest newShardRequest() {
return new ShardOptimizeRequest();
}
@Override
protected ShardOptimizeRequest newShardRequest(int numShards, ShardRouting shard, OptimizeRequest request) {
return new ShardOptimizeRequest(shard.shardId(), request);

View File

@ -52,29 +52,18 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
* Transport action for shard recovery operation. This transport action does not actually
* perform shard recovery, it only reports on recoveries (both active and complete).
*/
public class TransportRecoveryAction extends
TransportBroadcastOperationAction<RecoveryRequest, RecoveryResponse, TransportRecoveryAction.ShardRecoveryRequest, ShardRecoveryResponse> {
public class TransportRecoveryAction extends TransportBroadcastOperationAction<RecoveryRequest, RecoveryResponse, TransportRecoveryAction.ShardRecoveryRequest, ShardRecoveryResponse> {
private final IndicesService indicesService;
@Inject
public TransportRecoveryAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
super(settings, RecoveryAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, RecoveryAction.NAME, threadPool, clusterService, transportService, actionFilters,
RecoveryRequest.class, ShardRecoveryRequest.class, ThreadPool.Names.MANAGEMENT);
this.indicesService = indicesService;
}
@Override
protected String executor() {
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected RecoveryRequest newRequestInstance() {
return new RecoveryRequest();
}
@Override
protected RecoveryResponse newResponse(RecoveryRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
@ -120,14 +109,8 @@ public class TransportRecoveryAction extends
}
}
RecoveryResponse response = new RecoveryResponse(shardsResponses.length(), successfulShards,
return new RecoveryResponse(shardsResponses.length(), successfulShards,
failedShards, request.detailed(), shardResponses, shardFailures);
return response;
}
@Override
protected ShardRecoveryRequest newShardRequest() {
return new ShardRecoveryRequest();
}
@Override

View File

@ -53,20 +53,11 @@ public class TransportRefreshAction extends TransportBroadcastOperationAction<Re
@Inject
public TransportRefreshAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
TransportService transportService, IndicesService indicesService, ActionFilters actionFilters) {
super(settings, RefreshAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, RefreshAction.NAME, threadPool, clusterService, transportService, actionFilters,
RefreshRequest.class, ShardRefreshRequest.class, ThreadPool.Names.REFRESH);
this.indicesService = indicesService;
}
@Override
protected String executor() {
return ThreadPool.Names.REFRESH;
}
@Override
protected RefreshRequest newRequestInstance() {
return new RefreshRequest();
}
@Override
protected RefreshResponse newResponse(RefreshRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
int successfulShards = 0;
@ -89,11 +80,6 @@ public class TransportRefreshAction extends TransportBroadcastOperationAction<Re
return new RefreshResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures);
}
@Override
protected ShardRefreshRequest newShardRequest() {
return new ShardRefreshRequest();
}
@Override
protected ShardRefreshRequest newShardRequest(int numShards, ShardRouting shard, RefreshRequest request) {
return new ShardRefreshRequest(shard.shardId(), request);

View File

@ -59,20 +59,11 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastOperationA
@Inject
public TransportIndicesSegmentsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
IndicesService indicesService, ActionFilters actionFilters) {
super(settings, IndicesSegmentsAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, IndicesSegmentsAction.NAME, threadPool, clusterService, transportService, actionFilters,
IndicesSegmentsRequest.class, TransportIndicesSegmentsAction.IndexShardSegmentRequest.class, ThreadPool.Names.MANAGEMENT);
this.indicesService = indicesService;
}
@Override
protected String executor() {
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected IndicesSegmentsRequest newRequestInstance() {
return new IndicesSegmentsRequest();
}
/**
* Segments goes across *all* active shards.
*/
@ -115,11 +106,6 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastOperationA
return new IndicesSegmentResponse(shards.toArray(new ShardSegments[shards.size()]), clusterState, shardsResponses.length(), successfulShards, failedShards, shardFailures);
}
@Override
protected IndexShardSegmentRequest newShardRequest() {
return new IndexShardSegmentRequest();
}
@Override
protected IndexShardSegmentRequest newShardRequest(int numShards, ShardRouting shard, IndicesSegmentsRequest request) {
return new IndexShardSegmentRequest(shard.shardId(), request);

View File

@ -50,7 +50,7 @@ public class TransportGetSettingsAction extends TransportMasterNodeReadOperation
@Inject
public TransportGetSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, SettingsFilter settingsFilter, ActionFilters actionFilters) {
super(settings, GetSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, GetSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetSettingsRequest.class);
this.settingsFilter = settingsFilter;
}
@ -66,11 +66,6 @@ public class TransportGetSettingsAction extends TransportMasterNodeReadOperation
}
@Override
protected GetSettingsRequest newRequest() {
return new GetSettingsRequest();
}
@Override
protected GetSettingsResponse newResponse() {
return new GetSettingsResponse();

View File

@ -45,7 +45,7 @@ public class TransportUpdateSettingsAction extends TransportMasterNodeOperationA
@Inject
public TransportUpdateSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
MetaDataUpdateSettingsService updateSettingsService, ActionFilters actionFilters) {
super(settings, UpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, UpdateSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, UpdateSettingsRequest.class);
this.updateSettingsService = updateSettingsService;
}
@ -68,11 +68,6 @@ public class TransportUpdateSettingsAction extends TransportMasterNodeOperationA
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
}
@Override
protected UpdateSettingsRequest newRequest() {
return new UpdateSettingsRequest();
}
@Override
protected UpdateSettingsResponse newResponse() {
return new UpdateSettingsResponse();

View File

@ -60,20 +60,11 @@ public class TransportIndicesStatsAction extends TransportBroadcastOperationActi
@Inject
public TransportIndicesStatsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
IndicesService indicesService, ActionFilters actionFilters) {
super(settings, IndicesStatsAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, IndicesStatsAction.NAME, threadPool, clusterService, transportService, actionFilters,
IndicesStatsRequest.class, IndexShardStatsRequest.class, ThreadPool.Names.MANAGEMENT);
this.indicesService = indicesService;
}
@Override
protected String executor() {
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected IndicesStatsRequest newRequestInstance() {
return new IndicesStatsRequest();
}
/**
* Status goes across *all* shards.
*/
@ -117,11 +108,6 @@ public class TransportIndicesStatsAction extends TransportBroadcastOperationActi
return new IndicesStatsResponse(shards.toArray(new ShardStats[shards.size()]), clusterState, shardsResponses.length(), successfulShards, failedShards, shardFailures);
}
@Override
protected IndexShardStatsRequest newShardRequest() {
return new IndexShardStatsRequest();
}
@Override
protected IndexShardStatsRequest newShardRequest(int numShards, ShardRouting shard, IndicesStatsRequest request) {
return new IndexShardStatsRequest(shard.shardId(), request);

View File

@ -42,7 +42,7 @@ public class TransportDeleteIndexTemplateAction extends TransportMasterNodeOpera
@Inject
public TransportDeleteIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService, ActionFilters actionFilters) {
super(settings, DeleteIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, DeleteIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteIndexTemplateRequest.class);
this.indexTemplateService = indexTemplateService;
}
@ -52,11 +52,6 @@ public class TransportDeleteIndexTemplateAction extends TransportMasterNodeOpera
return ThreadPool.Names.SAME;
}
@Override
protected DeleteIndexTemplateRequest newRequest() {
return new DeleteIndexTemplateRequest();
}
@Override
protected DeleteIndexTemplateResponse newResponse() {
return new DeleteIndexTemplateResponse();

View File

@ -44,7 +44,7 @@ public class TransportGetIndexTemplatesAction extends TransportMasterNodeReadOpe
@Inject
public TransportGetIndexTemplatesAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, GetIndexTemplatesAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, GetIndexTemplatesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetIndexTemplatesRequest.class);
}
@Override
@ -57,11 +57,6 @@ public class TransportGetIndexTemplatesAction extends TransportMasterNodeReadOpe
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
}
@Override
protected GetIndexTemplatesRequest newRequest() {
return new GetIndexTemplatesRequest();
}
@Override
protected GetIndexTemplatesResponse newResponse() {
return new GetIndexTemplatesResponse();

View File

@ -42,7 +42,7 @@ public class TransportPutIndexTemplateAction extends TransportMasterNodeOperatio
@Inject
public TransportPutIndexTemplateAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, MetaDataIndexTemplateService indexTemplateService, ActionFilters actionFilters) {
super(settings, PutIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, PutIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters, PutIndexTemplateRequest.class);
this.indexTemplateService = indexTemplateService;
}
@ -52,11 +52,6 @@ public class TransportPutIndexTemplateAction extends TransportMasterNodeOperatio
return ThreadPool.Names.SAME;
}
@Override
protected PutIndexTemplateRequest newRequest() {
return new PutIndexTemplateRequest();
}
@Override
protected PutIndexTemplateResponse newResponse() {
return new PutIndexTemplateResponse();

View File

@ -76,7 +76,8 @@ public class TransportValidateQueryAction extends TransportBroadcastOperationAct
@Inject
public TransportValidateQueryAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, IndicesService indicesService, ScriptService scriptService, PageCacheRecycler pageCacheRecycler, BigArrays bigArrays, ActionFilters actionFilters) {
super(settings, ValidateQueryAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, ValidateQueryAction.NAME, threadPool, clusterService, transportService, actionFilters,
ValidateQueryRequest.class, ShardValidateQueryRequest.class, ThreadPool.Names.SEARCH);
this.indicesService = indicesService;
this.scriptService = scriptService;
this.pageCacheRecycler = pageCacheRecycler;
@ -89,21 +90,6 @@ public class TransportValidateQueryAction extends TransportBroadcastOperationAct
super.doExecute(request, listener);
}
@Override
protected String executor() {
return ThreadPool.Names.SEARCH;
}
@Override
protected ValidateQueryRequest newRequestInstance() {
return new ValidateQueryRequest();
}
@Override
protected ShardValidateQueryRequest newShardRequest() {
return new ShardValidateQueryRequest();
}
@Override
protected ShardValidateQueryRequest newShardRequest(int numShards, ShardRouting shard, ValidateQueryRequest request) {
String[] filteringAliases = clusterService.state().metaData().filteringAliases(shard.index(), request.indices());

View File

@ -52,7 +52,7 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeOperationAct
@Inject
public TransportDeleteWarmerAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, DeleteWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, DeleteWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteWarmerRequest.class);
}
@Override
@ -61,11 +61,6 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeOperationAct
return ThreadPool.Names.SAME;
}
@Override
protected DeleteWarmerRequest newRequest() {
return new DeleteWarmerRequest();
}
@Override
protected DeleteWarmerResponse newResponse() {
return new DeleteWarmerResponse();

View File

@ -44,7 +44,7 @@ public class TransportGetWarmersAction extends TransportClusterInfoAction<GetWar
@Inject
public TransportGetWarmersAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, GetWarmersAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, GetWarmersAction.NAME, transportService, clusterService, threadPool, actionFilters, GetWarmersRequest.class);
}
@Override
@ -58,11 +58,6 @@ public class TransportGetWarmersAction extends TransportClusterInfoAction<GetWar
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, state.metaData().concreteIndices(request.indicesOptions(), request.indices()));
}
@Override
protected GetWarmersRequest newRequest() {
return new GetWarmersRequest();
}
@Override
protected GetWarmersResponse newResponse() {
return new GetWarmersResponse();

View File

@ -58,7 +58,7 @@ public class TransportPutWarmerAction extends TransportMasterNodeOperationAction
@Inject
public TransportPutWarmerAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
TransportSearchAction searchAction, ActionFilters actionFilters) {
super(settings, PutWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters);
super(settings, PutWarmerAction.NAME, transportService, clusterService, threadPool, actionFilters, PutWarmerRequest.class);
this.searchAction = searchAction;
}
@ -67,11 +67,6 @@ public class TransportPutWarmerAction extends TransportMasterNodeOperationAction
return ThreadPool.Names.SAME;
}
@Override
protected PutWarmerRequest newRequest() {
return new PutWarmerRequest();
}
@Override
protected PutWarmerResponse newResponse() {
return new PutWarmerResponse();

View File

@ -51,7 +51,7 @@ public class BulkItemResponse implements Streamable {
this.index = index;
this.type = type;
this.id = id;
this.message = ExceptionsHelper.detailedMessage(t);
this.message = t.toString();
this.status = ExceptionsHelper.status(t);
}

View File

@ -21,7 +21,6 @@ package org.elasticsearch.action.bulk;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.ExceptionsHelper;
@ -68,19 +67,15 @@ import java.util.concurrent.atomic.AtomicInteger;
public class TransportBulkAction extends HandledTransportAction<BulkRequest, BulkResponse> {
private final AutoCreateIndex autoCreateIndex;
private final boolean allowIdGeneration;
private final ClusterService clusterService;
private final TransportShardBulkAction shardBulkAction;
private final TransportCreateIndexAction createIndexAction;
@Inject
public TransportBulkAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService,
TransportShardBulkAction shardBulkAction, TransportCreateIndexAction createIndexAction, ActionFilters actionFilters) {
super(settings, BulkAction.NAME, threadPool, transportService, actionFilters);
super(settings, BulkAction.NAME, threadPool, transportService, actionFilters, BulkRequest.class);
this.clusterService = clusterService;
this.shardBulkAction = shardBulkAction;
this.createIndexAction = createIndexAction;
@ -89,33 +84,39 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
this.allowIdGeneration = this.settings.getAsBoolean("action.bulk.action.allow_id_generation", true);
}
@Override
public BulkRequest newRequestInstance(){
return new BulkRequest();
}
@Override
protected void doExecute(final BulkRequest bulkRequest, final ActionListener<BulkResponse> listener) {
final long startTime = System.currentTimeMillis();
final AtomicArray<BulkItemResponse> responses = new AtomicArray<>(bulkRequest.requests.size());
if (autoCreateIndex.needToCheck()) {
final Set<String> indices = Sets.newHashSet();
// Keep track of all unique indices and all unique types per index for the create index requests:
final Map<String, Set<String>> indicesAndTypes = new HashMap<>();
for (ActionRequest request : bulkRequest.requests) {
if (request instanceof DocumentRequest) {
DocumentRequest req = (DocumentRequest) request;
if (!indices.contains(req.index())) {
indices.add(req.index());
Set<String> types = indicesAndTypes.get(req.index());
if (types == null) {
indicesAndTypes.put(req.index(), types = new HashSet<>());
}
types.add(req.type());
} else {
throw new ElasticsearchException("Parsed unknown request in bulk actions: " + request.getClass().getSimpleName());
}
}
final AtomicInteger counter = new AtomicInteger(indices.size());
final AtomicInteger counter = new AtomicInteger(indicesAndTypes.size());
ClusterState state = clusterService.state();
for (final String index : indices) {
for (Map.Entry<String, Set<String>> entry : indicesAndTypes.entrySet()) {
final String index = entry.getKey();
if (autoCreateIndex.shouldAutoCreate(index, state)) {
createIndexAction.execute(new CreateIndexRequest(bulkRequest).index(index).cause("auto(bulk api)").masterNodeTimeout(bulkRequest.timeout()), new ActionListener<CreateIndexResponse>() {
CreateIndexRequest createIndexRequest = new CreateIndexRequest(bulkRequest);
createIndexRequest.index(index);
for (String type : entry.getValue()) {
createIndexRequest.mapping(type);
}
createIndexRequest.cause("auto(bulk api)");
createIndexRequest.masterNodeTimeout(bulkRequest.timeout());
createIndexAction.execute(createIndexRequest, new ActionListener<CreateIndexResponse>() {
@Override
public void onResponse(CreateIndexResponse result) {
if (counter.decrementAndGet() == 0) {

View File

@ -56,6 +56,7 @@ import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.Mapping;
import org.elasticsearch.index.mapper.SourceToParse;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.river.RiverIndexName;
@ -83,17 +84,13 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
public TransportShardBulkAction(Settings settings, TransportService transportService, ClusterService clusterService,
IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
MappingUpdatedAction mappingUpdatedAction, UpdateHelper updateHelper, ActionFilters actionFilters) {
super(settings, ACTION_NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, actionFilters);
super(settings, ACTION_NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, actionFilters,
BulkShardRequest.class, BulkShardRequest.class, ThreadPool.Names.BULK);
this.mappingUpdatedAction = mappingUpdatedAction;
this.updateHelper = updateHelper;
this.allowIdGeneration = settings.getAsBoolean("action.allow_id_generation", true);
}
@Override
protected String executor() {
return ThreadPool.Names.BULK;
}
@Override
protected boolean checkWriteConsistency() {
return true;
@ -103,17 +100,6 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
protected TransportRequestOptions transportOptions() {
return BulkAction.INSTANCE.transportOptions(settings);
}
@Override
protected BulkShardRequest newRequestInstance() {
return new BulkShardRequest();
}
@Override
protected BulkShardRequest newReplicaRequestInstance() {
return newRequestInstance();
}
@Override
protected BulkShardResponse newResponseInstance() {
return new BulkShardResponse();
@ -157,7 +143,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
}
throw (ElasticsearchException) e;
}
if (e instanceof ElasticsearchException && ((ElasticsearchException) e).status() == RestStatus.CONFLICT) {
if (ExceptionsHelper.status(e) == RestStatus.CONFLICT) {
logger.trace("{} failed to execute bulk item (index) {}", e, shardRequest.shardId, indexRequest);
} else {
logger.debug("{} failed to execute bulk item (index) {}", e, shardRequest.shardId, indexRequest);
@ -190,7 +176,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
}
throw (ElasticsearchException) e;
}
if (e instanceof ElasticsearchException && ((ElasticsearchException) e).status() == RestStatus.CONFLICT) {
if (ExceptionsHelper.status(e) == RestStatus.CONFLICT) {
logger.trace("{} failed to execute bulk item (delete) {}", e, shardRequest.shardId, deleteRequest);
} else {
logger.debug("{} failed to execute bulk item (delete) {}", e, shardRequest.shardId, deleteRequest);
@ -279,7 +265,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
case UPSERT:
case INDEX:
IndexRequest indexRequest = updateResult.request();
if (t instanceof ElasticsearchException && ((ElasticsearchException) t).status() == RestStatus.CONFLICT) {
if (ExceptionsHelper.status(t) == RestStatus.CONFLICT) {
logger.trace("{} failed to execute bulk item (index) {}", t, shardRequest.shardId, indexRequest);
} else {
logger.debug("{} failed to execute bulk item (index) {}", t, shardRequest.shardId, indexRequest);
@ -289,7 +275,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
break;
case DELETE:
DeleteRequest deleteRequest = updateResult.request();
if (t instanceof ElasticsearchException && ((ElasticsearchException) t).status() == RestStatus.CONFLICT) {
if (ExceptionsHelper.status(t) == RestStatus.CONFLICT) {
logger.trace("{} failed to execute bulk item (delete) {}", t, shardRequest.shardId, deleteRequest);
} else {
logger.debug("{} failed to execute bulk item (delete) {}", t, shardRequest.shardId, deleteRequest);
@ -546,10 +532,9 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
@Override
protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) throws Exception {
IndexService indexService = indicesService.indexServiceSafe(shardRequest.shardId.getIndex());
IndexShard indexShard = indexService.shardSafe(shardRequest.shardId.id());
final BulkShardRequest request = shardRequest.request;
protected void shardOperationOnReplica(ShardId shardId, BulkShardRequest request) throws Exception {
IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
IndexShard indexShard = indexService.shardSafe(shardId.id());
for (int i = 0; i < request.items().length; i++) {
BulkItemRequest item = request.items()[i];
if (item == null || item.isIgnoreOnReplica()) {

View File

@ -65,18 +65,16 @@ import static org.elasticsearch.search.internal.SearchContext.DEFAULT_TERMINATE_
public class TransportCountAction extends TransportBroadcastOperationAction<CountRequest, CountResponse, ShardCountRequest, ShardCountResponse> {
private final IndicesService indicesService;
private final ScriptService scriptService;
private final PageCacheRecycler pageCacheRecycler;
private final BigArrays bigArrays;
@Inject
public TransportCountAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
IndicesService indicesService, ScriptService scriptService, PageCacheRecycler pageCacheRecycler,
BigArrays bigArrays, ActionFilters actionFilters) {
super(settings, CountAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, CountAction.NAME, threadPool, clusterService, transportService, actionFilters,
CountRequest.class, ShardCountRequest.class, ThreadPool.Names.SEARCH);
this.indicesService = indicesService;
this.scriptService = scriptService;
this.pageCacheRecycler = pageCacheRecycler;
@ -89,21 +87,6 @@ public class TransportCountAction extends TransportBroadcastOperationAction<Coun
super.doExecute(request, listener);
}
@Override
protected String executor() {
return ThreadPool.Names.SEARCH;
}
@Override
protected CountRequest newRequestInstance() {
return new CountRequest();
}
@Override
protected ShardCountRequest newShardRequest() {
return new ShardCountRequest();
}
@Override
protected ShardCountRequest newShardRequest(int numShards, ShardRouting shard, CountRequest request) {
String[] filteringAliases = clusterService.state().metaData().filteringAliases(shard.index(), request.indices());

View File

@ -40,6 +40,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.indices.IndexAlreadyExistsException;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.threadpool.ThreadPool;
@ -51,23 +52,18 @@ import org.elasticsearch.transport.TransportService;
public class TransportDeleteAction extends TransportShardReplicationOperationAction<DeleteRequest, DeleteRequest, DeleteResponse> {
private final AutoCreateIndex autoCreateIndex;
private final TransportCreateIndexAction createIndexAction;
@Inject
public TransportDeleteAction(Settings settings, TransportService transportService, ClusterService clusterService,
IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
TransportCreateIndexAction createIndexAction, ActionFilters actionFilters) {
super(settings, DeleteAction.NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, actionFilters);
super(settings, DeleteAction.NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, actionFilters,
DeleteRequest.class, DeleteRequest.class, ThreadPool.Names.INDEX);
this.createIndexAction = createIndexAction;
this.autoCreateIndex = new AutoCreateIndex(settings);
}
@Override
protected String executor() {
return ThreadPool.Names.INDEX;
}
@Override
protected void doExecute(final DeleteRequest request, final ActionListener<DeleteResponse> listener) {
if (autoCreateIndex.shouldAutoCreate(request.index(), clusterService.state())) {
@ -125,16 +121,6 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct
return true;
}
@Override
protected DeleteRequest newRequestInstance() {
return new DeleteRequest();
}
@Override
protected DeleteRequest newReplicaRequestInstance() {
return newRequestInstance();
}
@Override
protected DeleteResponse newResponseInstance() {
return new DeleteResponse();
@ -165,9 +151,8 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct
}
@Override
protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) {
DeleteRequest request = shardRequest.request;
IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.shardId.getIndex()).shardSafe(shardRequest.shardId.id());
protected void shardOperationOnReplica(ShardId shardId, DeleteRequest request) {
IndexShard indexShard = indicesService.indexServiceSafe(shardId.getIndex()).shardSafe(shardId.id());
Engine.Delete delete = indexShard.prepareDelete(request.type(), request.id(), request.version(), request.versionType(), Engine.Operation.Origin.REPLICA);
indexShard.delete(delete);

View File

@ -48,7 +48,7 @@ public class TransportDeleteByQueryAction extends TransportIndicesReplicationOpe
public TransportDeleteByQueryAction(Settings settings, ClusterService clusterService, TransportService transportService,
ThreadPool threadPool, TransportIndexDeleteByQueryAction indexDeleteByQueryAction,
NodeSettingsService nodeSettingsService, ActionFilters actionFilters) {
super(settings, DeleteByQueryAction.NAME, transportService, clusterService, threadPool, indexDeleteByQueryAction, actionFilters);
super(settings, DeleteByQueryAction.NAME, transportService, clusterService, threadPool, indexDeleteByQueryAction, actionFilters, DeleteByQueryRequest.class);
this.destructiveOperations = new DestructiveOperations(logger, settings, nodeSettingsService);
}
@ -63,11 +63,6 @@ public class TransportDeleteByQueryAction extends TransportIndicesReplicationOpe
return clusterState.metaData().resolveSearchRouting(request.routing(), request.indices());
}
@Override
protected DeleteByQueryRequest newRequestInstance() {
return new DeleteByQueryRequest();
}
@Override
protected DeleteByQueryResponse newResponseInstance(DeleteByQueryRequest request, AtomicReferenceArray indexResponses) {
DeleteByQueryResponse response = new DeleteByQueryResponse();

View File

@ -36,6 +36,7 @@ import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.query.ParsedQuery;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.internal.DefaultSearchContext;
@ -62,7 +63,8 @@ public class TransportShardDeleteByQueryAction extends TransportShardReplication
ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool,
ShardStateAction shardStateAction, ScriptService scriptService,
PageCacheRecycler pageCacheRecycler, BigArrays bigArrays, ActionFilters actionFilters) {
super(settings, ACTION_NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, actionFilters);
super(settings, ACTION_NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, actionFilters,
ShardDeleteByQueryRequest.class, ShardDeleteByQueryRequest.class, ThreadPool.Names.INDEX);
this.scriptService = scriptService;
this.pageCacheRecycler = pageCacheRecycler;
this.bigArrays = bigArrays;
@ -73,21 +75,6 @@ public class TransportShardDeleteByQueryAction extends TransportShardReplication
return true;
}
@Override
protected String executor() {
return ThreadPool.Names.INDEX;
}
@Override
protected ShardDeleteByQueryRequest newRequestInstance() {
return new ShardDeleteByQueryRequest();
}
@Override
protected ShardDeleteByQueryRequest newReplicaRequestInstance() {
return newRequestInstance();
}
@Override
protected ShardDeleteByQueryResponse newResponseInstance() {
return new ShardDeleteByQueryResponse();
@ -121,10 +108,9 @@ public class TransportShardDeleteByQueryAction extends TransportShardReplication
@Override
protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) {
ShardDeleteByQueryRequest request = shardRequest.request;
IndexService indexService = indicesService.indexServiceSafe(shardRequest.shardId.getIndex());
IndexShard indexShard = indexService.shardSafe(shardRequest.shardId.id());
protected void shardOperationOnReplica(ShardId shardId, ShardDeleteByQueryRequest request) {
IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
IndexShard indexShard = indexService.shardSafe(shardId.id());
SearchContext.setCurrent(new DefaultSearchContext(0, new ShardSearchLocalRequest(request.types(), request.nowInMillis()), null,
indexShard.acquireSearcher(DELETE_BY_QUERY_API, true), indexService, indexShard, scriptService,

View File

@ -65,18 +65,16 @@ import static org.elasticsearch.action.exists.ExistsRequest.DEFAULT_MIN_SCORE;
public class TransportExistsAction extends TransportBroadcastOperationAction<ExistsRequest, ExistsResponse, ShardExistsRequest, ShardExistsResponse> {
private final IndicesService indicesService;
private final ScriptService scriptService;
private final PageCacheRecycler pageCacheRecycler;
private final BigArrays bigArrays;
@Inject
public TransportExistsAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
IndicesService indicesService, ScriptService scriptService,
PageCacheRecycler pageCacheRecycler, BigArrays bigArrays, ActionFilters actionFilters) {
super(settings, ExistsAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, ExistsAction.NAME, threadPool, clusterService, transportService, actionFilters,
ExistsRequest.class, ShardExistsRequest.class, ThreadPool.Names.SEARCH);
this.indicesService = indicesService;
this.scriptService = scriptService;
this.pageCacheRecycler = pageCacheRecycler;
@ -89,21 +87,6 @@ public class TransportExistsAction extends TransportBroadcastOperationAction<Exi
new ExistsAsyncBroadcastAction(request, listener).start();
}
@Override
protected String executor() {
return ThreadPool.Names.SEARCH;
}
@Override
protected ExistsRequest newRequestInstance() {
return new ExistsRequest();
}
@Override
protected ShardExistsRequest newShardRequest() {
return new ShardExistsRequest();
}
@Override
protected ShardExistsRequest newShardRequest(int numShards, ShardRouting shard, ExistsRequest request) {
String[] filteringAliases = clusterService.state().metaData().filteringAliases(shard.index(), request.indices());

View File

@ -71,7 +71,8 @@ public class TransportExplainAction extends TransportShardSingleOperationAction<
TransportService transportService, IndicesService indicesService,
ScriptService scriptService, PageCacheRecycler pageCacheRecycler,
BigArrays bigArrays, ActionFilters actionFilters) {
super(settings, ExplainAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, ExplainAction.NAME, threadPool, clusterService, transportService, actionFilters,
ExplainRequest.class, ThreadPool.Names.GET);
this.indicesService = indicesService;
this.scriptService = scriptService;
this.pageCacheRecycler = pageCacheRecycler;
@ -84,11 +85,6 @@ public class TransportExplainAction extends TransportShardSingleOperationAction<
super.doExecute(request, listener);
}
@Override
protected String executor() {
return ThreadPool.Names.GET; // Or use Names.SEARCH?
}
@Override
protected boolean resolveIndex() {
return true;
@ -147,11 +143,6 @@ public class TransportExplainAction extends TransportShardSingleOperationAction<
}
}
@Override
protected ExplainRequest newRequest() {
return new ExplainRequest();
}
@Override
protected ExplainResponse newResponse() {
return new ExplainResponse();

View File

@ -59,20 +59,10 @@ public class TransportFieldStatsTransportAction extends TransportBroadcastOperat
@Inject
public TransportFieldStatsTransportAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, IndicesService indicesService) {
super(settings, FieldStatsAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, FieldStatsAction.NAME, threadPool, clusterService, transportService, actionFilters, FieldStatsRequest.class, FieldStatsShardRequest.class, ThreadPool.Names.MANAGEMENT);
this.indicesService = indicesService;
}
@Override
protected String executor() {
return ThreadPool.Names.MANAGEMENT;
}
@Override
protected FieldStatsRequest newRequestInstance() {
return new FieldStatsRequest();
}
@Override
protected FieldStatsResponse newResponse(FieldStatsRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
int successfulShards = 0;
@ -125,11 +115,6 @@ public class TransportFieldStatsTransportAction extends TransportBroadcastOperat
return new FieldStatsResponse(shardsResponses.length(), successfulShards, failedShards, shardFailures, indicesMergedFieldStats);
}
@Override
protected FieldStatsShardRequest newShardRequest() {
return new FieldStatsShardRequest();
}
@Override
protected FieldStatsShardRequest newShardRequest(int numShards, ShardRouting shard, FieldStatsRequest request) {
return new FieldStatsShardRequest(shard.shardId(), request);

View File

@ -49,17 +49,13 @@ public class TransportGetAction extends TransportShardSingleOperationAction<GetR
@Inject
public TransportGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, GetAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, GetAction.NAME, threadPool, clusterService, transportService, actionFilters,
GetRequest.class, ThreadPool.Names.GET);
this.indicesService = indicesService;
this.realtime = settings.getAsBoolean("action.get.realtime", true);
}
@Override
protected String executor() {
return ThreadPool.Names.GET;
}
@Override
protected boolean resolveIndex() {
return true;
@ -106,11 +102,6 @@ public class TransportGetAction extends TransportShardSingleOperationAction<GetR
return new GetResponse(result);
}
@Override
protected GetRequest newRequest() {
return new GetRequest();
}
@Override
protected GetResponse newResponse() {
return new GetResponse();

View File

@ -45,16 +45,11 @@ public class TransportMultiGetAction extends HandledTransportAction<MultiGetRequ
@Inject
public TransportMultiGetAction(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterService clusterService, TransportShardMultiGetAction shardAction, ActionFilters actionFilters) {
super(settings, MultiGetAction.NAME, threadPool, transportService, actionFilters);
super(settings, MultiGetAction.NAME, threadPool, transportService, actionFilters, MultiGetRequest.class);
this.clusterService = clusterService;
this.shardAction = shardAction;
}
@Override
public MultiGetRequest newRequestInstance(){
return new MultiGetRequest();
}
@Override
protected void doExecute(final MultiGetRequest request, final ActionListener<MultiGetResponse> listener) {
ClusterState clusterState = clusterService.state();

View File

@ -48,7 +48,8 @@ public class TransportShardMultiGetAction extends TransportShardSingleOperationA
@Inject
public TransportShardMultiGetAction(Settings settings, ClusterService clusterService, TransportService transportService,
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters) {
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters,
MultiGetShardRequest.class, ThreadPool.Names.GET);
this.indicesService = indicesService;
this.realtime = settings.getAsBoolean("action.get.realtime", true);
@ -59,16 +60,6 @@ public class TransportShardMultiGetAction extends TransportShardSingleOperationA
return true;
}
@Override
protected String executor() {
return ThreadPool.Names.GET;
}
@Override
protected MultiGetShardRequest newRequest() {
return new MultiGetShardRequest();
}
@Override
protected MultiGetShardResponse newResponse() {
return new MultiGetShardResponse();

View File

@ -47,6 +47,7 @@ import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.Mapping;
import org.elasticsearch.index.mapper.SourceToParse;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.indices.IndexAlreadyExistsException;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.river.RiverIndexName;
@ -68,18 +69,16 @@ import java.io.IOException;
public class TransportIndexAction extends TransportShardReplicationOperationAction<IndexRequest, IndexRequest, IndexResponse> {
private final AutoCreateIndex autoCreateIndex;
private final boolean allowIdGeneration;
private final TransportCreateIndexAction createIndexAction;
private final MappingUpdatedAction mappingUpdatedAction;
@Inject
public TransportIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
TransportCreateIndexAction createIndexAction, MappingUpdatedAction mappingUpdatedAction, ActionFilters actionFilters) {
super(settings, IndexAction.NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, actionFilters);
super(settings, IndexAction.NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, actionFilters,
IndexRequest.class, IndexRequest.class, ThreadPool.Names.INDEX);
this.createIndexAction = createIndexAction;
this.mappingUpdatedAction = mappingUpdatedAction;
this.autoCreateIndex = new AutoCreateIndex(settings);
@ -145,26 +144,11 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi
return true;
}
@Override
protected IndexRequest newRequestInstance() {
return new IndexRequest();
}
@Override
protected IndexRequest newReplicaRequestInstance() {
return newRequestInstance();
}
@Override
protected IndexResponse newResponseInstance() {
return new IndexResponse();
}
@Override
protected String executor() {
return ThreadPool.Names.INDEX;
}
@Override
protected ShardIterator shards(ClusterState clusterState, InternalRequest request) {
return clusterService.operationRouting()
@ -260,10 +244,9 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi
}
@Override
protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) throws IOException {
IndexService indexService = indicesService.indexServiceSafe(shardRequest.shardId.getIndex());
IndexShard indexShard = indexService.shardSafe(shardRequest.shardId.id());
IndexRequest request = shardRequest.request;
protected void shardOperationOnReplica(ShardId shardId, IndexRequest request) throws IOException {
IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex());
IndexShard indexShard = indexService.shardSafe(shardId.id());
SourceToParse sourceToParse = SourceToParse.source(SourceToParse.Origin.REPLICA, request.source()).type(request.type()).id(request.id())
.routing(request.routing()).parent(request.parent()).timestamp(request.timestamp()).ttl(request.ttl());
if (request.opType() == IndexRequest.OpType.INDEX) {

View File

@ -40,15 +40,10 @@ public class TransportDeleteIndexedScriptAction extends HandledTransportAction<D
@Inject
public TransportDeleteIndexedScriptAction(Settings settings, ThreadPool threadPool, ScriptService scriptService,
TransportService transportService, ActionFilters actionFilters) {
super(settings, DeleteIndexedScriptAction.NAME, threadPool, transportService, actionFilters);
super(settings, DeleteIndexedScriptAction.NAME, threadPool, transportService, actionFilters, DeleteIndexedScriptRequest.class);
this.scriptService = scriptService;
}
@Override
public DeleteIndexedScriptRequest newRequestInstance(){
return new DeleteIndexedScriptRequest();
}
@Override
protected void doExecute(final DeleteIndexedScriptRequest request, final ActionListener<DeleteIndexedScriptResponse> listener) {
scriptService.deleteScriptFromIndex(request, new DelegatingActionListener<DeleteResponse, DeleteIndexedScriptResponse>(listener) {

View File

@ -39,15 +39,10 @@ public class TransportGetIndexedScriptAction extends HandledTransportAction<GetI
@Inject
public TransportGetIndexedScriptAction(Settings settings, ThreadPool threadPool, ScriptService scriptService,
TransportService transportService, ActionFilters actionFilters) {
super(settings, GetIndexedScriptAction.NAME, threadPool,transportService, actionFilters);
super(settings, GetIndexedScriptAction.NAME, threadPool,transportService, actionFilters, GetIndexedScriptRequest.class);
this.scriptService = scriptService;
}
@Override
public GetIndexedScriptRequest newRequestInstance(){
return new GetIndexedScriptRequest();
}
@Override
public void doExecute(GetIndexedScriptRequest request, final ActionListener<GetIndexedScriptResponse> listener){
// forward the handling to the script service we are running on a network thread here...

View File

@ -40,15 +40,10 @@ public class TransportPutIndexedScriptAction extends HandledTransportAction<PutI
@Inject
public TransportPutIndexedScriptAction(Settings settings, ThreadPool threadPool,
ScriptService scriptService, TransportService transportService, ActionFilters actionFilters) {
super(settings, PutIndexedScriptAction.NAME, threadPool, transportService, actionFilters);
super(settings, PutIndexedScriptAction.NAME, threadPool, transportService, actionFilters, PutIndexedScriptRequest.class);
this.scriptService = scriptService;
}
@Override
public PutIndexedScriptRequest newRequestInstance(){
return new PutIndexedScriptRequest();
}
@Override
protected void doExecute(final PutIndexedScriptRequest request, final ActionListener<PutIndexedScriptResponse> listener) {
scriptService.putScriptToIndex(request, new DelegatingActionListener<IndexResponse,PutIndexedScriptResponse>(listener) {

View File

@ -69,19 +69,15 @@ import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
public class TransportMoreLikeThisAction extends HandledTransportAction<MoreLikeThisRequest, SearchResponse> {
private final TransportSearchAction searchAction;
private final TransportGetAction getAction;
private final IndicesService indicesService;
private final ClusterService clusterService;
private final TransportService transportService;
@Inject
public TransportMoreLikeThisAction(Settings settings, ThreadPool threadPool, TransportSearchAction searchAction, TransportGetAction getAction,
ClusterService clusterService, IndicesService indicesService, TransportService transportService, ActionFilters actionFilters) {
super(settings, MoreLikeThisAction.NAME, threadPool, transportService, actionFilters);
super(settings, MoreLikeThisAction.NAME, threadPool, transportService, actionFilters, MoreLikeThisRequest.class);
this.searchAction = searchAction;
this.getAction = getAction;
this.indicesService = indicesService;
@ -89,11 +85,6 @@ public class TransportMoreLikeThisAction extends HandledTransportAction<MoreLike
this.transportService = transportService;
}
@Override
public MoreLikeThisRequest newRequestInstance(){
return new MoreLikeThisRequest();
}
@Override
protected void doExecute(final MoreLikeThisRequest request, final ActionListener<SearchResponse> listener) {
// update to actual index name

View File

@ -60,18 +60,13 @@ public class TransportMultiPercolateAction extends HandledTransportAction<MultiP
public TransportMultiPercolateAction(Settings settings, ThreadPool threadPool, TransportShardMultiPercolateAction shardMultiPercolateAction,
ClusterService clusterService, TransportService transportService, PercolatorService percolatorService,
TransportMultiGetAction multiGetAction, ActionFilters actionFilters) {
super(settings, MultiPercolateAction.NAME, threadPool, transportService, actionFilters);
super(settings, MultiPercolateAction.NAME, threadPool, transportService, actionFilters, MultiPercolateRequest.class);
this.shardMultiPercolateAction = shardMultiPercolateAction;
this.clusterService = clusterService;
this.percolatorService = percolatorService;
this.multiGetAction = multiGetAction;
}
@Override
public MultiPercolateRequest newRequestInstance() {
return new MultiPercolateRequest();
}
@Override
protected void doExecute(final MultiPercolateRequest request, final ActionListener<MultiPercolateResponse> listener) {
final ClusterState clusterState = clusterService.state();

View File

@ -62,7 +62,8 @@ public class TransportPercolateAction extends TransportBroadcastOperationAction<
public TransportPercolateAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
TransportService transportService, PercolatorService percolatorService,
TransportGetAction getAction, ActionFilters actionFilters) {
super(settings, PercolateAction.NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, PercolateAction.NAME, threadPool, clusterService, transportService, actionFilters,
PercolateRequest.class, PercolateShardRequest.class, ThreadPool.Names.PERCOLATE);
this.percolatorService = percolatorService;
this.getAction = getAction;
}
@ -95,16 +96,6 @@ public class TransportPercolateAction extends TransportBroadcastOperationAction<
}
}
@Override
protected String executor() {
return ThreadPool.Names.PERCOLATE;
}
@Override
protected PercolateRequest newRequestInstance() {
return new PercolateRequest();
}
@Override
protected ClusterBlockException checkGlobalBlock(ClusterState state, PercolateRequest request) {
return state.blocks().globalBlockedException(ClusterBlockLevel.READ);
@ -165,11 +156,6 @@ public class TransportPercolateAction extends TransportBroadcastOperationAction<
}
}
@Override
protected PercolateShardRequest newShardRequest() {
return new PercolateShardRequest();
}
@Override
protected PercolateShardRequest newShardRequest(int numShards, ShardRouting shard, PercolateRequest request) {
return new PercolateShardRequest(shard.shardId(), numShards, request);

View File

@ -57,7 +57,8 @@ public class TransportShardMultiPercolateAction extends TransportShardSingleOper
@Inject
public TransportShardMultiPercolateAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, PercolatorService percolatorService, ActionFilters actionFilters) {
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters);
super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters,
Request.class, ThreadPool.Names.PERCOLATE);
this.percolatorService = percolatorService;
}
@ -66,16 +67,6 @@ public class TransportShardMultiPercolateAction extends TransportShardSingleOper
return true;
}
@Override
protected String executor() {
return ThreadPool.Names.PERCOLATE;
}
@Override
protected Request newRequest() {
return new Request();
}
@Override
protected Response newResponse() {
return new Response();

View File

@ -20,25 +20,30 @@
package org.elasticsearch.action.search;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexException;
import org.elasticsearch.rest.RestStatus;
import java.io.IOException;
import java.util.*;
/**
*
*/
public class SearchPhaseExecutionException extends ElasticsearchException {
private final String phaseName;
private ShardSearchFailure[] shardFailures;
public SearchPhaseExecutionException(String phaseName, String msg, ShardSearchFailure[] shardFailures) {
super(buildMessage(phaseName, msg, shardFailures));
super(msg);
this.phaseName = phaseName;
this.shardFailures = shardFailures;
}
public SearchPhaseExecutionException(String phaseName, String msg, Throwable cause, ShardSearchFailure[] shardFailures) {
super(buildMessage(phaseName, msg, shardFailures), cause);
super(msg, cause);
this.phaseName = phaseName;
this.shardFailures = shardFailures;
}
@ -60,10 +65,6 @@ public class SearchPhaseExecutionException extends ElasticsearchException {
return status;
}
public String phaseName() {
return phaseName;
}
public ShardSearchFailure[] shardFailures() {
return shardFailures;
}
@ -83,4 +84,90 @@ public class SearchPhaseExecutionException extends ElasticsearchException {
}
return sb.toString();
}
@Override
protected void innerToXContent(XContentBuilder builder, Params params) throws IOException {
builder.field("phase", phaseName);
final boolean group = params.paramAsBoolean("group_shard_failures", true); // we group by default
builder.field("grouped", group); // notify that it's grouped
builder.field("failed_shards");
builder.startArray();
ShardSearchFailure[] failures = params.paramAsBoolean("group_shard_failures", true) ? groupBy(shardFailures) : shardFailures;
for (ShardSearchFailure failure : failures) {
builder.startObject();
failure.toXContent(builder, params);
builder.endObject();
}
builder.endArray();
super.innerToXContent(builder, params);
}
private ShardSearchFailure[] groupBy(ShardSearchFailure[] failures) {
List<ShardSearchFailure> uniqueFailures = new ArrayList<>();
Set<GroupBy> reasons = new HashSet<>();
for (ShardSearchFailure failure : failures) {
GroupBy reason = new GroupBy(failure.getCause());
if (reasons.contains(reason) == false) {
reasons.add(reason);
uniqueFailures.add(failure);
}
}
return uniqueFailures.toArray(new ShardSearchFailure[0]);
}
@Override
public ElasticsearchException[] guessRootCauses() {
ShardSearchFailure[] failures = groupBy(shardFailures);
List<ElasticsearchException> rootCauses = new ArrayList<>(failures.length);
for (ShardSearchFailure failure : failures) {
ElasticsearchException[] guessRootCauses = ElasticsearchException.guessRootCauses(failure.getCause());
rootCauses.addAll(Arrays.asList(guessRootCauses));
}
return rootCauses.toArray(new ElasticsearchException[0]);
}
@Override
public String toString() {
return buildMessage(phaseName, getMessage(), shardFailures);
}
static class GroupBy {
final String reason;
final Index index;
final Class<? extends Throwable> causeType;
public GroupBy(Throwable t) {
if (t instanceof IndexException) {
index = ((IndexException) t).index();
} else {
index = null;
}
reason = t.getMessage();
causeType = t.getClass();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GroupBy groupBy = (GroupBy) o;
if (!causeType.equals(groupBy.causeType)) return false;
if (index != null ? !index.equals(groupBy.index) : groupBy.index != null) return false;
if (reason != null ? !reason.equals(groupBy.reason) : groupBy.reason != null) return false;
return true;
}
@Override
public int hashCode() {
int result = reason != null ? reason.hashCode() : 0;
result = 31 * result + (index != null ? index.hashCode() : 0);
result = 31 * result + causeType.hashCode();
return result;
}
}
}

View File

@ -25,24 +25,29 @@ import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.SearchException;
import org.elasticsearch.search.SearchShardTarget;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import static org.elasticsearch.search.SearchShardTarget.readSearchShardTarget;
/**
* Represents a failure to search on a specific shard.
*/
public class ShardSearchFailure implements ShardOperationFailedException {
public class ShardSearchFailure implements ShardOperationFailedException, ToXContent {
public static final ShardSearchFailure[] EMPTY_ARRAY = new ShardSearchFailure[0];
private SearchShardTarget shardTarget;
private String reason;
private RestStatus status;
private Throwable cause;
private ShardSearchFailure() {
@ -59,12 +64,9 @@ public class ShardSearchFailure implements ShardOperationFailedException {
} else if (shardTarget != null) {
this.shardTarget = shardTarget;
}
if (actual != null && actual instanceof ElasticsearchException) {
status = ((ElasticsearchException) actual).status();
} else {
status = RestStatus.INTERNAL_SERVER_ERROR;
}
status = ExceptionsHelper.status(actual);
this.reason = ExceptionsHelper.detailedMessage(t);
this.cause = actual;
}
public ShardSearchFailure(String reason, SearchShardTarget shardTarget) {
@ -138,6 +140,7 @@ public class ShardSearchFailure implements ShardOperationFailedException {
}
reason = in.readString();
status = RestStatus.readFrom(in);
cause = in.readThrowable();
}
@Override
@ -150,5 +153,26 @@ public class ShardSearchFailure implements ShardOperationFailedException {
}
out.writeString(reason);
RestStatus.writeTo(out, status);
out.writeThrowable(cause);
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field("shard", shardId());
builder.field("index", index());
if (shardTarget != null) {
builder.field("node", shardTarget.nodeId());
}
if (cause != null) {
builder.field("reason");
builder.startObject();
ElasticsearchException.toXContent(builder, params, cause);
builder.endObject();
}
return builder;
}
public Throwable getCause() {
return cause;
}
}

Some files were not shown because too many files have changed in this diff Show More