hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From binli...@apache.org
Subject hbase git commit: HBASE-19338 Performance regression in RegionServerRpcQuotaManager to get ugi
Date Tue, 28 Nov 2017 01:57:47 GMT
Repository: hbase
Updated Branches:
  refs/heads/master b048207c8 -> 3863559b0


HBASE-19338 Performance regression in RegionServerRpcQuotaManager to get ugi


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3863559b
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3863559b
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3863559b

Branch: refs/heads/master
Commit: 3863559b07fe19ff72f4cf5a326be7e09e70609c
Parents: b048207
Author: binlijin <binlijin@gmail.com>
Authored: Tue Nov 28 09:57:35 2017 +0800
Committer: binlijin <binlijin@gmail.com>
Committed: Tue Nov 28 09:57:35 2017 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/quotas/RegionServerRpcQuotaManager.java  | 10 ++++++++--
 .../hadoop/hbase/security/access/AccessController.java    |  7 ++++++-
 .../hadoop/hbase/security/visibility/VisibilityUtils.java |  9 ++++++++-
 3 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/3863559b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/RegionServerRpcQuotaManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/RegionServerRpcQuotaManager.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/RegionServerRpcQuotaManager.java
index 69253d7..51b8cc9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/RegionServerRpcQuotaManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/RegionServerRpcQuotaManager.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.quotas;
 
 import java.io.IOException;
 import java.util.List;
+import java.util.Optional;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -33,7 +34,6 @@ import org.apache.hadoop.hbase.regionserver.Region;
 import org.apache.hadoop.hbase.regionserver.RegionServerServices;
 import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.security.UserGroupInformation;
-
 import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTesting;
 
 /**
@@ -176,7 +176,13 @@ public class RegionServerRpcQuotaManager {
   private OperationQuota checkQuota(final Region region,
       final int numWrites, final int numReads, final int numScans)
       throws IOException, ThrottlingException {
-    UserGroupInformation ugi = RpcServer.getRequestUser().orElse(User.getCurrent()).getUGI();
+    Optional<User> user = RpcServer.getRequestUser();
+    UserGroupInformation ugi;
+    if (user.isPresent()) {
+      ugi = user.get().getUGI();
+    } else {
+      ugi = User.getCurrent().getUGI();
+    }
     TableName table = region.getTableDescriptor().getTableName();
 
     OperationQuota quota = getQuota(ugi, table);

http://git-wip-us.apache.org/repos/asf/hbase/blob/3863559b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
index b921937..f2b7541 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
@@ -429,7 +429,12 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
    */
   private User getActiveUser(ObserverContext<?> ctx) throws IOException {
     // for non-rpc handling, fallback to system user
-    return ctx.getCaller().orElse(userProvider.getCurrent());
+    Optional<User> optionalUser = ctx.getCaller();
+    User user;
+    if (optionalUser.isPresent()) {
+      return optionalUser.get();
+    }
+    return userProvider.getCurrent();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/3863559b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityUtils.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityUtils.java
index 7d141e7..3db8d0e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityUtils.java
@@ -31,6 +31,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.Set;
 
 import org.apache.commons.lang3.StringUtils;
@@ -282,7 +283,13 @@ public class VisibilityUtils {
    * @throws IOException When there is IOE in getting the system user (During non-RPC handling).
    */
   public static User getActiveUser() throws IOException {
-    User user = RpcServer.getRequestUser().orElse(User.getCurrent());
+    Optional<User> optionalUser = RpcServer.getRequestUser();
+    User user;
+    if (optionalUser.isPresent()) {
+      user = optionalUser.get();
+    } else {
+      user = User.getCurrent();
+    }
     if (LOG.isTraceEnabled()) {
       LOG.trace("Current active user name is " + user.getShortName());
     }


Mime
View raw message