You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/06/27 11:07:28 UTC

[GitHub] [ozone] sodonnel commented on a diff in pull request #3550: HDDS-6945. EC: EC Reconstruction Command count queues should be included in DN heartbeat

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


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/ec/reconstruction/TestECReconstructionSupervisor.java:
##########
@@ -17,37 +17,57 @@
  */
 package org.apache.hadoop.ozone.container.ec.reconstruction;
 
+import com.google.common.collect.ImmutableList;
+import org.apache.hadoop.hdds.client.ECReplicationConfig;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
 import org.apache.ozone.test.GenericTestUtils;
+import org.junit.Assert;
 import org.junit.Test;
 
+import java.io.IOException;
+import java.util.SortedMap;
 import java.util.concurrent.TimeoutException;
 
 /**
  * Tests the ECReconstructionSupervisor.
  */
 public class TestECReconstructionSupervisor {
 
-  private final ECReconstructionSupervisor supervisor =
-      new ECReconstructionSupervisor(null, null, 5, null);
-
   @Test
   public void testAddTaskShouldExecuteTheGivenTask()
-      throws InterruptedException, TimeoutException {
-    FakeTask task = new FakeTask(null);
-    supervisor.addTask(task);
-    GenericTestUtils.waitFor(() -> task.isExecuted, 100, 15000);
-  }
-
-  static class FakeTask extends ECReconstructionCoordinatorTask {
-    private boolean isExecuted = false;
-
-    FakeTask(ECReconstructionCommandInfo reconstructionCommandInfo) {
-      super(null, reconstructionCommandInfo);
-    }
-
-    @Override
-    public void run() {
-      isExecuted = true;
-    }
+      throws InterruptedException, TimeoutException, IOException {
+    final boolean[] reconstructInvoked = {false};

Review Comment:
   Why are these arrays? I guess its because a Boolean is immutable and we cannot change it if its a final, and the variable has to be final to be use in the run block.
   
   I think it would be more clear to use a pair of CountDownLatch objects here. Then we can get rid of most of the waitFor() calls, eg
   
   ```
   CountDownLatch runnableInvoked = new CountDownLatch(1);
   CountDownLatch holdProcessing = new CountDownLatch(1);
   
   // Inside the reconstructECContainerGroup
   ...
   runnableInvoked.countDown();
   holdProcessing.await();
   ...
   
   // In the main test method:
       supervisor.addTask(
           new ECReconstructionCommandInfo(1, new ECReplicationConfig(3, 2),
               new byte[0], ImmutableList.of(), ImmutableList.of()));
       runnableInvoked.await()
       Assert.assertEquals(1, supervisor.getInFlightReplications());
       holdProcessing.countDown();
       GenericTestUtils
           .waitFor(() -> supervisor.getInFlightReplications() == 0, 100, 15000);
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org