Merge branch 'master' into 3.0.0

pull/1303/head
Nikita 7 years ago
commit 8105c192fa

@ -94,6 +94,8 @@ public class RedisClient {
bootstrap.handler(new RedisChannelInitializer(bootstrap, config, this, channels, type)); bootstrap.handler(new RedisChannelInitializer(bootstrap, config, this, channels, type));
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.getConnectTimeout()); bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.getConnectTimeout());
bootstrap.option(ChannelOption.SO_KEEPALIVE, config.isKeepAlive());
bootstrap.option(ChannelOption.TCP_NODELAY, config.isTcpNoDelay());
return bootstrap; return bootstrap;
} }

@ -49,6 +49,9 @@ public class RedisClientConfig {
private String clientName; private String clientName;
private boolean readOnly; private boolean readOnly;
private boolean keepPubSubOrder = true; private boolean keepPubSubOrder = true;
private boolean pingConnection;
private boolean keepAlive;
private boolean tcpNoDelay;
private boolean sslEnableEndpointIdentification = true; private boolean sslEnableEndpointIdentification = true;
private SslProvider sslProvider = SslProvider.JDK; private SslProvider sslProvider = SslProvider.JDK;
@ -206,8 +209,33 @@ public class RedisClientConfig {
public boolean isKeepPubSubOrder() { public boolean isKeepPubSubOrder() {
return keepPubSubOrder; return keepPubSubOrder;
} }
public void setKeepPubSubOrder(boolean keepPubSubOrder) { public RedisClientConfig setKeepPubSubOrder(boolean keepPubSubOrder) {
this.keepPubSubOrder = keepPubSubOrder; this.keepPubSubOrder = keepPubSubOrder;
return this;
}
public boolean isPingConnection() {
return pingConnection;
}
public RedisClientConfig setPingConnection(boolean pingConnection) {
this.pingConnection = pingConnection;
return this;
}
public boolean isKeepAlive() {
return keepAlive;
}
public RedisClientConfig setKeepAlive(boolean keepAlive) {
this.keepAlive = keepAlive;
return this;
} }
public boolean isTcpNoDelay() {
return tcpNoDelay;
}
public RedisClientConfig setTcpNoDelay(boolean tcpNoDelay) {
this.tcpNoDelay = tcpNoDelay;
return this;
}
} }

@ -80,6 +80,10 @@ public abstract class BaseConnectionHandler<C extends RedisConnection> extends C
RFuture<Object> future = connection.async(RedisCommands.READONLY); RFuture<Object> future = connection.async(RedisCommands.READONLY);
futures.add(future); futures.add(future);
} }
if (config.isPingConnection()) {
RFuture<Object> future = connection.async(RedisCommands.PING);
futures.add(future);
}
if (futures.isEmpty()) { if (futures.isEmpty()) {
ctx.fireChannelActive(); ctx.fireChannelActive();

@ -105,6 +105,12 @@ class BaseConfig<T extends BaseConfig<T>> {
private String sslKeystorePassword; private String sslKeystorePassword;
private boolean pingConnection;
private boolean keepAlive;
private boolean tcpNoDelay;
BaseConfig() { BaseConfig() {
} }
@ -127,6 +133,9 @@ class BaseConfig<T extends BaseConfig<T>> {
setSslTruststorePassword(config.getSslTruststorePassword()); setSslTruststorePassword(config.getSslTruststorePassword());
setSslKeystore(config.getSslKeystore()); setSslKeystore(config.getSslKeystore());
setSslKeystorePassword(config.getSslKeystorePassword()); setSslKeystorePassword(config.getSslKeystorePassword());
setPingConnection(config.isPingConnection());
setKeepAlive(config.isKeepAlive());
setTcpNoDelay(config.isTcpNoDelay());
} }
/** /**
@ -332,7 +341,7 @@ class BaseConfig<T extends BaseConfig<T>> {
/** /**
* Enables SSL endpoint identification. * Enables SSL endpoint identification.
* <p> * <p>
* Default is true * Default is <code>true</code>
* *
* @param sslEnableEndpointIdentification - boolean value * @param sslEnableEndpointIdentification - boolean value
* @return config * @return config
@ -419,6 +428,57 @@ class BaseConfig<T extends BaseConfig<T>> {
return (T) this; return (T) this;
} }
public boolean isPingConnection() {
return pingConnection;
}
/**
* Enables PING command sending during connection initialization
* <p>
* Default is <code>false</code>
*
* @param pingConnection - boolean value
* @return config
*/
public T setPingConnection(boolean pingConnection) {
this.pingConnection = pingConnection;
return (T) this;
}
public boolean isKeepAlive() {
return keepAlive;
}
/**
* Enables TCP keepAlive for connection
* <p>
* Default is <code>false</code>
*
* @param keepAlive - boolean value
* @return config
*/
public T setKeepAlive(boolean keepAlive) {
this.keepAlive = keepAlive;
return (T) this;
}
public boolean isTcpNoDelay() {
return tcpNoDelay;
}
/**
* Enables TCP noDelay for connection
* <p>
* Default is <code>false</code>
*
* @param tcpNoDelay - boolean value
* @return config
*/
public T setTcpNoDelay(boolean tcpNoDelay) {
this.tcpNoDelay = tcpNoDelay;
return (T) this;
}
} }

@ -377,7 +377,10 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
.setSslKeystore(config.getSslKeystore()) .setSslKeystore(config.getSslKeystore())
.setSslKeystorePassword(config.getSslKeystorePassword()) .setSslKeystorePassword(config.getSslKeystorePassword())
.setClientName(config.getClientName()) .setClientName(config.getClientName())
.setKeepPubSubOrder(cfg.isKeepPubSubOrder()); .setKeepPubSubOrder(cfg.isKeepPubSubOrder())
.setPingConnection(config.isPingConnection())
.setKeepAlive(config.isKeepAlive())
.setTcpNoDelay(config.isTcpNoDelay());
if (type != NodeType.SENTINEL) { if (type != NodeType.SENTINEL) {
redisConfig.setDatabase(config.getDatabase()); redisConfig.setDatabase(config.getDatabase());

Loading…
Cancel
Save