Browse Source

AMBARI-15227: Move HAWQMASTER above HAWQSTANDBY in Assign Masters page (mithmatt via jaoki)

Jun Aoki 9 năm trước cách đây
mục cha
commit
fa38d29a13

+ 3 - 0
ambari-web/app/mixins/wizard/assign_master_components.js

@@ -897,8 +897,11 @@ App.AssignMasterComponents = Em.Mixin.create({
    */
   sortComponentsByServiceName: function(components) {
     var displayOrder = App.StackService.displayOrder;
+    var componentsOrderForService = App.StackService.componentsOrderForService;
     var indexForUnordered = Math.max(displayOrder.length, components.length);
     return components.sort(function (a, b) {
+      if(a.serviceId === b.serviceId && a.serviceId in componentsOrderForService)
+        return componentsOrderForService[a.serviceId].indexOf(a.component_name) - componentsOrderForService[b.serviceId].indexOf(b.component_name);
       var aValue = displayOrder.indexOf(a.serviceId) != -1 ? displayOrder.indexOf(a.serviceId) : indexForUnordered;
       var bValue = displayOrder.indexOf(b.serviceId) != -1 ? displayOrder.indexOf(b.serviceId) : indexForUnordered;
       return aValue - bValue;

+ 4 - 0
ambari-web/app/models/stack_service.js

@@ -204,6 +204,10 @@ App.StackService.displayOrder = [
   'FLUME'
 ];
 
+App.StackService.componentsOrderForService = {
+  'HAWQ': ['HAWQMASTER', 'HAWQSTANDBY']
+};
+
 //@TODO: Write unit test for no two keys in the object should have any intersecting elements in their values
 App.StackService.coSelected = {
   'YARN': ['MAPREDUCE2']

+ 0 - 27
ambari-web/test/controllers/wizard/step5_test.js

@@ -1261,33 +1261,6 @@ describe('App.WizardStep5Controller', function () {
 
   });
 
-  describe('#sortComponentsByServiceName', function () {
-
-    var components = [{
-      "component_name": "METRICS_COLLECTOR",
-      "serviceId": "AMBARI_METRICS"
-    }, {"component_name": "ZOOKEEPER_SERVER", "serviceId": "ZOOKEEPER"}, {
-      "component_name": "NAMENODE",
-      "serviceId": "HDFS"
-    }, {"component_name": "DRPC_SERVER", "serviceId": "STORM"}, {
-      "component_name": "APP_TIMELINE_SERVER",
-      "serviceId": "YARN"
-    }, {"component_name": "RESOURCEMANAGER", "serviceId": "YARN"}, {
-      "component_name": "SECONDARY_NAMENODE",
-      "serviceId": "HDFS"
-    }, {"component_name": "ZOOKEEPER_SERVER", "serviceId": "ZOOKEEPER"}, {
-      "component_name": "HISTORYSERVER",
-      "serviceId": "MAPREDUCE2"
-    }, {"component_name": "NIMBUS", "serviceId": "STORM"}, {"component_name": "STORM_UI_SERVER", "serviceId": "STORM"}];
-
-    it('ZKS should be one after anothert', function () {
-      var sorted = c.sortComponentsByServiceName(components);
-      expect(sorted.mapProperty('component_name').join('|').contains('ZOOKEEPER_SERVER|ZOOKEEPER_SERVER')).to.be.true;
-    });
-
-
-  });
-
   describe('#submit',function(){
     it('if Next button is clicked multiple times before the next step renders, it must not be processed',function(){
       c.reopen({isSubmitDisabled:false, submitDisabled:false, useServerValidation:false});

+ 56 - 0
ambari-web/test/mixins/wizard/assign_master_components_test.js

@@ -151,4 +151,60 @@ describe('App.AssignMasterComponents', function () {
     });
 
   });
+
+
+  describe('#sortComponentsByServiceName', function () {
+
+    var components = [{
+      "component_name": "METRICS_COLLECTOR",
+      "serviceId": "AMBARI_METRICS"
+    }, {
+      "component_name": "ZOOKEEPER_SERVER",
+      "serviceId": "ZOOKEEPER"
+    }, {
+      "component_name": "NAMENODE",
+      "serviceId": "HDFS"
+    }, {
+      "component_name": "DRPC_SERVER",
+      "serviceId": "STORM"
+    }, {
+      "component_name": "APP_TIMELINE_SERVER",
+      "serviceId": "YARN"
+    }, {
+      "component_name": "RESOURCEMANAGER",
+      "serviceId": "YARN"
+    }, {
+      "component_name": "SECONDARY_NAMENODE",
+      "serviceId": "HDFS"
+    }, {
+      "component_name": "ZOOKEEPER_SERVER",
+      "serviceId": "ZOOKEEPER"
+    }, {
+      "component_name": "HISTORYSERVER",
+      "serviceId": "MAPREDUCE2"
+    }, {
+      "component_name": "HAWQSTANDBY",
+      "serviceId": "HAWQ"
+    }, {
+      "component_name": "NIMBUS",
+      "serviceId": "STORM"
+    }, {
+      "component_name": "HAWQMASTER",
+      "serviceId": "HAWQ"
+    }, {
+      "component_name": "STORM_UI_SERVER",
+      "serviceId": "STORM"
+    }];
+
+    it('should place ZOOKEEPER_SERVER one after another', function () {
+      var sorted = c.sortComponentsByServiceName(components);
+      expect(sorted.mapProperty('component_name').join('|').contains('ZOOKEEPER_SERVER|ZOOKEEPER_SERVER')).to.be.true;
+    });
+
+    it('should place HAWQMASTER just before HAWQSTANDBY', function () {
+      var sorted = c.sortComponentsByServiceName(components);
+      expect(sorted.mapProperty('component_name').join('|').contains('HAWQMASTER|HAWQSTANDBY')).to.be.true;
+    });
+
+  });
 });