Forráskód Böngészése

AMBARI-7229. Stack version must start with 2. to be considered Hadoop-2.x compatible. (jaimin)

Jaimin Jetly 10 éve
szülő
commit
ab532a54bd

+ 11 - 2
ambari-web/app/app.js

@@ -37,6 +37,8 @@ module.exports = Em.Application.create({
   isManager: function() {
     return this.get('isAdmin') || this.get('isOperator');
   }.property('isAdmin','isOperator'),
+
+  isStackServicesLoaded: false,
   /**
    * return url prefix with number value of version of HDP stack
    */
@@ -80,8 +82,15 @@ module.exports = Em.Application.create({
   }.property('currentStackVersion', 'currentStackName'),
 
   isHadoop2Stack: function () {
-    return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") > -1);
-  }.property('currentStackVersionNumber'),
+    var result = true;
+    var hdfsService = App.StackService.find().findProperty('serviceName','HDFS');
+    if (hdfsService) {
+      result = stringUtils.compareVersions(hdfsService.get('serviceVersion'), "2.0") > -1;
+    } else {
+      result = stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.0") > -1;
+    }
+    return result;
+  }.property('router.clusterController.isLoaded', 'isStackServicesLoaded','currentStackVersionNumber'),
 
   isHadoop22Stack: function () {
     return (stringUtils.compareVersions(this.get('currentStackVersionNumber'), "2.2") > -1);

+ 2 - 0
ambari-web/app/mappers/stack_service_mapper.js

@@ -63,10 +63,12 @@ App.stackServiceMapper = App.QuickDataMapper.create({
   },
 
   mapStackServices: function(json) {
+    App.set('isStackServicesLoaded',false);
     this.clearStackModels();
     App.resetDsStoreTypeMap(App.StackServiceComponent);
     App.resetDsStoreTypeMap(App.StackService);
     this.map(json);
+    App.set('isStackServicesLoaded',true);
   },
 
   map: function (json) {

+ 37 - 14
ambari-web/test/app_test.js

@@ -145,10 +145,10 @@ describe('App', function () {
         result: '1.3.1'
       }
     ];
-    before(function() {
+    before(function () {
       App.set('defaultStackVersion', '');
     });
-    after(function() {
+    after(function () {
       App.set('defaultStackVersion', 'HDP-2.0.5');
     });
     testCases.forEach(function (test) {
@@ -161,13 +161,13 @@ describe('App', function () {
   });
 
   describe('#isHadoop2Stack', function () {
-    before(function() {
+    before(function () {
       App.set('defaultStackVersion', '');
     });
-    after(function() {
+    after(function () {
       App.set('defaultStackVersion', 'HDP-2.0.5');
     });
-    var testCases = [
+    var testCasesWithoutHDFSDefined = [
       {
         title: 'if currentStackVersion is empty then isHadoop2Stack should be false',
         currentStackVersion: '',
@@ -190,23 +190,44 @@ describe('App', function () {
       }
     ];
 
-    testCases.forEach(function (test) {
+    testCasesWithoutHDFSDefined.forEach(function (test) {
       it(test.title, function () {
         App.set('currentStackVersion', test.currentStackVersion);
         expect(App.get('isHadoop2Stack')).to.equal(test.result);
         App.set('currentStackVersion', "HDP-1.2.2");
       });
     });
+
+
+    it('HDFS service version should get priority when defined', function () {
+      var stackServices = [
+        Em.Object.create({
+          serviceName: 'HDFS',
+          serviceVersion: '2.1'
+        })
+      ];
+      sinon.stub(App.StackService, 'find', function () {
+        return stackServices;
+      });
+      App.set('currentStackVersion', '0.8');
+      App.set('isStackServicesLoaded', true);
+      expect(App.get('isHadoop2Stack')).to.equal(true);
+      App.set('isStackServicesLoaded', false);
+      App.set('currentStackVersion', "HDP-1.2.2");
+      App.StackService.find.restore();
+    });
   });
 
   describe('#isHaEnabled when HDFS is installed:', function () {
 
     beforeEach(function () {
       sinon.stub(App.Service, 'find', function () {
-        return [{
-          id : 'HDFS',
-          serviceName: 'HDFS'
-        }];
+        return [
+          {
+            id: 'HDFS',
+            serviceName: 'HDFS'
+          }
+        ];
       });
     });
 
@@ -239,10 +260,12 @@ describe('App', function () {
 
     beforeEach(function () {
       sinon.stub(App.Service, 'find', function () {
-        return [{
-          id : 'ZOOKEEPER',
-          serviceName: 'ZOOKEEPER'
-        }];
+        return [
+          {
+            id: 'ZOOKEEPER',
+            serviceName: 'ZOOKEEPER'
+          }
+        ];
       });
     });