Class RedisSocketReplicator
- java.lang.Object
-
- com.moilioncircle.redis.replicator.AbstractReplicatorListener
-
- com.moilioncircle.redis.replicator.AbstractReplicator
-
- com.moilioncircle.redis.replicator.RedisSocketReplicator
-
- All Implemented Interfaces:
Replicator,ReplicatorListener,ReplicatorRegister,Closeable,AutoCloseable
public class RedisSocketReplicator extends AbstractReplicator
- Since:
- 2.1.0
- Author:
- Leon Chen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classRedisSocketReplicator.SyncMode
-
Field Summary
Fields Modifier and Type Field Description protected intdbprotected XScheduledExecutorServiceexecutorprotected ScheduledFuture<?>heartbeatprotected Stringhostprotected static org.slf4j.Loggerloggerprotected AtomicBooleanmanualprotected RedisOutputStreamoutputStreamprotected intportprotected ReplFilter[]replFiltersprotected ReplyParserreplyParserprotected Socketsocketprotected RedisSocketFactorysocketFactory-
Fields inherited from class com.moilioncircle.redis.replicator.AbstractReplicator
commands, configuration, connected, inputStream, modules, rdbVisitor
-
Fields inherited from class com.moilioncircle.redis.replicator.AbstractReplicatorListener
closeListeners, eventListeners, exceptionListeners, rawByteListeners, statusListeners
-
-
Constructor Summary
Constructors Constructor Description RedisSocketReplicator(String host, int port, Configuration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidauth(String user, String password)voidclose()protected voidconnect()protected voiddoClose()protected voidestablishConnection()StringgetHost()intgetPort()protected voidheartbeat()voidopen()PSYNCprotected voidparseDump(AbstractReplicator replicator)protected <T> Treply()protected <T> Treply(BulkReplyHandler handler)protected voidsend(byte[] command)protected voidsend(byte[] command, byte[]... args)protected voidsendPing()protected voidsendQuietly(byte[] command, byte[]... args)protected voidsendSlaveCapa(String cmd)protected voidsendSlaveFilter(ReplFilter filter)protected voidsendSlaveIp()protected voidsendSlavePort()protected RedisSocketReplicator.SyncModetrySync(String reply)-
Methods inherited from class com.moilioncircle.redis.replicator.AbstractReplicator
addCommandParser, addModuleParser, builtInCommandParserRegister, compareAndSet, doOpen, dress, getCommandParser, getConfiguration, getModuleParser, getRdbVisitor, getStatus, removeCommandParser, removeModuleParser, setRdbVisitor, setStatus, submitEvent, submitEvent, verbose
-
Methods inherited from class com.moilioncircle.redis.replicator.AbstractReplicatorListener
addCloseListener, addEventListener, addExceptionListener, addRawByteListener, addStatusListener, doCloseListener, doEventListener, doExceptionListener, doStatusListener, removeCloseListener, removeEventListener, removeExceptionListener, removeRawByteListener, removeStatusListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.moilioncircle.redis.replicator.ReplicatorListener
addCloseListener, addEventListener, addExceptionListener, addRawByteListener, addStatusListener, removeCloseListener, removeEventListener, removeExceptionListener, removeRawByteListener, removeStatusListener
-
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
db
protected int db
-
socket
protected Socket socket
-
replyParser
protected ReplyParser replyParser
-
heartbeat
protected ScheduledFuture<?> heartbeat
-
outputStream
protected RedisOutputStream outputStream
-
executor
protected XScheduledExecutorService executor
-
port
protected final int port
-
host
protected final String host
-
replFilters
protected final ReplFilter[] replFilters
-
socketFactory
protected final RedisSocketFactory socketFactory
-
manual
protected final AtomicBoolean manual
-
-
Constructor Detail
-
RedisSocketReplicator
public RedisSocketReplicator(String host, int port, Configuration configuration)
-
-
Method Detail
-
getHost
public String getHost()
-
getPort
public int getPort()
-
open
public void open() throws IOExceptionPSYNC- Specified by:
openin interfaceReplicator- Overrides:
openin classAbstractReplicator- Throws:
IOException- when read timeout or connect timeout
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceReplicator- Overrides:
closein classAbstractReplicator- Throws:
IOException
-
trySync
protected RedisSocketReplicator.SyncMode trySync(String reply) throws IOException
- Throws:
IOException
-
parseDump
protected void parseDump(AbstractReplicator replicator) throws IOException
- Throws:
IOException
-
establishConnection
protected void establishConnection() throws IOException- Throws:
IOException
-
auth
protected void auth(String user, String password) throws IOException
- Throws:
IOException
-
sendPing
protected void sendPing() throws IOException- Throws:
IOException
-
sendSlavePort
protected void sendSlavePort() throws IOException- Throws:
IOException
-
sendSlaveIp
protected void sendSlaveIp() throws IOException- Throws:
IOException
-
sendSlaveCapa
protected void sendSlaveCapa(String cmd) throws IOException
- Throws:
IOException
-
sendSlaveFilter
protected void sendSlaveFilter(ReplFilter filter) throws IOException
- Throws:
IOException
-
heartbeat
protected void heartbeat()
-
send
protected void send(byte[] command) throws IOException- Throws:
IOException
-
send
protected void send(byte[] command, byte[]... args) throws IOException- Throws:
IOException
-
sendQuietly
protected void sendQuietly(byte[] command, byte[]... args)
-
reply
protected <T> T reply() throws IOException- Throws:
IOException
-
reply
protected <T> T reply(BulkReplyHandler handler) throws IOException
- Throws:
IOException
-
connect
protected void connect() throws IOException- Throws:
IOException
-
doClose
protected void doClose() throws IOException- Overrides:
doClosein classAbstractReplicator- Throws:
IOException
-
-