Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ public Void call() throws Exception {
if (duResponse.get("status").equals("PATH_NOT_FOUND")) {
printPathNotFound();
} else {
if (parent.isObjectStoreBucket(path) ||
!parent.bucketIsPresentInThePath(path)) {
if (parent.isOBSBucketOrNotPresentInPath(path)) {
printBucketReminder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public Void call() throws Exception {
} else if (distResponse.get("status").equals("TYPE_NOT_APPLICABLE")) {
printTypeNA("File Size Distribution");
} else {
if (parent.isObjectStoreBucket(path) ||
!parent.bucketIsPresentInThePath(path)) {
if (parent.isOBSBucketOrNotPresentInPath(path)) {
printBucketReminder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,86 +86,52 @@ public Class<?> getParentType() {
return OzoneAdmin.class;
}

public boolean isFileSystemOptimizedBucket(String path) throws IOException {
OFSPath ofsPath = new OFSPath(path,
OzoneConfiguration.of(getOzoneConfig()));

OzoneClient ozoneClient = OzoneClientFactory.getRpcClient(getOzoneConfig());
ObjectStore objectStore = ozoneClient.getObjectStore();

try {
OzoneBucket bucket = objectStore.getVolume(ofsPath.getVolumeName())
.getBucket(ofsPath.getBucketName());

// Resolve the bucket layout in case this is a Link Bucket.
BucketLayout resolvedBucketLayout =
OzoneClientUtils.resolveLinkBucketLayout(bucket, objectStore,
new HashSet<>());

return resolvedBucketLayout.isFileSystemOptimized();
} catch (IOException e) {
System.out.println(
"Bucket layout couldn't be verified for path: " + ofsPath +
". Exception: " + e);
return false;
}
}

public boolean isObjectStoreBucket(String path) throws IOException {
OFSPath ofsPath = new OFSPath(path,
OzoneConfiguration.of(getOzoneConfig()));

private boolean isObjectStoreBucket(OzoneBucket bucket, ObjectStore objectStore) {
boolean enableFileSystemPaths = getOzoneConfig()
.getBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS_DEFAULT);

OzoneClient ozoneClient = OzoneClientFactory.getRpcClient(getOzoneConfig());
ObjectStore objectStore = ozoneClient.getObjectStore();

try {
OzoneBucket bucket = objectStore.getVolume(ofsPath.getVolumeName())
.getBucket(ofsPath.getBucketName());

// Resolve the bucket layout in case this is a Link Bucket.
BucketLayout resolvedBucketLayout =
OzoneClientUtils.resolveLinkBucketLayout(bucket, objectStore,
new HashSet<>());

return resolvedBucketLayout.isObjectStore(enableFileSystemPaths);
} catch (IOException e) {
System.out.println(
"Bucket layout couldn't be verified for path: " + ofsPath +
". Exception: " + e);
"Bucket layout couldn't be resolved. Exception thrown: " + e);
return false;
}
}

/**
* Checking if the bucket is part of the path.
* Checks if bucket is OBS bucket or if bucket is part of the path.
* Return false if path is root, just a volume or invalid.
* Returns false if bucket is part of path but not a OBS bucket.
* @param path
* @return true if the bucket
* is not part of the given path.
* @return true if bucket is OBS bucket or not part of provided path.
* @throws IOException
*/
public boolean bucketIsPresentInThePath(String path) throws IOException {
public boolean isOBSBucketOrNotPresentInPath(String path) throws IOException {
Comment thread
adoroszlai marked this conversation as resolved.
Outdated
OFSPath ofsPath = new OFSPath(path,
OzoneConfiguration.of(getOzoneConfig()));

OzoneClient ozoneClient = OzoneClientFactory.getRpcClient(getOzoneConfig());
ObjectStore objectStore = ozoneClient.getObjectStore();

OzoneBucket bucket;
Comment thread
adoroszlai marked this conversation as resolved.
Outdated
try {
OzoneBucket bucket = objectStore.getVolume(ofsPath.getVolumeName())
// Checks if the bucket is part of the path.
bucket = objectStore.getVolume(ofsPath.getVolumeName())
.getBucket(ofsPath.getBucketName());

return Objects.nonNull(bucket);
} catch (IOException e) {
System.out.println(
"Bucket layout couldn't be verified for path: " + ofsPath +
". Exception: " + e);
return false;
bucket = null;
} finally {
ozoneClient.close();
}
boolean isOBSBucket = bucket != null ? isObjectStoreBucket(bucket, objectStore) : false;
return isOBSBucket || !Objects.nonNull(bucket);
Comment thread
adoroszlai marked this conversation as resolved.
Outdated
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public Void call() throws Exception {
} else if (quotaResponse.get("status").equals("TYPE_NOT_APPLICABLE")) {
printTypeNA("Quota");
} else {
if (parent.isObjectStoreBucket(path) ||
!parent.bucketIsPresentInThePath(path)) {
if (parent.isOBSBucketOrNotPresentInPath(path)) {
printBucketReminder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public Void call() throws Exception {
if (summaryResponse.get("status").equals("PATH_NOT_FOUND")) {
printPathNotFound();
} else {
if (parent.isObjectStoreBucket(path) ||
!parent.bucketIsPresentInThePath(path)) {
if (parent.isOBSBucketOrNotPresentInPath(path)) {
printBucketReminder();
}

Expand Down