kezhuw commented on code in PR #464:
URL: https://github.com/apache/curator/pull/464#discussion_r1212564545
##########
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:
Hmm, `isStarted` is marked as `Deprecated`. CURATOR-147(#44) targeted
removing invocation of its usages, though I guess we are only deprecating the
API part. Keep it as is for now ? All other usages in Curator use this shape
currently.
--
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]