Search in sources :

Example 6 with Endpoint

use of com.ctrip.xpipe.api.endpoint.Endpoint 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)6 DefaultEndPoint (com.ctrip.xpipe.endpoint.DefaultEndPoint)2 NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)1 FakeRedisServer (com.ctrip.xpipe.redis.core.server.FakeRedisServer)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 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 InetSocketAddress (java.net.InetSocketAddress)1 Socket (java.net.Socket)1 Before (org.junit.Before)1 Test (org.junit.Test)1