Skip to content

Commit

Permalink
v0.9.1 redis-7.0-GA support
Browse files Browse the repository at this point in the history
  • Loading branch information
leonchen83 committed Apr 29, 2022
1 parent 75fff6d commit 474d0f9
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 320 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.9.1

Support for redis 7.0-GA.

### 0.9.0

Fix `redis sentinel` auth and ssl bug.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,13 @@ User should follow the steps below to implement a sink service.
<dependency>
<groupId>com.moilioncircle</groupId>
<artifactId>redis-rdb-cli-api</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.moilioncircle</groupId>
<artifactId>redis-replicator</artifactId>
<version>[3.6.2, )</version>
<version>[3.6.3, )</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,13 @@ migrate_flush=yes
<dependency>
<groupId>com.moilioncircle</groupId>
<artifactId>redis-rdb-cli-api</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.moilioncircle</groupId>
<artifactId>redis-replicator</artifactId>
<version>[3.6.2, )</version>
<version>[3.6.3, )</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>com.moilioncircle</groupId>
<artifactId>redis-replicator</artifactId>
<version>3.6.2</version>
<version>3.6.3</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -81,7 +81,7 @@
<dependency>
<groupId>com.moilioncircle</groupId>
<artifactId>redis-rdb-cli-api</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.moilioncircle.redis.rdb.cli.ext.datatype.CommandConstants.FUNCTION;
import static com.moilioncircle.redis.replicator.Constants.RDB_OPCODE_FUNCTION;
import static com.moilioncircle.redis.replicator.Constants.RDB_OPCODE_FUNCTION2;
import static com.moilioncircle.redis.replicator.rdb.datatype.ExpiredType.NONE;

import java.io.IOException;
Expand Down Expand Up @@ -67,6 +68,20 @@ public Event applyFunction(RedisInputStream in, int version) throws IOException
return event;
}

@Override
public Event applyFunction2(RedisInputStream in, int version) throws IOException {
escaper.encode(FUNCTION, out);
delimiter(out);
Event event = null;
version = getVersion(version);
try (DumpRawByteListener listener = new DumpRawByteListener(replicator, version, out, escaper)) {
listener.write((byte) RDB_OPCODE_FUNCTION2);
event = super.applyFunction2(in, version);
}
Outputs.write('\n', out);
return event;
}

@Override
public Event doApplyString(RedisInputStream in, int version, byte[] key, int type, ContextKeyValuePair context) throws IOException {
escaper.encode(key, out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static com.moilioncircle.redis.replicator.Constants.QUICKLIST_NODE_CONTAINER_PLAIN;
import static com.moilioncircle.redis.replicator.Constants.RDB_LOAD_NONE;
import static com.moilioncircle.redis.replicator.Constants.RDB_OPCODE_FUNCTION;
import static com.moilioncircle.redis.replicator.Constants.RDB_OPCODE_FUNCTION2;
import static com.moilioncircle.redis.replicator.Constants.RDB_TYPE_HASH;
import static com.moilioncircle.redis.replicator.Constants.RDB_TYPE_LIST;
import static com.moilioncircle.redis.replicator.Constants.RDB_TYPE_ZSET;
Expand Down Expand Up @@ -89,6 +90,23 @@ public Event applyFunction(RedisInputStream in, int version) throws IOException
}
}

@Override
public Event applyFunction2(RedisInputStream in, int version) throws IOException {
version = getVersion(version);
if (version < 10 /* since redis rdb version 10 */) {
return super.applyFunction2(in, version);
} else {
try (LayeredOutputStream out = new LayeredOutputStream(configure)) {
try (DumpRawByteListener listener = new DumpRawByteListener(replicator, version, out, escaper)) {
listener.write((byte) RDB_OPCODE_FUNCTION2);
super.applyFunction2(in, version);
}
Protocols.functionRestore(this.out, out.toByteBuffers(), replace);
return new DumpFunction();
}
}
}

@Override
protected Event doApplyString(RedisInputStream in, int version, byte[] key, int type, ContextKeyValuePair context) throws IOException {
ByteBuffer ex = ZERO_BUF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.moilioncircle.redis.rdb.cli.ext.rct;

import static com.moilioncircle.redis.replicator.Constants.RDB_OPCODE_FUNCTION;
import static com.moilioncircle.redis.replicator.Constants.RDB_OPCODE_FUNCTION2;

import java.io.IOException;

Expand Down Expand Up @@ -85,6 +86,11 @@ public Event applyAux(RedisInputStream in, int version) throws IOException {
public Event applyFunction(RedisInputStream in, int version) throws IOException {
return formatter.applyFunction(replicator, in, version, RDB_OPCODE_FUNCTION);
}

@Override
public Event applyFunction2(RedisInputStream in, int version) throws IOException {
return formatter.applyFunction2(replicator, in, version, RDB_OPCODE_FUNCTION2);
}

@Override
protected Event doApplyString(RedisInputStream in, int version, byte[] key, int type, ContextKeyValuePair context) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ public Event applyFunction(RedisInputStream in, int version) throws IOException
return function;
}

@Override
public Event applyFunction2(RedisInputStream in, int version) throws IOException {
Function function = (Function) super.applyFunction2(in, version);
Protocols.functionLoad(this.out, function, replace);
return function;
}

@Override
public DB applySelectDB(RedisInputStream in, int version) throws IOException {
DB db = super.applySelectDB(in, version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ public Event applyFunction(RedisInputStream in, int version) throws IOException
listener.setGuard(Guard.SAVE);
}
}

@Override
public Event applyFunction2(RedisInputStream in, int version) throws IOException {
listener.setGuard(Guard.DRAIN);
try {
return super.applyFunction2(in, version);
} finally {
listener.setGuard(Guard.SAVE);
}
}

@Override
public DB applySelectDB(RedisInputStream in, int version) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ public Event applyFunction(RedisInputStream in, int version) throws IOException
}
}

@Override
public Event applyFunction2(RedisInputStream in, int version) throws IOException {
listener.setGuard(Guard.DRAIN);
try {
return super.applyFunction2(in, version);
} finally {
listener.setGuard(Guard.SAVE);
}
}

@Override
public DB applySelectDB(RedisInputStream in, int version) throws IOException {
listener.setGuard(Guard.DRAIN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ public Event applyFunction(RedisInputStream in, int version) throws IOException
listener.setGuard(Guard.SAVE);
}
}

@Override
public Event applyFunction2(RedisInputStream in, int version) throws IOException {
listener.setGuard(Guard.DRAIN);
try {
return super.applyFunction2(in, version);
} finally {
listener.setGuard(Guard.SAVE);
}
}

@Override
public DB applySelectDB(RedisInputStream in, int version) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public Event applyFunction(RedisInputStream in, int version) throws IOException
return function;
}

@Override
public Event applyFunction2(RedisInputStream in, int version) throws IOException {
DumpFunction function = valueVisitor.applyFunction2(in, version);
return function;
}

@Override
protected Event doApplyString(RedisInputStream in, int version, byte[] key, int type, ContextKeyValuePair context) throws IOException {
DumpKeyValuePair dump = new DumpKeyValuePair();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public Event applyFunction(RedisInputStream in, int version) throws IOException
return function;
}

@Override
public Event applyFunction2(RedisInputStream in, int version) throws IOException {
DumpFunction function = valueVisitor.applyFunction2(in, version);
return function;
}

@Override
protected Event doApplyString(RedisInputStream in, int version, byte[] key, int type, ContextKeyValuePair context) throws IOException {
DumpKeyValuePair dump = new DumpKeyValuePair();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import com.moilioncircle.redis.replicator.rdb.DefaultRdbVisitor;
import com.moilioncircle.redis.replicator.rdb.RdbValueVisitor;
import com.moilioncircle.redis.replicator.rdb.datatype.ContextKeyValuePair;
import com.moilioncircle.redis.replicator.rdb.skip.SkipRdbValueVisitor;
import com.moilioncircle.redis.replicator.util.Strings;

/**
Expand Down
Loading

0 comments on commit 474d0f9

Please sign in to comment.