public abstract static class ElasticsearchIO.ConnectionConfiguration
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
ConnectionConfiguration() |
Modifier and Type | Method and Description |
---|---|
static ElasticsearchIO.ConnectionConfiguration |
create(java.lang.String[] addresses)
Creates a new Elasticsearch connection configuration with no default index nor type.
|
static ElasticsearchIO.ConnectionConfiguration |
create(java.lang.String[] addresses,
java.lang.String index)
Creates a new Elasticsearch connection configuration with no default type.
|
static ElasticsearchIO.ConnectionConfiguration |
create(java.lang.String[] addresses,
java.lang.String index,
java.lang.String type)
Creates a new Elasticsearch connection configuration.
|
abstract java.util.List<java.lang.String> |
getAddresses() |
abstract @Nullable java.lang.String |
getApiKey() |
java.lang.String |
getApiPrefix()
Generates the API endpoint prefix based on the set values.
|
abstract @Nullable java.lang.String |
getBearerToken() |
java.lang.String |
getBulkEndPoint() |
abstract @Nullable java.lang.Integer |
getConnectTimeout() |
java.lang.String |
getCountEndPoint() |
abstract @Nullable java.util.List<Header> |
getDefaultHeaders() |
abstract java.lang.String |
getIndex() |
abstract @Nullable java.lang.String |
getKeystorePassword() |
abstract @Nullable java.lang.String |
getKeystorePath() |
abstract @Nullable java.lang.String |
getPassword() |
abstract @Nullable java.lang.String |
getPathPrefix() |
java.lang.String |
getPrefixedEndpoint(java.lang.String endpoint) |
java.lang.String |
getSearchEndPoint() |
abstract @Nullable java.lang.Integer |
getSocketTimeout() |
abstract @Nullable java.lang.String |
getType() |
abstract @Nullable java.lang.String |
getUsername() |
abstract boolean |
isCompressionEnabled() |
abstract boolean |
isTrustSelfSignedCerts() |
ElasticsearchIO.ConnectionConfiguration |
withApiKey(java.lang.String apiKey)
If Elasticsearch authentication is enabled, provide an API key.
|
ElasticsearchIO.ConnectionConfiguration |
withBearerToken(java.lang.String bearerToken)
If Elasticsearch authentication is enabled, provide a bearer token.
|
ElasticsearchIO.ConnectionConfiguration |
withCompressionEnabled(boolean compressionEnabled)
Configure whether the REST client should compress requests using gzip content encoding and
add the "Accept-Encoding: gzip".
|
ElasticsearchIO.ConnectionConfiguration |
withConnectTimeout(java.lang.Integer connectTimeout)
If set, overwrites the default connect timeout (1000ms) in the
RequestConfig of the
Elastic RestClient . |
ElasticsearchIO.ConnectionConfiguration |
withDefaultHeaders(Header[] defaultHeaders)
For authentication or custom requirements, provide a set if default headers for the client.
|
ElasticsearchIO.ConnectionConfiguration |
withKeystorePassword(java.lang.String keystorePassword)
If Elasticsearch uses SSL/TLS with mutual authentication (via shield), provide the password
to open the client keystore.
|
ElasticsearchIO.ConnectionConfiguration |
withKeystorePath(java.lang.String keystorePath)
If Elasticsearch uses SSL/TLS with mutual authentication (via shield), provide the keystore
containing the client key.
|
ElasticsearchIO.ConnectionConfiguration |
withPassword(java.lang.String password)
If Elasticsearch authentication is enabled, provide the password.
|
ElasticsearchIO.ConnectionConfiguration |
withPathPrefix(java.lang.String pathPrefix)
If Elasticsearch is not running at the root path, e.g.
|
ElasticsearchIO.ConnectionConfiguration |
withSocketTimeout(java.lang.Integer socketTimeout)
If set, overwrites the default max retry timeout (30000ms) in the Elastic
RestClient
and the default socket timeout (30000ms) in the RequestConfig of the Elastic RestClient . |
ElasticsearchIO.ConnectionConfiguration |
withTrustSelfSignedCerts(boolean trustSelfSignedCerts)
If Elasticsearch uses SSL/TLS then configure whether to trust self signed certs or not.
|
ElasticsearchIO.ConnectionConfiguration |
withUsername(java.lang.String username)
If Elasticsearch authentication is enabled, provide the username.
|
public abstract java.util.List<java.lang.String> getAddresses()
public abstract @Nullable java.lang.String getUsername()
public abstract @Nullable java.lang.String getPassword()
public abstract @Nullable java.lang.String getApiKey()
public abstract @Nullable java.lang.String getBearerToken()
public abstract @Nullable java.util.List<Header> getDefaultHeaders()
public abstract @Nullable java.lang.String getKeystorePath()
public abstract @Nullable java.lang.String getKeystorePassword()
public abstract @Nullable java.lang.String getPathPrefix()
public abstract java.lang.String getIndex()
public abstract @Nullable java.lang.String getType()
public abstract @Nullable java.lang.Integer getSocketTimeout()
public abstract @Nullable java.lang.Integer getConnectTimeout()
public abstract boolean isTrustSelfSignedCerts()
public abstract boolean isCompressionEnabled()
public static ElasticsearchIO.ConnectionConfiguration create(java.lang.String[] addresses, java.lang.String index, java.lang.String type)
addresses
- list of addresses of Elasticsearch nodesindex
- the index toward which the requests will be issuedtype
- the document type toward which the requests will be issuedpublic static ElasticsearchIO.ConnectionConfiguration create(java.lang.String[] addresses, java.lang.String index)
addresses
- list of addresses of Elasticsearch nodesindex
- the index toward which the requests will be issuedpublic static ElasticsearchIO.ConnectionConfiguration create(java.lang.String[] addresses)
addresses
- list of addresses of Elasticsearch nodespublic java.lang.String getApiPrefix()
Based on ConnectionConfiguration constructors, we know that one of the following is true:
Example valid endpoints therefore include:
public java.lang.String getPrefixedEndpoint(java.lang.String endpoint)
public java.lang.String getBulkEndPoint()
public java.lang.String getSearchEndPoint()
public java.lang.String getCountEndPoint()
public ElasticsearchIO.ConnectionConfiguration withUsername(java.lang.String username)
username
- the username used to authenticate to ElasticsearchElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withPassword(java.lang.String password)
password
- the password used to authenticate to ElasticsearchElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withPathPrefix(java.lang.String pathPrefix)
pathPrefix
- the path prefix used in Elasticsearch instance.ElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withApiKey(java.lang.String apiKey)
withBearerToken()
and withDefaultHeaders
at the same time, as they (potentially) use the same header.apiKey
- the API key used to authenticate to ElasticsearchElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withBearerToken(java.lang.String bearerToken)
withBearerToken()
and withDefaultHeaders
at the same time, as they (potentially) use the same header.bearerToken
- the bearer token used to authenticate to ElasticsearchElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withDefaultHeaders(Header[] defaultHeaders)
withApiToken()
, withBearerToken()
and
withDefaultHeaders
at the same time, as they (potentially) use the same header.
An example of where this could be useful is if the client needs to use short-lived credentials that need to be renewed on a certain interval. To implement that, a user could implement a custom header that tracks the renewal period, for example:
{@code class OAuthTokenHeader extends BasicHeader { OAuthToken accessToken; ...
defaultHeaders
- the headers to add to outgoing requestsElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withKeystorePath(java.lang.String keystorePath)
keystorePath
- the location of the keystore containing the client key.ElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withKeystorePassword(java.lang.String keystorePassword)
keystorePassword
- the password of the client keystore.ElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withTrustSelfSignedCerts(boolean trustSelfSignedCerts)
trustSelfSignedCerts
- Whether to trust self signed certsElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withCompressionEnabled(boolean compressionEnabled)
compressionEnabled
- Whether to compress requests using gzip content encoding and add
the "Accept-Encoding: gzip"ElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withSocketTimeout(java.lang.Integer socketTimeout)
RestClient
and the default socket timeout (30000ms) in the RequestConfig
of the Elastic RestClient
.socketTimeout
- the socket and retry timeout in millis.ElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.public ElasticsearchIO.ConnectionConfiguration withConnectTimeout(java.lang.Integer connectTimeout)
RequestConfig
of the
Elastic RestClient
.connectTimeout
- the socket and retry timeout in millis.ElasticsearchIO.ConnectionConfiguration
describes a connection configuration to
Elasticsearch.