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/3c256b18 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3c256b18 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3c256b18 Branch: refs/heads/branch-feature-AMBARI-21450 Commit: 3c256b18aa86db51cd808f03caf708d6df0ff812 Parents: 7711642 Author: Andrii Tkach <atk...@apache.org> Authored: Mon Aug 7 14:08:17 2017 +0300 Committer: Andrii Tkach <atk...@apache.org> Committed: Mon Aug 7 14:08:17 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/3c256b18/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 31c8e9f..e8303f3 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -104,6 +104,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', @@ -1104,6 +1109,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 @@ -1579,6 +1630,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