Created
June 6, 2019 13:19
-
-
Save Randgalt/a5ab016c5dcab8bac9cee223932548c2 to your computer and use it in GitHub Desktop.
checkBackgroundRetry() change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@VisibleForTesting | |
volatile CountDownLatch debugCheckBackgroundRetryLatch; | |
@VisibleForTesting | |
volatile CountDownLatch debugCheckBackgroundRetryReadyLatch; | |
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored"}) | |
private <DATA_TYPE> boolean checkBackgroundRetry(OperationAndData<DATA_TYPE> operationAndData, CuratorEvent event) | |
{ | |
boolean doRetry = false; | |
if ( client.getRetryPolicy().allowRetry(operationAndData.getThenIncrementRetryCount(), operationAndData.getElapsedTimeMs(), operationAndData) ) | |
{ | |
doRetry = true; | |
} | |
else | |
{ | |
if ( operationAndData.getErrorCallback() != null ) | |
{ | |
operationAndData.getErrorCallback().retriesExhausted(operationAndData); | |
} | |
if ( operationAndData.getCallback() != null ) | |
{ | |
sendToBackgroundCallback(operationAndData, event); | |
} | |
KeeperException.Code code = KeeperException.Code.get(event.getResultCode()); | |
Exception e = null; | |
try | |
{ | |
e = (code != null) ? KeeperException.create(code) : null; | |
} | |
catch ( Throwable t ) | |
{ | |
ThreadUtils.checkInterrupted(t); | |
} | |
if ( e == null ) | |
{ | |
e = new Exception("Unknown result codegetResultCode()"); | |
} | |
if ( debugCheckBackgroundRetryLatch != null ) | |
{ | |
if ( debugCheckBackgroundRetryReadyLatch != null ) | |
{ | |
debugCheckBackgroundRetryReadyLatch.countDown(); | |
} | |
try | |
{ | |
debugCheckBackgroundRetryLatch.await(); | |
} | |
catch ( InterruptedException ex ) | |
{ | |
Thread.currentThread().interrupt(); | |
} | |
} | |
validateConnection(codeToState(code)); | |
logError("Background operation retry gave up", e); | |
} | |
return doRetry; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment