diff --git a/src/main/java/org/elasticsearch/action/TransportActionModule.java b/src/main/java/org/elasticsearch/action/TransportActionModule.java index 334f1d0911a..5a6765df6bc 100644 --- a/src/main/java/org/elasticsearch/action/TransportActionModule.java +++ b/src/main/java/org/elasticsearch/action/TransportActionModule.java @@ -19,6 +19,7 @@ package org.elasticsearch.action; +import com.google.common.collect.Maps; import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; import org.elasticsearch.action.admin.cluster.node.info.TransportNodesInfoAction; import org.elasticsearch.action.admin.cluster.node.restart.TransportNodesRestartAction; @@ -71,90 +72,125 @@ import org.elasticsearch.action.percolate.TransportPercolateAction; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.search.TransportSearchScrollAction; import org.elasticsearch.action.search.type.*; +import org.elasticsearch.action.support.BaseAction; import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.inject.multibindings.MapBinder; + +import java.util.Map; /** * */ public class TransportActionModule extends AbstractModule { + private final Map actions = Maps.newHashMap(); + + static class ActionEntry { + public final String name; + public final Class action; + public final Class[] supportActions; + + ActionEntry(String name, Class action, Class... supportActions) { + this.name = name; + this.action = action; + this.supportActions = supportActions; + } + + + } + + public TransportActionModule() { + } + + /** + * Registers a custom action under the provided action name, the actual action implementation, and + * any supported actions (bind as singletons). + * + * @param actionName The action name + * @param action The action itself + * @param supportActions Support actions. + */ + public void registerAction(String actionName, Class action, Class... supportActions) { + actions.put(actionName, new ActionEntry(actionName, action, supportActions)); + } + @Override protected void configure() { - bind(TransportNodesInfoAction.class).asEagerSingleton(); - bind(TransportNodesStatsAction.class).asEagerSingleton(); - bind(TransportNodesShutdownAction.class).asEagerSingleton(); - bind(TransportNodesRestartAction.class).asEagerSingleton(); - bind(TransportClusterStateAction.class).asEagerSingleton(); - bind(TransportClusterHealthAction.class).asEagerSingleton(); - bind(TransportClusterUpdateSettingsAction.class).asEagerSingleton(); - bind(TransportClusterRerouteAction.class).asEagerSingleton(); + registerAction(TransportActions.Admin.Cluster.Node.INFO, TransportNodesInfoAction.class); + registerAction(TransportActions.Admin.Cluster.Node.STATS, TransportNodesStatsAction.class); + registerAction(TransportActions.Admin.Cluster.Node.SHUTDOWN, TransportNodesShutdownAction.class); + registerAction(TransportActions.Admin.Cluster.Node.RESTART, TransportNodesRestartAction.class); - bind(TransportSinglePingAction.class).asEagerSingleton(); - bind(TransportBroadcastPingAction.class).asEagerSingleton(); - bind(TransportShardReplicationPingAction.class).asEagerSingleton(); - bind(TransportIndexReplicationPingAction.class).asEagerSingleton(); - bind(TransportReplicationPingAction.class).asEagerSingleton(); + registerAction(TransportActions.Admin.Cluster.STATE, TransportClusterStateAction.class); + registerAction(TransportActions.Admin.Cluster.HEALTH, TransportClusterHealthAction.class); + registerAction(TransportActions.Admin.Cluster.UPDATE_SETTINGS, TransportClusterUpdateSettingsAction.class); + registerAction(TransportActions.Admin.Cluster.REROUTE, TransportClusterRerouteAction.class); - bind(TransportIndicesStatsAction.class).asEagerSingleton(); - bind(TransportIndicesStatusAction.class).asEagerSingleton(); - bind(TransportIndicesSegmentsAction.class).asEagerSingleton(); - bind(TransportCreateIndexAction.class).asEagerSingleton(); - bind(TransportDeleteIndexAction.class).asEagerSingleton(); - bind(TransportOpenIndexAction.class).asEagerSingleton(); - bind(TransportCloseIndexAction.class).asEagerSingleton(); - bind(TransportIndicesExistsAction.class).asEagerSingleton(); - bind(TransportPutMappingAction.class).asEagerSingleton(); - bind(TransportDeleteMappingAction.class).asEagerSingleton(); - bind(TransportIndicesAliasesAction.class).asEagerSingleton(); - bind(TransportUpdateSettingsAction.class).asEagerSingleton(); - bind(TransportAnalyzeAction.class).asEagerSingleton(); - bind(TransportPutIndexTemplateAction.class).asEagerSingleton(); - bind(TransportDeleteIndexTemplateAction.class).asEagerSingleton(); - bind(TransportValidateQueryAction.class).asEagerSingleton(); + registerAction(TransportActions.Admin.Cluster.Ping.SINGLE, TransportSinglePingAction.class); + registerAction(TransportActions.Admin.Cluster.Ping.BROADCAST, TransportBroadcastPingAction.class); + registerAction(TransportActions.Admin.Cluster.Ping.REPLICATION, TransportReplicationPingAction.class, + TransportIndexReplicationPingAction.class, TransportShardReplicationPingAction.class); - bind(TransportGatewaySnapshotAction.class).asEagerSingleton(); + registerAction(TransportActions.Admin.Indices.STATS, TransportIndicesStatsAction.class); + registerAction(TransportActions.Admin.Indices.STATUS, TransportIndicesStatusAction.class); + registerAction(TransportActions.Admin.Indices.SEGMENTS, TransportIndicesSegmentsAction.class); + registerAction(TransportActions.Admin.Indices.CREATE, TransportCreateIndexAction.class); + registerAction(TransportActions.Admin.Indices.DELETE, TransportDeleteIndexAction.class); + registerAction(TransportActions.Admin.Indices.OPEN, TransportOpenIndexAction.class); + registerAction(TransportActions.Admin.Indices.CLOSE, TransportCloseIndexAction.class); + registerAction(TransportActions.Admin.Indices.EXISTS, TransportIndicesExistsAction.class); + registerAction(TransportActions.Admin.Indices.Mapping.PUT, TransportPutMappingAction.class); + registerAction(TransportActions.Admin.Indices.Mapping.DELETE, TransportDeleteMappingAction.class); + registerAction(TransportActions.Admin.Indices.ALIASES, TransportIndicesAliasesAction.class); + registerAction(TransportActions.Admin.Indices.UPDATE_SETTINGS, TransportUpdateSettingsAction.class); + registerAction(TransportActions.Admin.Indices.ANALYZE, TransportAnalyzeAction.class); + registerAction(TransportActions.Admin.Indices.Template.PUT, TransportPutIndexTemplateAction.class); + registerAction(TransportActions.Admin.Indices.Template.DELETE, TransportDeleteIndexTemplateAction.class); + registerAction(TransportActions.Admin.Indices.Validate.QUERY, TransportValidateQueryAction.class); + registerAction(TransportActions.Admin.Indices.Gateway.SNAPSHOT, TransportGatewaySnapshotAction.class); + registerAction(TransportActions.Admin.Indices.REFRESH, TransportRefreshAction.class); + registerAction(TransportActions.Admin.Indices.FLUSH, TransportFlushAction.class); + registerAction(TransportActions.Admin.Indices.OPTIMIZE, TransportOptimizeAction.class); + registerAction(TransportActions.Admin.Indices.Cache.CLEAR, TransportClearIndicesCacheAction.class); - bind(TransportRefreshAction.class).asEagerSingleton(); - bind(TransportFlushAction.class).asEagerSingleton(); - bind(TransportOptimizeAction.class).asEagerSingleton(); - bind(TransportClearIndicesCacheAction.class).asEagerSingleton(); + registerAction(TransportActions.INDEX, TransportIndexAction.class); + registerAction(TransportActions.GET, TransportGetAction.class); + registerAction(TransportActions.DELETE, TransportDeleteAction.class, + TransportIndexDeleteAction.class, TransportShardDeleteAction.class); + registerAction(TransportActions.COUNT, TransportCountAction.class); + registerAction(TransportActions.UPDATE, TransportUpdateAction.class); + registerAction(TransportActions.MULTI_GET, TransportMultiGetAction.class, + TransportShardMultiGetAction.class); + registerAction(TransportActions.BULK, TransportBulkAction.class, + TransportShardBulkAction.class); + registerAction(TransportActions.DELETE_BY_QUERY, TransportDeleteByQueryAction.class, + TransportIndexDeleteByQueryAction.class, TransportShardDeleteByQueryAction.class); + registerAction(TransportActions.SEARCH, TransportSearchAction.class, + TransportSearchCache.class, + TransportSearchDfsQueryThenFetchAction.class, + TransportSearchQueryThenFetchAction.class, + TransportSearchDfsQueryAndFetchAction.class, + TransportSearchQueryAndFetchAction.class, + TransportSearchScanAction.class + ); + registerAction(TransportActions.SEARCH_SCROLL, TransportSearchScrollAction.class, + TransportSearchScrollScanAction.class, + TransportSearchScrollQueryThenFetchAction.class, + TransportSearchScrollQueryAndFetchAction.class + ); + registerAction(TransportActions.MORE_LIKE_THIS, TransportMoreLikeThisAction.class); + registerAction(TransportActions.PERCOLATE, TransportPercolateAction.class); - bind(TransportIndexAction.class).asEagerSingleton(); - bind(TransportGetAction.class).asEagerSingleton(); - bind(TransportDeleteAction.class).asEagerSingleton(); - bind(TransportIndexDeleteAction.class).asEagerSingleton(); - bind(TransportShardDeleteAction.class).asEagerSingleton(); - bind(TransportCountAction.class).asEagerSingleton(); - bind(TransportUpdateAction.class).asEagerSingleton(); + MapBinder actionsBinder + = MapBinder.newMapBinder(binder(), String.class, BaseAction.class); - bind(TransportMultiGetAction.class).asEagerSingleton(); - bind(TransportShardMultiGetAction.class).asEagerSingleton(); - - bind(TransportBulkAction.class).asEagerSingleton(); - bind(TransportShardBulkAction.class).asEagerSingleton(); - - bind(TransportShardDeleteByQueryAction.class).asEagerSingleton(); - bind(TransportIndexDeleteByQueryAction.class).asEagerSingleton(); - bind(TransportDeleteByQueryAction.class).asEagerSingleton(); - - - bind(TransportSearchCache.class).asEagerSingleton(); - bind(TransportSearchDfsQueryThenFetchAction.class).asEagerSingleton(); - bind(TransportSearchQueryThenFetchAction.class).asEagerSingleton(); - bind(TransportSearchDfsQueryAndFetchAction.class).asEagerSingleton(); - bind(TransportSearchQueryAndFetchAction.class).asEagerSingleton(); - bind(TransportSearchScanAction.class).asEagerSingleton(); - bind(TransportSearchAction.class).asEagerSingleton(); - - bind(TransportSearchScrollScanAction.class).asEagerSingleton(); - bind(TransportSearchScrollQueryThenFetchAction.class).asEagerSingleton(); - bind(TransportSearchScrollQueryAndFetchAction.class).asEagerSingleton(); - bind(TransportSearchScrollAction.class).asEagerSingleton(); - - bind(TransportMoreLikeThisAction.class).asEagerSingleton(); - - bind(TransportPercolateAction.class).asEagerSingleton(); + for (Map.Entry entry : actions.entrySet()) { + actionsBinder.addBinding(entry.getKey()).to(entry.getValue().action).asEagerSingleton(); + for (Class supportAction : entry.getValue().supportActions) { + bind(supportAction).asEagerSingleton(); + } + } } } diff --git a/src/main/java/org/elasticsearch/action/TransportActions.java b/src/main/java/org/elasticsearch/action/TransportActions.java index f98af2c008a..8f9d49d688c 100644 --- a/src/main/java/org/elasticsearch/action/TransportActions.java +++ b/src/main/java/org/elasticsearch/action/TransportActions.java @@ -54,9 +54,6 @@ public class TransportActions { public static final String ALIASES = "indices/aliases"; public static final String UPDATE_SETTINGS = "indices/updateSettings"; public static final String ANALYZE = "indices/analyze"; - public static final String PUT_INDEX_TEMPLATE = "indices/putIndexTemplate"; - public static final String DELETE_INDEX_TEMPLATE = "indices/deleteIndexTemplate"; - public static final String VALIDATE_QUERY = "indices/validateQuery"; public static class Gateway { public static final String SNAPSHOT = "indices/gateway/snapshot"; @@ -67,6 +64,15 @@ public class TransportActions { public static final String DELETE = "indices/mapping/delete"; } + public static class Template { + public static final String PUT = "indices/template/put"; + public static final String DELETE = "indices/template/delete"; + } + + public static class Validate { + public static final String QUERY = "indices/validate/query"; + } + public static class Cache { public static final String CLEAR = "indices/cache/clear"; } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java index 2ac0a23aa1c..2e9d8031450 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java @@ -37,8 +37,6 @@ import java.util.concurrent.atomic.AtomicReference; /** * Delete index action. - * - * */ public class TransportDeleteIndexTemplateAction extends TransportMasterNodeOperationAction { @@ -58,7 +56,7 @@ public class TransportDeleteIndexTemplateAction extends TransportMasterNodeOpera @Override protected String transportAction() { - return TransportActions.Admin.Indices.DELETE_INDEX_TEMPLATE; + return TransportActions.Admin.Indices.Template.DELETE; } @Override diff --git a/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java b/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java index 4b9d0887fb9..234618901f6 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java @@ -37,8 +37,6 @@ import java.util.concurrent.atomic.AtomicReference; /** * Put index template action. - * - * */ public class TransportPutIndexTemplateAction extends TransportMasterNodeOperationAction { @@ -58,7 +56,7 @@ public class TransportPutIndexTemplateAction extends TransportMasterNodeOperatio @Override protected String transportAction() { - return TransportActions.Admin.Indices.PUT_INDEX_TEMPLATE; + return TransportActions.Admin.Indices.Template.PUT; } @Override diff --git a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java index a8fec5bce64..89e86ea901e 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java @@ -67,7 +67,7 @@ public class TransportValidateQueryAction extends TransportBroadcastOperationAct @Override protected String transportAction() { - return TransportActions.Admin.Indices.VALIDATE_QUERY; + return TransportActions.Admin.Indices.Validate.QUERY; } @Override diff --git a/src/main/java/org/elasticsearch/client/node/NodeClient.java b/src/main/java/org/elasticsearch/client/node/NodeClient.java index 8f52e14e8ab..aa733170ff6 100644 --- a/src/main/java/org/elasticsearch/client/node/NodeClient.java +++ b/src/main/java/org/elasticsearch/client/node/NodeClient.java @@ -21,6 +21,7 @@ package org.elasticsearch.client.node; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.TransportActions; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.TransportBulkAction; @@ -43,6 +44,7 @@ import org.elasticsearch.action.percolate.PercolateRequest; import org.elasticsearch.action.percolate.PercolateResponse; import org.elasticsearch.action.percolate.TransportPercolateAction; import org.elasticsearch.action.search.*; +import org.elasticsearch.action.support.BaseAction; import org.elasticsearch.action.update.TransportUpdateAction; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.action.update.UpdateResponse; @@ -53,6 +55,8 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; +import java.util.Map; + /** * */ @@ -87,25 +91,21 @@ public class NodeClient extends AbstractClient implements InternalClient { private final TransportPercolateAction percolateAction; @Inject - public NodeClient(Settings settings, ThreadPool threadPool, NodeAdminClient admin, - TransportIndexAction indexAction, TransportUpdateAction updateAction, TransportDeleteAction deleteAction, TransportBulkAction bulkAction, - TransportDeleteByQueryAction deleteByQueryAction, TransportGetAction getAction, TransportMultiGetAction multiGetAction, TransportCountAction countAction, - TransportSearchAction searchAction, TransportSearchScrollAction searchScrollAction, - TransportMoreLikeThisAction moreLikeThisAction, TransportPercolateAction percolateAction) { + public NodeClient(Settings settings, ThreadPool threadPool, NodeAdminClient admin, Map actions) { this.threadPool = threadPool; this.admin = admin; - this.indexAction = indexAction; - this.updateAction = updateAction; - this.deleteAction = deleteAction; - this.bulkAction = bulkAction; - this.deleteByQueryAction = deleteByQueryAction; - this.getAction = getAction; - this.multiGetAction = multiGetAction; - this.countAction = countAction; - this.searchAction = searchAction; - this.searchScrollAction = searchScrollAction; - this.moreLikeThisAction = moreLikeThisAction; - this.percolateAction = percolateAction; + this.indexAction = (TransportIndexAction) actions.get(TransportActions.INDEX); + this.updateAction = (TransportUpdateAction) actions.get(TransportActions.UPDATE); + this.deleteAction = (TransportDeleteAction) actions.get(TransportActions.DELETE); + this.bulkAction = (TransportBulkAction) actions.get(TransportActions.BULK); + this.deleteByQueryAction = (TransportDeleteByQueryAction) actions.get(TransportActions.DELETE_BY_QUERY); + this.getAction = (TransportGetAction) actions.get(TransportActions.GET); + this.multiGetAction = (TransportMultiGetAction) actions.get(TransportActions.MULTI_GET); + this.countAction = (TransportCountAction) actions.get(TransportActions.COUNT); + this.searchAction = (TransportSearchAction) actions.get(TransportActions.SEARCH); + this.searchScrollAction = (TransportSearchScrollAction) actions.get(TransportActions.SEARCH_SCROLL); + this.moreLikeThisAction = (TransportMoreLikeThisAction) actions.get(TransportActions.MORE_LIKE_THIS); + this.percolateAction = (TransportPercolateAction) actions.get(TransportActions.PERCOLATE); } @Override diff --git a/src/main/java/org/elasticsearch/client/node/NodeClusterAdminClient.java b/src/main/java/org/elasticsearch/client/node/NodeClusterAdminClient.java index 81a2b14207b..d97b4b77c67 100644 --- a/src/main/java/org/elasticsearch/client/node/NodeClusterAdminClient.java +++ b/src/main/java/org/elasticsearch/client/node/NodeClusterAdminClient.java @@ -21,6 +21,7 @@ package org.elasticsearch.client.node; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.TransportActions; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction; @@ -54,12 +55,15 @@ import org.elasticsearch.action.admin.cluster.settings.TransportClusterUpdateSet import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.cluster.state.TransportClusterStateAction; +import org.elasticsearch.action.support.BaseAction; import org.elasticsearch.client.internal.InternalClusterAdminClient; import org.elasticsearch.client.support.AbstractClusterAdminClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; +import java.util.Map; + /** * */ @@ -90,22 +94,19 @@ public class NodeClusterAdminClient extends AbstractClusterAdminClient implement private final TransportNodesRestartAction nodesRestart; @Inject - public NodeClusterAdminClient(Settings settings, ThreadPool threadPool, - TransportClusterHealthAction clusterHealthAction, TransportClusterStateAction clusterStateAction, TransportClusterRerouteAction clusterRerouteAction, TransportClusterUpdateSettingsAction clusterUpdateSettingsAction, - TransportSinglePingAction singlePingAction, TransportBroadcastPingAction broadcastPingAction, TransportReplicationPingAction replicationPingAction, - TransportNodesInfoAction nodesInfoAction, TransportNodesShutdownAction nodesShutdown, TransportNodesRestartAction nodesRestart, TransportNodesStatsAction nodesStatsAction) { + public NodeClusterAdminClient(Settings settings, ThreadPool threadPool, Map actions) { this.threadPool = threadPool; - this.clusterRerouteAction = clusterRerouteAction; - this.clusterHealthAction = clusterHealthAction; - this.clusterStateAction = clusterStateAction; - this.clusterUpdateSettingsAction = clusterUpdateSettingsAction; - this.nodesInfoAction = nodesInfoAction; - this.nodesShutdown = nodesShutdown; - this.nodesRestart = nodesRestart; - this.singlePingAction = singlePingAction; - this.broadcastPingAction = broadcastPingAction; - this.replicationPingAction = replicationPingAction; - this.nodesStatsAction = nodesStatsAction; + this.clusterRerouteAction = (TransportClusterRerouteAction) actions.get(TransportActions.Admin.Cluster.REROUTE); + this.clusterHealthAction = (TransportClusterHealthAction) actions.get(TransportActions.Admin.Cluster.HEALTH); + this.clusterStateAction = (TransportClusterStateAction) actions.get(TransportActions.Admin.Cluster.STATE); + this.clusterUpdateSettingsAction = (TransportClusterUpdateSettingsAction) actions.get(TransportActions.Admin.Cluster.UPDATE_SETTINGS); + this.nodesInfoAction = (TransportNodesInfoAction) actions.get(TransportActions.Admin.Cluster.Node.INFO); + this.nodesStatsAction = (TransportNodesStatsAction) actions.get(TransportActions.Admin.Cluster.Node.STATS); + this.nodesShutdown = (TransportNodesShutdownAction) actions.get(TransportActions.Admin.Cluster.Node.SHUTDOWN); + this.nodesRestart = (TransportNodesRestartAction) actions.get(TransportActions.Admin.Cluster.Node.RESTART); + this.singlePingAction = (TransportSinglePingAction) actions.get(TransportActions.Admin.Cluster.Ping.SINGLE); + this.broadcastPingAction = (TransportBroadcastPingAction) actions.get(TransportActions.Admin.Cluster.Ping.BROADCAST); + this.replicationPingAction = (TransportReplicationPingAction) actions.get(TransportActions.Admin.Cluster.Ping.REPLICATION); } @Override diff --git a/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java b/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java index a0953a22a55..d318351c825 100644 --- a/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/node/NodeIndicesAdminClient.java @@ -21,6 +21,7 @@ package org.elasticsearch.client.node; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.TransportActions; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction; @@ -84,12 +85,15 @@ import org.elasticsearch.action.admin.indices.template.put.TransportPutIndexTemp import org.elasticsearch.action.admin.indices.validate.query.TransportValidateQueryAction; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; +import org.elasticsearch.action.support.BaseAction; import org.elasticsearch.client.IndicesAdminClient; import org.elasticsearch.client.support.AbstractIndicesAdminClient; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; +import java.util.Map; + /** * */ @@ -140,36 +144,29 @@ public class NodeIndicesAdminClient extends AbstractIndicesAdminClient implement private final TransportValidateQueryAction validateQueryAction; @Inject - public NodeIndicesAdminClient(Settings settings, ThreadPool threadPool, TransportIndicesExistsAction indicesExistsAction, TransportIndicesStatsAction indicesStatsAction, TransportIndicesStatusAction indicesStatusAction, TransportIndicesSegmentsAction indicesSegmentsAction, - TransportCreateIndexAction createIndexAction, TransportDeleteIndexAction deleteIndexAction, - TransportCloseIndexAction closeIndexAction, TransportOpenIndexAction openIndexAction, - TransportRefreshAction refreshAction, TransportFlushAction flushAction, TransportOptimizeAction optimizeAction, - TransportPutMappingAction putMappingAction, TransportDeleteMappingAction deleteMappingAction, TransportGatewaySnapshotAction gatewaySnapshotAction, - TransportIndicesAliasesAction indicesAliasesAction, TransportClearIndicesCacheAction clearIndicesCacheAction, - TransportUpdateSettingsAction updateSettingsAction, TransportAnalyzeAction analyzeAction, - TransportPutIndexTemplateAction putIndexTemplateAction, TransportDeleteIndexTemplateAction deleteIndexTemplateAction, TransportValidateQueryAction validateQueryAction) { + public NodeIndicesAdminClient(Settings settings, ThreadPool threadPool, Map actions) { this.threadPool = threadPool; - this.indicesExistsAction = indicesExistsAction; - this.indicesStatsAction = indicesStatsAction; - this.indicesStatusAction = indicesStatusAction; - this.indicesSegmentsAction = indicesSegmentsAction; - this.createIndexAction = createIndexAction; - this.deleteIndexAction = deleteIndexAction; - this.closeIndexAction = closeIndexAction; - this.openIndexAction = openIndexAction; - this.refreshAction = refreshAction; - this.flushAction = flushAction; - this.optimizeAction = optimizeAction; - this.deleteMappingAction = deleteMappingAction; - this.putMappingAction = putMappingAction; - this.gatewaySnapshotAction = gatewaySnapshotAction; - this.indicesAliasesAction = indicesAliasesAction; - this.clearIndicesCacheAction = clearIndicesCacheAction; - this.updateSettingsAction = updateSettingsAction; - this.analyzeAction = analyzeAction; - this.putIndexTemplateAction = putIndexTemplateAction; - this.deleteIndexTemplateAction = deleteIndexTemplateAction; - this.validateQueryAction = validateQueryAction; + this.indicesExistsAction = (TransportIndicesExistsAction) actions.get(TransportActions.Admin.Indices.EXISTS); + this.indicesStatsAction = (TransportIndicesStatsAction) actions.get(TransportActions.Admin.Indices.STATS); + this.indicesStatusAction = (TransportIndicesStatusAction) actions.get(TransportActions.Admin.Indices.STATUS); + this.indicesSegmentsAction = (TransportIndicesSegmentsAction) actions.get(TransportActions.Admin.Indices.SEGMENTS); + this.createIndexAction = (TransportCreateIndexAction) actions.get(TransportActions.Admin.Indices.CREATE); + this.deleteIndexAction = (TransportDeleteIndexAction) actions.get(TransportActions.Admin.Indices.DELETE); + this.closeIndexAction = (TransportCloseIndexAction) actions.get(TransportActions.Admin.Indices.CLOSE); + this.openIndexAction = (TransportOpenIndexAction) actions.get(TransportActions.Admin.Indices.OPEN); + this.refreshAction = (TransportRefreshAction) actions.get(TransportActions.Admin.Indices.REFRESH); + this.flushAction = (TransportFlushAction) actions.get(TransportActions.Admin.Indices.FLUSH); + this.optimizeAction = (TransportOptimizeAction) actions.get(TransportActions.Admin.Indices.OPTIMIZE); + this.deleteMappingAction = (TransportDeleteMappingAction) actions.get(TransportActions.Admin.Indices.Mapping.DELETE); + this.putMappingAction = (TransportPutMappingAction) actions.get(TransportActions.Admin.Indices.Mapping.PUT); + this.gatewaySnapshotAction = (TransportGatewaySnapshotAction) actions.get(TransportActions.Admin.Indices.Gateway.SNAPSHOT); + this.indicesAliasesAction = (TransportIndicesAliasesAction) actions.get(TransportActions.Admin.Indices.ALIASES); + this.clearIndicesCacheAction = (TransportClearIndicesCacheAction) actions.get(TransportActions.Admin.Indices.Cache.CLEAR); + this.updateSettingsAction = (TransportUpdateSettingsAction) actions.get(TransportActions.Admin.Indices.UPDATE_SETTINGS); + this.analyzeAction = (TransportAnalyzeAction) actions.get(TransportActions.Admin.Indices.ANALYZE); + this.putIndexTemplateAction = (TransportPutIndexTemplateAction) actions.get(TransportActions.Admin.Indices.Template.PUT); + this.deleteIndexTemplateAction = (TransportDeleteIndexTemplateAction) actions.get(TransportActions.Admin.Indices.Template.DELETE); + this.validateQueryAction = (TransportValidateQueryAction) actions.get(TransportActions.Admin.Indices.Validate.QUERY); } @Override diff --git a/src/main/java/org/elasticsearch/client/transport/action/ClientTransportActionModule.java b/src/main/java/org/elasticsearch/client/transport/action/ClientTransportActionModule.java index 1db0d2f5053..67a84b71438 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/ClientTransportActionModule.java +++ b/src/main/java/org/elasticsearch/client/transport/action/ClientTransportActionModule.java @@ -19,6 +19,8 @@ package org.elasticsearch.client.transport.action; +import com.google.common.collect.Maps; +import org.elasticsearch.action.TransportActions; import org.elasticsearch.client.transport.action.admin.cluster.health.ClientTransportClusterHealthAction; import org.elasticsearch.client.transport.action.admin.cluster.node.info.ClientTransportNodesInfoAction; import org.elasticsearch.client.transport.action.admin.cluster.node.restart.ClientTransportNodesRestartAction; @@ -61,60 +63,100 @@ import org.elasticsearch.client.transport.action.index.ClientTransportIndexActio import org.elasticsearch.client.transport.action.percolate.ClientTransportPercolateAction; import org.elasticsearch.client.transport.action.search.ClientTransportSearchAction; import org.elasticsearch.client.transport.action.search.ClientTransportSearchScrollAction; +import org.elasticsearch.client.transport.action.support.BaseClientTransportAction; import org.elasticsearch.client.transport.action.update.ClientTransportUpdateAction; import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.inject.multibindings.MapBinder; + +import java.util.Map; /** * */ public class ClientTransportActionModule extends AbstractModule { + private final Map actions = Maps.newHashMap(); + + static class ActionEntry { + public final String name; + public final Class action; + public final Class[] supportActions; + + ActionEntry(String name, Class action, Class... supportActions) { + this.name = name; + this.action = action; + this.supportActions = supportActions; + } + } + + /** + * Registers a custom action under the provided action name, the actual action implementation, and + * any supported actions (bind as singletons). + * + * @param actionName The action name + * @param action The action itself + * @param supportActions Support actions. + */ + public void registerAction(String actionName, Class action, Class... supportActions) { + actions.put(actionName, new ActionEntry(actionName, action, supportActions)); + } + @Override protected void configure() { - bind(ClientTransportIndexAction.class).asEagerSingleton(); - bind(ClientTransportDeleteAction.class).asEagerSingleton(); - bind(ClientTransportDeleteByQueryAction.class).asEagerSingleton(); - bind(ClientTransportGetAction.class).asEagerSingleton(); - bind(ClientTransportMultiGetAction.class).asEagerSingleton(); - bind(ClientTransportCountAction.class).asEagerSingleton(); - bind(ClientTransportSearchAction.class).asEagerSingleton(); - bind(ClientTransportSearchScrollAction.class).asEagerSingleton(); - bind(ClientTransportBulkAction.class).asEagerSingleton(); - bind(ClientTransportPercolateAction.class).asEagerSingleton(); - bind(ClientTransportUpdateAction.class).asEagerSingleton(); + registerAction(TransportActions.INDEX, ClientTransportIndexAction.class); + registerAction(TransportActions.DELETE, ClientTransportDeleteAction.class); + registerAction(TransportActions.DELETE_BY_QUERY, ClientTransportDeleteByQueryAction.class); + registerAction(TransportActions.GET, ClientTransportGetAction.class); + registerAction(TransportActions.MULTI_GET, ClientTransportMultiGetAction.class); + registerAction(TransportActions.COUNT, ClientTransportCountAction.class); + registerAction(TransportActions.SEARCH, ClientTransportSearchAction.class); + registerAction(TransportActions.SEARCH_SCROLL, ClientTransportSearchScrollAction.class); + registerAction(TransportActions.BULK, ClientTransportBulkAction.class); + registerAction(TransportActions.PERCOLATE, ClientTransportPercolateAction.class); + registerAction(TransportActions.UPDATE, ClientTransportUpdateAction.class); - bind(ClientTransportIndicesExistsAction.class).asEagerSingleton(); - bind(ClientTransportIndicesStatsAction.class).asEagerSingleton(); - bind(ClientTransportIndicesStatusAction.class).asEagerSingleton(); - bind(ClientTransportIndicesSegmentsAction.class).asEagerSingleton(); - bind(ClientTransportRefreshAction.class).asEagerSingleton(); - bind(ClientTransportFlushAction.class).asEagerSingleton(); - bind(ClientTransportOptimizeAction.class).asEagerSingleton(); - bind(ClientTransportCreateIndexAction.class).asEagerSingleton(); - bind(ClientTransportDeleteIndexAction.class).asEagerSingleton(); - bind(ClientTransportCloseIndexAction.class).asEagerSingleton(); - bind(ClientTransportOpenIndexAction.class).asEagerSingleton(); - bind(ClientTransportPutMappingAction.class).asEagerSingleton(); - bind(ClientTransportDeleteMappingAction.class).asEagerSingleton(); - bind(ClientTransportGatewaySnapshotAction.class).asEagerSingleton(); - bind(ClientTransportIndicesAliasesAction.class).asEagerSingleton(); - bind(ClientTransportClearIndicesCacheAction.class).asEagerSingleton(); - bind(ClientTransportUpdateSettingsAction.class).asEagerSingleton(); - bind(ClientTransportAnalyzeAction.class).asEagerSingleton(); - bind(ClientTransportPutIndexTemplateAction.class).asEagerSingleton(); - bind(ClientTransportDeleteIndexTemplateAction.class).asEagerSingleton(); - bind(ClientTransportValidateQueryAction.class).asEagerSingleton(); + registerAction(TransportActions.Admin.Indices.EXISTS, ClientTransportIndicesExistsAction.class); + registerAction(TransportActions.Admin.Indices.STATS, ClientTransportIndicesStatsAction.class); + registerAction(TransportActions.Admin.Indices.STATUS, ClientTransportIndicesStatusAction.class); + registerAction(TransportActions.Admin.Indices.SEGMENTS, ClientTransportIndicesSegmentsAction.class); + registerAction(TransportActions.Admin.Indices.REFRESH, ClientTransportRefreshAction.class); + registerAction(TransportActions.Admin.Indices.FLUSH, ClientTransportFlushAction.class); + registerAction(TransportActions.Admin.Indices.OPTIMIZE, ClientTransportOptimizeAction.class); + registerAction(TransportActions.Admin.Indices.CREATE, ClientTransportCreateIndexAction.class); + registerAction(TransportActions.Admin.Indices.DELETE, ClientTransportDeleteIndexAction.class); + registerAction(TransportActions.Admin.Indices.CLOSE, ClientTransportCloseIndexAction.class); + registerAction(TransportActions.Admin.Indices.OPEN, ClientTransportOpenIndexAction.class); + registerAction(TransportActions.Admin.Indices.Mapping.PUT, ClientTransportPutMappingAction.class); + registerAction(TransportActions.Admin.Indices.Mapping.DELETE, ClientTransportDeleteMappingAction.class); + registerAction(TransportActions.Admin.Indices.Gateway.SNAPSHOT, ClientTransportGatewaySnapshotAction.class); + registerAction(TransportActions.Admin.Indices.ALIASES, ClientTransportIndicesAliasesAction.class); + registerAction(TransportActions.Admin.Indices.Cache.CLEAR, ClientTransportClearIndicesCacheAction.class); + registerAction(TransportActions.Admin.Indices.UPDATE_SETTINGS, ClientTransportUpdateSettingsAction.class); + registerAction(TransportActions.Admin.Indices.ANALYZE, ClientTransportAnalyzeAction.class); + registerAction(TransportActions.Admin.Indices.Template.PUT, ClientTransportPutIndexTemplateAction.class); + registerAction(TransportActions.Admin.Indices.Template.DELETE, ClientTransportDeleteIndexTemplateAction.class); + registerAction(TransportActions.Admin.Indices.Validate.QUERY, ClientTransportValidateQueryAction.class); - bind(ClientTransportNodesInfoAction.class).asEagerSingleton(); - bind(ClientTransportNodesStatsAction.class).asEagerSingleton(); - bind(ClientTransportNodesShutdownAction.class).asEagerSingleton(); - bind(ClientTransportNodesRestartAction.class).asEagerSingleton(); - bind(ClientTransportSinglePingAction.class).asEagerSingleton(); - bind(ClientTransportReplicationPingAction.class).asEagerSingleton(); - bind(ClientTransportBroadcastPingAction.class).asEagerSingleton(); - bind(ClientTransportClusterStateAction.class).asEagerSingleton(); - bind(ClientTransportClusterHealthAction.class).asEagerSingleton(); - bind(ClientTransportClusterUpdateSettingsAction.class).asEagerSingleton(); - bind(ClientTransportClusterRerouteAction.class).asEagerSingleton(); + registerAction(TransportActions.Admin.Cluster.Node.INFO, ClientTransportNodesInfoAction.class); + registerAction(TransportActions.Admin.Cluster.Node.STATS, ClientTransportNodesStatsAction.class); + registerAction(TransportActions.Admin.Cluster.Node.SHUTDOWN, ClientTransportNodesShutdownAction.class); + registerAction(TransportActions.Admin.Cluster.Node.RESTART, ClientTransportNodesRestartAction.class); + registerAction(TransportActions.Admin.Cluster.Ping.SINGLE, ClientTransportSinglePingAction.class); + registerAction(TransportActions.Admin.Cluster.Ping.REPLICATION, ClientTransportReplicationPingAction.class); + registerAction(TransportActions.Admin.Cluster.Ping.BROADCAST, ClientTransportBroadcastPingAction.class); + registerAction(TransportActions.Admin.Cluster.STATE, ClientTransportClusterStateAction.class); + registerAction(TransportActions.Admin.Cluster.HEALTH, ClientTransportClusterHealthAction.class); + registerAction(TransportActions.Admin.Cluster.UPDATE_SETTINGS, ClientTransportClusterUpdateSettingsAction.class); + registerAction(TransportActions.Admin.Cluster.REROUTE, ClientTransportClusterRerouteAction.class); + + MapBinder actionsBinder + = MapBinder.newMapBinder(binder(), String.class, BaseClientTransportAction.class); + + for (Map.Entry entry : actions.entrySet()) { + actionsBinder.addBinding(entry.getKey()).to(entry.getValue().action).asEagerSingleton(); + for (Class supportAction : entry.getValue().supportActions) { + bind(supportAction).asEagerSingleton(); + } + } } } diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/delete/ClientTransportDeleteIndexTemplateAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/delete/ClientTransportDeleteIndexTemplateAction.java index fe6d7d193b3..ab91878f9f0 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/delete/ClientTransportDeleteIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/delete/ClientTransportDeleteIndexTemplateAction.java @@ -39,6 +39,6 @@ public class ClientTransportDeleteIndexTemplateAction extends BaseClientTranspor @Override protected String action() { - return TransportActions.Admin.Indices.DELETE_INDEX_TEMPLATE; + return TransportActions.Admin.Indices.Template.DELETE; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/put/ClientTransportPutIndexTemplateAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/put/ClientTransportPutIndexTemplateAction.java index b8e7331cce6..38618792553 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/put/ClientTransportPutIndexTemplateAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/template/put/ClientTransportPutIndexTemplateAction.java @@ -39,6 +39,6 @@ public class ClientTransportPutIndexTemplateAction extends BaseClientTransportAc @Override protected String action() { - return TransportActions.Admin.Indices.PUT_INDEX_TEMPLATE; + return TransportActions.Admin.Indices.Template.PUT; } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/validate/query/ClientTransportValidateQueryAction.java b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/validate/query/ClientTransportValidateQueryAction.java index 1072b28c140..0612dfcbe87 100644 --- a/src/main/java/org/elasticsearch/client/transport/action/admin/indices/validate/query/ClientTransportValidateQueryAction.java +++ b/src/main/java/org/elasticsearch/client/transport/action/admin/indices/validate/query/ClientTransportValidateQueryAction.java @@ -20,6 +20,6 @@ public class ClientTransportValidateQueryAction extends BaseClientTransportActio @Override protected String action() { - return TransportActions.Admin.Indices.VALIDATE_QUERY; + return TransportActions.Admin.Indices.Validate.QUERY; } } diff --git a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java index 526e1bbe3e5..8bfb59e35f0 100644 --- a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java +++ b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClient.java @@ -22,6 +22,7 @@ package org.elasticsearch.client.transport.support; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.TransportActions; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.count.CountRequest; @@ -59,12 +60,15 @@ import org.elasticsearch.client.transport.action.mlt.ClientTransportMoreLikeThis import org.elasticsearch.client.transport.action.percolate.ClientTransportPercolateAction; import org.elasticsearch.client.transport.action.search.ClientTransportSearchAction; import org.elasticsearch.client.transport.action.search.ClientTransportSearchScrollAction; +import org.elasticsearch.client.transport.action.support.BaseClientTransportAction; import org.elasticsearch.client.transport.action.update.ClientTransportUpdateAction; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; +import java.util.Map; + /** * */ @@ -103,26 +107,23 @@ public class InternalTransportClient extends AbstractClient implements InternalC @Inject public InternalTransportClient(Settings settings, ThreadPool threadPool, TransportClientNodesService nodesService, InternalTransportAdminClient adminClient, - ClientTransportIndexAction indexAction, ClientTransportUpdateAction updateAction, ClientTransportDeleteAction deleteAction, ClientTransportBulkAction bulkAction, ClientTransportGetAction getAction, ClientTransportMultiGetAction multiGetAction, - ClientTransportDeleteByQueryAction deleteByQueryAction, ClientTransportCountAction countAction, - ClientTransportSearchAction searchAction, ClientTransportSearchScrollAction searchScrollAction, - ClientTransportMoreLikeThisAction moreLikeThisAction, ClientTransportPercolateAction percolateAction) { + Map actions) { this.threadPool = threadPool; this.nodesService = nodesService; this.adminClient = adminClient; - this.indexAction = indexAction; - this.updateAction = updateAction; - this.deleteAction = deleteAction; - this.bulkAction = bulkAction; - this.getAction = getAction; - this.multiGetAction = multiGetAction; - this.deleteByQueryAction = deleteByQueryAction; - this.countAction = countAction; - this.searchAction = searchAction; - this.searchScrollAction = searchScrollAction; - this.moreLikeThisAction = moreLikeThisAction; - this.percolateAction = percolateAction; + this.indexAction = (ClientTransportIndexAction) actions.get(TransportActions.INDEX); + this.updateAction = (ClientTransportUpdateAction) actions.get(TransportActions.UPDATE); + this.deleteAction = (ClientTransportDeleteAction) actions.get(TransportActions.DELETE); + this.bulkAction = (ClientTransportBulkAction) actions.get(TransportActions.BULK); + this.getAction = (ClientTransportGetAction) actions.get(TransportActions.GET); + this.multiGetAction = (ClientTransportMultiGetAction) actions.get(TransportActions.MULTI_GET); + this.deleteByQueryAction = (ClientTransportDeleteByQueryAction) actions.get(TransportActions.DELETE_BY_QUERY); + this.countAction = (ClientTransportCountAction) actions.get(TransportActions.COUNT); + this.searchAction = (ClientTransportSearchAction) actions.get(TransportActions.SEARCH); + this.searchScrollAction = (ClientTransportSearchScrollAction) actions.get(TransportActions.SEARCH_SCROLL); + this.moreLikeThisAction = (ClientTransportMoreLikeThisAction) actions.get(TransportActions.MORE_LIKE_THIS); + this.percolateAction = (ClientTransportPercolateAction) actions.get(TransportActions.PERCOLATE); } @Override diff --git a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClusterAdminClient.java b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClusterAdminClient.java index 6b242ff99a0..f5c73322b07 100644 --- a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClusterAdminClient.java +++ b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportClusterAdminClient.java @@ -22,6 +22,7 @@ package org.elasticsearch.client.transport.support; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.TransportActions; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest; @@ -58,11 +59,14 @@ import org.elasticsearch.client.transport.action.admin.cluster.ping.single.Clien import org.elasticsearch.client.transport.action.admin.cluster.reroute.ClientTransportClusterRerouteAction; import org.elasticsearch.client.transport.action.admin.cluster.settings.ClientTransportClusterUpdateSettingsAction; import org.elasticsearch.client.transport.action.admin.cluster.state.ClientTransportClusterStateAction; +import org.elasticsearch.client.transport.action.support.BaseClientTransportAction; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; +import java.util.Map; + /** * */ @@ -96,22 +100,20 @@ public class InternalTransportClusterAdminClient extends AbstractClusterAdminCli @Inject public InternalTransportClusterAdminClient(Settings settings, TransportClientNodesService nodesService, ThreadPool threadPool, - ClientTransportClusterHealthAction clusterHealthAction, ClientTransportClusterStateAction clusterStateAction, ClientTransportClusterRerouteAction clusterRerouteAction, ClientTransportClusterUpdateSettingsAction clusterUpdateSettingsAction, - ClientTransportSinglePingAction singlePingAction, ClientTransportReplicationPingAction replicationPingAction, ClientTransportBroadcastPingAction broadcastPingAction, - ClientTransportNodesInfoAction nodesInfoAction, ClientTransportNodesShutdownAction nodesShutdownAction, ClientTransportNodesRestartAction nodesRestartAction, ClientTransportNodesStatsAction nodesStatsAction) { + Map actions) { this.nodesService = nodesService; this.threadPool = threadPool; - this.clusterHealthAction = clusterHealthAction; - this.clusterRerouteAction = clusterRerouteAction; - this.clusterStateAction = clusterStateAction; - this.clusterUpdateSettingsAction = clusterUpdateSettingsAction; - this.nodesInfoAction = nodesInfoAction; - this.nodesShutdownAction = nodesShutdownAction; - this.nodesRestartAction = nodesRestartAction; - this.singlePingAction = singlePingAction; - this.replicationPingAction = replicationPingAction; - this.broadcastPingAction = broadcastPingAction; - this.nodesStatsAction = nodesStatsAction; + this.clusterHealthAction = (ClientTransportClusterHealthAction) actions.get(TransportActions.Admin.Cluster.HEALTH); + this.clusterRerouteAction = (ClientTransportClusterRerouteAction) actions.get(TransportActions.Admin.Cluster.REROUTE); + this.clusterStateAction = (ClientTransportClusterStateAction) actions.get(TransportActions.Admin.Cluster.STATE); + this.clusterUpdateSettingsAction = (ClientTransportClusterUpdateSettingsAction) actions.get(TransportActions.Admin.Cluster.UPDATE_SETTINGS); + this.nodesInfoAction = (ClientTransportNodesInfoAction) actions.get(TransportActions.Admin.Cluster.Node.INFO); + this.nodesShutdownAction = (ClientTransportNodesShutdownAction) actions.get(TransportActions.Admin.Cluster.Node.SHUTDOWN); + this.nodesRestartAction = (ClientTransportNodesRestartAction) actions.get(TransportActions.Admin.Cluster.Node.RESTART); + this.singlePingAction = (ClientTransportSinglePingAction) actions.get(TransportActions.Admin.Cluster.Ping.SINGLE); + this.replicationPingAction = (ClientTransportReplicationPingAction) actions.get(TransportActions.Admin.Cluster.Ping.REPLICATION); + this.broadcastPingAction = (ClientTransportBroadcastPingAction) actions.get(TransportActions.Admin.Cluster.Ping.BROADCAST); + this.nodesStatsAction = (ClientTransportNodesStatsAction) actions.get(TransportActions.Admin.Cluster.Node.STATS); } @Override diff --git a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java index 12e7ce46a9e..4f6e5216c50 100644 --- a/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java +++ b/src/main/java/org/elasticsearch/client/transport/support/InternalTransportIndicesAdminClient.java @@ -22,6 +22,7 @@ package org.elasticsearch.client.transport.support; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.TransportActions; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest; @@ -88,11 +89,14 @@ import org.elasticsearch.client.transport.action.admin.indices.status.ClientTran import org.elasticsearch.client.transport.action.admin.indices.template.delete.ClientTransportDeleteIndexTemplateAction; import org.elasticsearch.client.transport.action.admin.indices.template.put.ClientTransportPutIndexTemplateAction; import org.elasticsearch.client.transport.action.admin.indices.validate.query.ClientTransportValidateQueryAction; +import org.elasticsearch.client.transport.action.support.BaseClientTransportAction; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; +import java.util.Map; + /** * */ @@ -146,37 +150,30 @@ public class InternalTransportIndicesAdminClient extends AbstractIndicesAdminCli @Inject public InternalTransportIndicesAdminClient(Settings settings, TransportClientNodesService nodesService, ThreadPool threadPool, - ClientTransportIndicesExistsAction indicesExistsAction, ClientTransportIndicesStatusAction indicesStatusAction, ClientTransportIndicesStatsAction indicesStatsAction, ClientTransportIndicesSegmentsAction indicesSegmentsAction, - ClientTransportCreateIndexAction createIndexAction, ClientTransportDeleteIndexAction deleteIndexAction, - ClientTransportCloseIndexAction closeIndexAction, ClientTransportOpenIndexAction openIndexAction, - ClientTransportRefreshAction refreshAction, ClientTransportFlushAction flushAction, ClientTransportOptimizeAction optimizeAction, - ClientTransportPutMappingAction putMappingAction, ClientTransportDeleteMappingAction deleteMappingAction, ClientTransportGatewaySnapshotAction gatewaySnapshotAction, - ClientTransportIndicesAliasesAction indicesAliasesAction, ClientTransportClearIndicesCacheAction clearIndicesCacheAction, - ClientTransportUpdateSettingsAction updateSettingsAction, ClientTransportAnalyzeAction analyzeAction, ClientTransportValidateQueryAction validateQueryAction, - ClientTransportPutIndexTemplateAction putIndexTemplateAction, ClientTransportDeleteIndexTemplateAction deleteIndexTemplateAction) { + Map actions) { this.nodesService = nodesService; this.threadPool = threadPool; - this.indicesExistsAction = indicesExistsAction; - this.indicesStatsAction = indicesStatsAction; - this.indicesStatusAction = indicesStatusAction; - this.indicesSegmentsAction = indicesSegmentsAction; - this.createIndexAction = createIndexAction; - this.deleteIndexAction = deleteIndexAction; - this.closeIndexAction = closeIndexAction; - this.openIndexAction = openIndexAction; - this.refreshAction = refreshAction; - this.flushAction = flushAction; - this.optimizeAction = optimizeAction; - this.putMappingAction = putMappingAction; - this.deleteMappingAction = deleteMappingAction; - this.gatewaySnapshotAction = gatewaySnapshotAction; - this.indicesAliasesAction = indicesAliasesAction; - this.clearIndicesCacheAction = clearIndicesCacheAction; - this.updateSettingsAction = updateSettingsAction; - this.analyzeAction = analyzeAction; - this.putIndexTemplateAction = putIndexTemplateAction; - this.deleteIndexTemplateAction = deleteIndexTemplateAction; - this.validateQueryAction = validateQueryAction; + this.indicesExistsAction = (ClientTransportIndicesExistsAction) actions.get(TransportActions.Admin.Indices.EXISTS); + this.indicesStatsAction = (ClientTransportIndicesStatsAction) actions.get(TransportActions.Admin.Indices.STATS); + this.indicesStatusAction = (ClientTransportIndicesStatusAction) actions.get(TransportActions.Admin.Indices.STATUS); + this.indicesSegmentsAction = (ClientTransportIndicesSegmentsAction) actions.get(TransportActions.Admin.Indices.SEGMENTS); + this.createIndexAction = (ClientTransportCreateIndexAction) actions.get(TransportActions.Admin.Indices.CREATE); + this.deleteIndexAction = (ClientTransportDeleteIndexAction) actions.get(TransportActions.Admin.Indices.DELETE); + this.closeIndexAction = (ClientTransportCloseIndexAction) actions.get(TransportActions.Admin.Indices.CLOSE); + this.openIndexAction = (ClientTransportOpenIndexAction) actions.get(TransportActions.Admin.Indices.OPEN); + this.refreshAction = (ClientTransportRefreshAction) actions.get(TransportActions.Admin.Indices.REFRESH); + this.flushAction = (ClientTransportFlushAction) actions.get(TransportActions.Admin.Indices.FLUSH); + this.optimizeAction = (ClientTransportOptimizeAction) actions.get(TransportActions.Admin.Indices.OPTIMIZE); + this.putMappingAction = (ClientTransportPutMappingAction) actions.get(TransportActions.Admin.Indices.Mapping.PUT); + this.deleteMappingAction = (ClientTransportDeleteMappingAction) actions.get(TransportActions.Admin.Indices.Mapping.DELETE); + this.gatewaySnapshotAction = (ClientTransportGatewaySnapshotAction) actions.get(TransportActions.Admin.Indices.Gateway.SNAPSHOT); + this.indicesAliasesAction = (ClientTransportIndicesAliasesAction) actions.get(TransportActions.Admin.Indices.ALIASES); + this.clearIndicesCacheAction = (ClientTransportClearIndicesCacheAction) actions.get(TransportActions.Admin.Indices.Cache.CLEAR); + this.updateSettingsAction = (ClientTransportUpdateSettingsAction) actions.get(TransportActions.Admin.Indices.UPDATE_SETTINGS); + this.analyzeAction = (ClientTransportAnalyzeAction) actions.get(TransportActions.Admin.Indices.ANALYZE); + this.putIndexTemplateAction = (ClientTransportPutIndexTemplateAction) actions.get(TransportActions.Admin.Indices.Template.PUT); + this.deleteIndexTemplateAction = (ClientTransportDeleteIndexTemplateAction) actions.get(TransportActions.Admin.Indices.Template.DELETE); + this.validateQueryAction = (ClientTransportValidateQueryAction) actions.get(TransportActions.Admin.Indices.Validate.QUERY); } @Override