org.elasticsearch.action.Action Java Examples

The following examples show how to use org.elasticsearch.action.Action. 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: AbstractClient.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public final <Request extends TransportRequest, Response extends TransportResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> ActionFuture<Response> execute(
        Action<Request, Response, RequestBuilder> action, Request request) {
    PlainActionFuture<Response> actionFuture = PlainActionFuture.newFuture();
    execute(action, request, actionFuture);
    return actionFuture;
}
 
Example #2
Source File: TransportClient.java    From elasticsearch-helper with Apache License 2.0 5 votes vote down vote up
@Inject
@SuppressWarnings("unchecked")
public ProxyActionMap(Settings settings, TransportService transportService, Map<String, GenericAction> actions) {
    MapBuilder<Action, TransportActionNodeProxy> actionsBuilder = new MapBuilder<>();
    for (GenericAction action : actions.values()) {
        if (action instanceof Action) {
            actionsBuilder.put((Action) action, new TransportActionNodeProxy(settings, action, transportService));
        }
    }
    this.proxies = actionsBuilder.immutableMap();
}
 
Example #3
Source File: HttpElasticsearchClient.java    From elasticsearch-helper 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) {
    ActionEntry entry = actionMap.get(action.name());
    if (entry == null) {
        throw new IllegalStateException("no action entry for " + action.name());
    }
    HttpAction<Request, Response> httpAction = entry.httpAction;
    if (httpAction == null) {
        throw new IllegalStateException("failed to find action [" + action + "] to execute");
    }
    HttpInvocationContext<Request, Response> httpInvocationContext = new HttpInvocationContext(httpAction, listener, new LinkedList<>(), request);
    try {
        httpInvocationContext.httpRequest = httpAction.createHttpRequest(this.url, request);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    ChannelFuture future = bootstrap.connect(new InetSocketAddress(url.getHost(), url.getPort()));
    future.awaitUninterruptibly();
    if (!future.isSuccess()) {
        bootstrap.releaseExternalResources();
        logger.error("can't connect to {}", url);
    } else {
        Channel channel = future.getChannel();
        httpInvocationContext.setChannel(channel);
        contextMap.put(channel, httpInvocationContext);
        channel.getConfig().setConnectTimeoutMillis(settings.getAsInt("http.client.timeout", 5000));
        httpAction.execute(httpInvocationContext, listener);
    }
}
 
Example #4
Source File: HttpInvoker.java    From elasticsearch-helper 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) {
    HttpElasticsearchClient.ActionEntry entry = actionMap.get(action.name());
    if (entry == null) {
        throw new IllegalStateException("no action entry for " + action.name());
    }
    HttpAction<Request, Response> httpAction = entry.httpAction;
    if (httpAction == null) {
        throw new IllegalStateException("failed to find action [" + action + "] to execute");
    }
    HttpInvocationContext<Request, Response> httpInvocationContext = new HttpInvocationContext(httpAction, listener, new LinkedList<>(), request);
    try {
        httpInvocationContext.httpRequest = httpAction.createHttpRequest(this.url, request);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    ChannelFuture future = bootstrap.connect(new InetSocketAddress(url.getHost(), url.getPort()));
    future.awaitUninterruptibly();
    if (!future.isSuccess()) {
        bootstrap.releaseExternalResources();
        logger.error("can't connect to {}", url);
    } else {
        Channel channel = future.getChannel();
        httpInvocationContext.setChannel(channel);
        contexts.put(channel, httpInvocationContext);
        channel.getConfig().setConnectTimeoutMillis(settings.getAsInt("http.client.timeout", 5000));
        httpAction.execute(httpInvocationContext, listener);
    }
}
 
Example #5
Source File: KerberizedClient.java    From elasticsearch-shield-kerberos-realm with Apache License 2.0 5 votes vote down vote up
private KerberosActionListener(final ActionListener inner, final Action action, final ActionRequest<ActionRequest> request,
        final GSSContext context) {
    super();
    this.inner = inner;
    this.action = action;
    this.request = request;
    this.context = context;
}
 
Example #6
Source File: ElasticsearchClientImpl.java    From herd with Apache License 2.0 5 votes vote down vote up
@Override
public <RequestT extends ActionRequest, ResponseT extends ActionResponse,
    RequestBuilderT extends ActionRequestBuilder<RequestT, ResponseT, RequestBuilderT>> RequestBuilderT prepareExecute(
    Action<RequestT, ResponseT, RequestBuilderT> action)
{
    return null;
}
 
Example #7
Source File: ElasticsearchClientImpl.java    From herd with Apache License 2.0 5 votes vote down vote up
@Override
public <RequestT extends ActionRequest, ResponseT extends ActionResponse,
    RequestBuilderT extends ActionRequestBuilder<RequestT, ResponseT, RequestBuilderT>> void execute(
    Action<RequestT, ResponseT, RequestBuilderT> action, RequestT request, ActionListener<ResponseT> actionListener)
{
  // stub method
}
 
Example #8
Source File: ElasticsearchClientImpl.java    From herd with Apache License 2.0 5 votes vote down vote up
@Override
public <RequestT extends ActionRequest, ResponseT extends ActionResponse,
    RequestBuilderT extends ActionRequestBuilder<RequestT, ResponseT, RequestBuilderT>> ActionFuture<ResponseT> execute(
    Action<RequestT, ResponseT, RequestBuilderT> action, RequestT request)
{
    return null;
}
 
Example #9
Source File: NodeClient.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public <Request extends TransportRequest,
        Response extends TransportResponse,
        RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void doExecute(
    Action<Request, Response, RequestBuilder> action,
    Request request,
    ActionListener<Response> listener) {

    // Discard the task because the Client interface doesn't use it.
    executeLocally(action, request, listener);
}
 
Example #10
Source File: RestImportAction.java    From elasticsearch-inout-plugin with Apache License 2.0 4 votes vote down vote up
protected Action action() {
    return ImportAction.INSTANCE;
}
 
Example #11
Source File: AppendLuceneRequestBuilder.java    From ES-Fastloader with Apache License 2.0 4 votes vote down vote up
public AppendLuceneRequestBuilder(ElasticsearchClient client, Action<AppendLuceneRequest, AppendLuceneResponse, AppendLuceneRequestBuilder> action) {
    super(client, action, new AppendLuceneRequest());
}
 
Example #12
Source File: MasterNodeReadOperationRequestBuilder.java    From crate with Apache License 2.0 4 votes vote down vote up
protected MasterNodeReadOperationRequestBuilder(ElasticsearchClient client, Action<Request, Response, RequestBuilder> action, Request request) {
    super(client, action, request);
}
 
Example #13
Source File: AcknowledgedRequestBuilder.java    From crate with Apache License 2.0 4 votes vote down vote up
protected AcknowledgedRequestBuilder(ElasticsearchClient client, Action<Request, Response, RequestBuilder> action, Request request) {
    super(client, action, request);
}
 
Example #14
Source File: ReplicationRequestBuilder.java    From crate with Apache License 2.0 4 votes vote down vote up
protected ReplicationRequestBuilder(ElasticsearchClient client, Action<Request, Response, RequestBuilder> action, Request request) {
    super(client, action, request);
}
 
Example #15
Source File: BroadcastOperationRequestBuilder.java    From crate with Apache License 2.0 4 votes vote down vote up
protected BroadcastOperationRequestBuilder(ElasticsearchClient client, Action<Request, Response, RequestBuilder> action, Request request) {
    super(client, action, request);
}
 
Example #16
Source File: AddVotingConfigExclusionsAction.java    From crate with Apache License 2.0 4 votes vote down vote up
AddVotingConfigExclusionsRequestBuilder(ElasticsearchClient client,
                                        Action<AddVotingConfigExclusionsRequest, AddVotingConfigExclusionsResponse, AddVotingConfigExclusionsRequestBuilder> action,
                                        AddVotingConfigExclusionsRequest request) {
    super(client, action, request);
}
 
Example #17
Source File: ClearVotingConfigExclusionsAction.java    From crate with Apache License 2.0 4 votes vote down vote up
ClearVotingConfigExclusionsRequestBuilder(ElasticsearchClient client,
                                          Action<ClearVotingConfigExclusionsRequest, ClearVotingConfigExclusionsResponse, ClearVotingConfigExclusionsRequestBuilder> action,
                                          ClearVotingConfigExclusionsRequest request) {
    super(client, action, request);
}
 
Example #18
Source File: TransportClient.java    From elasticsearch-helper with Apache License 2.0 4 votes vote down vote up
public ImmutableMap<Action, TransportActionNodeProxy> getProxies() {
    return proxies;
}
 
Example #19
Source File: RestRestoreAction.java    From elasticsearch-inout-plugin with Apache License 2.0 4 votes vote down vote up
@Override
protected Action action() {
    return RestoreAction.INSTANCE;
}
 
Example #20
Source File: RestDumpAction.java    From elasticsearch-inout-plugin with Apache License 2.0 4 votes vote down vote up
@Override
protected Action<ExportRequest, ExportResponse, ExportRequestBuilder> action() {
    return DumpAction.INSTANCE;
}
 
Example #21
Source File: ResizeRequestBuilder.java    From crate with Apache License 2.0 4 votes vote down vote up
public ResizeRequestBuilder(ElasticsearchClient client, Action<ResizeRequest, ResizeResponse, ResizeRequestBuilder> action) {
    super(client, action, new ResizeRequest());
}
 
Example #22
Source File: RestReindexAction.java    From elasticsearch-inout-plugin with Apache License 2.0 4 votes vote down vote up
@Override
protected Action<SearchIntoRequest, SearchIntoResponse, SearchIntoRequestBuilder> action() {
    return ReindexAction.INSTANCE;
}
 
Example #23
Source File: RestSearchIntoAction.java    From elasticsearch-inout-plugin with Apache License 2.0 4 votes vote down vote up
protected Action<SearchIntoRequest, SearchIntoResponse, SearchIntoRequestBuilder> action() {
    return SearchIntoAction.INSTANCE;
}
 
Example #24
Source File: RestExportAction.java    From elasticsearch-inout-plugin with Apache License 2.0 4 votes vote down vote up
protected Action<ExportRequest, ExportResponse, ExportRequestBuilder> action() {
    return ExportAction.INSTANCE;
}
 
Example #25
Source File: MasterNodeOperationRequestBuilder.java    From crate with Apache License 2.0 4 votes vote down vote up
protected MasterNodeOperationRequestBuilder(ElasticsearchClient client, Action<Request, Response, RequestBuilder> action, Request request) {
    super(client, action, request);
}
 
Example #26
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
/**
 * This is the single execution point of *all* clients.
 */
@Override
public final <Request extends TransportRequest, Response extends TransportResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void execute(
        Action<Request, Response, RequestBuilder> action, Request request, ActionListener<Response> listener) {
    doExecute(action, request, listener);
}
 
Example #27
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public <Request extends TransportRequest, Response extends TransportResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> ActionFuture<Response> execute(
        Action<Request, Response, RequestBuilder> action, Request request) {
    return client.execute(action, request);
}
 
Example #28
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public <Request extends TransportRequest, Response extends TransportResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void execute(
        Action<Request, Response, RequestBuilder> action, Request request, ActionListener<Response> listener) {
    client.execute(action, request, listener);
}
 
Example #29
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public <Request extends TransportRequest, Response extends TransportResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> ActionFuture<Response> execute(
        Action<Request, Response, RequestBuilder> action, Request request) {
    return client.execute(action, request);
}
 
Example #30
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public <Request extends TransportRequest, Response extends TransportResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void execute(
        Action<Request, Response, RequestBuilder> action, Request request, ActionListener<Response> listener) {
    client.execute(action, request, listener);
}