You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2018/06/14 00:28:21 UTC
[ambari] branch trunk updated: [AMBARI-24088] Log Feeder dint start
during cluster install because of java.net.ConnectException (#1525)
This is an automated email from the ASF dual-hosted git repository.
swagle pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 3906975 [AMBARI-24088] Log Feeder dint start during cluster install because of java.net.ConnectException (#1525)
3906975 is described below
commit 390697530ddd2995e9bcaa06e8fcfeecbc191e15
Author: kasakrisz <33...@users.noreply.github.com>
AuthorDate: Thu Jun 14 02:27:59 2018 +0200
[AMBARI-24088] Log Feeder dint start during cluster install because of java.net.ConnectException (#1525)
---
.../config/zookeeper/LogSearchConfigZK.java | 54 +++++++++++++++++++---
1 file changed, 48 insertions(+), 6 deletions(-)
diff --git a/ambari-logsearch/ambari-logsearch-config-zookeeper/src/main/java/org/apache/ambari/logsearch/config/zookeeper/LogSearchConfigZK.java b/ambari-logsearch/ambari-logsearch-config-zookeeper/src/main/java/org/apache/ambari/logsearch/config/zookeeper/LogSearchConfigZK.java
index 64a6777..382d8fa 100644
--- a/ambari-logsearch/ambari-logsearch-config-zookeeper/src/main/java/org/apache/ambari/logsearch/config/zookeeper/LogSearchConfigZK.java
+++ b/ambari-logsearch/ambari-logsearch-config-zookeeper/src/main/java/org/apache/ambari/logsearch/config/zookeeper/LogSearchConfigZK.java
@@ -28,10 +28,12 @@ import org.apache.ambari.logsearch.config.api.LogSearchPropertyDescription;
import org.apache.ambari.logsearch.config.api.model.loglevelfilter.LogLevelFilter;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.cache.TreeCache;
-import org.apache.curator.retry.ExponentialBackoffRetry;
+import org.apache.curator.retry.RetryForever;
+import org.apache.curator.retry.RetryUntilElapsed;
import org.apache.zookeeper.KeeperException.NodeExistsException;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
@@ -46,8 +48,9 @@ import com.google.gson.GsonBuilder;
public class LogSearchConfigZK implements LogSearchConfig {
private static final Logger LOG = LoggerFactory.getLogger(LogSearchConfigZK.class);
- private static final int SESSION_TIMEOUT = 60000;
- private static final int CONNECTION_TIMEOUT = 30000;
+ private static final int DEFAULT_SESSION_TIMEOUT = 60000;
+ private static final int DEFAULT_CONNECTION_TIMEOUT = 30000;
+ private static final int RETRY_INTERVAL_MS = 10000;
private static final String DEFAULT_ZK_ROOT = "/logsearch";
private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS";
@@ -76,6 +79,30 @@ public class LogSearchConfigZK implements LogSearchConfig {
)
private static final String ZK_ROOT_NODE_PROPERTY = "logsearch.config.zk_root";
+ @LogSearchPropertyDescription(
+ name = "logsearch.config.zk_session_time_out_ms",
+ description = "ZooKeeper session timeout in milliseconds",
+ examples = {"60000"},
+ sources = {"logsearch.properties", "logfeeder.properties"}
+ )
+ private static final String ZK_SESSION_TIMEOUT_PROPERTY = "logsearch.config.zk_session_time_out_ms";
+
+ @LogSearchPropertyDescription(
+ name = "logsearch.config.zk_connection_time_out_ms",
+ description = "ZooKeeper connection timeout in milliseconds",
+ examples = {"30000"},
+ sources = {"logsearch.properties", "logfeeder.properties"}
+ )
+ private static final String ZK_CONNECTION_TIMEOUT_PROPERTY = "logsearch.config.zk_connection_time_out_ms";
+
+ @LogSearchPropertyDescription(
+ name = "logsearch.config.zk_connection_retry_time_out_ms",
+ description = "The maximum elapsed time for connecting to ZooKeeper in milliseconds. 0 means retrying forever.",
+ examples = {"1200000"},
+ sources = {"logsearch.properties", "logfeeder.properties"}
+ )
+ private static final String ZK_CONNECTION_RETRY_TIMEOUT_PROPERTY = "logsearch.config.zk_connection_retry_time_out_ms";
+
protected Map<String, String> properties;
protected CuratorFramework client;
protected TreeCache outputCache;
@@ -88,9 +115,9 @@ public class LogSearchConfigZK implements LogSearchConfig {
LOG.info("Connecting to ZooKeeper at " + properties.get(ZK_CONNECT_STRING_PROPERTY) + root);
client = CuratorFrameworkFactory.builder()
.connectString(properties.get(ZK_CONNECT_STRING_PROPERTY) + root)
- .retryPolicy(new ExponentialBackoffRetry(1000, 3))
- .connectionTimeoutMs(CONNECTION_TIMEOUT)
- .sessionTimeoutMs(SESSION_TIMEOUT)
+ .retryPolicy(getRetryPolicy(properties.get(ZK_CONNECTION_RETRY_TIMEOUT_PROPERTY)))
+ .connectionTimeoutMs(getIntProperty(ZK_CONNECTION_TIMEOUT_PROPERTY, DEFAULT_CONNECTION_TIMEOUT))
+ .sessionTimeoutMs(getIntProperty(ZK_SESSION_TIMEOUT_PROPERTY, DEFAULT_SESSION_TIMEOUT))
.build();
client.start();
@@ -100,6 +127,21 @@ public class LogSearchConfigZK implements LogSearchConfig {
gson = new GsonBuilder().setDateFormat(DATE_FORMAT).create();
}
+ private int getIntProperty(String propertyKey, int defaultValue) {
+ if (properties.get(propertyKey) == null)
+ return defaultValue;
+ return Integer.parseInt(properties.get(propertyKey));
+ }
+
+ private RetryPolicy getRetryPolicy(String zkConnectionRetryTimeoutValue) {
+ if (zkConnectionRetryTimeoutValue == null)
+ return new RetryForever(RETRY_INTERVAL_MS);
+ int maxElapsedTimeMs = Integer.parseInt(zkConnectionRetryTimeoutValue);
+ if (maxElapsedTimeMs == 0)
+ return new RetryForever(RETRY_INTERVAL_MS);
+ return new RetryUntilElapsed(maxElapsedTimeMs, RETRY_INTERVAL_MS);
+ }
+
@Override
public void createInputConfig(String clusterName, String serviceName, String inputConfig) throws Exception {
String nodePath = String.format("/%s/input/%s", clusterName, serviceName);
--
To stop receiving notification emails like this one, please contact
swagle@apache.org.