com.github.lontime.shaded.org.redisson.config.SingleServerConfig Maven / Gradle / Ivy
/**
* Copyright (c) 2013-2021 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.lontime.shaded.org.redisson.config;
/**
*
* @author Nikita Koksharov
*
*/
public class SingleServerConfig extends BaseConfig {
/**
* Redis server address
*
*/
private String address;
/**
* Minimum idle subscription connection amount
*/
private int subscriptionConnectionMinimumIdleSize = 1;
/**
* Redis subscription connection maximum pool size
*
*/
private int subscriptionConnectionPoolSize = 50;
/**
* Minimum idle Redis connection amount
*/
private int connectionMinimumIdleSize = 24;
/**
* Redis connection maximum pool size
*/
private int connectionPoolSize = 64;
/**
* Database index used for Redis connection
*/
private int database = 0;
/**
* Interval in milliseconds to check DNS
*/
private long dnsMonitoringInterval = 5000;
SingleServerConfig() {
}
SingleServerConfig(SingleServerConfig config) {
super(config);
setAddress(config.getAddress());
setConnectionPoolSize(config.getConnectionPoolSize());
setSubscriptionConnectionPoolSize(config.getSubscriptionConnectionPoolSize());
setDnsMonitoringInterval(config.getDnsMonitoringInterval());
setSubscriptionConnectionMinimumIdleSize(config.getSubscriptionConnectionMinimumIdleSize());
setConnectionMinimumIdleSize(config.getConnectionMinimumIdleSize());
setDatabase(config.getDatabase());
}
/**
* Redis connection pool size
*
* Default is 64
*
* @param connectionPoolSize - pool size
* @return config
*/
public SingleServerConfig setConnectionPoolSize(int connectionPoolSize) {
this.connectionPoolSize = connectionPoolSize;
return this;
}
public int getConnectionPoolSize() {
return connectionPoolSize;
}
/**
* Redis subscription-connection pool size limit
*
* Default is 50
*
* @param subscriptionConnectionPoolSize - pool size
* @return config
*/
public SingleServerConfig setSubscriptionConnectionPoolSize(int subscriptionConnectionPoolSize) {
this.subscriptionConnectionPoolSize = subscriptionConnectionPoolSize;
return this;
}
public int getSubscriptionConnectionPoolSize() {
return subscriptionConnectionPoolSize;
}
/**
* Set server address. Use follow format -- host:port
*
* @param address of Redis
* @return config
*/
public SingleServerConfig setAddress(String address) {
if (address != null) {
this.address = address;
}
return this;
}
public String getAddress() {
return address;
}
/**
* Interval in milliseconds to check the endpoint's DNS
* Applications must ensure the JVM DNS cache TTL is low enough to support this.
* Set -1
to disable.
*
* Default is 5000
.
*
* @param dnsMonitoringInterval time
* @return config
*/
public SingleServerConfig setDnsMonitoringInterval(long dnsMonitoringInterval) {
this.dnsMonitoringInterval = dnsMonitoringInterval;
return this;
}
public long getDnsMonitoringInterval() {
return dnsMonitoringInterval;
}
/**
* Minimum idle subscription connection amount.
*
* Default is 1
*
* @param subscriptionConnectionMinimumIdleSize - connections amount
* @return config
*
*/
public SingleServerConfig setSubscriptionConnectionMinimumIdleSize(int subscriptionConnectionMinimumIdleSize) {
this.subscriptionConnectionMinimumIdleSize = subscriptionConnectionMinimumIdleSize;
return this;
}
public int getSubscriptionConnectionMinimumIdleSize() {
return subscriptionConnectionMinimumIdleSize;
}
/**
* Minimum idle Redis connection amount.
*
* Default is 24
*
* @param connectionMinimumIdleSize - connections amount
* @return config
*/
public SingleServerConfig setConnectionMinimumIdleSize(int connectionMinimumIdleSize) {
this.connectionMinimumIdleSize = connectionMinimumIdleSize;
return this;
}
public int getConnectionMinimumIdleSize() {
return connectionMinimumIdleSize;
}
/**
* Database index used for Redis connection
* Default is 0
*
* @param database index
* @return config
*/
public SingleServerConfig setDatabase(int database) {
this.database = database;
return this;
}
public int getDatabase() {
return database;
}
}