Search in sources :

Example 1 with ClientInfo

use of com.cdeledu.util.database.redis.entity.ClientInfo in project wechat by dllwh.

the class AbstractRedisService method getClientList.

public List<ClientInfo> getClientList(Jedis jedisClient) {
    List<ClientInfo> clientList = Lists.newArrayList();
    String[] clientStrs = jedisClient.clientList().split("\n");
    if (clientStrs != null && clientStrs.length > 0) {
        for (String client : clientStrs) {
            ClientInfo clientInfo;
            String[] infoArr = client.trim().split(" ");
            if (infoArr != null && infoArr.length > 0) {
                for (String info : infoArr) {
                    clientInfo = new ClientInfo();
                    String[] inFoArr2 = info.split("=");
                    if (inFoArr2 != null && inFoArr2.length > 1) {
                        clientInfo.setKey(inFoArr2[0]);
                        clientInfo.setValue(inFoArr2[1]);
                        clientList.add(clientInfo);
                    }
                }
            }
        }
    }
    return clientList;
}
Also used : ClientInfo(com.cdeledu.util.database.redis.entity.ClientInfo)

Example 2 with ClientInfo

use of com.cdeledu.util.database.redis.entity.ClientInfo in project wechat by dllwh.

the class RedisClient method getClientList.

/**
 * @方法描述: 用于返回所有连接到服务器的客户端信息和统计数据
 * @返回参数详情:http://redisdoc.com/server/client_list.html
 * @return
 */
public List<ClientInfo> getClientList() {
    Jedis jedis = null;
    List<ClientInfo> clientList = Lists.newArrayList();
    Client client = null;
    try {
        jedis = new RedisClient().acquireConnection();
        String[] strs = jedis.clientList().split("\n");
        if (strs != null && strs.length > 0) {
            ClientInfo clientInfo = null;
            for (int i = 0; i < strs.length; i++) {
                String[] infoArr = strs[i].trim().split(" ");
                if (infoArr != null && infoArr.length > 0) {
                    for (String info : infoArr) {
                        clientInfo = new ClientInfo();
                        String[] inFoArr2 = info.split("=");
                        if (inFoArr2 != null && inFoArr2.length > 1) {
                            clientInfo.setKey(inFoArr2[0]);
                            clientInfo.setValue(inFoArr2[1]);
                            clientList.add(clientInfo);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        returnClient(client);
        returnConnection(jedis);
    }
    return clientList;
}
Also used : Jedis(redis.clients.jedis.Jedis) ClientInfo(com.cdeledu.util.database.redis.entity.ClientInfo) Client(redis.clients.jedis.Client)

Example 3 with ClientInfo

use of com.cdeledu.util.database.redis.entity.ClientInfo in project wechat by dllwh.

the class RedisClientPoolHelper method getClientList.

public List<ClientInfo> getClientList() throws Exception {
    List<ClientInfo> clientList = Lists.newArrayList();
    Jedis jedis = null;
    try {
        jedis = getRedisClient();
        clientList = getClientList(jedis);
    } finally {
        closeRedisClient(jedis);
    }
    return clientList;
}
Also used : Jedis(redis.clients.jedis.Jedis) ClientInfo(com.cdeledu.util.database.redis.entity.ClientInfo)

Example 4 with ClientInfo

use of com.cdeledu.util.database.redis.entity.ClientInfo in project wechat by dllwh.

the class RedisClientSentinelHelper method getClientList.

/**
 * @方法描述: 用于返回所有连接到服务器的客户端信息和统计数据
 * @返回参数详情:http://redisdoc.com/server/client_list.html
 */
public List<ClientInfo> getClientList() throws Exception {
    List<ClientInfo> clientList = Lists.newArrayList();
    /**
     * 非切片额客户端连接
     */
    Jedis jedis = null;
    try {
        jedis = getRedisClient();
        clientList = getClientList(jedis);
    } finally {
        closeRedisClient(jedis);
    }
    return clientList;
}
Also used : Jedis(redis.clients.jedis.Jedis) ClientInfo(com.cdeledu.util.database.redis.entity.ClientInfo)

Aggregations

ClientInfo (com.cdeledu.util.database.redis.entity.ClientInfo)4 Jedis (redis.clients.jedis.Jedis)3 Client (redis.clients.jedis.Client)1