Internal: made it possible to disable the main transport handler in TransportShardSingleOperationAction

TransportShardSingleOperationAction is currently subclassed by different transport actions. Some of them are internal only, meaning that their execution will take place only in the same node where their parent execution took place. That means that their main transport handler doesn't need to be registered, the only transport handler that's needed is the shard level one.

Added `isSubAction` method (defaults to false) to the parent class that tells whether the action is a main one or a subaction, used to decide whether we need to register the main transport handler.

Closes #7285
This commit is contained in:
javanna 2014-08-14 17:01:12 +02:00 committed by Luca Cavanna
parent 9c63abde04
commit a279f2e8c6
5 changed files with 30 additions and 4 deletions

View File

@ -57,6 +57,11 @@ public class TransportShardMultiGetAction extends TransportShardSingleOperationA
this.realtime = settings.getAsBoolean("action.get.realtime", true); this.realtime = settings.getAsBoolean("action.get.realtime", true);
} }
@Override
protected boolean isSubAction() {
return true;
}
@Override @Override
protected String executor() { protected String executor() {
return ThreadPool.Names.GET; return ThreadPool.Names.GET;

View File

@ -59,6 +59,11 @@ public class TransportShardMultiPercolateAction extends TransportShardSingleOper
this.percolatorService = percolatorService; this.percolatorService = percolatorService;
} }
@Override
protected boolean isSubAction() {
return true;
}
@Override @Override
protected String executor() { protected String executor() {
return ThreadPool.Names.PERCOLATE; return ThreadPool.Names.PERCOLATE;

View File

@ -67,10 +67,21 @@ public abstract class TransportShardSingleOperationAction<Request extends Single
this.transportShardAction = actionName + "[s]"; this.transportShardAction = actionName + "[s]";
this.executor = executor(); this.executor = executor();
transportService.registerHandler(actionName, new TransportHandler()); if (!isSubAction()) {
transportService.registerHandler(actionName, new TransportHandler());
}
transportService.registerHandler(transportShardAction, new ShardTransportHandler()); transportService.registerHandler(transportShardAction, new ShardTransportHandler());
} }
/**
* Tells whether the action is a main one or a subaction. Used to decide whether we need to register
* the main transport handler. In fact if the action is a subaction, its execute method
* will be called locally to its parent action.
*/
protected boolean isSubAction() {
return false;
}
@Override @Override
protected void doExecute(Request request, ActionListener<Response> listener) { protected void doExecute(Request request, ActionListener<Response> listener) {
new AsyncSingleAction(request, listener).start(); new AsyncSingleAction(request, listener).start();

View File

@ -49,6 +49,11 @@ public class TransportSingleShardMultiTermsVectorAction extends TransportShardSi
this.indicesService = indicesService; this.indicesService = indicesService;
} }
@Override
protected boolean isSubAction() {
return true;
}
@Override @Override
protected String executor() { protected String executor() {
return ThreadPool.Names.GET; return ThreadPool.Names.GET;

View File

@ -230,7 +230,7 @@ final class ActionNames {
addShardAction(ExplainAction.NAME, "explain", builder); addShardAction(ExplainAction.NAME, "explain", builder);
addShardAction(GetAction.NAME, "get", builder); addShardAction(GetAction.NAME, "get", builder);
builder.put(MultiGetAction.NAME, "mget"); builder.put(MultiGetAction.NAME, "mget");
addShardAction(MultiGetAction.NAME + "[shard]", "mget/shard", builder); builder.put(MultiGetAction.NAME + "[shard][s]", "mget/shard/s");
builder.put(GetIndexedScriptAction.NAME, "getIndexedScript"); builder.put(GetIndexedScriptAction.NAME, "getIndexedScript");
builder.put(PutIndexedScriptAction.NAME, "putIndexedScript"); builder.put(PutIndexedScriptAction.NAME, "putIndexedScript");
@ -239,12 +239,12 @@ final class ActionNames {
builder.put(MoreLikeThisAction.NAME, "mlt"); builder.put(MoreLikeThisAction.NAME, "mlt");
builder.put(MultiPercolateAction.NAME, "mpercolate"); builder.put(MultiPercolateAction.NAME, "mpercolate");
addShardAction(MultiPercolateAction.NAME + "[shard]", "mpercolate/shard", builder); builder.put(MultiPercolateAction.NAME + "[shard][s]", "mpercolate/shard/s");
builder.put(MultiSearchAction.NAME, "msearch"); builder.put(MultiSearchAction.NAME, "msearch");
builder.put(MultiTermVectorsAction.NAME, "mtv"); builder.put(MultiTermVectorsAction.NAME, "mtv");
addShardAction(MultiTermVectorsAction.NAME + "[shard]", "mtv/shard", builder); builder.put(MultiTermVectorsAction.NAME + "[shard][s]", "mtv/shard/s");
addShardAction(PercolateAction.NAME, "percolate", builder); addShardAction(PercolateAction.NAME, "percolate", builder);