HBASE-24872 refactor valueOf PoolType (#2250)

Signed-off-by: Huaxiang Sun <huaxiangsun@apache.com>
This commit is contained in:
niuyulin 2020-08-18 11:35:18 -05:00 committed by GitHub
parent ea26463a33
commit 998ee77133
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 22 deletions

View File

@ -284,7 +284,7 @@ public abstract class AbstractRpcClient<T extends RpcConnection> implements RpcC
*/
private static PoolMap.PoolType getPoolType(Configuration config) {
return PoolMap.PoolType.valueOf(config.get(HConstants.HBASE_CLIENT_IPC_POOL_TYPE),
PoolMap.PoolType.RoundRobin, PoolMap.PoolType.ThreadLocal);
PoolMap.PoolType.RoundRobin);
}
/**

View File

@ -27,7 +27,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
@ -230,27 +229,8 @@ public class PoolMap<K, V> implements Map<K, V> {
public enum PoolType {
ThreadLocal, RoundRobin;
public static PoolType valueOf(String poolTypeName,
PoolType defaultPoolType, PoolType... allowedPoolTypes) {
public static PoolType valueOf(String poolTypeName, PoolType defaultPoolType) {
PoolType poolType = PoolType.fuzzyMatch(poolTypeName);
if (poolType != null) {
boolean allowedType = false;
if (poolType.equals(defaultPoolType)) {
allowedType = true;
} else {
if (allowedPoolTypes != null) {
for (PoolType allowedPoolType : allowedPoolTypes) {
if (poolType.equals(allowedPoolType)) {
allowedType = true;
break;
}
}
}
}
if (!allowedType) {
poolType = null;
}
}
return (poolType != null) ? poolType : defaultPoolType;
}