use of com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSlaveOfCommand in project x-pipe by ctripcorp.
the class RedisPromotor method redisModified.
private void redisModified(RedisSlave redisSlave, SimpleObjectPool<NettyClient> clientPool) throws Exception {
try {
logger.info("[redisModified]{}", redisSlave);
AbstractSlaveOfCommand slaveOfCmd = new SlaveOfCommand(clientPool, scheduled);
slaveOfCmd.execute().sync();
InfoCommand infoServerCmd = new InfoCommand(clientPool, "server", scheduled);
String info = infoServerCmd.execute().get();
String masterId = null;
List<String> lines = IOUtils.readLines(new StringReader(info));
for (String line : lines) {
if (line.startsWith("run_id:")) {
masterId = line.substring("run_id:".length());
}
}
InfoCommand infoLastMasterCmd = new InfoCommand(clientPool, "lastmaster", scheduled);
String infoLastMaster = infoLastMasterCmd.execute().get();
long keeperOffset = 0, newMasterOffset = 0;
try {
String[] parts = infoLastMaster.split("\\s");
keeperOffset = Long.parseLong(parts[1]);
newMasterOffset = Long.parseLong(parts[2]);
redisKeeperServer.getRedisKeeperServerState().setPromotionState(PROMOTION_STATE.SLAVE_PROMTED, new SlavePromotionInfo(keeperOffset, new DefaultEndPoint(promoteServerIp, promoteServerPort), masterId, newMasterOffset));
} catch (Exception e) {
logger.error("[onComplete]" + promoteServerIp + ":" + promoteServerPort, e);
}
} catch (IOException e1) {
logger.error("promoteSlaveToMaster", e1);
}
}
use of com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSlaveOfCommand in project x-pipe by ctripcorp.
the class RedisPromotor method redisNotModified.
private void redisNotModified(RedisSlave redisSlave, SimpleObjectPool<NettyClient> clientPool) throws InterruptedException, ExecutionException, IOException {
logger.info("[redisNotModified]{}", redisSlave);
AbstractSlaveOfCommand slaveOfCmd = new SlaveOfCommand(clientPool, scheduled);
slaveOfCmd.execute().sync();
redisKeeperServer.getRedisKeeperServerState().setPromotionState(PROMOTION_STATE.SLAVE_PROMTED, new InetSocketAddress(promoteServerIp, promoteServerPort));
}
Aggregations