getAsync("key").get(timeout,sec)不等待,返回null [英] getAsync("key").get(timeout, sec) doesn't wait, return null

查看:99
本文介绍了getAsync("key").get(timeout,sec)不等待,返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hazelcast 3.4.4. 我遇到了无论如何map.getAsync返回null的情况.即使超时设置为10000000TimeUnit.SECONDS,它也不会等待.

Hazelcast 3.4.4. I got a situation when map.getAsync returns null no matter what. It even if timeout set to 10000000, TimeUnit.SECONDS it doesn't wait.

但是,如果我将Thread.sleep(10000)放在getAsync之前,那么它将从映射返回正确的值.

But if I put Thread.sleep(10000) just before getAsync then it returns proper value from the map.

我想知道怎么了?如何检查/修复/理解它?

I wonder what's wrong and how I could check/fix/undersand it?

UPDATE :如果我从代码和所有依赖项(如Scala.concurent.Future)中删除了import ExecutionContext.Implicit.global,则getAsync将再次开始工作.但是我还是不满意...

UPDATE: if I remove import ExecutionContext.Implicit.global from my code and all dependencies (like Scala.concurent.Future), then getAsync starts working again. But I'm not satisfied still ...

推荐答案

在我看来,您希望它等待到在地图中输入一个值,对吗?

To me it feels like you expect it to wait until a value is put into the map, doesn't it?

这并不意味着它将等到一个值可用时才出现,它只是让您可以选择在群集完全耗尽并且无法足够快地回答您的请求的情况下超时.

It doesn't mean that it will wait until a value becomes available, it just gives you the option to have a timeout for the case the cluster is totally exhausted and cannot answer your request fast enough.

我实际上认为没有什么好的方法可以实现您想要的目标,但是如果可以的话,您可以使用本地EntryListeners,等待键并通过主题转发事件.您可能还需要Promise的实现.

I actually think there is no good way to achieve what you're looking for but you could use the local EntryListeners, waiting for a key and forward the event through a topic, if that makes sense. You might also need a Promise kind of implementation.

这篇关于getAsync("key").get(timeout,sec)不等待,返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆