Repository: ambari Updated Branches: refs/heads/trunk 78c0bbb5a -> bd8af3f27
AMBARI-9730 Ambari Metrics service check fails after deploy ambari (dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/db43413e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/db43413e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/db43413e Branch: refs/heads/trunk Commit: db43413ee457c07aaee9eb9c33538e697bb2b248 Parents: 78c0bbb Author: Dmytro Sen <[email protected]> Authored: Fri Feb 20 18:45:37 2015 +0200 Committer: Dmytro Sen <[email protected]> Committed: Fri Feb 20 18:45:37 2015 +0200 ---------------------------------------------------------------------- .../metrics/timeline/HBaseTimelineMetricStore.java | 8 ++++++++ .../0.1.0/package/scripts/service_check.py | 16 +++++++++------- .../package/templates/smoketest_metrics.json.j2 | 8 ++++---- 3 files changed, 21 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/db43413e/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/HBaseTimelineMetricStore.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/HBaseTimelineMetricStore.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/HBaseTimelineMetricStore.java index b9a2922..3969fa9 100644 --- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/HBaseTimelineMetricStore.java +++ b/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"); } http://git-wip-us.apache.org/repos/asf/ambari/blob/db43413e/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/service_check.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/service_check.py b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/service_check.py index b5a5745..7954f8c 100644 --- a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/service_check.py +++ b/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.") http://git-wip-us.apache.org/repos/asf/ambari/blob/db43413e/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/smoketest_metrics.json.j2 ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/smoketest_metrics.json.j2 b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/smoketest_metrics.json.j2 index c90c29e..2ee0efa 100644 --- a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/templates/smoketest_metrics.json.j2 +++ b/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}} } } ]
