-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
706 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/codec/WalEntryCodec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.netease.nim.camellia.redis.proxy.upstream.local.storage.codec; | ||
|
||
import com.netease.nim.camellia.codec.Pack; | ||
import com.netease.nim.camellia.codec.Unpack; | ||
import com.netease.nim.camellia.redis.proxy.upstream.local.storage.key.KeyInfo; | ||
import com.netease.nim.camellia.redis.proxy.upstream.local.storage.wal.StringWalEntry; | ||
import com.netease.nim.camellia.redis.proxy.upstream.local.storage.wal.WalEntry; | ||
import com.netease.nim.camellia.redis.proxy.upstream.local.storage.wal.WalEntryType; | ||
|
||
/** | ||
* Created by caojiajun on 2025/1/17 | ||
*/ | ||
public class WalEntryCodec { | ||
|
||
public static byte[] encode(WalEntry walEntry) { | ||
if (walEntry instanceof StringWalEntry) { | ||
Pack pack = new Pack(); | ||
pack.putByte(WalEntryType.string.getType()); | ||
pack.putMarshallable(((StringWalEntry) walEntry).keyInfo()); | ||
byte[] value = ((StringWalEntry) walEntry).value(); | ||
if (value != null) { | ||
pack.putVarbin(value); | ||
} | ||
pack.getBuffer().capacity(pack.getBuffer().readableBytes()); | ||
return pack.getBuffer().array(); | ||
} else { | ||
throw new IllegalArgumentException("not support WalEntry"); | ||
} | ||
} | ||
|
||
public static WalEntry decode(byte[] data) { | ||
Unpack unpack = new Unpack(data); | ||
byte type = unpack.popByte(); | ||
if (type == WalEntryType.string.getType()) { | ||
KeyInfo keyInfo = new KeyInfo(); | ||
unpack.popMarshallable(keyInfo); | ||
byte[] value = null; | ||
if (unpack.getBuffer().readableBytes() > 0) { | ||
value = unpack.popVarbin(); | ||
} | ||
return new StringWalEntry(keyInfo, value); | ||
} else { | ||
throw new IllegalArgumentException("not support WalEntry"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...n/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/flush/FlushResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.netease.nim.camellia.redis.proxy.upstream.local.storage.flush; | ||
|
||
/** | ||
* Created by caojiajun on 2025/1/3 | ||
*/ | ||
public enum FlushResult { | ||
OK, | ||
ERROR, | ||
SKIP, | ||
; | ||
} |
11 changes: 11 additions & 0 deletions
11
...n/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/flush/FlushStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.netease.nim.camellia.redis.proxy.upstream.local.storage.flush; | ||
|
||
/** | ||
* Created by caojiajun on 2025/1/6 | ||
*/ | ||
public enum FlushStatus { | ||
PREPARE, | ||
FLUSHING, | ||
FLUSH_OK, | ||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...netease/nim/camellia/redis/proxy/upstream/local/storage/key/persist/KeyFlushExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.