|
|
@ -26,11 +26,11 @@ import org.redisson.codec.RedissonCodec;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class Config {
|
|
|
|
public class Config {
|
|
|
|
|
|
|
|
|
|
|
|
private SentinelConnectionConfig sentinelConnectionConfig;
|
|
|
|
private SentinelServersConfig sentinelServersConfig;
|
|
|
|
|
|
|
|
|
|
|
|
private MasterSlaveConnectionConfig masterSlaveConnectionConfig;
|
|
|
|
private MasterSlaveServersConfig masterSlaveServersConfig;
|
|
|
|
|
|
|
|
|
|
|
|
private SingleConnectionConfig singleConnectionConfig;
|
|
|
|
private SingleServerConfig singleServerConfig;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Threads amount shared between all redis node clients
|
|
|
|
* Threads amount shared between all redis node clients
|
|
|
@ -53,14 +53,14 @@ public class Config {
|
|
|
|
|
|
|
|
|
|
|
|
setThreads(oldConf.getThreads());
|
|
|
|
setThreads(oldConf.getThreads());
|
|
|
|
setCodec(oldConf.getCodec());
|
|
|
|
setCodec(oldConf.getCodec());
|
|
|
|
if (oldConf.getSingleConnectionConfig() != null) {
|
|
|
|
if (oldConf.getSingleServerConfig() != null) {
|
|
|
|
setSingleConnectionConfig(new SingleConnectionConfig(oldConf.getSingleConnectionConfig()));
|
|
|
|
setSingleServerConfig(new SingleServerConfig(oldConf.getSingleServerConfig()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (oldConf.getMasterSlaveConnectionConfig() != null) {
|
|
|
|
if (oldConf.getMasterSlaveServersConfig() != null) {
|
|
|
|
setMasterSlaveConnectionConfig(new MasterSlaveConnectionConfig(oldConf.getMasterSlaveConnectionConfig()));
|
|
|
|
setMasterSlaveServersConfig(new MasterSlaveServersConfig(oldConf.getMasterSlaveServersConfig()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (oldConf.getSentinelConnectionConfig() != null ) {
|
|
|
|
if (oldConf.getSentinelServersConfig() != null ) {
|
|
|
|
setSentinelConnectionConfig(new SentinelConnectionConfig(oldConf.getSentinelConnectionConfig()));
|
|
|
|
setSentinelServersConfig(new SentinelServersConfig(oldConf.getSentinelServersConfig()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -78,52 +78,54 @@ public class Config {
|
|
|
|
return codec;
|
|
|
|
return codec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SingleConnectionConfig useSingleConnection() {
|
|
|
|
public SingleServerConfig useSingleServer() {
|
|
|
|
if (masterSlaveConnectionConfig != null) {
|
|
|
|
checkMasterSlaveServersConfig();
|
|
|
|
throw new IllegalStateException("master/slave connection already used!");
|
|
|
|
checkSentinelServersConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (singleConnectionConfig == null) {
|
|
|
|
if (singleServerConfig == null) {
|
|
|
|
singleConnectionConfig = new SingleConnectionConfig();
|
|
|
|
singleServerConfig = new SingleServerConfig();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return singleConnectionConfig;
|
|
|
|
return singleServerConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SingleConnectionConfig getSingleConnectionConfig() {
|
|
|
|
|
|
|
|
return singleConnectionConfig;
|
|
|
|
SingleServerConfig getSingleServerConfig() {
|
|
|
|
|
|
|
|
return singleServerConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void setSingleConnectionConfig(SingleConnectionConfig singleConnectionConfig) {
|
|
|
|
void setSingleServerConfig(SingleServerConfig singleConnectionConfig) {
|
|
|
|
this.singleConnectionConfig = singleConnectionConfig;
|
|
|
|
this.singleServerConfig = singleConnectionConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SentinelConnectionConfig useSentinelConnection() {
|
|
|
|
public SentinelServersConfig useSentinelConnection() {
|
|
|
|
if (singleConnectionConfig != null) {
|
|
|
|
checkSingleServerConfig();
|
|
|
|
throw new IllegalStateException("single connection already used!");
|
|
|
|
checkMasterSlaveServersConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sentinelConnectionConfig == null) {
|
|
|
|
if (sentinelServersConfig == null) {
|
|
|
|
sentinelConnectionConfig = new SentinelConnectionConfig();
|
|
|
|
sentinelServersConfig = new SentinelServersConfig();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sentinelConnectionConfig;
|
|
|
|
return sentinelServersConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SentinelConnectionConfig getSentinelConnectionConfig() {
|
|
|
|
|
|
|
|
return sentinelConnectionConfig;
|
|
|
|
SentinelServersConfig getSentinelServersConfig() {
|
|
|
|
|
|
|
|
return sentinelServersConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void setSentinelConnectionConfig(SentinelConnectionConfig sentinelConnectionConfig) {
|
|
|
|
void setSentinelServersConfig(SentinelServersConfig sentinelConnectionConfig) {
|
|
|
|
this.sentinelConnectionConfig = sentinelConnectionConfig;
|
|
|
|
this.sentinelServersConfig = sentinelConnectionConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public MasterSlaveConnectionConfig useMasterSlaveConnection() {
|
|
|
|
public MasterSlaveServersConfig useMasterSlaveConnection() {
|
|
|
|
if (singleConnectionConfig != null) {
|
|
|
|
checkSingleServerConfig();
|
|
|
|
throw new IllegalStateException("single connection already used!");
|
|
|
|
checkSentinelServersConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (masterSlaveConnectionConfig == null) {
|
|
|
|
if (masterSlaveServersConfig == null) {
|
|
|
|
masterSlaveConnectionConfig = new MasterSlaveConnectionConfig();
|
|
|
|
masterSlaveServersConfig = new MasterSlaveServersConfig();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return masterSlaveConnectionConfig;
|
|
|
|
return masterSlaveServersConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MasterSlaveConnectionConfig getMasterSlaveConnectionConfig() {
|
|
|
|
MasterSlaveServersConfig getMasterSlaveServersConfig() {
|
|
|
|
return masterSlaveConnectionConfig;
|
|
|
|
return masterSlaveServersConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void setMasterSlaveConnectionConfig(MasterSlaveConnectionConfig masterSlaveConnectionConfig) {
|
|
|
|
void setMasterSlaveServersConfig(MasterSlaveServersConfig masterSlaveConnectionConfig) {
|
|
|
|
this.masterSlaveConnectionConfig = masterSlaveConnectionConfig;
|
|
|
|
this.masterSlaveServersConfig = masterSlaveConnectionConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int getThreads() {
|
|
|
|
public int getThreads() {
|
|
|
@ -135,4 +137,22 @@ public class Config {
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkSentinelServersConfig() {
|
|
|
|
|
|
|
|
if (sentinelServersConfig != null) {
|
|
|
|
|
|
|
|
throw new IllegalStateException("sentinel servers config already used!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkMasterSlaveServersConfig() {
|
|
|
|
|
|
|
|
if (masterSlaveServersConfig != null) {
|
|
|
|
|
|
|
|
throw new IllegalStateException("master/slave servers already used!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkSingleServerConfig() {
|
|
|
|
|
|
|
|
if (singleServerConfig != null) {
|
|
|
|
|
|
|
|
throw new IllegalStateException("single server config already used!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|