public class MasterSlaveConnectionManager extends Object implements ConnectionManager
Modifier and Type | Field and Description |
---|---|
protected RedisCodec |
codec |
protected MasterSlaveServersConfig |
config |
protected NavigableMap<Integer,MasterSlaveEntry> |
entries |
protected io.netty.channel.EventLoopGroup |
group |
protected ConcurrentMap<String,PubSubConnectionEntry> |
name2PubSubConnection |
Constructor and Description |
---|
MasterSlaveConnectionManager(MasterSlaveServersConfig cfg,
Config config) |
Modifier and Type | Method and Description |
---|---|
protected void |
addSlave(String host,
int port) |
protected void |
changeMaster(String host,
int port)
Freeze slave with
host:port from slaves list. |
<K,V> RedisConnection<K,V> |
connectionReadOp(int slot) |
protected <K,V> RedisConnection<K,V> |
connectionWriteOp(int slot) |
<T> io.netty.util.concurrent.FutureListener<T> |
createReleaseReadListener(int slot,
RedisConnection conn) |
<T> io.netty.util.concurrent.FutureListener<T> |
createReleaseWriteListener(int slot,
RedisConnection conn) |
<V> V |
get(io.netty.util.concurrent.Future<V> future) |
protected MasterSlaveEntry |
getEntry() |
protected MasterSlaveEntry |
getEntry(int slot) |
PubSubConnectionEntry |
getEntry(String channelName) |
io.netty.channel.EventLoopGroup |
getGroup() |
protected void |
init(Config cfg) |
protected void |
init(MasterSlaveServersConfig config) |
protected void |
init(MasterSlaveServersConfig config,
Config cfg) |
<V,T> T |
read(AsyncOperation<V,T> asyncOperation) |
<V,R> R |
read(SyncOperation<V,R> operation) |
<V,T> io.netty.util.concurrent.Future<T> |
readAsync(AsyncOperation<V,T> asyncOperation) |
void |
releaseRead(int slot,
RedisConnection connection) |
protected void |
releaseWrite(int slot,
RedisConnection connection) |
protected void |
returnSubscribeConnection(int slot,
PubSubConnectionEntry entry) |
void |
shutdown() |
protected void |
slaveDown(String host,
int port) |
protected void |
slaveUp(String host,
int port) |
<K,V> PubSubConnectionEntry |
subscribe(RedisPubSubAdapter<V> listener,
String channelName) |
<K,V> PubSubConnectionEntry |
subscribe(String channelName) |
io.netty.util.concurrent.Future |
unsubscribe(String channelName) |
<V,R> R |
write(AsyncOperation<V,R> asyncOperation) |
<V,R> R |
write(SyncOperation<V,R> operation) |
<V,T> io.netty.util.concurrent.Future<T> |
writeAllAsync(AsyncOperation<V,T> asyncOperation) |
<V,T> io.netty.util.concurrent.Future<T> |
writeAsync(AsyncOperation<V,T> asyncOperation) |
protected RedisCodec codec
protected io.netty.channel.EventLoopGroup group
protected final ConcurrentMap<String,PubSubConnectionEntry> name2PubSubConnection
protected MasterSlaveServersConfig config
protected NavigableMap<Integer,MasterSlaveEntry> entries
public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config)
protected void init(MasterSlaveServersConfig config, Config cfg)
protected void init(MasterSlaveServersConfig config)
protected void init(Config cfg)
public <T> io.netty.util.concurrent.FutureListener<T> createReleaseWriteListener(int slot, RedisConnection conn)
public <T> io.netty.util.concurrent.FutureListener<T> createReleaseReadListener(int slot, RedisConnection conn)
public <V,T> io.netty.util.concurrent.Future<T> writeAllAsync(AsyncOperation<V,T> asyncOperation)
writeAllAsync
in interface ConnectionManager
public <V,T> io.netty.util.concurrent.Future<T> writeAsync(AsyncOperation<V,T> asyncOperation)
writeAsync
in interface ConnectionManager
public <V,R> R write(SyncOperation<V,R> operation)
write
in interface ConnectionManager
public <V,R> R read(SyncOperation<V,R> operation)
read
in interface ConnectionManager
public <V,R> R write(AsyncOperation<V,R> asyncOperation)
write
in interface ConnectionManager
public <V> V get(io.netty.util.concurrent.Future<V> future)
get
in interface ConnectionManager
public <V,T> T read(AsyncOperation<V,T> asyncOperation)
read
in interface ConnectionManager
public <V,T> io.netty.util.concurrent.Future<T> readAsync(AsyncOperation<V,T> asyncOperation)
readAsync
in interface ConnectionManager
public PubSubConnectionEntry getEntry(String channelName)
getEntry
in interface ConnectionManager
public <K,V> PubSubConnectionEntry subscribe(String channelName)
subscribe
in interface ConnectionManager
public <K,V> PubSubConnectionEntry subscribe(RedisPubSubAdapter<V> listener, String channelName)
subscribe
in interface ConnectionManager
public io.netty.util.concurrent.Future unsubscribe(String channelName)
unsubscribe
in interface ConnectionManager
protected MasterSlaveEntry getEntry()
protected MasterSlaveEntry getEntry(int slot)
protected void slaveDown(String host, int port)
protected void addSlave(String host, int port)
protected void slaveUp(String host, int port)
protected void changeMaster(String host, int port)
host:port
from slaves list.
Re-attach pub/sub listeners from it to other slave.
Shutdown old master client.protected <K,V> RedisConnection<K,V> connectionWriteOp(int slot)
public <K,V> RedisConnection<K,V> connectionReadOp(int slot)
connectionReadOp
in interface ConnectionManager
protected void returnSubscribeConnection(int slot, PubSubConnectionEntry entry)
protected void releaseWrite(int slot, RedisConnection connection)
public void releaseRead(int slot, RedisConnection connection)
releaseRead
in interface ConnectionManager
public void shutdown()
shutdown
in interface ConnectionManager
public io.netty.channel.EventLoopGroup getGroup()
getGroup
in interface ConnectionManager
Copyright © 2014. All rights reserved.