Updated Branches: refs/heads/trunk f006ab202 -> 0a9cd6496
AMBARI-4471. Refactor of component lists. (Denys Buzhor via onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0a9cd649 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0a9cd649 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0a9cd649 Branch: refs/heads/trunk Commit: 0a9cd6496e06af042fa44010833d02152edece68 Parents: f006ab2 Author: Oleg Nechiporenko <[email protected]> Authored: Fri Jan 31 13:47:05 2014 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Fri Jan 31 13:47:05 2014 +0200 ---------------------------------------------------------------------- ambari-web/app/app.js | 16 ++++++++++- ambari-web/app/assets/test/tests.js | 3 ++- ambari-web/app/config.js | 3 --- .../app/controllers/wizard/step9_controller.js | 8 +++--- ambari-web/app/views/main/host/summary.js | 6 ++--- ambari-web/app/views/main/service/item.js | 2 +- ambari-web/test/app_test.js | 28 ++++++++++++++++++++ ambari-web/test/installer/step9_test.js | 11 +++++--- 8 files changed, 60 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0a9cd649/ambari-web/app/app.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js index 8078961..a8eb611 100644 --- a/ambari-web/app/app.js +++ b/ambari-web/app/app.js @@ -71,8 +71,22 @@ module.exports = Em.Application.create({ isHaEnabled: function() { if (!this.get('isHadoop2Stack')) return false; return !this.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE'); - }.property('router.clusterController.isLoaded') + }.property('router.clusterController.isLoaded'), + components: Ember.Object.create({ + reassignable: ['NAMENODE', 'SECONDARY_NAMENODE', 'JOBTRACKER', 'RESOURCEMANAGER'], + restartable: ['APP_TIMELINE_SERVER'], + deletable: ['SUPERVISOR', 'HBASE_MASTER'], + slaves: function() { + return require('data/service_components').filter(function(component){ + return !component.isClient && !component.isMaster + }).mapProperty('component_name').uniq().without("DASHBOARD"); + }.property().cacheable(), + + masters: function() { + return require('data/service_components').filterProperty('isMaster', true).mapProperty('component_name').uniq(); + }.property().cacheable() + }) }); /** http://git-wip-us.apache.org/repos/asf/ambari/blob/0a9cd649/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index 20ff4b3..85181fc 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -16,6 +16,7 @@ * limitations under the License. */ +require('test/app_test'); require('test/controllers/global/background_operations_test'); require('test/controllers/global/cluster_controller_test'); require('test/controllers/main/app_contoller_test'); @@ -99,4 +100,4 @@ require('test/views/main/dashboard/widgets/namenode_cpu_test'); require('test/views/common/configs/services_config_test'); require('test/views/wizard/step9_view_test'); require('test/models/host_test'); -require('test/models/rack_test'); \ No newline at end of file +require('test/models/rack_test'); http://git-wip-us.apache.org/repos/asf/ambari/blob/0a9cd649/ambari-web/app/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js index 2b11095..711be61 100644 --- a/ambari-web/app/config.js +++ b/ambari-web/app/config.js @@ -38,9 +38,6 @@ App.maxRunsForAppBrowser = 500; App.pageReloadTime=3600000; App.singleNodeInstall = false; App.singleNodeAlias = document.location.hostname; -App.reassignableComponents = ['NAMENODE', 'SECONDARY_NAMENODE', 'JOBTRACKER', 'RESOURCEMANAGER']; -App.restartableComponents = ['APP_TIMELINE_SERVER']; -App.deletableComponents = ['SUPERVISOR', 'HBASE_MASTER']; // experimental features are automatically enabled if running on brunch server App.enableExperimental = false; http://git-wip-us.apache.org/repos/asf/ambari/blob/0a9cd649/ambari-web/app/controllers/wizard/step9_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step9_controller.js b/ambari-web/app/controllers/wizard/step9_controller.js index 6c3fe08..47509a5 100644 --- a/ambari-web/app/controllers/wizard/step9_controller.js +++ b/ambari-web/app/controllers/wizard/step9_controller.js @@ -352,7 +352,7 @@ App.WizardStep9Controller = Em.Controller.extend({ data = { "RequestInfo": { "context": Em.I18n.t("requestInfo.startHostComponents"), - "query": "HostRoles/component_name.in(GANGLIA_MONITOR,HBASE_REGIONSERVER,DATANODE,TASKTRACKER,NODEMANAGER)&HostRoles/state=INSTALLED&HostRoles/host_name.in(" + hostnames.join(',') + ")" + "query": "HostRoles/component_name.in(" + App.get('components.slaves').join(',') + ")&HostRoles/state=INSTALLED&HostRoles/host_name.in(" + hostnames.join(',') + ")" }, "Body": { "HostRoles": { "state": "STARTED" } @@ -467,8 +467,8 @@ App.WizardStep9Controller = Em.Controller.extend({ isMasterFailed: function(polledData) { var result = false; polledData.filterProperty('Tasks.command', 'INSTALL').filterProperty('Tasks.status', 'FAILED').mapProperty('Tasks.role').forEach ( - function (task) { - if (!['DATANODE', 'TASKTRACKER', 'HBASE_REGIONSERVER', 'GANGLIA_MONITOR'].contains(task)) { + function (role) { + if (!App.get('components.slaves').contains(role)) { result = true; } } @@ -546,7 +546,7 @@ App.WizardStep9Controller = Em.Controller.extend({ return; } var actionsPerRole = polledData.filterProperty('Tasks.role', role); - if (['DATANODE', 'TASKTRACKER', 'HBASE_REGIONSERVER', 'GANGLIA_MONITOR'].contains(role)) { + if (App.get('components.slaves').contains(role)) { // check slave components for success factor. // partial failure for slave components are allowed. var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 'FAILED'); http://git-wip-us.apache.org/repos/asf/ambari/blob/0a9cd649/ambari-web/app/views/main/host/summary.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/summary.js b/ambari-web/app/views/main/host/summary.js index c8779c9..e3befcc 100644 --- a/ambari-web/app/views/main/host/summary.js +++ b/ambari-web/app/views/main/host/summary.js @@ -773,7 +773,7 @@ App.MainHostSummaryView = Em.View.extend({ * Shows whether we need to show Delete button */ isDeletableComponent: function () { - return App.deletableComponents.contains(this.get('content.componentName')); + return App.get('components.deletable').contains(this.get('content.componentName')); }.property('content'), isDeleteComponentDisabled: function () { @@ -782,11 +782,11 @@ App.MainHostSummaryView = Em.View.extend({ }.property('workStatus'), isReassignable: function () { - return App.supports.reassignMaster && App.reassignableComponents.contains(this.get('content.componentName')) && App.Host.find().content.length > 1; + return App.supports.reassignMaster && App.get('components.reassignable').contains(this.get('content.componentName')) && App.Host.find().content.length > 1; }.property('content.componentName'), isRestartableComponent: function() { - return App.restartableComponents.contains(this.get('content.componentName')); + return App.get('components.restartable').contains(this.get('content.componentName')); }.property('content'), isRestartComponentDisabled: function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/0a9cd649/ambari-web/app/views/main/service/item.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/item.js b/ambari-web/app/views/main/service/item.js index c6b919e..e617e98 100644 --- a/ambari-web/app/views/main/service/item.js +++ b/ambari-web/app/views/main/service/item.js @@ -46,7 +46,7 @@ App.MainServiceItemView = Em.View.extend({ case 'MAPREDUCE': if (App.supports.reassignMaster && hosts > 1) { allMasters.forEach(function (hostComponent) { - if (App.reassignableComponents.contains(hostComponent)) { + if (App.get('components.reassignable').contains(hostComponent)) { options.push({action: 'reassignMaster', context: hostComponent, cssClass: 'icon-share-alt', 'label': Em.I18n.t('services.service.actions.reassign.master').format(App.format.role(hostComponent)), disabled: false}); } http://git-wip-us.apache.org/repos/asf/ambari/blob/0a9cd649/ambari-web/test/app_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/app_test.js b/ambari-web/test/app_test.js new file mode 100644 index 0000000..59ec825 --- /dev/null +++ b/ambari-web/test/app_test.js @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); + +describe('#App.components', function() { + it('slaves and masters should not intersect', function() { + var intersected = App.get('components.slaves').filter(function(item){ + return App.get('components.masters').contains(item); + }); + expect(intersected).to.eql([]); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/0a9cd649/ambari-web/test/installer/step9_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/installer/step9_test.js b/ambari-web/test/installer/step9_test.js index a3b4370..eb0de3f 100644 --- a/ambari-web/test/installer/step9_test.js +++ b/ambari-web/test/installer/step9_test.js @@ -379,7 +379,8 @@ describe('App.InstallerStep9Controller', function () { {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'DATANODE'}}, {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'TASKTRACKER'}}, {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'HBASE_REGIONSERVER'}}, - {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'GANGLIA_MONITOR'}} + {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'GANGLIA_MONITOR'}}, + {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'SUPERVISOR'}} ], e: false, m: 'No one Master is failed' @@ -389,7 +390,8 @@ describe('App.InstallerStep9Controller', function () { {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'NAMENODE'}}, {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'TASKTRACKER'}}, {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'HBASE_REGIONSERVER'}}, - {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'GANGLIA_MONITOR'}} + {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'GANGLIA_MONITOR'}}, + {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'SUPERVISOR'}} ], e: true, m: 'One Master is failed' @@ -399,7 +401,8 @@ describe('App.InstallerStep9Controller', function () { {Tasks: {command: 'PENDING',status: 'FAILED',role: 'NAMENODE'}}, {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'TASKTRACKER'}}, {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'HBASE_REGIONSERVER'}}, - {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'GANGLIA_MONITOR'}} + {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'GANGLIA_MONITOR'}}, + {Tasks: {command: 'INSTALL',status: 'FAILED',role: 'SUPERVISOR'}} ], e: false, m: 'one Master is failed but command is not install' @@ -967,4 +970,4 @@ describe('App.InstallerStep9Controller', function () { }); }); -}); \ No newline at end of file +});
