use of com.ctrip.xpipe.redis.keeper.exception.RedisSlavePromotionException in project x-pipe by ctripcorp.
the class SlaveOfCommandHandler method handleForwarding.
private void handleForwarding(String[] args, RedisClient redisClient) {
if (args[0].equalsIgnoreCase(NO)) {
String ip = args[2];
// already validated
int port = Integer.parseInt(args[3]);
try {
redisClient.getRedisKeeperServer().promoteSlave(ip, port);
redisClient.sendMessage(new BulkStringParser(RedisProtocol.OK).format());
return;
} catch (RedisSlavePromotionException e) {
logger.error("[doHandle]{},{},{}", redisClient, ip, port);
redisClient.sendMessage(new RedisErrorParser(e.getMessage()).format());
}
}
}
use of com.ctrip.xpipe.redis.keeper.exception.RedisSlavePromotionException in project x-pipe by ctripcorp.
the class RedisPromotor method promote.
public void promote() throws RedisSlavePromotionException {
final RedisSlave redisSlave = findSlave(this.redisKeeperServer, this.promoteServerIp, this.promoteServerPort);
if (redisSlave == null) {
String msg = String.format("%s:%s is not a connected slave", promoteServerIp, promoteServerPort);
throw new RedisSlavePromotionException(msg);
}
logger.info("[promote]{},{} ,{}:{}", redisKeeperServer, redisSlave, promoteServerIp, promoteServerPort);
new Thread() {
public void run() {
try {
promoteSlaveToMaster(redisSlave);
} catch (Exception e) {
logger.error("[run][promote slave]" + redisSlave, e);
}
}
}.start();
}
Aggregations