public class MasterSlaveConnectionManager extends Object implements ConnectionManager
Modifier and Type | Field and Description |
---|---|
protected Codec |
codec |
protected MasterSlaveServersConfig |
config |
protected ConnectionListener |
connectListener |
protected Map<ClusterSlotRange,MasterSlaveEntry> |
entries |
protected io.netty.channel.EventLoopGroup |
group |
protected static int |
MAX_SLOT |
protected ConcurrentMap<String,PubSubConnectionEntry> |
name2PubSubConnection |
protected ClusterSlotRange |
singleSlotRange |
protected Class<? extends io.netty.channel.socket.SocketChannel> |
socketChannelClass |
Modifier | Constructor and Description |
---|---|
protected |
MasterSlaveConnectionManager() |
|
MasterSlaveConnectionManager(MasterSlaveServersConfig cfg,
Config config) |
Modifier and Type | Method and Description |
---|---|
protected void |
addEntry(ClusterSlotRange slotRange,
MasterSlaveEntry entry) |
int |
calcSlot(String key) |
protected void |
changeMaster(ClusterSlotRange slotRange,
String host,
int port) |
io.netty.util.concurrent.Future<RedisConnection> |
connectionReadOp(NodeSource source,
RedisCommand<?> command) |
io.netty.util.concurrent.Future<RedisConnection> |
connectionWriteOp(NodeSource source,
RedisCommand<?> command) |
RedisClient |
createClient(String host,
int port) |
RedisClient |
createClient(String host,
int port,
int timeout) |
<T> io.netty.util.concurrent.FutureListener<T> |
createReleaseReadListener(NodeSource source,
RedisConnection conn,
io.netty.util.Timeout timeout) |
<T> io.netty.util.concurrent.FutureListener<T> |
createReleaseWriteListener(NodeSource source,
RedisConnection conn,
io.netty.util.Timeout timeout) |
Collection<RedisClientEntry> |
getClients() |
Codec |
getCodec() |
MasterSlaveServersConfig |
getConfig() |
Map<ClusterSlotRange,MasterSlaveEntry> |
getEntries() |
protected MasterSlaveEntry |
getEntry(ClusterSlotRange slotRange) |
MasterSlaveEntry |
getEntry(InetSocketAddress addr) |
protected MasterSlaveEntry |
getEntry(int slot) |
io.netty.channel.EventLoopGroup |
getGroup() |
PubSubConnectionEntry |
getPubSubEntry(String channelName) |
InfinitySemaphoreLatch |
getShutdownLatch() |
io.netty.util.HashedWheelTimer |
getTimer() |
protected void |
init(Config cfg) |
protected void |
init(MasterSlaveServersConfig config) |
protected void |
init(MasterSlaveServersConfig config,
Config cfg) |
protected void |
initEntry(MasterSlaveServersConfig config) |
<R> io.netty.util.concurrent.Future<R> |
newFailedFuture(Throwable cause) |
<R> io.netty.util.concurrent.Promise<R> |
newPromise() |
io.netty.util.Timeout |
newTimeout(io.netty.util.TimerTask task,
long delay,
TimeUnit unit) |
io.netty.util.concurrent.Future<PubSubConnectionEntry> |
psubscribe(String channelName,
Codec codec) |
Codec |
punsubscribe(String channelName) |
void |
releaseRead(NodeSource source,
RedisConnection connection) |
protected void |
releaseSubscribeConnection(int slot,
PubSubConnectionEntry entry) |
void |
releaseWrite(NodeSource source,
RedisConnection connection) |
protected MasterSlaveEntry |
removeMaster(ClusterSlotRange slotRange) |
void |
shutdown() |
void |
shutdownAsync(RedisClient client) |
protected void |
slaveDown(ClusterSlotRange slotRange,
String host,
int port,
ConnectionEntry.FreezeReason freezeReason) |
void |
slaveDown(MasterSlaveEntry entry,
String host,
int port,
ConnectionEntry.FreezeReason freezeReason) |
void |
subscribe(RedisPubSubListener listener,
String channelName) |
io.netty.util.concurrent.Future<PubSubConnectionEntry> |
subscribe(String channelName,
Codec codec) |
Codec |
unsubscribe(String channelName) |
protected static final int MAX_SLOT
protected final ClusterSlotRange singleSlotRange
protected Codec codec
protected io.netty.channel.EventLoopGroup group
protected ConnectionListener connectListener
protected Class<? extends io.netty.channel.socket.SocketChannel> socketChannelClass
protected final ConcurrentMap<String,PubSubConnectionEntry> name2PubSubConnection
protected MasterSlaveServersConfig config
protected final Map<ClusterSlotRange,MasterSlaveEntry> entries
protected MasterSlaveConnectionManager()
public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config)
public io.netty.util.HashedWheelTimer getTimer()
getTimer
in interface ConnectionManager
public MasterSlaveServersConfig getConfig()
getConfig
in interface ConnectionManager
public Codec getCodec()
getCodec
in interface ConnectionManager
public Map<ClusterSlotRange,MasterSlaveEntry> getEntries()
getEntries
in interface ConnectionManager
protected void init(MasterSlaveServersConfig config, Config cfg)
protected void init(MasterSlaveServersConfig config)
protected void initEntry(MasterSlaveServersConfig config)
protected void init(Config cfg)
public RedisClient createClient(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 <T> io.netty.util.concurrent.FutureListener<T> createReleaseWriteListener(NodeSource source, RedisConnection conn, io.netty.util.Timeout timeout)
createReleaseWriteListener
in interface ConnectionManager
public <T> io.netty.util.concurrent.FutureListener<T> createReleaseReadListener(NodeSource source, RedisConnection conn, io.netty.util.Timeout timeout)
createReleaseReadListener
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> subscribe(String channelName, Codec codec)
subscribe
in interface ConnectionManager
public io.netty.util.concurrent.Future<PubSubConnectionEntry> psubscribe(String channelName, Codec codec)
psubscribe
in interface ConnectionManager
public void subscribe(RedisPubSubListener listener, String channelName)
subscribe
in interface ConnectionManager
public Codec unsubscribe(String channelName)
unsubscribe
in interface ConnectionManager
public Codec punsubscribe(String channelName)
punsubscribe
in interface ConnectionManager
public MasterSlaveEntry getEntry(InetSocketAddress addr)
getEntry
in interface ConnectionManager
protected MasterSlaveEntry getEntry(ClusterSlotRange slotRange)
protected MasterSlaveEntry getEntry(int slot)
public void slaveDown(MasterSlaveEntry entry, String host, int port, ConnectionEntry.FreezeReason freezeReason)
slaveDown
in interface ConnectionManager
protected void slaveDown(ClusterSlotRange slotRange, String host, int port, ConnectionEntry.FreezeReason freezeReason)
protected void changeMaster(ClusterSlotRange slotRange, String host, int port)
protected void addEntry(ClusterSlotRange slotRange, MasterSlaveEntry entry)
protected MasterSlaveEntry removeMaster(ClusterSlotRange slotRange)
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 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> 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
Copyright © 2014–2015. All rights reserved.