ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [20/50] ambari git commit: AMBARI-20403 : Yarn Container metrics are not being collected by AMS (avijayan)
Date Tue, 14 Mar 2017 18:42:04 GMT
AMBARI-20403 : Yarn Container metrics are not being collected by AMS (avijayan)


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

Branch: refs/heads/branch-feature-AMBARI-12556
Commit: c4fce5383b650dc6e2480b554cb6832876ced311
Parents: b13467f
Author: Aravindan Vijayan <avijayan@hortonworks.com>
Authored: Sun Mar 12 16:11:02 2017 -0700
Committer: Aravindan Vijayan <avijayan@hortonworks.com>
Committed: Sun Mar 12 16:11:02 2017 -0700

----------------------------------------------------------------------
 .../sink/timeline/AbstractTimelineMetricsSink.java  | 16 +++++-----------
 .../sink/timeline/HadoopTimelineMetricsSink.java    | 15 +++++++++++++--
 .../metrics/system/impl/AmbariMetricSinkImpl.java   |  2 +-
 .../system/impl/TestAmbariMetricsSinkImpl.java      |  2 +-
 4 files changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c4fce538/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/AbstractTimelineMetricsSink.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/AbstractTimelineMetricsSink.java
b/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/AbstractTimelineMetricsSink.java
index a1fd008..46f32f9 100644
--- a/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/AbstractTimelineMetricsSink.java
+++ b/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/AbstractTimelineMetricsSink.java
@@ -209,7 +209,7 @@ public abstract class AbstractTimelineMetricsSink {
     }
   }
 
-  protected boolean emitMetrics(TimelineMetrics metrics) {
+  protected String getCurrentCollectorHost() {
     String collectorHost;
     // Get cached target
     if (targetCollectorHostSupplier != null) {
@@ -232,11 +232,14 @@ public abstract class AbstractTimelineMetricsSink {
       } else {
         nullCollectorCounter.compareAndSet(NUMBER_OF_NULL_COLLECTOR_EXCEPTIONS, 0);
       }
-      return false;
     } else {
       nullCollectorCounter.set(0);
     }
+    return collectorHost;
+  }
 
+  protected boolean emitMetrics(TimelineMetrics metrics) {
+    String collectorHost = getCurrentCollectorHost();
     String connectUrl = getCollectorUri(collectorHost);
     String jsonData = null;
     LOG.debug("EmitMetrics connectUrl = "  + connectUrl);
@@ -499,15 +502,6 @@ public abstract class AbstractTimelineMetricsSink {
     return sb.toString();
   }
 
-  protected String constructContainerMetricUri(String protocol, String host, String port)
{
-    StringBuilder sb = new StringBuilder(protocol);
-    sb.append("://");
-    sb.append(host);
-    sb.append(":");
-    sb.append(port);
-    sb.append(WS_V1_TIMELINE_METRICS);
-    return sb.toString();
-  }
   /**
    * Parses input Sting of format "host1,host2" into Collection of hostnames
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4fce538/ambari-metrics/ambari-metrics-hadoop-sink/src/main/java/org/apache/hadoop/metrics2/sink/timeline/HadoopTimelineMetricsSink.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-hadoop-sink/src/main/java/org/apache/hadoop/metrics2/sink/timeline/HadoopTimelineMetricsSink.java
b/ambari-metrics/ambari-metrics-hadoop-sink/src/main/java/org/apache/hadoop/metrics2/sink/timeline/HadoopTimelineMetricsSink.java
index 6e0eba5..a112ef2 100644
--- a/ambari-metrics/ambari-metrics-hadoop-sink/src/main/java/org/apache/hadoop/metrics2/sink/timeline/HadoopTimelineMetricsSink.java
+++ b/ambari-metrics/ambari-metrics-hadoop-sink/src/main/java/org/apache/hadoop/metrics2/sink/timeline/HadoopTimelineMetricsSink.java
@@ -201,7 +201,7 @@ public class HadoopTimelineMetricsSink extends AbstractTimelineMetricsSink
imple
   /**
    * Parses input Stings array of format "host1,host2" into Collection of hostnames
    */
-  protected Collection<String> parseHostsStringArrayIntoCollection(String[] hostStrings)
{
+  protected Collection<String>  parseHostsStringArrayIntoCollection(String[] hostStrings)
{
     Collection<String> result = new HashSet<>();
     if (hostStrings == null) return result;
     for (String s : hostStrings) {
@@ -428,11 +428,22 @@ public class HadoopTimelineMetricsSink extends AbstractTimelineMetricsSink
imple
       LOG.error("Unable to parse container metrics ", e);
     }
     if (jsonData != null) {
-      // TODO: Container metrics should be able to utilize failover mechanism
+      String collectorHost = getCurrentCollectorHost();
+      containerMetricsUri = constructContainerMetricUri(protocol, collectorHost, port);
       emitMetricsJson(containerMetricsUri, jsonData);
     }
   }
 
+  protected String constructContainerMetricUri(String protocol, String host, String port)
{
+    StringBuilder sb = new StringBuilder(protocol);
+    sb.append("://");
+    sb.append(host);
+    sb.append(":");
+    sb.append(port);
+    sb.append(WS_V1_CONTAINER_METRICS);
+    return sb.toString();
+  }
+
   // Taken as is from Ganglia30 implementation
   @InterfaceAudience.Private
   public void appendPrefix(MetricsRecord record, StringBuilder sb) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4fce538/ambari-server/src/main/java/org/apache/ambari/server/metrics/system/impl/AmbariMetricSinkImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/metrics/system/impl/AmbariMetricSinkImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/metrics/system/impl/AmbariMetricSinkImpl.java
index f066c3d..8b53c10 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/metrics/system/impl/AmbariMetricSinkImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/metrics/system/impl/AmbariMetricSinkImpl.java
@@ -246,7 +246,7 @@ public class AmbariMetricSinkImpl extends AbstractTimelineMetricsSink
implements
    */
   @Override
   protected String getCollectorUri(String host) {
-    return constructContainerMetricUri(protocol, host, port);
+    return constructTimelineMetricUri(protocol, host, port);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4fce538/ambari-server/src/test/java/org/apache/ambari/server/metric/system/impl/TestAmbariMetricsSinkImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/metric/system/impl/TestAmbariMetricsSinkImpl.java
b/ambari-server/src/test/java/org/apache/ambari/server/metric/system/impl/TestAmbariMetricsSinkImpl.java
index 996f3fc..4a60892 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/metric/system/impl/TestAmbariMetricsSinkImpl.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/metric/system/impl/TestAmbariMetricsSinkImpl.java
@@ -40,7 +40,7 @@ public class TestAmbariMetricsSinkImpl extends AbstractTimelineMetricsSink
imple
 
   @Override
   protected String getCollectorUri(String host) {
-    return constructContainerMetricUri(getCollectorProtocol(), host, getCollectorPort());
+    return constructTimelineMetricUri(getCollectorProtocol(), host, getCollectorPort());
   }
 
   @Override


Mime
View raw message