-
Notifications
You must be signed in to change notification settings - Fork 599
HDDS-14037. Create DBDefinition and corresponding MetadataManager for SnapshotDiff DB #9398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
...anager/src/main/java/org/apache/hadoop/ozone/om/snapshot/db/SnapshotDiffDBDefinition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,145 @@ | ||||||||||
| /* | ||||||||||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||||
| * contributor license agreements. See the NOTICE file distributed with | ||||||||||
| * this work for additional information regarding copyright ownership. | ||||||||||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||||||||||
| * (the "License"); you may not use this file except in compliance with | ||||||||||
| * the License. You may obtain a copy of the License at | ||||||||||
| * | ||||||||||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| * | ||||||||||
| * Unless required by applicable law or agreed to in writing, software | ||||||||||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| * See the License for the specific language governing permissions and | ||||||||||
| * limitations under the License. | ||||||||||
| */ | ||||||||||
|
|
||||||||||
| package org.apache.hadoop.ozone.om.snapshot.db; | ||||||||||
|
|
||||||||||
| import static org.apache.hadoop.ozone.OzoneConsts.OM_SNAPSHOT_DIFF_DB_NAME; | ||||||||||
| import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SNAPSHOT_DIFF_DB_DIR; | ||||||||||
| import static org.apache.hadoop.ozone.snapshot.SnapshotDiffReportOzone.getDiffReportEntryCodec; | ||||||||||
|
|
||||||||||
| import java.util.Map; | ||||||||||
| import org.apache.hadoop.hdds.utils.db.BooleanCodec; | ||||||||||
| import org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition; | ||||||||||
| import org.apache.hadoop.hdds.utils.db.DBDefinition; | ||||||||||
| import org.apache.hadoop.hdds.utils.db.LongCodec; | ||||||||||
| import org.apache.hadoop.hdds.utils.db.StringCodec; | ||||||||||
| import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; | ||||||||||
| import org.apache.hadoop.ozone.om.helpers.SnapshotDiffJob; | ||||||||||
| import org.apache.hadoop.ozone.om.snapshot.diff.helper.SnapshotDiffObjectInfo; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * The SnapshotDiffDBDefinition class defines the schema for the snapshot | ||||||||||
| * difference database tables used in snapshot diff operations. Each table | ||||||||||
| * corresponds to a specific aspect of snapshot diff job processing and data | ||||||||||
| * storage, ensuring proper organization and efficient access. | ||||||||||
| */ | ||||||||||
| public final class SnapshotDiffDBDefinition extends DBDefinition.WithMap { | ||||||||||
| /** | ||||||||||
| * Contains all the snap diff job which are either queued, in_progress or | ||||||||||
| * done. This table is used to make sure that there is only single job for | ||||||||||
| * requests with the same snapshot pair at any point of time. | ||||||||||
| * |------------------------------------------------| | ||||||||||
| * | KEY | VALUE | | ||||||||||
| * |------------------------------------------------| | ||||||||||
| * | fromSnapshotId-toSnapshotId | SnapshotDiffJob | | ||||||||||
| * |------------------------------------------------| | ||||||||||
| */ | ||||||||||
| public static final String SNAP_DIFF_JOB_TABLE_NAME = "snap-diff-job-table"; | ||||||||||
|
|
||||||||||
| public static final DBColumnFamilyDefinition<String, SnapshotDiffJob> SNAP_DIFF_JOB_TABLE_DEF | ||||||||||
| = new DBColumnFamilyDefinition<>(SNAP_DIFF_JOB_TABLE_NAME, StringCodec.get(), SnapshotDiffJob.getCodec()); | ||||||||||
| /** | ||||||||||
| * Global table to keep the diff report. Each key is prefixed by the jobId | ||||||||||
| * to improve look up and clean up. JobId comes from snap-diff-job-table. | ||||||||||
| * |--------------------------------| | ||||||||||
| * | KEY | VALUE | | ||||||||||
| * |--------------------------------| | ||||||||||
| * | jobId-index | DiffReportEntry | | ||||||||||
| * |--------------------------------| | ||||||||||
| */ | ||||||||||
| public static final String SNAP_DIFF_REPORT_TABLE_NAME = "snap-diff-report-table"; | ||||||||||
| public static final DBColumnFamilyDefinition<String, DiffReportEntry> SNAP_DIFF_REPORT_TABLE_NAME_DEF | ||||||||||
| = new DBColumnFamilyDefinition<>(SNAP_DIFF_REPORT_TABLE_NAME, StringCodec.get(), getDiffReportEntryCodec()); | ||||||||||
| /** | ||||||||||
| * Contains all the snap diff job which can be purged either due to max | ||||||||||
| * allowed time is over, FAILED or REJECTED. | ||||||||||
| * |-------------------------------------------| | ||||||||||
| * | KEY | VALUE | | ||||||||||
| * |-------------------------------------------| | ||||||||||
| * | jobId | numOfTotalEntriesInReportTable | | ||||||||||
| * |-------------------------------------------| | ||||||||||
| */ | ||||||||||
| public static final String SNAP_DIFF_PURGED_JOB_TABLE_NAME = "snap-diff-purged-job-table"; | ||||||||||
| public static final DBColumnFamilyDefinition<String, Long> SNAP_DIFF_PURGED_JOB_TABLE_DEF | ||||||||||
| = new DBColumnFamilyDefinition<>(SNAP_DIFF_PURGED_JOB_TABLE_NAME, StringCodec.get(), LongCodec.get()); | ||||||||||
| /** | ||||||||||
| * Contains all the snap diff job intermediate object output for from snapshot. | ||||||||||
| * |----------------------------------------------------| | ||||||||||
| * | KEY | VALUE | | ||||||||||
| * |----------------------------------------------------| | ||||||||||
| * | jobId-objectId | SnapshotDiffObjectInfo | | ||||||||||
| * |----------------------------------------------------| | ||||||||||
| */ | ||||||||||
| public static final String SNAP_DIFF_FROM_SNAP_OBJECT_TABLE_NAME = "-from-snap"; | ||||||||||
| public static final DBColumnFamilyDefinition<String, SnapshotDiffObjectInfo> SNAP_DIFF_FROM_SNAP_OBJECT_TABLE_DEF | ||||||||||
| = new DBColumnFamilyDefinition<>(SNAP_DIFF_FROM_SNAP_OBJECT_TABLE_NAME, StringCodec.get(), | ||||||||||
| SnapshotDiffObjectInfo.getCodec()); | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Contains all the snap diff job intermediate object output for to snapshot. | ||||||||||
| * |----------------------------------------------------| | ||||||||||
| * | KEY | VALUE | | ||||||||||
| * |----------------------------------------------------| | ||||||||||
| * | jobId-objectId | SnapshotDiffObjectInfo | | ||||||||||
| * |----------------------------------------------------| | ||||||||||
| */ | ||||||||||
| public static final String SNAP_DIFF_TO_SNAP_OBJECT_TABLE_NAME = "-to-snap"; | ||||||||||
| public static final DBColumnFamilyDefinition<String, SnapshotDiffObjectInfo> SNAP_DIFF_TO_SNAP_OBJECT_TABLE_DEF | ||||||||||
| = new DBColumnFamilyDefinition<>(SNAP_DIFF_TO_SNAP_OBJECT_TABLE_NAME, StringCodec.get(), | ||||||||||
| SnapshotDiffObjectInfo.getCodec()); | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Contains all the snap diff job intermediate object output for to snapshot. | ||||||||||
|
||||||||||
| * Contains all the snap diff job intermediate object output for to snapshot. | |
| * Contains unique object IDs encountered during snapshot diff job processing. | |
| * Each entry maps a jobId-objectId pair to a boolean indicating whether the | |
| * object ID is unique for the given job. |
51 changes: 51 additions & 0 deletions
51
...ger/src/main/java/org/apache/hadoop/ozone/om/snapshot/db/SnapshotDiffMetadataManager.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.ozone.om.snapshot.db; | ||
|
|
||
| import org.apache.hadoop.hdds.utils.db.Table; | ||
| import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry; | ||
| import org.apache.hadoop.ozone.om.helpers.SnapshotDiffJob; | ||
| import org.apache.hadoop.ozone.om.snapshot.diff.helper.SnapshotDiffObjectInfo; | ||
|
|
||
| /** | ||
| * Interface representing the metadata manager for snapshot difference operations. | ||
| * This interface provides methods to access various tables storing metadata | ||
| * related to snapshot diff jobs, diff reports, purged jobs, and object information | ||
| * for snapshots. | ||
| * | ||
| * Implementations of this interface should handle the setup, maintenance, and | ||
| * querying of the relevant metadata tables. | ||
| * | ||
| * The interface extends {@link AutoCloseable}, requiring implementations to | ||
| * handle proper resource cleanup. | ||
| */ | ||
| public interface SnapshotDiffMetadataManager extends AutoCloseable { | ||
|
|
||
| Table<String, SnapshotDiffJob> getSnapshotDiffJobTable(); | ||
|
|
||
| Table<String, DiffReportEntry> getSnapshotDiffReportTable(); | ||
|
|
||
| Table<String, Long> getSnapshotDiffPurgedJobTable(); | ||
|
|
||
| Table<String, SnapshotDiffObjectInfo> getSnapshotDiffFromSnapshotObjectInfoTable(); | ||
|
|
||
| Table<String, SnapshotDiffObjectInfo> getSnapshotDiffToSnapshotObjectInfoTable(); | ||
|
|
||
| Table<String, Boolean> getSnapshotDiffUniqueObjectIdsTable(); | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Inconsistent constant usage:
SNAP_DIFF_PURGED_JOB_TABLE_NAMEis statically imported (line 56), whileSNAP_DIFF_JOB_TABLE_NAMEandSNAP_DIFF_REPORT_TABLE_NAMEare referenced with the class prefixSnapshotDiffDBDefinition. For consistency, either statically import all three table name constants or use the class prefix for all of them.