org.hibernate.search.elasticsearch.processor.impl

## Class ElasticsearchWorkProcessor

- java.lang.Object
- - org.hibernate.search.elasticsearch.processor.impl.ElasticsearchWorkProcessor

- All Implemented Interfaces:
    AutoCloseable

      public class ElasticsearchWorkProcessor
      extends Object
      implements AutoCloseable

  Executes single or multiple `ElasticsearchWork`s against the Elasticsearch server.

  When processing multiple requests, bulk requests will be formed and executed as far as possible.

  Requests can be processed synchronously or asynchronously. In the latter case, incoming requests are added to a queue via a `BatchingSharedElasticsearchWorkOrchestrator` and processed in bulks.

  Author:
    Gunnar Morling

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ElasticsearchWorkProcessor(BuildContext context, ElasticsearchClient client, GsonProvider gsonProvider, ElasticsearchWorkFactory workFactory)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `BarrierElasticsearchWorkOrchestrator` | `createNonStreamOrchestrator(String indexName, boolean refreshAfterWrite)` Return an orchestrator for non-stream background works.
    `<T> CompletableFuture<T>` | `executeAsyncUnsafe(ElasticsearchWork<T> work)` Execute a single work asynchronously, without bulking it with other asynchronous works, and potentially throwing exceptions (the error handler isn't used).
    `<T> T` | `executeSyncUnsafe(ElasticsearchWork<T> work)` Execute a single work synchronously, potentially throwing exceptions (the error handler isn't used).
    `BarrierElasticsearchWorkOrchestrator` | `getStreamOrchestrator()` Return the orchestrator for asynchronous, non-stream background works.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ElasticsearchWorkProcessor

          public ElasticsearchWorkProcessor(BuildContext context,
                                            ElasticsearchClient client,
                                            GsonProvider gsonProvider,
                                            ElasticsearchWorkFactory workFactory)

  - ### Method Detail

    - #### close

          public void close()

      Specified by:
        `close` in interface `AutoCloseable`

    - #### executeSyncUnsafe

          public <T> T executeSyncUnsafe(ElasticsearchWork<T> work)

      Execute a single work synchronously, potentially throwing exceptions (the error handler isn't used).
      Parameters:
        `work` - The work to be executed.
      Returns:
        The result of the given work.

    - #### executeAsyncUnsafe

          public <T> CompletableFuture<T> executeAsyncUnsafe(ElasticsearchWork<T> work)

      Execute a single work asynchronously, without bulking it with other asynchronous works, and potentially throwing exceptions (the error handler isn't used).
      Parameters:
        `work` - The work to be executed.
      Returns:
        The result of the given work.

    - #### createNonStreamOrchestrator

          public BarrierElasticsearchWorkOrchestrator createNonStreamOrchestrator(String indexName,
                                                                                  boolean refreshAfterWrite)

      Return an orchestrator for non-stream background works.

      Works submitted in the same changeset will be executed in the given order. Relative execution order between changesets is undefined.

      Works submitted to this orchestrator will only be bulked with subsequent works (possibly of a different changeset).

      If any work throws an exception, this exception will be passed to the error handler with an `ErrorContext` spanning exactly the given works, and the remaining works will not be executed.

      Returns:
        the orchestrator for synchronous, non-stream background works.

    - #### getStreamOrchestrator

          public BarrierElasticsearchWorkOrchestrator getStreamOrchestrator()

      Return the orchestrator for asynchronous, non-stream background works.

      Works submitted in the same changeset will be executed in the given order. Relative execution order between changesets is undefined.

      Works submitted to this orchestrator will only be bulked with subsequent works from the same changeset or with works from a different changeset.

      If any work throws an exception, this exception will be passed to the error handler with an `ErrorContext` spanning exactly the given works, and the remaining works will not be executed.

      Returns:
        the orchestrator for stream background works.

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved