HBASE-19338 Performance regression in RegionServerRpcQuotaManager to get ugi
This commit is contained in:
parent
749361e304
commit
a62010c9e7
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue