Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion hadoop-hdds/docs/content/feature/PrefixFSO.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Following picture describes the OM metadata changes while performing a rename

The following configuration can be configured in `ozone-site.xml` to define the default value for bucket layout during bucket creation
if the client has not specified the bucket layout argument.
Supported values are `OBJECT_STORE` and `FILE_SYSTEM_OPTIMIZED`.
Supported values are `OBJECT_STORE`, `FILE_SYSTEM_OPTIMIZED` and `LEGACY`.

By default, this config value is empty. Ozone will default to `LEGACY` bucket layout if it finds an empty config value.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1088,4 +1088,38 @@ public void testListVolumeBucketKeyShouldPrintValidJsonArray()
testVolumes.forEach(vol -> execute(ozoneShell, new String[] {
"volume", "delete", vol}));
}

@Test
public void testClientBucketLayoutValidation() {
String volName = "/vol-" + UUID.randomUUID();
String[] args =
new String[]{"volume", "create", "o3://" + omServiceId + volName};
execute(ozoneShell, args);

args = new String[]{
"bucket", "create", "o3://" + omServiceId + volName + "/buck-1",
"--layout", ""
};
try {
execute(ozoneShell, args);
Assert.fail("Should throw exception on unsupported bucket layouts!");
} catch (Exception e) {
GenericTestUtils.assertExceptionContains(
"expected one of [FILE_SYSTEM_OPTIMIZED, OBJECT_STORE, LEGACY] ",
e);
}

args = new String[]{
"bucket", "create", "o3://" + omServiceId + volName + "/buck-2",
"--layout", "INVALID"
};
try {
execute(ozoneShell, args);
Assert.fail("Should throw exception on unsupported bucket layouts!");
} catch (Exception e) {
GenericTestUtils.assertExceptionContains(
"expected one of [FILE_SYSTEM_OPTIMIZED, OBJECT_STORE, LEGACY] ",
e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,10 @@ public class CreateBucketHandler extends BucketHandler {
" user if not specified")
private String ownerName;

enum AllowedBucketLayouts {
FILE_SYSTEM_OPTIMIZED("FILE_SYSTEM_OPTIMIZED"),
OBJECT_STORE("OBJECT_STORE"),
DEFAULT("");

// Assigning a value to each enum
private final String layout;
AllowedBucketLayouts(String layout) {
this.layout = layout;
}

// Overriding toString() method to return the value passed to the
// constructor.
@Override
public String toString() {
return this.layout;
}
}
enum AllowedBucketLayouts { FILE_SYSTEM_OPTIMIZED, OBJECT_STORE, LEGACY }

@Option(names = { "--layout", "-l" },
description = "Allowed Bucket Layouts: ${COMPLETION-CANDIDATES}",
defaultValue = "")
description = "Allowed Bucket Layouts: ${COMPLETION-CANDIDATES}")
private AllowedBucketLayouts allowedBucketLayout;

@CommandLine.Mixin
Expand All @@ -100,12 +82,14 @@ public void execute(OzoneClient client, OzoneAddress address)
ownerName = UserGroupInformation.getCurrentUser().getShortUserName();
}

BucketArgs.Builder bb;
BucketLayout bucketLayout =
BucketLayout.fromString(allowedBucketLayout.toString());
bb = new BucketArgs.Builder().setStorageType(StorageType.DEFAULT)
.setVersioning(false).setBucketLayout(bucketLayout)
.setOwner(ownerName);
BucketArgs.Builder bb =
new BucketArgs.Builder().setStorageType(StorageType.DEFAULT)
.setVersioning(false).setOwner(ownerName);
if (allowedBucketLayout != null) {
BucketLayout bucketLayout =
BucketLayout.fromString(allowedBucketLayout.toString());
bb.setBucketLayout(bucketLayout);
}
// TODO: New Client talking to old server, will it create a LEGACY bucket?

if (isGdprEnforced != null) {
Expand Down