Search in sources :

Example 1 with FencedLockProxy

use of com.hazelcast.cp.internal.datastructures.lock.proxy.FencedLockProxy in project hazelcast by hazelcast.

the class LockService method createProxy.

@Override
public FencedLock createProxy(String proxyName) {
    proxyName = withoutDefaultGroupName(proxyName);
    while (true) {
        FencedLockProxy proxy = proxies.get(proxyName);
        if (proxy != null) {
            CPGroupId groupId = raftService.createRaftGroupForProxy(proxyName);
            if (!proxy.getGroupId().equals(groupId)) {
                proxies.remove(proxyName, proxy);
            } else {
                return proxy;
            }
        }
        proxy = doCreateProxy(proxyName);
        FencedLockProxy existing = proxies.putIfAbsent(proxyName, proxy);
        if (existing == null) {
            return proxy;
        }
    }
}
Also used : CPGroupId(com.hazelcast.cp.CPGroupId) FencedLockProxy(com.hazelcast.cp.internal.datastructures.lock.proxy.FencedLockProxy)

Aggregations

CPGroupId (com.hazelcast.cp.CPGroupId)1 FencedLockProxy (com.hazelcast.cp.internal.datastructures.lock.proxy.FencedLockProxy)1