From a6b06f71797ad1ed9edbcef279bcf7d9e569f955 Mon Sep 17 00:00:00 2001 From: Naganarasimha Date: Thu, 12 Jan 2017 06:40:41 +0530 Subject: [PATCH] YARN-6072. RM unable to start in secure mode. Contributed by Ajith S. --- .../server/resourcemanager/AdminService.java | 2 +- .../resourcemanager/ResourceManager.java | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java index 04ee5d8985..86bb896d88 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java @@ -708,7 +708,7 @@ void refreshAll() throws ServiceFailedException { } refreshClusterMaxPriority(); } catch (Exception ex) { - throw new ServiceFailedException(ex.getMessage()); + throw new ServiceFailedException("RefreshAll operation failed", ex); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java index 0c9d095d6d..886f4abf7c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java @@ -272,15 +272,6 @@ protected void serviceInit(Configuration conf) throws Exception { this.rmContext.setHAEnabled(HAUtil.isHAEnabled(this.conf)); if (this.rmContext.isHAEnabled()) { HAUtil.verifyAndSetConfiguration(this.conf); - - // If the RM is configured to use an embedded leader elector, - // initialize the leader elector. - if (HAUtil.isAutomaticFailoverEnabled(conf) && - HAUtil.isAutomaticFailoverEmbedded(conf)) { - EmbeddedElector elector = createEmbeddedElector(); - addIfService(elector); - rmContext.setLeaderElectorService(elector); - } } // Set UGI and do login @@ -298,10 +289,27 @@ protected void serviceInit(Configuration conf) throws Exception { addIfService(rmDispatcher); rmContext.setDispatcher(rmDispatcher); + // The order of services below should not be changed as services will be + // started in same order + // As elector service needs admin service to be initialized and started, + // first we add admin service then elector service + adminService = createAdminService(); addService(adminService); rmContext.setRMAdminService(adminService); + // elector must be added post adminservice + if (this.rmContext.isHAEnabled()) { + // If the RM is configured to use an embedded leader elector, + // initialize the leader elector. + if (HAUtil.isAutomaticFailoverEnabled(conf) + && HAUtil.isAutomaticFailoverEmbedded(conf)) { + EmbeddedElector elector = createEmbeddedElector(); + addIfService(elector); + rmContext.setLeaderElectorService(elector); + } + } + rmContext.setYarnConfiguration(conf); createAndInitActiveServices(false);