Redis Cluster:Too many Cluster redirections异常

 

转载请注明出处哈:http://carlosfu.iteye.com/blog/2240426


 

一、现象:
    我们的redis私有云,对外提供了redis-standalone, redis-sentinel, redis-cluster三种类型的redis服务。
    其中redis-cluster, 使用的版本是 Redis Cluster 3.0.2, 客户端是jedis 2.7.2。
    有人在使用时候,业务的日志中发现了一些异常(Too many Cluster redirections)。 
    
 
二、jedis源码分析:
    先从jedis源码中找到这个异常,这段异常是在JedisClusterCommand类中
if (redirections <= 0) {
       throw new JedisClusterMaxRedirectionsException("Too many Cluster redirections? key=" + key);
}
    在jedis中调用redis-cluster使用的JedisCluster类,所有api的调用方式类似如下:
   public String set(final String key, final String value) {
        return new JedisClusterCommand<String>(connectionHandler, maxRedirections) {
            @Override
            public String execute(Jedis connection) {
                return connection.set(key, value);
            }
        }.run(key);
    }
     
    所以重点代码在JedisClusterCommand这个类里,重要代码如下:
    public T run(int keyCount, String... keys) {
        if (keys == null || keys.length == 0) {
            throw new JedisClusterException("No way to di
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值