/* * BackupProgress.h * * This source file is part of the FoundationDB open source project * * Copyright 2013-2019 Apple Inc. and the FoundationDB project authors * * Licensed 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. */ #if defined(NO_INTELLISENSE) && !defined(FDBSERVER_BACKUPPROGRESS_ACTOR_G_H) #define FDBSERVER_BACKUPPROGRESS_ACTOR_G_H #include "fdbserver/BackupProgress.actor.g.h" #elif !defined(FDBSERVER_BACKUPPROGRESS_ACTOR_H) #define FDBSERVER_BACKUPPROGRESS_ACTOR_H #include #include #include "fdbclient/FDBTypes.h" #include "fdbserver/LogSystem.h" #include "flow/Arena.h" #include "flow/FastRef.h" #include "flow/actorcompiler.h" // This must be the last #include. class BackupProgress : NonCopyable, ReferenceCounted { public: BackupProgress(UID id, const std::map& infos) : dbgid(id), epochInfos(infos) {} ~BackupProgress() {} // Adds a backup status. If the tag already has an entry, then the max of // savedVersion is used. void addBackupStatus(const WorkerBackupStatus& status); // Returns a map of tuple : map, so that // the backup range should be [savedVersion + 1, endVersion) for the "tag" of the "Epoch". // // Specifically, the backup ranges for each old epoch are: // if tag in tags_without_backup_progress: // backup [epochBegin, endVersion) // else if savedVersion < endVersion - 1 = knownCommittedVersion // backup [savedVersion + 1, endVersion) std::map, std::map> getUnfinishedBackup(); // Set the value for "backupStartedKey" void setBackupStartedValue(Optional value) { backupStartedValue = value; } // Returns progress for an epoch. std::map getEpochStatus(LogEpoch epoch) const { const auto it = progress.find(epoch); if (it == progress.end()) return {}; return it->second; } void addref() { ReferenceCounted::addref(); } void delref() { ReferenceCounted::delref(); } private: std::set enumerateLogRouterTags(int logRouterTags) { std::set tags; for (int i = 0; i < logRouterTags; i++) { tags.insert(Tag(tagLocalityLogRouter, i)); } return tags; } // For each tag in progress, the saved version is smaller than endVersion - 1, // add {tag, savedVersion+1} to tagVersions and remove the tag from "tags". void updateTagVersions(std::map* tagVersions, std::set* tags, const std::map& progress, Version endVersion, Version adjustedBeginVersion, LogEpoch epoch); const UID dbgid; // Note this MUST be iterated in ascending order. const std::map epochInfos; // Backup progress saved in the system keyspace. Note there can be multiple // progress status for a tag in an epoch due to later epoch trying to fill // the gap. "progress" MUST be iterated in ascending order. std::map> progress; // LogRouterTags for each epoch obtained by decoding backup progress from // the system keyspace. std::map epochTags; // Value of the "backupStartedKey". Optional backupStartedValue; }; ACTOR Future getBackupProgress(Database cx, UID dbgid, Reference bStatus, bool logging); #include "flow/unactorcompiler.h" #endif