tisonkun commented on code in PR #464:
URL: https://github.com/apache/curator/pull/464#discussion_r1223020774
##########
curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java:
##########
@@ -694,17 +714,46 @@ <DATA_TYPE> void
processBackgroundOperation(OperationAndData<DATA_TYPE> operatio
}
}
+ private void closeOperation(OperationAndData<?> operation) {
+ if (operation.getCallback() == null) {
+ return;
+ }
+ CuratorEvent event = new CuratorEventImpl(this,
CuratorEventType.CLOSING, KeeperException.Code.SESSIONEXPIRED.intValue(), null,
null, operation.getContext(), null, null, null, null, null, null);
+ sendToBackgroundCallback(operation, event);
+ }
+
+ private void requeueSleepOperation(OperationAndData<?> operationAndData) {
+ operationAndData.clearSleep();
+ synchronized (closeLock)
+ {
+ if (getState() == CuratorFrameworkState.STARTED)
+ {
+ if (backgroundOperations.remove(operationAndData))
+ {
+ // due to the internals of DelayQueue, operation must be
removed/re-added so that re-sorting occurs
+ backgroundOperations.offer(operationAndData);
+ } // This operation has been taken over by background thread.
+ return;
+ }
+ }
+ closeOperation(operationAndData);
+ }
+
/**
* @param operationAndData operation entry
* @return true if the operation was actually queued, false if not
*/
<DATA_TYPE> boolean queueOperation(OperationAndData<DATA_TYPE>
operationAndData)
{
- if ( getState() == CuratorFrameworkState.STARTED )
+ synchronized (closeLock)
{
- backgroundOperations.offer(operationAndData);
- return true;
+ if (getState() == CuratorFrameworkState.STARTED)
Review Comment:
Thanks for your explanation! SGTM.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]