linyiqun commented on a change in pull request #1503: URL: https://github.com/apache/hadoop-ozone/pull/1503#discussion_r506854548
########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java ########## @@ -2205,6 +2272,167 @@ private void listStatusFindKeyInTableCache( return fileStatusList; } + public List<OzoneFileStatus> listStatusV1(OmKeyArgs args, boolean recursive, + String startKey, long numEntries, String clientAddress) + throws IOException { + Preconditions.checkNotNull(args, "Key args can not be null"); + + List<OzoneFileStatus> fileStatusList = new ArrayList<>(); + if (numEntries <= 0) { + return fileStatusList; + } + + String volumeName = args.getVolumeName(); + String bucketName = args.getBucketName(); + String keyName = args.getKeyName(); + // A map sorted by OmKey to combine results from TableCache and DB. + TreeMap<String, OzoneFileStatus> cacheKeyMap = new TreeMap<>(); + String seekKeyInDB = ""; + long prefixKeyInDB = Long.MIN_VALUE; + String prefixPath = keyName; + + metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName, + bucketName); + try { + if (Strings.isNullOrEmpty(startKey)) { + OzoneFileStatus fileStatus = getFileStatus(args, clientAddress); + if (fileStatus.isFile()) { + return Collections.singletonList(fileStatus); + } + + // keyName is a directory + if (fileStatus.getKeyInfo() != null) { + seekKeyInDB = fileStatus.getKeyInfo().getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = fileStatus.getKeyInfo().getObjectID(); + } else { + String bucketKey = metadataManager.getBucketKey(volumeName, + bucketName); + OmBucketInfo omBucketInfo = + metadataManager.getBucketTable().get(bucketKey); + seekKeyInDB = omBucketInfo.getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = omBucketInfo.getObjectID(); + } + } else { + // startKey will be used in iterator seek and sets the beginning point + // for key traversal. + // key name will be used as parent ID where the user has requested to + // list the keys from. + OzoneFileStatus fileStatusInfo = getOzoneFileStatusV1(volumeName, + bucketName, startKey, false, null); + if (fileStatusInfo != null) { + prefixKeyInDB = fileStatusInfo.getKeyInfo().getParentObjectID(); + seekKeyInDB = prefixKeyInDB + OZONE_URI_DELIMITER + + fileStatusInfo.getKeyInfo().getFileName(); + } Review comment: If we cannot find the first OzoneFileStatus based on given startKey. It means that there is no other OzoneFileStatus matched. And we should return the empty list. ########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java ########## @@ -2205,6 +2272,167 @@ private void listStatusFindKeyInTableCache( return fileStatusList; } + public List<OzoneFileStatus> listStatusV1(OmKeyArgs args, boolean recursive, + String startKey, long numEntries, String clientAddress) + throws IOException { + Preconditions.checkNotNull(args, "Key args can not be null"); + + List<OzoneFileStatus> fileStatusList = new ArrayList<>(); + if (numEntries <= 0) { + return fileStatusList; + } + + String volumeName = args.getVolumeName(); + String bucketName = args.getBucketName(); + String keyName = args.getKeyName(); + // A map sorted by OmKey to combine results from TableCache and DB. + TreeMap<String, OzoneFileStatus> cacheKeyMap = new TreeMap<>(); + String seekKeyInDB = ""; + long prefixKeyInDB = Long.MIN_VALUE; + String prefixPath = keyName; + + metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName, + bucketName); + try { + if (Strings.isNullOrEmpty(startKey)) { + OzoneFileStatus fileStatus = getFileStatus(args, clientAddress); + if (fileStatus.isFile()) { + return Collections.singletonList(fileStatus); + } + + // keyName is a directory + if (fileStatus.getKeyInfo() != null) { + seekKeyInDB = fileStatus.getKeyInfo().getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = fileStatus.getKeyInfo().getObjectID(); + } else { + String bucketKey = metadataManager.getBucketKey(volumeName, + bucketName); + OmBucketInfo omBucketInfo = + metadataManager.getBucketTable().get(bucketKey); + seekKeyInDB = omBucketInfo.getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = omBucketInfo.getObjectID(); + } + } else { + // startKey will be used in iterator seek and sets the beginning point + // for key traversal. + // key name will be used as parent ID where the user has requested to + // list the keys from. + OzoneFileStatus fileStatusInfo = getOzoneFileStatusV1(volumeName, + bucketName, startKey, false, null); Review comment: startKey can be a non-existed key here. We cannot just reuse getOzoneFileStatusV1 to find the OzoneFileStatus. getOzoneFileStatusV1 needs the key existed then it has the result. Example, key list: /a/a /a/c /a/d If given startkey: /a/b, here should return /a/c ########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java ########## @@ -2205,6 +2272,167 @@ private void listStatusFindKeyInTableCache( return fileStatusList; } + public List<OzoneFileStatus> listStatusV1(OmKeyArgs args, boolean recursive, + String startKey, long numEntries, String clientAddress) + throws IOException { + Preconditions.checkNotNull(args, "Key args can not be null"); + + List<OzoneFileStatus> fileStatusList = new ArrayList<>(); + if (numEntries <= 0) { + return fileStatusList; + } + + String volumeName = args.getVolumeName(); + String bucketName = args.getBucketName(); + String keyName = args.getKeyName(); + // A map sorted by OmKey to combine results from TableCache and DB. + TreeMap<String, OzoneFileStatus> cacheKeyMap = new TreeMap<>(); + String seekKeyInDB = ""; + long prefixKeyInDB = Long.MIN_VALUE; + String prefixPath = keyName; + + metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName, + bucketName); + try { + if (Strings.isNullOrEmpty(startKey)) { + OzoneFileStatus fileStatus = getFileStatus(args, clientAddress); + if (fileStatus.isFile()) { + return Collections.singletonList(fileStatus); + } + + // keyName is a directory + if (fileStatus.getKeyInfo() != null) { + seekKeyInDB = fileStatus.getKeyInfo().getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = fileStatus.getKeyInfo().getObjectID(); + } else { + String bucketKey = metadataManager.getBucketKey(volumeName, + bucketName); + OmBucketInfo omBucketInfo = + metadataManager.getBucketTable().get(bucketKey); + seekKeyInDB = omBucketInfo.getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = omBucketInfo.getObjectID(); + } + } else { + // startKey will be used in iterator seek and sets the beginning point + // for key traversal. + // key name will be used as parent ID where the user has requested to + // list the keys from. + OzoneFileStatus fileStatusInfo = getOzoneFileStatusV1(volumeName, + bucketName, startKey, false, null); + if (fileStatusInfo != null) { + prefixKeyInDB = fileStatusInfo.getKeyInfo().getParentObjectID(); + seekKeyInDB = prefixKeyInDB + OZONE_URI_DELIMITER + + fileStatusInfo.getKeyInfo().getFileName(); Review comment: We should reset prefixPath after we find the ozone dir info to list. ########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java ########## @@ -2205,6 +2272,167 @@ private void listStatusFindKeyInTableCache( return fileStatusList; } + public List<OzoneFileStatus> listStatusV1(OmKeyArgs args, boolean recursive, + String startKey, long numEntries, String clientAddress) + throws IOException { + Preconditions.checkNotNull(args, "Key args can not be null"); + + List<OzoneFileStatus> fileStatusList = new ArrayList<>(); + if (numEntries <= 0) { + return fileStatusList; + } + + String volumeName = args.getVolumeName(); + String bucketName = args.getBucketName(); + String keyName = args.getKeyName(); + // A map sorted by OmKey to combine results from TableCache and DB. + TreeMap<String, OzoneFileStatus> cacheKeyMap = new TreeMap<>(); + String seekKeyInDB = ""; + long prefixKeyInDB = Long.MIN_VALUE; + String prefixPath = keyName; + + metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName, + bucketName); + try { + if (Strings.isNullOrEmpty(startKey)) { + OzoneFileStatus fileStatus = getFileStatus(args, clientAddress); + if (fileStatus.isFile()) { + return Collections.singletonList(fileStatus); + } + + // keyName is a directory + if (fileStatus.getKeyInfo() != null) { + seekKeyInDB = fileStatus.getKeyInfo().getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = fileStatus.getKeyInfo().getObjectID(); + } else { + String bucketKey = metadataManager.getBucketKey(volumeName, + bucketName); + OmBucketInfo omBucketInfo = + metadataManager.getBucketTable().get(bucketKey); + seekKeyInDB = omBucketInfo.getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = omBucketInfo.getObjectID(); Review comment: Should reset prefixPath to bucketKey I think. ########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/file/OMFileRequest.java ########## @@ -583,4 +588,112 @@ public static OmKeyInfo getOmKeyInfoFromFileTable(boolean openFileTable, return dbOmKeyInfo; } + /** + * Gets OmKeyInfo if exists for the given key name in the DB. + * + * @param omMetadataMgr metadata manager + * @param volumeName volume name + * @param bucketName bucket name + * @param keyName key name + * @param scmBlockSize scm block size + * @return OzoneFileStatus + * @throws IOException DB failure + */ + @Nullable + public static OzoneFileStatus getOMKeyInfoIfExists( + OMMetadataManager omMetadataMgr, String volumeName, String bucketName, + String keyName, long scmBlockSize) throws IOException { + + Path keyPath = Paths.get(keyName); + Iterator<Path> elements = keyPath.iterator(); + String bucketKey = omMetadataMgr.getBucketKey(volumeName, bucketName); + OmBucketInfo omBucketInfo = + omMetadataMgr.getBucketTable().get(bucketKey); + + long lastKnownParentId = omBucketInfo.getObjectID(); + OmDirectoryInfo omDirInfo = null; + while (elements.hasNext()) { + String fileName = elements.next().toString(); + + // For example, /vol1/buck1/a/b/c/d/e/file1.txt + // 1. Do lookup path component on directoryTable starting from bucket + // 'buck1' to the leaf node component, which is 'file1.txt'. + // 2. If there is no dir exists for the leaf node component 'file1.txt' + // then do look it on fileTable. + String dbNodeName = omMetadataMgr.getOzonePathKey( + lastKnownParentId, fileName); + omDirInfo = omMetadataMgr.getDirectoryTable().get(dbNodeName); + + if (omDirInfo != null) { + lastKnownParentId = omDirInfo.getObjectID(); + } else if (!elements.hasNext()) { + // reached last path component. Check file exists for the given path. + OmKeyInfo omKeyInfo = OMFileRequest.getOmKeyInfoFromFileTable(false, + omMetadataMgr, dbNodeName, keyName); + if (omKeyInfo != null) { + return new OzoneFileStatus(omKeyInfo, scmBlockSize, false); + } + } else { + // Missing intermediate directory and just return null; + // key not found in DB + return null; + } + } + + if (omDirInfo != null) { + OmKeyInfo omKeyInfo = getOmKeyInfo(volumeName, bucketName, omDirInfo, + keyName); + return new OzoneFileStatus(omKeyInfo, scmBlockSize, true); + } + + // key not found in DB + return null; + } + + /** + * Prepare OmKeyInfo from OmDirectoryInfo. + * + * @param volumeName volume name + * @param bucketName bucket name + * @param dirInfo directory info + * @param keyName usewr given key name Review comment: Typo: usewr -> user ########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java ########## @@ -2205,6 +2272,167 @@ private void listStatusFindKeyInTableCache( return fileStatusList; } + public List<OzoneFileStatus> listStatusV1(OmKeyArgs args, boolean recursive, + String startKey, long numEntries, String clientAddress) + throws IOException { + Preconditions.checkNotNull(args, "Key args can not be null"); + + List<OzoneFileStatus> fileStatusList = new ArrayList<>(); + if (numEntries <= 0) { + return fileStatusList; + } + + String volumeName = args.getVolumeName(); + String bucketName = args.getBucketName(); + String keyName = args.getKeyName(); + // A map sorted by OmKey to combine results from TableCache and DB. Review comment: Update the comment here, actually no results get from TableCache. ########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java ########## @@ -2205,6 +2272,167 @@ private void listStatusFindKeyInTableCache( return fileStatusList; } + public List<OzoneFileStatus> listStatusV1(OmKeyArgs args, boolean recursive, + String startKey, long numEntries, String clientAddress) + throws IOException { + Preconditions.checkNotNull(args, "Key args can not be null"); + + List<OzoneFileStatus> fileStatusList = new ArrayList<>(); + if (numEntries <= 0) { + return fileStatusList; + } + + String volumeName = args.getVolumeName(); + String bucketName = args.getBucketName(); + String keyName = args.getKeyName(); + // A map sorted by OmKey to combine results from TableCache and DB. + TreeMap<String, OzoneFileStatus> cacheKeyMap = new TreeMap<>(); + String seekKeyInDB = ""; + long prefixKeyInDB = Long.MIN_VALUE; + String prefixPath = keyName; + + metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName, + bucketName); + try { + if (Strings.isNullOrEmpty(startKey)) { + OzoneFileStatus fileStatus = getFileStatus(args, clientAddress); + if (fileStatus.isFile()) { + return Collections.singletonList(fileStatus); + } + + // keyName is a directory + if (fileStatus.getKeyInfo() != null) { + seekKeyInDB = fileStatus.getKeyInfo().getObjectID() + + OZONE_URI_DELIMITER; Review comment: Can we reuse an existed method OzoneFSUtils#addTrailingSlashIfNeeded(keyName) instead of? ########## File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java ########## @@ -249,12 +273,10 @@ public void tearDown() { } } - private void setupOzoneFileSystem() + protected void setupOzoneFileSystem() throws IOException, TimeoutException, InterruptedException { - OzoneConfiguration conf = new OzoneConfiguration(); - conf.setInt(FS_TRASH_INTERVAL_KEY, 1); - conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, - enabledFileSystemPaths); + OzoneConfiguration conf = getOzoneConfig(); + //conf.set(OMConfigKeys.OZONE_OM_LAYOUT_VERSION, "V1"); Review comment: Can we remove this unused line. ########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java ########## @@ -2205,6 +2272,167 @@ private void listStatusFindKeyInTableCache( return fileStatusList; } + public List<OzoneFileStatus> listStatusV1(OmKeyArgs args, boolean recursive, + String startKey, long numEntries, String clientAddress) + throws IOException { + Preconditions.checkNotNull(args, "Key args can not be null"); + + List<OzoneFileStatus> fileStatusList = new ArrayList<>(); + if (numEntries <= 0) { + return fileStatusList; + } + + String volumeName = args.getVolumeName(); + String bucketName = args.getBucketName(); + String keyName = args.getKeyName(); + // A map sorted by OmKey to combine results from TableCache and DB. + TreeMap<String, OzoneFileStatus> cacheKeyMap = new TreeMap<>(); + String seekKeyInDB = ""; + long prefixKeyInDB = Long.MIN_VALUE; + String prefixPath = keyName; + + metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName, + bucketName); + try { + if (Strings.isNullOrEmpty(startKey)) { + OzoneFileStatus fileStatus = getFileStatus(args, clientAddress); + if (fileStatus.isFile()) { + return Collections.singletonList(fileStatus); + } + + // keyName is a directory + if (fileStatus.getKeyInfo() != null) { + seekKeyInDB = fileStatus.getKeyInfo().getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = fileStatus.getKeyInfo().getObjectID(); + } else { + String bucketKey = metadataManager.getBucketKey(volumeName, + bucketName); + OmBucketInfo omBucketInfo = + metadataManager.getBucketTable().get(bucketKey); + seekKeyInDB = omBucketInfo.getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = omBucketInfo.getObjectID(); + } + } else { + // startKey will be used in iterator seek and sets the beginning point + // for key traversal. + // key name will be used as parent ID where the user has requested to + // list the keys from. + OzoneFileStatus fileStatusInfo = getOzoneFileStatusV1(volumeName, + bucketName, startKey, false, null); + if (fileStatusInfo != null) { + prefixKeyInDB = fileStatusInfo.getKeyInfo().getParentObjectID(); + seekKeyInDB = prefixKeyInDB + OZONE_URI_DELIMITER + + fileStatusInfo.getKeyInfo().getFileName(); + } + } + + // Not required to search in TableCache because all the deleted keys + // are marked directly in directory table or in key table by breaking + // the pointer to its sub-dirs. So, there is no issue of inconsistency. + int countEntries = 0; + // Seek the given key in key table. + countEntries = getFilesFromDirectory(cacheKeyMap, seekKeyInDB, + prefixPath, countEntries, numEntries, prefixKeyInDB); + // Seek the given key in dir table. + Table dirTable = metadataManager.getDirectoryTable(); + TableIterator<String, ? extends Table.KeyValue<String, OmDirectoryInfo>> + iterator = dirTable.iterator(); + + iterator.seek(seekKeyInDB); + + while (iterator.hasNext() && numEntries - countEntries > 0) { + String entryInDb = iterator.key(); + OmDirectoryInfo dirInfo = iterator.value().getValue(); + if (!isImmediateChild(dirInfo.getParentObjectID(), prefixKeyInDB)) { + break; + } + + if (recursive) { + // for recursive list all the entries + prefixPath = OMFileRequest.getAbsolutePath(prefixPath, + dirInfo.getName()); + OmKeyInfo omKeyInfo = OMFileRequest.getOmKeyInfo(volumeName, + bucketName, dirInfo, prefixPath); + cacheKeyMap.put(entryInDb, + new OzoneFileStatus(omKeyInfo, 0, true)); + ++countEntries; + // files from this directory + seekKeyInDB = dirInfo.getObjectID() + OZONE_URI_DELIMITER; Review comment: prefixKeyInDB should also updated to new dir objectID dirInfo.getObjectID() ########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java ########## @@ -2205,6 +2272,167 @@ private void listStatusFindKeyInTableCache( return fileStatusList; } + public List<OzoneFileStatus> listStatusV1(OmKeyArgs args, boolean recursive, + String startKey, long numEntries, String clientAddress) + throws IOException { + Preconditions.checkNotNull(args, "Key args can not be null"); + + List<OzoneFileStatus> fileStatusList = new ArrayList<>(); + if (numEntries <= 0) { + return fileStatusList; + } + + String volumeName = args.getVolumeName(); + String bucketName = args.getBucketName(); + String keyName = args.getKeyName(); + // A map sorted by OmKey to combine results from TableCache and DB. + TreeMap<String, OzoneFileStatus> cacheKeyMap = new TreeMap<>(); + String seekKeyInDB = ""; + long prefixKeyInDB = Long.MIN_VALUE; + String prefixPath = keyName; + + metadataManager.getLock().acquireReadLock(BUCKET_LOCK, volumeName, + bucketName); + try { + if (Strings.isNullOrEmpty(startKey)) { + OzoneFileStatus fileStatus = getFileStatus(args, clientAddress); + if (fileStatus.isFile()) { + return Collections.singletonList(fileStatus); + } + + // keyName is a directory + if (fileStatus.getKeyInfo() != null) { + seekKeyInDB = fileStatus.getKeyInfo().getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = fileStatus.getKeyInfo().getObjectID(); + } else { + String bucketKey = metadataManager.getBucketKey(volumeName, + bucketName); + OmBucketInfo omBucketInfo = + metadataManager.getBucketTable().get(bucketKey); + seekKeyInDB = omBucketInfo.getObjectID() + + OZONE_URI_DELIMITER; + prefixKeyInDB = omBucketInfo.getObjectID(); + } + } else { + // startKey will be used in iterator seek and sets the beginning point + // for key traversal. + // key name will be used as parent ID where the user has requested to + // list the keys from. + OzoneFileStatus fileStatusInfo = getOzoneFileStatusV1(volumeName, + bucketName, startKey, false, null); + if (fileStatusInfo != null) { + prefixKeyInDB = fileStatusInfo.getKeyInfo().getParentObjectID(); + seekKeyInDB = prefixKeyInDB + OZONE_URI_DELIMITER + + fileStatusInfo.getKeyInfo().getFileName(); + } + } + + // Not required to search in TableCache because all the deleted keys + // are marked directly in directory table or in key table by breaking + // the pointer to its sub-dirs. So, there is no issue of inconsistency. + int countEntries = 0; + // Seek the given key in key table. + countEntries = getFilesFromDirectory(cacheKeyMap, seekKeyInDB, + prefixPath, countEntries, numEntries, prefixKeyInDB); + // Seek the given key in dir table. + Table dirTable = metadataManager.getDirectoryTable(); + TableIterator<String, ? extends Table.KeyValue<String, OmDirectoryInfo>> + iterator = dirTable.iterator(); + + iterator.seek(seekKeyInDB); + + while (iterator.hasNext() && numEntries - countEntries > 0) { + String entryInDb = iterator.key(); + OmDirectoryInfo dirInfo = iterator.value().getValue(); + if (!isImmediateChild(dirInfo.getParentObjectID(), prefixKeyInDB)) { + break; + } + + if (recursive) { + // for recursive list all the entries + prefixPath = OMFileRequest.getAbsolutePath(prefixPath, + dirInfo.getName()); + OmKeyInfo omKeyInfo = OMFileRequest.getOmKeyInfo(volumeName, + bucketName, dirInfo, prefixPath); + cacheKeyMap.put(entryInDb, + new OzoneFileStatus(omKeyInfo, 0, true)); + ++countEntries; + // files from this directory + seekKeyInDB = dirInfo.getObjectID() + OZONE_URI_DELIMITER; + countEntries = getFilesFromDirectory(cacheKeyMap, seekKeyInDB, + prefixPath, countEntries, numEntries, prefixKeyInDB); + } else { + String dirName = OMFileRequest.getAbsolutePath(prefixPath, + dirInfo.getName()); + OmKeyInfo omKeyInfo = OMFileRequest.getOmKeyInfo(volumeName, + bucketName, dirInfo, dirName); + cacheKeyMap.put(entryInDb, + new OzoneFileStatus(omKeyInfo, 0, true)); + countEntries++; + } + // move to next entry in the table + iterator.next(); + } + } finally { + metadataManager.getLock().releaseReadLock(BUCKET_LOCK, volumeName, + bucketName); + } + + int countEntries = 0; + // Convert results in cacheKeyMap to List + for (Map.Entry<String, OzoneFileStatus> entry : cacheKeyMap.entrySet()) { + // No need to check if a key is deleted or not here, this is handled + // when adding entries to cacheKeyMap from DB. + if (args.getRefreshPipeline()) { + refreshPipeline(entry.getValue().getKeyInfo()); + } + fileStatusList.add(entry.getValue()); + if (args.getSortDatanodes()) { + sortDatanodeInPipeline(entry.getValue().getKeyInfo(), clientAddress); + } + countEntries++; + if (countEntries >= numEntries) { + break; + } + } + // Clean up temp map and set + cacheKeyMap.clear(); + + return fileStatusList; + } + + private int getFilesFromDirectory(Map<String, OzoneFileStatus> cacheKeyMap, + String seekKeyInDB, String prefixKeyPath, int countEntries, + long numEntries, long prefixKeyInDB) throws IOException { + + Table<String, OmKeyInfo> keyTable = metadataManager.getKeyTable(); + TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>> + iterator = keyTable.iterator(); + iterator.seek(seekKeyInDB); + while (iterator.hasNext() && numEntries - countEntries > 0) { + String entryInDb = iterator.key(); + OmKeyInfo keyInfo = iterator.value().getValue(); + + if (!isImmediateChild(keyInfo.getParentObjectID(), prefixKeyInDB)) { + break; + } + + keyInfo.setFileName(keyInfo.getKeyName()); + String fullKeyPath = OMFileRequest.getAbsolutePath(prefixKeyPath, + keyInfo.getKeyName()); + keyInfo.setKeyName(fullKeyPath); + cacheKeyMap.put(entryInDb, new OzoneFileStatus(keyInfo, 0, false)); Review comment: We need to pass scmBlockSize as well: OzoneFileStatus(keyInfo, 0, false) -> OzoneFileStatus(keyInfo, scmBlockSize, false) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org