Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BD0A611B58 for ; Thu, 18 Sep 2014 14:43:51 +0000 (UTC) Received: (qmail 62312 invoked by uid 500); 18 Sep 2014 14:43:51 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 62191 invoked by uid 500); 18 Sep 2014 14:43:51 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 61426 invoked by uid 99); 18 Sep 2014 14:43:51 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Sep 2014 14:43:51 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B4631A1B0FB; Thu, 18 Sep 2014 14:43:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jonathanhurley@apache.org To: commits@ambari.apache.org Date: Thu, 18 Sep 2014 14:44:11 -0000 Message-Id: <6ac9a42f0f554b1a98690ecbe70e97db@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [22/34] git commit: AMBARI-7374. Slider View: BE - Provide alerts in view API. Correcting component counts AMBARI-7374. Slider View: BE - Provide alerts in view API. Correcting component counts Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/00589244 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/00589244 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/00589244 Branch: refs/heads/branch-alerts-dev Commit: 0058924443bee9cb4b55afade3bfa08196765308 Parents: c7651de Author: Srimanth Gunturi Authored: Wed Sep 17 21:00:46 2014 -0700 Committer: Srimanth Gunturi Committed: Wed Sep 17 21:00:46 2014 -0700 ---------------------------------------------------------------------- .../ambari/view/slider/SliderAppsAlerts.java | 30 ++++++++++++-------- .../slider/SliderAppsViewControllerImpl.java | 8 ++++++ .../assets/data/resource/service_configs.json | 2 +- .../createAppWizard/step1_controller.js | 2 +- .../ui/app/templates/slider_app/summary.hbs | 2 +- 5 files changed, 29 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/00589244/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsAlerts.java ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsAlerts.java b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsAlerts.java index 957c6e8..4eb54d5 100644 --- a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsAlerts.java +++ b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsAlerts.java @@ -66,8 +66,23 @@ public class SliderAppsAlerts { HashMap alertItem = new HashMap(); Date date = Calendar.getInstance().getTime(); - - AlertState state = getComponentState(component); + int totalContainerCount = component.getInstanceCount(); + int activeContainerCount = component.getActiveContainers() != null ? component + .getActiveContainers().size() : 0; + AlertState state = AlertState.UNKNOWN; + String message = String.format("%s out of %s active", activeContainerCount, + totalContainerCount); + if (totalContainerCount == activeContainerCount || totalContainerCount < 1) { + // Everything OK + state = AlertState.OK; + } else { + float fraction = (float) activeContainerCount / (float) totalContainerCount; + if (fraction <= 0.2) { // less than or equal to 20% + state = AlertState.WARNING; + } else { + state = AlertState.CRITICAL; + } + } alertItem.put(AlertField.description, String.format("%s component",component.getComponentName())); alertItem.put(AlertField.host_name, getComponentHostName(component)); alertItem.put(AlertField.last_status, state); @@ -78,7 +93,7 @@ public class SliderAppsAlerts { alertItem.put(AlertField.component_name, component.getComponentName()); alertItem.put(AlertField.status, state); alertItem.put(AlertField.status_time, new java.sql.Timestamp(date.getTime())); - alertItem.put(AlertField.output, state); + alertItem.put(AlertField.output, message); alertItem.put(AlertField.actual_status, state); return alertItem; } @@ -108,13 +123,4 @@ public class SliderAppsAlerts { } return null; } - - private AlertState getComponentState(SliderAppComponent component){ - if (component.getInstanceCount() == component.getActiveContainers().size()){ - return AlertState.OK; - } - return AlertState.CRITICAL; - } - - } http://git-wip-us.apache.org/repos/asf/ambari/blob/00589244/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java index 027f824..ef11cfa 100644 --- a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java +++ b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java @@ -319,9 +319,17 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController { containerId, containerDataMap); } } + // Set total instances count from statistics appComponent.setInstanceCount(appComponent .getActiveContainers().size() + appComponent.getCompletedContainers().size()); + if (description.statistics != null + && description.statistics.containsKey(componentEntry.getKey())) { + Map statisticsMap = description.statistics.get(componentEntry.getKey()); + if (statisticsMap.containsKey("containers.desired")) { + appComponent.setInstanceCount(statisticsMap.get("containers.desired")); + } + } } } app.setAlerts(sliderAlerts.generateComponentsAlerts(componentTypeMap, app.getType())); http://git-wip-us.apache.org/repos/asf/ambari/blob/00589244/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_configs.json ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_configs.json b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_configs.json index f255bec..24c1a31 100644 --- a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_configs.json +++ b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/service_configs.json @@ -19,7 +19,7 @@ "rrdcached_flush_timeout" : "7200", "gmond_user" : "nobody", "ganglia_runtime_dir" : "/var/run/ganglia/hdp", - "ganglia_custom_clusters": "'HBaseCluster1','7000','AccumuloCluster1','7001','HBaseCluster2','7002'" + "additional_clusters": "'HBaseCluster1','7000','AccumuloCluster1','7001','HBaseCluster2','7002'" }, "properties_attributes" : { } } http://git-wip-us.apache.org/repos/asf/ambari/blob/00589244/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js index 9ffc432..8583443 100644 --- a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js +++ b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js @@ -141,7 +141,7 @@ App.CreateAppWizardStep1Controller = Ember.Controller.extend({ var gangliaCustomClusters = []; if (data.items[0]) { - var prop = Em.get(data.items[0].configurations[0].properties, 'ganglia_custom_clusters'); + var prop = Em.get(data.items[0].configurations[0].properties, 'additional_clusters'); if (prop) { //parse CSV string with cluster names and ports prop.replace(/\'/g, "").split(',').forEach(function(item, index){ http://git-wip-us.apache.org/repos/asf/ambari/blob/00589244/contrib/views/slider/src/main/resources/ui/app/templates/slider_app/summary.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/slider_app/summary.hbs b/contrib/views/slider/src/main/resources/ui/app/templates/slider_app/summary.hbs index 68d47b4..ae056a6 100644 --- a/contrib/views/slider/src/main/resources/ui/app/templates/slider_app/summary.hbs +++ b/contrib/views/slider/src/main/resources/ui/app/templates/slider_app/summary.hbs @@ -90,7 +90,7 @@
{{title}}
-
{{timeSinceAlert}}
+
{{timeSinceAlert}}
{{message}}