瀏覽代碼

AMBARI-9730 Ambari Metrics service check fails after deploy ambari (dsen)

Dmytro Sen 10 年之前
父節點
當前提交
db43413ee4

+ 8 - 0
ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/HBaseTimelineMetricStore.java

@@ -116,6 +116,10 @@ public class HBaseTimelineMetricStore extends AbstractService
     if (applicationId == null || applicationId.trim().length() == 0) {
       throw new IllegalArgumentException("No applicationID filter specified.");
     }
+    if ((startTime == null && endTime != null)
+        || (startTime != null && endTime == null)) {
+      throw new IllegalArgumentException("Open ended query not supported ");
+    }
     if (limit != null && limit > PhoenixHBaseAccessor.RESULTSET_LIMIT){
       throw new IllegalArgumentException("Limit too big");
     }
@@ -221,6 +225,10 @@ public class HBaseTimelineMetricStore extends AbstractService
     if (applicationId == null || applicationId.trim().length() == 0) {
       throw new IllegalArgumentException("No applicationID filter specified.");
     }
+    if ((startTime == null && endTime != null)
+        || (startTime != null && endTime == null)) {
+      throw new IllegalArgumentException("Open ended query not supported ");
+    }
     if (limit !=null && limit > PhoenixHBaseAccessor.RESULTSET_LIMIT){
       throw new IllegalArgumentException("Limit too big");
     }

+ 9 - 7
ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/service_check.py

@@ -68,7 +68,7 @@ class AMSServiceCheck(Script):
     env.set_params(params)
 
     random_value1 = random.random()
-    current_time = time.time()
+    current_time = int(time.time()) * 1000
     metric_json = Template('smoketest_metrics.json.j2', hostname=params.hostname, random1=random_value1,
                            current_time=current_time).get_content()
     Logger.info("Generated metrics:\n%s" % metric_json)
@@ -111,7 +111,8 @@ class AMSServiceCheck(Script):
       "metricNames": "AMBARI_METRICS.SmokeTest.FakeMetric",
       "appId": "amssmoketestfake",
       "hostname": params.hostname,
-      "startTime": 1419860000000,
+      "startTime": current_time - 60000,
+      "endTime": current_time + 61000,
       "precision": "seconds",
       "grouped": "false",
     }
@@ -143,14 +144,15 @@ class AMSServiceCheck(Script):
       return abs(f1-f2) < delta
 
     for metrics_data in data_json["metrics"]:
-      if (floats_eq(metrics_data["metrics"]["1419860001000"], random_value1, 0.0000001)
-          and floats_eq(metrics_data["metrics"]["1419860002000"], current_time, 1)):
-        Logger.info("Values %s and %s were found in response." % (random_value1, current_time))
+      if (str(current_time) in metrics_data["metrics"] and str(current_time + 1000) in metrics_data["metrics"]
+          and floats_eq(metrics_data["metrics"][str(current_time)], random_value1, 0.0000001)
+          and floats_eq(metrics_data["metrics"][str(current_time + 1000)], current_time, 1)):
+        Logger.info("Values %s and %s were found in the response." % (random_value1, current_time))
         break
       pass
     else:
-      Logger.info("Values %s and %s were not found in response." % (random_value1, current_time))
-      raise Fail("Values %s and %s were not found in response." % (random_value1, current_time))
+      Logger.info("Values %s and %s were not found in the response." % (random_value1, current_time))
+      raise Fail("Values %s and %s were not found in the response." % (random_value1, current_time))
 
     Logger.info("Ambari Metrics service check is finished.")
 

+ 4 - 4
ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/smoketest_metrics.json.j2

@@ -4,11 +4,11 @@
       "metricname": "AMBARI_METRICS.SmokeTest.FakeMetric",
       "appid": "amssmoketestfake",
       "hostname": "{{hostname}}",
-      "timestamp": 1419860001000,
-      "starttime": 1419860001000,
+      "timestamp": {{current_time}},
+      "starttime": {{current_time}},
       "metrics": {
-        "1419860001000": {{random1}},
-        "1419860002000": {{current_time}}
+        "{{current_time}}": {{random1}},
+        "{{current_time + 1000}}": {{current_time}}
       }
     }
   ]