Package org.redisson.connection
Class MasterSlaveConnectionManager
- java.lang.Object
-
- org.redisson.connection.MasterSlaveConnectionManager
-
- All Implemented Interfaces:
ConnectionManager
- Direct Known Subclasses:
ClusterConnectionManager
,ReplicatedConnectionManager
,SentinelConnectionManager
,SingleConnectionManager
public class MasterSlaveConnectionManager extends Object implements ConnectionManager
- Author:
- Nikita Koksharov
-
-
Field Summary
Fields Modifier and Type Field Description protected Codec
codec
protected MasterSlaveServersConfig
config
protected DNSMonitor
dnsMonitor
static io.netty.util.Timeout
DUMMY_TIMEOUT
protected io.netty.channel.EventLoopGroup
group
protected String
id
static int
MAX_SLOT
protected io.netty.resolver.AddressResolverGroup<InetSocketAddress>
resolverGroup
protected ClusterSlotRange
singleSlotRange
protected Class<? extends io.netty.channel.socket.SocketChannel>
socketChannelClass
protected PublishSubscribeService
subscribeService
-
Constructor Summary
Constructors Modifier Constructor Description protected
MasterSlaveConnectionManager(Config cfg, UUID id)
MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config, UUID id)
-
Method Summary
-
-
-
Field Detail
-
DUMMY_TIMEOUT
public static final io.netty.util.Timeout DUMMY_TIMEOUT
-
id
protected final String id
-
MAX_SLOT
public static final int MAX_SLOT
- See Also:
- Constant Field Values
-
singleSlotRange
protected final ClusterSlotRange singleSlotRange
-
codec
protected Codec codec
-
group
protected final io.netty.channel.EventLoopGroup group
-
socketChannelClass
protected final Class<? extends io.netty.channel.socket.SocketChannel> socketChannelClass
-
dnsMonitor
protected DNSMonitor dnsMonitor
-
config
protected MasterSlaveServersConfig config
-
resolverGroup
protected final io.netty.resolver.AddressResolverGroup<InetSocketAddress> resolverGroup
-
subscribeService
protected PublishSubscribeService subscribeService
-
-
Constructor Detail
-
MasterSlaveConnectionManager
public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config, UUID id)
-
-
Method Detail
-
closeNodeConnections
protected void closeNodeConnections()
-
closeNodeConnection
protected void closeNodeConnection(RedisConnection conn)
-
disconnectNode
protected final void disconnectNode(RedisURI addr)
-
connectToNode
protected final CompletionStage<RedisConnection> connectToNode(BaseConfig<?> cfg, RedisURI addr, String sslHostname)
-
connectToNode
protected final CompletionStage<RedisConnection> connectToNode(NodeType type, BaseConfig<?> cfg, RedisURI addr, String sslHostname)
-
getId
public String getId()
- Specified by:
getId
in interfaceConnectionManager
-
isClusterMode
public boolean isClusterMode()
- Specified by:
isClusterMode
in interfaceConnectionManager
-
getConnectionWatcher
public IdleConnectionWatcher getConnectionWatcher()
- Specified by:
getConnectionWatcher
in interfaceConnectionManager
-
getCfg
public Config getCfg()
- Specified by:
getCfg
in interfaceConnectionManager
-
getConfig
public MasterSlaveServersConfig getConfig()
- Specified by:
getConfig
in interfaceConnectionManager
-
getCodec
public Codec getCodec()
- Specified by:
getCodec
in interfaceConnectionManager
-
getEntrySet
public Collection<MasterSlaveEntry> getEntrySet()
- Specified by:
getEntrySet
in interfaceConnectionManager
-
initTimer
protected void initTimer(MasterSlaveServersConfig config)
-
initSingleEntry
protected void initSingleEntry()
-
startDNSMonitoring
protected void startDNSMonitoring(RedisClient masterHost)
-
getDisconnectedNodes
protected Collection<RedisURI> getDisconnectedNodes()
-
create
protected MasterSlaveServersConfig create(BaseMasterSlaveServersConfig<?> cfg)
-
createClient
public RedisClient createClient(NodeType type, RedisURI address, String sslHostname)
- Specified by:
createClient
in interfaceConnectionManager
-
createClient
public RedisClient createClient(NodeType type, InetSocketAddress address, RedisURI uri, String sslHostname)
- Specified by:
createClient
in interfaceConnectionManager
-
createClient
public RedisClient createClient(NodeType type, RedisURI address, int timeout, int commandTimeout, String sslHostname)
- Specified by:
createClient
in interfaceConnectionManager
-
createRedisConfig
protected RedisClientConfig createRedisConfig(NodeType type, RedisURI address, int timeout, int commandTimeout, String sslHostname)
-
calcSlot
public int calcSlot(String key)
- Specified by:
calcSlot
in interfaceConnectionManager
-
calcSlot
public int calcSlot(byte[] key)
- Specified by:
calcSlot
in interfaceConnectionManager
-
getEntry
public MasterSlaveEntry getEntry(InetSocketAddress address)
- Specified by:
getEntry
in interfaceConnectionManager
-
getEntry
protected MasterSlaveEntry getEntry(RedisURI addr)
-
getEntry
public MasterSlaveEntry getEntry(RedisClient redisClient)
- Specified by:
getEntry
in interfaceConnectionManager
-
getEntry
public MasterSlaveEntry getEntry(String name)
- Specified by:
getEntry
in interfaceConnectionManager
-
getEntry
public MasterSlaveEntry getEntry(int slot)
- Specified by:
getEntry
in interfaceConnectionManager
-
changeMaster
protected CompletableFuture<RedisClient> changeMaster(int slot, RedisURI address)
-
connectionWriteOp
public RFuture<RedisConnection> connectionWriteOp(NodeSource source, RedisCommand<?> command)
- Specified by:
connectionWriteOp
in interfaceConnectionManager
-
connectionReadOp
public RFuture<RedisConnection> connectionReadOp(NodeSource source, RedisCommand<?> command)
- Specified by:
connectionReadOp
in interfaceConnectionManager
-
createNodeNotFoundException
public RedisNodeNotFoundException createNodeNotFoundException(NodeSource source)
- Specified by:
createNodeNotFoundException
in interfaceConnectionManager
-
releaseWrite
public void releaseWrite(NodeSource source, RedisConnection connection)
- Specified by:
releaseWrite
in interfaceConnectionManager
-
releaseRead
public void releaseRead(NodeSource source, RedisConnection connection)
- Specified by:
releaseRead
in interfaceConnectionManager
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceConnectionManager
-
shutdown
public void shutdown(long quietPeriod, long timeout, TimeUnit unit)
- Specified by:
shutdown
in interfaceConnectionManager
-
isShuttingDown
public boolean isShuttingDown()
- Specified by:
isShuttingDown
in interfaceConnectionManager
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfaceConnectionManager
-
getGroup
public io.netty.channel.EventLoopGroup getGroup()
- Specified by:
getGroup
in interfaceConnectionManager
-
newTimeout
public io.netty.util.Timeout newTimeout(io.netty.util.TimerTask task, long delay, TimeUnit unit)
- Specified by:
newTimeout
in interfaceConnectionManager
-
getShutdownLatch
public InfinitySemaphoreLatch getShutdownLatch()
- Specified by:
getShutdownLatch
in interfaceConnectionManager
-
getShutdownPromise
public io.netty.util.concurrent.Future<Void> getShutdownPromise()
- Specified by:
getShutdownPromise
in interfaceConnectionManager
-
getConnectionEventsHub
public ConnectionEventsHub getConnectionEventsHub()
- Specified by:
getConnectionEventsHub
in interfaceConnectionManager
-
stopThreads
protected void stopThreads()
-
getSubscribeService
public PublishSubscribeService getSubscribeService()
- Specified by:
getSubscribeService
in interfaceConnectionManager
-
getElementsSubscribeService
public ElementsSubscribeService getElementsSubscribeService()
- Specified by:
getElementsSubscribeService
in interfaceConnectionManager
-
getExecutor
public ExecutorService getExecutor()
- Specified by:
getExecutor
in interfaceConnectionManager
-
getLastClusterNode
public RedisURI getLastClusterNode()
- Specified by:
getLastClusterNode
in interfaceConnectionManager
-
applyNatMap
public RedisURI applyNatMap(RedisURI address)
- Specified by:
applyNatMap
in interfaceConnectionManager
-
resolveIP
public CompletableFuture<RedisURI> resolveIP(RedisURI address)
- Specified by:
resolveIP
in interfaceConnectionManager
-
resolveIP
protected CompletableFuture<RedisURI> resolveIP(String scheme, RedisURI address)
-
-