use of com.ctrip.xpipe.redis.keeper.RedisClient in project x-pipe by ctripcorp.
the class XRedisPartialTest method createRedisKeeperServer.
@Override
protected RedisKeeperServer createRedisKeeperServer(KeeperMeta keeperMeta, File baseDir, KeeperConfig keeperConfig, MetaServerKeeperService metaService, LeaderElectorManager leaderElectorManager, KeepersMonitorManager keeperMonitorManager) {
return new DefaultRedisKeeperServer(keeperMeta, keeperConfig, baseDir, metaService, leaderElectorManager, keeperMonitorManager) {
private int count = 0;
@Override
public RedisKeeperServerState getRedisKeeperServerState() {
RedisKeeperServerState redisKeeperServerState = super.getRedisKeeperServerState();
return (RedisKeeperServerState) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { RedisKeeperServerState.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("psync")) {
count++;
logger.info("[psync][count]{}, {}", args, count);
if (count == 2) {
RedisClient redisClient = (RedisClient) args[0];
logger.info("[psync][close client]{}, {}", count, redisClient);
redisClient.close();
}
}
return method.invoke(redisKeeperServerState, args);
}
});
}
};
}
use of com.ctrip.xpipe.redis.keeper.RedisClient in project x-pipe by ctripcorp.
the class DefaultRedisSlaveTest method beforeDefaultRedisSlaveTest.
@Before
public void beforeDefaultRedisSlaveTest() {
when(channel.closeFuture()).thenReturn(new DefaultChannelPromise(channel));
when(channel.remoteAddress()).thenReturn(localhostInetAddress(randomPort()));
RedisClient redisClient = new DefaultRedisClient(channel, redisKeeperServer);
redisSlave = new DefaultRedisSlave(redisClient);
redisSlave.setRdbDumpMaxWaitMilli(waitDumpMilli);
}
Aggregations