use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperContainerService method addOrStart.
public RedisKeeperServer addOrStart(KeeperTransMeta keeperTransMeta) {
String keeperServerKey = assembleKeeperServerKey(keeperTransMeta);
RedisKeeperServer keeperServer = redisKeeperServers.get(keeperServerKey);
if (keeperServer == null) {
return add(keeperTransMeta);
}
start(keeperTransMeta.getClusterId(), keeperTransMeta.getShardId());
return keeperServer;
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperContainerService method remove.
public void remove(String clusterId, String shardId) {
String keeperServerKey = assembleKeeperServerKey(clusterId, shardId);
RedisKeeperServer keeperServer = redisKeeperServers.get(keeperServerKey);
if (keeperServer == null) {
return;
}
try {
// 1. stop and dispose keeper server
deRegister(keeperServer);
// 2. remove keeper
removeKeeperCache(keeperServerKey);
// 3. clean external resources, such as replication stores
keeperServer.destroy();
} catch (Throwable ex) {
throw new RedisKeeperRuntimeException(new ErrorMessage<>(KeeperContainerErrorCode.INTERNAL_EXCEPTION, String.format("Remove keeper failed for cluster %s shard %s", clusterId, shardId)), ex);
}
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class AbstractFakeRedisTest method startRedisKeeperServerAndConnectToFakeRedis.
protected RedisKeeperServer startRedisKeeperServerAndConnectToFakeRedis(int replicationStoreCommandFileNumToKeep, int replicationStoreMaxCommandsToTransferBeforeCreateRdb, int minTimeMilliToGcAfterCreate) throws Exception {
RedisKeeperServer redisKeeperServer = startRedisKeeperServer(replicationStoreCommandFileNumToKeep, replicationStoreMaxCommandsToTransferBeforeCreateRdb, 1000);
connectToFakeRedis(redisKeeperServer);
return redisKeeperServer;
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class FakeRedisExceptionTest method testRdbFileError.
@Test
public void testRdbFileError() throws Exception {
RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis();
countDownLatch.await(10, TimeUnit.SECONDS);
RdbStore rdbStore = ((DefaultReplicationStore) redisKeeperServer.getReplicationStore()).getRdbStore();
Assert.assertFalse(rdbStore.checkOk());
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class FakeRedisRdbDumpLong method testRedisNoLf.
@Test
public void testRedisNoLf() throws Exception {
int sleepBeforeSendRdb = replicationTimeoutMilli * 3;
fakeRedisServer.setSleepBeforeSendRdb(sleepBeforeSendRdb);
fakeRedisServer.setSendLFBeforeSendRdb(false);
RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis();
sleep(replicationTimeoutMilli * 3);
Assert.assertEquals(MASTER_STATE.REDIS_REPL_HANDSHAKE, redisKeeperServer.getRedisMaster().getMasterState());
}
Aggregations