Browse Source

AMBARI-846. Select Masters Page: make ZooKeeper addition/removal UI more organized. (Jaimin Jetly via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1396847 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 years ago
parent
commit
18819c9086

+ 3 - 0
AMBARI-666-CHANGES.txt

@@ -241,6 +241,9 @@ AMBARI-666 branch (unreleased changes)
 
 
   BUG FIXES
   BUG FIXES
 
 
+  AMBARI-846. Select Masters Page: make ZooKeeper addition/removal UI more
+  organized. (Jaimin Jetly via yusaku)
+
   AMBARI-840. Hitting browser refresh should not clear present step data that 
   AMBARI-840. Hitting browser refresh should not clear present step data that 
   had already been persisted to local DB. (Jaimin Jetly via yusaku)
   had already been persisted to local DB. (Jaimin Jetly via yusaku)
 
 

+ 47 - 32
ambari-web/app/controllers/installer/step5_controller.js

@@ -53,7 +53,7 @@ App.InstallerStep5Controller = Em.Controller.extend({
       hosts.add(hostInfo[index]);
       hosts.add(hostInfo[index]);
       console.log("TRACE: host name is: " + hostInfo[index].name);
       console.log("TRACE: host name is: " + hostInfo[index].name);
     }
     }
-    return hosts.filterProperty('bootStatus','success');
+    return hosts.filterProperty('bootStatus', 'success');
   },
   },
 
 
 
 
@@ -77,7 +77,7 @@ App.InstallerStep5Controller = Em.Controller.extend({
 
 
   loadServices: function () {
   loadServices: function () {
     var serviceInfo = App.db.getService();
     var serviceInfo = App.db.getService();
-    var services = serviceInfo.filterProperty('isSelected',true).mapProperty('serviceName');
+    var services = serviceInfo.filterProperty('isSelected', true).mapProperty('serviceName');
     services.forEach(function (item) {
     services.forEach(function (item) {
       console.log("TRACE: service name is: " + item);
       console.log("TRACE: service name is: " + item);
       this.get("selectedServices").pushObject(Ember.Object.create({service_name: item}));
       this.get("selectedServices").pushObject(Ember.Object.create({service_name: item}));
@@ -88,22 +88,30 @@ App.InstallerStep5Controller = Em.Controller.extend({
   },
   },
 
 
   loadComponents: function (services) {
   loadComponents: function (services) {
-    var self = this;
     var components = new Ember.Set();
     var components = new Ember.Set();
-
-    var masterComponents = self.components.filterProperty('isMaster', true);
-    for (var index in services) {
-      var componentInfo = masterComponents.filterProperty('service_name', services[index]);
-      componentInfo.forEach(function (_componentInfo) {
-        console.log("TRACE: master component name is: " + _componentInfo.display_name);
+    if (App.db.getMasterComponentHosts() === undefined) {
+      var masterComponents = this.components.filterProperty('isMaster', true);
+      for (var index in services) {
+        var componentInfo = masterComponents.filterProperty('service_name', services[index]);
+        componentInfo.forEach(function (_componentInfo) {
+          console.log("TRACE: master component name is: " + _componentInfo.display_name);
+          var componentObj = {};
+          componentObj.component_name = _componentInfo.display_name;
+          componentObj.selectedHost = this.selectHost(_componentInfo.component_name);   // call the method that plays selectNode algorithm or fetches from server
+          componentObj.availableHosts = [];
+          components.add(componentObj);
+        }, this);
+      }
+    } else {
+      var masterComponentHosts = App.db.getMasterComponentHosts();
+      masterComponentHosts.forEach(function (_masterComponentHost) {
         var componentObj = {};
         var componentObj = {};
-        componentObj.component_name = _componentInfo.display_name;
-        componentObj.selectedHost = this.selectHost(_componentInfo.component_name);   // call the method that plays selectNode algorithm or fetches from server
+        componentObj.component_name =_masterComponentHost.component;
+        componentObj.selectedHost = _masterComponentHost.hostName;   // call the method that plays selectNode algorithm or fetches from server
         componentObj.availableHosts = [];
         componentObj.availableHosts = [];
         components.add(componentObj);
         components.add(componentObj);
       }, this);
       }, this);
     }
     }
-
     return components;
     return components;
   },
   },
 
 
@@ -128,16 +136,10 @@ App.InstallerStep5Controller = Em.Controller.extend({
             this.get('selectedServicesMasters').pushObject(_service);
             this.get('selectedServicesMasters').pushObject(_service);
           }, this);
           }, this);
         }
         }
-        this.set('zId', this.get('zId') + 1);
+        this.set('zId', parseInt(this.get('zId')) + 1);
         zookeeperComponent = Ember.Object.create(item);
         zookeeperComponent = Ember.Object.create(item);
         zookeeperComponent.set('zId', this.get('zId'));
         zookeeperComponent.set('zId', this.get('zId'));
-        zookeeperComponent.set("showAddControl", true);
-        if (zookeeperComponent.get('zId') === 1) {
-          zookeeperComponent.set("showRemoveControl", false);
-        } else {
-          zookeeperComponent.set("showRemoveControl", true);
-        }
-
+        zookeeperComponent.set("showRemoveControl", true);
         zookeeperComponent.set("availableHosts", this.get("hosts").slice(0));
         zookeeperComponent.set("availableHosts", this.get("hosts").slice(0));
         this.get("selectedServicesMasters").pushObject(Ember.Object.create(zookeeperComponent));
         this.get("selectedServicesMasters").pushObject(Ember.Object.create(zookeeperComponent));
 
 
@@ -147,7 +149,6 @@ App.InstallerStep5Controller = Em.Controller.extend({
         this.get("selectedServicesMasters").pushObject(componentObj);
         this.get("selectedServicesMasters").pushObject(componentObj);
       }
       }
     }, this);
     }, this);
-
   },
   },
 
 
   getKerberosServer: function (noOfHosts) {
   getKerberosServer: function (noOfHosts) {
@@ -403,18 +404,26 @@ App.InstallerStep5Controller = Em.Controller.extend({
       return this.get("hosts");
       return this.get("hosts");
     }
     }
   },
   },
+  /*
 
 
-  assignHostToMaster: function (masterService, selectedHost, zId) {
-    if (selectedHost && masterService) {
-      if ((masterService === "ZooKeeper") && zId) {
-        this.get('selectedServicesMasters').findProperty("zId", zId).set("selectedHost", selectedHost);
-        this.rebalanceZookeeperHosts();
-      }
-      else {
-        this.get('selectedServicesMasters').findProperty("component_name", masterService).set("selectedHost", selectedHost);
-      }
+   assignHostToMaster: function (masterService, selectedHost, zId) {
+   if (selectedHost && masterService) {
+   if ((masterService === "ZooKeeper") && zId) {
+   this.get('selectedServicesMasters').findProperty("zId", zId).set("selectedHost", selectedHost);
+   this.rebalanceZookeeperHosts();
+   }
+   else {
+   this.get('selectedServicesMasters').findProperty("component_name", masterService).set("selectedHost", selectedHost);
+   }
+
+   }
+   },
+   */
 
 
-    }
+  lastZooKeeper: function () {
+    var currentZooKeepers = this.get("selectedServicesMasters").filterProperty("component_name", "ZooKeeper");
+    var lastZooKeeper = currentZooKeepers.get("lastObject");
+    return lastZooKeeper;
   },
   },
 
 
   addZookeepers: function () {
   addZookeepers: function () {
@@ -441,7 +450,7 @@ App.InstallerStep5Controller = Em.Controller.extend({
     if (currentZooKeepers.get("length") < maxNumZooKeepers) {
     if (currentZooKeepers.get("length") < maxNumZooKeepers) {
       console.log('currentZookeeper length less than maximum. Its: ' + currentZooKeepers.get("length"))
       console.log('currentZookeeper length less than maximum. Its: ' + currentZooKeepers.get("length"))
       currentZooKeepers.set("lastObject.showAddControl", false);
       currentZooKeepers.set("lastObject.showAddControl", false);
-      if (currentZooKeepers.get("length") > 1) {
+      if (currentZooKeepers.get("length") >= 1) {
         currentZooKeepers.set("lastObject.showRemoveControl", true);
         currentZooKeepers.set("lastObject.showRemoveControl", true);
       }
       }
 
 
@@ -471,6 +480,7 @@ App.InstallerStep5Controller = Em.Controller.extend({
 
 
       newZookeeper.set("selectedHost", suggestedHost);
       newZookeeper.set("selectedHost", suggestedHost);
       newZookeeper.set("zId", (currentZooKeepers.get("lastObject.zId") + 1));
       newZookeeper.set("zId", (currentZooKeepers.get("lastObject.zId") + 1));
+      this.set('zId', parseInt(this.get('zId')) + 1);
 
 
       this.get("selectedServicesMasters").pushObject(newZookeeper);
       this.get("selectedServicesMasters").pushObject(newZookeeper);
 
 
@@ -498,6 +508,11 @@ App.InstallerStep5Controller = Em.Controller.extend({
       if (currentZooKeepers.get("length") < this.get("hosts.length")) {
       if (currentZooKeepers.get("length") < this.get("hosts.length")) {
         currentZooKeepers.set("lastObject.showAddControl", true);
         currentZooKeepers.set("lastObject.showAddControl", true);
       }
       }
+
+      if (currentZooKeepers.get("length") === 1) {
+        currentZooKeepers.set("lastObject.showRemoveControl", false);
+      }
+      this.set('zId', parseInt(this.get('zId')) - 1);
       this.rebalanceZookeeperHosts();
       this.rebalanceZookeeperHosts();
 
 
       return true;
       return true;

+ 1 - 0
ambari-web/app/routes/installer.js

@@ -116,6 +116,7 @@ module.exports = Em.Route.extend({
     },
     },
     back: Em.Router.transitionTo('step3'),
     back: Em.Router.transitionTo('step3'),
     next: function (router, context) {
     next: function (router, context) {
+      App.db.setMasterComponentHosts(undefined);
       router.transitionTo('step5');
       router.transitionTo('step5');
     }
     }
   }),
   }),

+ 1 - 0
ambari-web/app/views/installer/step5_view.js

@@ -26,6 +26,7 @@ App.InstallerStep5View = Em.View.extend({
   didInsertElement: function () {
   didInsertElement: function () {
     var controller = this.get('controller');
     var controller = this.get('controller');
     controller.loadStep();
     controller.loadStep();
+    controller.lastZooKeeper().set('showAddControl',true);
   }
   }
 
 
 });
 });