use of com.ctrip.xpipe.redis.keeper.exception.RedisKeeperRuntimeException in project x-pipe by ctripcorp.
the class KeeperContainerService method add.
public RedisKeeperServer add(KeeperTransMeta keeperTransMeta) {
KeeperMeta keeperMeta = keeperTransMeta.getKeeperMeta();
enrichKeeperMetaFromKeeperTransMeta(keeperMeta, keeperTransMeta);
String keeperServerKey = assembleKeeperServerKey(keeperTransMeta);
if (!redisKeeperServers.containsKey(keeperServerKey)) {
synchronized (this) {
if (!redisKeeperServers.containsKey(keeperServerKey)) {
if (runningPorts.contains(keeperMeta.getPort())) {
throw new RedisKeeperRuntimeException(new ErrorMessage<>(KeeperContainerErrorCode.KEEPER_ALREADY_EXIST, String.format("Add keeper for cluster %s shard %s failed since port %d is already used", keeperTransMeta.getClusterId(), keeperTransMeta.getShardId(), keeperMeta.getPort())), null);
}
try {
RedisKeeperServer redisKeeperServer = doAdd(keeperTransMeta, keeperMeta);
cacheKeeper(keeperServerKey, redisKeeperServer);
return redisKeeperServer;
} catch (Throwable ex) {
throw new RedisKeeperRuntimeException(new ErrorMessage<>(KeeperContainerErrorCode.INTERNAL_EXCEPTION, String.format("Add keeper for cluster %s shard %s failed", keeperTransMeta.getClusterId(), keeperTransMeta.getShardId())), ex);
}
}
}
}
throw new RedisKeeperRuntimeException(new ErrorMessage<>(KeeperContainerErrorCode.KEEPER_ALREADY_EXIST, String.format("Keeper already exists for cluster %s shard %s", keeperTransMeta.getClusterId(), keeperTransMeta.getShardId())), null);
}
Aggregations