You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2014/01/29 16:53:38 UTC

git commit: AMBARI-4229 Maintenance Mode: Host Detail page (Components Section)[new api]. (ababiichuk)

Updated Branches:
  refs/heads/trunk 4a1eaf22d -> 7bc910320


AMBARI-4229 Maintenance Mode: Host Detail page (Components Section)[new api]. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: 7bc9103204cbddfc475f345b935470e4174bcf06
Parents: 4a1eaf2
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Wed Jan 29 17:44:30 2014 +0200
Committer: aBabiichuk <ab...@cybervisiontech.com>
Committed: Wed Jan 29 17:50:37 2014 +0200

----------------------------------------------------------------------
 .../controllers/global/cluster_controller.js    |  4 +-
 .../app/controllers/global/update_controller.js |  1 +
 ambari-web/app/controllers/main/host/details.js | 18 ++---
 ambari-web/app/mappers/server_data_mapper.js    |  1 +
 .../app/mappers/service_metrics_mapper.js       |  4 +-
 ambari-web/app/mappers/status_mapper.js         | 13 +++-
 ambari-web/app/messages.js                      | 10 +--
 ambari-web/app/models/host_component.js         |  6 +-
 ambari-web/app/templates/main/host/summary.hbs  | 78 ++++++++++----------
 ambari-web/app/utils/ajax.js                    |  6 +-
 ambari-web/app/views/main/host/summary.js       | 10 +--
 11 files changed, 81 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index 46670a1..f8c4fea 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -202,11 +202,11 @@ App.ClusterController = Em.Controller.extend({
       return false;
     }
     var testUrl = App.get('isHadoop2Stack') ? '/data/hosts/HDP2/hc_host_status.json' : '/data/dashboard/services.json';
-    var statusUrl = '/hosts?fields=Hosts/host_status,host_components/HostRoles/state&minimal_response=true';
+    var statusUrl = '/hosts?fields=Hosts/host_status,host_components/HostRoles/state,host_components/HostRoles/passive_state&minimal_response=true';
     if (isInitialLoad) {
       testUrl = '/data/hosts/HDP2/hosts_init.json';
       statusUrl = '/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/cpu_count,Hosts/ph_cpu_count,Hosts/total_mem,' +
-        'Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components/HostRoles/state,' +
+        'Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components/HostRoles/state,host_components/HostRoles/passive_state,' +
         'Hosts/disk_info,metrics/disk,metrics/load/load_one,metrics/cpu/cpu_system,metrics/cpu/cpu_user,' +
         'metrics/memory/mem_total,metrics/memory/mem_free,alerts/summary&minimal_response=true';
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index db8e7d0..196a39a 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -144,6 +144,7 @@ App.UpdateController = Em.Controller.extend({
     var realUrl = '/components/?ServiceComponentInfo/category=MASTER&fields=' +
       'ServiceComponentInfo,' +
       'host_components/HostRoles/state,' +
+      'host_components/HostRoles/passive_state,' +
       'host_components/HostRoles/stale_configs,' +
       'host_components/metrics/jvm/memHeapUsedM,' +
       'host_components/metrics/jvm/HeapMemoryMax,' +

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index f81a794..73fa87a 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -1169,34 +1169,34 @@ App.MainHostDetailsController = Em.Controller.extend({
     });
   },
 
-  turnOnOffMaintenanceConfirmation: function(event){
+  turnOnOffPassiveConfirmation: function(event){
     var self = this;
     var component = event.context;
     var componentName = component.get('componentName').toUpperCase();
     var state, onOff;
-    if (component.get("workStatus") == App.HostComponentStatus.maintenance) {
+    if (component.get("passiveState") == "PASSIVE") {
       onOff = "Off";
-      state = App.HostComponentStatus.stopped;
+      state = "ACTIVE";
     } else {
       onOff = "On";
-      state = App.HostComponentStatus.maintenance;
+      state = "PASSIVE";
     }
     App.showConfirmationPopup(function() {
-          self.turnOnOffmaintenance(state, componentName)
+          self.turnOnOffPassive(state, componentName)
         },
-        Em.I18n.t('hosts.maintenanceMode.popup').format(onOff,component.get('displayName'))
+        Em.I18n.t('hosts.passiveMode.popup').format(onOff,component.get('displayName'))
     );
   },
 
-  turnOnOffmaintenance: function(state,componentName) {
+  turnOnOffPassive: function(state,componentName) {
     var hostName = this.get('content.hostName');
     App.ajax.send({
-      name: 'host_component.maintenance_mode',
+      name: 'host_component.passive',
       sender: this,
       data: {
         hostName: hostName,
         componentName: componentName,
-        state: state,
+        passive_state: state,
         requestInfo: componentName + " " + state
       }
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/mappers/server_data_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/server_data_mapper.js b/ambari-web/app/mappers/server_data_mapper.js
index 3977e5d..b15bcae 100644
--- a/ambari-web/app/mappers/server_data_mapper.js
+++ b/ambari-web/app/mappers/server_data_mapper.js
@@ -26,6 +26,7 @@ App.cache = {
   'Hosts': {},
   'previousHostStatuses': {},
   'previousComponentStatuses': {},
+  'previousComponentPassiveStates': {},
   'hostComponentsOnService': {},
   'services': [],
   'hostComponentRecordsMap': {}

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/mappers/service_metrics_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/service_metrics_mapper.js b/ambari-web/app/mappers/service_metrics_mapper.js
index 541f738..66af2ca 100644
--- a/ambari-web/app/mappers/service_metrics_mapper.js
+++ b/ambari-web/app/mappers/service_metrics_mapper.js
@@ -133,6 +133,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
   config3: {
     id: 'id',
     work_status: 'HostRoles.state',
+    passive_state:'HostRoles.passive_state',
     desired_status: 'HostRoles.desired_state',
     component_name: 'HostRoles.component_name',
     host_id: 'HostRoles.host_name',
@@ -153,7 +154,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
       var hostComponents = [];
       var services = App.cache['services'];
       var previousComponentStatuses = App.cache['previousComponentStatuses'];
-
+      var previousComponentPassiveStates = App.cache['previousComponentPassiveStates'];
       /**
        * services contains constructed service-components structure from components array
        */
@@ -164,6 +165,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
         component.host_components.forEach(function (host_component) {
           host_component.id = host_component.HostRoles.component_name + "_" + host_component.HostRoles.host_name;
           previousComponentStatuses[host_component.id] = host_component.HostRoles.state;
+          previousComponentPassiveStates[host_component.id] = host_component.HostRoles.passive_state;
           if (host_component.HostRoles.component_name == "HBASE_MASTER") {
             this.config3.ha_status = 'metrics.hbase.master.IsActiveMaster';
           }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/mappers/status_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/status_mapper.js b/ambari-web/app/mappers/status_mapper.js
index 793c440..788e14a 100644
--- a/ambari-web/app/mappers/status_mapper.js
+++ b/ambari-web/app/mappers/status_mapper.js
@@ -25,12 +25,14 @@ App.statusMapper = App.QuickDataMapper.create({
       var hostsCache = App.cache['Hosts'];
       var previousHostStatuses = App.cache['previousHostStatuses'];
       var previousComponentStatuses = App.cache['previousComponentStatuses'];
+      var previousComponentPassiveStates = App.cache['previousComponentPassiveStates'];
       var hostComponentRecordsMap = App.cache['hostComponentRecordsMap'];
       var hostStatuses = {};
       var addedHostComponents = [];
       var updatedHostComponents = [];
       var componentServiceMap = App.QuickDataMapper.componentServiceMap();
       var currentComponentStatuses = {};
+      var currentComponentPassiveStates = {};
       var currentHostStatuses = {};
       var hostComponentsOnService = {};
 
@@ -46,20 +48,23 @@ App.statusMapper = App.QuickDataMapper.create({
         host.host_components.forEach(function (host_component) {
           host_component.id = host_component.HostRoles.component_name + "_" + hostName;
           var existedComponent = previousComponentStatuses[host_component.id];
+          var existedPassiveComponent = previousComponentPassiveStates[host_component.id];
           var service = componentServiceMap[host_component.HostRoles.component_name];
 
           //delete all currently existed host-components to indicate which need to be deleted from model
           delete previousComponentStatuses[host_component.id];
+          delete previousComponentPassiveStates[host_component.id];
 
-          if (existedComponent) {
+          if (existedComponent || existedPassiveComponent) {
             //update host-components, which have status changed
-            if (existedComponent !== host_component.HostRoles.state) {
+            if (existedComponent !== host_component.HostRoles.state || existedPassiveComponent !== host_component.HostRoles.passive_state) {
               updatedHostComponents.push(host_component);
             }
           } else {
             addedHostComponents.push({
               id: host_component.id,
               component_name: host_component.HostRoles.component_name,
+              passive_state: host_component.HostRoles.passive_state,
               work_status: host_component.HostRoles.state,
               host_id: hostName,
               service_id: service
@@ -68,7 +73,7 @@ App.statusMapper = App.QuickDataMapper.create({
             if (hostsCache[hostName]) hostsCache[hostName].is_modified = true;
           }
           currentComponentStatuses[host_component.id] = host_component.HostRoles.state;
-
+          currentComponentPassiveStates[host_component.id] = host_component.HostRoles.passive_state;
           //host-components to host relations
           hostComponentsOnHost.push(host_component.id);
           //host-component to service relations
@@ -96,6 +101,7 @@ App.statusMapper = App.QuickDataMapper.create({
         var hostComponentRecord = hostComponentRecordsMap[hostComponent.id];
         if (hostComponentRecord) {
           hostComponentRecord.set('workStatus', hostComponent.HostRoles.state);
+          hostComponentRecord.set('passiveState', hostComponent.HostRoles.passive_state);
         }
       }, this);
 
@@ -116,6 +122,7 @@ App.statusMapper = App.QuickDataMapper.create({
 
       App.cache['previousHostStatuses'] = currentHostStatuses;
       App.cache['previousComponentStatuses'] = currentComponentStatuses;
+      App.cache['previousComponentPassiveStates'] = currentComponentPassiveStates;
       App.cache['hostComponentsOnService'] = hostComponentsOnService;
 
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 22c38f1..9b86447 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -171,10 +171,10 @@ Em.I18n.translations = {
   'common.url': 'URL',
   'common.advanced': 'Advanced',
 
-  'maintenance.turnOn':'Turn On Maintenance Mode',
-  'maintenance.turnOff':'Turn Off Maintenance Mode',
-  'maintenance.turnOnFor':'Turn On Maintenance Mode for',
-  'maintenance.turnOffFor':'Turn Off Maintenance Mode for',
+  'passiveState.turnOn':'Turn On Passive Mode',
+  'passiveState.turnOff':'Turn Off Passive Mode',
+  'passiveState.turnOnFor':'Turn On Passive Mode for',
+  'passiveState.turnOffFor':'Turn Off Passive Mode for',
 
   'requestInfo.installComponents':'Install Components',
   'requestInfo.installServices':'Install Services',
@@ -1454,7 +1454,7 @@ Em.I18n.translations = {
     'If this host has a DataNode, it should be decommissioned first to prevent data loss.',
   'hosts.add.header':'Add Host Wizard',
   'hosts.assignRack':'Assign Rack',
-  'hosts.maintenanceMode.popup':'Are you sure you want to Turn {0} Maintenance Mode for {1}?',
+  'hosts.passiveMode.popup':'Are you sure you want to Turn {0} Passive Mode for {1}?',
 
   'charts.horizon.chart.showText':'show',
   'charts.horizon.chart.hideText':'hide',

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/models/host_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host_component.js b/ambari-web/app/models/host_component.js
index 3c97531..591b1c4 100644
--- a/ambari-web/app/models/host_component.js
+++ b/ambari-web/app/models/host_component.js
@@ -20,6 +20,7 @@ var App = require('app');
 
 App.HostComponent = DS.Model.extend({
   workStatus: DS.attr('string'),
+  passiveState: DS.attr('string'),
   componentName: DS.attr('string'),
   haStatus: DS.attr('string'),
   displayNameAdvanced: DS.attr('string'),
@@ -170,7 +171,6 @@ App.HostComponentStatus = {
   install_failed: "INSTALL_FAILED",
   installing: "INSTALLING",
   upgrade_failed: "UPGRADE_FAILED",
-  maintenance: "MAINTENANCE",
   unknown: "UNKNOWN",
 
   /**
@@ -194,8 +194,6 @@ App.HostComponentStatus = {
         return 'installing';
       case this.upgrade_failed:
         return 'upgrade_failed';
-      case this.maintenance:
-        return 'maintenance';
       case this.unknown:
         return 'unknown';
     }
@@ -225,8 +223,6 @@ App.HostComponentStatus = {
         return 'Heartbeat lost...';
       case this.upgrade_failed:
         return 'Upgrade Failed';
-      case this.maintenance:
-        return 'Maintenance';
     }
     return 'Unknown';
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/templates/main/host/summary.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/summary.hbs b/ambari-web/app/templates/main/host/summary.hbs
index 072676c..282da83 100644
--- a/ambari-web/app/templates/main/host/summary.hbs
+++ b/ambari-web/app/templates/main/host/summary.hbs
@@ -137,54 +137,58 @@
                     </li>
                   {{/if}}
                   {{#unless view.isInstalling}}
-                    {{#unless view.isInMaintenance}}
-                      {{#if view.isStart}}
+                    {{#if view.isStart}}
                         <li {{bindAttr class=" view.isDecommissioning:hidden view.noActionAvailable"}}>
-                          <a href="javascript:void(null)" data-toggle="modal" {{action "stopComponent" view.content target="controller"}}>
-                            {{t common.stop}}
-                          </a>
+                            <a href="javascript:void(null)"
+                               data-toggle="modal" {{action "stopComponent" view.content target="controller"}}>
+                              {{t common.stop}}
+                            </a>
                         </li>
-                      {{/if}}
-                      {{#unless view.isStart}}
+                    {{/if}}
+                    {{#unless view.isStart}}
                         <li {{bindAttr class="view.isUpgradeFailed:hidden view.isInstallFailed:hidden view.isDecommissioning:hidden view.noActionAvailable"}}>
-                          <a href="javascript:void(null)" data-toggle="modal" {{action "startComponent" view.content target="controller"}}>
-                            {{t common.start}}
-                          </a>
+                            <a href="javascript:void(null)"
+                               data-toggle="modal" {{action "startComponent" view.content target="controller"}}>
+                              {{t common.start}}
+                            </a>
+                        </li>
+                    {{/unless}}
+                    {{#if view.isUpgradeFailed}}
+                        <li {{bindAttr class="view.noActionAvailable"}}>
+                            <a href="javascript:void(null)"
+                               data-toggle="modal" {{action "upgradeComponent" view.content target="controller"}}>
+                              {{t common.reUpgrade}}
+                            </a>
                         </li>
-                      {{/unless}}
-                      {{#if view.isUpgradeFailed}}
+                    {{/if}}
+                    {{#if view.isInstallFailed}}
                         <li {{bindAttr class="view.noActionAvailable"}}>
-                          <a href="javascript:void(null)" data-toggle="modal" {{action "upgradeComponent" view.content target="controller"}}>
-                            {{t common.reUpgrade}}
-                          </a>
+                            <a href="javascript:void(null)"
+                               data-toggle="modal" {{action "installComponent" view.content target="controller"}}>
+                              {{t common.reinstall}}
+                            </a>
                         </li>
-                      {{/if}}
-                      {{#if view.isInstallFailed}}
+                    {{/if}}
+                    {{#if view.isReassignable}}
                         <li {{bindAttr class="view.noActionAvailable"}}>
-                          <a href="javascript:void(null)" data-toggle="modal" {{action "installComponent" view.content target="controller"}}>
-                            {{t common.reinstall}}
-                          </a>
+                            <a href="javascript:void(null)"
+                               data-toggle="modal" {{action "moveComponent" view.content target="controller"}}>
+                              {{t common.move}}
+                            </a>
                         </li>
-                      {{/if}}
-                      {{#if view.isReassignable}}
+                    {{/if}}
+                     {{#if view.isPassive}}
                         <li {{bindAttr class="view.noActionAvailable"}}>
-                          <a href="javascript:void(null)" data-toggle="modal" {{action "moveComponent" view.content target="controller"}}>
-                            {{t common.move}}
-                          </a>
+                            <a href="javascript:void(null)"
+                               data-toggle="modal" {{action "turnOnOffPassiveConfirmation" view.content target="controller"}}>
+                              {{t passiveState.turnOff}}
+                            </a>
                         </li>
-                      {{/if}}
-                      {{#if view.isStop}}
-                          <li {{bindAttr class="view.noActionAvailable"}}>
-                              <a href="javascript:void(null)" data-toggle="modal" {{action "turnOnOffMaintenanceConfirmation" view.content target="controller"}}>
-                                {{t maintenance.turnOn}}
-                              </a>
-                          </li>
-                      {{/if}}
-                    {{/unless}}
-                    {{#if view.isInMaintenance}}
+                      {{else}}
                         <li {{bindAttr class="view.noActionAvailable"}}>
-                            <a href="javascript:void(null)" data-toggle="modal" {{action "turnOnOffMaintenanceConfirmation" view.content target="controller"}}>
-                              {{t maintenance.turnOff}}
+                            <a href="javascript:void(null)"
+                               data-toggle="modal" {{action "turnOnOffPassiveConfirmation" view.content target="controller"}}>
+                              {{t passiveState.turnOn}}
                             </a>
                         </li>
                     {{/if}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index 5e59549..2edb3a3 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/ambari-web/app/utils/ajax.js
@@ -207,11 +207,11 @@ var urls = {
     }
   },
 
-  'host_component.maintenance_mode': {
+  'host_component.passive': {
     'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
     'mock': '',
     'type': 'PUT',
-    'format': function() {
+    'format': function(data) {
       return {
         data: JSON.stringify({
           RequestInfo: {
@@ -219,7 +219,7 @@ var urls = {
           },
           Body: {
             HostRoles: {
-              state: data.state
+              passive_state: data.passive_state
             }
           }
         })

http://git-wip-us.apache.org/repos/asf/ambari/blob/7bc91032/ambari-web/app/views/main/host/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/summary.js b/ambari-web/app/views/main/host/summary.js
index 395222b..67d5f1c 100644
--- a/ambari-web/app/views/main/host/summary.js
+++ b/ambari-web/app/views/main/host/summary.js
@@ -317,13 +317,13 @@ App.MainHostSummaryView = Em.View.extend({
       }
 
       //Class when maintenance
-      if (this.get('workStatus') === App.HostComponentStatus.maintenance) {
+      if (this.get('content.passiveState') === "PASSIVE") {
         return 'icon-medkit';
       }
 
       //For all other cases
       return 'health-status-' + App.HostComponentStatus.getKeyName(this.get('workStatus'));
-    }.property('workStatus', 'isDataNodeRecommissionAvailable', 'isNodeManagerRecommissionAvailable', 'isTaskTrackerRecommissionAvailable'),
+    }.property('content.passiveState','workStatus', 'isDataNodeRecommissionAvailable', 'isNodeManagerRecommissionAvailable', 'isTaskTrackerRecommissionAvailable'),
 
     disabled: function () {
       return (this.get('parentView.content.healthClass') === "health-status-DEAD-YELLOW") ? 'disabled' : '';
@@ -412,9 +412,9 @@ App.MainHostSummaryView = Em.View.extend({
       return this.get('content.componentName') === 'HBASE_REGIONSERVER';
     }.property('content'),
 
-    isInMaintenance: function () {
-      return (this.get('workStatus') == App.HostComponentStatus.maintenance);
-    }.property("workStatus"),
+    isPassive: function () {
+      return (this.get('content.passiveState') == "PASSIVE");
+    }.property('content.passiveState'),
 
 
     isDecommissioning: function () {