Hi,
Can I use the InterProcessSemaphoreMutex and Reaper together for ZK path
cleanup? When I create the semaphore mutex with a path, say “/a/b/c”, two ZK
paths are created:
/a/b/c/locks
/a/b/c/leases
I add the path “/a/b/c” to my Reaper instance with a reaping threshold of 1
minute. I then proceed to use my mutex:
CuratorFramework client = /* Create the client */
Reaper reaper = new Reaper(client, 60000);
InterProcessLock lock = new InterProcessSemaphoreMutex(client, “/a/b/c”);
reaper.addPath(“/a/b/c”, Reaper.Mode.REAP_UNTIL_GONE);
if (lock.acquire(0, TimeUnit.SECONDS)) {
try {
/* Execute critical section */
} finally {
lock.release();
}
} else {
/* Log it */
}
After the above code finishes, I notice the reaper kicking in several times,
but I continue to see the locks and leases subdirectories sticking around?
Shouldn’t the directory ‘c’ and everything under it be deleted by the Reaper? I
experimented using an InterProcessMutex and the path gets deleted as expected.
Thanks,
-Terry