|
|
|
package com.fr.plugin.db.redis.core.pool;
|
|
|
|
|
|
|
|
import com.fr.config.ConfigContext;
|
|
|
|
import com.fanruan.api.conf.BaseConfiguration;
|
|
|
|
import com.fanruan.api.conf.HolderKit;
|
|
|
|
|
|
|
|
import javax.xml.ws.Holder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author richie
|
|
|
|
* @version 10.0
|
|
|
|
* Created by richie on 2019-03-21
|
|
|
|
*/
|
|
|
|
public class RedisConnectionPoolConfig extends BaseConfiguration {
|
|
|
|
|
|
|
|
private static volatile RedisConnectionPoolConfig instance = null;
|
|
|
|
|
|
|
|
public static RedisConnectionPoolConfig getInstance() {
|
|
|
|
if (instance == null) {
|
|
|
|
instance = ConfigContext.getConfigInstance(RedisConnectionPoolConfig.class);
|
|
|
|
}
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final int MAX_TOTAL = 10;
|
|
|
|
private static final int MAX_IDLE = 10;
|
|
|
|
private static final int MAX_WAIT = -1;
|
|
|
|
private static final int TIME_OUT = 100 * 1000;
|
|
|
|
|
|
|
|
private HolderKit.Conf<Integer> maxTotal = HolderKit.simple(MAX_TOTAL);
|
|
|
|
private HolderKit.Conf<Integer> maxWait = HolderKit.simple(MAX_WAIT);
|
|
|
|
private HolderKit.Conf<Integer> maxIdle = HolderKit.simple(MAX_IDLE);
|
|
|
|
private HolderKit.Conf<Boolean> blockWhenExhausted = HolderKit.simple(true);
|
|
|
|
private HolderKit.Conf<Boolean> lifo = HolderKit.simple(true);
|
|
|
|
private HolderKit.Conf<Integer> timeout = HolderKit.simple(TIME_OUT);
|
|
|
|
|
|
|
|
public int getMaxTotal() {
|
|
|
|
return maxTotal.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMaxTotal(Integer maxTotal) {
|
|
|
|
this.maxTotal.set(maxTotal);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getMaxIdle() {
|
|
|
|
return maxIdle.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMaxIdle(int maxIdle) {
|
|
|
|
this.maxIdle.set(maxIdle);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getMaxWait() {
|
|
|
|
return maxWait.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMaxWait(int maxWait) {
|
|
|
|
this.maxWait.set(maxWait);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean getBlockWhenExhausted() {
|
|
|
|
return blockWhenExhausted.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setBlockWhenExhausted(boolean blockWhenExhausted) {
|
|
|
|
this.blockWhenExhausted.set(blockWhenExhausted);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean getLifo() {
|
|
|
|
return lifo.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLifo(boolean lifo) {
|
|
|
|
this.lifo.set(lifo);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getTimeout() {
|
|
|
|
return timeout.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTimeout(int timeout) {
|
|
|
|
this.timeout.set(timeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object clone() throws CloneNotSupportedException {
|
|
|
|
RedisConnectionPoolConfig cloned = (RedisConnectionPoolConfig) super.clone();
|
|
|
|
cloned.maxTotal = (HolderKit.Conf<Integer>) maxTotal.clone();
|
|
|
|
cloned.maxWait = (HolderKit.Conf<Integer>) maxWait.clone();
|
|
|
|
cloned.maxIdle = (HolderKit.Conf<Integer>) maxIdle.clone();
|
|
|
|
cloned.blockWhenExhausted = (HolderKit.Conf<Boolean>) blockWhenExhausted.clone();
|
|
|
|
cloned.lifo = (HolderKit.Conf<Boolean>) lifo.clone();
|
|
|
|
cloned.timeout = (HolderKit.Conf<Integer>) timeout.clone();
|
|
|
|
return cloned;
|
|
|
|
}
|
|
|
|
}
|