Curator - InterProcessMutex lock does not delete nodes
Asked Answered
S

0

8

Does anybody know which of the Curator lock recipes creates ephemeral nodes ?

I tested InterProcessMutex lock but as far as I can see (with the zkClient) it does not delete the nodes after release or close the session.

This is the code I'm using for lock keys.

public void lock(final LockKey lockkey, final LockAcquiredListener listener) throws Exception {

    final String lockKeyPath = lockkey.toString();

    LOGGER.info("Trying to acquire the lock {}", lockKeyPath);

    final InterProcessMutex lock = new InterProcessMutex(client, LOCKS_PREFIX + lockKeyPath);

    if (!lock.acquire(LOCK_MS_TIME_OUT, TimeUnit.MILLISECONDS)) {
        LOGGER.info("Could not acquire the lock {}", lockkey.toString());
        throw new LockAcquisitionTimeOutException("Could not acquire the lock: " + lockKeyPath);
    }
    try {
        if (listener != null) {
            LOGGER.info("Lock acquired for key {}", lockKeyPath);
            listener.lockAcquired(lockkey);
        }
    } finally {
        LOGGER.info("Release acquired key {}", lockKeyPath);
        lock.release();
    }
}

Thanks!

Shaped answered 6/4, 2015 at 15:18 Comment(3)
can you go into more detail regarding your statement "as far as I can see"? in my look into the code, i see it does delete the path upon releaseShelled
Yes, In Zookeper Client I can see the node after released the lock [zk: localhost:2181(CONNECTED) 7] ls /notifier/locks [testtestgrouped] This corresponde with the persistence node behaviour.Shaped
Have you got a solution for this issue? I am also facing a similar issue with InterProcessSemaphoreMutex under high loads where it is working fine under regular load conditions.Refresh

© 2022 - 2024 — McMap. All rights reserved.