Skip to content

Commit

Permalink
HDDS-4727. [FSO]OMConfig: Modify 'ozone.om.layout.version' config (#2118
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sadanand48 authored and rakeshadr committed Apr 8, 2021
1 parent 9ecfafe commit bd22405
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 67 deletions.
13 changes: 8 additions & 5 deletions hadoop-hdds/common/src/main/resources/ozone-default.xml
Expand Up @@ -2771,12 +2771,15 @@
</property>

<property>
<name>ozone.om.layout.version</name>
<name>ozone.om.metadata.layout</name>
<tag>OZONE, OM</tag>
<value>V0</value>
<description>Temporary workaround for OM upgrade and will be replaced once
upgrade HDDS-3698 story reaches consensus. Defaulting to 'V0' so that
existing unit test cases won't be affected. New OM version should be 'V1'
<value>LEGACY</value>
<description>
This property is used to define the metadata layout of file system
paths. If it is configured as PREFIX in combination with
ozone.om.enable.filesystem.paths to true then this allows to perform
atomic rename and delete of any directory at any level in the namespace.
Defaulting to LEGACY. Supported values: LEGACY and PREFIX.
</description>
</property>
<property>
Expand Down
Expand Up @@ -245,14 +245,17 @@ private OMConfigKeys() {

public static final long OZONE_FS_TRASH_CHECKPOINT_INTERVAL_DEFAULT = 0;

// TODO: Temporary workaround for OM upgrade path and will be replaced once
// upgrade HDDS-3698 story reaches consensus. Defaulting to 'V0' so that
// existing unit test cases won't be affected. New OM version should be 'V1'.
public static final String OZONE_OM_LAYOUT_VERSION =
"ozone.om.layout.version";
public static final String OZONE_OM_LAYOUT_VERSION_DEFAULT = "V0";

public static final String OZONE_OM_LAYOUT_VERSION_V1 = "V1";
// This property is used to define the metadata layout of file system
// paths. If it is configured as PREFIX in combination with
// ozone.om.enable.filesystem.paths to true then this allows to perform
// atomic rename and delete of any directory at any level in the namespace.
// Defaulting to LEGACY. Supported values: LEGACY and PREFIX.

public static final String OZONE_OM_METADATA_LAYOUT =
"ozone.om.metadata.layout";
public static final String OZONE_OM_METADATA_LAYOUT_DEFAULT = "LEGACY";

public static final String OZONE_OM_METADATA_LAYOUT_PREFIX = "PREFIX";

/**
* Configuration properties for Directory Deleting Service.
Expand Down
Expand Up @@ -216,18 +216,18 @@ public static int getFileCount(String keyName) {
*/
public static boolean isFSOptimizedBucket(
Map<String, String> bucketMetadata) {
// layout version V1 represents optimized FS path
boolean layoutVersionEnabled =
// layout 'PREFIX' represents optimized FS path
boolean metadataLayoutEnabled =
org.apache.commons.lang3.StringUtils.equalsIgnoreCase(
OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1,
OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX,
bucketMetadata
.get(OMConfigKeys.OZONE_OM_LAYOUT_VERSION));
.get(OMConfigKeys.OZONE_OM_METADATA_LAYOUT));

boolean fsEnabled =
Boolean.parseBoolean(bucketMetadata
.get(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS));

return layoutVersionEnabled && fsEnabled;
return metadataLayoutEnabled && fsEnabled;
}

public static String removeTrailingSlashIfNeeded(String key) {
Expand Down
14 changes: 7 additions & 7 deletions hadoop-ozone/dist/src/main/compose/ozone/docker-compose.yaml
Expand Up @@ -26,8 +26,8 @@ x-common-config:
- docker-config

x-layout_version:
&layout_version
OZONE-SITE.XML_ozone.om.layout.version: ${OZONE_OM_LAYOUT_VERSION:-V0}
&metadata_layout
OZONE-SITE.XML_ozone.om.metadata.layout: ${OZONE_OM_METADATA_LAYOUT:-LEGACY}
OZONE-SITE.XML_ozone.om.enable.filesystem.paths: ${OZONE_OM_ENABLE_FILESYSTEM_PATHS:-false}

x-replication:
Expand All @@ -42,7 +42,7 @@ services:
- 9882
environment:
<<: *replication
<<: *layout_version
<<: *metadata_layout
OZONE_OPTS:
command: ["ozone","datanode"]
om:
Expand All @@ -51,7 +51,7 @@ services:
ENSURE_OM_INITIALIZED: /data/metadata/om/current/VERSION
OZONE_OPTS:
<<: *replication
<<: *layout_version
<<: *metadata_layout
ports:
- 9874:9874
- 9862:9862
Expand All @@ -66,14 +66,14 @@ services:
OZONE-SITE.XML_hdds.scm.safemode.min.datanode: ${OZONE_SAFEMODE_MIN_DATANODES:-1}
OZONE_OPTS:
<<: *replication
<<: *layout_version
<<: *metadata_layout
command: ["ozone","scm"]
s3g:
<<: *common-config
environment:
OZONE_OPTS:
<<: *replication
<<: *layout_version
<<: *metadata_layout
ports:
- 9878:9878
command: ["ozone","s3g"]
Expand All @@ -84,5 +84,5 @@ services:
environment:
OZONE_OPTS:
<<: *replication
<<: *layout_version
<<: *metadata_layout
command: ["ozone","recon"]
8 changes: 4 additions & 4 deletions hadoop-ozone/dist/src/main/compose/ozone/test.sh
Expand Up @@ -53,9 +53,9 @@ stop_docker_env

# running FS tests with different config requires restart of the cluster
export OZONE_KEEP_RESULTS=true
export OZONE_OM_LAYOUT_VERSION OZONE_OM_ENABLE_FILESYSTEM_PATHS
for OZONE_OM_LAYOUT_VERSION in V0 V1; do
if [[ $OZONE_OM_LAYOUT_VERSION == "V1" ]]; then
export OZONE_OM_METADATA_LAYOUT OZONE_OM_ENABLE_FILESYSTEM_PATHS
for OZONE_OM_METADATA_LAYOUT in LEGACY PREFIX; do
if [[ $OZONE_OM_METADATA_LAYOUT == "PREFIX" ]]; then
OZONE_OM_ENABLE_FILESYSTEM_PATHS=true
else
OZONE_OM_ENABLE_FILESYSTEM_PATHS=false
Expand All @@ -64,7 +64,7 @@ for OZONE_OM_LAYOUT_VERSION in V0 V1; do
start_docker_env
for scheme in ofs o3fs; do
for bucket in link bucket; do
execute_robot_test scm -v SCHEME:${scheme} -v BUCKET_TYPE:${bucket} -N ozonefs-${OZONE_OM_LAYOUT_VERSION}-${scheme}-${bucket} ozonefs/ozonefs.robot
execute_robot_test scm -v SCHEME:${scheme} -v BUCKET_TYPE:${bucket} -N ozonefs-${OZONE_OM_METADATA_LAYOUT}-${scheme}-${bucket} ozonefs/ozonefs.robot
done
done
stop_docker_env
Expand Down
Expand Up @@ -86,7 +86,7 @@ public static void init() throws Exception {
conf.setBoolean(OZONE_ACL_ENABLED, true);
if (isBucketFSOptimized) {
TestOMRequestUtils.configureFSOptimizedPaths(conf,
enabledFileSystemPaths, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
enabledFileSystemPaths, OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
} else {
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
enabledFileSystemPaths);
Expand Down
Expand Up @@ -151,7 +151,7 @@ private void setupOzoneFileSystem()
OzoneConfiguration conf = new OzoneConfiguration();
conf.setInt(FS_TRASH_INTERVAL_KEY, 1);
TestOMRequestUtils.configureFSOptimizedPaths(conf,
true, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
true, OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
cluster = MiniOzoneCluster.newBuilder(conf)
.setNumDatanodes(3)
.build();
Expand Down
Expand Up @@ -45,8 +45,8 @@ public TestOzoneFileInterfacesV1(boolean setDefaultFs,
@Override
protected OzoneConfiguration getOzoneConfiguration() {
OzoneConfiguration conf = new OzoneConfiguration();
TestOMRequestUtils.configureFSOptimizedPaths(conf,
enableFileSystemPaths, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
TestOMRequestUtils.configureFSOptimizedPaths(conf, enableFileSystemPaths,
OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
return conf;
}

Expand Down
Expand Up @@ -73,7 +73,7 @@ public void setupOzoneFileSystem()
OzoneConfiguration conf = new OzoneConfiguration();
conf.setInt(FS_TRASH_INTERVAL_KEY, 1);
TestOMRequestUtils.configureFSOptimizedPaths(conf,
true, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
true, OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
cluster = MiniOzoneCluster.newBuilder(conf)
.setNumDatanodes(3)
.build();
Expand Down
Expand Up @@ -149,11 +149,11 @@ private void init() throws Exception {
conf.setBoolean(OMConfigKeys.OZONE_OM_RATIS_ENABLE_KEY, omRatisEnabled);
conf.setBoolean(OZONE_ACL_ENABLED, true);
if (isBucketFSOptimized) {
TestOMRequestUtils.configureFSOptimizedPaths(conf,
enabledFileSystemPaths, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
TestOMRequestUtils.configureFSOptimizedPaths(conf, enabledFileSystemPaths,
OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
} else {
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
enabledFileSystemPaths);
enabledFileSystemPaths);
}
cluster = MiniOzoneCluster.newBuilder(conf)
.setNumDatanodes(3)
Expand Down
Expand Up @@ -62,7 +62,7 @@ public void init() throws Exception {
configuration = new OzoneConfiguration();

TestOMRequestUtils.configureFSOptimizedPaths(configuration,
true, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
true, OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);

cluster = MiniOzoneCluster.newBuilder(configuration)
.setNumDatanodes(3)
Expand Down
Expand Up @@ -156,7 +156,7 @@ public static void init() throws Exception {
conf.setBoolean(OMConfigKeys.OZONE_OM_RATIS_ENABLE_KEY, omRatisEnabled);
if (isBucketFSOptimized) {
TestOMRequestUtils.configureFSOptimizedPaths(conf,
true, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
true, OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
} else {
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
enabledFileSystemPaths);
Expand Down
Expand Up @@ -88,8 +88,8 @@ public static void createCluster() throws IOException {
if (fsOptimizedServer){
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
true);
conf.set(OMConfigKeys.OZONE_OM_LAYOUT_VERSION,
OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
conf.set(OMConfigKeys.OZONE_OM_METADATA_LAYOUT,
OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
}

cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(5).build();
Expand Down
Expand Up @@ -106,7 +106,7 @@ public class TestOzoneClientMultipartUploadV1 {
public static void init() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
TestOMRequestUtils.configureFSOptimizedPaths(conf,
true, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
true, OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
startCluster(conf);
}

Expand Down
Expand Up @@ -103,8 +103,8 @@ public TestReadRetries(String layoutVersion) {
@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(
new Object[]{OMConfigKeys.OZONE_OM_LAYOUT_VERSION_DEFAULT},
new Object[]{OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1});
new Object[]{OMConfigKeys.OZONE_OM_METADATA_LAYOUT_DEFAULT },
new Object[]{OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX });
}

/**
Expand Down
Expand Up @@ -28,7 +28,7 @@ public class TestHadoopDirTreeGeneratorV1 extends TestHadoopDirTreeGenerator {
protected OzoneConfiguration getOzoneConfiguration() {
OzoneConfiguration conf = new OzoneConfiguration();
TestOMRequestUtils.configureFSOptimizedPaths(conf,
true, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
true, OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
return conf;
}

Expand Down
Expand Up @@ -102,7 +102,7 @@ public static void init() throws Exception {
scmId = UUID.randomUUID().toString();
omId = UUID.randomUUID().toString();
TestOMRequestUtils.configureFSOptimizedPaths(conf,
true, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
true, OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
cluster = MiniOzoneCluster.newBuilder(conf)
.setClusterId(clusterId)
.setScmId(scmId)
Expand Down
Expand Up @@ -216,9 +216,9 @@
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_HANDLER_COUNT_KEY;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_KERBEROS_KEYTAB_FILE_KEY;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_KERBEROS_PRINCIPAL_KEY;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_LAYOUT_VERSION;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_LAYOUT_VERSION_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_METADATA_LAYOUT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_METADATA_LAYOUT_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_METRICS_SAVE_INTERVAL;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_METRICS_SAVE_INTERVAL_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_USER_MAX_VOLUME;
Expand Down Expand Up @@ -1112,7 +1112,7 @@ public void start() throws IOException {
// TODO: Temporary workaround for OM upgrade path and will be replaced once
// upgrade HDDS-3698 story reaches consensus. Instead of cluster level
// configuration, OM needs to check this property on every bucket level.
getOMLayoutVersion();
getOMMetadataLayout();

metadataManager.start(configuration);
startSecretManagerIfNecessary();
Expand Down Expand Up @@ -3689,16 +3689,16 @@ public boolean getEnableFileSystemPaths() {
OZONE_OM_ENABLE_FILESYSTEM_PATHS_DEFAULT);
}

public String getOMLayoutVersion() {
String version = configuration.getTrimmed(OZONE_OM_LAYOUT_VERSION,
OZONE_OM_LAYOUT_VERSION_DEFAULT);
boolean omLayoutVersionV1 = StringUtils.equalsIgnoreCase(version,
OZONE_OM_LAYOUT_VERSION_V1);
public String getOMMetadataLayout() {
String version = configuration.getTrimmed(OZONE_OM_METADATA_LAYOUT,
OZONE_OM_METADATA_LAYOUT_DEFAULT);
boolean omMetadataLayoutPrefix = StringUtils.equalsIgnoreCase(version,
OZONE_OM_METADATA_LAYOUT_PREFIX);
LOG.info("Configured {}={} and enabled:{} optimized OM FS operations",
OZONE_OM_LAYOUT_VERSION, version, omLayoutVersionV1);
OZONE_OM_METADATA_LAYOUT, version, omMetadataLayoutPrefix);

boolean isBucketFSOptimized =
omLayoutVersionV1 && getEnableFileSystemPaths();
omMetadataLayoutPrefix && getEnableFileSystemPaths();
OzoneManagerRatisUtils.setBucketFSOptimized(isBucketFSOptimized);

return version;
Expand Down
Expand Up @@ -382,9 +382,9 @@ private void addFSOptimizedBucketDetails(OzoneManager ozoneManager,
}
// TODO: Many unit test cases has null config and done a simple null
// check now. It can be done later, to avoid massive test code changes.
if(StringUtils.isNotBlank(ozoneManager.getOMLayoutVersion())){
String layOutVersion = ozoneManager.getOMLayoutVersion();
metadata.put(OMConfigKeys.OZONE_OM_LAYOUT_VERSION, layOutVersion);
if(StringUtils.isNotBlank(ozoneManager.getOMMetadataLayout())){
String metadataLayout = ozoneManager.getOMMetadataLayout();
metadata.put(OMConfigKeys.OZONE_OM_METADATA_LAYOUT, metadataLayout);
boolean fsPathsEnabled = ozoneManager.getEnableFileSystemPaths();
metadata.put(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
Boolean.toString(fsPathsEnabled));
Expand Down
Expand Up @@ -467,8 +467,8 @@ public static List< HddsProtos.KeyValue> getMetadataListV1() {
metadataList.add(HddsProtos.KeyValue.newBuilder().setKey("key2").setValue(
"value2").build());
metadataList.add(HddsProtos.KeyValue.newBuilder().setKey(
OMConfigKeys.OZONE_OM_LAYOUT_VERSION).setValue(
OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1).build());
OMConfigKeys.OZONE_OM_METADATA_LAYOUT).setValue(
OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX).build());
metadataList.add(HddsProtos.KeyValue.newBuilder().setKey(
OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS).setValue(
"false").build());
Expand Down Expand Up @@ -967,6 +967,6 @@ public static void configureFSOptimizedPaths(Configuration conf,
boolean enableFileSystemPaths, String version) {
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
enableFileSystemPaths);
conf.set(OMConfigKeys.OZONE_OM_LAYOUT_VERSION, version);
conf.set(OMConfigKeys.OZONE_OM_METADATA_LAYOUT, version);
}
}
Expand Up @@ -74,7 +74,7 @@ public void setup() throws Exception {
auditLogger = Mockito.mock(AuditLogger.class);
when(ozoneManager.getAuditLogger()).thenReturn(auditLogger);
Mockito.doNothing().when(auditLogger).logWrite(any(AuditMessage.class));
when(ozoneManager.getOMLayoutVersion()).thenReturn(null);
when(ozoneManager.getOMMetadataLayout()).thenReturn(null);
}

@After
Expand Down
Expand Up @@ -39,8 +39,8 @@ public class TestOMBucketCreateRequestV1 extends TestOMBucketCreateRequest {

@Test
public void testValidateAndUpdateCacheWithFSOBucket() throws Exception {
when(ozoneManager.getOMLayoutVersion()).thenReturn(
OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
when(ozoneManager.getOMMetadataLayout()).thenReturn(
OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();

Expand Down
Expand Up @@ -90,7 +90,7 @@ public void setup() throws Exception {
ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS,
folder.newFolder().getAbsolutePath());
TestOMRequestUtils.configureFSOptimizedPaths(ozoneConfiguration,
true, OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
true, OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration);
when(ozoneManager.getMetrics()).thenReturn(omMetrics);
when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
Expand Down

0 comments on commit bd22405

Please sign in to comment.