hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aengin...@apache.org
Subject hadoop git commit: HDFS-11913. Ozone: TestKeySpaceManager#testDeleteVolume fails. Contributed by Weiwei Yang.
Date Fri, 02 Jun 2017 07:53:33 GMT
Repository: hadoop
Updated Branches:
  refs/heads/HDFS-7240 f289e8e73 -> 5cdd88007


HDFS-11913. Ozone: TestKeySpaceManager#testDeleteVolume fails. Contributed by Weiwei Yang.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/5cdd8800
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/5cdd8800
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/5cdd8800

Branch: refs/heads/HDFS-7240
Commit: 5cdd880078f13d08683925c96448299a78aec008
Parents: f289e8e
Author: Anu Engineer <aengineer@apache.org>
Authored: Fri Jun 2 00:48:39 2017 -0700
Committer: Anu Engineer <aengineer@apache.org>
Committed: Fri Jun 2 00:48:39 2017 -0700

----------------------------------------------------------------------
 .../hadoop/ozone/ksm/MetadataManagerImpl.java   | 12 ++++--
 .../hadoop/ozone/ksm/TestKeySpaceManager.java   | 45 +++++++++++++-------
 2 files changed, 38 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/5cdd8800/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java
index 8efe724..043175e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/MetadataManagerImpl.java
@@ -201,10 +201,14 @@ public class MetadataManagerImpl implements  MetadataManager {
       byte[] dbVolumeRootKey = DFSUtil.string2Bytes(dbVolumeRootName);
       // Seek to the root of the volume and look for the next key
       iterator.seek(dbVolumeRootKey);
-      String firstBucketKey = DFSUtil.bytes2String(iterator.next().getKey());
-      // if the key starts with /<volume name>
-      // then there is at least one bucket
-      return !firstBucketKey.startsWith(OzoneConsts.KSM_VOLUME_PREFIX + volume);
+      if (iterator.hasNext()) {
+        String firstBucketKey = DFSUtil.bytes2String(iterator.next().getKey());
+        // if the key starts with /<volume name>/
+        // then there is at least one bucket
+        return !firstBucketKey.startsWith(dbVolumeRootName);
+      } else {
+        return true;
+      }
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5cdd8800/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/ksm/TestKeySpaceManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/ksm/TestKeySpaceManager.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/ksm/TestKeySpaceManager.java
index 90dbc25..0acebcb 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/ksm/TestKeySpaceManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/ksm/TestKeySpaceManager.java
@@ -187,26 +187,41 @@ public class TestKeySpaceManager {
     String userName = "user" + RandomStringUtils.randomNumeric(5);
     String adminName = "admin" + RandomStringUtils.randomNumeric(5);
     String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
+    String volumeName1 = volumeName + "_A";
+    String volumeName2 = volumeName + "_AA";
+    VolumeArgs volumeArgs = null;
+    VolumeInfo volumeInfo = null;
 
-    VolumeArgs createVolumeArgs = new VolumeArgs(volumeName, userArgs);
-    createVolumeArgs.setUserName(userName);
-    createVolumeArgs.setAdminName(adminName);
-    storageHandler.createVolume(createVolumeArgs);
+    // Create 2 empty volumes with same prefix.
+    volumeArgs = new VolumeArgs(volumeName1, userArgs);
+    volumeArgs.setUserName(userName);
+    volumeArgs.setAdminName(adminName);
+    storageHandler.createVolume(volumeArgs);
 
-    VolumeArgs getVolumeArgs = new VolumeArgs(volumeName, userArgs);
-    VolumeInfo retVolumeInfo = storageHandler.getVolumeInfo(getVolumeArgs);
-    Assert.assertTrue(retVolumeInfo.getVolumeName().equals(volumeName));
-    Assert.assertTrue(retVolumeInfo.getOwner().getName().equals(userName));
+    volumeArgs = new VolumeArgs(volumeName2, userArgs);
+    volumeArgs.setUserName(userName);
+    volumeArgs.setAdminName(adminName);
+    storageHandler.createVolume(volumeArgs);
+
+    volumeArgs  = new VolumeArgs(volumeName1, userArgs);
+    volumeInfo = storageHandler.getVolumeInfo(volumeArgs);
+    Assert.assertTrue(volumeInfo.getVolumeName().equals(volumeName1));
+    Assert.assertTrue(volumeInfo.getOwner().getName().equals(userName));
     Assert.assertEquals(0, ksmMetrics.getNumVolumeCreateFails());
 
-    storageHandler.deleteVolume(createVolumeArgs);
+    // Volume with _A should be able to delete as it is empty.
+    storageHandler.deleteVolume(volumeArgs);
 
-    try {
-      retVolumeInfo = storageHandler.getVolumeInfo(getVolumeArgs);
-    } catch (IOException ex) {
-      Assert.assertEquals(ex.getMessage(),
-          "Info Volume failed, error:VOLUME_NOT_FOUND");
-    }
+    // Make sure volume with _AA suffix still exists.
+    volumeArgs = new VolumeArgs(volumeName2, userArgs);
+    volumeInfo = storageHandler.getVolumeInfo(volumeArgs);
+    Assert.assertTrue(volumeInfo.getVolumeName().equals(volumeName2));
+
+    // Make sure volume with _A suffix is successfully deleted.
+    exception.expect(IOException.class);
+    exception.expectMessage("Info Volume failed, error:VOLUME_NOT_FOUND");
+    volumeArgs = new VolumeArgs(volumeName1, userArgs);
+    storageHandler.getVolumeInfo(volumeArgs);
   }
 
   // Create a volume and a bucket inside the volume,


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


Mime
View raw message