C
- The Elasticsearch client, that implements AutoCloseable
.@Internal public interface ElasticsearchApiCallBridge<C extends AutoCloseable> extends Serializable
ElasticsearchApiCallBridge
is used to bridge incompatible Elasticsearch Java API calls
across different versions. This includes calls to create Elasticsearch clients, handle failed
item responses, etc. Any incompatible Elasticsearch Java APIs should be bridged using this
interface.
Implementations are allowed to be stateful. For example, for Elasticsearch 1.x, since connecting via an embedded node is allowed, the call bridge will hold reference to the created embedded node. Each instance of the sink will hold exactly one instance of the call bridge, and state cleanup is performed when the sink is closed.
Modifier and Type | Method and Description |
---|---|
default void |
cleanup()
Perform any necessary state cleanup.
|
void |
configureBulkProcessorBackoff(org.elasticsearch.action.bulk.BulkProcessor.Builder builder,
ElasticsearchSinkBase.BulkFlushBackoffPolicy flushBackoffPolicy)
Set backoff-related configurations on the provided
BulkProcessor.Builder . |
void |
configureBulkProcessorFlushInterval(org.elasticsearch.action.bulk.BulkProcessor.Builder builder,
long flushIntervalMillis)
Sets the bulk flush interval, in milliseconds on the provided
BulkProcessor.Builder . |
org.elasticsearch.action.bulk.BulkProcessor.Builder |
createBulkProcessorBuilder(C client,
org.elasticsearch.action.bulk.BulkProcessor.Listener listener)
Creates a
BulkProcessor.Builder for creating the bulk processor. |
RequestIndexer |
createBulkProcessorIndexer(org.elasticsearch.action.bulk.BulkProcessor bulkProcessor,
boolean flushOnCheckpoint,
AtomicLong numPendingRequestsRef)
Creates a
RequestIndexer that is able to work with BulkProcessor binary
compatible. |
C |
createClient(Map<String,String> clientConfig)
Creates an Elasticsearch client implementing
AutoCloseable . |
Throwable |
extractFailureCauseFromBulkItemResponse(org.elasticsearch.action.bulk.BulkItemResponse bulkItemResponse)
Extracts the cause of failure of a bulk item action.
|
void |
verifyClientConnection(C client)
Verify the client connection by making a test request/ping to the Elasticsearch cluster.
|
C createClient(Map<String,String> clientConfig)
AutoCloseable
.clientConfig
- The configuration to use when constructing the client.org.elasticsearch.action.bulk.BulkProcessor.Builder createBulkProcessorBuilder(C client, org.elasticsearch.action.bulk.BulkProcessor.Listener listener)
BulkProcessor.Builder
for creating the bulk processor.client
- the Elasticsearch client.listener
- the bulk processor listener.@Nullable Throwable extractFailureCauseFromBulkItemResponse(org.elasticsearch.action.bulk.BulkItemResponse bulkItemResponse)
bulkItemResponse
- the bulk item response to extract cause of failureThrowable
from the response (null
is the response is
successful).void configureBulkProcessorFlushInterval(org.elasticsearch.action.bulk.BulkProcessor.Builder builder, long flushIntervalMillis)
BulkProcessor.Builder
.
The builder will be later on used to instantiate the actual BulkProcessor
.builder
- the BulkProcessor.Builder
to configure.flushIntervalMillis
- the flush interval in milliseconds.void configureBulkProcessorBackoff(org.elasticsearch.action.bulk.BulkProcessor.Builder builder, @Nullable ElasticsearchSinkBase.BulkFlushBackoffPolicy flushBackoffPolicy)
BulkProcessor.Builder
. The builder
will be later on used to instantiate the actual BulkProcessor
.builder
- the BulkProcessor.Builder
to configure.flushBackoffPolicy
- user-provided backoff retry settings (null
if the user
disabled backoff retries).void verifyClientConnection(C client) throws IOException
Called by ElasticsearchSinkBase.open(org.apache.flink.configuration.Configuration)
after creating the client. This makes sure the underlying client is closed if the connection
is not successful and preventing thread leak.
client
- the Elasticsearch client.IOException
RequestIndexer createBulkProcessorIndexer(org.elasticsearch.action.bulk.BulkProcessor bulkProcessor, boolean flushOnCheckpoint, AtomicLong numPendingRequestsRef)
RequestIndexer
that is able to work with BulkProcessor
binary
compatible.default void cleanup()
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.