Search in sources :

Example 1 with RedisMaster

use of com.ctrip.xpipe.redis.keeper.RedisMaster in project x-pipe by ctripcorp.

the class RoleCommandHandler method doHandle.

@Override
protected void doHandle(String[] args, RedisClient redisClient) {
    RedisKeeperServer redisKeeperServer = redisClient.getRedisKeeperServer();
    ReplicationStore replicationStore = redisKeeperServer.getReplicationStore();
    RedisMaster redisMaster = redisKeeperServer.getRedisMaster();
    Endpoint masterEndPoint = null;
    if (redisMaster != null) {
        masterEndPoint = redisMaster.masterEndPoint();
    }
    Object[] result = new Object[5];
    result[0] = redisKeeperServer.role().toString();
    result[1] = masterEndPoint == null ? "0.0.0.0" : masterEndPoint.getHost();
    result[2] = masterEndPoint == null ? "0" : masterEndPoint.getPort();
    result[3] = redisMaster == null ? MASTER_STATE.REDIS_REPL_NONE.getDesc() : redisMaster.getMasterState().getDesc();
    result[4] = replicationStore == null ? -1L : replicationStore.getEndOffset();
    redisClient.sendMessage(ParserManager.parse(result));
}
Also used : RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) Endpoint(com.ctrip.xpipe.api.endpoint.Endpoint) ReplicationStore(com.ctrip.xpipe.redis.core.store.ReplicationStore) RedisMaster(com.ctrip.xpipe.redis.keeper.RedisMaster)

Aggregations

Endpoint (com.ctrip.xpipe.api.endpoint.Endpoint)1 ReplicationStore (com.ctrip.xpipe.redis.core.store.ReplicationStore)1 RedisKeeperServer (com.ctrip.xpipe.redis.keeper.RedisKeeperServer)1 RedisMaster (com.ctrip.xpipe.redis.keeper.RedisMaster)1