kerneltime commented on code in PR #6990:
URL: https://github.com/apache/ozone/pull/6990#discussion_r1692549146
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java:
##########
@@ -496,24 +496,30 @@ public boolean createDirectory(String pathStr) throws
IOException {
LOG.trace("creating dir for path: {}", pathStr);
incrementCounter(Statistic.OBJECTS_CREATED, 1);
OFSPath ofsPath = new OFSPath(pathStr, config);
- if (ofsPath.getVolumeName().isEmpty()) {
+
+ String volumeName = ofsPath.getVolumeName();
+ if (volumeName.isEmpty()) {
// Volume name unspecified, invalid param, return failure
return false;
}
- if (ofsPath.getBucketName().isEmpty()) {
+
+ String bucketName = ofsPath.getBucketName();
+ if (bucketName.isEmpty()) {
// Create volume only
- objectStore.createVolume(ofsPath.getVolumeName());
+ objectStore.createVolume(volumeName);
return true;
}
+
String keyStr = ofsPath.getKeyName();
try {
- OzoneBucket bucket = getBucket(ofsPath, true);
- // Empty keyStr here indicates only volume and bucket is
- // given in pathStr, so getBucket above should handle the creation
- // of volume and bucket. We won't feed empty keyStr to
- // bucket.createDirectory as that would be a NPE.
- if (keyStr != null && keyStr.length() > 0) {
- bucket.createDirectory(keyStr);
+ if (keyStr == null || keyStr.isEmpty()) {
+ // Empty keyStr here indicates only volume and bucket is
+ // given in pathStr, so getBucket above should handle the creation
+ // of volume and bucket. We won't feed empty keyStr to
+ // bucket.createDirectory as that would be a NPE.
+ getBucket(volumeName, bucketName, true);
+ } else {
+ proxy.createDirectory(volumeName, bucketName, keyStr);
Review Comment:
Is this code expected to create both the bucket and the path? The code
before would issue a redundant get bucket info if the bucket was already there
but the new code will fail if the bucket is not present?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]