Use override for virtual functions.

This commit is contained in:
Jingyu Zhou 2019-08-29 20:32:49 -07:00
parent b745373163
commit c7f51782b8
1 changed files with 34 additions and 34 deletions

View File

@ -258,15 +258,15 @@ std::string BackupDescription::toJSON() const {
*/
class BackupContainerFileSystem : public IBackupContainer {
public:
virtual void addref() = 0;
virtual void delref() = 0;
void addref() = 0 override;
void delref() = 0 override;
BackupContainerFileSystem() {}
virtual ~BackupContainerFileSystem() {}
// Create the container
virtual Future<Void> create() = 0;
virtual Future<bool> exists() = 0;
Future<Void> create() = 0 override;
Future<bool> exists() = 0 override;
// Get a list of fileNames and their sizes in the container under the given path
// Although not required, an implementation can avoid traversing unwanted subfolders
@ -275,7 +275,7 @@ public:
virtual Future<FilesAndSizesT> listFiles(std::string path = "", std::function<bool(std::string const &)> folderPathFilter = nullptr) = 0;
// Open a file for read by fileName
virtual Future<Reference<IAsyncFile>> readFile(std::string fileName) = 0;
Future<Reference<IAsyncFile>> readFile(std::string fileName) = 0 override;
// Open a file for write by fileName
virtual Future<Reference<IBackupFile>> writeFile(std::string fileName) = 0;
@ -285,7 +285,7 @@ public:
// Delete entire container. During the process, if pNumDeleted is not null it will be
// updated with the count of deleted files so that progress can be seen.
virtual Future<Void> deleteContainer(int *pNumDeleted) = 0;
Future<Void> deleteContainer(int* pNumDeleted) = 0 override;
// Creates a 2-level path (x/y) where v should go such that x/y/* contains (10^smallestBucket) possible versions
static std::string versionFolderString(Version v, int smallestBucket) {
@ -333,11 +333,11 @@ public:
return format("logs/%s/", versionFolderString(v, 11).c_str());
}
Future<Reference<IBackupFile>> writeLogFile(Version beginVersion, Version endVersion, int blockSize) {
Future<Reference<IBackupFile>> writeLogFile(Version beginVersion, Version endVersion, int blockSize) override {
return writeFile(logVersionFolderString(beginVersion) + format("log,%lld,%lld,%s,%d", beginVersion, endVersion, deterministicRandom()->randomUniqueID().toString().c_str(), blockSize));
}
Future<Reference<IBackupFile>> writeRangeFile(Version snapshotBeginVersion, int snapshotFileCount, Version fileVersion, int blockSize) {
Future<Reference<IBackupFile>> writeRangeFile(Version snapshotBeginVersion, int snapshotFileCount, Version fileVersion, int blockSize) override {
std::string fileName = format("range,%" PRId64 ",%s,%d", fileVersion, deterministicRandom()->randomUniqueID().toString().c_str(), blockSize);
// In order to test backward compatibility in simulation, sometimes write to the old path format
@ -495,7 +495,7 @@ public:
return Void();
}
Future<Void> writeKeyspaceSnapshotFile(std::vector<std::string> fileNames, int64_t totalBytes) {
Future<Void> writeKeyspaceSnapshotFile(std::vector<std::string> fileNames, int64_t totalBytes) override {
return writeKeyspaceSnapshotFile_impl(Reference<BackupContainerFileSystem>::addRef(this), fileNames, totalBytes);
};
@ -612,7 +612,7 @@ public:
return BackupFileList({fRanges.get(), fLogs.get(), fSnapshots.get()});
}
Future<BackupFileList> dumpFileList(Version begin, Version end) {
Future<BackupFileList> dumpFileList(Version begin, Version end) override {
return dumpFileList_impl(Reference<BackupContainerFileSystem>::addRef(this), begin, end);
}
@ -829,7 +829,7 @@ public:
}
// Uses the virtual methods to describe the backup contents
Future<BackupDescription> describeBackup(bool deepScan, Version logStartVersionOverride) {
Future<BackupDescription> describeBackup(bool deepScan, Version logStartVersionOverride) override {
return describeBackup_impl(Reference<BackupContainerFileSystem>::addRef(this), deepScan, logStartVersionOverride);
}
@ -1009,7 +1009,7 @@ public:
}
// Delete all data up to (but not including endVersion)
Future<Void> expireData(Version expireEndVersion, bool force, ExpireProgress *progress, Version restorableBeginVersion) {
Future<Void> expireData(Version expireEndVersion, bool force, ExpireProgress *progress, Version restorableBeginVersion) override {
return expireData_impl(Reference<BackupContainerFileSystem>::addRef(this), expireEndVersion, force, progress, restorableBeginVersion);
}
@ -1067,7 +1067,7 @@ public:
return Optional<RestorableFileSet>();
}
Future<Optional<RestorableFileSet>> getRestoreSet(Version targetVersion){
Future<Optional<RestorableFileSet>> getRestoreSet(Version targetVersion) override {
return getRestoreSet_impl(Reference<BackupContainerFileSystem>::addRef(this), targetVersion);
}
@ -1152,8 +1152,8 @@ public:
class BackupContainerLocalDirectory : public BackupContainerFileSystem, ReferenceCounted<BackupContainerLocalDirectory> {
public:
void addref() { return ReferenceCounted<BackupContainerLocalDirectory>::addref(); }
void delref() { return ReferenceCounted<BackupContainerLocalDirectory>::delref(); }
void addref() override { return ReferenceCounted<BackupContainerLocalDirectory>::addref(); }
void delref() override { return ReferenceCounted<BackupContainerLocalDirectory>::delref(); }
static std::string getURLFormat() { return "file://</path/to/base/dir/>"; }
@ -1202,7 +1202,7 @@ public:
return results;
}
Future<Void> create() {
Future<Void> create() override {
// Nothing should be done here because create() can be called by any process working with the container URL, such as fdbbackup.
// Since "local directory" containers are by definition local to the machine they are accessed from,
// the container's creation (in this case the creation of a directory) must be ensured prior to every file creation,
@ -1212,11 +1212,11 @@ public:
}
// The container exists if the folder it resides in exists
Future<bool> exists() {
Future<bool> exists() override {
return directoryExists(m_path);
}
Future<Reference<IAsyncFile>> readFile(std::string path) {
Future<Reference<IAsyncFile>> readFile(std::string path) override {
int flags = IAsyncFile::OPEN_NO_AIO | IAsyncFile::OPEN_READONLY | IAsyncFile::OPEN_UNCACHED;
// Simulation does not properly handle opening the same file from multiple machines using a shared filesystem,
// so create a symbolic link to make each file opening appear to be unique. This could also work in production
@ -1285,15 +1285,15 @@ public:
return finish_impl(Reference<BackupFile>::addRef(this));
}
void addref() { return ReferenceCounted<BackupFile>::addref(); }
void delref() { return ReferenceCounted<BackupFile>::delref(); }
void addref() override { return ReferenceCounted<BackupFile>::addref(); }
void delref() override { return ReferenceCounted<BackupFile>::delref(); }
private:
Reference<IAsyncFile> m_file;
std::string m_finalFullPath;
};
Future<Reference<IBackupFile>> writeFile(std::string path) {
Future<Reference<IBackupFile>> writeFile(std::string path) override {
int flags = IAsyncFile::OPEN_NO_AIO | IAsyncFile::OPEN_CREATE | IAsyncFile::OPEN_ATOMIC_WRITE_AND_CREATE | IAsyncFile::OPEN_READWRITE;
std::string fullPath = joinPath(m_path, path);
platform::createDirectory(parentDirectory(fullPath));
@ -1304,7 +1304,7 @@ public:
});
}
Future<Void> deleteFile(std::string path) {
Future<Void> deleteFile(std::string path) override {
::deleteFile(joinPath(m_path, path));
return Void();
}
@ -1329,7 +1329,7 @@ public:
return results;
}
Future<Void> deleteContainer(int *pNumDeleted) {
Future<Void> deleteContainer(int* pNumDeleted) override {
// In order to avoid deleting some random directory due to user error, first describe the backup
// and make sure it has something in it.
return map(describeBackup(false, invalidVersion), [=](BackupDescription const &desc) {
@ -1389,8 +1389,8 @@ public:
}
}
void addref() { return ReferenceCounted<BackupContainerBlobStore>::addref(); }
void delref() { return ReferenceCounted<BackupContainerBlobStore>::delref(); }
void addref() override { return ReferenceCounted<BackupContainerBlobStore>::addref(); }
void delref() override { return ReferenceCounted<BackupContainerBlobStore>::delref(); }
static std::string getURLFormat() {
return BlobStoreEndpoint::getURLFormat(true) + " (Note: The 'bucket' parameter is required.)";
@ -1398,7 +1398,7 @@ public:
virtual ~BackupContainerBlobStore() {}
Future<Reference<IAsyncFile>> readFile(std::string path) {
Future<Reference<IAsyncFile>> readFile(std::string path) override {
return Reference<IAsyncFile>(
new AsyncFileReadAheadCache(
Reference<IAsyncFile>(new AsyncFileBlobStoreRead(m_bstore, m_bucket, dataPath(path))),
@ -1435,17 +1435,17 @@ public:
return map(m_file->sync(), [=](Void _) { self->m_file.clear(); return Void(); });
}
void addref() { return ReferenceCounted<BackupFile>::addref(); }
void delref() { return ReferenceCounted<BackupFile>::delref(); }
void addref() override { return ReferenceCounted<BackupFile>::addref(); }
void delref() override { return ReferenceCounted<BackupFile>::delref(); }
private:
Reference<IAsyncFile> m_file;
};
Future<Reference<IBackupFile>> writeFile(std::string path) {
Future<Reference<IBackupFile>> writeFile(std::string path) override {
return Reference<IBackupFile>(new BackupFile(path, Reference<IAsyncFile>(new AsyncFileBlobStoreWrite(m_bstore, m_bucket, dataPath(path)))));
}
Future<Void> deleteFile(std::string path) {
Future<Void> deleteFile(std::string path) override {
return m_bstore->deleteObject(m_bucket, dataPath(path));
}
@ -1483,12 +1483,12 @@ public:
return Void();
}
Future<Void> create() {
Future<Void> create() override {
return create_impl(Reference<BackupContainerBlobStore>::addRef(this));
}
// The container exists if the index entry in the blob bucket exists
Future<bool> exists() {
Future<bool> exists() override {
return m_bstore->objectExists(m_bucket, indexEntry());
}
@ -1508,7 +1508,7 @@ public:
return Void();
}
Future<Void> deleteContainer(int *pNumDeleted) {
Future<Void> deleteContainer(int* pNumDeleted) override {
return deleteContainer_impl(Reference<BackupContainerBlobStore>::addRef(this), pNumDeleted);
}