org.redisson.client.RedisNodeNotFoundException:节点:尚未发现NodeSource

时间:2019-09-04 12:21:43

标签: spring-boot redis redisson

我是Redisson的新手,我试图在Redis缓存的帮助下将Redisson + Spring Boot集成到分布式锁中。

我遇到以下错误:

org.redisson.client.RedisNodeNotFoundException:节点:NodeSource [slot = 14577,addr = redis://10.150.77.93:6381,redisClient = null,redirect = MOVED,entry = null]尚未发现。     在org.redisson.connection.MasterSlaveConnectionManager.createNodeNotFoundFuture(MasterSlaveConnectionManager.java:612)〜[redisson-3.11.3.jar:3.11.3]     在org.redisson.connection.MasterSlaveConnectionManager.connectionWriteOp(MasterSlaveConnectionManager.java:564)〜[redisson-3.11.3.jar:3.11.3]     在org.redisson.command.RedisExecutor.getConnection(RedisExecutor.java:671)〜[redisson-3.11.3.jar:3.11.3]     在org.redisson.command.RedisExecutor.execute(RedisExecutor.java:134)〜[redisson-3.11.3.jar:3.11.3]     在org.redisson.command.RedisExecutor $ 2.run(RedisExecutor.java:273)〜[redisson-3.11.3.jar:3.11.3]     在io.netty.util.HashedWheelTimer $ HashedWheelTimeout.expire(HashedWheelTimer.java:668)〜[netty-common-4.1.25.Final.jar:4.1.25.Final]     在io.netty.util.HashedWheelTimer $ HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:743)〜[netty-common-4.1.25.Final.jar:4.1.25.Final]     在io.netty.util.HashedWheelTimer $ Worker.run(HashedWheelTimer.java:471)〜[netty-common-4.1.25.Final.jar:4.1.25.Final]     在java.lang.Thread.run(Thread.java:748)〜[na:1.8.0_161]

Redis缓存由Spring引导自动配置,并且我已经为主从群集配置了RedissonClient。

@Configuration
public class RedissonConfiguration
{
   @Bean
   RedissonClient redissonClient(Config config)
   {
     return Redisson.create(config);
   }


  @Bean
  Config config()
  {
    Config config =  new Config();
    config.useMasterSlaveServers().setMasterAddress("redis://10.150.77.91:6381")
            .addSlaveAddress("redis://10.150.77.93:6382");
    return config;
}
}




 @Component
 public class TriggerHandler
 {
private static final Logger LOGGER = LoggerFactory.getLogger(TriggerHandler.class);


@Autowired
RedissonClient redissonClient;

@Async
public void triggerEvent(AsyncEventTriggerRequest eventTriggerRequest)
{


    String lockName = eventTriggerRequest.getTenantId().concat("lock");

    RLock lock = redissonClient.getLock(lockName);


    try
    {
        if(lock.tryLock(2,5, TimeUnit.SECONDS))
        {
            LOGGER.info("Lock has been Achieved for: {}", lockName);
        }
    }
    catch (InterruptedException e)
    {
        lock.forceUnlock();
        e.printStackTrace();
    }

    lock.unlock();

}
}

为什么会失败? Redisson不会自动将Redis客户端配置为Redis吗?

1 个答案:

答案 0 :(得分:0)

此错误意味着尚未发现Redis 10.150.77.93,因为Redis集群信息不包含有关Redis的任何信息。