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
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public interface OMMetadataManager extends DBStoreHAManager {
*
* @param volume - Volume name
* @param bucket - Bucket name
* @return /volume/bucket/
*/
String getBucketKeyPrefix(String volume, String bucket);

Expand All @@ -129,6 +130,8 @@ public interface OMMetadataManager extends DBStoreHAManager {
*
* @param volume - Volume name
* @param bucket - Bucket name
* @return /volumeId/bucketId/
* e.g. /-9223372036854772480/-9223372036854771968/
*/
String getBucketKeyPrefixFSO(String volume, String bucket) throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import static org.apache.hadoop.ozone.om.snapshot.SnapshotDiffManager.getSnapshotRootPath;
import static org.apache.hadoop.ozone.om.snapshot.SnapshotUtils.checkSnapshotActive;
import static org.apache.hadoop.ozone.om.snapshot.SnapshotUtils.dropColumnFamilyHandle;
import static org.apache.hadoop.ozone.om.snapshot.SnapshotUtils.getOzonePathKeyForFso;
import static org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.JobStatus.DONE;

import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -499,8 +498,7 @@ private static void deleteKeysFromDelDirTableInSnapshotScope(
String bucketName, BatchOperation batchOperation) throws IOException {

// Range delete start key (inclusive)
final String keyPrefix = getOzonePathKeyForFso(omMetadataManager,
volumeName, bucketName);
final String keyPrefix = omMetadataManager.getBucketKeyPrefixFSO(volumeName, bucketName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should eventually move all fo these to KeyManager class eventually

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will do this as part of GC refactoring fixes


try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>>
iter = omMetadataManager.getDeletedDirTable().iterator(keyPrefix)) {
Expand Down Expand Up @@ -566,7 +564,7 @@ private static void deleteKeysFromDelKeyTableInSnapshotScope(

// Range delete start key (inclusive)
final String keyPrefix =
omMetadataManager.getOzoneKey(volumeName, bucketName, "");
omMetadataManager.getBucketKeyPrefix(volumeName, bucketName);

try (TableIterator<String,
? extends Table.KeyValue<String, RepeatedOmKeyInfo>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import static org.apache.hadoop.ozone.om.helpers.SnapshotInfo.SnapshotStatus.SNAPSHOT_ACTIVE;
import static org.apache.hadoop.ozone.om.request.file.OMFileRequest.getDirectoryInfo;
import static org.apache.hadoop.ozone.om.snapshot.SnapshotUtils.getOzonePathKeyForFso;
import static org.apache.hadoop.ozone.om.snapshot.SnapshotUtils.getPreviousSnapshot;

import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -207,7 +206,7 @@ public BackgroundTaskResult call() {
.getKeyTable(bucketInfo.getBucketLayout());
}

String dbBucketKeyForDir = getOzonePathKeyForFso(metadataManager,
String dbBucketKeyForDir = metadataManager.getBucketKeyPrefixFSO(
currSnapInfo.getVolumeName(), currSnapInfo.getBucketName());
try (ReferenceCounted<OmSnapshot>
rcCurrOmSnapshot = omSnapshotManager.getActiveSnapshot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.UUID;
import org.apache.hadoop.hdds.utils.db.managed.ManagedRocksDB;
import org.apache.hadoop.ozone.om.OMMetadataManager;
import org.apache.hadoop.ozone.om.OmMetadataManagerImpl;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.SnapshotChainManager;
import org.apache.hadoop.ozone.om.exceptions.OMException;
Expand Down Expand Up @@ -221,9 +220,8 @@ public static Map<String, String> getColumnFamilyToKeyPrefixMap(
String volumeName,
String bucketName
) throws IOException {
String keyPrefix = getOzonePathKey(volumeName, bucketName);
String keyPrefixFso = getOzonePathKeyForFso(omMetadataManager, volumeName,
bucketName);
String keyPrefix = omMetadataManager.getBucketKeyPrefix(volumeName, bucketName);
String keyPrefixFso = omMetadataManager.getBucketKeyPrefixFSO(volumeName, bucketName);

Map<String, String> columnFamilyToPrefixMap = new HashMap<>();
columnFamilyToPrefixMap.put(KEY_TABLE, keyPrefix);
Expand All @@ -232,50 +230,6 @@ public static Map<String, String> getColumnFamilyToKeyPrefixMap(
return columnFamilyToPrefixMap;
}

/**
* Helper method to generate /volumeName/bucketBucket/ DB key prefix from
* given volume name and bucket name as a prefix for legacy and OBS buckets.
* Follows:
* {@link OmMetadataManagerImpl#getOzonePathKey(long, long, long, String)}.
* <p>
* Note: Currently, this is only intended to be a special use case in
* Snapshot. If this is used elsewhere, consider moving this to
* {@link OMMetadataManager}.
*
* @param volumeName volume name
* @param bucketName bucket name
* @return /volumeName/bucketName/
*/
public static String getOzonePathKey(String volumeName,
String bucketName) throws IOException {
return OM_KEY_PREFIX + volumeName + OM_KEY_PREFIX + bucketName +
OM_KEY_PREFIX;
}

/**
* Helper method to generate /volumeId/bucketId/ DB key prefix from given
* volume name and bucket name as a prefix for FSO buckets.
* Follows:
* {@link OmMetadataManagerImpl#getOzonePathKey(long, long, long, String)}.
* <p>
* Note: Currently, this is only intended to be a special use case in
* Snapshot. If this is used elsewhere, consider moving this to
* {@link OMMetadataManager}.
*
* @param volumeName volume name
* @param bucketName bucket name
* @return /volumeId/bucketId/
* e.g. /-9223372036854772480/-9223372036854771968/
*/
public static String getOzonePathKeyForFso(OMMetadataManager metadataManager,
String volumeName,
String bucketName)
throws IOException {
final long volumeId = metadataManager.getVolumeId(volumeName);
final long bucketId = metadataManager.getBucketId(volumeName, bucketName);
return OM_KEY_PREFIX + volumeId + OM_KEY_PREFIX + bucketId + OM_KEY_PREFIX;
}

/**
* Returns merged repeatedKeyInfo entry with the existing deleted entry in the table.
* @param snapshotMoveKeyInfos keyInfos to be added.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.SnapshotInfo;
import org.apache.hadoop.ozone.om.snapshot.SnapshotUtils;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateSnapshotResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse;
Expand Down Expand Up @@ -211,8 +210,7 @@ private Set<String> addTestKeysToDeletedDirTable(String volumeName,
// Add deletedDirectoryTable key entries that "surround" the snapshot scope
Set<String> sentinelKeys = new HashSet<>();

final String dbKeyPfx = SnapshotUtils.getOzonePathKeyForFso(
omMetadataManager, volumeName, bucketName);
final String dbKeyPfx = omMetadataManager.getBucketKeyPrefixFSO(volumeName, bucketName);

// Calculate offset to bucketId's last character in dbKeyPfx.
// First -1 for offset, second -1 for second to last char (before '/')
Expand Down