ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject [1/3] ambari git commit: AMBARI-16988. Invalid recommended value for storm.local.dir (/usr/hdp/hadoop/storm) (alexantonenko)
Date Wed, 01 Jun 2016 17:25:50 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 950b91cbd -> ecef55d3d


AMBARI-16988. Invalid recommended value for storm.local.dir (/usr/hdp/hadoop/storm) (alexantonenko)


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

Branch: refs/heads/branch-2.4
Commit: ecef55d3ddc68f7ea9a79e68c975a86aa95c0c4b
Parents: babe17d
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Wed Jun 1 18:55:25 2016 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Wed Jun 1 20:25:43 2016 +0300

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  |  19 ++-
 .../mount_points_based_initializer_mixin.js     |  48 +++---
 .../utils/configs/config_initializer_test.js    | 152 ++++++++++++++++++-
 3 files changed, 199 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ecef55d3/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index a6fe332..57a993f 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -736,8 +736,25 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
     var localDB = {
       hosts: this.get('wizardController.content.hosts'),
       masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
-      slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
+      slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts'),
+      selectedStack: {}
     };
+    var selectedRepoVersion,
+        repoVersion;
+    if (this.get('wizardController.name') === 'addServiceController') {
+      repoVersion = App.RepositoryVersion.find().filter(function(i) {
+        return i.get('stackVersionType') === App.get('currentStackName') &&
+          i.get('stackVersionNumber') === App.get('currentStackVersionNumber');
+      })[0];
+      if (repoVersion) {
+        selectedRepoVersion = Em.get(repoVersion, 'repositoryVersion').split('-')[0];
+      }
+    } else {
+      selectedRepoVersion = Em.getWithDefault(App.Stack.find().findProperty('isSelected',
true) || {}, 'repositoryVersion', false);
+    }
+    if (selectedRepoVersion) {
+      localDB.selectedStack = selectedRepoVersion;
+    }
     var configsByService = {}, dependencies = this.get('configDependencies');
 
     configs.forEach(function (_config) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecef55d3/ambari-web/app/utils/configs/mount_points_based_initializer_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/mount_points_based_initializer_mixin.js b/ambari-web/app/utils/configs/mount_points_based_initializer_mixin.js
index 944dd9b..59a3985 100644
--- a/ambari-web/app/utils/configs/mount_points_based_initializer_mixin.js
+++ b/ambari-web/app/utils/configs/mount_points_based_initializer_mixin.js
@@ -61,7 +61,7 @@ App.MountPointsBasedInitializerMixin = Em.Mixin.create({
     if (!setOfHostNames.length) {
       return configProperty;
     }
-    var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo);
+    var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo, localDB);
 
     var mPoint = allMountPoints[0].mountpoint;
     if (mPoint === "/") {
@@ -107,7 +107,7 @@ App.MountPointsBasedInitializerMixin = Em.Mixin.create({
       return configProperty;
     }
 
-    var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo);
+    var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo, localDB);
     var mPoint = '';
 
     allMountPoints.forEach(function (eachDrive) {
@@ -207,26 +207,36 @@ App.MountPointsBasedInitializerMixin = Em.Mixin.create({
    *   <li>Should not be docker-dir</li>
    *   <li>Should not be boot-dir</li>
    *   <li>Should not be dev-dir</li>
+   *   <li>Valid mount point started from /usr/hdp/ should be /usr/hdp/current
+   *       or /usr/hdp/<STACK_VERSION_NUMBER> e.g. /usr/hdp/2.5.0.0
+   *   </li>
    * </ul>
    *
    * @param {{mountpoint: string, available: number}} mPoint
-   * @returns {boolean} true - valid, false - invalid
+   * @returns {function} true - valid, false - invalid
    * @private
    */
-  _filterMountPoint: function (mPoint) {
-    var isAvailable = mPoint.available !== 0;
-    if (!isAvailable) {
-      return false;
-    }
+  _filterMountPoint: function (localDB) {
+    var stackVersionNumber = [Em.getWithDefault(localDB.selectedStack || {}, 'repository_version',
null)].compact();
+    return function(mPoint) {
+      var isAvailable = mPoint.available !== 0;
+      if (!isAvailable) {
+        return false;
+      }
 
-    var notHome = !['/', '/home'].contains(mPoint.mountpoint);
-    var notDocker = !['/etc/resolv.conf', '/etc/hostname', '/etc/hosts'].contains(mPoint.mountpoint);
-    var notBoot = mPoint.mountpoint && !(mPoint.mountpoint.startsWith('/boot')
-                                        || mPoint.mountpoint.startsWith('/mnt')
-                                        || mPoint.mountpoint.startsWith('/tmp'));
-    var notDev = !(['devtmpfs', 'tmpfs', 'vboxsf', 'CDFS'].contains(mPoint.type));
+      var stackRoot = '/usr/hdp';
+      var notHome = !['/', '/home'].contains(mPoint.mountpoint);
+      var notDocker = !['/etc/resolv.conf', '/etc/hostname', '/etc/hosts'].contains(mPoint.mountpoint);
+      var notBoot = mPoint.mountpoint && !(mPoint.mountpoint.startsWith('/boot')
+                                           || mPoint.mountpoint.startsWith('/mnt')
+                                           || mPoint.mountpoint.startsWith('/tmp'));
+      var notDev = !(['devtmpfs', 'tmpfs', 'vboxsf', 'CDFS'].contains(mPoint.type));
+      var validStackRootMount = !(mPoint.mountpoint.startsWith(stackRoot) && !['current'].concat(stackVersionNumber).filter(function(i)
{
+        return mPoint.mountpoint === stackRoot + '/' + i;
+      }).length);
 
-    return notHome && notDocker && notBoot && notDev;
+      return notHome && notDocker && notBoot && notDev &&
validStackRootMount;
+    };
   },
 
   /**
@@ -258,11 +268,13 @@ App.MountPointsBasedInitializerMixin = Em.Mixin.create({
    *
    * @param {string[]} setOfHostNames
    * @param {object} hostsInfo
+   * @param {topologyLocalDB} localDB
    * @returns {string[]}
    * @private
    */
-  _getAllMountPoints: function (setOfHostNames, hostsInfo) {
-    var allMountPoints = [];
+  _getAllMountPoints: function (setOfHostNames, hostsInfo, localDB) {
+    var allMountPoints = [],
+        mountPointFilter = this._filterMountPoint(localDB);
     for (var i = 0; i < setOfHostNames.length; i++) {
       var hostname = setOfHostNames[i];
       var mountPointsPerHost = hostsInfo[hostname].disk_info;
@@ -276,7 +288,7 @@ App.MountPointsBasedInitializerMixin = Em.Mixin.create({
         };
       }
 
-      mountPointsPerHost.filter(this._filterMountPoint).forEach(function (mPoint) {
+      mountPointsPerHost.filter(mountPointFilter).forEach(function (mPoint) {
         if( !allMountPoints.findProperty("mountpoint", mPoint.mountpoint)) {
           allMountPoints.push(mPoint);
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecef55d3/ambari-web/test/utils/configs/config_initializer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/configs/config_initializer_test.js b/ambari-web/test/utils/configs/config_initializer_test.js
index d2d91e9..7eeea6d 100644
--- a/ambari-web/test/utils/configs/config_initializer_test.js
+++ b/ambari-web/test/utils/configs/config_initializer_test.js
@@ -1217,7 +1217,157 @@ describe('App.ConfigInitializer', function () {
         expect(App.ConfigInitializer[name]).to.be.a.function;
       });
     });
-
   });
 
+  describe('#_filterMountPoint', function() {
+    var cases = [
+      {
+        mPoint: {
+          mountpoint: '/'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/home'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/etc/resolv.conf'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/etc/hostname'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/etc/hosts'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/boot'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/mnt'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/tmp'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/some-dir',
+          type: 'devtmpfs'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/some-dir',
+          type: 'tmpfs'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/some-dir',
+          type: 'vboxsf'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/some-dir',
+          type: 'CDFS'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/usr/hdp'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/usr/hdp/1'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/usr/hdp/current'
+        },
+        localDB: {},
+        e: true
+      },
+      {
+        mPoint: {
+          mountpoint: '/usr/hdp/2.5'
+        },
+        localDB: {
+          selectedStack: {
+            repository_version: '2.5'
+          }
+        },
+        e: true
+      },
+      {
+        mPoint: {
+          mountpoint: '/usr/hdp/2.5.0'
+        },
+        localDB: {
+          selectedStack: {
+            repository_version: '2.5'
+          }
+        },
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/normal/directory'
+        },
+        localDB: {
+          selectedStack: {
+            repository_version: '2.5'
+          }
+        },
+        e: true
+      }
+    ].forEach(function(test) {
+      it('mount point "{0}" should be {1}'.format(test.mPoint.mountpoint, test.e ? 'valid'
: 'invalid'), function() {
+        var fFn = App.ConfigInitializer._filterMountPoint(test.localDB);
+        expect(fFn(test.mPoint)).to.be.eql(test.e);
+      });
+    });
+  });
 });


Mime
View raw message