public class MasterSlaveConnectionManager extends Object implements ConnectionManager
Modifier and Type | Field and Description |
---|---|
protected Codec |
codec |
protected MasterSlaveServersConfig |
config |
protected ConnectionInitializer |
connectListener |
protected Queue<PubSubConnectionEntry> |
freePubSubConnections |
protected io.netty.channel.EventLoopGroup |
group |
static int |
MAX_SLOT |
protected ConcurrentMap<String,PubSubConnectionEntry> |
name2PubSubConnection |
protected ClusterSlotRange |
singleSlotRange |
protected Class<? extends io.netty.channel.socket.SocketChannel> |
socketChannelClass |
Constructor and Description |
---|
MasterSlaveConnectionManager(Config cfg) |
MasterSlaveConnectionManager(MasterSlaveServersConfig cfg,
Config config) |
public static final int MAX_SLOT
protected final ClusterSlotRange singleSlotRange
protected Codec codec
protected io.netty.channel.EventLoopGroup group
protected ConnectionInitializer connectListener
protected Class<? extends io.netty.channel.socket.SocketChannel> socketChannelClass
protected final ConcurrentMap<String,PubSubConnectionEntry> name2PubSubConnection
protected final Queue<PubSubConnectionEntry> freePubSubConnections
protected MasterSlaveServersConfig config
public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config)
public MasterSlaveConnectionManager(Config cfg)
public boolean isClusterMode()
isClusterMode
in interface ConnectionManager
public IdleConnectionWatcher getConnectionWatcher()
getConnectionWatcher
in interface ConnectionManager
public MasterSlaveServersConfig getConfig()
getConfig
in interface ConnectionManager
public Codec getCodec()
getCodec
in interface ConnectionManager
public Set<MasterSlaveEntry> getEntrySet()
getEntrySet
in interface ConnectionManager
protected void init(MasterSlaveServersConfig config)
public ConnectionInitializer getConnectListener()
getConnectListener
in interface ConnectionManager
protected void initEntry(MasterSlaveServersConfig config)
protected MasterSlaveEntry createMasterSlaveEntry(MasterSlaveServersConfig config, HashSet<ClusterSlotRange> slots)
protected MasterSlaveServersConfig create(BaseMasterSlaveServersConfig<?> cfg)
public RedisClient createClient(NodeType type, String host, int port)
createClient
in interface ConnectionManager
public void shutdownAsync(RedisClient client)
shutdownAsync
in interface ConnectionManager
public RedisClient createClient(String host, int port, int timeout)
createClient
in interface ConnectionManager
public int calcSlot(String key)
calcSlot
in interface ConnectionManager
public PubSubConnectionEntry getPubSubEntry(String channelName)
getPubSubEntry
in interface ConnectionManager
public io.netty.util.concurrent.Future<PubSubConnectionEntry> psubscribe(String channelName, Codec codec, RedisPubSubListener<?> listener)
psubscribe
in interface ConnectionManager
public io.netty.util.concurrent.Future<PubSubConnectionEntry> psubscribe(String channelName, Codec codec, RedisPubSubListener<?> listener, Semaphore semaphore)
psubscribe
in interface ConnectionManager
public io.netty.util.concurrent.Future<PubSubConnectionEntry> subscribe(Codec codec, String channelName, RedisPubSubListener<?> listener)
subscribe
in interface ConnectionManager
public io.netty.util.concurrent.Future<PubSubConnectionEntry> subscribe(Codec codec, String channelName, RedisPubSubListener<?> listener, Semaphore semaphore)
subscribe
in interface ConnectionManager
public Semaphore getSemaphore(String channelName)
getSemaphore
in interface ConnectionManager
public Codec unsubscribe(String channelName, Semaphore lock)
unsubscribe
in interface ConnectionManager
public Codec unsubscribe(String channelName)
unsubscribe
in interface ConnectionManager
public Codec punsubscribe(String channelName, Semaphore lock)
punsubscribe
in interface ConnectionManager
public Codec punsubscribe(String channelName)
punsubscribe
in interface ConnectionManager
public MasterSlaveEntry getEntry(InetSocketAddress addr)
getEntry
in interface ConnectionManager
public MasterSlaveEntry getEntry(int slot)
getEntry
in interface ConnectionManager
protected void slaveDown(ClusterSlotRange slotRange, String host, int port, ClientConnectionsEntry.FreezeReason freezeReason)
protected void changeMaster(int slot, String host, int port)
protected void addEntry(Integer slot, MasterSlaveEntry entry)
protected MasterSlaveEntry removeMaster(Integer slot)
public io.netty.util.concurrent.Future<RedisConnection> connectionWriteOp(NodeSource source, RedisCommand<?> command)
connectionWriteOp
in interface ConnectionManager
public io.netty.util.concurrent.Future<RedisConnection> connectionReadOp(NodeSource source, RedisCommand<?> command)
connectionReadOp
in interface ConnectionManager
protected void releaseSubscribeConnection(int slot, PubSubConnectionEntry entry)
public void releaseWrite(NodeSource source, RedisConnection connection)
releaseWrite
in interface ConnectionManager
public void releaseRead(NodeSource source, RedisConnection connection)
releaseRead
in interface ConnectionManager
public void shutdown()
shutdown
in interface ConnectionManager
public void shutdown(long quietPeriod, long timeout, TimeUnit unit)
shutdown
in interface ConnectionManager
public boolean isShuttingDown()
isShuttingDown
in interface ConnectionManager
public boolean isShutdown()
isShutdown
in interface ConnectionManager
public Collection<RedisClientEntry> getClients()
getClients
in interface ConnectionManager
public <R> io.netty.util.concurrent.Promise<R> newPromise()
newPromise
in interface ConnectionManager
public <R> io.netty.util.concurrent.Future<R> newSucceededFuture(R value)
newSucceededFuture
in interface ConnectionManager
public <R> io.netty.util.concurrent.Future<R> newFailedFuture(Throwable cause)
newFailedFuture
in interface ConnectionManager
public io.netty.channel.EventLoopGroup getGroup()
getGroup
in interface ConnectionManager
public io.netty.util.Timeout newTimeout(io.netty.util.TimerTask task, long delay, TimeUnit unit)
newTimeout
in interface ConnectionManager
public InfinitySemaphoreLatch getShutdownLatch()
getShutdownLatch
in interface ConnectionManager
public io.netty.util.concurrent.Future<Boolean> getShutdownPromise()
getShutdownPromise
in interface ConnectionManager
public ConnectionEventsHub getConnectionEventsHub()
getConnectionEventsHub
in interface ConnectionManager
protected void stopThreads()
public URI getLastClusterNode()
getLastClusterNode
in interface ConnectionManager
Copyright © 2014–2016. All rights reserved.