yl09099 commented on code in PR #1258:
URL: 
https://github.com/apache/incubator-uniffle/pull/1258#discussion_r1377215762


##########
client-spark/common/src/main/java/org/apache/uniffle/shuffle/manager/ShuffleManagerGrpcService.java:
##########
@@ -163,6 +239,90 @@ public void unregisterShuffle(int shuffleId) {
     shuffleStatus.remove(shuffleId);
   }
 
+  private static class ShuffleServerFailureRecord {
+    private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+    private final ReentrantReadWriteLock.ReadLock readLock = lock.readLock();
+    private final ReentrantReadWriteLock.WriteLock writeLock = 
lock.writeLock();
+    private final Map<String, AtomicInteger> shuffleServerFailureRecordCount;
+    private int stageAttemptNumber;
+
+    private ShuffleServerFailureRecord(
+        Map<String, AtomicInteger> shuffleServerFailureRecordCount, int 
stageAttemptNumber) {
+      this.shuffleServerFailureRecordCount = shuffleServerFailureRecordCount;
+      this.stageAttemptNumber = stageAttemptNumber;
+    }
+
+    private <T> T withReadLock(Supplier<T> fn) {
+      readLock.lock();
+      try {
+        return fn.get();
+      } finally {
+        readLock.unlock();
+      }
+    }
+
+    private <T> T withWriteLock(Supplier<T> fn) {
+      writeLock.lock();
+      try {
+        return fn.get();
+      } finally {
+        writeLock.unlock();
+      }
+    }
+
+    public int getStageAttempt() {
+      return withReadLock(() -> this.stageAttemptNumber);
+    }
+
+    public int resetStageAttemptIfNecessary(int stageAttemptNumber) {

Review Comment:
   > Could we return `bool` type here?
   
   Have been changed.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to