use of com.ctrip.xpipe.redis.core.protocal.cmd.Fsync in project x-pipe by ctripcorp.
the class RedisPromotor method promoteSlaveToMaster.
private void promoteSlaveToMaster(RedisSlave redisSlave) throws Exception {
SimpleObjectPool<NettyClient> fsyncPool = null;
SimpleObjectPool<NettyClient> clientPool = null;
try {
fsyncPool = NettyPoolUtil.createNettyPool(new InetSocketAddress(promoteServerIp, promoteServerPort));
clientPool = NettyPoolUtil.createNettyPool(new InetSocketAddress(promoteServerIp, promoteServerPort));
waitUntilSlaveSync(redisSlave, this.promoteServerIp, this.promoteServerPort, waitTimeoutMilli);
try {
redisKeeperServer.getRedisKeeperServerState().setPromotionState(PROMOTION_STATE.BEGIN_PROMOTE_SLAVE);
Fsync fsyncCmd = new Fsync(fsyncPool, scheduled);
String fsyncResult = fsyncCmd.execute().get();
logger.info("[promoteSlaveToMaster][fsync done]{}, {},{}", fsyncResult, promoteServerIp, promoteServerPort);
redisModified(redisSlave, clientPool);
} catch (ExecutionException e) {
logger.error("[promoteSlaveToMaster]" + redisSlave, e.getCause());
if (e.getCause() instanceof RedisError) {
logger.info("[promoteSlaveToMaster][fsync not supported, raw redis]{}", redisSlave);
redisNotModified(redisSlave, clientPool);
} else {
logger.error("[promoteSlaveToMaster][fail]" + redisSlave);
}
}
} finally {
if (fsyncPool != null) {
fsyncPool.clear();
}
if (clientPool != null) {
clientPool.clear();
}
}
}
Aggregations