Java – How does Hazelcast acquire all current locks?

How does Hazelcast acquire all current locks?… here is a solution to the problem.

How does Hazelcast acquire all current locks?

I need to see all the locks in the Hazelcast cluster.

I know someone below has asked this question:

How to show all current locks in hazelcast

However, as

far as I can tell, the getInstances method seems to have been removed from HazelcastInstance.

What is the correct way to do this in the hazelcast-3.6 version?

Solution

In Hazelcast 3.x, you will use the public super interface DistributedObject

Collection<DistributedObject> objects = hazelcastInstance.getDistributedObjects();
for (DistributedObject object : objects) {
  if (object instanceof ILock) {
    handleLock((ILock) object);
  }
}

However, this applies only to locks created by hazelcastInstance.getLock(...), not to keylocks created through the IMap interface.

Related Problems and Solutions