Hazelcast IMAP锁在不同豆荚的kubernetes上不起作用
我们正在使用Hazelcast 4在Kuberentes上的两个POD上实施分布式锁定。
我们开发了分布式应用程序,创建了两个微服务的豆荚。这两种实例都在发现自动和成员。
我们正在尝试使用imap.lock(键)方法来实现两个POD上的分布式锁定,但是两个POD都在同时获取锁定,从而同时执行业务逻辑。 Hazelcast管理中心还显示了创建IMAP的零锁。
您能否帮助如何实现IMAP锁定(键)的同步,以便单个POD在给定时间点获得给定键的锁定?
代码段: -
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
try{
IMap map = client.getMap("customers");
map.lock( key );
//business logic
} finally {
map.unlock( key );
}
}
We are using Hazelcast 4 to implement distributed locking across two pods on kuberentes.
We have developed distributed application, two pods of micro service has been created. Both instances are getting auto discovered and forming members.
We are trying to use IMap.lock(key) method to achieve distributed locking across two pods however both pods are acquiring lock at same time, thereby executing the business logic at the concurrently. Also hazelcast management center shows zero locks for the created Imap.
Can you please help on how to achieve synchronization of imap lock(key) so that single pod get the lock for given key at given point of time ?
Code Snippet:-
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
try{
IMap map = client.getMap("customers");
map.lock( key );
//business logic
} finally {
map.unlock( key );
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建一个 mvce 并确认使用的Hazelcast版本。
有锁的测试在这里您也许可以用作简化的方式来确定故障的位置。
Can you create an mvce and confirm the version of Hazelcast used please.
There are tests for locks here that you can perhaps use as a way to simplify to determine where the fault lies.