Skip to content

Commit

Permalink
add swallow info log
Browse files Browse the repository at this point in the history
  • Loading branch information
hailu committed Jan 23, 2024
1 parent d3278d9 commit 1959955
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public void testUnknowParse() {
Assert.assertEquals(RedisOpType.UNKNOWN, redisOp.getOpType());
Assert.assertNull(redisOp.getOpGtid());
Assert.assertArrayEquals(rawOpArgs, redisOp.buildRawOpArgs());
byte[][] rawOpArgs1 = {"credis_flushall".getBytes()};
redisOp = parser.parse(rawOpArgs1);
Assert.assertEquals(RedisOpType.UNKNOWN, redisOp.getOpType());
Assert.assertNull(redisOp.getOpGtid());
Assert.assertArrayEquals(rawOpArgs1, redisOp.buildRawOpArgs());

RedisSingleKeyOp redisSingleKeyOp = (RedisSingleKeyOp) redisOp;
Assert.assertNull(redisSingleKeyOp.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ protected boolean shouldFilter(RedisOp redisOp) {
}
}
if (redisOp.getOpType().isSwallow()) {
logger.info("[onRedisOp] swallow redisOp: {}", redisOp);
EventMonitor.DEFAULT.logEvent("APPLIER.SWALLOW.OP", String.format("swallow redisOp %s", redisOp.toString()));
logger.info("[onRedisOp] swallow redisOp: {}", redisOp.toString());
EventMonitor.DEFAULT.logEvent("APPLIER.SWALLOW.OP", new String(redisOp.buildRawOpArgs()[0]));

Check warning on line 305 in redis/redis-keeper/src/main/java/com/ctrip/xpipe/redis/keeper/applier/xsync/DefaultCommandDispatcher.java

View check run for this annotation

Codecov / codecov/patch

redis/redis-keeper/src/main/java/com/ctrip/xpipe/redis/keeper/applier/xsync/DefaultCommandDispatcher.java#L304-L305

Added lines #L304 - L305 were not covered by tests
}
return redisOp.getOpType().isSwallow();
}
Expand Down Expand Up @@ -333,7 +333,7 @@ private void doOnRedisOp(RedisOp redisOp, long commandOffsetToAccumulate) {
}

if (shouldFilter(redisOp)) {
gtid_executed.get().add(redisOp.getOpGtid());
addLwm(redisOp);

Check warning on line 336 in redis/redis-keeper/src/main/java/com/ctrip/xpipe/redis/keeper/applier/xsync/DefaultCommandDispatcher.java

View check run for this annotation

Codecov / codecov/patch

redis/redis-keeper/src/main/java/com/ctrip/xpipe/redis/keeper/applier/xsync/DefaultCommandDispatcher.java#L336

Added line #L336 was not covered by tests
offsetRecorder.addAndGet(commandOffsetToAccumulate);
return;
}
Expand All @@ -349,6 +349,16 @@ private void doOnRedisOp(RedisOp redisOp, long commandOffsetToAccumulate) {
}
}

private void addLwm(RedisOp redisOp) {
stateThread.execute(() -> {

Check warning on line 353 in redis/redis-keeper/src/main/java/com/ctrip/xpipe/redis/keeper/applier/xsync/DefaultCommandDispatcher.java

View check run for this annotation

Codecov / codecov/patch

redis/redis-keeper/src/main/java/com/ctrip/xpipe/redis/keeper/applier/xsync/DefaultCommandDispatcher.java#L353

Added line #L353 was not covered by tests
try {
gtid_executed.get().add(redisOp.getOpGtid());
} catch (Throwable t) {
logger.error("[onRedisOp] unlikely - error", t);
}
});
}

Check warning on line 360 in redis/redis-keeper/src/main/java/com/ctrip/xpipe/redis/keeper/applier/xsync/DefaultCommandDispatcher.java

View check run for this annotation

Codecov / codecov/patch

redis/redis-keeper/src/main/java/com/ctrip/xpipe/redis/keeper/applier/xsync/DefaultCommandDispatcher.java#L355-L360

Added lines #L355 - L360 were not covered by tests

@Override
public void onRedisOp(RedisOp redisOp) {
doOnRedisOp(redisOp, 0);
Expand Down

0 comments on commit 1959955

Please sign in to comment.