You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by bh...@apache.org on 2021/11/02 17:24:55 UTC

[ozone] branch master updated: HDDS-5908. MPU getKey can fail, if completeMPU result is still in cache. (#2787)

This is an automated email from the ASF dual-hosted git repository.

bharat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f0a588  HDDS-5908. MPU getKey can fail, if completeMPU result is still in cache. (#2787)
5f0a588 is described below

commit 5f0a5887c289a9c0a78c188472e80e5496dee1e4
Author: Bharat Viswanadham <bh...@apache.org>
AuthorDate: Tue Nov 2 10:24:28 2021 -0700

    HDDS-5908. MPU getKey can fail, if completeMPU result is still in cache. (#2787)
---
 .../apache/hadoop/ozone/om/helpers/OmKeyInfo.java  |  3 +-
 .../hadoop/ozone/om/helpers/TestOmKeyInfo.java     | 41 ++++++++++++++++++----
 2 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java
index da48fe4..4282f33 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java
@@ -676,7 +676,8 @@ public final class OmKeyInfo extends WithParentObjectId {
     keyLocationVersions.forEach(keyLocationVersion ->
         builder.addOmKeyLocationInfoGroup(
             new OmKeyLocationInfoGroup(keyLocationVersion.getVersion(),
-                keyLocationVersion.getLocationList())));
+                keyLocationVersion.getLocationList(),
+                keyLocationVersion.isMultipartKey())));
 
     acls.forEach(acl -> builder.addAcl(new OzoneAcl(acl.getType(),
             acl.getName(), (BitSet) acl.getAclBitSet().clone(),
diff --git a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmKeyInfo.java b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmKeyInfo.java
index eaf83d9..a3df5b2 100644
--- a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmKeyInfo.java
+++ b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmKeyInfo.java
@@ -66,6 +66,15 @@ public class TestOmKeyInfo {
 
   @Test
   public void testCopyObject() {
+    createdAndTest(false);
+  }
+
+  @Test
+  public void testCopyObjectWithMPU() {
+    createdAndTest(true);
+  }
+
+  private void createdAndTest(boolean isMPU) {
     OmKeyInfo key = new Builder()
         .setKeyName("key1")
         .setBucketName("bucket")
@@ -74,11 +83,11 @@ public class TestOmKeyInfo {
         .setModificationTime(Time.now())
         .setDataSize(100L)
         .setReplicationConfig(
-                new RatisReplicationConfig(ReplicationFactor.THREE))
+            new RatisReplicationConfig(ReplicationFactor.THREE))
         .addMetadata("key1", "value1")
         .addMetadata("key2", "value2")
         .setOmKeyLocationInfos(
-            Collections.singletonList(createOmKeyLocationInfoGroup()))
+            Collections.singletonList(createOmKeyLocationInfoGroup(isMPU)))
         .build();
 
     OmKeyInfo cloneKey = key.copyObject();
@@ -87,6 +96,27 @@ public class TestOmKeyInfo {
     // method, so it checks only references.
     Assert.assertNotEquals(key, cloneKey);
 
+    // Check each version content here.
+    Assert.assertEquals(key.getKeyLocationVersions().size(),
+        cloneKey.getKeyLocationVersions().size());
+
+    // Check blocks for each version.
+    for (int i = 0; i < key.getKeyLocationVersions().size(); i++) {
+      OmKeyLocationInfoGroup orig = key.getKeyLocationVersions().get(i);
+      OmKeyLocationInfoGroup clone = key.getKeyLocationVersions().get(i);
+
+      Assert.assertEquals(orig.isMultipartKey(), clone.isMultipartKey());
+      Assert.assertEquals(orig.getVersion(), clone.getVersion());
+
+      Assert.assertEquals(orig.getLocationList().size(),
+          clone.getLocationList().size());
+
+      for (int j = 0; j < orig.getLocationList().size(); j++) {
+        OmKeyLocationInfo origLocationInfo = orig.getLocationList().get(j);
+        OmKeyLocationInfo cloneLocationInfo = clone.getLocationList().get(j);
+        Assert.assertEquals(origLocationInfo, cloneLocationInfo);
+      }
+    }
 
     key.setAcls(Arrays.asList(new OzoneAcl(
         IAccessAuthorizer.ACLIdentityType.USER, "user1",
@@ -101,17 +131,16 @@ public class TestOmKeyInfo {
     cloneKey = key.copyObject();
 
     Assert.assertEquals(key.getAcls(), cloneKey.getAcls());
-
-
   }
 
-  private OmKeyLocationInfoGroup createOmKeyLocationInfoGroup() {
+
+  private OmKeyLocationInfoGroup createOmKeyLocationInfoGroup(boolean isMPU) {
     List<OmKeyLocationInfo> omKeyLocationInfos = new ArrayList<>();
     omKeyLocationInfos.add(getOmKeyLocationInfo(new BlockID(100L, 101L),
         getPipeline()));
     omKeyLocationInfos.add(getOmKeyLocationInfo(new BlockID(101L, 100L),
         getPipeline()));
-    return new OmKeyLocationInfoGroup(0, omKeyLocationInfos);
+    return new OmKeyLocationInfoGroup(0, omKeyLocationInfos, isMPU);
 
   }
 

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