You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2014/09/05 14:56:16 UTC

git commit: AMBARI-7170. Assign Slaves and Clients page shows issues after page reload. (akovalenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 057580fe2 -> 582c4948b


AMBARI-7170. Assign Slaves and Clients page shows issues after page reload. (akovalenko)


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

Branch: refs/heads/trunk
Commit: 582c4948b680625b5d26e707f65b880cb905be5d
Parents: 057580f
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Fri Sep 5 15:53:56 2014 +0300
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Fri Sep 5 15:54:29 2014 +0300

----------------------------------------------------------------------
 .../app/controllers/wizard/step5_controller.js  |  8 +-
 .../app/controllers/wizard/step6_controller.js  | 50 ++++++++--
 ambari-web/app/mixins/common/blueprint.js       |  6 +-
 ambari-web/app/utils/blueprint.js               |  8 +-
 .../test/controllers/wizard/step6_test.js       | 96 ++++++++++++++++++++
 ambari-web/test/models/dataset_job_test.js      |  2 +-
 ambari-web/test/utils/blueprint_test.js         |  2 +-
 7 files changed, 150 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/582c4948/ambari-web/app/controllers/wizard/step5_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step5_controller.js b/ambari-web/app/controllers/wizard/step5_controller.js
index b7f48b5..fb8ccf7 100644
--- a/ambari-web/app/controllers/wizard/step5_controller.js
+++ b/ambari-web/app/controllers/wizard/step5_controller.js
@@ -356,10 +356,8 @@ App.WizardStep5Controller = Em.Controller.extend(App.BlueprintMixin, {
 
     var mapping = self.get('masterHostMapping');
 
-    var i = 0;
-    mapping.forEach(function(item) {
-      i += 1;
-      var group_name = 'host-group-' + i;
+    mapping.forEach(function(item, i) {
+      var group_name = 'host-group-' + (i+1);
 
       var host_group = {
         name: group_name,
@@ -371,7 +369,7 @@ App.WizardStep5Controller = Em.Controller.extend(App.BlueprintMixin, {
       var binding = {
         name: group_name,
         hosts: [ { fqdn: item.host_name } ]
-      }
+      };
 
       res.blueprint.host_groups.push(host_group);
       res.blueprint_cluster_binding.host_groups.push(binding);

http://git-wip-us.apache.org/repos/asf/ambari/blob/582c4948/ambari-web/app/controllers/wizard/step6_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step6_controller.js b/ambari-web/app/controllers/wizard/step6_controller.js
index 7c7423c..9fe3659 100644
--- a/ambari-web/app/controllers/wizard/step6_controller.js
+++ b/ambari-web/app/controllers/wizard/step6_controller.js
@@ -556,7 +556,7 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
     var invisibleSlaves = App.StackServiceComponent.find().filterProperty("isSlave").filterProperty("isShownOnInstallerSlaveClientPage", false).mapProperty("componentName");
 
     if (this.get('isInstallerWizard') || this.get('isAddServiceWizard')) {
-      masterBlueprint = App.router.get('wizardStep5Controller').getCurrentBlueprint();
+      masterBlueprint = self.getCurrentMastersBlueprint();
 
       var invisibleMasters = [];
       if (this.get('isInstallerWizard')) {
@@ -707,10 +707,8 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
     var clientComponents = self.get('content.clients').mapProperty('component_name');
     var mapping = self.get('hosts');
 
-    var i = 0;
-    mapping.forEach(function (item) {
-      i += 1;
-      var group_name = 'host-group-' + i;
+    mapping.forEach(function (item, i) {
+      var group_name = 'host-group-' + (i+1);
 
       var host_group = {
         name: group_name,
@@ -732,7 +730,7 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
         hosts: [
           { fqdn: item.hostName }
         ]
-      }
+      };
 
       res.blueprint.host_groups.push(host_group);
       res.blueprint_cluster_binding.host_groups.push(binding);
@@ -742,6 +740,46 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
   },
 
   /**
+   * Create blueprint from assigned master components to appropriate hosts
+   * @returns {Object}
+   * @method getCurrentMastersBlueprint
+   */
+  getCurrentMastersBlueprint: function () {
+    var res = {
+      blueprint: { host_groups: [] },
+      blueprint_cluster_binding: { host_groups: [] }
+    };
+
+    var masters = this.get('content.masterComponentHosts');
+    var hosts = this.get('content.hosts');
+
+    Em.keys(hosts).forEach(function (host, i) {
+      var group_name = 'host-group-' + (i + 1);
+      var components = [];
+      masters.forEach(function (master) {
+        if (master.hostName === host) {
+          components.push({
+            name: master.component
+          });
+        }
+      });
+      res.blueprint.host_groups.push({
+        name: group_name,
+        components: components
+      });
+      res.blueprint_cluster_binding.host_groups.push({
+        name: group_name,
+        hosts: [
+          {
+            fqdn: host
+          }
+        ]
+      });
+    }, this);
+    return blueprintUtils.mergeBlueprints(res, this.getCurrentSlaveBlueprint());
+  },
+
+  /**
    * callClientSideValidation form. Return do we have errors or not
    * @return {bool}
    * @method callClientSideValidation

http://git-wip-us.apache.org/repos/asf/ambari/blob/582c4948/ambari-web/app/mixins/common/blueprint.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/blueprint.js b/ambari-web/app/mixins/common/blueprint.js
index 993f58b..938fca9 100644
--- a/ambari-web/app/mixins/common/blueprint.js
+++ b/ambari-web/app/mixins/common/blueprint.js
@@ -32,10 +32,8 @@ App.BlueprintMixin = Em.Mixin.create({
       blueprint_cluster_binding: { host_groups: [] }
     };
 
-    var i = 0;
-    hosts.forEach(function (host) {
-      i += 1;
-      var group_name = 'host-group-' + i;
+    hosts.forEach(function (host, i) {
+      var group_name = 'host-group-' + (i+1);
 
       res.blueprint.host_groups.push({
         name: group_name,

http://git-wip-us.apache.org/repos/asf/ambari/blob/582c4948/ambari-web/app/utils/blueprint.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/blueprint.js b/ambari-web/app/utils/blueprint.js
index d6cccb6..442e7ea 100644
--- a/ambari-web/app/utils/blueprint.js
+++ b/ambari-web/app/utils/blueprint.js
@@ -37,10 +37,8 @@ module.exports = {
       blueprint_cluster_binding: { host_groups: [] }
     };
 
-    var i = 0;
-    matches.forEach(function(match){
-      i += 1;
-      var group_name = 'host-group-' + i;
+    matches.forEach(function(match, i){
+      var group_name = 'host-group-' + (i+1);
 
       var masterComponents = self.getComponentsFromBlueprintByGroupName(masterBlueprint, match.g1);
       var slaveComponents = self.getComponentsFromBlueprintByGroupName(slaveBlueprint, match.g2);
@@ -155,7 +153,7 @@ module.exports = {
       return null;
     }
 
-    var res = JSON.parse(JSON.stringify(blueprint))
+    var res = JSON.parse(JSON.stringify(blueprint));
     var emptyGroups = [];
 
     for (var i = 0; i < res.blueprint.host_groups.length; i++) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/582c4948/ambari-web/test/controllers/wizard/step6_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step6_test.js b/ambari-web/test/controllers/wizard/step6_test.js
index 67fd91c..e1fadaa 100644
--- a/ambari-web/test/controllers/wizard/step6_test.js
+++ b/ambari-web/test/controllers/wizard/step6_test.js
@@ -511,4 +511,100 @@ describe('App.WizardStep6Controller', function () {
     });
   });
 
+  describe('#getCurrentMastersBlueprint', function () {
+    var tests = Em.A([
+      {
+        masterComponentHosts: Em.A([
+          {hostName: 'h1', component: 'c1'}
+        ]),
+        hosts: {'h1': {}},
+        m: 'one host and one component',
+        e:{
+          blueprint: {
+            host_groups: [
+              {
+                name: 'host-group-1',
+                components: [
+                  { name: 'c1' }
+                ]
+              }
+            ]
+          },
+          blueprint_cluster_binding: {
+            host_groups: [
+              {
+                name: 'host-group-1',
+                hosts: [
+                  { fqdn: 'h1' }
+                ]
+              }
+            ]
+          }
+        }
+      },
+      {
+        masterComponentHosts: Em.A([
+          {hostName: 'h1', component: 'c1'},
+          {hostName: 'h2', component: 'c2'},
+          {hostName: 'h2', component: 'c3'}
+        ]),
+        hosts: {'h1': {}, 'h2': {}, 'h3': {}},
+        m: 'multiple hosts and multiple components',
+        e: {
+          blueprint: {
+            host_groups: [
+              {
+                name: 'host-group-1',
+                components: [
+                  { name: 'c1' }
+                ]
+              },
+              {
+                name: 'host-group-2',
+                components: [
+                  { name: 'c2' },
+                  { name: 'c3' }
+                ]
+              },
+              {
+                name: 'host-group-3',
+                components: []
+              }
+            ]
+          },
+          blueprint_cluster_binding: {
+            host_groups: [
+              {
+                name: 'host-group-1',
+                hosts: [
+                  { fqdn: 'h1' }
+                ]
+              },
+              {
+                name: 'host-group-2',
+                hosts: [
+                  { fqdn: 'h2' }
+                ]
+              },
+              {
+                name: 'host-group-3',
+                hosts: [
+                  { fqdn: 'h3' }
+                ]
+              }
+            ]
+          }
+        }
+      }
+    ]);
+    tests.forEach(function (test) {
+      it(test.m, function () {
+        controller.set('content.masterComponentHosts', test.masterComponentHosts);
+        controller.set('content.hosts', test.hosts);
+        var r = controller.getCurrentMastersBlueprint();
+        expect(r).to.eql(test.e);
+      });
+    });
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/582c4948/ambari-web/test/models/dataset_job_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/dataset_job_test.js b/ambari-web/test/models/dataset_job_test.js
index d7e64fa..d1abc8d 100644
--- a/ambari-web/test/models/dataset_job_test.js
+++ b/ambari-web/test/models/dataset_job_test.js
@@ -42,7 +42,7 @@ var dataSetJob,
       time: function () {
         return App.dateTime();
       },
-      result: 'less than a minute ago'
+      result: 'a moment ago'
     },
     {
       title: 'should be empty',

http://git-wip-us.apache.org/repos/asf/ambari/blob/582c4948/ambari-web/test/utils/blueprint_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/blueprint_test.js b/ambari-web/test/utils/blueprint_test.js
index d615896..52930c8 100644
--- a/ambari-web/test/utils/blueprint_test.js
+++ b/ambari-web/test/utils/blueprint_test.js
@@ -400,7 +400,7 @@ describe('utils/blueprint', function() {
                     "fqdn": "host2"
                   }
                 ]
-              },
+              }
             ]
           }
         }