You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2012/12/09 14:37:36 UTC

svn commit: r1418947 - in /incubator/ambari/branches/AMBARI-666/ambari-web/app: controllers/ controllers/main/service/ controllers/wizard/ models/ routes/ templates/wizard/ views/wizard/

Author: yusaku
Date: Sun Dec  9 13:37:36 2012
New Revision: 1418947

URL: http://svn.apache.org/viewvc?rev=1418947&view=rev
Log:
AMBARI-1059. Refactor cluster management. (yusaku)

Modified:
    incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/installer.js
    incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/service/add_controller.js
    incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step5_controller.js
    incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js
    incubator/ambari/branches/AMBARI-666/ambari-web/app/models/component.js
    incubator/ambari/branches/AMBARI-666/ambari-web/app/routes/add_service_routes.js
    incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/wizard/step6.hbs
    incubator/ambari/branches/AMBARI-666/ambari-web/app/views/wizard/step6_view.js

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/installer.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/installer.js?rev=1418947&r1=1418946&r2=1418947&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/installer.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/installer.js Sun Dec  9 13:37:36 2012
@@ -440,7 +440,6 @@ App.InstallerController = Em.Controller.
     var servicesInfo = App.db.getService();
     servicesInfo.forEach(function (item, index) {
       servicesInfo[index] = Em.Object.create(item);
-      servicesInfo[index].isInstalled = false;
     });
     this.set('content.services', servicesInfo);
     console.log('installerController.loadServices: loaded data ', servicesInfo);
@@ -488,7 +487,7 @@ App.InstallerController = Em.Controller.
    * Load master component hosts data for using in required step controllers
    */
   loadMasterComponentHosts: function () {
-    var masterComponentHosts = App.db.getMasterComponentHosts() || [];
+    var masterComponentHosts = App.db.getMasterComponentHosts();
     this.set("content.masterComponentHosts", masterComponentHosts);
     console.log("InstallerController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
   },
@@ -837,7 +836,6 @@ App.InstallerController = Em.Controller.
   finish: function(){
     this.setCurrentStep('1', false);
     App.db.setService(undefined); //not to use this data at AddService page
-    App.db.setHosts(undefined);
   }
 
 });

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/service/add_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/service/add_controller.js?rev=1418947&r1=1418946&r2=1418947&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/service/add_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/main/service/add_controller.js Sun Dec  9 13:37:36 2012
@@ -43,7 +43,6 @@ App.AddServiceController = Em.Controller
     hostSlaveComponents: null,
     masterComponentHosts: null,
     serviceConfigProperties: null,
-    advancedServiceConfig: null,
     controllerName: 'addServiceController'
   }),
 
@@ -204,23 +203,19 @@ App.AddServiceController = Em.Controller
    * Will be used at <code>Assign Masters(step5)</code> step
    */
   loadConfirmedHosts: function(){
-    var hosts = App.db.getHosts();
-    if(!hosts){
-      var hosts = {};
-
-      App.Host.find().forEach(function(item){
-        hosts[item.get('id')] = {
-          name: item.get('id'),
-          cpu: item.get('cpu'),
-          memory: item.get('memory'),
-          bootStatus: "success",
-          isInstalled: true
-        };
-      });
-    }
+    var hosts = {};
+
+    App.Host.find().forEach(function(item){
+      hosts[item.get('id')] = {
+        name: item.get('id'),
+        cpu: item.get('cpu'),
+        memory: item.get('memory'),
+        bootStatus: "success",
+        isInstalled: true
+      };
+    });
 
     this.set('content.hostsInfo', hosts);
-    console.log('AddServiceController.loadConfirmedHosts: loaded hosts', hosts);
   },
 
   /**
@@ -273,7 +268,6 @@ App.AddServiceController = Em.Controller
       servicesInfo.forEach(function(item, index){
         servicesInfo[index].isSelected = App.Service.find().someProperty('id', item.serviceName);
         servicesInfo[index].isDisabled = servicesInfo[index].isSelected;
-        servicesInfo[index].isInstalled = servicesInfo[index].isSelected;
       });
     }
 
@@ -282,7 +276,7 @@ App.AddServiceController = Em.Controller
     });
     this.set('content.services', servicesInfo);
     console.log('AddServiceController.loadServices: loaded data ', servicesInfo);
-    console.log('selected services ', servicesInfo.filterProperty('isSelected', true).filterProperty('isDisabled', false).mapProperty('serviceName'));
+    console.log('selected services ', servicesInfo.filterProperty('isSelected', true).mapProperty('serviceName'));
   },
 
   /**
@@ -291,14 +285,15 @@ App.AddServiceController = Em.Controller
    */
   saveServices: function (stepController) {
     var serviceNames = [];
+    // we can also do it without stepController since all data,
+    // changed at page, automatically changes in model(this.content.services)
     App.db.setService(stepController.get('content'));
-    console.log('AddServiceController.saveServices: saved data', stepController.get('content'));
-    stepController.filterProperty('isSelected', true).filterProperty('isInstalled', false).forEach(function (item) {
+    stepController.filterProperty('isSelected', true).filterProperty('isDisabled', false).forEach(function (item) {
       serviceNames.push(item.serviceName);
     });
     this.set('content.selectedServiceNames', serviceNames);
     App.db.setSelectedServiceNames(serviceNames);
-    console.log('AddServiceController.selectedServiceNames:', serviceNames);
+    console.log('AddServiceController.saveServices: saved data ', serviceNames);
   },
 
   /**
@@ -311,12 +306,14 @@ App.AddServiceController = Em.Controller
     var installedComponents = App.Component.find();
 
     obj.forEach(function (_component) {
+      if(!installedComponents.someProperty('componentName', _component.component_name)){
         masterComponentHosts.push({
           display_name: _component.display_name,
           component: _component.component_name,
           hostName: _component.selectedHost,
-          isInstalled: installedComponents.someProperty('componentName', _component.component_name)
+          isInstalled: false
         });
+      }
     });
 
     console.log("AddServiceController.saveMasterComponentHosts: saved hosts ", masterComponentHosts);
@@ -328,18 +325,15 @@ App.AddServiceController = Em.Controller
    * Load master component hosts data for using in required step controllers
    */
   loadMasterComponentHosts: function () {
-    var masterComponentHosts = App.db.getMasterComponentHosts();
-    if(!masterComponentHosts){
-      masterComponentHosts = [];
-      App.Component.find().filterProperty('isMaster', true).forEach(function(item){
-        masterComponentHosts.push({
-          component: item.get('componentName'),
-          hostName: item.get('host.hostName'),
-          isInstalled: true
-        })
-      });
-
-    }
+    var masterComponentHosts = App.db.getMasterComponentHosts() || [];
+    App.Component.find().filterProperty('isMaster', true).forEach(function(item){
+      masterComponentHosts.push({
+        component: item.get('componentName'),
+        display_name: item.get('displayName'),
+        hostName: item.get('host.hostName'),
+        isInstalled: true
+      })
+    });
     this.set("content.masterComponentHosts", masterComponentHosts);
     console.log("AddServiceController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
   },
@@ -355,7 +349,6 @@ App.AddServiceController = Em.Controller
     var isHbSelected = stepController.get('isHbSelected');
 
     App.db.setHostSlaveComponents(hosts);
-    console.log('addServiceController.hostSlaveComponents: saved hosts', hosts);
     this.set('content.hostSlaveComponents', hosts);
 
     var dataNodeHosts = [];
@@ -424,7 +417,6 @@ App.AddServiceController = Em.Controller
     });
 
     App.db.setSlaveComponentHosts(slaveComponentHosts);
-    console.log('addServiceController.slaveComponentHosts: saved hosts', slaveComponentHosts);
     this.set('content.slaveComponentHosts', slaveComponentHosts);
   },
 
@@ -526,55 +518,6 @@ App.AddServiceController = Em.Controller
     }
   },
 
-  loadAdvancedConfigs: function () {
-    App.db.getSelectedServiceNames().forEach(function (_serviceName) {
-      this.loadAdvancedConfig(_serviceName);
-    }, this);
-  },
-  /**
-   * Generate serviceProperties save it to localdata
-   * called form stepController step6WizardController
-   */
-
-  loadAdvancedConfig: function (serviceName) {
-    var self = this;
-    var url = (App.testMode) ? '/data/wizard/stack/hdp/version01/' + serviceName + '.json' : '/api/stacks/HDP/version/1.2.0/services/' + serviceName; // TODO: get this url from the stack selected by the user in Install Options page
-    var method = 'GET';
-    $.ajax({
-      type: method,
-      url: url,
-      async: false,
-      dataType: 'text',
-      timeout: 5000,
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        console.log("TRACE: Step6 submit -> In success function for the loadAdvancedConfig call");
-        console.log("TRACE: Step6 submit -> value of the url is: " + url);
-        var serviceComponents = jsonData.properties;
-        serviceComponents.setEach('serviceName', serviceName);
-        var configs;
-        if (App.db.getAdvancedServiceConfig()) {
-          configs = App.db.getAdvancedServiceConfig();
-        } else {
-          configs = [];
-        }
-        configs = configs.concat(serviceComponents);
-        self.set('content.advancedServiceConfig', configs);
-        App.db.setAdvancedServiceConfig(configs);
-        console.log('TRACE: servicename: ' + serviceName);
-      },
-
-      error: function (request, ajaxOptions, error) {
-        console.log("TRACE: STep6 submit -> In error function for the loadAdvancedConfig call");
-        console.log("TRACE: STep6 submit-> value of the url is: " + url);
-        console.log("TRACE: STep6 submit-> error code status is: " + request.status);
-        console.log('Step6 submit: Error message is: ' + request.responseText);
-      },
-
-      statusCode: require('data/statusCodes')
-    });
-  },
-
   /**
    * Generate clients list for selected services and save it to model
    * @param stepController step8WizardController or step9WizardController

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step5_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step5_controller.js?rev=1418947&r1=1418946&r2=1418947&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step5_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step5_controller.js Sun Dec  9 13:37:36 2012
@@ -74,35 +74,46 @@ App.WizardStep5Controller = Em.Controlle
   loadComponents: function () {
 
     var services = this.get('content.services')
-      .filterProperty('isSelected', true).mapProperty('serviceName'); //list of shown services
+      .filterProperty('isSelected', true).mapProperty('serviceName');
 
     services.forEach(function (item) {
       this.get("selectedServices").pushObject(Ember.Object.create({service_name: item}));
     }, this);
 
-    var masterHosts = this.get('content.masterComponentHosts'); //saved to local storadge info
+    var masterHosts = this.get('content.masterComponentHosts');
 
-    var resultComponents = new Ember.Set();
+    var components = new Ember.Set();
+    if (!masterHosts) {
 
-    var masterComponents = this.get('components').filterProperty('isMaster', true); //get full list from mock data
-
-    for (var index in services) {
-      var componentInfo = masterComponents.filterProperty('service_name', services[index]);
+      var masterComponents = this.get('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.component_name;
+          componentObj.display_name = _componentInfo.display_name;
+          componentObj.selectedHost = this.selectHost(_componentInfo.component_name);   // call the method that plays selectNode algorithm or fetches from server
+          componentObj.isInstalled = App.Component.find().someProperty('componentName', _componentInfo.component_name);
+          componentObj.availableHosts = [];
+          components.add(componentObj);
+        }, this);
+      }
 
-      componentInfo.forEach(function (_componentInfo) {
+    } else {
 
-        var savedComponent = masterHosts.findProperty('component', _componentInfo.component_name);
+      masterHosts.forEach(function (_masterComponentHost) {
         var componentObj = {};
-        componentObj.component_name = _componentInfo.component_name;
-        componentObj.display_name = _componentInfo.display_name;
-        componentObj.selectedHost = savedComponent ? savedComponent.hostName : this.selectHost(_componentInfo.component_name);   // call the method that plays selectNode algorithm or fetches from server
-        componentObj.isInstalled = savedComponent ? savedComponent.isInstalled : App.Component.find().someProperty('componentName', _componentInfo.component_name);
+        componentObj.component_name = _masterComponentHost.component;
+        componentObj.display_name = _masterComponentHost.display_name;
+        componentObj.selectedHost = _masterComponentHost.hostName;
+        componentObj.isInstalled = _masterComponentHost.isInstalled;
         componentObj.availableHosts = [];
-        resultComponents.add(componentObj);
+        components.add(componentObj);
       }, this);
-    }
 
-    return resultComponents;
+    }
+    return components;
   },
 
   /**
@@ -139,12 +150,6 @@ App.WizardStep5Controller = Em.Controlle
         this.get("selectedServicesMasters").pushObject(componentObj);
       }
     }, this);
-
-    // if no new master nodes
-    if(!masterComponents.filterProperty('isInstalled', false).length){
-      console.log('no master components to add')
-      App.router.send('next');
-    }
   },
 
   getKerberosServer: function (noOfHosts) {

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js?rev=1418947&r1=1418946&r2=1418947&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js Sun Dec  9 13:37:36 2012
@@ -29,6 +29,10 @@ App.WizardStep8Controller = Em.Controlle
   configMapping: require('data/config_mapping'),
 
   selectedServices: function () {
+    var services = App.Service.find();
+    this.get('content.services').forEach(function (item) {
+      item.set('isInstalled', services.someProperty('serviceName', item.get('serviceName')));
+    });
     return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
   }.property('content.services').cacheable(),
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/models/component.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/models/component.js?rev=1418947&r1=1418946&r2=1418947&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/models/component.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/models/component.js Sun Dec  9 13:37:36 2012
@@ -37,7 +37,7 @@ App.Component = DS.Model.extend({
   isMaster: function () {
     switch (this.get('componentName')) {
       case 'NAMENODE':
-      case 'SECONDARY_NAMENODE':
+      case 'SNAMENODE':
       case 'JOBTRACKER':
       case 'ZOOKEEPER_SERVER':
       case 'HIVE_SERVER':

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/routes/add_service_routes.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/routes/add_service_routes.js?rev=1418947&r1=1418946&r2=1418947&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/routes/add_service_routes.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/routes/add_service_routes.js Sun Dec  9 13:37:36 2012
@@ -85,14 +85,7 @@ module.exports = Em.Route.extend({
       controller.loadAllPriorSteps();
       controller.connectOutlet('wizardStep6', controller.get('content'));
     },
-    back: function(router){
-      var controller = router.get('addServiceController');
-      if(controller.get('content.masterComponentHosts').someProperty('isInstalled', false)){
-        router.transitionTo('step2');
-      } else {
-        router.transitionTo('step1');
-      }
-    },
+    back: Em.Router.transitionTo('step2'),
     next: function (router) {
       var addServiceController = router.get('addServiceController');
       var wizardStep6Controller = router.get('wizardStep6Controller');
@@ -101,7 +94,6 @@ module.exports = Em.Route.extend({
         addServiceController.saveSlaveComponentHosts(wizardStep6Controller);
         addServiceController.get('content').set('serviceConfigProperties', null);
         App.db.setServiceConfigProperties(null);
-        addServiceController.loadAdvancedConfigs();
         router.transitionTo('step4');
       }
     }

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/wizard/step6.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/wizard/step6.hbs?rev=1418947&r1=1418946&r2=1418947&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/wizard/step6.hbs (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/wizard/step6.hbs Sun Dec  9 13:37:36 2012
@@ -85,7 +85,7 @@
   </table>
   </div>
   <div class="btn-area">
-    <a class="btn" {{action back}}>&larr; Back</a>
+    <a class="btn" {{action back href="true"}}>&larr; Back</a>
     <a class="btn btn-success pull-right" {{action next}}>Next &rarr;</a>
   </div>
 </div>

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/wizard/step6_view.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/wizard/step6_view.js?rev=1418947&r1=1418946&r2=1418947&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/wizard/step6_view.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/wizard/step6_view.js Sun Dec  9 13:37:36 2012
@@ -61,7 +61,7 @@ App.WizardStep6HostView = Em.View.extend
     if(components){
       components = components.join(" /\n");
       this.$().popover({
-        title: 'master components hosted on ' + this.get('host.hostName'),
+        title: 'master components hosted on ' + this.get('host.hostname'),
         content: components,
         placement: 'right',
         trigger: 'hover'