AMBARI-21636 Fix atlas.rest.address property when Atlas is in HA for Atlas-hive 
hook. (atkach)


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

Branch: refs/heads/branch-feature-AMBARI-14714
Commit: 58827ad307f68e2db6f649987a4feae7885944d5
Parents: afa1b48
Author: Andrii Tkach <atk...@apache.org>
Authored: Mon Aug 7 14:40:57 2017 +0300
Committer: Andrii Tkach <atk...@apache.org>
Committed: Mon Aug 7 14:40:57 2017 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 69 ++++++++++++++++++++
 1 file changed, 69 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/58827ad3/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 382b09d..20b14ee 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -110,6 +110,11 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
       configTagsCallbackName: 'loadStormConfigs',
       configsCallbackName: 'onLoadStormConfigs'
     },
+    'ATLAS_SERVER': {
+      deletePropertyName: 'deleteAtlasServer',
+      hostPropertyName: 'atlasServer',
+      configsCallbackName: 'onLoadAtlasConfigs'
+    },
     'RANGER_KMS_SERVER': {
       deletePropertyName: 'deleteRangerKMSServer',
       hostPropertyName: 'rangerKMSServerHost',
@@ -1117,6 +1122,52 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
     }
   },
 
+  onLoadAtlasConfigs: function(data) {
+    var atlasServer = this.get('atlasServer'),
+      atlasServerHosts = this.getAtlasServerHosts(),
+      configs = {},
+      attributes = {},
+      propertiesToChange = this.get('allPropertiesToChange');
+
+    this.saveLoadedConfigs(data);
+    data.items.forEach(function (item) {
+      configs[item.type] = item.properties;
+      attributes[item.type] = item.properties_attributes || {};
+    }, this);
+
+    var atlasAddresses = 
configs['application-properties']['atlas.rest.address'];
+    var hostMask = 
atlasAddresses.split(',')[0].replace(/([https|http]*\:\/\/)(.*?)(:[0-9]+)/, 
'$1{hostname}$3');
+    var atlasAddressesRecommended = atlasServerHosts.map(function(hostName) {
+      return hostMask.replace('{hostname}', hostName);
+    }).join(',');
+    configs['application-properties']['atlas.rest.address'] = 
atlasAddressesRecommended;
+    if (this.get('isReconfigureRequired') && atlasAddresses !== 
atlasAddressesRecommended) {
+      var service = 
App.config.get('serviceByConfigTypeMap')['application-properties'];
+      propertiesToChange.pushObject({
+        propertyFileName: 'application-properties',
+        propertyName: 'atlas.rest.address',
+        serviceDisplayName: service && service.get('displayName'),
+        initialValue: atlasAddresses,
+        recommendedValue: atlasAddressesRecommended
+      });
+    }
+    var groups = [
+      {
+        properties: {
+          'application-properties': configs['application-properties']
+        },
+        properties_attributes: {
+          'application-properties': attributes['application-properties']
+        }
+      }
+    ];
+    if (this.get('isReconfigureRequired')) {
+      this.setConfigsChanges(groups);
+    } else {
+      this.saveConfigsBatch(groups, 'ATLAS_SERVER', atlasServer);
+    }
+  },
+
   /**
    * Success callback for load configs request
    * @param {object} data
@@ -1592,6 +1643,24 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
     return stormNimbusHosts.sort();
   },
 
+  getAtlasServerHosts: function () {
+    var
+      atlasServerHosts = 
App.HostComponent.find().filterProperty('componentName', 
'ATLAS_SERVER').mapProperty('hostName'),
+      atlasServer = this.get('atlasServer');
+
+    if (!!atlasServer) {
+      atlasServerHosts.push(atlasServer);
+      this.set('atlasServer', '');
+    }
+
+    if (this.get('fromDeleteHost') || this.get('deleteAtlasServer')) {
+      this.set('deleteAtlasServer', false);
+      this.set('fromDeleteHost', false);
+      return atlasServerHosts.without(this.get('content.hostName'));
+    }
+    return atlasServerHosts.sort();
+  },
+
   /**
    * Send command to server to resfresh configs of selected component
    * @param {object} event

Reply via email to