From ae2b77a0e52c0ebfd2879931b24bd3e51ee29e5a Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Mon, 9 Oct 2017 14:52:50 -0700 Subject: [PATCH] HDFS-12546. Ozone: DB listing operation performance improvement. Contributed by Weiwei Yang. --- .../ozone/container/common/impl/KeyManagerImpl.java | 2 +- .../statemachine/background/BlockDeletingService.java | 2 +- .../apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java | 8 ++++---- .../hadoop/ozone/scm/container/ContainerMapping.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyManagerImpl.java index 7fff0a34b4..98661b869d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/KeyManagerImpl.java @@ -180,7 +180,7 @@ public List listKey( DFSUtil.string2Bytes(startKey); MetadataKeyFilter prefixFilter = new KeyPrefixFilter(prefix); List> range = - db.getRangeKVs(startKeyInBytes, count, prefixFilter); + db.getSequentialRangeKVs(startKeyInBytes, count, prefixFilter); for (Map.Entry entry : range) { String keyName = KeyUtils.getKeyName(entry.getKey()); KeyData value = KeyUtils.getKeyData(entry.getValue()); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/background/BlockDeletingService.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/background/BlockDeletingService.java index 644e928bab..a90b1e9c16 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/background/BlockDeletingService.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/background/BlockDeletingService.java @@ -175,7 +175,7 @@ public BackgroundTaskResult call() throws Exception { KeyPrefixFilter filter = new KeyPrefixFilter( OzoneConsts.DELETING_KEY_PREFIX); List> toDeleteBlocks = - meta.getRangeKVs(null, blockLimitPerTask, filter); + meta.getSequentialRangeKVs(null, blockLimitPerTask, filter); if (toDeleteBlocks.isEmpty()) { LOG.debug("No under deletion block found in container : {}", containerData.getContainerName()); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java index a24d279e17..f729bfe9f4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/ksm/KSMMetadataManagerImpl.java @@ -347,13 +347,13 @@ public List listKeys(String volumeName, String bucketName, if (!Strings.isNullOrEmpty(startKey)) { //Since we are excluding start key from the result, // the maxNumOfBuckets is incremented. - rangeResult = store.getRangeKVs( + rangeResult = store.getSequentialRangeKVs( getDBKeyBytes(volumeName, bucketName, startKey), maxKeys + 1, filter); //Remove start key from result. rangeResult.remove(0); } else { - rangeResult = store.getRangeKVs(null, maxKeys, filter); + rangeResult = store.getSequentialRangeKVs(null, maxKeys, filter); } for (Map.Entry entry : rangeResult) { @@ -440,7 +440,7 @@ private VolumeList getAllVolumes() throws IOException { // it should be fine to scan all users in db and return us a // list of volume names in string per user. List> rangeKVs = store - .getRangeKVs(null, Integer.MAX_VALUE, filter); + .getSequentialRangeKVs(null, Integer.MAX_VALUE, filter); VolumeList.Builder builder = VolumeList.newBuilder(); for (Map.Entry entry : rangeKVs) { @@ -458,7 +458,7 @@ public List getPendingDeletionKeys(final int count) final MetadataKeyFilter deletingKeyFilter = new KeyPrefixFilter(DELETING_KEY_PREFIX); List> rangeResult = - store.getRangeKVs(null, count, deletingKeyFilter); + store.getSequentialRangeKVs(null, count, deletingKeyFilter); for (Map.Entry entry : rangeResult) { KsmKeyInfo info = KsmKeyInfo.getFromProtobuf(KeyInfo.parseFrom(entry.getValue())); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java index ad1d3c9f91..c6a0f31026 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/scm/container/ContainerMapping.java @@ -145,7 +145,7 @@ public List listContainer(String startName, String prefixName, byte[] startKey = startName == null ? null : DFSUtil.string2Bytes( startName); List> range = - containerStore.getRangeKVs(startKey, count, prefixFilter); + containerStore.getSequentialRangeKVs(startKey, count, prefixFilter); // Transform the values into the pipelines. // TODO: return list of ContainerInfo instead of pipelines.