Fix IAsyncFileSystem method signatures
This commit is contained in:
parent
8dc39f4d8f
commit
86c7c1e946
|
@ -239,7 +239,7 @@ public:
|
|||
// However, we could have unfinished version in the buffer when EOF is true,
|
||||
// which means we should look for data in the next file. The caller
|
||||
// should call getUnfinishedBuffer() to get these left data.
|
||||
bool finished() { return (eof && keyValues.empty()) || (leftover && !keyValues.empty()); }
|
||||
bool finished() const { return (eof && keyValues.empty()) || (leftover && !keyValues.empty()); }
|
||||
|
||||
std::vector<VersionedKVPart>&& getUnfinishedBuffer() && { return std::move(keyValues); }
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace {
|
|||
|
||||
class BackupFile : public IBackupFile, ReferenceCounted<BackupFile> {
|
||||
public:
|
||||
BackupFile(std::string fileName, Reference<IAsyncFile> file, std::string finalFullPath)
|
||||
BackupFile(const std::string& fileName, Reference<IAsyncFile> file, const std::string& finalFullPath)
|
||||
: IBackupFile(fileName), m_file(file), m_finalFullPath(finalFullPath) {}
|
||||
|
||||
Future<Void> append(const void* data, int len) {
|
||||
|
|
|
@ -108,7 +108,7 @@ ACTOR static Future<Void> incrementalDeleteHelper( std::string filename, bool mu
|
|||
return Void();
|
||||
}
|
||||
|
||||
Future<Void> IAsyncFileSystem::incrementalDeleteFile( std::string filename, bool mustBeDurable ) {
|
||||
Future<Void> IAsyncFileSystem::incrementalDeleteFile(const std::string& filename, bool mustBeDurable) {
|
||||
return uncancellable(incrementalDeleteHelper(
|
||||
filename,
|
||||
mustBeDurable,
|
||||
|
|
|
@ -88,17 +88,17 @@ typedef void (*runCycleFuncPtr)();
|
|||
class IAsyncFileSystem {
|
||||
public:
|
||||
// Opens a file for asynchronous I/O
|
||||
virtual Future< Reference<class IAsyncFile> > open( std::string filename, int64_t flags, int64_t mode ) = 0;
|
||||
virtual Future<Reference<class IAsyncFile>> open(const std::string& filename, int64_t flags, int64_t mode) = 0;
|
||||
|
||||
// Deletes the given file. If mustBeDurable, returns only when the file is guaranteed to be deleted even after a power failure.
|
||||
virtual Future< Void > deleteFile( std::string filename, bool mustBeDurable ) = 0;
|
||||
virtual Future<Void> deleteFile(const std::string& filename, bool mustBeDurable) = 0;
|
||||
|
||||
// Unlinks a file and then deletes it slowly by truncating the file repeatedly.
|
||||
// If mustBeDurable, returns only when the file is guaranteed to be deleted even after a power failure.
|
||||
virtual Future<Void> incrementalDeleteFile( std::string filename, bool mustBeDurable );
|
||||
virtual Future<Void> incrementalDeleteFile(const std::string& filename, bool mustBeDurable);
|
||||
|
||||
// Returns the time of the last modification of the file.
|
||||
virtual Future<std::time_t> lastWriteTime( std::string filename ) = 0;
|
||||
virtual Future<std::time_t> lastWriteTime(const std::string& filename) = 0;
|
||||
|
||||
static IAsyncFileSystem* filesystem() { return filesystem(g_network); }
|
||||
static runCycleFuncPtr runCycleFunc() { return reinterpret_cast<runCycleFuncPtr>(reinterpret_cast<flowGlobalType>(g_network->global(INetwork::enRunCycleFunc))); }
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
#include "fdbrpc/AsyncFileWriteChecker.h"
|
||||
|
||||
// Opens a file for asynchronous I/O
|
||||
Future< Reference<class IAsyncFile> > Net2FileSystem::open( std::string filename, int64_t flags, int64_t mode )
|
||||
{
|
||||
Future<Reference<class IAsyncFile>> Net2FileSystem::open(const std::string& filename, int64_t flags, int64_t mode) {
|
||||
#ifdef __linux__
|
||||
if (checkFileSystem) {
|
||||
dev_t fileDeviceId = getDeviceId(filename);
|
||||
|
@ -75,22 +74,19 @@ Future< Reference<class IAsyncFile> > Net2FileSystem::open( std::string filename
|
|||
}
|
||||
|
||||
// Deletes the given file. If mustBeDurable, returns only when the file is guaranteed to be deleted even after a power failure.
|
||||
Future< Void > Net2FileSystem::deleteFile( std::string filename, bool mustBeDurable )
|
||||
{
|
||||
Future<Void> Net2FileSystem::deleteFile(const std::string& filename, bool mustBeDurable) {
|
||||
return Net2AsyncFile::deleteFile(filename, mustBeDurable);
|
||||
}
|
||||
|
||||
Future< std::time_t > Net2FileSystem::lastWriteTime( std::string filename ) {
|
||||
Future<std::time_t> Net2FileSystem::lastWriteTime(const std::string& filename) {
|
||||
return Net2AsyncFile::lastWriteTime( filename );
|
||||
}
|
||||
|
||||
void Net2FileSystem::newFileSystem(double ioTimeout, std::string fileSystemPath)
|
||||
{
|
||||
void Net2FileSystem::newFileSystem(double ioTimeout, const std::string& fileSystemPath) {
|
||||
g_network->setGlobal(INetwork::enFileSystem, (flowGlobalType) new Net2FileSystem(ioTimeout, fileSystemPath));
|
||||
}
|
||||
|
||||
Net2FileSystem::Net2FileSystem(double ioTimeout, std::string fileSystemPath)
|
||||
{
|
||||
Net2FileSystem::Net2FileSystem(double ioTimeout, const std::string& fileSystemPath) {
|
||||
Net2AsyncFile::init();
|
||||
#ifdef __linux__
|
||||
if (!FLOW_KNOBS->DISABLE_POSIX_KERNEL_AIO)
|
||||
|
|
|
@ -24,25 +24,25 @@
|
|||
|
||||
#include "fdbrpc/IAsyncFile.h"
|
||||
|
||||
class Net2FileSystem : public IAsyncFileSystem {
|
||||
class Net2FileSystem final : public IAsyncFileSystem {
|
||||
public:
|
||||
// Opens a file for asynchronous I/O
|
||||
virtual Future< Reference<class IAsyncFile> > open( std::string filename, int64_t flags, int64_t mode );
|
||||
Future<Reference<class IAsyncFile>> open(const std::string& filename, int64_t flags, int64_t mode) override;
|
||||
|
||||
// Deletes the given file. If mustBeDurable, returns only when the file is guaranteed to be deleted even after a power failure.
|
||||
virtual Future< Void > deleteFile( std::string filename, bool mustBeDurable );
|
||||
Future<Void> deleteFile(const std::string& filename, bool mustBeDurable) override;
|
||||
|
||||
// Returns the time of the last modification of the file.
|
||||
virtual Future< std::time_t > lastWriteTime( std::string filename );
|
||||
Future<std::time_t> lastWriteTime(const std::string& filename) override;
|
||||
|
||||
//void init();
|
||||
static void stop();
|
||||
|
||||
Net2FileSystem(double ioTimeout=0.0, std::string fileSystemPath = "");
|
||||
Net2FileSystem(double ioTimeout = 0.0, const std::string& fileSystemPath = "");
|
||||
|
||||
virtual ~Net2FileSystem() {}
|
||||
|
||||
static void newFileSystem(double ioTimeout=0.0, std::string fileSystemPath = "");
|
||||
static void newFileSystem(double ioTimeout = 0.0, const std::string& fileSystemPath = "");
|
||||
|
||||
#ifdef __linux__
|
||||
dev_t fileSystemDeviceId;
|
||||
|
|
|
@ -2027,8 +2027,7 @@ int sf_open( const char* filename, int flags, int convFlags, int mode ) {
|
|||
#endif
|
||||
|
||||
// Opens a file for asynchronous I/O
|
||||
Future< Reference<class IAsyncFile> > Sim2FileSystem::open( std::string filename, int64_t flags, int64_t mode )
|
||||
{
|
||||
Future<Reference<class IAsyncFile>> Sim2FileSystem::open(const std::string& filename, int64_t flags, int64_t mode) {
|
||||
ASSERT( (flags & IAsyncFile::OPEN_ATOMIC_WRITE_AND_CREATE) ||
|
||||
!(flags & IAsyncFile::OPEN_CREATE) ||
|
||||
StringRef(filename).endsWith(LiteralStringRef(".fdb-lock")) ); // We don't use "ordinary" non-atomic file creation right now except for folder locking, and we don't have code to simulate its unsafeness.
|
||||
|
@ -2065,12 +2064,11 @@ Future< Reference<class IAsyncFile> > Sim2FileSystem::open( std::string filename
|
|||
}
|
||||
|
||||
// Deletes the given file. If mustBeDurable, returns only when the file is guaranteed to be deleted even after a power failure.
|
||||
Future< Void > Sim2FileSystem::deleteFile( std::string filename, bool mustBeDurable )
|
||||
{
|
||||
Future<Void> Sim2FileSystem::deleteFile(const std::string& filename, bool mustBeDurable) {
|
||||
return Sim2::deleteFileImpl(&g_sim2, filename, mustBeDurable);
|
||||
}
|
||||
|
||||
Future< std::time_t > Sim2FileSystem::lastWriteTime( std::string filename ) {
|
||||
Future<std::time_t> Sim2FileSystem::lastWriteTime(const std::string& filename) {
|
||||
// TODO: update this map upon file writes.
|
||||
static std::map<std::string, double> fileWrites;
|
||||
if (BUGGIFY && deterministicRandom()->random01() < 0.01) {
|
||||
|
|
|
@ -383,12 +383,12 @@ extern Future<Void> waitUntilDiskReady(Reference<DiskParameters> parameters, int
|
|||
class Sim2FileSystem : public IAsyncFileSystem {
|
||||
public:
|
||||
// Opens a file for asynchronous I/O
|
||||
virtual Future< Reference<class IAsyncFile> > open( std::string filename, int64_t flags, int64_t mode );
|
||||
Future<Reference<class IAsyncFile>> open(const std::string& filename, int64_t flags, int64_t mode) override;
|
||||
|
||||
// Deletes the given file. If mustBeDurable, returns only when the file is guaranteed to be deleted even after a power failure.
|
||||
virtual Future< Void > deleteFile( std::string filename, bool mustBeDurable );
|
||||
Future<Void> deleteFile(const std::string& filename, bool mustBeDurable) override;
|
||||
|
||||
virtual Future< std::time_t > lastWriteTime( std::string filename );
|
||||
Future<std::time_t> lastWriteTime(const std::string& filename) override;
|
||||
|
||||
Sim2FileSystem() {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue