helix icon indicating copy to clipboard operation
helix copied to clipboard

Why LockListener is not public

Open hungvm90 opened this issue 4 years ago • 5 comments

Describe the bug

interface LockListener { /**

  • call back called when the lock is preempted */ void onCleanupNotification(); } This interface should be public

To Reproduce

When not set LockListener, try to lock with higher priority, it throw "Cleanup has not been finished by lock owner"

Expected behavior

interface LockListener should be public, or when not set LockListener, it should be pass

Additional context

Add any other context about the problem here.

hungvm90 avatar Oct 12 '21 03:10 hungvm90

Thanks @hungvm90. Will let original author to fix it.

junkaixue avatar Oct 13 '21 16:10 junkaixue

@mgao0

junkaixue avatar Oct 28 '21 20:10 junkaixue

@zhangmeng916 Is not set LockListener an expected user behavior? I tried making LockListener public, but it didn't solve the problem because not setting LockListener will cause NPE, no matter if the interface is public or not.

mgao0 avatar Jan 03 '22 18:01 mgao0

@hungvm90 The LockListener needs to be set for the lock to be able to work, since it listens on Zookeeper once there is any change in the lock path.

zhangmeng916 avatar Jan 03 '22 20:01 zhangmeng916

Sorry, my description for this issue is not correct, but I think LockListener should be public. For example, I implement lock with priority, so I need ack when I lose this lock. But LockListener is not public, so I can't implement it.

lock = new ZKDistributedNonblockingLock.Builder() .setLockScope(new HelixLockScope(HelixLockScope.LockScopeProperty.RESOURCE, pathKeys)) .setZkAddress(zooKeeperHost) .setUserId(instanceName) .setTimeout(timeout) .setPriority(LOCK_LOW_PRIORITY) .setLockListener(new LockListener() { @Override public void onCleanupNotification() { for (LockLoseListener listener : listeners) { listener.onLoseLock(lock); } } }) .setLockMsg(String.format("Lock %s from %s", resource, instanceName)) .build();

hungvm90 avatar Jan 25 '22 14:01 hungvm90