use of com.ctrip.xpipe.redis.keeper.exception.RedisKeeperRuntimeException 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.exception.RedisKeeperRuntimeException in project x-pipe by ctripcorp.
the class KeeperContainerServiceTest method testAddKeeperWithError.
@Test
public void testAddKeeperWithError() throws Exception {
Exception someException = new Exception("some error happened");
when(componentRegistry.add(any(RedisKeeperServer.class))).thenThrow(someException);
Exception cause = null;
try {
keeperContainerService.add(someKeeperTransMeta);
} catch (RedisKeeperRuntimeException ex) {
cause = (Exception) ex.getCause();
}
assertEquals(someException, cause);
}
use of com.ctrip.xpipe.redis.keeper.exception.RedisKeeperRuntimeException in project x-pipe by ctripcorp.
the class KeeperContainerService method stop.
public void stop(String clusterId, String shardId) {
String keeperServerKey = assembleKeeperServerKey(clusterId, shardId);
RedisKeeperServer keeperServer = redisKeeperServers.get(keeperServerKey);
if (keeperServer == null) {
throw new RedisKeeperRuntimeException(new ErrorMessage<>(KeeperContainerErrorCode.KEEPER_NOT_EXIST, String.format("Stop keeper for cluster %s shard %s failed since keeper doesn't exist", clusterId, shardId)), null);
}
if (keeperServer.getLifecycleState().isStopped()) {
throw new RedisKeeperRuntimeException(new ErrorMessage<>(KeeperContainerErrorCode.KEEPER_ALREADY_STOPPED, String.format("Keeper for cluster %s shard %s already stopped", clusterId, shardId)), null);
}
try {
keeperServer.stop();
} catch (Throwable ex) {
throw new RedisKeeperRuntimeException(new ErrorMessage<>(KeeperContainerErrorCode.INTERNAL_EXCEPTION, String.format("Stop keeper failed for cluster %s shard %s", clusterId, shardId)), ex);
}
}
use of com.ctrip.xpipe.redis.keeper.exception.RedisKeeperRuntimeException in project x-pipe by ctripcorp.
the class DefaultRedisSlave method beginWriteCommands.
@Override
public void beginWriteCommands(long beginOffset) {
closeState.makeSureOpen();
try {
if (partialState == PARTIAL_STATE.UNKNOWN) {
partialState = PARTIAL_STATE.PARTIAL;
}
logger.info("[beginWriteCommands]{}, {}", this, beginOffset);
slaveState = SLAVE_STATE.REDIS_REPL_ONLINE;
getRedisKeeperServer().getReplicationStore().addCommandsListener(beginOffset, this);
} catch (IOException e) {
throw new RedisKeeperRuntimeException("[beginWriteCommands]" + beginOffset + "," + this, e);
}
}
use of com.ctrip.xpipe.redis.keeper.exception.RedisKeeperRuntimeException in project x-pipe by ctripcorp.
the class KeeperContainerService method start.
public void start(String clusterId, String shardId) {
String keeperServerKey = assembleKeeperServerKey(clusterId, shardId);
RedisKeeperServer keeperServer = redisKeeperServers.get(keeperServerKey);
if (keeperServer == null) {
throw new RedisKeeperRuntimeException(new ErrorMessage<>(KeeperContainerErrorCode.KEEPER_NOT_EXIST, String.format("Start keeper for cluster %s shard %s failed since keeper doesn't exist", clusterId, shardId)), null);
}
if (keeperServer.getLifecycleState().isStarted()) {
throw new RedisKeeperRuntimeException(new ErrorMessage<>(KeeperContainerErrorCode.KEEPER_ALREADY_STARTED, String.format("Keeper for cluster %s shard %s already started", clusterId, shardId)), null);
}
try {
keeperServer.start();
} catch (Throwable ex) {
throw new RedisKeeperRuntimeException(new ErrorMessage<>(KeeperContainerErrorCode.INTERNAL_EXCEPTION, String.format("Start keeper failed for cluster %s shard %s", clusterId, shardId)), ex);
}
}
Aggregations