ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject ambari git commit: AMBARI-12107. Moving RM on a RM HA enabled cluster does not update the yarn.resourcemanager.webapp.address and yarn.resourcemanager.webapp.https.address. (Di Li via Jaimin)
Date Tue, 07 Jul 2015 23:58:08 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 63164d9b8 -> 978fd3512


AMBARI-12107. Moving RM on a RM HA enabled cluster does not update the yarn.resourcemanager.webapp.address
and yarn.resourcemanager.webapp.https.address. (Di Li via Jaimin)


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

Branch: refs/heads/trunk
Commit: 978fd351293f7d61184095fedffc9169afc34de7
Parents: 63164d9
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Tue Jul 7 16:56:36 2015 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Tue Jul 7 16:57:55 2015 -0700

----------------------------------------------------------------------
 .../main/service/reassign/step4_controller.js   | 38 +++++++++++
 .../service/reassign/step4_controller_test.js   | 67 ++++++++++++++++++--
 2 files changed, 101 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/978fd351/ambari-web/app/controllers/main/service/reassign/step4_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/reassign/step4_controller.js b/ambari-web/app/controllers/main/service/reassign/step4_controller.js
index edc9b8f..4a58804 100644
--- a/ambari-web/app/controllers/main/service/reassign/step4_controller.js
+++ b/ambari-web/app/controllers/main/service/reassign/step4_controller.js
@@ -677,13 +677,51 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro
     if (App.get('isRMHaEnabled')) {
       if (configs['yarn-site']['yarn.resourcemanager.hostname.rm1'] === sourceHostName) {
         configs['yarn-site']['yarn.resourcemanager.hostname.rm1'] = targetHostName;
+        
+        var webAddressPort = this.getWebAddressPort(configs, 'yarn.resourcemanager.webapp.address.rm1');
+        if(webAddressPort != null)
+          configs['yarn-site']['yarn.resourcemanager.webapp.address.rm1'] = targetHostName
+":"+ webAddressPort;
+        
+        var httpsWebAddressPort = this.getWebAddressPort(configs, 'yarn.resourcemanager.webapp.https.address.rm1');
+        if(httpsWebAddressPort != null)
+          configs['yarn-site']['yarn.resourcemanager.webapp.https.address.rm1'] = targetHostName
+":"+ httpsWebAddressPort;
       } else {
         configs['yarn-site']['yarn.resourcemanager.hostname.rm2'] = targetHostName;
+        
+        var webAddressPort = this.getWebAddressPort(configs, 'yarn.resourcemanager.webapp.address.rm2');
+        if(webAddressPort != null)
+          configs['yarn-site']['yarn.resourcemanager.webapp.address.rm2'] = targetHostName
+":"+ webAddressPort;
+        
+        var httpsWebAddressPort = this.getWebAddressPort(configs, 'yarn.resourcemanager.webapp.https.address.rm2');
+        if(httpsWebAddressPort != null)
+          configs['yarn-site']['yarn.resourcemanager.webapp.https.address.rm2'] = targetHostName
+":"+ httpsWebAddressPort;
       }
     }
   },
 
   /**
+   * Get the web address port when RM HA is enabled. 
+   * @param configs
+   * @param webAddressKey (http vs https)
+   * */
+  getWebAddressPort: function (configs, webAddressKey){
+    var result = null;
+    var rmWebAddressValue = configs['yarn-site'][webAddressKey];
+    if(rmWebAddressValue){
+      var tokens = rmWebAddressValue.split(":");
+      if(tokens.length > 1){
+        result = tokens[1];
+        result = result.replace(/^\s+|\s+$/g, '');
+      }
+    }
+    
+    if(result)  //only return non-empty result
+      return result;
+    else
+      return null;
+  },
+  
+  /**
    * set specific configs which applies only to Hive related configs
    * @param configs
    * @param targetHostName

http://git-wip-us.apache.org/repos/asf/ambari/blob/978fd351/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
index 0713abf..849af6e 100644
--- a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
@@ -582,6 +582,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
       sinon.stub(controller, 'setSecureConfigs', Em.K);
       sinon.stub(controller, 'setSpecificNamenodeConfigs', Em.K);
       sinon.stub(controller, 'setSpecificResourceMangerConfigs', Em.K);
+      sinon.stub(controller, 'getWebAddressPort', Em.K);
       sinon.stub(controller, 'getComponentDir', Em.K);
       sinon.stub(controller, 'saveClusterStatus', Em.K);
       sinon.stub(controller, 'saveConfigsToServer', Em.K);
@@ -593,6 +594,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
       controller.setSecureConfigs.restore();
       controller.setSpecificNamenodeConfigs.restore();
       controller.setSpecificResourceMangerConfigs.restore();
+      controller.getWebAddressPort.restore();
       controller.getComponentDir.restore();
       controller.saveClusterStatus.restore();
       controller.saveConfigsToServer.restore();
@@ -813,28 +815,85 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
       isRMHaEnabled = true;
       var configs = {
         'yarn-site': {
-          'yarn.resourcemanager.hostname.rm1': 'host1'
+          'yarn.resourcemanager.hostname.rm1': 'host1',
+          'yarn.resourcemanager.webapp.address.rm1': 'host1:8088',
+          'yarn.resourcemanager.webapp.https.address.rm1': 'host1:8443'
         }
       };
       controller.setSpecificResourceMangerConfigs(configs, 'host2');
       expect(configs['yarn-site']).to.eql({
-        'yarn.resourcemanager.hostname.rm1': 'host2'
+        'yarn.resourcemanager.hostname.rm1': 'host2',
+        'yarn.resourcemanager.webapp.address.rm1': 'host2:8088',
+        'yarn.resourcemanager.webapp.https.address.rm1': 'host2:8443'
       });
     });
     it('HA enabled and resource manager 2', function () {
       isRMHaEnabled = true;
       var configs = {
         'yarn-site': {
-          'yarn.resourcemanager.hostname.rm2': 'host2'
+          'yarn.resourcemanager.hostname.rm2': 'host2',
+          'yarn.resourcemanager.webapp.address.rm2': 'host2:8088',
+          'yarn.resourcemanager.webapp.https.address.rm2': 'host2:8443'
         }
       };
       controller.setSpecificResourceMangerConfigs(configs, 'host1');
       expect(configs['yarn-site']).to.eql({
-        'yarn.resourcemanager.hostname.rm2': 'host1'
+        'yarn.resourcemanager.hostname.rm2': 'host1',
+        'yarn.resourcemanager.webapp.address.rm2': 'host1:8088',
+        'yarn.resourcemanager.webapp.https.address.rm2': 'host1:8443'
       });
     });
   });
 
+  describe('#getWebAddressPort', function(){
+    var configs = {
+        'yarn-site': {
+          'yarn.resourcemanager.hostname.rm2': 'host2',
+          'yarn.resourcemanager.webapp.address.rm2': 'host2:8088',
+          'yarn.resourcemanager.webapp.https.address.rm2': 'host2:8443'
+        }
+    };
+    
+    var httpPort = controller.getWebAddressPort(configs, 'yarn.resourcemanager.webapp.address.rm2');
+    expect(httpPort).to.eql('8088');
+    
+    var httpsPort = controller.getWebAddressPort(configs, 'yarn.resourcemanager.webapp.https.address.rm2');
+    expect(httpsPort).to.eql('8443');
+
+    configs = {
+        'yarn-site': {
+          'yarn.resourcemanager.hostname.rm2': 'host2',
+          'yarn.resourcemanager.webapp.address.rm2': 'host2:',
+          'yarn.resourcemanager.webapp.https.address.rm2': 'host2:  '
+        }
+    };
+    
+    //check for falsy conditions
+    httpPort = controller.getWebAddressPort(configs, 'yarn.resourcemanager.webapp.address.rm2');
+    var flag = "falsy"
+    if (httpPort)
+      flag = "truthy"
+    expect(flag).to.eql('falsy')
+
+    httpsPort = controller.getWebAddressPort(configs, 'yarn.resourcemanager.webapp.https.address.rm2');
+    flag = "falsy"
+    if (httpsPort)
+      flag = "truthy"
+    expect(flag).to.eql("falsy")
+
+    configs = {
+        'yarn-site': {
+          'yarn.resourcemanager.hostname.rm2': 'host2'
+        }
+    };
+
+   httpPort = controller.getWebAddressPort(configs, 'yarn.resourcemanager.webapp.address.rm2');
+   var flag = "falsy"
+   if (httpPort != null) //check for null, still part of the falsy condition checks.
+      flag = "truthy"
+    expect(flag).to.eql('falsy')
+  });
+  
   describe('#setSecureConfigs()', function () {
     it('undefined component and security disabled', function () {
       var secureConfigs = [];


Mime
View raw message