Repository: ambari Updated Branches: refs/heads/trunk fea33155a -> eba68bfcc
AMBARI-10014. Do not pick up /boot and /mnt for suggesting directories (alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/eba68bfc Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/eba68bfc Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/eba68bfc Branch: refs/heads/trunk Commit: eba68bfcced0aae26bb5c3f50fdb51ac8f9d3271 Parents: e8daa48 Author: Alex Antonenko <[email protected]> Authored: Tue Mar 10 20:58:27 2015 +0200 Committer: Alex Antonenko <[email protected]> Committed: Tue Mar 10 23:42:00 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/models/service_config.js | 9 +- ambari-web/test/models/service_config_test.js | 306 +++++++++++++++++++++ 2 files changed, 310 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/eba68bfc/ambari-web/app/models/service_config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js index dc7a4e7..73abf51 100644 --- a/ambari-web/app/models/service_config.js +++ b/ambari-web/app/models/service_config.js @@ -776,10 +776,10 @@ App.ServiceConfigProperty = Em.Object.extend({ } mountPointsPerHost = mountPointsPerHost.filter(function (mPoint) { - return !(['/', '/home', '/boot'].contains(mPoint.mountpoint) - || ['devtmpfs', 'tmpfs', 'vboxsf'].contains(mPoint.type) - || mPoint.available == 0 - || mPoint.type == 'CDFS'); + return !(['/', '/home'].contains(mPoint.mountpoint) + || mPoint.mountpoint && (mPoint.mountpoint.startsWith('/boot') || mPoint.mountpoint.startsWith('/mnt')) + || ['devtmpfs', 'tmpfs', 'vboxsf', 'CDFS'].contains(mPoint.type) + || mPoint.available == 0); }); mountPointsPerHost.forEach(function (mPoint) { @@ -803,7 +803,6 @@ App.ServiceConfigProperty = Em.Object.extend({ mPoint += this.get('defaultDirectory') + "\n"; } else if(winRegex.test(eachDrive.mountpoint.toLowerCase())) { switch (this.get('name')) { - case 'dfs.datanode.data.dir': case 'dfs.name.dir': case 'dfs.namenode.name.dir': case 'dfs.data.dir': http://git-wip-us.apache.org/repos/asf/ambari/blob/eba68bfc/ambari-web/test/models/service_config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service_config_test.js b/ambari-web/test/models/service_config_test.js index 7b0b516..bba0f31 100644 --- a/ambari-web/test/models/service_config_test.js +++ b/ambari-web/test/models/service_config_test.js @@ -1088,4 +1088,310 @@ describe('App.ServiceConfigProperty', function () { }); + describe('#unionAllMountPoints', function () { + + var localDB = { + masterComponentHosts: [ + { + component: 'NAMENODE', + hostName: 'h0' + }, + { + component: 'SECONDARY_NAMENODE', + hostName: 'h4' + }, + { + component: 'APP_TIMELINE_SERVER', + hostName: 'h0' + }, + { + component: 'ZOOKEEPER_SERVER', + hostName: 'h0' + }, + { + component: 'ZOOKEEPER_SERVER', + hostName: 'h1' + }, + { + component: 'OOZIE_SERVER', + hostName: 'h0' + }, + { + component: 'OOZIE_SERVER', + hostName: 'h1' + }, + { + component: 'NIMBUS', + hostName: 'h2' + }, + { + component: 'FALCON_SERVER', + hostName: 'h3' + }, + { + component: 'KAFKA_BROKER', + hostName: 'h0' + }, + { + component: 'KAFKA_BROKER', + hostName: 'h1' + } + ], + slaveComponentHosts: [ + { + componentName: 'DATANODE', + hosts: [ + { + hostName: 'h0' + }, + { + hostName: 'h1' + } + ] + }, + { + componentName: 'TASKTRACKER', + hosts: [ + { + hostName: 'h0' + }, + { + hostName: 'h1' + } + ] + }, + { + componentName: 'NODEMANAGER', + hosts: [ + { + hostName: 'h0' + }, + { + hostName: 'h1' + }, + { + hostName: 'h4' + } + ] + }, + { + componentName: 'HBASE_REGIONSERVER', + hosts: [ + { + hostName: 'h0' + }, + { + hostName: 'h1' + } + ] + }, + { + componentName: 'SUPERVISOR', + hosts: [ + { + hostName: 'h0' + }, + { + hostName: 'h1' + } + ] + } + ], + hosts: { + h0: { + disk_info: [ + { + mountpoint: '/' + }, + { + mountpoint: '/home' + }, + { + mountpoint: '/boot' + }, + { + mountpoint: '/boot/efi' + }, + { + mountpoint: '/mnt' + }, + { + mountpoint: '/mnt/efi' + }, + { + mountpoint: '/media/disk0', + available: '100000000' + }, + { + mountpoint: '/mount0', + available: '100000000' + } + ] + }, + h4: { + disk_info: [ + { + mountpoint: 'c:', + available: '100000000' + } + ] + } + } + }, + cases = [ + { + name: 'dfs.namenode.name.dir', + isOnlyFirstOneNeeded: false, + value: '/media/disk0/default\n/mount0/default\n' + }, + { + name: 'dfs.name.dir', + isOnlyFirstOneNeeded: false, + value: '/media/disk0/default\n/mount0/default\n' + }, + { + name: 'fs.checkpoint.dir', + isOnlyFirstOneNeeded: true, + value: 'file:///c:/default\n' + }, + { + name: 'dfs.namenode.checkpoint.dir', + isOnlyFirstOneNeeded: true, + value: 'file:///c:/default\n' + }, + { + name: 'dfs.data.dir', + isOnlyFirstOneNeeded: false, + value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n' + }, + { + name: 'dfs.datanode.data.dir', + isOnlyFirstOneNeeded: false, + value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n' + }, + { + name: 'mapred.local.dir', + isOnlyFirstOneNeeded: false, + value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n' + }, + { + name: 'yarn.nodemanager.log-dirs', + isOnlyFirstOneNeeded: false, + value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\nc:\\default\n' + }, + { + name: 'yarn.nodemanager.local-dirs', + isOnlyFirstOneNeeded: false, + value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\nc:\\default\n' + }, + { + name: 'yarn.timeline-service.leveldb-timeline-store.path', + isOnlyFirstOneNeeded: true, + value: '/media/disk0/default' + }, + { + name: 'dataDir', + isOnlyFirstOneNeeded: true, + value: '/media/disk0/default' + }, + { + name: 'oozie_data_dir', + isOnlyFirstOneNeeded: true, + value: '/media/disk0/default' + }, + { + name: 'hbase.tmp.dir', + isOnlyFirstOneNeeded: true, + value: '/media/disk0/default' + }, + { + name: 'storm.local.dir', + isOnlyFirstOneNeeded: true, + value: '/media/disk0/default' + }, + { + name: '*.falcon.graph.storage.directory', + isOnlyFirstOneNeeded: true, + value: '/default' + }, + { + name: '*.falcon.graph.serialize.path', + isOnlyFirstOneNeeded: true, + value: '/default' + }, + { + name: 'log.dirs', + isOnlyFirstOneNeeded: false, + value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n' + } + ]; + + beforeEach(function () { + sinon.stub(App.Host, 'find').returns([ + Em.Object.create({ + id: 'h1', + diskInfo: [ + { + mountpoint: '/media/disk1', + type: 'devtmpfs' + }, + { + mountpoint: '/media/disk1', + type: 'tmpfs' + }, + { + mountpoint: '/media/disk1', + type: 'vboxsf' + }, + { + mountpoint: '/media/disk1', + type: 'CDFS' + }, + { + mountpoint: '/media/disk1', + available: '0' + }, + { + mountpoint: '/media/disk1', + available: '100000000' + }, + { + mountpoint: '/mount1', + available: '100000000' + } + ] + }), + Em.Object.create({ + id: 'h2', + diskInfo: [ + { + mountpoint: '/' + } + ] + }), + Em.Object.create({ + id: 'h3', + diskInfo: [] + }) + ]); + }); + + afterEach(function () { + App.Host.find.restore(); + }); + + cases.forEach(function (item) { + it(item.name, function () { + serviceConfigProperty.setProperties({ + name: item.name, + defaultDirectory: '/default' + }); + serviceConfigProperty.unionAllMountPoints(item.isOnlyFirstOneNeeded, localDB); + expect(serviceConfigProperty.get('value')).to.equal(item.value); + expect(serviceConfigProperty.get('defaultValue')).to.equal(item.value); + }); + }); + + }); + });
