Rename IAsyncFile::incrementalDelete -> IAsyncFileSystem::incrementalDeleteFile.

`deleteFile` existed in IAsyncFileSystem, so an incremental delete function
seems to belong more as a virtual method on IAsyncFileSystem than a static
method on IAsyncFile, and the naming should match.

As long as we're here, change IAsyncFile to declare a virtual destructor, so
that it has good and proper C++ behavior.  I presume this is what was vaguely
intended by the default constructor definition that previously existed?
This commit is contained in:
Alex Miller 2017-11-29 15:24:59 -08:00
parent f9efdf1fc1
commit c7a120c59d
4 changed files with 14 additions and 14 deletions

View File

@ -25,7 +25,7 @@
#include "flow/UnitTest.h"
#include <iostream>
IAsyncFile::IAsyncFile(){};
IAsyncFile::~IAsyncFile() = default;
ACTOR static Future<Void> incrementalDeleteHelper( std::string filename, bool mustBeDurable, int64_t truncateAmt, double interval ) {
state Reference<IAsyncFile> file;
@ -53,7 +53,7 @@ ACTOR static Future<Void> incrementalDeleteHelper( std::string filename, bool mu
return Void();
}
Future<Void> IAsyncFile::incrementalDelete( std::string filename, bool mustBeDurable ) {
Future<Void> IAsyncFileSystem::incrementalDeleteFile( std::string filename, bool mustBeDurable ) {
return uncancellable(incrementalDeleteHelper(
filename,
mustBeDurable,
@ -74,6 +74,6 @@ TEST_CASE( "fileio/incrementalDelete" ) {
Void _ = wait(f->truncate(fileSize));
//close the file by deleting the reference
f.clear();
Void _ = wait(IAsyncFile::incrementalDelete(filename, true));
Void _ = wait(IAsyncFileSystem::filesystem()->incrementalDeleteFile(filename, true));
return Void();
}

View File

@ -27,7 +27,7 @@
//All outstanding operations must be cancelled before the destructor of IAsyncFile is called.
class IAsyncFile {
public:
IAsyncFile();
virtual ~IAsyncFile();
// Pass these to g_network->open to get an IAsyncFile
enum {
// Implementation relies on the low bits being the same as the SQLite flags (this is validated by a static_assert there)
@ -58,10 +58,6 @@ public:
virtual Future<int64_t> size() = 0;
virtual std::string getFilename() = 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.
static Future<Void> incrementalDelete( std::string filename, bool mustBeDurable );
// Attempt to read the *length bytes at offset without copying. If successful, a pointer to the
// requested bytes is written to *data, and the number of bytes successfully read is
// written to *length. If unsuccessful, *data and *length are undefined.
@ -83,11 +79,15 @@ typedef void (*runCycleFuncPtr)();
class IAsyncFileSystem {
public:
virtual Future< Reference<class IAsyncFile> > open( std::string filename, int64_t flags, int64_t mode ) = 0;
// 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< Void > deleteFile( std::string filename, bool mustBeDurable ) = 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;
// 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 );
static IAsyncFileSystem* filesystem() { return filesystem(g_network); }
static runCycleFuncPtr runCycleFunc() { return reinterpret_cast<runCycleFuncPtr>(reinterpret_cast<flowGlobalType>(g_network->global(INetwork::enRunCycleFunc))); }

View File

@ -405,8 +405,8 @@ public:
TraceEvent("DiskQueueShutdownDeleting", self->dbgid)
.detail("File0", self->filename(0))
.detail("File1", self->filename(1));
Void _ = wait( IAsyncFile::incrementalDelete( self->filename(0), false ) );
Void _ = wait( IAsyncFile::incrementalDelete( self->filename(1), true ) );
Void _ = wait( IAsyncFileSystem::filesystem()->incrementalDeleteFile( self->filename(0), false ) );
Void _ = wait( IAsyncFileSystem::filesystem()->incrementalDeleteFile( self->filename(1), true ) );
}
TraceEvent("DiskQueueShutdownComplete", self->dbgid)
.detail("DeleteFiles", deleteFiles)

View File

@ -1827,8 +1827,8 @@ private:
self->logging.cancel();
Void _ = wait( self->readThreads->stop() && self->writeThread->stop() );
if (deleteOnClose) {
Void _ = wait( IAsyncFile::incrementalDelete( self->filename, true ) );
Void _ = wait( IAsyncFile::incrementalDelete( self->filename + "-wal", false ) );
Void _ = wait( IAsyncFileSystem::filesystem()->incrementalDeleteFile( self->filename, true ) );
Void _ = wait( IAsyncFileSystem::filesystem()->incrementalDeleteFile( self->filename + "-wal", false ) );
}
} catch (Error& e) {
TraceEvent(SevError, "KVDoCloseError", self->logID)