Class Config
- java.lang.Object
-
- org.redisson.config.Config
-
- Direct Known Subclasses:
RedissonNodeFileConfig
public class Config extends Object
Redisson configuration- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ConfigfromJSON(File file)Deprecated.static ConfigfromJSON(File file, ClassLoader classLoader)Deprecated.static ConfigfromJSON(InputStream inputStream)Deprecated.static ConfigfromJSON(Reader reader)Deprecated.static ConfigfromJSON(String content)Deprecated.static ConfigfromJSON(URL url)Deprecated.static ConfigfromYAML(File file)Read config object stored in YAML format fromFilestatic ConfigfromYAML(File file, ClassLoader classLoader)static ConfigfromYAML(InputStream inputStream)Read config object stored in YAML format fromInputStreamstatic ConfigfromYAML(Reader reader)Read config object stored in YAML format fromReaderstatic ConfigfromYAML(String content)Read config object stored in YAML format fromStringstatic ConfigfromYAML(URL url)Read config object stored in YAML format fromURLAddressResolverGroupFactorygetAddressResolverGroupFactory()intgetCleanUpKeysAmount()protected ClusterServersConfiggetClusterServersConfig()CodecgetCodec()ConnectionListenergetConnectionListener()io.netty.channel.EventLoopGroupgetEventLoopGroup()ExecutorServicegetExecutor()longgetLockWatchdogTimeout()protected MasterSlaveServersConfiggetMasterSlaveServersConfig()intgetMaxCleanUpDelay()intgetMinCleanUpDelay()NettyHookgetNettyHook()intgetNettyThreads()longgetReliableTopicWatchdogTimeout()protected ReplicatedServersConfiggetReplicatedServersConfig()protected SentinelServersConfiggetSentinelServersConfig()protected SingleServerConfiggetSingleServerConfig()intgetThreads()TransportModegetTransportMode()booleanisClusterConfig()booleanisKeepPubSubOrder()booleanisReferenceEnabled()Config option indicate whether Redisson Reference feature is enabled.booleanisSentinelConfig()booleanisUseScriptCache()booleanisUseThreadClassLoader()ConfigsetAddressResolverGroupFactory(AddressResolverGroupFactory addressResolverGroupFactory)Used to switch betweenDnsAddressResolverGroupimplementations.ConfigsetCleanUpKeysAmount(int cleanUpKeysAmount)Defines expired keys amount deleted per single operation during clean up process of expired entries.protected voidsetClusterServersConfig(ClusterServersConfig clusterServersConfig)ConfigsetCodec(Codec codec)Redis data codec.ConfigsetConnectionListener(ConnectionListener connectionListener)Sets connection listener which is triggered when Redisson connected/disconnected to Redis serverConfigsetEventLoopGroup(io.netty.channel.EventLoopGroup eventLoopGroup)Use external EventLoopGroup.ConfigsetExecutor(ExecutorService executor)Use external ExecutorService.ConfigsetKeepPubSubOrder(boolean keepPubSubOrder)Defines whether to keep PubSub messages handling in arrival order or handle messages concurrently.ConfigsetLockWatchdogTimeout(long lockWatchdogTimeout)This parameter is only used if lock has been acquired without leaseTimeout parameter definition.protected voidsetMasterSlaveServersConfig(MasterSlaveServersConfig masterSlaveConnectionConfig)ConfigsetMaxCleanUpDelay(int maxCleanUpDelay)Defines maximum delay in seconds for clean up process of expired entries.ConfigsetMinCleanUpDelay(int minCleanUpDelay)Defines minimum delay in seconds for clean up process of expired entries.ConfigsetNettyHook(NettyHook nettyHook)Netty hook applied to Netty Bootstrap and Channel objects.ConfigsetNettyThreads(int nettyThreads)Threads amount shared between all redis clients used by Redisson.voidsetReferenceEnabled(boolean redissonReferenceEnabled)Config option for enabling Redisson Reference featureConfigsetReliableTopicWatchdogTimeout(long timeout)Reliable Topic subscriber expires aftertimeoutif watchdog didn't extend it to nexttimeouttime interval.protected voidsetReplicatedServersConfig(ReplicatedServersConfig replicatedServersConfig)protected voidsetSentinelServersConfig(SentinelServersConfig sentinelConnectionConfig)protected voidsetSingleServerConfig(SingleServerConfig singleConnectionConfig)ConfigsetThreads(int threads)Threads amount shared across all listeners ofRTopicobject, invocation handlers ofRRemoteServiceobject andRExecutorServicetasks.ConfigsetTransportMode(TransportMode transportMode)Transport modeConfigsetUseScriptCache(boolean useScriptCache)Defines whether to use Lua-script cache on Redis side.ConfigsetUseThreadClassLoader(boolean useThreadClassLoader)Defines whether to supply Thread ContextClassLoader to Codec.StringtoJSON()Deprecated.StringtoYAML()Convert current configuration to YAML formatClusterServersConfiguseClusterServers()Init cluster servers configurationvoiduseCustomServers(ConnectionManager connectionManager)This is an extension point to supply custom connection manager.MasterSlaveServersConfiguseMasterSlaveServers()Init master/slave servers configuration.ReplicatedServersConfiguseReplicatedServers()Init Replicated servers configuration.SentinelServersConfiguseSentinelServers()Init sentinel servers configuration.SingleServerConfiguseSingleServer()Init single server configuration.
-
-
-
Constructor Detail
-
Config
public Config()
-
Config
public Config(Config oldConf)
-
-
Method Detail
-
getNettyHook
public NettyHook getNettyHook()
-
setNettyHook
public Config setNettyHook(NettyHook nettyHook)
Netty hook applied to Netty Bootstrap and Channel objects.- Parameters:
nettyHook- - netty hook object- Returns:
- config
-
setCodec
public Config setCodec(Codec codec)
Redis data codec. Default is MarshallingCodec codec- Parameters:
codec- object- Returns:
- config
- See Also:
Codec,MarshallingCodec
-
getCodec
public Codec getCodec()
-
isReferenceEnabled
public boolean isReferenceEnabled()
Config option indicate whether Redisson Reference feature is enabled.Default value is
true- Returns:
trueif Redisson Reference feature enabled
-
setReferenceEnabled
public void setReferenceEnabled(boolean redissonReferenceEnabled)
Config option for enabling Redisson Reference featureDefault value is
true- Parameters:
redissonReferenceEnabled- flag
-
useClusterServers
public ClusterServersConfig useClusterServers()
Init cluster servers configuration- Returns:
- config
-
getClusterServersConfig
protected ClusterServersConfig getClusterServersConfig()
-
setClusterServersConfig
protected void setClusterServersConfig(ClusterServersConfig clusterServersConfig)
-
useReplicatedServers
public ReplicatedServersConfig useReplicatedServers()
Init Replicated servers configuration. Most used with Azure Redis Cache or AWS Elasticache- Returns:
- ReplicatedServersConfig
-
getReplicatedServersConfig
protected ReplicatedServersConfig getReplicatedServersConfig()
-
setReplicatedServersConfig
protected void setReplicatedServersConfig(ReplicatedServersConfig replicatedServersConfig)
-
useCustomServers
public void useCustomServers(ConnectionManager connectionManager)
This is an extension point to supply custom connection manager.- Parameters:
connectionManager- for supply- See Also:
on how to implement a connection manager.
-
useSingleServer
public SingleServerConfig useSingleServer()
Init single server configuration.- Returns:
- SingleServerConfig
-
getSingleServerConfig
protected SingleServerConfig getSingleServerConfig()
-
setSingleServerConfig
protected void setSingleServerConfig(SingleServerConfig singleConnectionConfig)
-
useSentinelServers
public SentinelServersConfig useSentinelServers()
Init sentinel servers configuration.- Returns:
- SentinelServersConfig
-
getSentinelServersConfig
protected SentinelServersConfig getSentinelServersConfig()
-
setSentinelServersConfig
protected void setSentinelServersConfig(SentinelServersConfig sentinelConnectionConfig)
-
useMasterSlaveServers
public MasterSlaveServersConfig useMasterSlaveServers()
Init master/slave servers configuration.- Returns:
- MasterSlaveServersConfig
-
getMasterSlaveServersConfig
protected MasterSlaveServersConfig getMasterSlaveServersConfig()
-
setMasterSlaveServersConfig
protected void setMasterSlaveServersConfig(MasterSlaveServersConfig masterSlaveConnectionConfig)
-
isClusterConfig
public boolean isClusterConfig()
-
isSentinelConfig
public boolean isSentinelConfig()
-
getThreads
public int getThreads()
-
setThreads
public Config setThreads(int threads)
Threads amount shared across all listeners ofRTopicobject, invocation handlers ofRRemoteServiceobject andRExecutorServicetasks.Default is
16.0meanscurrent_processors_amount * 2- Parameters:
threads- amount- Returns:
- config
-
setTransportMode
public Config setTransportMode(TransportMode transportMode)
Transport modeDefault is
TransportMode.NIO- Parameters:
transportMode- param- Returns:
- config
-
getTransportMode
public TransportMode getTransportMode()
-
setNettyThreads
public Config setNettyThreads(int nettyThreads)
Threads amount shared between all redis clients used by Redisson.Default is
32.0meanscurrent_processors_amount * 2- Parameters:
nettyThreads- amount- Returns:
- config
-
getNettyThreads
public int getNettyThreads()
-
setExecutor
public Config setExecutor(ExecutorService executor)
Use external ExecutorService. ExecutorService processes all listeners ofRTopic,RRemoteServiceinvocation handlers andRExecutorServicetasks.The caller is responsible for closing the ExecutorService.
- Parameters:
executor- object- Returns:
- config
-
getExecutor
public ExecutorService getExecutor()
-
setEventLoopGroup
public Config setEventLoopGroup(io.netty.channel.EventLoopGroup eventLoopGroup)
Use external EventLoopGroup. EventLoopGroup processes all Netty connection tied to Redis servers. Each EventLoopGroup creates own threads and each Redisson client creates own EventLoopGroup by default. So if there are multiple Redisson instances in same JVM it would be useful to share one EventLoopGroup among them.Only
EpollEventLoopGroup,KQueueEventLoopGroupNioEventLoopGroupcan be used.The caller is responsible for closing the EventLoopGroup.
- Parameters:
eventLoopGroup- object- Returns:
- config
-
getEventLoopGroup
public io.netty.channel.EventLoopGroup getEventLoopGroup()
-
setLockWatchdogTimeout
public Config setLockWatchdogTimeout(long lockWatchdogTimeout)
This parameter is only used if lock has been acquired without leaseTimeout parameter definition. Lock expires afterlockWatchdogTimeoutif watchdog didn't extend it to nextlockWatchdogTimeouttime interval.This prevents against infinity locked locks due to Redisson client crush or any other reason when lock can't be released in proper way.
Default is 30000 milliseconds
- Parameters:
lockWatchdogTimeout- timeout in milliseconds- Returns:
- config
-
getLockWatchdogTimeout
public long getLockWatchdogTimeout()
-
setKeepPubSubOrder
public Config setKeepPubSubOrder(boolean keepPubSubOrder)
Defines whether to keep PubSub messages handling in arrival order or handle messages concurrently.This setting applied only for PubSub messages per channel.
Default is
true.- Parameters:
keepPubSubOrder- -trueif order required,falseotherwise.- Returns:
- config
-
isKeepPubSubOrder
public boolean isKeepPubSubOrder()
-
setAddressResolverGroupFactory
public Config setAddressResolverGroupFactory(AddressResolverGroupFactory addressResolverGroupFactory)
Used to switch betweenDnsAddressResolverGroupimplementations. Switch to round robinRoundRobinDnsAddressResolverGroupwhen you need to optimize the url resolving.- Parameters:
addressResolverGroupFactory-- Returns:
- config
-
getAddressResolverGroupFactory
public AddressResolverGroupFactory getAddressResolverGroupFactory()
-
fromJSON
@Deprecated public static Config fromJSON(String content) throws IOException
Deprecated.- Throws:
IOException
-
fromJSON
@Deprecated public static Config fromJSON(InputStream inputStream) throws IOException
Deprecated.- Throws:
IOException
-
fromJSON
@Deprecated public static Config fromJSON(File file, ClassLoader classLoader) throws IOException
Deprecated.- Throws:
IOException
-
fromJSON
@Deprecated public static Config fromJSON(File file) throws IOException
Deprecated.- Throws:
IOException
-
fromJSON
@Deprecated public static Config fromJSON(URL url) throws IOException
Deprecated.- Throws:
IOException
-
fromJSON
@Deprecated public static Config fromJSON(Reader reader) throws IOException
Deprecated.- Throws:
IOException
-
toJSON
@Deprecated public String toJSON() throws IOException
Deprecated.- Throws:
IOException
-
fromYAML
public static Config fromYAML(String content) throws IOException
Read config object stored in YAML format fromString- Parameters:
content- of config- Returns:
- config
- Throws:
IOException- error
-
fromYAML
public static Config fromYAML(InputStream inputStream) throws IOException
Read config object stored in YAML format fromInputStream- Parameters:
inputStream- object- Returns:
- config
- Throws:
IOException- error
-
fromYAML
public static Config fromYAML(File file) throws IOException
Read config object stored in YAML format fromFile- Parameters:
file- object- Returns:
- config
- Throws:
IOException- error
-
fromYAML
public static Config fromYAML(File file, ClassLoader classLoader) throws IOException
- Throws:
IOException
-
fromYAML
public static Config fromYAML(URL url) throws IOException
Read config object stored in YAML format fromURL- Parameters:
url- object- Returns:
- config
- Throws:
IOException- error
-
fromYAML
public static Config fromYAML(Reader reader) throws IOException
Read config object stored in YAML format fromReader- Parameters:
reader- object- Returns:
- config
- Throws:
IOException- error
-
toYAML
public String toYAML() throws IOException
Convert current configuration to YAML format- Returns:
- config in yaml format
- Throws:
IOException- error
-
setUseScriptCache
public Config setUseScriptCache(boolean useScriptCache)
Defines whether to use Lua-script cache on Redis side. Most Redisson methods are Lua-script based and this setting turned on could increase speed of such methods execution and save network traffic.Default is
false.- Parameters:
useScriptCache- -trueif Lua-script caching is required,falseotherwise.- Returns:
- config
-
isUseScriptCache
public boolean isUseScriptCache()
-
getMinCleanUpDelay
public int getMinCleanUpDelay()
-
setMinCleanUpDelay
public Config setMinCleanUpDelay(int minCleanUpDelay)
Defines minimum delay in seconds for clean up process of expired entries.Applied to JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects.
Default is
5.- Parameters:
minCleanUpDelay- - delay in seconds- Returns:
- config
-
getMaxCleanUpDelay
public int getMaxCleanUpDelay()
-
setMaxCleanUpDelay
public Config setMaxCleanUpDelay(int maxCleanUpDelay)
Defines maximum delay in seconds for clean up process of expired entries.Applied to JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects.
Default is
1800.- Parameters:
maxCleanUpDelay- - delay in seconds- Returns:
- config
-
getCleanUpKeysAmount
public int getCleanUpKeysAmount()
-
setCleanUpKeysAmount
public Config setCleanUpKeysAmount(int cleanUpKeysAmount)
Defines expired keys amount deleted per single operation during clean up process of expired entries.Applied to JCache, RSetCache, RMapCache, RListMultimapCache, RSetMultimapCache objects.
Default is
100.- Parameters:
cleanUpKeysAmount- - delay in seconds- Returns:
- config
-
isUseThreadClassLoader
public boolean isUseThreadClassLoader()
-
setUseThreadClassLoader
public Config setUseThreadClassLoader(boolean useThreadClassLoader)
Defines whether to supply Thread ContextClassLoader to Codec. Usage of Thread.getContextClassLoader() may resolve ClassNotFoundException error. For example, this error arise if Redisson is used in both Tomcat and deployed application.Default is
true.- Parameters:
useThreadClassLoader-trueif Thread ContextClassLoader is used,falseotherwise.- Returns:
- config
-
getReliableTopicWatchdogTimeout
public long getReliableTopicWatchdogTimeout()
-
setReliableTopicWatchdogTimeout
public Config setReliableTopicWatchdogTimeout(long timeout)
Reliable Topic subscriber expires aftertimeoutif watchdog didn't extend it to nexttimeouttime interval.This prevents against infinity grow of stored messages in topic due to Redisson client crush or any other reason when subscriber can't consumer messages anymore.
Default is 600000 milliseconds
- Parameters:
timeout- timeout in milliseconds- Returns:
- config
-
getConnectionListener
public ConnectionListener getConnectionListener()
-
setConnectionListener
public Config setConnectionListener(ConnectionListener connectionListener)
Sets connection listener which is triggered when Redisson connected/disconnected to Redis server- Parameters:
connectionListener- - connection listener- Returns:
- config
-
-