Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // provide a RestClientFactory for custom configuration on the internally created REST client
- // i only show the setMaxRetryTimeoutMillis for illustration purposes, the actual code will use HTTP cutom callback
- esSinkBuilder.setRestClientFactory(
- restClientBuilder -> {
- restClientBuilder.setMaxRetryTimeoutMillis(10)
- }
- )
- // provide a RestClientFactory for custom configuration on the internally created REST client// provide a RestClientFactory for custom configuration on the internally created REST client
- import org.apache.http.auth.AuthScope
- import org.apache.http.auth.UsernamePasswordCredentials
- import org.apache.http.client.CredentialsProvider
- import org.apache.http.impl.client.BasicCredentialsProvider
- import org.apache.http.impl.nio.client.HttpAsyncClientBuilder
- import org.elasticsearch.client.RestClientBuilder
- // provide a RestClientFactory for custom configuration on the internally created REST client// provide a RestClientFactory for custom configuration on the internally created REST client
- esSinkBuilder.setRestClientFactory((restClientBuilder) => {
- def foo(restClientBuilder) = restClientBuilder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
- override def customizeHttpClient(httpClientBuilder: HttpAsyncClientBuilder): HttpAsyncClientBuilder = { // elasticsearch username and password
- val credentialsProvider = new BasicCredentialsProvider
- credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(es_user, es_password))
- httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)
- }
- })
- foo(restClientBuilder)
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement