Sfoglia il codice sorgente

AMBARI-1059. Refactor cluster management. (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1418940 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 anni fa
parent
commit
aa675fde9e

+ 3 - 1
ambari-web/app/controllers/installer.js

@@ -440,6 +440,7 @@ App.InstallerController = Em.Controller.extend({
     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);
@@ -487,7 +488,7 @@ App.InstallerController = Em.Controller.extend({
    * 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);
   },
@@ -836,6 +837,7 @@ App.InstallerController = Em.Controller.extend({
   finish: function(){
     this.setCurrentStep('1', false);
     App.db.setService(undefined); //not to use this data at AddService page
+    App.db.setHosts(undefined);
   }
 
 });

+ 85 - 28
ambari-web/app/controllers/main/service/add_controller.js

@@ -43,6 +43,7 @@ App.AddServiceController = Em.Controller.extend({
     hostSlaveComponents: null,
     masterComponentHosts: null,
     serviceConfigProperties: null,
+    advancedServiceConfig: null,
     controllerName: 'addServiceController'
   }),
 
@@ -203,19 +204,23 @@ App.AddServiceController = Em.Controller.extend({
    * Will be used at <code>Assign Masters(step5)</code> step
    */
   loadConfirmedHosts: function(){
-    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.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
+        };
+      });
+    }
 
     this.set('content.hostsInfo', hosts);
+    console.log('AddServiceController.loadConfirmedHosts: loaded hosts', hosts);
   },
 
   /**
@@ -268,6 +273,7 @@ App.AddServiceController = Em.Controller.extend({
       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;
       });
     }
 
@@ -276,7 +282,7 @@ App.AddServiceController = Em.Controller.extend({
     });
     this.set('content.services', servicesInfo);
     console.log('AddServiceController.loadServices: loaded data ', servicesInfo);
-    console.log('selected services ', servicesInfo.filterProperty('isSelected', true).mapProperty('serviceName'));
+    console.log('selected services ', servicesInfo.filterProperty('isSelected', true).filterProperty('isDisabled', false).mapProperty('serviceName'));
   },
 
   /**
@@ -285,15 +291,14 @@ App.AddServiceController = Em.Controller.extend({
    */
   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'));
-    stepController.filterProperty('isSelected', true).filterProperty('isDisabled', false).forEach(function (item) {
+    console.log('AddServiceController.saveServices: saved data', stepController.get('content'));
+    stepController.filterProperty('isSelected', true).filterProperty('isInstalled', false).forEach(function (item) {
       serviceNames.push(item.serviceName);
     });
     this.set('content.selectedServiceNames', serviceNames);
     App.db.setSelectedServiceNames(serviceNames);
-    console.log('AddServiceController.saveServices: saved data ', serviceNames);
+    console.log('AddServiceController.selectedServiceNames:', serviceNames);
   },
 
   /**
@@ -306,14 +311,12 @@ App.AddServiceController = Em.Controller.extend({
     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: false
+          isInstalled: installedComponents.someProperty('componentName', _component.component_name)
         });
-      }
     });
 
     console.log("AddServiceController.saveMasterComponentHosts: saved hosts ", masterComponentHosts);
@@ -325,15 +328,18 @@ App.AddServiceController = Em.Controller.extend({
    * Load master component hosts data for using in required step controllers
    */
   loadMasterComponentHosts: function () {
-    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
-      })
-    });
+    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
+        })
+      });
+
+    }
     this.set("content.masterComponentHosts", masterComponentHosts);
     console.log("AddServiceController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
   },
@@ -349,6 +355,7 @@ App.AddServiceController = Em.Controller.extend({
     var isHbSelected = stepController.get('isHbSelected');
 
     App.db.setHostSlaveComponents(hosts);
+    console.log('addServiceController.hostSlaveComponents: saved hosts', hosts);
     this.set('content.hostSlaveComponents', hosts);
 
     var dataNodeHosts = [];
@@ -417,6 +424,7 @@ App.AddServiceController = Em.Controller.extend({
     });
 
     App.db.setSlaveComponentHosts(slaveComponentHosts);
+    console.log('addServiceController.slaveComponentHosts: saved hosts', slaveComponentHosts);
     this.set('content.slaveComponentHosts', slaveComponentHosts);
   },
 
@@ -518,6 +526,55 @@ App.AddServiceController = Em.Controller.extend({
     }
   },
 
+  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

+ 24 - 29
ambari-web/app/controllers/wizard/step5_controller.js

@@ -74,46 +74,35 @@ App.WizardStep5Controller = Em.Controller.extend({
   loadComponents: function () {
 
     var services = this.get('content.services')
-      .filterProperty('isSelected', true).mapProperty('serviceName');
+      .filterProperty('isSelected', true).mapProperty('serviceName'); //list of shown services
 
     services.forEach(function (item) {
       this.get("selectedServices").pushObject(Ember.Object.create({service_name: item}));
     }, this);
 
-    var masterHosts = this.get('content.masterComponentHosts');
-
-    var components = new Ember.Set();
-    if (!masterHosts) {
-
-      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);
-      }
+    var masterHosts = this.get('content.masterComponentHosts'); //saved to local storadge info
 
-    } else {
+    var resultComponents = new Ember.Set();
+
+    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]);
+
+      componentInfo.forEach(function (_componentInfo) {
 
-      masterHosts.forEach(function (_masterComponentHost) {
+        var savedComponent = masterHosts.findProperty('component', _componentInfo.component_name);
         var componentObj = {};
-        componentObj.component_name = _masterComponentHost.component;
-        componentObj.display_name = _masterComponentHost.display_name;
-        componentObj.selectedHost = _masterComponentHost.hostName;
-        componentObj.isInstalled = _masterComponentHost.isInstalled;
+        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.availableHosts = [];
-        components.add(componentObj);
+        resultComponents.add(componentObj);
       }, this);
-
     }
-    return components;
+
+    return resultComponents;
   },
 
   /**
@@ -150,6 +139,12 @@ App.WizardStep5Controller = Em.Controller.extend({
         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) {

+ 0 - 4
ambari-web/app/controllers/wizard/step8_controller.js

@@ -29,10 +29,6 @@ App.WizardStep8Controller = Em.Controller.extend({
   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(),
 

+ 1 - 1
ambari-web/app/models/component.js

@@ -37,7 +37,7 @@ App.Component = DS.Model.extend({
   isMaster: function () {
     switch (this.get('componentName')) {
       case 'NAMENODE':
-      case 'SNAMENODE':
+      case 'SECONDARY_NAMENODE':
       case 'JOBTRACKER':
       case 'ZOOKEEPER_SERVER':
       case 'HIVE_SERVER':

+ 9 - 1
ambari-web/app/routes/add_service_routes.js

@@ -85,7 +85,14 @@ module.exports = Em.Route.extend({
       controller.loadAllPriorSteps();
       controller.connectOutlet('wizardStep6', controller.get('content'));
     },
-    back: Em.Router.transitionTo('step2'),
+    back: function(router){
+      var controller = router.get('addServiceController');
+      if(controller.get('content.masterComponentHosts').someProperty('isInstalled', false)){
+        router.transitionTo('step2');
+      } else {
+        router.transitionTo('step1');
+      }
+    },
     next: function (router) {
       var addServiceController = router.get('addServiceController');
       var wizardStep6Controller = router.get('wizardStep6Controller');
@@ -94,6 +101,7 @@ module.exports = Em.Route.extend({
         addServiceController.saveSlaveComponentHosts(wizardStep6Controller);
         addServiceController.get('content').set('serviceConfigProperties', null);
         App.db.setServiceConfigProperties(null);
+        addServiceController.loadAdvancedConfigs();
         router.transitionTo('step4');
       }
     }

+ 1 - 1
ambari-web/app/templates/wizard/step6.hbs

@@ -85,7 +85,7 @@
   </table>
   </div>
   <div class="btn-area">
-    <a class="btn" {{action back href="true"}}>&larr; Back</a>
+    <a class="btn" {{action back}}>&larr; Back</a>
     <a class="btn btn-success pull-right" {{action next}}>Next &rarr;</a>
   </div>
 </div>

+ 1 - 1
ambari-web/app/views/wizard/step6_view.js

@@ -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'