ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From avija...@apache.org
Subject [1/3] ambari git commit: AMBARI-18012 : Metrics Sink unable to connect to zookeeper to locate collector host. (avijayan)
Date Wed, 17 Aug 2016 17:57:42 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 793adfe46 -> ad2da2908


AMBARI-18012 : Metrics Sink unable to connect to zookeeper to locate collector host. (avijayan)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8d47d382
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8d47d382
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8d47d382

Branch: refs/heads/trunk
Commit: 8d47d3825489e63d5e16e537257b02f8075dceab
Parents: 793adfe
Author: Aravindan Vijayan <avijayan@hortonworks.com>
Authored: Wed Aug 17 10:55:03 2016 -0700
Committer: Aravindan Vijayan <avijayan@hortonworks.com>
Committed: Wed Aug 17 10:55:03 2016 -0700

----------------------------------------------------------------------
 .../availability/MetricCollectorHAHelper.java      | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8d47d382/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/availability/MetricCollectorHAHelper.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/availability/MetricCollectorHAHelper.java
b/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/availability/MetricCollectorHAHelper.java
index 7b13362..4d0ec14 100644
--- a/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/availability/MetricCollectorHAHelper.java
+++ b/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/availability/MetricCollectorHAHelper.java
@@ -22,13 +22,12 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.curator.CuratorZookeeperClient;
 import org.apache.curator.RetryLoop;
 import org.apache.curator.RetryPolicy;
-import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.retry.RetryUntilElapsed;
 import org.apache.zookeeper.ZooKeeper;
 
-import java.net.HttpURLConnection;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Callable;
 
@@ -43,7 +42,7 @@ public class MetricCollectorHAHelper {
   private final int sleepMsBetweenRetries;
 
   private static final int CONNECTION_TIMEOUT = 2000;
-  private static final int SESSION_TIMEOUT = 5000;
+  private static final int SESSION_TIMEOUT = 10000;
   private static final String ZK_PATH = "/ambari-metrics-cluster/LIVEINSTANCES";
   private static final String INSTANCE_NAME_DELIMITER = "_";
 
@@ -68,15 +67,15 @@ public class MetricCollectorHAHelper {
     final CuratorZookeeperClient client = new CuratorZookeeperClient(zookeeperQuorum,
       SESSION_TIMEOUT, CONNECTION_TIMEOUT, null, retryPolicy);
 
-    String liveInstances = null;
+    List<String> liveInstances = null;
 
     try {
-      liveInstances = RetryLoop.callWithRetry(client, new Callable<String>() {
+      client.start();
+      liveInstances = RetryLoop.callWithRetry(client, new Callable<List<String>>()
{
         @Override
-        public String call() throws Exception {
+        public List<String> call() throws Exception {
           ZooKeeper zookeeper = client.getZooKeeper();
-          byte[] data = zookeeper.getData(ZK_PATH, null, null);
-          return data != null ? new String(data) : null;
+          return zookeeper.getChildren(ZK_PATH, false);
         }
       });
     } catch (Exception e) {
@@ -86,7 +85,7 @@ public class MetricCollectorHAHelper {
 
     // [ambari-sid-3.c.pramod-thangali.internal_12001]
     if (liveInstances != null && !liveInstances.isEmpty()) {
-      for (String instanceStr : liveInstances.split(",")) {
+      for (String instanceStr : liveInstances) {
         collectors.add(instanceStr.substring(0, instanceStr.indexOf(INSTANCE_NAME_DELIMITER)));
       }
     }


Mime
View raw message