This is an automated email from the ASF dual-hosted git repository. elek pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git
The following commit(s) were added to refs/heads/master by this push: new e1ef54d HDDS-3672. Ozone fs failed to list intermediate directory. (#976) e1ef54d is described below commit e1ef54d8fb51dab66e537e68eeccd39d2241db02 Author: Sammi Chen <sammic...@apache.org> AuthorDate: Tue Jun 2 22:20:10 2020 +0800 HDDS-3672. Ozone fs failed to list intermediate directory. (#976) --- .../hadoop/fs/ozone/TestOzoneFileSystem.java | 29 ++++++++++++++++++++++ .../org/apache/hadoop/ozone/om/KeyManagerImpl.java | 10 ++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java index ce176b0..c784897 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java @@ -19,6 +19,8 @@ package org.apache.hadoop.fs.ozone; import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; import java.util.Set; import java.util.TreeSet; import java.util.concurrent.TimeoutException; @@ -37,9 +39,12 @@ import org.apache.hadoop.ozone.OzoneConsts; import org.apache.hadoop.ozone.TestDataUtil; import org.apache.hadoop.ozone.client.OzoneBucket; import org.apache.hadoop.ozone.client.OzoneKeyDetails; +import org.apache.hadoop.ozone.om.helpers.OmKeyArgs; +import org.apache.hadoop.ozone.om.helpers.OpenKeySession; import org.apache.hadoop.test.GenericTestUtils; import org.apache.commons.io.IOUtils; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -49,6 +54,7 @@ import static org.junit.Assert.fail; import org.apache.hadoop.test.LambdaTestUtils; import org.junit.After; +import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout; @@ -280,6 +286,29 @@ public class TestOzoneFileSystem { 3, fileStatuses.length); } + @Test + public void testListStatusWithIntermediateDir() throws Exception { + setupOzoneFileSystem(); + String keyName = "object-dir/object-name"; + OmKeyArgs keyArgs = new OmKeyArgs.Builder() + .setVolumeName(volumeName) + .setBucketName(bucketName) + .setKeyName(keyName) + .setAcls(Collections.emptyList()) + .setLocationInfoList(new ArrayList<>()) + .build(); + + OpenKeySession session = cluster.getOzoneManager().openKey(keyArgs); + cluster.getOzoneManager().commitKey(keyArgs, session.getId()); + + Path parent = new Path("/"); + FileStatus[] fileStatuses = fs.listStatus(parent); + + // the number of immediate children of root is 1 + Assert.assertEquals(1, fileStatuses.length); + cluster.getOzoneManager().deleteKey(keyArgs); + } + /** * Tests listStatus operation on root directory. */ diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java index 62f0015..9e12e13 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java @@ -2037,11 +2037,11 @@ public class KeyManagerImpl implements KeyManager { // if entry is a directory if (!deletedKeySet.contains(entryInDb)) { if (!entryKeyName.equals(immediateChild)) { - OmKeyInfo fakeDirEntry = new OmKeyInfo.Builder() - .setVolumeName(omKeyInfo.getVolumeName()) - .setBucketName(omKeyInfo.getBucketName()) - .setKeyName(immediateChild) - .build(); + OmKeyInfo fakeDirEntry = createDirectoryKey( + omKeyInfo.getVolumeName(), + omKeyInfo.getBucketName(), + immediateChild, + omKeyInfo.getAcls()); cacheKeyMap.put(entryInDb, new OzoneFileStatus(fakeDirEntry, scmBlockSize, true)); } else { --------------------------------------------------------------------- To unsubscribe, e-mail: ozone-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: ozone-commits-h...@hadoop.apache.org