From 703fa1b141a98449746bd6fb3b144e74d964d1f5 Mon Sep 17 00:00:00 2001 From: Jian He Date: Thu, 13 Aug 2015 16:02:57 -0700 Subject: [PATCH] YARN-4047. ClientRMService getApplications has high scheduler lock contention. Contributed by Jason Lowe (cherry picked from commit 7a445fcfabcf9c6aae219051f65d3f6cb8feb87c) --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../yarn/server/resourcemanager/ClientRMService.java | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index aa936333ed3..09469e34227 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -714,6 +714,9 @@ Release 2.8.0 - UNRELEASED YARN-4005. Completed container whose app is finished is possibly not removed from NMStateStore. (Jun Gong via jianhe) + YARN-4047. ClientRMService getApplications has high scheduler lock contention. + (Jason Lowe via jianhe) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java index 0ef43888dab..e88f9678df6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java @@ -751,13 +751,9 @@ public class ClientRMService extends AbstractService implements RMApp application = appsIter.next(); // Check if current application falls under the specified scope - boolean allowAccess = checkAccess(callerUGI, application.getUser(), - ApplicationAccessType.VIEW_APP, application); if (scope == ApplicationsRequestScope.OWN && !callerUGI.getUserName().equals(application.getUser())) { continue; - } else if (scope == ApplicationsRequestScope.VIEWABLE && !allowAccess) { - continue; } if (applicationTypes != null && !applicationTypes.isEmpty()) { @@ -806,6 +802,13 @@ public class ClientRMService extends AbstractService implements } } + // checkAccess can grab the scheduler lock so call it last + boolean allowAccess = checkAccess(callerUGI, application.getUser(), + ApplicationAccessType.VIEW_APP, application); + if (scope == ApplicationsRequestScope.VIEWABLE && !allowAccess) { + continue; + } + reports.add(application.createAndGetApplicationReport( callerUGI.getUserName(), allowAccess)); }