Skip to content

Commit

Permalink
2.3.1-release
Browse files Browse the repository at this point in the history
add 3 command
ltrim
rpoplpush
sort

fix reconnect bug
  • Loading branch information
leonchen83 committed Jul 29, 2017
1 parent a826663 commit d34e562
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The following I mentioned `Command` which means `Writable Command` in redis and
## 2.1. Requirements
jdk 1.7+
maven-3.2.3+
redis 2.4 - 4.0
redis 2.6 - 4.0

## 2.2. Maven dependency
```java
Expand All @@ -98,9 +98,9 @@ redis 2.4 - 4.0

| **redis version** |**redis-replicator version** |
| ---------------------------- | ---------------------------- |
| \[2.4, 4.0.0\] | \[2.3.0\] |
| \[2.4, 4.0-RC3\] | \[2.1.0, 2.2.0\] |
| \[2.4, 3.2.x\] | \[1.0.18\](not supported) |
| \[2.6, 4.0.0\] | \[2.3.0\] |
| \[2.6, 4.0-RC3\] | \[2.1.0, 2.2.0\] |
| \[2.6, 3.2.x\] | \[1.0.18\](not supported) |


# 3. Simple usage
Expand Down
8 changes: 4 additions & 4 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Redis Replicator是一款rdb解析以及命令解析的工具. 此工具完整
## 2.1. 安装前置条件
jdk 1.7+
maven-3.2.3+
redis 2.4 - 4.0
redis 2.6 - 4.0

## 2.2. Maven依赖
```java
Expand All @@ -103,9 +103,9 @@ redis 2.4 - 4.0

| **redis 版本** |**redis-replicator 版本** |
| ------------------------- | ------------------------- |
| \[2.4, 4.0.0\] | \[2.3.0\] |
| \[2.4, 4.0-RC3\] | \[2.1.0, 2.2.0\] |
| \[2.4, 3.2.x\] | \[1.0.18\](不再提供支持) |
| \[2.6, 4.0.0\] | \[2.3.0\] |
| \[2.6, 4.0-RC3\] | \[2.1.0, 2.2.0\] |
| \[2.6, 3.2.x\] | \[1.0.18\](不再提供支持) |


# 3. 简要用法
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,13 @@ public byte[] handle(long len, RedisInputStream in) throws IOException {
//sync command
String reply = new String(rawReply, UTF_8);
if ("OK".equals(reply)) return;
//redis 2.8+
if (reply.contains("NOAUTH")) throw new AssertionError(reply);
//redis 2.4 - 2.6
if (reply.contains("operation not permitted")) throw new AssertionError(reply);
throw new IOException("SYNC failed. reason : [" + reply + "]");
}

protected void establishConnection() throws IOException {
connect();
if (configuration.getAuthPassword() != null) auth(configuration.getAuthPassword());
sendPing();
sendSlavePort();
sendSlaveIp();
sendSlaveCapa("eof");
Expand All @@ -245,10 +242,27 @@ protected void auth(String password) throws IOException {
final String reply = new String((byte[]) reply(), UTF_8);
logger.info(reply);
if ("OK".equals(reply)) return;
if (reply.contains("no password")) {
logger.warn("[AUTH " + password + "] failed. " + reply);
return;
}
throw new AssertionError("[AUTH " + password + "] failed. " + reply);
}
}

protected void sendPing() throws IOException {
if (logger.isInfoEnabled()) {
logger.info("PING");
}
send("PING".getBytes());
final String reply = new String((byte[]) reply(), UTF_8);
logger.info(reply);
if ("PONG".equalsIgnoreCase(reply)) return;
if (reply.contains("NOAUTH")) throw new AssertionError(reply);
if (reply.contains("operation not permitted")) throw new AssertionError("-NOAUTH Authentication required.");
logger.warn("[PING] failed. " + reply);
}

protected void sendSlavePort() throws IOException {
//REPLCONF listening-prot ${port}
if (logger.isInfoEnabled()) {
Expand All @@ -259,7 +273,7 @@ protected void sendSlavePort() throws IOException {
logger.info(reply);
if ("OK".equals(reply)) return;
if (logger.isWarnEnabled()) {
logger.warn("[REPLCONF listening-port " + socket.getLocalPort() + "] failed." + reply);
logger.warn("[REPLCONF listening-port " + socket.getLocalPort() + "] failed. " + reply);
}
}

Expand All @@ -274,7 +288,7 @@ protected void sendSlaveIp() throws IOException {
if ("OK".equals(reply)) return;
//redis 3.2+
if (logger.isWarnEnabled()) {
logger.warn("[REPLCONF ip-address " + socket.getLocalAddress().getHostAddress() + "] failed." + reply);
logger.warn("[REPLCONF ip-address " + socket.getLocalAddress().getHostAddress() + "] failed. " + reply);
}
}

Expand All @@ -288,7 +302,7 @@ protected void sendSlaveCapa(String cmd) throws IOException {
logger.info(reply);
if ("OK".equals(reply)) return;
if (logger.isWarnEnabled()) {
logger.warn("[REPLCONF capa " + cmd + "] failed." + reply);
logger.warn("[REPLCONF capa " + cmd + "] failed. " + reply);
}
}

Expand Down

0 comments on commit d34e562

Please sign in to comment.