This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf-decanter.git


The following commit(s) were added to refs/heads/master by this push:
     new af7ac54  [KARAF-5587] Fix jest appender declaration, speed up the 
reconnect delay by defining timeouts
af7ac54 is described below

commit af7ac548865f5a4f6f4490b5322785d4d8034861
Author: Jean-Baptiste Onofré <jbono...@apache.org>
AuthorDate: Fri Feb 2 13:54:45 2018 +0100

    [KARAF-5587] Fix jest appender declaration, speed up the reconnect delay by 
defining timeouts
---
 .../appender/elasticsearch/jest/ElasticsearchAppender.java       | 5 ++---
 .../appender/elasticsearch/rest/ElasticsearchAppender.java       | 9 +++++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git 
a/appender/elasticsearch-jest/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/jest/ElasticsearchAppender.java
 
b/appender/elasticsearch-jest/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/jest/ElasticsearchAppender.java
index abc39e3..d0791f9 100644
--- 
a/appender/elasticsearch-jest/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/jest/ElasticsearchAppender.java
+++ 
b/appender/elasticsearch-jest/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/jest/ElasticsearchAppender.java
@@ -46,9 +46,8 @@ import io.searchbox.client.config.HttpClientConfig.Builder;
 import io.searchbox.core.Index;
 
 @Component(
-    name ="org.apache.karaf.decanter.appender.elasticsearch.rest",
+    name ="org.apache.karaf.decanter.appender.elasticsearch.jest",
     immediate = true,
-    configurationPolicy = ConfigurationPolicy.REQUIRE,
     property=EventConstants.EVENT_TOPIC + "=decanter/collect/*"
 )
 public class ElasticsearchAppender implements EventHandler {
@@ -76,7 +75,7 @@ public class ElasticsearchAppender implements EventHandler {
         Set<String> addresses = new 
HashSet<String>(Arrays.asList(addressesString.split(";")));
         String username = getValue(config, "username", null);
         String password = getValue(config, "password", null);
-        Builder builder = new HttpClientConfig.Builder(addresses)
+        Builder builder = new 
HttpClientConfig.Builder(addresses).readTimeout(10000)
             .multiThreaded(true);
         
         if (addresses.size() > 1) {
diff --git 
a/appender/elasticsearch-rest/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/rest/ElasticsearchAppender.java
 
b/appender/elasticsearch-rest/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/rest/ElasticsearchAppender.java
index 52cdbf9..901ed37 100644
--- 
a/appender/elasticsearch-rest/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/rest/ElasticsearchAppender.java
+++ 
b/appender/elasticsearch-rest/src/main/java/org/apache/karaf/decanter/appender/elasticsearch/rest/ElasticsearchAppender.java
@@ -21,6 +21,7 @@ import org.apache.http.HttpHost;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.entity.ContentType;
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
@@ -89,6 +90,14 @@ public class ElasticsearchAppender implements EventHandler {
         }
         RestClientBuilder restClientBuilder = RestClient.builder(hosts);
 
+        restClientBuilder.setRequestConfigCallback(new 
RestClientBuilder.RequestConfigCallback() {
+            @Override
+            public RequestConfig.Builder 
customizeRequestConfig(RequestConfig.Builder requestConfigBuilder) {
+                return requestConfigBuilder.setConnectTimeout(1000)
+                        .setSocketTimeout(10000);
+            }
+        }).setMaxRetryTimeoutMillis(20000);
+
         if (username != null) {
             final CredentialsProvider credentialsProvider = new 
BasicCredentialsProvider();
             credentialsProvider.setCredentials(AuthScope.ANY, new 
UsernamePasswordCredentials(username, password));

-- 
To stop receiving notification emails like this one, please contact
jbono...@apache.org.

Reply via email to