HBASE-27708 CPU hot-spot resolving User subject
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
dbb78388e5
commit
59434e9cd4
|
@ -270,20 +270,28 @@ public abstract class User {
|
|||
public static final class SecureHadoopUser extends User {
|
||||
private String shortName;
|
||||
private LoadingCache<String, String[]> cache;
|
||||
/**
|
||||
* Cache value of this instance's {@link #toString()} value. Computing this value is expensive.
|
||||
* Assumes the UGI is never updated. See HBASE-27708.
|
||||
*/
|
||||
private final String toString;
|
||||
|
||||
public SecureHadoopUser() throws IOException {
|
||||
ugi = UserGroupInformation.getCurrentUser();
|
||||
this.cache = null;
|
||||
this.toString = ugi.toString();
|
||||
}
|
||||
|
||||
public SecureHadoopUser(UserGroupInformation ugi) {
|
||||
this.ugi = ugi;
|
||||
this.cache = null;
|
||||
this.toString = ugi.toString();
|
||||
}
|
||||
|
||||
public SecureHadoopUser(UserGroupInformation ugi, LoadingCache<String, String[]> cache) {
|
||||
this.ugi = ugi;
|
||||
this.cache = cache;
|
||||
this.toString = ugi.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -320,6 +328,11 @@ public abstract class User {
|
|||
return ugi.doAs(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a user for testing.
|
||||
* @see User#createUserForTesting(org.apache.hadoop.conf.Configuration, String, String[])
|
||||
|
|
Loading…
Reference in New Issue