Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. @VisibleForTesting
  2. volatile CountDownLatch debugCheckBackgroundRetryLatch;
  3. @VisibleForTesting
  4. volatile CountDownLatch debugCheckBackgroundRetryReadyLatch;
  5.  
  6. @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
  7. private <DATA_TYPE> boolean checkBackgroundRetry(OperationAndData<DATA_TYPE> operationAndData, CuratorEvent event)
  8. {
  9. boolean doRetry = false;
  10. if ( client.getRetryPolicy().allowRetry(operationAndData.getThenIncrementRetryCount(), operationAndData.getElapsedTimeMs(), operationAndData) )
  11. {
  12. doRetry = true;
  13. }
  14. else
  15. {
  16. if ( operationAndData.getErrorCallback() != null )
  17. {
  18. operationAndData.getErrorCallback().retriesExhausted(operationAndData);
  19. }
  20.  
  21. if ( operationAndData.getCallback() != null )
  22. {
  23. sendToBackgroundCallback(operationAndData, event);
  24. }
  25.  
  26. KeeperException.Code code = KeeperException.Code.get(event.getResultCode());
  27. Exception e = null;
  28. try
  29. {
  30. e = (code != null) ? KeeperException.create(code) : null;
  31. }
  32. catch ( Throwable t )
  33. {
  34. ThreadUtils.checkInterrupted(t);
  35. }
  36. if ( e == null )
  37. {
  38. e = new Exception("Unknown result codegetResultCode()");
  39. }
  40.  
  41. if ( debugCheckBackgroundRetryLatch != null )
  42. {
  43. if ( debugCheckBackgroundRetryReadyLatch != null )
  44. {
  45. debugCheckBackgroundRetryReadyLatch.countDown();
  46. }
  47. try
  48. {
  49. debugCheckBackgroundRetryLatch.await();
  50. }
  51. catch ( InterruptedException ex )
  52. {
  53. Thread.currentThread().interrupt();
  54. }
  55. }
  56.  
  57. validateConnection(codeToState(code));
  58. logError("Background operation retry gave up", e);
  59. }
  60. return doRetry;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement