Skip to content

Commit ef0c24f

Browse files
authored
HDDS-12333. Move ozone.om.enable.filesystem.paths into OmConfig (apache#7888)
1 parent 889c6a3 commit ef0c24f

15 files changed

Lines changed: 77 additions & 75 deletions

File tree

hadoop-hdds/common/src/main/resources/ozone-default.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,21 +3558,6 @@
35583558
</description>
35593559
</property>
35603560

3561-
<property>
3562-
<name>ozone.om.enable.filesystem.paths</name>
3563-
<tag>OZONE, OM</tag>
3564-
<value>false</value>
3565-
<description>If true, key names will be interpreted as file system paths.
3566-
"/" will be treated as a special character and paths will be normalized
3567-
and must follow Unix filesystem path naming conventions. This flag will
3568-
be helpful when objects created by S3G need to be accessed using OFS/O3Fs.
3569-
If false, it will fallback to default behavior of Key/MPU create
3570-
requests where key paths are not normalized and any intermediate
3571-
directories will not be created or any file checks happens to check
3572-
filesystem semantics.
3573-
</description>
3574-
</property>
3575-
35763561
<property>
35773562
<name>ozone.om.key.path.lock.enabled</name>
35783563
<tag>OZONE, OM</tag>

hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/keys/DeleteKeyHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.hadoop.ozone.client.OzoneClient;
2525
import org.apache.hadoop.ozone.client.OzoneKeyDetails;
2626
import org.apache.hadoop.ozone.client.OzoneVolume;
27+
import org.apache.hadoop.ozone.om.OmConfig;
2728
import org.apache.hadoop.ozone.om.exceptions.OMException;
2829
import org.apache.hadoop.ozone.om.helpers.OzoneFileStatus;
2930
import org.apache.hadoop.ozone.shell.OzoneAddress;
@@ -40,8 +41,6 @@
4041
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY;
4142
import static org.apache.hadoop.fs.FileSystem.TRASH_PREFIX;
4243
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
43-
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS;
44-
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS_DEFAULT;
4544

4645
/**
4746
* Executes Delete Key.
@@ -70,7 +69,7 @@ protected void execute(OzoneClient client, OzoneAddress address)
7069
}
7170

7271
if (bucket.getBucketLayout().isLegacy() && keyName.endsWith(OZONE_URI_DELIMITER)
73-
&& (getConf().getBoolean(OZONE_OM_ENABLE_FILESYSTEM_PATHS, OZONE_OM_ENABLE_FILESYSTEM_PATHS_DEFAULT))) {
72+
&& (getConf().getBoolean(OmConfig.Keys.ENABLE_FILESYSTEM_PATHS, OmConfig.Defaults.ENABLE_FILESYSTEM_PATHS))) {
7473
out().printf("Use FS(ofs/o3fs) interface to delete legacy bucket directory %n");
7574
return;
7675
}

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,12 @@ private OMConfigKeys() {
342342
public static final boolean OZONE_OM_KEYNAME_CHARACTER_CHECK_ENABLED_DEFAULT =
343343
false;
344344

345-
// This config needs to be enabled, when S3G created objects used via
346-
// FileSystem API.
345+
@Deprecated
347346
public static final String OZONE_OM_ENABLE_FILESYSTEM_PATHS =
348-
"ozone.om.enable.filesystem.paths";
347+
OmConfig.Keys.ENABLE_FILESYSTEM_PATHS;
348+
@Deprecated
349349
public static final boolean OZONE_OM_ENABLE_FILESYSTEM_PATHS_DEFAULT =
350-
false;
350+
OmConfig.Defaults.ENABLE_FILESYSTEM_PATHS;
351351

352352
public static final String OZONE_SERVER_DEFAULT_REPLICATION_KEY =
353353
"ozone.server.default.replication";

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OmConfig.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@
2828
@ConfigGroup(prefix = "ozone.om")
2929
public class OmConfig {
3030

31+
/** This config needs to be enabled, when S3G created objects used via FileSystem API. */
32+
@Config(
33+
key = "enable.filesystem.paths",
34+
defaultValue = "false",
35+
description = "If true, key names will be interpreted as file system paths. " +
36+
"'/' will be treated as a special character and paths will be normalized " +
37+
"and must follow Unix filesystem path naming conventions. This flag will " +
38+
"be helpful when objects created by S3G need to be accessed using OFS/O3Fs. " +
39+
"If false, it will fallback to default behavior of Key/MPU create " +
40+
"requests where key paths are not normalized and any intermediate " +
41+
"directories will not be created or any file checks happens to check " +
42+
"filesystem semantics.",
43+
tags = { ConfigTag.OM, ConfigTag.OZONE }
44+
)
45+
private boolean fileSystemPathEnabled;
46+
3147
@Config(
3248
key = "server.list.max.size",
3349
defaultValue = "1000",
@@ -36,6 +52,14 @@ public class OmConfig {
3652
)
3753
private long maxListSize;
3854

55+
public boolean isFileSystemPathEnabled() {
56+
return fileSystemPathEnabled;
57+
}
58+
59+
public void setFileSystemPathEnabled(boolean newValue) {
60+
fileSystemPathEnabled = newValue;
61+
}
62+
3963
public long getMaxListSize() {
4064
return maxListSize;
4165
}
@@ -56,13 +80,15 @@ public void validate() {
5680
* String keys for tests and grep.
5781
*/
5882
public static final class Keys {
83+
public static final String ENABLE_FILESYSTEM_PATHS = "ozone.om.enable.filesystem.paths";
5984
public static final String SERVER_LIST_MAX_SIZE = "ozone.om.server.list.max.size";
6085
}
6186

6287
/**
6388
* Default values for tests.
6489
*/
65-
static final class Defaults {
90+
public static final class Defaults {
91+
public static final boolean ENABLE_FILESYSTEM_PATHS = false;
6692
public static final long SERVER_LIST_MAX_SIZE = 1000;
6793
}
6894

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestOzoneConfigurationFields.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ private void addPropertiesNotInXml() {
9494
OMConfigKeys.OZONE_FS_TRASH_CHECKPOINT_INTERVAL_KEY,
9595
OMConfigKeys.OZONE_OM_S3_GPRC_SERVER_ENABLED,
9696
OMConfigKeys.OZONE_OM_FEATURES_DISABLED,
97+
OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
9798
OzoneConfigKeys.OZONE_ACL_AUTHORIZER_CLASS_NATIVE,
9899
OzoneConfigKeys.OZONE_CLIENT_REQUIRED_OM_VERSION_MIN_KEY,
99100
OzoneConfigKeys.OZONE_RECOVERING_CONTAINER_SCRUBBING_SERVICE_WORKERS,

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/OzoneRpcClientTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
import org.apache.hadoop.ozone.container.common.interfaces.DBHandle;
113113
import org.apache.hadoop.ozone.container.keyvalue.KeyValueContainerData;
114114
import org.apache.hadoop.ozone.container.keyvalue.helpers.BlockUtils;
115-
import org.apache.hadoop.ozone.om.OMConfigKeys;
116115
import org.apache.hadoop.ozone.om.OMMetadataManager;
117116
import org.apache.hadoop.ozone.om.OmFailoverProxyUtil;
118117
import org.apache.hadoop.ozone.om.OzoneManager;
@@ -1741,8 +1740,7 @@ public void testMissingParentBucketUsedNamespace(BucketLayout layout)
17411740
OzoneBucket bucket = volume.getBucket(bucketName);
17421741

17431742
if (layout.equals(BucketLayout.LEGACY)) {
1744-
OzoneConfiguration conf = cluster.getConf();
1745-
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, true);
1743+
cluster.getOzoneManager().getConfig().setFileSystemPathEnabled(true);
17461744
}
17471745

17481746
// the directory "/dir1", ""/dir1/dir2/", "/dir1/dir2/dir3/"

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestObjectStoreWithLegacyFS.java

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323
import org.apache.commons.lang3.RandomStringUtils;
2424
import org.apache.commons.lang3.RandomUtils;
2525
import org.apache.hadoop.hdds.client.RatisReplicationConfig;
26-
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
2726
import org.apache.hadoop.hdds.protocol.StorageType;
2827
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
2928
import org.apache.hadoop.hdds.utils.db.Table;
3029
import org.apache.hadoop.hdds.utils.db.TableIterator;
31-
import org.apache.hadoop.ozone.MiniOzoneCluster;
3230
import org.apache.hadoop.ozone.OzoneConsts;
3331
import org.apache.hadoop.ozone.TestDataUtil;
3432
import org.apache.hadoop.ozone.client.BucketArgs;
@@ -44,10 +42,12 @@
4442
import org.apache.hadoop.ozone.om.helpers.OmMultipartUploadCompleteInfo;
4543

4644
import org.apache.ozone.test.GenericTestUtils;
45+
import org.apache.ozone.test.NonHATests;
4746
import org.junit.jupiter.api.AfterAll;
4847
import org.junit.jupiter.api.BeforeAll;
4948
import org.junit.jupiter.api.BeforeEach;
5049
import org.junit.jupiter.api.Test;
50+
import org.junit.jupiter.api.TestInstance;
5151
import org.junit.jupiter.api.Timeout;
5252
import org.slf4j.Logger;
5353
import org.slf4j.LoggerFactory;
@@ -68,11 +68,11 @@
6868
/**
6969
* Test verifies object store with OZONE_OM_ENABLE_FILESYSTEM_PATHS enabled.
7070
*/
71+
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
7172
@Timeout(200)
72-
public class TestObjectStoreWithLegacyFS {
73+
public abstract class TestObjectStoreWithLegacyFS implements NonHATests.TestCase {
7374

74-
private static MiniOzoneCluster cluster = null;
75-
private static OzoneClient client;
75+
private OzoneClient client;
7676

7777
private String volumeName;
7878

@@ -82,30 +82,22 @@ public class TestObjectStoreWithLegacyFS {
8282

8383
private static final Logger LOG =
8484
LoggerFactory.getLogger(TestObjectStoreWithLegacyFS.class);
85+
private boolean originalFileSystemPathEnabled;
8586

8687
@BeforeAll
87-
public static void initClass() throws Exception {
88-
OzoneConfiguration conf = new OzoneConfiguration();
89-
90-
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, true);
91-
conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT,
92-
BucketLayout.LEGACY.name());
93-
cluster = MiniOzoneCluster.newBuilder(conf)
94-
.setNumDatanodes(3)
95-
.build();
96-
cluster.waitForClusterToBeReady();
97-
client = cluster.newClient();
88+
void initClass() throws Exception {
89+
OmConfig omConfig = cluster().getOzoneManager().getConfig();
90+
originalFileSystemPathEnabled = omConfig.isFileSystemPathEnabled();
91+
omConfig.setFileSystemPathEnabled(true);
92+
93+
client = cluster().newClient();
9894
}
9995

100-
/**
101-
* Shutdown MiniOzoneCluster.
102-
*/
10396
@AfterAll
104-
public static void shutdown() {
97+
void cleanup() {
10598
IOUtils.closeQuietly(client);
106-
if (cluster != null) {
107-
cluster.shutdown();
108-
}
99+
OmConfig omConfig = cluster().getOzoneManager().getConfig();
100+
omConfig.setFileSystemPathEnabled(originalFileSystemPathEnabled);
109101
}
110102

111103
@BeforeEach
@@ -132,11 +124,11 @@ public void testFlatKeyStructureWithOBS() throws Exception {
132124
.createKey("dir1/dir2/dir3/key-1", 0);
133125
stream.close();
134126
Table<String, OmKeyInfo> keyTable =
135-
cluster.getOzoneManager().getMetadataManager()
127+
cluster().getOzoneManager().getMetadataManager()
136128
.getKeyTable(BucketLayout.OBJECT_STORE);
137129

138130
String seekKey = "dir";
139-
String dbKey = cluster.getOzoneManager().getMetadataManager()
131+
String dbKey = cluster().getOzoneManager().getMetadataManager()
140132
.getOzoneKey(volumeName, bucketName, seekKey);
141133

142134
GenericTestUtils

hadoop-ozone/integration-test/src/test/java/org/apache/ozone/test/NonHATests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ public MiniOzoneCluster cluster() {
170170
}
171171
}
172172

173+
@Nested
174+
class ObjectStoreWithLegacyFS extends org.apache.hadoop.ozone.om.TestObjectStoreWithLegacyFS {
175+
@Override
176+
public MiniOzoneCluster cluster() {
177+
return getCluster();
178+
}
179+
}
180+
173181
@Nested
174182
class OmBlockVersioning extends org.apache.hadoop.ozone.om.TestOmBlockVersioning {
175183
@Override

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ public class KeyManagerImpl implements KeyManager {
192192
private SnapshotDeletingService snapshotDeletingService;
193193

194194
private final KeyProviderCryptoExtension kmsProvider;
195-
private final boolean enableFileSystemPaths;
196195
private DirectoryDeletingService dirDeletingService;
197196
private final OMPerformanceMetrics metrics;
198197

@@ -218,9 +217,6 @@ public KeyManagerImpl(OzoneManager om, ScmClient scmClient,
218217
this.grpcBlockTokenEnabled = conf.getBoolean(
219218
HDDS_BLOCK_TOKEN_ENABLED,
220219
HDDS_BLOCK_TOKEN_ENABLED_DEFAULT);
221-
this.enableFileSystemPaths =
222-
conf.getBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
223-
OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS_DEFAULT);
224220

225221
this.ozoneManager = om;
226222
this.scmClient = scmClient;
@@ -473,7 +469,7 @@ private OmKeyInfo readKeyInfo(OmKeyArgs args, BucketLayout bucketLayout)
473469
bucketName);
474470
try {
475471
keyName = OMClientRequest
476-
.validateAndNormalizeKey(enableFileSystemPaths, keyName,
472+
.validateAndNormalizeKey(ozoneManager.getEnableFileSystemPaths(), keyName,
477473
bucketLayout);
478474

479475
if (bucketLayout.isFileSystemOptimized()) {
@@ -665,7 +661,7 @@ public ListKeysResult listKeys(String volumeName, String bucketName,
665661
// underlying table using an iterator. That automatically creates a
666662
// snapshot of the data, so we don't need these locks at a higher level
667663
// when we iterate.
668-
if (bucketLayout.shouldNormalizePaths(enableFileSystemPaths)) {
664+
if (bucketLayout.shouldNormalizePaths(ozoneManager.getEnableFileSystemPaths())) {
669665
startKey = OmUtils.normalizeKey(startKey, true);
670666
keyPrefix = OmUtils.normalizeKey(keyPrefix, true);
671667
}

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,6 @@
278278
import static org.apache.hadoop.ozone.OzoneConsts.TRANSACTION_INFO_KEY;
279279
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_KEY_DELETING_LIMIT_PER_TASK;
280280
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
281-
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS;
282-
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS_DEFAULT;
283281
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_KEY_PATH_LOCK_ENABLED;
284282
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_KEY_PATH_LOCK_ENABLED_DEFAULT;
285283
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_HANDLER_COUNT_DEFAULT;
@@ -4467,8 +4465,7 @@ public void setExitManagerForTesting(ExitManager exitManagerForTesting) {
44674465
}
44684466

44694467
public boolean getEnableFileSystemPaths() {
4470-
return configuration.getBoolean(OZONE_OM_ENABLE_FILESYSTEM_PATHS,
4471-
OZONE_OM_ENABLE_FILESYSTEM_PATHS_DEFAULT);
4468+
return config.isFileSystemPathEnabled();
44724469
}
44734470

44744471
public boolean getKeyPathLockEnabled() {

0 commit comments

Comments
 (0)