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/01/14 07:19:04 UTC

[GitHub] [ozone] adoroszlai commented on a change in pull request #2989: HDDS-6109 Preserve the underlying exception raised in client lib.

adoroszlai commented on a change in pull request #2989:
URL: https://github.com/apache/ozone/pull/2989#discussion_r784594546



##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestContainerStateMachineFailures.java
##########
@@ -677,4 +682,133 @@ public void testWriteStateMachineDataIdempotencyWithClosedContainer()
 
     r2.run();
   }
+
+  @Test
+  public void testContainerStateMachineSingleFailureRetry()
+      throws Exception {
+    OzoneOutputStream key =
+        objectStore.getVolume(volumeName).getBucket(bucketName)
+            .createKey("ratis1", 1024, ReplicationType.RATIS,
+                ReplicationFactor.THREE, new HashMap<>());
+
+    key.write("ratis".getBytes(UTF_8));
+    key.flush();
+    key.write("ratis".getBytes(UTF_8));
+    key.write("ratis".getBytes(UTF_8));
+
+    KeyOutputStream groupOutputStream = (KeyOutputStream) key.
+        getOutputStream();
+    List<OmKeyLocationInfo> locationInfoList =
+        groupOutputStream.getLocationInfoList();
+    Assert.assertEquals(1, locationInfoList.size());
+
+    OmKeyLocationInfo omKeyLocationInfo = locationInfoList.get(0);
+
+    Set<HddsDatanodeService> datanodeSet =
+        TestHelper.getDatanodeServices(cluster,
+            omKeyLocationInfo.getPipeline());
+
+    UUID leader = omKeyLocationInfo.getPipeline().getLeaderId();
+    for (HddsDatanodeService dn : datanodeSet) {
+      UUID dnUuid = dn.getDatanodeDetails().getUuid();
+      if (!dnUuid.equals(leader)) {
+        ContainerData containerData =
+            dn.getDatanodeStateMachine()
+                .getContainer().getContainerSet()
+                .getContainer(omKeyLocationInfo.getContainerID())
+                .getContainerData();
+        Assert.assertTrue(containerData instanceof KeyValueContainerData);
+        KeyValueContainerData keyValueContainerData =
+            (KeyValueContainerData) containerData;
+        FileUtil.fullyDelete(new File(keyValueContainerData.getChunksPath()));
+        break;
+      }
+    }
+    try {
+      key.close();
+    } catch (Exception ioe) {
+      // Should not fail..
+      Assert.fail("Exception " + ioe.getMessage());
+    }
+    validateData("ratis1", 2, "ratisratisratis");
+  }
+
+  @Test
+  public void testContainerStateMachineDualFailureRetry()

Review comment:
       `testContainerStateMachineSingleFailureRetry` and `testContainerStateMachineDualFailureRetry` are almost the same.  Can you please reduce code duplication to make the rather subtle difference more visible?
   
   Something along the lines:
   
   ```
       OzoneOutputStream key = writeKey("ratis1");
       deleteFollowerContainers(getKeyLocationInfo(key), 1);
       closeKey(key);
       validateData("ratis1", 2, "ratisratisratis");
   ```
   
   BTW, Is 2 the expected `locationCount` due to the call to `key.flush()`?

##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestContainerStateMachineFailures.java
##########
@@ -677,4 +682,133 @@ public void testWriteStateMachineDataIdempotencyWithClosedContainer()
 
     r2.run();
   }
+
+  @Test
+  public void testContainerStateMachineSingleFailureRetry()
+      throws Exception {
+    OzoneOutputStream key =
+        objectStore.getVolume(volumeName).getBucket(bucketName)
+            .createKey("ratis1", 1024, ReplicationType.RATIS,
+                ReplicationFactor.THREE, new HashMap<>());
+
+    key.write("ratis".getBytes(UTF_8));
+    key.flush();
+    key.write("ratis".getBytes(UTF_8));
+    key.write("ratis".getBytes(UTF_8));
+
+    KeyOutputStream groupOutputStream = (KeyOutputStream) key.
+        getOutputStream();
+    List<OmKeyLocationInfo> locationInfoList =
+        groupOutputStream.getLocationInfoList();
+    Assert.assertEquals(1, locationInfoList.size());
+
+    OmKeyLocationInfo omKeyLocationInfo = locationInfoList.get(0);
+
+    Set<HddsDatanodeService> datanodeSet =
+        TestHelper.getDatanodeServices(cluster,
+            omKeyLocationInfo.getPipeline());
+
+    UUID leader = omKeyLocationInfo.getPipeline().getLeaderId();
+    for (HddsDatanodeService dn : datanodeSet) {
+      UUID dnUuid = dn.getDatanodeDetails().getUuid();
+      if (!dnUuid.equals(leader)) {
+        ContainerData containerData =
+            dn.getDatanodeStateMachine()
+                .getContainer().getContainerSet()
+                .getContainer(omKeyLocationInfo.getContainerID())
+                .getContainerData();
+        Assert.assertTrue(containerData instanceof KeyValueContainerData);
+        KeyValueContainerData keyValueContainerData =
+            (KeyValueContainerData) containerData;
+        FileUtil.fullyDelete(new File(keyValueContainerData.getChunksPath()));
+        break;
+      }
+    }
+    try {
+      key.close();
+    } catch (Exception ioe) {
+      // Should not fail..
+      Assert.fail("Exception " + ioe.getMessage());
+    }
+    validateData("ratis1", 2, "ratisratisratis");
+  }
+
+  @Test
+  public void testContainerStateMachineDualFailureRetry()
+      throws Exception {
+    OzoneOutputStream key =
+        objectStore.getVolume(volumeName).getBucket(bucketName)
+            .createKey("ratis2", 1024, ReplicationType.RATIS,
+                ReplicationFactor.THREE, new HashMap<>());
+
+    key.write("ratis".getBytes(UTF_8));
+    key.flush();
+    key.write("ratis".getBytes(UTF_8));
+    key.write("ratis".getBytes(UTF_8));
+
+    KeyOutputStream groupOutputStream = (KeyOutputStream) key.
+        getOutputStream();
+    List<OmKeyLocationInfo> locationInfoList =
+        groupOutputStream.getLocationInfoList();
+    Assert.assertEquals(1, locationInfoList.size());
+
+    OmKeyLocationInfo omKeyLocationInfo = locationInfoList.get(0);
+
+    Set<HddsDatanodeService> datanodeSet =
+        TestHelper.getDatanodeServices(cluster,
+            omKeyLocationInfo.getPipeline());
+
+    UUID leader = omKeyLocationInfo.getPipeline().getLeaderId();
+    for (HddsDatanodeService dn : datanodeSet) {
+      UUID dnUuid = dn.getDatanodeDetails().getUuid();
+      if (!dnUuid.equals(leader)) {
+        ContainerData containerData =
+            dn.getDatanodeStateMachine()
+                .getContainer().getContainerSet()
+                .getContainer(omKeyLocationInfo.getContainerID())
+                .getContainerData();
+        Assert.assertTrue(containerData instanceof KeyValueContainerData);
+        KeyValueContainerData keyValueContainerData =
+            (KeyValueContainerData) containerData;
+        FileUtil.fullyDelete(new File(keyValueContainerData.getChunksPath()));
+      }
+    }
+    try {
+      key.close();
+    } catch (Exception ioe) {
+      // Should not fail..
+      Assert.fail("Exception " + ioe.getMessage());
+    }
+    validateData("ratis2", 2, "ratisratisratis");
+  }
+
+  private void validateData(String key, int locationCount, String payload) {
+    OmKeyArgs omKeyArgs = new OmKeyArgs.Builder()
+        .setVolumeName(volumeName)
+        .setBucketName(bucketName)
+        .setKeyName(key)
+        .setRefreshPipeline(true)
+        .build();
+    OmKeyInfo keyInfo = null;
+    try {
+      keyInfo = cluster.getOzoneManager().lookupKey(omKeyArgs);
+      Assert.assertEquals(
+          keyInfo.getLatestVersionLocations().getLocationListCount(),
+          locationCount);

Review comment:
       Nit: actual and expected values are swapped.
   
   ```suggestion
         Assert.assertEquals(locationCount,
             keyInfo.getLatestVersionLocations().getLocationListCount());
   ```




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