use of com.ctrip.xpipe.redis.core.protocal.cmd.InfoCommand in project x-pipe by ctripcorp.
the class XRedisXpipeCommandTest method getSyncFull.
private Integer getSyncFull(RedisMeta redis) throws Exception {
SimpleObjectPool<NettyClient> keyPool = getXpipeNettyClientKeyedObjectPool().getKeyPool(new InetSocketAddress(redis.getIp(), redis.getPort()));
InfoCommand infoCommand = new InfoCommand(keyPool, InfoCommand.INFO_TYPE.STATS, scheduled);
String value = infoCommand.execute().get();
Integer sync_full = new InfoResultExtractor(value).extractAsInteger("sync_full");
return sync_full;
}
use of com.ctrip.xpipe.redis.core.protocal.cmd.InfoCommand 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.InfoCommand in project x-pipe by ctripcorp.
the class DefaultSentinelManager method infoSentinel.
@Override
public String infoSentinel(Sentinel sentinel) {
SimpleObjectPool<NettyClient> clientPool = keyedClientPool.getKeyPool(new InetSocketAddress(sentinel.getIp(), sentinel.getPort()));
InfoCommand infoCommand = new InfoCommand(clientPool, InfoCommand.INFO_TYPE.SENTINEL, scheduled);
infoCommand.logResponse(false);
try {
return infoCommand.execute().get();
} catch (Exception e) {
logger.error("[infoSentinel] " + sentinel, e);
}
return null;
}
use of com.ctrip.xpipe.redis.core.protocal.cmd.InfoCommand in project x-pipe by ctripcorp.
the class AbstractRedisTest method getInfoKey.
protected String getInfoKey(RedisMeta slaveMeta, String infoSection, String key) throws Exception {
SimpleObjectPool<NettyClient> keyPool = getXpipeNettyClientKeyedObjectPool().getKeyPool(new InetSocketAddress(slaveMeta.getIp(), slaveMeta.getPort()));
String info = new InfoCommand(keyPool, infoSection, scheduled).execute().get();
return new InfoResultExtractor(info).extract(key);
}
use of com.ctrip.xpipe.redis.core.protocal.cmd.InfoCommand in project x-pipe by ctripcorp.
the class AbstractRedisTest method getRedisServerRole.
protected SERVER_ROLE getRedisServerRole(RedisMeta slave) throws Exception {
SimpleObjectPool<NettyClient> clientPool = NettyPoolUtil.createNettyPool(new InetSocketAddress(slave.getIp(), slave.getPort()));
String info = new InfoCommand(clientPool, "replication", scheduled).execute().get();
for (String line : info.split("\r\n")) {
String[] parts = line.split(":");
if (parts.length >= 2 && parts[0].equals("role")) {
String role = parts[1].trim();
return SERVER_ROLE.of(role);
}
}
return SERVER_ROLE.UNKNOWN;
}
Aggregations