ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject git commit: AMBARI-7229. Stack version must start with 2. to be considered Hadoop-2.x compatible. (jaimin)
Date Fri, 10 Oct 2014 01:16:10 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 306903330 -> 25b5adc0e


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


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

Branch: refs/heads/branch-1.7.0
Commit: 25b5adc0e9233bffbbda877d807936c156de358d
Parents: 3069033
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Thu Oct 9 15:23:16 2014 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Thu Oct 9 18:15:18 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/app.js                          | 13 +++++-
 ambari-web/app/mappers/stack_service_mapper.js |  2 +
 ambari-web/test/app_test.js                    | 51 +++++++++++++++------
 3 files changed, 50 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/25b5adc0/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index e057814..c92e0ac 100644
--- a/ambari-web/app/app.js
+++ b/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);

http://git-wip-us.apache.org/repos/asf/ambari/blob/25b5adc0/ambari-web/app/mappers/stack_service_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/stack_service_mapper.js b/ambari-web/app/mappers/stack_service_mapper.js
index 1732549..6a13bd3 100644
--- a/ambari-web/app/mappers/stack_service_mapper.js
+++ b/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) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/25b5adc0/ambari-web/test/app_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/app_test.js b/ambari-web/test/app_test.js
index a8f5151..fb35c86 100644
--- a/ambari-web/test/app_test.js
+++ b/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'
+          }
+        ];
       });
     });
 


Mime
View raw message