szetszwo commented on code in PR #3482:
URL: https://github.com/apache/ozone/pull/3482#discussion_r896980706


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/LegacyReplicationManager.java:
##########
@@ -102,6 +105,111 @@ public class LegacyReplicationManager {
   public static final Logger LOG =
       LoggerFactory.getLogger(LegacyReplicationManager.class);
 
+  static class InflightMap {
+    private final Map<ContainerID, List<InflightAction>> map
+        = new ConcurrentHashMap<>();
+    private final InflightType type;
+    private final int sizeLimit;
+    private final AtomicInteger inflightCount = new AtomicInteger();
+
+    InflightMap(InflightType type, int sizeLimit) {
+      this.type = type;
+      this.sizeLimit = sizeLimit > 0 ? sizeLimit : Integer.MAX_VALUE;
+    }
+
+    boolean isReplication() {
+      return type == InflightType.REPLICATION;
+    }
+
+    private List<InflightAction> get(ContainerID id) {
+      return map.get(id);
+    }
+
+    boolean containsKey(ContainerID id) {
+      return map.containsKey(id);
+    }
+
+    int inflightActionCount(ContainerID id) {
+      return Optional.ofNullable(map.get(id)).map(List::size).orElse(0);
+    }
+
+    int containerCount() {
+      return map.size();
+    }
+
+    boolean isFull() {
+      return inflightCount.get() >= sizeLimit;
+    }
+
+    void clear() {
+      map.clear();
+    }
+
+    void iterate(ContainerID id, Function<InflightAction, Boolean> processor) {
+      for (; ;) {
+        final List<InflightAction> actions = get(id);
+        if (actions == null) {
+          return;
+        }
+        synchronized (actions) {
+          if (get(id) != actions) {
+            continue; //actions is changed, retry
+          }
+          for (Iterator<InflightAction> i = actions.iterator(); i.hasNext();) {
+            final Boolean remove = processor.apply(i.next());
+            if (remove == Boolean.TRUE) {

Review Comment:
   @adoroszlai , thanks for pointing out the findbugs warning.  I kept checking 
all the highlighted Warnings like this 
https://github.com/apache/ozone/runs/6874432894?check_suite_focus=true#step:5:1669
 but missed the real findbugs warning was not highlighted 
https://github.com/apache/ozone/runs/6874432894?check_suite_focus=true#step:5:1726
   
   And yes, windbags is findbugs after the auto spelling correction.  :)



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