Skip to content

Commit

Permalink
HDDS-10319. Also consider bucket layout deciding whether to normalize…
Browse files Browse the repository at this point in the history
… path for listKeys (apache#6195)
  • Loading branch information
devmadhuu authored Feb 9, 2024
1 parent 75df6c1 commit d3e2e59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
import org.apache.ratis.server.RaftServer;
import org.apache.ratis.server.raftlog.RaftLog;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
Expand Down Expand Up @@ -88,8 +89,9 @@ private void shutdown() {
*
* @throws IOException
*/
private void startCluster() throws Exception {
private void startCluster(boolean fsPathsEnabled) throws Exception {
conf = getOzoneConfiguration();
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, fsPathsEnabled);
conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT,
BucketLayout.OBJECT_STORE.name());
cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(5).build();
Expand All @@ -104,10 +106,11 @@ private OzoneConfiguration getOzoneConfiguration() {
return new OzoneConfiguration();
}

@Test
public void testOmBucketReadWriteKeyOps() throws Exception {
@ParameterizedTest(name = "Filesystem Paths Enabled: {0}")
@ValueSource(booleans = {false, true})
public void testOmBucketReadWriteKeyOps(boolean fsPathsEnabled) throws Exception {
try {
startCluster();
startCluster(fsPathsEnabled);
FileOutputStream out = FileUtils.openOutputStream(new File(path,
"conf"));
cluster.getConf().writeXml(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,17 @@ public ListKeysResult listKeys(String volumeName, String bucketName,
int maxKeys) throws IOException {
Preconditions.checkNotNull(volumeName);
Preconditions.checkNotNull(bucketName);

OmBucketInfo omBucketInfo = getBucketInfo(volumeName, bucketName);
if (omBucketInfo == null) {
throw new OMException("Bucket " + bucketName + " not found.",
ResultCodes.BUCKET_NOT_FOUND);
}
BucketLayout bucketLayout = omBucketInfo.getBucketLayout();
// We don't take a lock in this path, since we walk the
// underlying table using an iterator. That automatically creates a
// snapshot of the data, so we don't need these locks at a higher level
// when we iterate.

if (enableFileSystemPaths) {
if (bucketLayout.shouldNormalizePaths(enableFileSystemPaths)) {
startKey = OmUtils.normalizeKey(startKey, true);
keyPrefix = OmUtils.normalizeKey(keyPrefix, true);
}
Expand Down

0 comments on commit d3e2e59

Please sign in to comment.