Skip to content

Commit

Permalink
Transport: better categorization for transport actions
Browse files Browse the repository at this point in the history
Our transport relies on action names that tell what we need to do with each message received and sent on any node, together with the content of the request itself.
The action names could use a better categorization and more consistent naming though, the following are the categories introduced with this commit:

- indices: for all the apis that execute against indices
  - admin: for the apis that allow to perform administration tasks against indices
  - data: for the apis that are about data
    - read: apis that read data
    - write: apis that write data
    - benchmark: apis that run benchmarks

- cluster: for all the cluster apis
  - admin: for the cluster apis that allow to perform administration tasks
  - monitor: for the cluster apis that allow to monitor the system

- internal: for all the internal actions that are used from node to node but not directly exposed to users

The change is applied in a backwards compatible manner: we keep the mapping old-to-new action name around, and when receiving a message, depending on the version of the node we receive it from, we use the received action name or we convert it to the previous version (old to new if version < 1.4). When sending a message, depending on the version of the node we talk to, we use the updated action or we convert it to the previous version (new to old if version < 1.4).
For the cases where we don't know the version of the node we talk to, namely unicast ping, transport client nodes info and transport client sniff mode (which calls cluster state), we just use a lower bound for the version, thus we will always use the old action name, which can be understood by both old nodes and new nodes.

Added test that enforces known updated categories for transport action names and test that verifies all action names have a pre 1.4 version for bw compatibility

Added backwards compatibility tests for unicast and transport client in sniff mode, the one for the ordinary transport client (which calls nodes info) is implicit as it's used all the time in our bw comp tests.
Added also backwards comp test that sends an empty message to any of the registered transport handler exposed by older nodes and verifies that what gets back is not ActionNotFoundTransportException, which would mean that there is a problem in the actions mappings.

Added TestCluster#getClusterName abstract method and allow to retrieve externalTransportAddress and internalCluster from CompositeTestCluster.

Closes #7105
  • Loading branch information
javanna committed Aug 4, 2014
1 parent 080953d commit 397a30d
Show file tree
Hide file tree
Showing 134 changed files with 1,057 additions and 287 deletions.
Expand Up @@ -27,7 +27,7 @@
public class ClusterHealthAction extends ClusterAction<ClusterHealthRequest, ClusterHealthResponse, ClusterHealthRequestBuilder> {

public static final ClusterHealthAction INSTANCE = new ClusterHealthAction();
public static final String NAME = "cluster/health";
public static final String NAME = "cluster:monitor/health";

private ClusterHealthAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class NodesHotThreadsAction extends ClusterAction<NodesHotThreadsRequest, NodesHotThreadsResponse, NodesHotThreadsRequestBuilder> {

public static final NodesHotThreadsAction INSTANCE = new NodesHotThreadsAction();
public static final String NAME = "cluster/nodes/hot_threads";
public static final String NAME = "cluster:monitor/nodes/hot_threads";

private NodesHotThreadsAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class NodesInfoAction extends ClusterAction<NodesInfoRequest, NodesInfoResponse, NodesInfoRequestBuilder> {

public static final NodesInfoAction INSTANCE = new NodesInfoAction();
public static final String NAME = "cluster/nodes/info";
public static final String NAME = "cluster:monitor/nodes/info";

private NodesInfoAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class NodesRestartAction extends ClusterAction<NodesRestartRequest, NodesRestartResponse, NodesRestartRequestBuilder> {

public static final NodesRestartAction INSTANCE = new NodesRestartAction();
public static final String NAME = "cluster/nodes/restart";
public static final String NAME = "cluster:admin/nodes/restart";

private NodesRestartAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class NodesShutdownAction extends ClusterAction<NodesShutdownRequest, NodesShutdownResponse, NodesShutdownRequestBuilder> {

public static final NodesShutdownAction INSTANCE = new NodesShutdownAction();
public static final String NAME = "cluster/nodes/shutdown";
public static final String NAME = "cluster:admin/nodes/shutdown";

private NodesShutdownAction() {
super(NAME);
Expand Down
Expand Up @@ -47,6 +47,8 @@
*/
public class TransportNodesShutdownAction extends TransportMasterNodeOperationAction<NodesShutdownRequest, NodesShutdownResponse> {

public static final String SHUTDOWN_NODE_ACTION_NAME = NodesShutdownAction.NAME + "[n]";

private final Node node;
private final ClusterName clusterName;
private final boolean disabled;
Expand All @@ -61,7 +63,7 @@ public TransportNodesShutdownAction(Settings settings, TransportService transpor
this.disabled = settings.getAsBoolean("action.disable_shutdown", componentSettings.getAsBoolean("disabled", false));
this.delay = componentSettings.getAsTime("delay", TimeValue.timeValueMillis(200));

this.transportService.registerHandler(NodeShutdownRequestHandler.ACTION, new NodeShutdownRequestHandler());
this.transportService.registerHandler(SHUTDOWN_NODE_ACTION_NAME, new NodeShutdownRequestHandler());
}

@Override
Expand Down Expand Up @@ -122,7 +124,7 @@ public void run() {
latch.countDown();
} else {
logger.trace("[cluster_shutdown]: sending shutdown request to [{}]", node);
transportService.sendRequest(node, NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request), new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {
transportService.sendRequest(node, SHUTDOWN_NODE_ACTION_NAME, new NodeShutdownRequest(request), new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {
@Override
public void handleResponse(TransportResponse.Empty response) {
logger.trace("[cluster_shutdown]: received shutdown response from [{}]", node);
Expand All @@ -146,7 +148,7 @@ public void handleException(TransportException exp) {

// now, kill the master
logger.trace("[cluster_shutdown]: shutting down the master [{}]", state.nodes().masterNode());
transportService.sendRequest(state.nodes().masterNode(), NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request), new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {
transportService.sendRequest(state.nodes().masterNode(), SHUTDOWN_NODE_ACTION_NAME, new NodeShutdownRequest(request), new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {
@Override
public void handleResponse(TransportResponse.Empty response) {
logger.trace("[cluster_shutdown]: received shutdown response from master");
Expand Down Expand Up @@ -190,7 +192,7 @@ public void run() {
}

logger.trace("[partial_cluster_shutdown]: sending shutdown request to [{}]", node);
transportService.sendRequest(node, NodeShutdownRequestHandler.ACTION, new NodeShutdownRequest(request), new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {
transportService.sendRequest(node, SHUTDOWN_NODE_ACTION_NAME, new NodeShutdownRequest(request), new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {
@Override
public void handleResponse(TransportResponse.Empty response) {
logger.trace("[partial_cluster_shutdown]: received shutdown response from [{}]", node);
Expand Down Expand Up @@ -221,8 +223,6 @@ public void handleException(TransportException exp) {

private class NodeShutdownRequestHandler extends BaseTransportRequestHandler<NodeShutdownRequest> {

static final String ACTION = "/cluster/nodes/shutdown/node";

@Override
public NodeShutdownRequest newInstance() {
return new NodeShutdownRequest();
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class NodesStatsAction extends ClusterAction<NodesStatsRequest, NodesStatsResponse, NodesStatsRequestBuilder> {

public static final NodesStatsAction INSTANCE = new NodesStatsAction();
public static final String NAME = "cluster/nodes/stats";
public static final String NAME = "cluster:monitor/nodes/stats";

private NodesStatsAction() {
super(NAME);
Expand Down
Expand Up @@ -28,7 +28,7 @@
public class DeleteRepositoryAction extends ClusterAction<DeleteRepositoryRequest, DeleteRepositoryResponse, DeleteRepositoryRequestBuilder> {

public static final DeleteRepositoryAction INSTANCE = new DeleteRepositoryAction();
public static final String NAME = "cluster/repository/delete";
public static final String NAME = "cluster:admin/repository/delete";

private DeleteRepositoryAction() {
super(NAME);
Expand Down
Expand Up @@ -28,7 +28,7 @@
public class GetRepositoriesAction extends ClusterAction<GetRepositoriesRequest, GetRepositoriesResponse, GetRepositoriesRequestBuilder> {

public static final GetRepositoriesAction INSTANCE = new GetRepositoriesAction();
public static final String NAME = "cluster/repository/get";
public static final String NAME = "cluster:admin/repository/get";

private GetRepositoriesAction() {
super(NAME);
Expand Down
Expand Up @@ -28,7 +28,7 @@
public class PutRepositoryAction extends ClusterAction<PutRepositoryRequest, PutRepositoryResponse, PutRepositoryRequestBuilder> {

public static final PutRepositoryAction INSTANCE = new PutRepositoryAction();
public static final String NAME = "cluster/repository/put";
public static final String NAME = "cluster:admin/repository/put";

private PutRepositoryAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class ClusterRerouteAction extends ClusterAction<ClusterRerouteRequest, ClusterRerouteResponse, ClusterRerouteRequestBuilder> {

public static final ClusterRerouteAction INSTANCE = new ClusterRerouteAction();
public static final String NAME = "cluster/reroute";
public static final String NAME = "cluster:admin/reroute";

private ClusterRerouteAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class ClusterUpdateSettingsAction extends ClusterAction<ClusterUpdateSettingsRequest, ClusterUpdateSettingsResponse, ClusterUpdateSettingsRequestBuilder> {

public static final ClusterUpdateSettingsAction INSTANCE = new ClusterUpdateSettingsAction();
public static final String NAME = "cluster/settings/update";
public static final String NAME = "cluster:admin/settings/update";

private ClusterUpdateSettingsAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class ClusterSearchShardsAction extends ClusterAction<ClusterSearchShardsRequest, ClusterSearchShardsResponse, ClusterSearchShardsRequestBuilder> {

public static final ClusterSearchShardsAction INSTANCE = new ClusterSearchShardsAction();
public static final String NAME = "cluster/shards/search_shards";
public static final String NAME = "indices:admin/shards/search_shards";

private ClusterSearchShardsAction() {
super(NAME);
Expand Down
Expand Up @@ -28,7 +28,7 @@
public class CreateSnapshotAction extends ClusterAction<CreateSnapshotRequest, CreateSnapshotResponse, CreateSnapshotRequestBuilder> {

public static final CreateSnapshotAction INSTANCE = new CreateSnapshotAction();
public static final String NAME = "cluster/snapshot/create";
public static final String NAME = "cluster:admin/snapshot/create";

private CreateSnapshotAction() {
super(NAME);
Expand Down
Expand Up @@ -28,7 +28,7 @@
public class DeleteSnapshotAction extends ClusterAction<DeleteSnapshotRequest, DeleteSnapshotResponse, DeleteSnapshotRequestBuilder> {

public static final DeleteSnapshotAction INSTANCE = new DeleteSnapshotAction();
public static final String NAME = "cluster/snapshot/delete";
public static final String NAME = "cluster:admin/snapshot/delete";

private DeleteSnapshotAction() {
super(NAME);
Expand Down
Expand Up @@ -28,7 +28,7 @@
public class GetSnapshotsAction extends ClusterAction<GetSnapshotsRequest, GetSnapshotsResponse, GetSnapshotsRequestBuilder> {

public static final GetSnapshotsAction INSTANCE = new GetSnapshotsAction();
public static final String NAME = "cluster/snapshot/get";
public static final String NAME = "cluster:admin/snapshot/get";

private GetSnapshotsAction() {
super(NAME);
Expand Down
Expand Up @@ -28,7 +28,7 @@
public class RestoreSnapshotAction extends ClusterAction<RestoreSnapshotRequest, RestoreSnapshotResponse, RestoreSnapshotRequestBuilder> {

public static final RestoreSnapshotAction INSTANCE = new RestoreSnapshotAction();
public static final String NAME = "cluster/snapshot/restore";
public static final String NAME = "cluster:admin/snapshot/restore";

private RestoreSnapshotAction() {
super(NAME);
Expand Down
Expand Up @@ -28,7 +28,7 @@
public class SnapshotsStatusAction extends ClusterAction<SnapshotsStatusRequest, SnapshotsStatusResponse, SnapshotsStatusRequestBuilder> {

public static final SnapshotsStatusAction INSTANCE = new SnapshotsStatusAction();
public static final String NAME = "cluster/snapshot/status";
public static final String NAME = "cluster:admin/snapshot/status";

private SnapshotsStatusAction() {
super(NAME);
Expand Down
Expand Up @@ -51,7 +51,7 @@
*/
public class TransportNodesSnapshotsStatus extends TransportNodesOperationAction<TransportNodesSnapshotsStatus.Request, TransportNodesSnapshotsStatus.NodesSnapshotStatus, TransportNodesSnapshotsStatus.NodeRequest, TransportNodesSnapshotsStatus.NodeSnapshotStatus> {

private static final String ACTION_NAME = "cluster/snapshot/status/nodes";
public static final String ACTION_NAME = SnapshotsStatusAction.NAME + "[nodes]";

private final SnapshotsService snapshotsService;

Expand Down
Expand Up @@ -27,7 +27,7 @@
public class ClusterStateAction extends ClusterAction<ClusterStateRequest, ClusterStateResponse, ClusterStateRequestBuilder> {

public static final ClusterStateAction INSTANCE = new ClusterStateAction();
public static final String NAME = "cluster/state";
public static final String NAME = "cluster:monitor/state";

private ClusterStateAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class ClusterStatsAction extends ClusterAction<ClusterStatsRequest, ClusterStatsResponse, ClusterStatsRequestBuilder> {

public static final ClusterStatsAction INSTANCE = new ClusterStatsAction();
public static final String NAME = "cluster/stats";
public static final String NAME = "cluster:monitor/stats";

private ClusterStatsAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class PendingClusterTasksAction extends ClusterAction<PendingClusterTasksRequest, PendingClusterTasksResponse, PendingClusterTasksRequestBuilder> {

public static final PendingClusterTasksAction INSTANCE = new PendingClusterTasksAction();
public static final String NAME = "cluster/task";
public static final String NAME = "cluster:monitor/task";

private PendingClusterTasksAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class IndicesAliasesAction extends IndicesAction<IndicesAliasesRequest, IndicesAliasesResponse, IndicesAliasesRequestBuilder> {

public static final IndicesAliasesAction INSTANCE = new IndicesAliasesAction();
public static final String NAME = "indices/aliases";
public static final String NAME = "indices:admin/aliases";

private IndicesAliasesAction() {
super(NAME);
Expand Down
Expand Up @@ -28,7 +28,7 @@
public class AliasesExistAction extends IndicesAction<GetAliasesRequest, AliasesExistResponse, AliasesExistRequestBuilder> {

public static final AliasesExistAction INSTANCE = new AliasesExistAction();
public static final String NAME = "indices/exists/aliases";
public static final String NAME = "indices:admin/aliases/exists";

private AliasesExistAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class GetAliasesAction extends IndicesAction<GetAliasesRequest, GetAliasesResponse, GetAliasesRequestBuilder> {

public static final GetAliasesAction INSTANCE = new GetAliasesAction();
public static final String NAME = "indices/get/aliases";
public static final String NAME = "indices:admin/aliases/get";

private GetAliasesAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class AnalyzeAction extends IndicesAction<AnalyzeRequest, AnalyzeResponse, AnalyzeRequestBuilder> {

public static final AnalyzeAction INSTANCE = new AnalyzeAction();
public static final String NAME = "indices/analyze";
public static final String NAME = "indices:admin/analyze";

private AnalyzeAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class ClearIndicesCacheAction extends IndicesAction<ClearIndicesCacheRequest, ClearIndicesCacheResponse, ClearIndicesCacheRequestBuilder> {

public static final ClearIndicesCacheAction INSTANCE = new ClearIndicesCacheAction();
public static final String NAME = "indices/cache/clear";
public static final String NAME = "indices:admin/cache/clear";

private ClearIndicesCacheAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class CloseIndexAction extends IndicesAction<CloseIndexRequest, CloseIndexResponse, CloseIndexRequestBuilder> {

public static final CloseIndexAction INSTANCE = new CloseIndexAction();
public static final String NAME = "indices/close";
public static final String NAME = "indices:admin/close";

private CloseIndexAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class CreateIndexAction extends IndicesAction<CreateIndexRequest, CreateIndexResponse, CreateIndexRequestBuilder> {

public static final CreateIndexAction INSTANCE = new CreateIndexAction();
public static final String NAME = "indices/create";
public static final String NAME = "indices:admin/create";

private CreateIndexAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class DeleteIndexAction extends IndicesAction<DeleteIndexRequest, DeleteIndexResponse, DeleteIndexRequestBuilder> {

public static final DeleteIndexAction INSTANCE = new DeleteIndexAction();
public static final String NAME = "indices/delete";
public static final String NAME = "indices:admin/delete";

private DeleteIndexAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class IndicesExistsAction extends IndicesAction<IndicesExistsRequest, IndicesExistsResponse, IndicesExistsRequestBuilder> {

public static final IndicesExistsAction INSTANCE = new IndicesExistsAction();
public static final String NAME = "indices/exists";
public static final String NAME = "indices:admin/exists";

private IndicesExistsAction() {
super(NAME);
Expand Down
Expand Up @@ -26,7 +26,7 @@
public class TypesExistsAction extends IndicesAction<TypesExistsRequest, TypesExistsResponse, TypesExistsRequestBuilder> {

public static final TypesExistsAction INSTANCE = new TypesExistsAction();
public static final String NAME = "indices/types/exists";
public static final String NAME = "indices:admin/types/exists";

private TypesExistsAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class FlushAction extends IndicesAction<FlushRequest, FlushResponse, FlushRequestBuilder> {

public static final FlushAction INSTANCE = new FlushAction();
public static final String NAME = "indices/flush";
public static final String NAME = "indices:admin/flush";

private FlushAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class DeleteMappingAction extends IndicesAction<DeleteMappingRequest, DeleteMappingResponse, DeleteMappingRequestBuilder> {

public static final DeleteMappingAction INSTANCE = new DeleteMappingAction();
public static final String NAME = "indices/mapping/delete";
public static final String NAME = "indices:admin/mapping/delete";

private DeleteMappingAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class GetFieldMappingsAction extends IndicesAction<GetFieldMappingsRequest, GetFieldMappingsResponse, GetFieldMappingsRequestBuilder> {

public static final GetFieldMappingsAction INSTANCE = new GetFieldMappingsAction();
public static final String NAME = "mappings/fields/get";
public static final String NAME = "indices:admin/mappings/fields/get";

private GetFieldMappingsAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class GetMappingsAction extends IndicesAction<GetMappingsRequest, GetMappingsResponse, GetMappingsRequestBuilder> {

public static final GetMappingsAction INSTANCE = new GetMappingsAction();
public static final String NAME = "mappings/get";
public static final String NAME = "indices:admin/mappings/get";

private GetMappingsAction() {
super(NAME);
Expand Down
Expand Up @@ -56,7 +56,7 @@
*/
public class TransportGetFieldMappingsIndexAction extends TransportSingleCustomOperationAction<GetFieldMappingsIndexRequest, GetFieldMappingsResponse> {

private static final String ACTION_NAME = GetFieldMappingsAction.NAME + "/index";
private static final String ACTION_NAME = GetFieldMappingsAction.NAME + "[index]";

protected final ClusterService clusterService;
private final IndicesService indicesService;
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class PutMappingAction extends IndicesAction<PutMappingRequest, PutMappingResponse, PutMappingRequestBuilder> {

public static final PutMappingAction INSTANCE = new PutMappingAction();
public static final String NAME = "indices/mapping/put";
public static final String NAME = "indices:admin/mapping/put";

private PutMappingAction() {
super(NAME);
Expand Down
Expand Up @@ -27,7 +27,7 @@
public class OpenIndexAction extends IndicesAction<OpenIndexRequest, OpenIndexResponse, OpenIndexRequestBuilder> {

public static final OpenIndexAction INSTANCE = new OpenIndexAction();
public static final String NAME = "indices/open";
public static final String NAME = "indices:admin/open";

private OpenIndexAction() {
super(NAME);
Expand Down

0 comments on commit 397a30d

Please sign in to comment.