public class Config extends Object
Modifier and Type | Method and Description |
---|---|
static Config |
fromJSON(File file)
Read config object stored in JSON format from
File |
static Config |
fromJSON(File file,
ClassLoader classLoader)
Read config object stored in JSON format from
File |
static Config |
fromJSON(InputStream inputStream)
Read config object stored in JSON format from
InputStream |
static Config |
fromJSON(Reader reader)
Read config object stored in JSON format from
Reader |
static Config |
fromJSON(String content)
Read config object stored in JSON format from
String |
static Config |
fromJSON(URL url)
Read config object stored in JSON format from
URL |
static Config |
fromYAML(File file)
Read config object stored in YAML format from
File |
static Config |
fromYAML(File file,
ClassLoader classLoader) |
static Config |
fromYAML(InputStream inputStream)
Read config object stored in YAML format from
InputStream |
static Config |
fromYAML(Reader reader)
Read config object stored in YAML format from
Reader |
static Config |
fromYAML(String content)
Read config object stored in YAML format from
String |
static Config |
fromYAML(URL url)
Read config object stored in YAML format from
URL |
AddressResolverGroupFactory |
getAddressResolverGroupFactory() |
Codec |
getCodec() |
io.netty.channel.EventLoopGroup |
getEventLoopGroup() |
ExecutorService |
getExecutor() |
long |
getLockWatchdogTimeout() |
int |
getNettyThreads() |
int |
getThreads() |
TransportMode |
getTransportMode() |
boolean |
isClusterConfig() |
boolean |
isDecodeInExecutor() |
boolean |
isKeepPubSubOrder() |
boolean |
isReferenceEnabled()
Config option indicate whether Redisson Reference feature is enabled.
|
boolean |
isSentinelConfig() |
boolean |
isUseScriptCache() |
Config |
setAddressResolverGroupFactory(AddressResolverGroupFactory addressResolverGroupFactory)
Used to switch between
DnsAddressResolverGroup implementations. |
Config |
setCodec(Codec codec)
Redis key/value codec.
|
Config |
setDecodeInExecutor(boolean decodeInExecutor)
Defines whether to decode data by
codec in executor's threads or netty's threads. |
Config |
setEventLoopGroup(io.netty.channel.EventLoopGroup eventLoopGroup)
Use external EventLoopGroup.
|
Config |
setExecutor(ExecutorService executor)
Use external ExecutorService.
|
Config |
setKeepPubSubOrder(boolean keepPubSubOrder)
Defines whether to 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.
|
void |
setReferenceEnabled(boolean redissonReferenceEnabled)
Config option for enabling Redisson Reference feature
Default value is
true |
Config |
setThreads(int threads)
Threads amount shared across all listeners of
RTopic object,
invocation handlers of RRemoteService object
and RExecutorService tasks. |
Config |
setTransportMode(TransportMode transportMode)
Transport mode
Default is
TransportMode.NIO |
Config |
setUseScriptCache(boolean useScriptCache)
Defines whether to use Lua-script cache on Redis side.
|
String |
toJSON()
Convert current configuration to JSON format
|
String |
toYAML()
Convert current configuration to YAML format
|
ClusterServersConfig |
useClusterServers()
Init cluster servers configuration
|
void |
useCustomServers(ConnectionManager connectionManager)
This is an extension point to supply custom connection manager.
|
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.
|
public Config()
public Config(Config oldConf)
public Config setCodec(Codec codec)
codec
- objectCodec
public Codec getCodec()
public boolean isReferenceEnabled()
Default value is true
true
if Redisson Reference feature enabledpublic void setReferenceEnabled(boolean redissonReferenceEnabled)
Default value is true
redissonReferenceEnabled
- flagpublic ClusterServersConfig useClusterServers()
public ReplicatedServersConfig useReplicatedServers()
public void useCustomServers(ConnectionManager connectionManager)
connectionManager
- for supplyon how to implement a connection
manager.
public SingleServerConfig useSingleServer()
public SentinelServersConfig useSentinelServers()
public MasterSlaveServersConfig useMasterSlaveServers()
public boolean isClusterConfig()
public boolean isSentinelConfig()
public int getThreads()
public Config setThreads(int threads)
RTopic
object,
invocation handlers of RRemoteService
object
and RExecutorService
tasks.
Default is 16
.
0
means current_processors_amount * 2
threads
- amountpublic Config setTransportMode(TransportMode transportMode)
Default is TransportMode.NIO
transportMode
- parampublic TransportMode getTransportMode()
public Config setNettyThreads(int nettyThreads)
Default is 32
.
0
means current_processors_amount * 2
nettyThreads
- amountpublic int getNettyThreads()
public Config setExecutor(ExecutorService executor)
RTopic
,
RRemoteService
invocation handlers
and RExecutorService
tasks.
The caller is responsible for closing the ExecutorService.
executor
- objectpublic ExecutorService getExecutor()
public Config setEventLoopGroup(io.netty.channel.EventLoopGroup eventLoopGroup)
Only EpollEventLoopGroup
,
KQueueEventLoopGroup
NioEventLoopGroup
can be used.
The caller is responsible for closing the EventLoopGroup.
eventLoopGroup
- objectpublic io.netty.channel.EventLoopGroup getEventLoopGroup()
public Config setLockWatchdogTimeout(long lockWatchdogTimeout)
lockWatchdogTimeout
if watchdog
didn't extend it to next lockWatchdogTimeout
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.
Default is 30000 milliseconds
lockWatchdogTimeout
- timeout in millisecondspublic long getLockWatchdogTimeout()
public Config setKeepPubSubOrder(boolean keepPubSubOrder)
This setting applied only for PubSub messages per channel.
Default is true
.
keepPubSubOrder
- - true
if order required, false
otherwise.public boolean isKeepPubSubOrder()
public Config setAddressResolverGroupFactory(AddressResolverGroupFactory addressResolverGroupFactory)
DnsAddressResolverGroup
implementations.
Switch to round robin RoundRobinDnsAddressResolverGroup
when you need to optimize the url resolving.addressResolverGroupFactory
- public AddressResolverGroupFactory getAddressResolverGroupFactory()
public static Config fromJSON(String content) throws IOException
String
content
- of configIOException
- errorpublic static Config fromJSON(InputStream inputStream) throws IOException
InputStream
inputStream
- objectIOException
- errorpublic static Config fromJSON(File file, ClassLoader classLoader) throws IOException
File
file
- objectclassLoader
- class loaderIOException
- errorpublic static Config fromJSON(File file) throws IOException
File
file
- objectIOException
- errorpublic static Config fromJSON(URL url) throws IOException
URL
url
- objectIOException
- errorpublic static Config fromJSON(Reader reader) throws IOException
Reader
reader
- objectIOException
- errorpublic String toJSON() throws IOException
IOException
- errorpublic static Config fromYAML(String content) throws IOException
String
content
- of configIOException
- errorpublic static Config fromYAML(InputStream inputStream) throws IOException
InputStream
inputStream
- objectIOException
- errorpublic static Config fromYAML(File file) throws IOException
File
file
- objectIOException
- errorpublic static Config fromYAML(File file, ClassLoader classLoader) throws IOException
IOException
public static Config fromYAML(URL url) throws IOException
URL
url
- objectIOException
- errorpublic static Config fromYAML(Reader reader) throws IOException
Reader
reader
- objectIOException
- errorpublic String toYAML() throws IOException
IOException
- errorpublic Config setUseScriptCache(boolean useScriptCache)
NOTE: readMode
option is not taken into account for such calls
as Redis slave redirects execution of cached Lua-script on Redis master node.
Default is false
.
useScriptCache
- - true
if Lua-script caching is required, false
otherwise.public boolean isUseScriptCache()
public boolean isDecodeInExecutor()
public Config setDecodeInExecutor(boolean decodeInExecutor)
codec
in executor's threads or netty's threads.
If decoding data process takes long time and netty thread is used then `RedisTimeoutException` could arise time to time.
Default is false
.
decodeInExecutor
- - true
to use executor's threads, false
to use netty's threads.Copyright © 2014–2019 The Redisson Project. All rights reserved.