Search in sources :

Example 6 with RedisNode

use of org.springframework.data.redis.connection.RedisNode in project cas by apereo.

the class RedisObjectFactory method createRedisNodesForProperties.

private List<RedisNode> createRedisNodesForProperties(final BaseRedisProperties redis) {
    final List<RedisNode> redisNodes = new ArrayList<RedisNode>();
    if (redis.getSentinel().getNode() != null) {
        final List<String> nodes = redis.getSentinel().getNode();
        for (final String hostAndPort : nodes) {
            final String[] args = StringUtils.split(hostAndPort, ":");
            redisNodes.add(new RedisNode(args[0], Integer.parseInt(args[1])));
        }
    }
    return redisNodes;
}
Also used : ArrayList(java.util.ArrayList) RedisNode(org.springframework.data.redis.connection.RedisNode)

Example 7 with RedisNode

use of org.springframework.data.redis.connection.RedisNode in project thingsboard by thingsboard.

the class TBRedisClusterConfiguration method getNodes.

private List<RedisNode> getNodes(String nodes) {
    List<RedisNode> result;
    if (StringUtils.isBlank(nodes)) {
        result = Collections.emptyList();
    } else {
        result = new ArrayList<>();
        for (String hostPort : nodes.split(COMMA)) {
            String host = hostPort.split(COLON)[0];
            Integer port = Integer.valueOf(hostPort.split(COLON)[1]);
            result.add(new RedisNode(host, port));
        }
    }
    return result;
}
Also used : RedisNode(org.springframework.data.redis.connection.RedisNode)

Example 8 with RedisNode

use of org.springframework.data.redis.connection.RedisNode in project incubator-shenyu by apache.

the class RateLimiterPluginDataHandler method createRedisNode.

private List<RedisNode> createRedisNode(final String url) {
    List<RedisNode> redisNodes = new ArrayList<>();
    List<String> nodes = Lists.newArrayList(Splitter.on(";").split(url));
    for (String node : nodes) {
        String[] parts = StringUtils.split(node, ":");
        Assert.state(Objects.requireNonNull(parts).length == 2, "Must be defined as 'host:port'");
        redisNodes.add(new RedisNode(parts[0], Integer.parseInt(parts[1])));
    }
    return redisNodes;
}
Also used : ArrayList(java.util.ArrayList) RedisNode(org.springframework.data.redis.connection.RedisNode)

Aggregations

RedisNode (org.springframework.data.redis.connection.RedisNode)8 ArrayList (java.util.ArrayList)4 RedisClusterConfiguration (org.springframework.data.redis.connection.RedisClusterConfiguration)3 RedisSentinelConfiguration (org.springframework.data.redis.connection.RedisSentinelConfiguration)2 RedisStandaloneConfiguration (org.springframework.data.redis.connection.RedisStandaloneConfiguration)2 LettuceConnectionFactory (org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory)2 RedisServerMatchStrategy (com.pamirs.attach.plugin.common.datasource.redisserver.RedisServerMatchStrategy)1 Attachment (com.pamirs.attach.plugin.dynamic.Attachment)1 RedisTemplate (com.pamirs.attach.plugin.dynamic.template.RedisTemplate)1 ShadowRedisConfig (com.pamirs.pradar.internal.config.ShadowRedisConfig)1 AbstractRedisClient (io.lettuce.core.AbstractRedisClient)1 ChannelGroup (io.netty.channel.group.ChannelGroup)1 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)1 InetSocketAddress (java.net.InetSocketAddress)1 HashSet (java.util.HashSet)1 Bean (org.springframework.context.annotation.Bean)1