Ver Fonte

AMBARI-1906. Make experimental Ambari Web features toggleable (turned on/off via config file). (yusaku via jaimin)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1468258 13f79535-47bb-0310-9956-ffa450edef68
Jaimin Jetly há 12 anos atrás
pai
commit
0171dea747

+ 3 - 0
CHANGES.txt

@@ -257,6 +257,9 @@ Trunk (unreleased changes):
  (Sumit Mohanty via mahadev)
 
  IMPROVEMENTS
+ 
+ AMBARI-1906. Make experimental Ambari Web features toggleable 
+ (turned on/off via config file). (yusaku via jaimin)
 
  AMBARI-1905. Test mode is broken. (yusaku via jaimin)
 

+ 24 - 10
ambari-web/app/config.js

@@ -18,29 +18,42 @@
 
 var App = require('app');
 
-App.testMode = false;
-if(location.port == '3333'){
-  App.testMode = true;
-}
+App.testMode = (location.port == '3333'); // test mode is automatically enabled if running on brunch server
 App.testModeDelayForActions = 10000;
 App.skipBootstrap = false;
 App.alwaysGoToInstaller = false;
-App.testEnableSecurity = true;                   // By default enable security is tested; turning it false tests disable security
+App.testEnableSecurity = true; // By default enable security is tested; turning it false tests disable security
 App.apiPrefix = '/api/v1';
 App.defaultStackVersion = 'HDP-1.3.0';
 App.defaultLocalStackVersion = 'HDPLocal-1.3.0';
 App.defaultJavaHome = '/usr/jdk/jdk1.6.0_31';
-App.addServicesEnabled = false;
-// default AJAX timeout
-App.timeout = 180000;
-// max number of retries for certain AJAX calls
-App.maxRetries = 3;
+App.timeout = 180000; // default AJAX timeout
+App.maxRetries = 3; // max number of retries for certain AJAX calls
 App.bgOperationsUpdateInterval = 6000;
 App.componentsUpdateInterval = 6000;
 App.contentUpdateInterval = 15000;
 App.maxRunsForAppBrowser = 500;
 App.pageReloadTime=3600000;
 
+App.disableAllSupports = false;
+
+App.supports = {
+  addServices: false,
+  hostOverrides: true,
+  mirroring: true,
+  secureCluster: true,
+  reassignMaster: true,
+  stackUpgrade: true,
+  capacitySchedulerUi: true,
+  startStopAllServices: true
+};
+
+if (App.disableAllSupports) {
+  for (var support in App.supports) {
+    App.supports[support] = false;
+  }
+}
+
 // this is to make sure that IE does not cache data when making AJAX calls to the server
 $.ajaxSetup({
   cache: false
@@ -50,3 +63,4 @@ $.ajaxSetup({
  * Test Mode values
  */
 App.test_hostname = 'hostname';
+

+ 4 - 2
ambari-web/app/controllers/wizard/step8_controller.js

@@ -1270,8 +1270,10 @@ App.WizardStep8Controller = Em.Controller.extend({
     }
     if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
       this.applyConfigurationToSite(this.createMrSiteObj());
-      this.applyConfigurationToSite(this.createCapacityScheduler());
-      this.applyConfigurationToSite(this.createMapredQueueAcls());
+      if (App.supports.capacitySchedulerUi) {
+        this.applyConfigurationToSite(this.createCapacityScheduler());
+        this.applyConfigurationToSite(this.createMapredQueueAcls());
+      }
     }
     if (selectedServices.someProperty('serviceName', 'HBASE')) {
       this.applyConfigurationToSite(this.createHbaseSiteObj());

+ 1 - 1
ambari-web/app/data/service_configs.js

@@ -48,7 +48,7 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'TaskTracker', displayName : 'TaskTracker', hostComponentNames : ['TASKTRACKER']}),
       App.ServiceConfigCategory.create({ name: 'General', displayName : 'General'}),
       App.ServiceConfigCategory.create({ name: 'Advanced', displayName : 'Advanced'}),
-      App.ServiceConfigCategory.create({ name: 'CapacityScheduler', displayName : 'Capacity Scheduler', isCustomView: true, siteFileName: 'capacity-scheduler.xml', siteFileNames: ['capacity-scheduler.xml', 'mapred-queue-acls.xml'], canAddProperty: true}),
+      App.ServiceConfigCategory.create({ name: 'CapacityScheduler', displayName : 'Capacity Scheduler', isCapacityScheduler : true, isCustomView: true, siteFileName: 'capacity-scheduler.xml', siteFileNames: ['capacity-scheduler.xml', 'mapred-queue-acls.xml'], canAddProperty: true}),
       App.ServiceConfigCategory.create({ name: 'AdvancedMapredSite', displayName : 'Custom mapred-site.xml', siteFileName: 'mapred-site.xml', canAddProperty: true})
     ],
     sites: ['global', 'core-site', 'mapred-site', 'capacity-scheduler', 'mapred-queue-acls'],

+ 4 - 0
ambari-web/app/templates/common/configs/service_config.hbs

@@ -47,7 +47,9 @@
 <div class="accordion">
   {{#each category in selectedService.configCategories}}
     {{#if category.isCustomView}}
+      {{#if App.supports.capacityScheduler}}
       {{view category.customView categoryBinding="category" serviceBinding="selectedService" canEditBinding="view.canEdit" serviceConfigsBinding="selectedService.configs"}}
+      {{/if}}
     {{else}}
     {{#view App.ServiceConfigsByCategoryView categoryBinding="category" canEditBinding="view.canEdit" serviceBinding="selectedService" serviceConfigsBinding="selectedService.configs"}}
 
@@ -76,7 +78,9 @@
                                 {{view viewClass serviceConfigBinding="this" categoryConfigsAllBinding="view.categoryConfigsAll" }}
                                 {{#if view.canEdit}}
 	                                {{#if isPropertyOverridable}}
+                                    {{#if App.supports.hostOverrides}}
 	                                    <a class="action" {{action "createOverrideProperty" this target="view" }} ><i class="icon-plus-sign"></i>{{t common.exception}}</a>
+                                    {{/if}}
 	                                {{/if}}
 	                                {{#if cantBeUndone}}
 	                                {{else}}

+ 3 - 1
ambari-web/app/templates/main/service.hbs

@@ -20,7 +20,7 @@
   <div id="services-menu" class="well span2" style="padding: 8px 0">
     {{view App.MainServiceMenuView}}
     {{#if App.isAdmin}}
-    {{#if App.addServicesEnabled}}
+    {{#if App.supports.addServices}}
     <div class="add-service-button">
       <a class="btn" {{action addService href="true"}}>
         <i class="icon-plus"></i>
@@ -28,6 +28,7 @@
       </a>
     </div>
     {{/if}}
+    {{#if App.supports.startStopAllServices}}
       <div class="start-stop-all-service-button">
         <a href="javascript:void(null)" {{bindAttr class=":btn controller.isStartAllDisabled:disabled:btn-success" }}
            data-toggle="modal" {{action "startAllService" target="controller"}}>
@@ -43,6 +44,7 @@
         </a>
       </div>
     {{/if}}
+    {{/if}}
   </div>
   <div class="span10">
     {{outlet}}

+ 7 - 1
ambari-web/app/utils/config.js

@@ -31,7 +31,13 @@ App.config = Em.Object.create({
   //categories which contain custom configs
   categoriesWithCustom: ['CapacityScheduler'],
   //configs with these filenames go to appropriate category not in Advanced
-  customFileNames: ['capacity-scheduler.xml', 'mapred-queue-acls.xml'],
+  customFileNames: function() {
+    if (App.supports.capacitySchedulerUi) {
+      return ['capacity-scheduler.xml', 'mapred-queue-acls.xml'];
+    } else {
+      return [];
+    }
+  }.property(''),
   /**
    * Cache of loaded configurations. This is useful in not loading
    * same configuration multiple times. It is populated in multiple

+ 22 - 16
ambari-web/app/views/main/admin.js

@@ -21,28 +21,34 @@ var App = require('app');
 App.MainAdminView = Em.View.extend({
   templateName: require('templates/main/admin'),
   selectedBinding: 'controller.category',
-  categories: [
-    {
+  categories: function() {
+    var items = [{
       name: 'user',
       url: 'adminUser',
       label: Em.I18n.t('common.users')
-    },
-    {
-      name: 'security',
-      url: 'adminSecurity.index',
-      label: Em.I18n.t('common.security')
-    },
-    {
-      name: 'cluster',
-      url: 'adminCluster',
-      label: Em.I18n.t('common.cluster')
-    },
-    {
+    }];
+    if (App.supports.secureCluster) {
+      items.push({
+        name: 'security',
+        url: 'adminSecurity.index',
+        label: Em.I18n.t('common.security')
+      });
+    }
+    if (App.supports.stackUpgrade) {
+      items.push({
+        name: 'cluster',
+        url: 'adminCluster',
+        label: Em.I18n.t('common.cluster')
+      });
+    }
+    items.push({
       name: 'misc',
       url: 'adminMisc',
       label: Em.I18n.t('common.misc')
-    }
-  ],
+    });
+    return items;
+  }.property(''),
+
   NavItemView: Ember.View.extend({
     tagName: 'li',
     classNameBindings: 'isActive:active'.w(),

+ 9 - 4
ambari-web/app/views/main/menu.js

@@ -31,11 +31,16 @@ App.MainMenuView = Em.CollectionView.extend({
       { label:Em.I18n.t('menu.item.heatmaps'), routing:'charts'},
       { label:Em.I18n.t('menu.item.services'), routing:'services'},
       { label:Em.I18n.t('menu.item.hosts'), routing:'hosts'},
-      { label:Em.I18n.t('menu.item.jobs'), routing:'apps'},
-      { label:Em.I18n.t('menu.item.mirroring'), routing:'mirroring'}
-
+      { label:Em.I18n.t('menu.item.jobs'), routing:'apps'}
     ];
-      if(App.get('isAdmin')) result.push({ label:Em.I18n.t('menu.item.admin'), routing:'admin'});
+
+    if (App.supports.mirroring) {
+      result.push({ label:Em.I18n.t('menu.item.mirroring'), routing:'mirroring'});
+    }
+
+    if (App.get('isAdmin')) {
+      result.push({ label:Em.I18n.t('menu.item.admin'), routing:'admin'});
+    }
     return result;
   }.property(),
     /**

+ 17 - 9
ambari-web/app/views/main/service/item.js

@@ -32,18 +32,24 @@ App.MainServiceItemView = Em.View.extend({
 //        break;
       case 'GANGLIA':
       case 'NAGIOS':
-        this.get('controller.content.hostComponents').filterProperty('isMaster').forEach (function (hostComponent){
-          options.push({action: 'reassignMaster', context: hostComponent, 'label': Em.I18n.t('services.service.actions.reassign.master').format(hostComponent.get('displayName'))});
-        })
+        if (App.supports.reassignMaster) {
+          this.get('controller.content.hostComponents').filterProperty('isMaster').forEach (function (hostComponent){
+            options.push({action: 'reassignMaster', context: hostComponent, 'label': Em.I18n.t('services.service.actions.reassign.master').format(hostComponent.get('displayName'))});
+          })
+        }
         break;
       case 'HIVE':
         options.push({action: 'runSmokeTest', 'label': Em.I18n.t('services.service.actions.run.smoke')});
-        options.push({action: 'reassignMaster', context: App.HostComponent.find().findProperty('componentName', 'HIVE_METASTORE'), 'label': Em.I18n.t('services.service.actions.reassign.master').format(App.HostComponent.find().findProperty('componentName', 'HIVE_METASTORE').get('displayName'))});
-        options.push({action: 'reassignMaster', context: App.HostComponent.find().findProperty('componentName', 'HIVE_SERVER'), 'label': Em.I18n.t('services.service.actions.reassign.master.hive')});
+        if (App.supports.reassignMaster) {
+          options.push({action: 'reassignMaster', context: App.HostComponent.find().findProperty('componentName', 'HIVE_METASTORE'), 'label': Em.I18n.t('services.service.actions.reassign.master').format(App.HostComponent.find().findProperty('componentName', 'HIVE_METASTORE').get('displayName'))});
+          options.push({action: 'reassignMaster', context: App.HostComponent.find().findProperty('componentName', 'HIVE_SERVER'), 'label': Em.I18n.t('services.service.actions.reassign.master.hive')});
+        }
         break;
       case 'WEBHCAT':
         options.push({action: 'runSmokeTest', 'label': Em.I18n.t('services.service.actions.run.smoke')});
-        options.push({action: 'reassignMaster', context: App.HostComponent.find().findProperty('componentName', 'HIVE_SERVER'), 'label': Em.I18n.t('services.service.actions.reassign.master.hive')});
+        if (App.supports.reassignMaster) {
+          options.push({action: 'reassignMaster', context: App.HostComponent.find().findProperty('componentName', 'HIVE_SERVER'), 'label': Em.I18n.t('services.service.actions.reassign.master.hive')});
+        }
         break;
       case 'HUE':
         options.push({action: 'runSmokeTest', 'label': Em.I18n.t('services.service.actions.run.smoke')});
@@ -51,9 +57,11 @@ App.MainServiceItemView = Em.View.extend({
       default:
         var components = this.get('controller.content.hostComponents');
         options.push({action: 'runSmokeTest', 'label': Em.I18n.t('services.service.actions.run.smoke')});
-        components.filterProperty('isMaster').mapProperty('displayName').uniq().forEach (function (hostComponent){
-          options.push({action: 'reassignMaster', context: components.findProperty('displayName', hostComponent), 'label': Em.I18n.t('services.service.actions.reassign.master').format(hostComponent)});
-        })
+        if (App.supports.reassignMaster) {
+          components.filterProperty('isMaster').mapProperty('displayName').uniq().forEach (function (hostComponent){
+            options.push({action: 'reassignMaster', context: components.findProperty('displayName', hostComponent), 'label': Em.I18n.t('services.service.actions.reassign.master').format(hostComponent)});
+          })
+        }
     }
     return options;
   }.property('controller.content'),