org.elasticsearch.action.support.TransportAction Java Examples

The following examples show how to use org.elasticsearch.action.support.TransportAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActionModule.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    bind(DestructiveOperations.class).toInstance(destructiveOperations);

    // register GenericAction -> transportAction Map used by NodeClient
    @SuppressWarnings("rawtypes")
    MapBinder<GenericAction, TransportAction> transportActionsBinder
            = MapBinder.newMapBinder(binder(), GenericAction.class, TransportAction.class);
    for (ActionHandler<?, ?> action : actions.values()) {
        // bind the action as eager singleton, so the map binder one will reuse it
        bind(action.getTransportAction()).asEagerSingleton();
        transportActionsBinder.addBinding(action.getAction()).to(action.getTransportAction()).asEagerSingleton();
        for (Class<?> supportAction : action.getSupportTransportActions()) {
            bind(supportAction).asEagerSingleton();
        }
    }
}
 
Example #2
Source File: ReindexModule.java    From elasticsearch-inout-plugin with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    bind(TransportReindexAction.class).asEagerSingleton();

    bind(ReindexParser.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder =
            MapBinder.newMapBinder(
                    binder(), GenericAction.class, TransportAction.class);

    transportActionsBinder.addBinding(ReindexAction.INSTANCE).to(
            TransportReindexAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder
            .newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(ReindexAction.NAME).toInstance(
            ReindexAction.INSTANCE);

}
 
Example #3
Source File: ImportModule.java    From elasticsearch-inout-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(TransportImportAction.class).asEagerSingleton();

    bind(ImportParser.class).asEagerSingleton();
    bind(Importer.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder = MapBinder.newMapBinder(binder(), GenericAction.class, TransportAction.class);
    transportActionsBinder.addBinding(ImportAction.INSTANCE).to(TransportImportAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder.newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(ImportAction.NAME).toInstance(ImportAction.INSTANCE);

}
 
Example #4
Source File: Transports.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Convenience to turn
 *
 *      `action.execute(request, listener) -> void`
 *
 *  into
 *
 *      `execute(action, request, convertResp) -> resultFuture`
 */
public static <Req extends TransportRequest, Resp extends TransportResponse, Result> CompletableFuture<Result> execute(
    TransportAction<Req, Resp> transportAction,
    Req request,
    Function<? super Resp, Result> convertResponse) {

    FutureActionListener<Resp, Result> listener = new FutureActionListener<>(convertResponse);
    transportAction.execute(request, listener);
    return listener;
}
 
Example #5
Source File: ActionPlugin.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Create a record of an action, the {@linkplain TransportAction} that handles it, and any supporting {@linkplain TransportActions}
 * that are needed by that {@linkplain TransportAction}.
 */
public ActionHandler(GenericAction<Request, Response> action, Class<? extends TransportAction<Request, Response>> transportAction,
        Class<?>... supportTransportActions) {
    this.action = action;
    this.transportAction = transportAction;
    this.supportTransportActions = supportTransportActions;
}
 
Example #6
Source File: ExportModule.java    From elasticsearch-inout-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(TransportExportAction.class).asEagerSingleton();

    bind(ExportParser.class).asEagerSingleton();
    bind(Exporter.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder = MapBinder.newMapBinder(binder(), GenericAction.class, TransportAction.class);

    transportActionsBinder.addBinding(ExportAction.INSTANCE).to(TransportExportAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder.newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(ExportAction.NAME).toInstance(ExportAction.INSTANCE);
}
 
Example #7
Source File: SearchIntoModule.java    From elasticsearch-inout-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(TransportSearchIntoAction.class).asEagerSingleton();

    bind(SearchIntoParser.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder =
            MapBinder.newMapBinder(
                    binder(), GenericAction.class, TransportAction.class);

    transportActionsBinder.addBinding(SearchIntoAction.INSTANCE).to(
            TransportSearchIntoAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder
            .newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(SearchIntoAction.NAME).toInstance(
            SearchIntoAction.INSTANCE);


    MapBinder<String, WriterCollectorFactory> collectorBinder
            = MapBinder.newMapBinder(binder(),
            String.class, WriterCollectorFactory.class);

    collectorBinder.addBinding(BulkWriterCollector.NAME).toProvider(
            FactoryProvider
                    .newFactory(WriterCollectorFactory.class,
                            BulkWriterCollector.class));


}
 
Example #8
Source File: ESJobContext.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public ESJobContext(int id,
                    String operationName,
                    List<? extends ActionRequest> requests,
                    List<? extends ActionListener> listeners,
                    List<SettableFuture<TaskResult>> resultFutures,
                    TransportAction transportAction,
                    @Nullable FlatProjectorChain projectorChain) {
    super(id, LOGGER);
    this.operationName = operationName;
    this.requests = requests;
    this.listeners = listeners;
    this.resultFutures = resultFutures;
    this.transportAction = transportAction;
    this.projectorChain = projectorChain;
}
 
Example #9
Source File: NodeClient.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void doExecute(Action<Request, Response, RequestBuilder> action, Request request, ActionListener<Response> listener) {
    TransportAction<Request, Response> transportAction = actions.get(action);
    if (transportAction == null) {
        throw new IllegalStateException("failed to find action [" + action + "] to execute");
    }
    transportAction.execute(request, listener);
}
 
Example #10
Source File: EsJobContextTask.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
protected void createContext(String operationName,
                             List<? extends ActionRequest> requests,
                             List<? extends ActionListener> listeners,
                             TransportAction transportAction,
                             @Nullable FlatProjectorChain projectorChain) {
    ESJobContext esJobContext = new ESJobContext(executionPhaseId, operationName,
            requests, listeners, results, transportAction, projectorChain);
    JobExecutionContext.Builder contextBuilder = jobContextService.newBuilder(jobId());
    contextBuilder.addSubContext(esJobContext);
    context = jobContextService.createContext(contextBuilder);
}
 
Example #11
Source File: ActionModule.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
ActionEntry(GenericAction<Request, Response> action, Class<? extends TransportAction<Request, Response>> transportAction, Class... supportTransportActions) {
    this.action = action;
    this.transportAction = transportAction;
    this.supportTransportActions = supportTransportActions;
}
 
Example #12
Source File: NodeClient.java    From crate with Apache License 2.0 4 votes vote down vote up
public void initialize(Map<GenericAction, TransportAction> actions) {
    this.actions = actions;
}
 
Example #13
Source File: ActionModule.java    From crate with Apache License 2.0 4 votes vote down vote up
static Map<String, ActionHandler<?, ?>> setupActions(List<ActionPlugin> actionPlugins) {
    // Subclass NamedRegistry for easy registration
    class ActionRegistry extends NamedRegistry<ActionHandler<?, ?>> {
        ActionRegistry() {
            super("action");
        }

        public void register(ActionHandler<?, ?> handler) {
            register(handler.getAction().name(), handler);
        }

        public <Request extends TransportRequest, Response extends TransportResponse> void register(
                GenericAction<Request, Response> action, Class<? extends TransportAction<Request, Response>> transportAction,
                Class<?>... supportTransportActions) {
            register(new ActionHandler<>(action, transportAction, supportTransportActions));
        }
    }

    ActionRegistry actions = new ActionRegistry();
    actions.register(ClusterStateAction.INSTANCE, TransportClusterStateAction.class);
    actions.register(ClusterHealthAction.INSTANCE, TransportClusterHealthAction.class);
    actions.register(ClusterUpdateSettingsAction.INSTANCE, TransportClusterUpdateSettingsAction.class);
    actions.register(ClusterRerouteAction.INSTANCE, TransportClusterRerouteAction.class);
    actions.register(PendingClusterTasksAction.INSTANCE, TransportPendingClusterTasksAction.class);
    actions.register(PutRepositoryAction.INSTANCE, TransportPutRepositoryAction.class);
    actions.register(DeleteRepositoryAction.INSTANCE, TransportDeleteRepositoryAction.class);
    actions.register(GetSnapshotsAction.INSTANCE, TransportGetSnapshotsAction.class);
    actions.register(DeleteSnapshotAction.INSTANCE, TransportDeleteSnapshotAction.class);
    actions.register(CreateSnapshotAction.INSTANCE, TransportCreateSnapshotAction.class);
    actions.register(RestoreSnapshotAction.INSTANCE, TransportRestoreSnapshotAction.class);
    actions.register(IndicesStatsAction.INSTANCE, TransportIndicesStatsAction.class);
    actions.register(CreateIndexAction.INSTANCE, TransportCreateIndexAction.class);
    actions.register(ResizeAction.INSTANCE, TransportResizeAction.class);
    actions.register(DeleteIndexAction.INSTANCE, TransportDeleteIndexAction.class);
    actions.register(PutMappingAction.INSTANCE, TransportPutMappingAction.class);
    actions.register(UpdateSettingsAction.INSTANCE, TransportUpdateSettingsAction.class);
    actions.register(PutIndexTemplateAction.INSTANCE, TransportPutIndexTemplateAction.class);
    actions.register(GetIndexTemplatesAction.INSTANCE, TransportGetIndexTemplatesAction.class);
    actions.register(DeleteIndexTemplateAction.INSTANCE, TransportDeleteIndexTemplateAction.class);
    actions.register(RefreshAction.INSTANCE, TransportRefreshAction.class);
    actions.register(SyncedFlushAction.INSTANCE, TransportSyncedFlushAction.class);
    actions.register(ForceMergeAction.INSTANCE, TransportForceMergeAction.class);
    actions.register(UpgradeAction.INSTANCE, TransportUpgradeAction.class);
    actions.register(UpgradeSettingsAction.INSTANCE, TransportUpgradeSettingsAction.class);
    actions.register(RecoveryAction.INSTANCE, TransportRecoveryAction.class);
    actions.register(AddVotingConfigExclusionsAction.INSTANCE, TransportAddVotingConfigExclusionsAction.class);
    actions.register(ClearVotingConfigExclusionsAction.INSTANCE, TransportClearVotingConfigExclusionsAction.class);
    actions.register(NodesStatsAction.INSTANCE, TransportNodesStatsAction.class);

    actionPlugins.stream().flatMap(p -> p.getActions().stream()).forEach(actions::register);

    return unmodifiableMap(actions.getRegistry());
}
 
Example #14
Source File: NodeClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject
public NodeClient(Settings settings, ThreadPool threadPool, Headers headers, Map<GenericAction, TransportAction> actions) {
    super(settings, threadPool, headers);
    this.actions = ImmutableMap.copyOf(actions);
}
 
Example #15
Source File: ActionPlugin.java    From crate with Apache License 2.0 4 votes vote down vote up
public Class<? extends TransportAction<Request, Response>> getTransportAction() {
    return transportAction;
}
 
Example #16
Source File: DumpModule.java    From elasticsearch-inout-plugin with Apache License 2.0 3 votes vote down vote up
@Override
protected void configure() {
    bind(TransportDumpAction.class).asEagerSingleton();

    bind(DumpParser.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder = MapBinder.newMapBinder(binder(), GenericAction.class, TransportAction.class);

    transportActionsBinder.addBinding(DumpAction.INSTANCE).to(TransportDumpAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder.newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(DumpAction.NAME).toInstance(DumpAction.INSTANCE);
}
 
Example #17
Source File: RestoreModule.java    From elasticsearch-inout-plugin with Apache License 2.0 3 votes vote down vote up
@Override
protected void configure() {
    bind(TransportRestoreAction.class).asEagerSingleton();

    bind(RestoreParser.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder = MapBinder.newMapBinder(binder(), GenericAction.class, TransportAction.class);
    transportActionsBinder.addBinding(RestoreAction.INSTANCE).to(TransportRestoreAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder.newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(RestoreAction.NAME).toInstance(RestoreAction.INSTANCE);

}
 
Example #18
Source File: ExtendedAnalyzeModule.java    From elasticsearch-extended-analyze with Apache License 2.0 3 votes vote down vote up
@Override
protected void configure() {
    bind(TransportExtendedAnalyzeAction.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder =
        MapBinder.newMapBinder(binder(), GenericAction.class, TransportAction.class);

    transportActionsBinder.addBinding(ExtendedAnalyzeAction.INSTANCE).to(TransportExtendedAnalyzeAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder.newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(ExtendedAnalyzeAction.NAME).toInstance(ExtendedAnalyzeAction.INSTANCE);

}
 
Example #19
Source File: ActionModule.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Registers an action.
 *
 * @param action                  The action type.
 * @param transportAction         The transport action implementing the actual action.
 * @param supportTransportActions Any support actions that are needed by the transport action.
 * @param <Request>               The request type.
 * @param <Response>              The response type.
 */
public <Request extends ActionRequest, Response extends ActionResponse> void registerAction(GenericAction<Request, Response> action, Class<? extends TransportAction<Request, Response>> transportAction, Class... supportTransportActions) {
    actions.put(action.name(), new ActionEntry<>(action, transportAction, supportTransportActions));
}