Package org.redisson.config
Class Config
- java.lang.Object
-
- org.redisson.config.Config
-
- Direct Known Subclasses:
RedissonNodeConfig
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 Config
fromJSON(File file)
Read config object stored in JSON format fromFile
static Config
fromJSON(File file, ClassLoader classLoader)
Read config object stored in JSON format fromFile
static Config
fromJSON(InputStream inputStream)
Read config object stored in JSON format fromInputStream
static Config
fromJSON(Reader reader)
Read config object stored in JSON format fromReader
static Config
fromJSON(String content)
Read config object stored in JSON format fromString
static Config
fromJSON(URL url)
Read config object stored in JSON format fromURL
static Config
fromYAML(File file)
Read config object stored in YAML format fromFile
static Config
fromYAML(File file, ClassLoader classLoader)
static Config
fromYAML(InputStream inputStream)
Read config object stored in YAML format fromInputStream
static Config
fromYAML(Reader reader)
Read config object stored in YAML format fromReader
static Config
fromYAML(String content)
Read config object stored in YAML format fromString
static Config
fromYAML(URL url)
Read config object stored in YAML format fromURL
AddressResolverGroupFactory
getAddressResolverGroupFactory()
Codec
getCodec()
io.netty.channel.EventLoopGroup
getEventLoopGroup()
ExecutorService
getExecutor()
long
getLockWatchdogTimeout()
int
getNettyThreads()
ReferenceCodecProvider
getReferenceCodecProvider()
Returns the CodecProvider instanceint
getThreads()
TransportMode
getTransportMode()
boolean
isClusterConfig()
boolean
isKeepPubSubOrder()
boolean
isReferenceEnabled()
Config option indicate whether Redisson Reference feature is enabled.boolean
isSentinelConfig()
boolean
isUseLinuxNativeEpoll()
Config
setAddressResolverGroupFactory(AddressResolverGroupFactory addressResolverGroupFactory)
Used to switch betweenDnsAddressResolverGroup
implementations.Config
setCodec(Codec codec)
Redis key/value codec.Config
setEventLoopGroup(io.netty.channel.EventLoopGroup eventLoopGroup)
Use external EventLoopGroup.Config
setExecutor(ExecutorService executor)
Use external ExecutorService.Config
setKeepPubSubOrder(boolean keepPubSubOrder)
Defines whether keep PubSub messages handling in arrival order or handle messages concurrently.Config
setLockWatchdogTimeout(long lockWatchdogTimeout)
This parameter is only used if lock has been acquired without leaseTimeout parameter definition.Config
setNettyThreads(int nettyThreads)
Threads amount shared between all redis clients used by Redisson.Config
setReferenceCodecProvider(ReferenceCodecProvider codecProvider)
Reference objects codec provider used for codec registry and look up.void
setReferenceEnabled(boolean redissonReferenceEnabled)
Config option for enabling Redisson Reference featureConfig
setThreads(int threads)
Threads amount shared across all listeners ofRTopic
object, invocation handlers ofRRemoteService
object andRExecutorService
tasks.Config
setTransportMode(TransportMode transportMode)
Transport modeConfig
setUseLinuxNativeEpoll(boolean useLinuxNativeEpoll)
Deprecated.String
toJSON()
Convert current configuration to JSON formatString
toYAML()
Convert current configuration to YAML formatClusterServersConfig
useClusterServers()
Init cluster servers configurationvoid
useCustomServers(ConnectionManager connectionManager)
This is an extension point to supply custom connection manager.ElasticacheServersConfig
useElasticacheServers()
Deprecated.MasterSlaveServersConfig
useMasterSlaveServers()
Init master/slave servers configuration.ReplicatedServersConfig
useReplicatedServers()
Init Replicated servers configuration.SentinelServersConfig
useSentinelServers()
Init sentinel servers configuration.SingleServerConfig
useSingleServer()
Init single server configuration.
-
-
-
Constructor Detail
-
Config
public Config()
-
Config
public Config(Config oldConf)
-
-
Method Detail
-
setCodec
public Config setCodec(Codec codec)
Redis key/value codec. Default is json-codec- Parameters:
codec
- object- Returns:
- config
- See Also:
Codec
-
getCodec
public Codec getCodec()
-
setReferenceCodecProvider
public Config setReferenceCodecProvider(ReferenceCodecProvider codecProvider)
Reference objects codec provider used for codec registry and look up.org.redisson.codec.DefaultReferenceCodecProvider
used by default.- Parameters:
codecProvider
- object- Returns:
- config
- See Also:
ReferenceCodecProvider
-
getReferenceCodecProvider
public ReferenceCodecProvider getReferenceCodecProvider()
Returns the CodecProvider instance- Returns:
- CodecProvider
-
isReferenceEnabled
public boolean isReferenceEnabled()
Config option indicate whether Redisson Reference feature is enabled.Default value is
true
- Returns:
true
if 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
-
useElasticacheServers
@Deprecated public ElasticacheServersConfig useElasticacheServers()
Deprecated.- Returns:
- config object
-
useReplicatedServers
public ReplicatedServersConfig useReplicatedServers()
Init Replicated servers configuration. Most used with Azure Redis Cache or AWS Elasticache- Returns:
- 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
-
useSentinelServers
public SentinelServersConfig useSentinelServers()
Init sentinel servers configuration.- Returns:
- SentinelServersConfig
-
useMasterSlaveServers
public MasterSlaveServersConfig useMasterSlaveServers()
Init master/slave servers configuration.- Returns:
- MasterSlaveServersConfig
-
isClusterConfig
public boolean isClusterConfig()
-
isSentinelConfig
public boolean isSentinelConfig()
-
getThreads
public int getThreads()
-
setThreads
public Config setThreads(int threads)
Threads amount shared across all listeners ofRTopic
object, invocation handlers ofRRemoteService
object andRExecutorService
tasks.Default is
0
.0
meanscurrent_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()
-
setUseLinuxNativeEpoll
@Deprecated public Config setUseLinuxNativeEpoll(boolean useLinuxNativeEpoll)
Deprecated.
-
isUseLinuxNativeEpoll
public boolean isUseLinuxNativeEpoll()
-
setNettyThreads
public Config setNettyThreads(int nettyThreads)
Threads amount shared between all redis clients used by Redisson.Default is
0
.0
meanscurrent_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
,RRemoteService
invocation handlers andRExecutorService
tasks.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
,KQueueEventLoopGroup
NioEventLoopGroup
can 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 will be expired afterlockWatchdogTimeout
if watchdog didn't extend it to nextlockWatchdogTimeout
time 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.
- Parameters:
lockWatchdogTimeout
- timeout in milliseconds- Returns:
- config
-
getLockWatchdogTimeout
public long getLockWatchdogTimeout()
-
setKeepPubSubOrder
public Config setKeepPubSubOrder(boolean keepPubSubOrder)
Defines whether 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
- -true
if order required,false
otherwise.- Returns:
- config
-
isKeepPubSubOrder
public boolean isKeepPubSubOrder()
-
setAddressResolverGroupFactory
public Config setAddressResolverGroupFactory(AddressResolverGroupFactory addressResolverGroupFactory)
Used to switch betweenDnsAddressResolverGroup
implementations. Switch to round robinRoundRobinDnsAddressResolverGroup
when you need to optimize the url resolving.- Parameters:
addressResolverGroupFactory
-- Returns:
- config
-
getAddressResolverGroupFactory
public AddressResolverGroupFactory getAddressResolverGroupFactory()
-
fromJSON
public static Config fromJSON(String content) throws IOException
Read config object stored in JSON format fromString
- Parameters:
content
- of config- Returns:
- config
- Throws:
IOException
- error
-
fromJSON
public static Config fromJSON(InputStream inputStream) throws IOException
Read config object stored in JSON format fromInputStream
- Parameters:
inputStream
- object- Returns:
- config
- Throws:
IOException
- error
-
fromJSON
public static Config fromJSON(File file, ClassLoader classLoader) throws IOException
Read config object stored in JSON format fromFile
- Parameters:
file
- objectclassLoader
- class loader- Returns:
- config
- Throws:
IOException
- error
-
fromJSON
public static Config fromJSON(File file) throws IOException
Read config object stored in JSON format fromFile
- Parameters:
file
- object- Returns:
- config
- Throws:
IOException
- error
-
fromJSON
public static Config fromJSON(URL url) throws IOException
Read config object stored in JSON format fromURL
- Parameters:
url
- object- Returns:
- config
- Throws:
IOException
- error
-
fromJSON
public static Config fromJSON(Reader reader) throws IOException
Read config object stored in JSON format fromReader
- Parameters:
reader
- object- Returns:
- config
- Throws:
IOException
- error
-
toJSON
public String toJSON() throws IOException
Convert current configuration to JSON format- Returns:
- config in json format
- Throws:
IOException
- error
-
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
-
-