HBASE-24872 refactor valueOf PoolType (#2250)
Signed-off-by: Huaxiang Sun <huaxiangsun@apache.com>
This commit is contained in:
parent
35a2875dc1
commit
751b4f040e
@ -281,7 +281,7 @@ public abstract class AbstractRpcClient<T extends RpcConnection> implements RpcC
|
|||||||
*/
|
*/
|
||||||
private static PoolMap.PoolType getPoolType(Configuration config) {
|
private static PoolMap.PoolType getPoolType(Configuration config) {
|
||||||
return PoolMap.PoolType.valueOf(config.get(HConstants.HBASE_CLIENT_IPC_POOL_TYPE),
|
return PoolMap.PoolType.valueOf(config.get(HConstants.HBASE_CLIENT_IPC_POOL_TYPE),
|
||||||
PoolMap.PoolType.RoundRobin, PoolMap.PoolType.ThreadLocal);
|
PoolMap.PoolType.RoundRobin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,6 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@ -230,27 +229,8 @@ public class PoolMap<K, V> implements Map<K, V> {
|
|||||||
public enum PoolType {
|
public enum PoolType {
|
||||||
ThreadLocal, RoundRobin;
|
ThreadLocal, RoundRobin;
|
||||||
|
|
||||||
public static PoolType valueOf(String poolTypeName,
|
public static PoolType valueOf(String poolTypeName, PoolType defaultPoolType) {
|
||||||
PoolType defaultPoolType, PoolType... allowedPoolTypes) {
|
|
||||||
PoolType poolType = PoolType.fuzzyMatch(poolTypeName);
|
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;
|
return (poolType != null) ? poolType : defaultPoolType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user