ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-7521 Adding a component to a host should check for the presence of host scope dependencies of that component, second patch. (Buzhor Denys via atkach)
Date Mon, 29 Sep 2014 15:49:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 377280bf3 -> 7faf263af


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


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7faf263a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7faf263a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7faf263a

Branch: refs/heads/trunk
Commit: 7faf263af1d16d929b6dd06dba12208d2417a202
Parents: 377280b
Author: atkach <atkach@hortonworks.com>
Authored: Mon Sep 29 18:45:53 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Mon Sep 29 18:49:25 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js |  5 ++-
 .../app/controllers/wizard/step8_controller.js  |  2 +-
 ambari-web/app/mappers/stack_service_mapper.js  |  7 +++--
 ambari-web/app/messages.js                      |  2 +-
 ambari-web/app/utils/ajax/ajax.js               |  2 +-
 ambari-web/app/utils/components.js              | 33 +++++++++++++++++---
 ambari-web/app/utils/helper.js                  | 15 +++++++++
 7 files changed, 55 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7faf263a/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index 2116ff5..3fad22e 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -393,7 +393,10 @@ 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'))
+    var missedComponents = componentsUtils.checkComponentDependencies(componentName, {
+      scope: 'host',
+      installedComponents: 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) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/7faf263a/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 185420a..b975f01 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1154,7 +1154,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs,
{
     clientNames.forEach(function (clientName) {
       clientsMap[clientName] = Em.A([]);
       dependedComponents.forEach(function (component) {
-        if (component.get('dependencies').contains(clientName)) clientsMap[clientName].push(component.get('componentName'));
+        if (component.get('dependencies').mapProperty('componentName').contains(clientName))
clientsMap[clientName].push(component.get('componentName'));
       });
       if (!clientsMap[clientName].length) delete clientsMap[clientName];
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/7faf263a/ambari-web/app/mappers/stack_service_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/stack_service_mapper.js b/ambari-web/app/mappers/stack_service_mapper.js
index 04860b5..1732549 100644
--- a/ambari-web/app/mappers/stack_service_mapper.js
+++ b/ambari-web/app/mappers/stack_service_mapper.js
@@ -58,7 +58,7 @@ App.stackServiceMapper = App.QuickDataMapper.create({
     dependencies_key: 'dependencies',
     dependencies_type: 'array',
     dependencies: {
-      item: 'Dependencies.component_name'
+      item: 'Dependencies'
     }
   },
 
@@ -80,8 +80,11 @@ App.stackServiceMapper = App.QuickDataMapper.create({
         var stackService = item.StackServices;
         var serviceComponents = [];
         item.serviceComponents.forEach(function (serviceComponent) {
+          var dependencies = serviceComponent.dependencies.map(function(dependecy) {
+            return { Dependencies: App.keysUnderscoreToCamelCase(App.permit(dependecy.Dependencies,
['component_name', 'scope'])) };
+          });
           serviceComponent.StackServiceComponents.id = serviceComponent.StackServiceComponents.component_name;
-          serviceComponent.StackServiceComponents.dependencies = serviceComponent.dependencies;
+          serviceComponent.StackServiceComponents.dependencies = dependencies;
           serviceComponents.push(serviceComponent.StackServiceComponents);
           stackServiceComponents.push(this.parseIt(serviceComponent.StackServiceComponents,
this.get('component_config')));
         }, this);

http://git-wip-us.apache.org/repos/asf/ambari/blob/7faf263a/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index c8e94a9..f5cfb9b 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1709,7 +1709,7 @@ 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.body': '{0} requires {1} to be installed
along with it on the same host. 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.',

http://git-wip-us.apache.org/repos/asf/ambari/blob/7faf263a/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index c591d22..de41194 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1094,7 +1094,7 @@ var urls = {
     }
   },
   'wizard.service_components': {
-    'real': '{stackUrl}/services?fields=StackServices/*,serviceComponents/*',
+    'real': '{stackUrl}/services?fields=StackServices/*,serviceComponents/*,serviceComponents/dependencies/Dependencies/scope',
     'mock': '/data/stacks/HDP-2.1/service_components.json',
     'format': function(data) {
       return {

http://git-wip-us.apache.org/repos/asf/ambari/blob/7faf263a/ambari-web/app/utils/components.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/components.js b/ambari-web/app/utils/components.js
index 63c5348..7bb4ae3 100644
--- a/ambari-web/app/utils/components.js
+++ b/ambari-web/app/utils/components.js
@@ -137,15 +137,38 @@ module.exports = {
   },
   /**
    * Check if all required components are installed on host.
+   * Available options:
+   *  scope: 'host' - dependency level `host`,`cluster` or `*`.
+   *  hostName: 'example.com' - host name to search installed components
+   *  installedComponents: ['A', 'B'] - names of installed components
+   *
+   * By default scope level is `*`
+   * For host level dependency you should specify at least `hostName` or `installedComponents`
attribute.
    *
    * @param {String} componentName
-   * @param {Array} installedComponentNames
+   * @param {Object} opt - options. Allowed options are `hostName`, `installedComponents`,
`scope`.
    * @return {Array} - names of missed components
    */
-  checkComponentDependencies: function(componentName, installedComponentNames) {
-    return App.StackServiceComponent.find(componentName).get('dependencies').filter(function(dependency)
{
-      return !installedComponentNames.contains(dependency)
-    });
+  checkComponentDependencies: function(componentName, opt) {
+    opt = opt || {};
+    opt.scope = opt.scope || '*';
+    var installedComponents;
+    var dependencies = App.StackServiceComponent.find(componentName).get('dependencies');
+    dependencies = opt.scope === '*' ? dependencies : dependencies.filterProperty('scope',
opt.scope);
+    if (dependencies.length == 0) return [];
+    switch (opt.scope) {
+      case 'host':
+        Em.assert("You should pass at least `hostName` or `installedComponents` to options.",
opt.hostName || opt.installedComponents);
+        installedComponents = opt.installedComponents || App.HostComponent.find().filterProperty('hostName',
opt.hostName).mapProperty('componentName').uniq();
+        break;
+      default:
+        // @todo: use more appropriate value regarding installed components
+        installedComponents = opt.installedComponents || App.HostComponent.find().mapProperty('componentName').uniq();
+        break;
+    }
+    return dependencies.filter(function(dependency) {
+      return !installedComponents.contains(dependency.componentName);
+    }).mapProperty('componentName');
   }
 
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/7faf263a/ambari-web/app/utils/helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js
index 036e03a..b5ce069 100644
--- a/ambari-web/app/utils/helper.js
+++ b/ambari-web/app/utils/helper.js
@@ -15,6 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+var stringUtils = require('utils/string_utils');
 
 /**
  * Remove spaces at beginning and ending of line.
@@ -287,6 +288,20 @@ App.isEmptyObject = function(obj) {
   for (var prop in obj) { if (obj.hasOwnProperty(prop)) {empty = false; break;} }
   return empty;
 }
+
+/**
+ * Convert object under_score keys to camelCase
+ *
+ * @param {Object} object
+ * @return {Object}
+ **/
+App.keysUnderscoreToCamelCase = function(object) {
+  var tmp = {};
+  for (var key in object) {
+    tmp[stringUtils.underScoreToCamelCase(key)] = object[key];
+  }
+  return tmp;
+};
 /**
  * Returns object with defined keys only.
  *


Mime
View raw message