use of com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer 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.impl.DefaultRedisKeeperServer in project x-pipe by ctripcorp.
the class DefaultRedisKeeperServerConnectToFakeRedisTest method testDumpWhileWaitForRdb.
@Test
public void testDumpWhileWaitForRdb() throws Exception {
int sleepBeforeSendRdb = 2000;
fakeRedisServer.setSleepBeforeSendRdb(sleepBeforeSendRdb);
RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis(100, allCommandsSize);
sleep(sleepBeforeSendRdb / 4);
int rdbDumpCount1 = ((DefaultRedisKeeperServer) redisKeeperServer).getRdbDumpTryCount();
Assert.assertEquals(1, rdbDumpCount1);
int keeperPort = redisKeeperServer.getListeningPort();
logger.info(remarkableMessage("send psync to keeper port:{}"), keeperPort);
InMemoryPsync psync = sendInmemoryPsync("localhost", keeperPort, "?", -1L);
sleep(1000);
int rdbDumpCount2 = ((DefaultRedisKeeperServer) redisKeeperServer).getRdbDumpTryCount();
Assert.assertEquals(1, rdbDumpCount2);
sleep(sleepBeforeSendRdb);
assertPsyncResultEquals(psync);
}
use of com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer in project x-pipe by ctripcorp.
the class FakeRedisRdbDumperTest method testRdbDumpWhileNotConnectedToMaster.
@Test
public void testRdbDumpWhileNotConnectedToMaster() throws Exception {
fakeRedisServer.setSleepBeforeSendFullSyncInfo(sleepBeforeSendFullSyncInfo);
RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis();
InMemoryPsync inMemoryPsync = sendInmemoryPsync("localhost", redisKeeperServer.getListeningPort());
CommandFuture<?> future = inMemoryPsync.future();
sleep(sleepBeforeSendFullSyncInfo + 1000);
Assert.assertEquals(1, ((DefaultRedisKeeperServer) redisKeeperServer).getRdbDumpTryCount());
Assert.assertFalse(future.isSuccess());
}
use of com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperContainerService method createRedisKeeperServer.
private RedisKeeperServer createRedisKeeperServer(KeeperMeta keeper, File baseDir, MetaServerKeeperService metaService) throws Exception {
RedisKeeperServer redisKeeperServer = new DefaultRedisKeeperServer(keeper, keeperConfig, baseDir, metaService, leaderElectorManager, keepersMonitorManager);
register(redisKeeperServer);
return redisKeeperServer;
}
Aggregations