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

avijayan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ambari-metrics.git


The following commit(s) were added to refs/heads/master by this push:
     new a197d28  AMBARI-25126.fix ambari-metric exception printed in namenode 
(#16)
a197d28 is described below

commit a197d284c583be1a96134215d61fbfc2ec62b66c
Author: asagjj <shenyin...@cmss.chinamobile.com>
AuthorDate: Tue Apr 2 01:45:38 2019 +0800

    AMBARI-25126.fix ambari-metric exception printed in namenode (#16)
    
    * AMBARI-25126.fix ambari-metric exception printed in namenode
    
    * Delete ambari-metrics.iml
---
 .../availability/MetricSinkWriteShardHostnameHashingStrategy.java     | 4 ++++
 1 file changed, 4 insertions(+)

diff --git 
a/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/availability/MetricSinkWriteShardHostnameHashingStrategy.java
 
b/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/availability/MetricSinkWriteShardHostnameHashingStrategy.java
index 25bff54..c79bbfb 100644
--- 
a/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/availability/MetricSinkWriteShardHostnameHashingStrategy.java
+++ 
b/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/availability/MetricSinkWriteShardHostnameHashingStrategy.java
@@ -36,6 +36,10 @@ public class MetricSinkWriteShardHostnameHashingStrategy 
implements MetricSinkWr
 
   @Override
   public String findCollectorShard(List<String> collectorHosts) {
+    if(collectorHosts.size() ==0) {
+      LOG.warn("No metrics collectors alive, please check collector status!");
+      return "";
+    }
     long index = hostnameHash % collectorHosts.size();
     index = index < 0 ? index + collectorHosts.size() : index;
     String collectorHost = collectorHosts.get((int) index);

Reply via email to