From 393a02d8e1822082095c9fa56b78e0f5989cdb7b Mon Sep 17 00:00:00 2001 From: Yiqun Lin Date: Tue, 24 Oct 2017 19:27:48 +0800 Subject: [PATCH] HDFS-12692. Ozone: fix javadoc/unit test for calling MetadataStore.getRangeKVs with non existing key. Contributed by Elek, Marton. --- .../src/main/java/org/apache/hadoop/utils/LevelDBStore.java | 2 +- .../main/java/org/apache/hadoop/utils/MetadataStore.java | 2 +- .../java/org/apache/hadoop/ozone/TestMetadataStore.java | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/utils/LevelDBStore.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/utils/LevelDBStore.java index 57ae538b18..38cee762be 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/utils/LevelDBStore.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/utils/LevelDBStore.java @@ -286,7 +286,7 @@ public List> getSequentialRangeKVs(byte[] startKey, * If the startKey is specified and found in levelDB, this key and the keys * after this key will be included in the result. If the startKey is null * all entries will be included as long as other conditions are satisfied. - * If the given startKey doesn't exist, an IOException will be thrown. + * If the given startKey doesn't exist, an empty list will be returned. *

* The count argument is to limit number of total entries to return, * the value for count must be an integer greater than 0. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/utils/MetadataStore.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/utils/MetadataStore.java index 9a17bb5489..b90b08f658 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/utils/MetadataStore.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/utils/MetadataStore.java @@ -78,7 +78,7 @@ public interface MetadataStore extends Closeable{ * If the startKey is specified and found in levelDB, this key and the keys * after this key will be included in the result. If the startKey is null * all entries will be included as long as other conditions are satisfied. - * If the given startKey doesn't exist, an IOException will be thrown. + * If the given startKey doesn't exist and empty list will be returned. *

* The count argument is to limit number of total entries to return, * the value for count must be an integer greater than 0. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/TestMetadataStore.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/TestMetadataStore.java index 9442e998d2..da42c483a3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/TestMetadataStore.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/TestMetadataStore.java @@ -95,7 +95,7 @@ public void init() throws IOException { // Add 20 entries. // {a0 : a-value0} to {a9 : a-value9} - // {b0 : a-value0} to {b0 : b-value9} + // {b0 : b-value0} to {b9 : b-value9} for (int i=0; i<10; i++) { store.put(getBytes("a" + i), getBytes("a-value" + i)); store.put(getBytes("b" + i), getBytes("b-value" + i)); @@ -242,6 +242,10 @@ public void testGetRangeKVs() throws IOException { Assert.assertEquals(5, result.size()); Assert.assertEquals("a-value2", getString(result.get(2).getValue())); + // Empty list if startKey doesn't exist. + result = store.getRangeKVs(getBytes("a12"), 5); + Assert.assertEquals(0, result.size()); + // Returns max available entries after a valid startKey. result = store.getRangeKVs(getBytes("b0"), MAX_GETRANGE_LENGTH); Assert.assertEquals(10, result.size());