Browse Source

AMBARI-4471. Refactor of component lists. (Denys Buzhor via onechiporenko)

Oleg Nechiporenko 11 năm trước cách đây
mục cha
commit
0a9cd6496e

+ 15 - 1
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()
+  })
 });
 
 /**

+ 2 - 1
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');
+require('test/models/rack_test');

+ 0 - 3
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;

+ 4 - 4
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');

+ 3 - 3
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() {

+ 1 - 1
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});
             }

+ 28 - 0
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([]);
+  });
+});

+ 7 - 4
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 () {
     });
   });
 
-});
+});