瀏覽代碼

AMBARI-7521 Adding a component to a host should check for the presence of host scope dependencies of that component. (Buzhor Denys via atkach)

atkach 10 年之前
父節點
當前提交
e7ce4bb6fd
共有 3 個文件被更改,包括 23 次插入1 次删除
  1. 9 1
      ambari-web/app/controllers/main/host/details.js
  2. 2 0
      ambari-web/app/messages.js
  3. 12 0
      ambari-web/app/utils/components.js

+ 9 - 1
ambari-web/app/controllers/main/host/details.js

@@ -19,6 +19,7 @@
 var App = require('app');
 var batchUtils = require('utils/batch_scheduled_requests');
 var componentsUtils = require('utils/components');
+var stringUtils = require('utils/string_utils');
 
 App.MainHostDetailsController = Em.Controller.extend({
 
@@ -392,7 +393,14 @@ App.MainHostDetailsController = Em.Controller.extend({
     var self = this;
     var component = event.context;
     var componentName = component.get('componentName');
-
+    var missedComponents = componentsUtils.checkComponentDependencies(componentName, this.get('content.hostComponents').mapProperty('componentName'))
+    if (!!missedComponents.length) {
+      var popupMessage = Em.I18n.t('host.host.addComponent.popup.dependedComponents.body').format(component.get('displayName'),
+        stringUtils.getFormattedStringFromArray(missedComponents.map(function(cName) {
+          return App.StackServiceComponent.find(cName).get('displayName');
+        })));
+      return App.showAlertPopup(Em.I18n.t('host.host.addComponent.popup.dependedComponents.header'), popupMessage);
+    }
     if (componentName === 'ZOOKEEPER_SERVER') {
       return App.showConfirmationPopup(function () {
         self.primary(component);

+ 2 - 0
ambari-web/app/messages.js

@@ -1709,6 +1709,8 @@ Em.I18n.translations = {
   'hosts.host.addComponent.msg':'Are you sure you want to add {0}?',
   'hosts.host.addComponent.addZooKeeper':'Adding ZooKeeper Server may reconfigure such properties:<ul><li>ha.zookeeper.quorum</li><li>hbase.zookeeper.quorum</li><li>templeton.zookeeper.hosts</li><li>yarn.resourcemanager.zk-address</li><li>hive.zookeeper.quorum</li></ul>',
   'hosts.host.addComponent.deleteHostWithZooKeeper':'Deleting host with ZooKeeper Server may reconfigure such properties:<ul><li>ha.zookeeper.quorum</li><li>hbase.zookeeper.quorum</li><li>templeton.zookeeper.hosts</li><li>yarn.resourcemanager.zk-address</li><li>hive.zookeeper.quorum</li></ul>',
+  'host.host.addComponent.popup.dependedComponents.body': '{0} requires {1} to be installed along with it. Please add them first and then try adding {0}',
+  'host.host.addComponent.popup.dependedComponents.header': 'Component dependencies',
   'hosts.host.zooKeeper.configs.save.note': 'This configuration is created by ambari while installing/deleting zookeeper component on a host',
   'hosts.host.addComponent.note':'<b>Important:</b> After this <i>{0}</i> is installed, go to <i>Services -> Nagios</i> to restart the Nagios service.  This is required for the alerts and notifications to work properly.',
   'hosts.host.addComponent.securityNote':'You are running your cluster in secure mode. You must set up the keytab for {0} on {1} before you proceed. Otherwise, the component will not be able to start properly.',

+ 12 - 0
ambari-web/app/utils/components.js

@@ -134,6 +134,18 @@ module.exports = {
       var newWindow = window.open(url);
       newWindow.focus();
     }
+  },
+  /**
+   * Check if all required components are installed on host.
+   *
+   * @param {String} componentName
+   * @param {Array} installedComponentNames
+   * @return {Array} - names of missed components
+   */
+  checkComponentDependencies: function(componentName, installedComponentNames) {
+    return App.StackServiceComponent.find(componentName).get('dependencies').filter(function(dependency) {
+      return !installedComponentNames.contains(dependency)
+    });
   }
 
 };