Repository: ambari
Updated Branches:
  refs/heads/trunk dd218d20b -> ce407e621


AMBARI-11065. Make sure that KMS related configs are updated when a new KMS is 
added to the cluster (akovalenko)


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

Branch: refs/heads/trunk
Commit: ce407e6216b0f9d4154d3bcebe10d9d21c003dd4
Parents: dd218d2
Author: Aleksandr Kovalenko <akovale...@hortonworks.com>
Authored: Tue May 12 17:37:33 2015 +0300
Committer: Aleksandr Kovalenko <akovale...@hortonworks.com>
Committed: Tue May 12 18:06:41 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 168 +++++++++++--------
 ambari-web/app/controllers/main/service/item.js |   4 +-
 ambari-web/app/messages.js                      |   5 +-
 .../main/host/details/deleteComponentPopup.hbs  |  22 ++-
 4 files changed, 123 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ce407e62/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 15df59f..02d02ad 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -239,6 +239,12 @@ App.MainHostDetailsController = Em.Controller.extend({
       deleteNimbusMsg: Em.View.extend({
         template: 
Em.Handlebars.compile(Em.I18n.t('hosts.host.deleteComponent.popup.deleteNimbus'))
       }),
+      isRangerKMSServer: function () {
+        return componentName == 'RANGER_KMS_SERVER';
+      }.property(),
+      deleteRangerKMSServereMsg: Em.View.extend({
+        template: 
Em.Handlebars.compile(Em.I18n.t('hosts.host.deleteComponent.popup.deleteRangerKMSServer'))
+      }),
       isChecked: false,
       disablePrimary: function () {
         return !this.get('isChecked');
@@ -338,6 +344,9 @@ App.MainHostDetailsController = Em.Controller.extend({
     } else if(data.componentName == 'NIMBUS') {
       this.set('deleteNimbusHost', true);
       this.loadConfigs('loadStormConfigs');
+    } else if(data.componentName == 'RANGER_KMS_SERVER') {
+      this.set('deleteRangerKMSServer', true);
+      this.loadConfigs('loadRangerConfigs');
     }
   },
 
@@ -456,11 +465,10 @@ App.MainHostDetailsController = Em.Controller.extend({
     var
       returnFunc,
       self = this,
-      hiveHost = event.hiveMetastoreHost ? event.hiveMetastoreHost : "";
       component = event.context,
-      hostName = this.get('content.hostName'),
+      hostName = event.selectedHost || this.get('content.hostName'),
       componentName = component.get('componentName'),
-      missedComponents = !!hiveHost ? [] : 
componentsUtils.checkComponentDependencies(componentName, {
+      missedComponents = event.selectedHost ? [] : 
componentsUtils.checkComponentDependencies(componentName, {
         scope: 'host',
         installedComponents: 
this.get('content.hostComponents').mapProperty('componentName')
       });
@@ -480,7 +488,7 @@ App.MainHostDetailsController = Em.Controller.extend({
         break;
       case 'HIVE_METASTORE':
         returnFunc = App.showConfirmationPopup(function () {
-          self.set('hiveMetastoreHost', hiveHost);
+          self.set('hiveMetastoreHost', hostName);
           self.loadConfigs("loadHiveConfigs");
         }, Em.I18n.t('hosts.host.addComponent.' + componentName ));
         break;
@@ -490,6 +498,12 @@ App.MainHostDetailsController = Em.Controller.extend({
             self.loadConfigs("loadStormConfigs");
         }, Em.I18n.t('hosts.host.addComponent.' + componentName));
         break;
+      case 'RANGER_KMS_SERVER':
+        returnFunc = App.showConfirmationPopup(function() {
+          self.set('rangerKMSServerHost', hostName);
+          self.loadConfigs("loadRangerConfigs");
+        }, Em.I18n.t('hosts.host.addComponent.' + componentName));
+        break;
       default:
         returnFunc = this.addClientComponent(component);
       }
@@ -698,59 +712,9 @@ App.MainHostDetailsController = Em.Controller.extend({
                }
            }
        ];
-    this.saveStormConfigsBatch(groups, nimbusHost);
+    this.saveConfigsBatch(groups, 'NIMBUS', nimbusHost);
    },
 
-     /**
-   * save configs' sites in batch
-   * @param nimbusHost
-   * @param groups
-   */
-  saveStormConfigsBatch: function (groups, nimbusHost) {
-    groups.forEach(function (group) {
-      var desiredConfigs = [],
-        tag = 'version' + (new Date).getTime(),
-        properties = group.properties;
-
-      for (var site in properties) {
-        if (!properties.hasOwnProperty(site) || Em.isNone(properties[site])) 
continue;
-        desiredConfigs.push({
-          "type": site,
-          "tag": tag,
-          "properties": properties[site],
-          "properties_attributes": group.properties_attributes[site],
-          "service_config_version_note": 
Em.I18n.t('hosts.host.storm.configs.save.note')
-        });
-      }
-      if (desiredConfigs.length > 0) {
-        App.ajax.send({
-          name: 'common.service.configurations',
-          sender: this,
-          data: {
-            desired_config: desiredConfigs,
-            stormNimbusHost: nimbusHost
-          },
-          success: 'installStormNimbus'
-        });
-      }
-      //clear nimbus host not to send second request to install component
-      nimbusHost = null;
-    }, this);
-  },
-
-  /**
-   * success callback for saveStormConfigsBatch method
-   * @param data
-   * @param opt
-   * @param params
-   */
-  installStormNimbus: function(data, opt, params) {
-    if (params.stormNimbusHost) {
-      componentsUtils.installHostComponent(params.stormNimbusHost, 
App.StackServiceComponent.find("NIMBUS"));
-    }
-  },
-  /**
-
   /**
    * Success callback for load configs request
    * @param {object} data
@@ -825,15 +789,15 @@ App.MainHostDetailsController = Em.Controller.extend({
         }
       }
     ];
-    this.saveConfigsBatch(groups, hiveMetastoreHost);
+    this.saveConfigsBatch(groups, 'HIVE_METASTORE', hiveMetastoreHost);
   },
 
   /**
    * save configs' sites in batch
-   * @param hiveMetastoreHost
+   * @param host
    * @param groups
    */
-  saveConfigsBatch: function (groups, hiveMetastoreHost) {
+  saveConfigsBatch: function (groups, componentName, host) {
     groups.forEach(function (group) {
       var desiredConfigs = [],
         tag = 'version' + (new Date).getTime(),
@@ -846,7 +810,7 @@ App.MainHostDetailsController = Em.Controller.extend({
           "tag": tag,
           "properties": properties[site],
           "properties_attributes": group.properties_attributes[site],
-          "service_config_version_note": 
Em.I18n.t('hosts.host.hive.configs.save.note')
+          "service_config_version_note": 
Em.I18n.t('hosts.host.configs.save.note').format(App.format.role(componentName))
         });
       }
       if (desiredConfigs.length > 0) {
@@ -855,13 +819,14 @@ App.MainHostDetailsController = Em.Controller.extend({
           sender: this,
           data: {
             desired_config: desiredConfigs,
-            hiveMetastoreHost: hiveMetastoreHost
+            componentName: componentName,
+            host: host
           },
-          success: 'installHiveMetastore'
+          success: 'installHostComponent'
         });
       }
       //clear hive metastore host not to send second request to install 
component
-      hiveMetastoreHost = null;
+      host = null;
     }, this);
   },
 
@@ -871,9 +836,9 @@ App.MainHostDetailsController = Em.Controller.extend({
    * @param opt
    * @param params
    */
-  installHiveMetastore: function(data, opt, params) {
-    if (params.hiveMetastoreHost) {
-      componentsUtils.installHostComponent(params.hiveMetastoreHost, 
App.StackServiceComponent.find("HIVE_METASTORE"));
+  installHostComponent: function(data, opt, params) {
+    if (params.host) {
+      componentsUtils.installHostComponent(params.host, 
App.StackServiceComponent.find(params.componentName));
     }
   },
   /**
@@ -901,6 +866,77 @@ App.MainHostDetailsController = Em.Controller.extend({
   },
 
   /**
+   * Success callback for load configs request
+   * @param {object} data
+   * @method loadHiveConfigs
+   */
+  loadRangerConfigs: function (data) {
+    App.ajax.send({
+      name: 'admin.get.all_configurations',
+      sender: this,
+      data: {
+        urlParams: '(type=core-site&tag=' + 
data.Clusters.desired_configs['core-site'].tag + ')|(type=hdfs-site&tag=' + 
data.Clusters.desired_configs['hdfs-site'].tag + ')|(type=kms-env&tag=' + 
data.Clusters.desired_configs['kms-env'].tag + ')'
+      },
+      success: 'onLoadRangerConfigs'
+    });
+  },
+
+  /**
+   * update and save Hive hive.metastore.uris config to server
+   * @param {object} data
+   * @method onLoadHiveConfigs
+   */
+  onLoadRangerConfigs: function (data) {
+    var hostToInstall = this.get('rangerKMSServerHost');
+    var rkmsHosts = this.getRangerKMSServerHosts();
+    var rkmsPort = data.items.findProperty('type', 
'kms-env').properties['kms_port'];
+    var coreSiteConfigs = data.items.findProperty('type', 'core-site');
+    var hdfsSiteConfigs = data.items.findProperty('type', 'core-site');
+    var groups = [
+      {
+        properties: {
+          'core-site': coreSiteConfigs.properties,
+          'hdfs-site': hdfsSiteConfigs.properties
+        },
+        properties_attributes: {
+          'core-site': coreSiteConfigs.properties_attributes,
+          'hdfs-site': hdfsSiteConfigs.properties_attributes
+        }
+      }
+    ];
+
+    for (var i = 0; i < rkmsHosts.length; i++) {
+      rkmsHosts[i] = rkmsHosts[i] + ':' + rkmsPort;
+    }
+    coreSiteConfigs.properties['hadoop.security.key.provider.path'] = 
'kms://http@' + rkmsHosts.join(',') + '/kms';
+    hdfsSiteConfigs.properties['dfs.encryption.key.provider.uri'] = 
'kms://http@' + rkmsHosts.join(',') + '/kms';
+    this.saveConfigsBatch(groups, 'RANGER_KMS_SERVER', hostToInstall);
+  },
+
+  /**
+   * Delete Hive Metastore is performed
+   * @type {bool}
+   */
+  deleteRangerKMSServer: false,
+
+  getRangerKMSServerHosts: function () {
+    var rkmsHosts = App.HostComponent.find().filterProperty('componentName', 
'RANGER_KMS_SERVER').mapProperty('hostName');
+    var rangerKMSServerHost = this.get('rangerKMSServerHost');
+
+    if(!!rangerKMSServerHost){
+      rkmsHosts.push(rangerKMSServerHost);
+      this.set('rangerKMSServerHost', '');
+    }
+
+    if (this.get('fromDeleteHost') || this.get('deleteRangerKMSServer')) {
+      this.set('deleteRangerKMSServer', false);
+      this.set('fromDeleteHost', false);
+      return rkmsHosts.without(this.get('content.hostName'));
+    }
+    return rkmsHosts.sort();
+  },
+
+  /**
    * Delete Storm Nimbus is performed
    * @type {bool}
    */
@@ -1099,7 +1135,7 @@ App.MainHostDetailsController = Em.Controller.extend({
         }
       );
     }
-    this.saveConfigsBatch(groups);
+    this.saveConfigsBatch(groups, 'ZOOKEEPER_SERVER');
   },
   /**
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/ce407e62/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js 
b/ambari-web/app/controllers/main/service/item.js
index 18b53aa..62f28e3 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -683,11 +683,11 @@ App.MainServiceItemController = Em.Controller.extend({
         var selectedHost = this.get('selectedHost');
 
         // Install
-        if(component.get('componentName') == "HIVE_METASTORE" && 
!!selectedHost){
+        if(['HIVE_METASTORE', 
'RANGER_KMS_SERVER'].contains(component.get('componentName')) && 
!!selectedHost){
           App.router.get('mainHostDetailsController').addComponent(
             {
               context: component,
-              hiveMetastoreHost: selectedHost
+              selectedHost: selectedHost
             }
           );
         } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ce407e62/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 74e98fb..0f33660 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2156,12 +2156,15 @@ Em.I18n.translations = {
   'host.host.componentFilter.client':'Client Components',
   'hosts.host.deleteComponent.popup.msg1':'Are you sure you want to delete 
{0}?',
   'hosts.host.deleteComponent.popup.deleteZooKeeperServer':'Deleting 
<i>ZooKeeper Server</i> 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><li>hive.cluster.delegation.token.store.zookeeper.connectString</li></ul>',
+  'hosts.host.deleteComponent.popup.deleteRangerKMSServer': 'Deleting 
<i>Ranger KMS Server</i> may reconfigure such 
properties:<ul><li>hadoop.security.key.provider.path</li><li>dfs.encryption.key.provider.uri</li>',
   'hosts.host.deleteComponent.popup.warning':'<b>WARNING!</b> Delete the last 
<i>{0}</i> component in the cluster?</br>Deleting the last component in the 
cluster could result in permanent loss of service data.',
   'hosts.host.deleteComponent.popup.confirm':'Confirm Delete',
   'hosts.host.installComponent.popup.confirm':'Confirm Install',
   'hosts.host.installComponent.msg':'Are you sure you want to install {0}?',
   'hosts.host.addComponent.msg':'Are you sure you want to add {0}?',
   'hosts.host.addComponent.ZOOKEEPER_SERVER':'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><li>hive.cluster.delegation.token.store.zookeeper.connectString</li></ul>',
+  'hosts.host.addComponent.NIMBUS': 'Adding Nimbus will reconfigure the 
<b>nimbus.seeds</b> property if it is defined.',
+  'hosts.host.addComponent.RANGER_KMS_SERVER': 'Adding Ranger KMS Server may 
reconfigure such 
properties:<ul><li>hadoop.security.key.provider.path</li><li>dfs.encryption.key.provider.uri</li>',
   '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><li>hive.cluster.delegation.token.store.zookeeper.connectString</li></ul>',
   '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',
@@ -2188,7 +2191,7 @@ Em.I18n.translations = {
   'hosts.host.decommissioning':'Decommissioning',
   'hosts.host.addComponent.HIVE_METASTORE':'Adding <i>Hive Metastore</i> will 
reconfigure such 
properties:<ul><li>hive.metastore.uris</li><li>templeton.hive.properties</li></ul>',
   'hosts.host.deleteComponent.popup.deleteHiveMetastore':'Deleting <i>Hive 
Metastore</i> will reconfigure such 
properties:<ul><li>hive.metastore.uris</li><li>templeton.hive.properties</li></ul>',
-  'hosts.host.hive.configs.save.note': 'This configuration is created by 
ambari while installing/deleting hive component on a host',
+  'hosts.host.configs.save.note': 'This configuration is created by ambari 
while installing/deleting {0} component on a host',
 
   'hosts.component.passive.implied.host.mode.tooltip':'Cannot Turn Off 
Maintenance Mode because Host is in Maintenance Mode',
   'hosts.component.passive.implied.service.mode.tooltip':'Cannot Turn Off 
Maintenance Mode because {0} is in Maintenance Mode',

http://git-wip-us.apache.org/repos/asf/ambari/blob/ce407e62/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs 
b/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs
index dd6f385..d157aa9 100644
--- a/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs
+++ b/ambari-web/app/templates/main/host/details/deleteComponentPopup.hbs
@@ -16,18 +16,26 @@
 * limitations under the License.
 }}
 
-{{deleteComponentMsg}}<br /><br />
+{{deleteComponentMsg}}<br/><br/>
 {{#if lastComponent}}
-    <div class="alert-error row-fluid">
-        <div class='tinyspan tinyoffset'>{{view Ember.Checkbox 
checkedBinding="isChecked"}}</div>
-        <div class='span10'>{{view lastComponentError}}</div>
-    </div>
+  <div class="alert-error row-fluid">
+    <div class='tinyspan tinyoffset'>{{view Ember.Checkbox 
checkedBinding="isChecked"}}</div>
+    <div class='span10'>{{view lastComponentError}}</div>
+  </div>
 {{/if}}
 {{#if isZkServer}}
-  <br />
+  <br/>
   <div class='alert'>{{view deleteZkServerMsg}}</div>
 {{/if}}
 {{#if isHiveMetastore}}
-  <br />
+  <br/>
   <div class='alert'>{{view deleteHiveMetastoreMsg}}</div>
+{{/if}}
+{{#if isNimbus}}
+  <br/>
+  <div class='alert'>{{view deleteNimbusMsg}}</div>
+{{/if}}
+{{#if isRangerKMSServer}}
+  <br/>
+  <div class='alert'>{{view deleteRangerKMSServereMsg}}</div>
 {{/if}}
\ No newline at end of file

Reply via email to