sodonnel commented on code in PR #3743:
URL: https://github.com/apache/ozone/pull/3743#discussion_r968281933


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManager.java:
##########
@@ -187,15 +188,22 @@ public ReplicationManager(final ConfigurationSource conf,
         TimeUnit.MILLISECONDS);
     this.containerReplicaPendingOps = replicaPendingOps;
     this.legacyReplicationManager = legacyReplicationManager;
-    this.ecContainerHealthCheck = new ECContainerHealthCheck();
+    this.ecReplicationCheckHandler = new ECReplicationCheckHandler();
     this.nodeManager = nodeManager;
     this.underRepQueue = createUnderReplicatedQueue();
     this.overRepQueue = new LinkedList<>();
     this.maintenanceRedundancy = rmConf.maintenanceRemainingRedundancy;
     ecUnderReplicationHandler = new ECUnderReplicationHandler(
-        containerPlacement, conf, nodeManager);
+        ecReplicationCheckHandler, containerPlacement, conf, nodeManager);
     ecOverReplicationHandler =
-        new ECOverReplicationHandler(containerPlacement, nodeManager);
+        new ECOverReplicationHandler(ecReplicationCheckHandler,
+            containerPlacement, nodeManager);
+
+    // Chain together the series of checks that are needed to validate the
+    // containers when they are checked by RM.
+    containerCheckChain = new OpenContainerHandler(this);
+    containerCheckChain.addNext(new ClosedWithMismatchedReplicasHandler(this));
+    containerCheckChain.addNext(ecReplicationCheckHandler);

Review Comment:
   It returns the "next" health check so you can chain the calls like above. 
Say we have 3 checks - openContainer, closedContainer, mptyContainer.
   
   When we do `containerCheckChain = new OpenContainer(this);` we have stored 
the openContainerCheck into the chain variable.
   
   When we call `containerCheckChain.addNext(new ClosedContainer(this)`, it 
adds closedContainer to successor in `openContainer`, but it returns 
closedContainer. Then we we call addNext again, it add emptyContainer to the 
successor in closedContainer. Its similar to how a builder object returns 
"this" so you can chain the calls.
   
   ```
       containerCheckChain = new OpenContainerHandler(this);
     \\ Add open ClosedWithMismatchedReplicasHandler to the successor in 
openContainerHandler
       containerCheckChain.addNext(new 
ClosedWithMismatchedReplicasHandler(this));
     \\ Add ecReplicationCheckHandler to the successor in 
ClosedWithMismatchedReplicasHandler
       containerCheckChain.addNext(ecReplicationCheckHandler);
   ```



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