Skip to content

Commit

Permalink
Rename restore methods of the same name to 3 different names
Browse files Browse the repository at this point in the history
life is so hard trying to reason which method is being invoked as
there are so many parameters in each method with the same name.
  • Loading branch information
Hao committed Nov 14, 2024
1 parent 40c4d62 commit b37ecb8
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 267 deletions.
36 changes: 18 additions & 18 deletions fdbbackup/backup.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2417,24 +2417,24 @@ ACTOR Future<Void> runRestore(Database db,
}

if (performRestore) {
Version restoredVersion = wait(backupAgent.restore(db,
origDb,
KeyRef(tagName),
KeyRef(container),
proxy,
ranges,
waitForDone,
targetVersion,
verbose,
KeyRef(addPrefix),
KeyRef(removePrefix),
LockDB::True,
UnlockDB::True,
onlyApplyMutationLogs,
inconsistentSnapshotOnly,
beginVersion,
encryptionKeyFile,
blobManifestUrl));
Version restoredVersion = wait(backupAgent.restoreWithBeginVersion(db,
origDb,
KeyRef(tagName),
KeyRef(container),
proxy,
ranges,
waitForDone,
targetVersion,
verbose,
KeyRef(addPrefix),
KeyRef(removePrefix),
LockDB::True,
UnlockDB::True,
onlyApplyMutationLogs,
inconsistentSnapshotOnly,
beginVersion,
encryptionKeyFile,
blobManifestUrl));

if (waitForDone && verbose) {
// If restore is now complete then report version restored
Expand Down
70 changes: 35 additions & 35 deletions fdbclient/FileBackupAgent.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6583,24 +6583,24 @@ Future<Version> FileBackupAgent::restore(Database cx,
blobManifestUrl);
}

Future<Version> FileBackupAgent::restore(Database cx,
Optional<Database> cxOrig,
Key tagName,
Key url,
Optional<std::string> proxy,
Standalone<VectorRef<KeyRangeRef>> ranges,
WaitForComplete waitForComplete,
Version targetVersion,
Verbose verbose,
Key addPrefix,
Key removePrefix,
LockDB lockDB,
UnlockDB unlockDB,
OnlyApplyMutationLogs onlyApplyMutationLogs,
InconsistentSnapshotOnly inconsistentSnapshotOnly,
Version beginVersion,
Optional<std::string> const& encryptionKeyFileName,
Optional<std::string> blobManifestUrl) {
Future<Version> FileBackupAgent::restoreWithBeginVersion(Database cx,
Optional<Database> cxOrig,
Key tagName,
Key url,
Optional<std::string> proxy,
Standalone<VectorRef<KeyRangeRef>> ranges,
WaitForComplete waitForComplete,
Version targetVersion,
Verbose verbose,
Key addPrefix,
Key removePrefix,
LockDB lockDB,
UnlockDB unlockDB,
OnlyApplyMutationLogs onlyApplyMutationLogs,
InconsistentSnapshotOnly inconsistentSnapshotOnly,
Version beginVersion,
Optional<std::string> const& encryptionKeyFileName,
Optional<std::string> blobManifestUrl) {
Standalone<VectorRef<Version>> beginVersions;
for (auto i = 0; i < ranges.size(); ++i) {
beginVersions.push_back(beginVersions.arena(), beginVersion);
Expand All @@ -6625,23 +6625,23 @@ Future<Version> FileBackupAgent::restore(Database cx,
blobManifestUrl);
}

Future<Version> FileBackupAgent::restore(Database cx,
Optional<Database> cxOrig,
Key tagName,
Key url,
Optional<std::string> proxy,
WaitForComplete waitForComplete,
Version targetVersion,
Verbose verbose,
KeyRange range,
Key addPrefix,
Key removePrefix,
LockDB lockDB,
OnlyApplyMutationLogs onlyApplyMutationLogs,
InconsistentSnapshotOnly inconsistentSnapshotOnly,
Version beginVersion,
Optional<std::string> const& encryptionKeyFileName,
Optional<std::string> blobManifestUrl) {
Future<Version> FileBackupAgent::restoreKeyRange(Database cx,
Optional<Database> cxOrig,
Key tagName,
Key url,
Optional<std::string> proxy,
WaitForComplete waitForComplete,
Version targetVersion,
Verbose verbose,
KeyRange range,
Key addPrefix,
Key removePrefix,
LockDB lockDB,
OnlyApplyMutationLogs onlyApplyMutationLogs,
InconsistentSnapshotOnly inconsistentSnapshotOnly,
Version beginVersion,
Optional<std::string> const& encryptionKeyFileName,
Optional<std::string> blobManifestUrl) {
Standalone<VectorRef<KeyRangeRef>> rangeRef;
if (range.begin.empty() && range.end.empty()) {
addDefaultBackupRanges(rangeRef);
Expand Down
75 changes: 39 additions & 36 deletions fdbclient/include/fdbclient/BackupAgent.actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,42 +206,45 @@ class FileBackupAgent : public BackupAgentBase {
Optional<std::string> const& encryptionKeyFileName = {},
Optional<std::string> blobManifestUrl = {});

Future<Version> restore(Database cx,
Optional<Database> cxOrig,
Key tagName,
Key url,
Optional<std::string> proxy,
WaitForComplete = WaitForComplete::True,
Version targetVersion = ::invalidVersion,
Verbose = Verbose::True,
KeyRange range = KeyRange(),
Key addPrefix = Key(),
Key removePrefix = Key(),
LockDB = LockDB::True,
OnlyApplyMutationLogs = OnlyApplyMutationLogs::False,
InconsistentSnapshotOnly = InconsistentSnapshotOnly::False,
Version beginVersion = ::invalidVersion,
Optional<std::string> const& encryptionKeyFileName = {},
Optional<std::string> blobManifestUrl = {});

Future<Version> restore(Database cx,
Optional<Database> cxOrig,
Key tagName,
Key url,
Optional<std::string> proxy,
Standalone<VectorRef<KeyRangeRef>> ranges,
WaitForComplete waitForComplete = WaitForComplete::True,
Version targetVersion = ::invalidVersion,
Verbose verbose = Verbose::True,
Key addPrefix = Key(),
Key removePrefix = Key(),
LockDB lockDB = LockDB::True,
UnlockDB unlockDB = UnlockDB::True,
OnlyApplyMutationLogs onlyApplyMutationLogs = OnlyApplyMutationLogs::False,
InconsistentSnapshotOnly inconsistentSnapshotOnly = InconsistentSnapshotOnly::False,
Version beginVersion = ::invalidVersion,
Optional<std::string> const& encryptionKeyFileName = {},
Optional<std::string> blobManifestUrl = {});
// this method will construct range and version vectors and then call restore()
Future<Version> restoreKeyRange(Database cx,
Optional<Database> cxOrig,
Key tagName,
Key url,
Optional<std::string> proxy,
WaitForComplete = WaitForComplete::True,
Version targetVersion = ::invalidVersion,
Verbose = Verbose::True,
KeyRange range = KeyRange(),
Key addPrefix = Key(),
Key removePrefix = Key(),
LockDB = LockDB::True,
OnlyApplyMutationLogs = OnlyApplyMutationLogs::False,
InconsistentSnapshotOnly = InconsistentSnapshotOnly::False,
Version beginVersion = ::invalidVersion,
Optional<std::string> const& encryptionKeyFileName = {},
Optional<std::string> blobManifestUrl = {});

// create a version vector of size ranges.size(), all elements are the same, i.e. beginVersion
Future<Version> restoreWithBeginVersion(
Database cx,
Optional<Database> cxOrig,
Key tagName,
Key url,
Optional<std::string> proxy,
Standalone<VectorRef<KeyRangeRef>> ranges,
WaitForComplete waitForComplete = WaitForComplete::True,
Version targetVersion = ::invalidVersion,
Verbose verbose = Verbose::True,
Key addPrefix = Key(),
Key removePrefix = Key(),
LockDB lockDB = LockDB::True,
UnlockDB unlockDB = UnlockDB::True,
OnlyApplyMutationLogs onlyApplyMutationLogs = OnlyApplyMutationLogs::False,
InconsistentSnapshotOnly inconsistentSnapshotOnly = InconsistentSnapshotOnly::False,
Version beginVersion = ::invalidVersion,
Optional<std::string> const& encryptionKeyFileName = {},
Optional<std::string> blobManifestUrl = {});

Future<Version> atomicRestore(Database cx,
Key tagName,
Expand Down
24 changes: 12 additions & 12 deletions fdbserver/workloads/BackupAndParallelRestoreCorrectness.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,18 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
try {
// TODO: Change to my restore agent code
TraceEvent(SevError, "MXFastRestore").detail("RestoreFunction", "ShouldChangeToMyOwnRestoreLogic");
wait(success(backupAgent->restore(cx,
cx,
self->backupTag,
KeyRef(lastBackupContainer),
{},
WaitForComplete::True,
::invalidVersion,
Verbose::True,
normalKeys,
Key(),
Key(),
self->locked)));
wait(success(backupAgent->restoreKeyRange(cx,
cx,
self->backupTag,
KeyRef(lastBackupContainer),
{},
WaitForComplete::True,
::invalidVersion,
Verbose::True,
normalKeys,
Key(),
Key(),
self->locked)));
TraceEvent(SevError, "BARW_RestoreAllowedOverwrittingDatabase", randomID).log();
ASSERT(false);
} catch (Error& e) {
Expand Down
Loading

0 comments on commit b37ecb8

Please sign in to comment.