This is an automated email from the ASF dual-hosted git repository. siyao pushed a commit to branch HDDS-2665-ofs in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git
commit b9dac41380617e1c680da2eb789857a64274ad6b Author: Siyao Meng <[email protected]> AuthorDate: Wed Jun 3 10:13:28 2020 -0700 HDDS-3709. Rebase OFS branch - 3. Adapt to HDDS-3501 (#1015) --- .../ozone/BasicRootedOzoneClientAdapterImpl.java | 48 ++++++++-------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java index 171937e..3c85906 100644 --- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java +++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java @@ -34,7 +34,6 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.crypto.key.KeyProvider; import org.apache.hadoop.fs.BlockLocation; import org.apache.hadoop.fs.FileAlreadyExistsException; -import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdds.client.ReplicationFactor; @@ -481,10 +480,8 @@ public class BasicRootedOzoneClientAdapterImpl try { OzoneBucket bucket = getBucket(ofsPath, false); OzoneFileStatus status = bucket.getFileStatus(key); - // Note: qualifiedPath passed in is good from - // BasicRootedOzoneFileSystem#getFileStatus. No need to prepend here. - makeQualified(status, uri, qualifiedPath, userName); - return toFileStatusAdapter(status); + return toFileStatusAdapter(status, userName, uri, qualifiedPath, + ofsPath.getNonKeyPath()); } catch (OMException e) { if (e.getResult() == OMException.ResultCodes.FILE_NOT_FOUND) { throw new FileNotFoundException(key + ": No such file or directory!"); @@ -495,15 +492,6 @@ public class BasicRootedOzoneClientAdapterImpl } } - public void makeQualified(FileStatus status, URI uri, Path path, - String username) { - if (status instanceof OzoneFileStatus) { - ((OzoneFileStatus) status) - .makeQualified(uri, path, - username, username); - } - } - @Override public Iterator<BasicKeyInfo> listKeys(String pathStr) { incrementCounter(Statistic.OBJECTS_LIST); @@ -634,12 +622,8 @@ public class BasicRootedOzoneClientAdapterImpl List<FileStatusAdapter> result = new ArrayList<>(); for (OzoneFileStatus status : statuses) { - // Get raw path (without volume and bucket name) and remove leading '/' - String rawPath = status.getPath().toString().substring(1); - Path appendedPath = new Path(ofsPathPrefix, rawPath); - Path qualifiedPath = appendedPath.makeQualified(uri, workingDir); - makeQualified(status, uri, qualifiedPath, username); - result.add(toFileStatusAdapter(status)); + result.add(toFileStatusAdapter(status, username, uri, workingDir, + ofsPathPrefix)); } return result; } catch (OMException e) { @@ -762,19 +746,23 @@ public class BasicRootedOzoneClientAdapterImpl } } - private FileStatusAdapter toFileStatusAdapter(OzoneFileStatus status) { + private FileStatusAdapter toFileStatusAdapter(OzoneFileStatus status, + String owner, URI defaultUri, Path workingDir, String ofsPathPrefix) { + OmKeyInfo keyInfo = status.getKeyInfo(); + short replication = (short) keyInfo.getFactor().getNumber(); return new FileStatusAdapter( - status.getLen(), - status.getPath(), + keyInfo.getDataSize(), + new Path(ofsPathPrefix + OZONE_URI_DELIMITER + keyInfo.getKeyName()) + .makeQualified(defaultUri, workingDir), status.isDirectory(), - status.getReplication(), + replication, status.getBlockSize(), - status.getModificationTime(), - status.getAccessTime(), - status.getPermission().toShort(), - status.getOwner(), - status.getGroup(), - status.getPath(), + keyInfo.getModificationTime(), + keyInfo.getModificationTime(), + status.isDirectory() ? (short) 00777 : (short) 00666, + owner, + owner, + null, getBlockLocations(status) ); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
