How to show all current locks in hazelcast

浪子不回头ぞ 提交于 2019-12-31 02:56:06

问题


I am a newbie for Hazelcast. I would like to know how can I list current lock in Hazelcast console?

For ex. assume that i open three console and i have taken 3 lock as follow:

m.lock object1
m.lock object2
m.lock object3

How can i get output like:

number of lock site: 3
locks: object1, object2, object3

回答1:


Console is just a test app to simulate basic functionalities of hazelcast.

To see your lock instances following code will help you.

HazelcastInstance hzInstance = Hazelcast.newHazelcastInstance(null);
Collection<Instance> instances = hzInstance.getInstances();
Set<Instance> locks = new HashSet<Instance>();
for (Instance inst : instances) {
    if(inst.getInstanceType().equals(Instance.InstanceType.LOCK))
    locks.add(inst);
}



回答2:


With Hazelcast 3.X we have to use hz.getDistributedObjects().

Please refer Renaming "instance" to "distributed object" for more details.



来源:https://stackoverflow.com/questions/11797671/how-to-show-all-current-locks-in-hazelcast

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!