1
0
Fork 0

renamed classes

This commit is contained in:
jsteemann 2017-02-27 11:40:15 +01:00
parent d75bf1d2e7
commit 90f32ed525
18 changed files with 191 additions and 192 deletions

View File

@ -170,8 +170,8 @@ void MMFilesCleanupThread::cleanupCollection(arangodb::LogicalCollection* collec
TRI_ASSERT(ditches != nullptr);
// check and remove all callback elements at the beginning of the list
auto callback = [&](arangodb::Ditch const* ditch) -> bool {
if (ditch->type() == arangodb::Ditch::TRI_DITCH_COLLECTION_UNLOAD) {
auto callback = [&](arangodb::MMFilesDitch const* ditch) -> bool {
if (ditch->type() == arangodb::MMFilesDitch::TRI_DITCH_COLLECTION_UNLOAD) {
// check if we can really unload, this is only the case if the
// collection's WAL markers
// were fully collected
@ -215,9 +215,9 @@ void MMFilesCleanupThread::cleanupCollection(arangodb::LogicalCollection* collec
if (gotStatus && !isUnloading) {
popped = false;
auto unloader =
ditches->process(popped, [](arangodb::Ditch const* ditch) -> bool {
ditches->process(popped, [](arangodb::MMFilesDitch const* ditch) -> bool {
return (ditch->type() ==
arangodb::Ditch::TRI_DITCH_COLLECTION_UNLOAD);
arangodb::MMFilesDitch::TRI_DITCH_COLLECTION_UNLOAD);
});
if (popped) {
// we've changed the list. try with current state in next turn
@ -264,17 +264,17 @@ void MMFilesCleanupThread::cleanupCollection(arangodb::LogicalCollection* collec
// execute callback, some of the callbacks might delete or unload our collection
auto const type = ditch->type();
if (type == arangodb::Ditch::TRI_DITCH_DATAFILE_DROP) {
dynamic_cast<arangodb::DropDatafileDitch*>(ditch)->executeCallback();
if (type == arangodb::MMFilesDitch::TRI_DITCH_DATAFILE_DROP) {
dynamic_cast<arangodb::MMFilesDropDatafileDitch*>(ditch)->executeCallback();
delete ditch;
// next iteration
} else if (type == arangodb::Ditch::TRI_DITCH_DATAFILE_RENAME) {
dynamic_cast<arangodb::RenameDatafileDitch*>(ditch)->executeCallback();
} else if (type == arangodb::MMFilesDitch::TRI_DITCH_DATAFILE_RENAME) {
dynamic_cast<arangodb::MMFilesRenameDatafileDitch*>(ditch)->executeCallback();
delete ditch;
// next iteration
} else if (type == arangodb::Ditch::TRI_DITCH_COLLECTION_UNLOAD) {
} else if (type == arangodb::MMFilesDitch::TRI_DITCH_COLLECTION_UNLOAD) {
// collection will be unloaded
bool hasUnloaded = dynamic_cast<arangodb::UnloadCollectionDitch*>(ditch)
bool hasUnloaded = dynamic_cast<arangodb::MMFilesUnloadCollectionDitch*>(ditch)
->executeCallback();
delete ditch;
@ -282,9 +282,9 @@ void MMFilesCleanupThread::cleanupCollection(arangodb::LogicalCollection* collec
// this has unloaded and freed the collection
return;
}
} else if (type == arangodb::Ditch::TRI_DITCH_COLLECTION_DROP) {
} else if (type == arangodb::MMFilesDitch::TRI_DITCH_COLLECTION_DROP) {
// collection will be dropped
bool hasDropped = dynamic_cast<arangodb::DropCollectionDitch*>(ditch)
bool hasDropped = dynamic_cast<arangodb::MMFilesDropCollectionDitch*>(ditch)
->executeCallback();
delete ditch;

View File

@ -1101,7 +1101,7 @@ void MMFilesCollection::figuresSpecific(std::shared_ptr<arangodb::velocypack::Bu
builder->add("time", VPackValue(&lastCompactionStampString[0]));
builder->close(); // compactionStatus
builder->add("documentReferences", VPackValue(_ditches.numDocumentDitches()));
builder->add("documentReferences", VPackValue(_ditches.numMMFilesDocumentMMFilesDitches()));
char const* waitingForDitch = _ditches.head();
builder->add("waitingFor", VPackValue(waitingForDitch == nullptr ? "-" : waitingForDitch));

View File

@ -219,7 +219,7 @@ class MMFilesCollection final : public PhysicalCollection {
double lastCompactionStamp() const { return _lastCompactionStamp; }
void lastCompactionStamp(double value) { _lastCompactionStamp = value; }
Ditches* ditches() const { return &_ditches; }
MMFilesDitches* ditches() const { return &_ditches; }
void open(bool ignoreErrors) override;
@ -467,7 +467,7 @@ class MMFilesCollection final : public PhysicalCollection {
bool& waitForSync);
private:
mutable arangodb::Ditches _ditches;
mutable arangodb::MMFilesDitches _ditches;
// lock protecting the indexes
mutable basics::ReadWriteLock _idxLock;

View File

@ -76,7 +76,7 @@ struct MMFilesCollectorCache {
~MMFilesCollectorCache() {
delete operations;
freeDitches();
freeMMFilesDitches();
}
/// @brief return a reference to an existing datafile statistics struct
@ -99,15 +99,15 @@ struct MMFilesCollectorCache {
}
/// @brief add a ditch
void addDitch(arangodb::DocumentDitch* ditch) {
void addDitch(arangodb::MMFilesDocumentDitch* ditch) {
TRI_ASSERT(ditch != nullptr);
ditches.emplace_back(ditch);
}
/// @brief free all ditches
void freeDitches() {
void freeMMFilesDitches() {
for (auto& it : ditches) {
it->ditches()->freeDocumentDitch(it, false);
it->ditches()->freeMMFilesDocumentDitch(it, false);
}
ditches.clear();
@ -129,7 +129,7 @@ struct MMFilesCollectorCache {
std::vector<MMFilesCollectorOperation>* operations;
/// @brief ditches held by the operations
std::vector<arangodb::DocumentDitch*> ditches;
std::vector<arangodb::MMFilesDocumentDitch*> ditches;
/// @brief datafile info cache, updated when the collector transfers markers
std::unordered_map<TRI_voc_fid_t, DatafileStatisticsContainer> dfi;

View File

@ -555,7 +555,7 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
// add a deletion ditch to the collection
auto b = arangodb::MMFilesCollection::toMMFilesCollection(collection)
->ditches()
->createDropDatafileDitch(compaction._datafile, collection,
->createMMFilesDropDatafileDitch(compaction._datafile, collection,
DropDatafileCallback, __FILE__,
__LINE__);
@ -586,7 +586,7 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
// add a rename marker
auto b = arangodb::MMFilesCollection::toMMFilesCollection(collection)
->ditches()
->createRenameDatafileDitch(
->createMMFilesRenameDatafileDitch(
compaction._datafile, context->_compactor,
context->_collection, RenameDatafileCallback, __FILE__,
__LINE__);
@ -604,7 +604,7 @@ void MMFilesCompactorThread::compactDatafiles(LogicalCollection* collection,
// add a drop datafile marker
auto b = arangodb::MMFilesCollection::toMMFilesCollection(collection)
->ditches()
->createDropDatafileDitch(compaction._datafile, collection,
->createMMFilesDropDatafileDitch(compaction._datafile, collection,
DropDatafileCallback, __FILE__,
__LINE__);
@ -907,7 +907,7 @@ void MMFilesCompactorThread::run() {
auto ce = arangodb::MMFilesCollection::toMMFilesCollection(
collection)
->ditches()
->createCompactionDitch(__FILE__, __LINE__);
->createMMFilesCompactionDitch(__FILE__, __LINE__);
if (ce == nullptr) {
// out of memory

View File

@ -28,96 +28,96 @@
using namespace arangodb;
Ditch::Ditch(Ditches* ditches, char const* filename, int line)
MMFilesDitch::MMFilesDitch(MMFilesDitches* ditches, char const* filename, int line)
: _ditches(ditches),
_prev(nullptr),
_next(nullptr),
_filename(filename),
_line(line) {}
Ditch::~Ditch() {}
MMFilesDitch::~MMFilesDitch() {}
/// @brief return the associated collection
LogicalCollection* Ditch::collection() const {
LogicalCollection* MMFilesDitch::collection() const {
return _ditches->collection();
}
DocumentDitch::DocumentDitch(Ditches* ditches, bool usedByTransaction,
MMFilesDocumentDitch::MMFilesDocumentDitch(MMFilesDitches* ditches, bool usedByTransaction,
char const* filename, int line)
: Ditch(ditches, filename, line),
: MMFilesDitch(ditches, filename, line),
_usedByTransaction(usedByTransaction) {}
DocumentDitch::~DocumentDitch() {}
MMFilesDocumentDitch::~MMFilesDocumentDitch() {}
ReplicationDitch::ReplicationDitch(Ditches* ditches, char const* filename,
MMFilesReplicationDitch::MMFilesReplicationDitch(MMFilesDitches* ditches, char const* filename,
int line)
: Ditch(ditches, filename, line) {}
: MMFilesDitch(ditches, filename, line) {}
ReplicationDitch::~ReplicationDitch() {}
MMFilesReplicationDitch::~MMFilesReplicationDitch() {}
CompactionDitch::CompactionDitch(Ditches* ditches, char const* filename,
MMFilesCompactionDitch::MMFilesCompactionDitch(MMFilesDitches* ditches, char const* filename,
int line)
: Ditch(ditches, filename, line) {}
: MMFilesDitch(ditches, filename, line) {}
CompactionDitch::~CompactionDitch() {}
MMFilesCompactionDitch::~MMFilesCompactionDitch() {}
DropDatafileDitch::DropDatafileDitch(
Ditches* ditches, MMFilesDatafile* datafile, LogicalCollection* collection,
MMFilesDropDatafileDitch::MMFilesDropDatafileDitch(
MMFilesDitches* ditches, MMFilesDatafile* datafile, LogicalCollection* collection,
std::function<void(MMFilesDatafile*, LogicalCollection*)> const& callback, char const* filename,
int line)
: Ditch(ditches, filename, line),
: MMFilesDitch(ditches, filename, line),
_datafile(datafile),
_collection(collection),
_callback(callback) {}
DropDatafileDitch::~DropDatafileDitch() { delete _datafile; }
MMFilesDropDatafileDitch::~MMFilesDropDatafileDitch() { delete _datafile; }
RenameDatafileDitch::RenameDatafileDitch(
Ditches* ditches, MMFilesDatafile* datafile, MMFilesDatafile* compactor,
MMFilesRenameDatafileDitch::MMFilesRenameDatafileDitch(
MMFilesDitches* ditches, MMFilesDatafile* datafile, MMFilesDatafile* compactor,
LogicalCollection* collection,
std::function<void(MMFilesDatafile*, MMFilesDatafile*, LogicalCollection*)> const& callback, char const* filename,
int line)
: Ditch(ditches, filename, line),
: MMFilesDitch(ditches, filename, line),
_datafile(datafile),
_compactor(compactor),
_collection(collection),
_callback(callback) {}
RenameDatafileDitch::~RenameDatafileDitch() {}
MMFilesRenameDatafileDitch::~MMFilesRenameDatafileDitch() {}
UnloadCollectionDitch::UnloadCollectionDitch(
Ditches* ditches, LogicalCollection* collection,
MMFilesUnloadCollectionDitch::MMFilesUnloadCollectionDitch(
MMFilesDitches* ditches, LogicalCollection* collection,
std::function<bool(LogicalCollection*)> const& callback,
char const* filename, int line)
: Ditch(ditches, filename, line),
: MMFilesDitch(ditches, filename, line),
_collection(collection),
_callback(callback) {}
UnloadCollectionDitch::~UnloadCollectionDitch() {}
MMFilesUnloadCollectionDitch::~MMFilesUnloadCollectionDitch() {}
DropCollectionDitch::DropCollectionDitch(
Ditches* ditches, arangodb::LogicalCollection* collection,
MMFilesDropCollectionDitch::MMFilesDropCollectionDitch(
MMFilesDitches* ditches, arangodb::LogicalCollection* collection,
std::function<bool(arangodb::LogicalCollection*)> callback,
char const* filename, int line)
: Ditch(ditches, filename, line),
: MMFilesDitch(ditches, filename, line),
_collection(collection),
_callback(callback) {}
DropCollectionDitch::~DropCollectionDitch() {}
MMFilesDropCollectionDitch::~MMFilesDropCollectionDitch() {}
Ditches::Ditches(LogicalCollection* collection)
MMFilesDitches::MMFilesDitches(LogicalCollection* collection)
: _collection(collection),
_lock(),
_begin(nullptr),
_end(nullptr),
_numDocumentDitches(0) {
_numMMFilesDocumentMMFilesDitches(0) {
TRI_ASSERT(_collection != nullptr);
}
Ditches::~Ditches() { destroy(); }
MMFilesDitches::~MMFilesDitches() { destroy(); }
/// @brief destroy the ditches - to be called on shutdown only
void Ditches::destroy() {
void MMFilesDitches::destroy() {
MUTEX_LOCKER(mutexLocker, _lock);
auto* ptr = _begin;
@ -125,14 +125,14 @@ void Ditches::destroy() {
auto* next = ptr->next();
auto const type = ptr->type();
if (type == Ditch::TRI_DITCH_COLLECTION_UNLOAD ||
type == Ditch::TRI_DITCH_COLLECTION_DROP ||
type == Ditch::TRI_DITCH_DATAFILE_DROP ||
type == Ditch::TRI_DITCH_DATAFILE_RENAME ||
type == Ditch::TRI_DITCH_REPLICATION ||
type == Ditch::TRI_DITCH_COMPACTION) {
if (type == MMFilesDitch::TRI_DITCH_COLLECTION_UNLOAD ||
type == MMFilesDitch::TRI_DITCH_COLLECTION_DROP ||
type == MMFilesDitch::TRI_DITCH_DATAFILE_DROP ||
type == MMFilesDitch::TRI_DITCH_DATAFILE_RENAME ||
type == MMFilesDitch::TRI_DITCH_REPLICATION ||
type == MMFilesDitch::TRI_DITCH_COMPACTION) {
delete ptr;
} else if (type == Ditch::TRI_DITCH_DOCUMENT) {
} else if (type == MMFilesDitch::TRI_DITCH_DOCUMENT) {
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "logic error. shouldn't have document ditches on unload";
TRI_ASSERT(false);
} else {
@ -144,20 +144,20 @@ void Ditches::destroy() {
}
/// @brief return the associated collection
LogicalCollection* Ditches::collection() const { return _collection; }
LogicalCollection* MMFilesDitches::collection() const { return _collection; }
/// @brief run a user-defined function under the lock
void Ditches::executeProtected(std::function<void()> callback) {
void MMFilesDitches::executeProtected(std::function<void()> callback) {
MUTEX_LOCKER(mutexLocker, _lock);
callback();
}
/// @brief process the first element from the list
/// the list will remain unchanged if the first element is either a
/// DocumentDitch, a ReplicationDitch or a CompactionDitch, or if the list
/// contains any DocumentDitches.
Ditch* Ditches::process(bool& popped,
std::function<bool(Ditch const*)> callback) {
/// MMFilesDocumentDitch, a MMFilesReplicationDitch or a MMFilesCompactionDitch, or if the list
/// contains any MMFilesDocumentMMFilesDitches.
MMFilesDitch* MMFilesDitches::process(bool& popped,
std::function<bool(MMFilesDitch const*)> callback) {
popped = false;
MUTEX_LOCKER(mutexLocker, _lock);
@ -173,11 +173,11 @@ Ditch* Ditches::process(bool& popped,
auto const type = ditch->type();
// if it is a DocumentDitch, it means that there is still a reference held
// if it is a MMFilesDocumentDitch, it means that there is still a reference held
// to document data in a datafile. We must then not unload or remove a file
if (type == Ditch::TRI_DITCH_DOCUMENT ||
type == Ditch::TRI_DITCH_REPLICATION ||
type == Ditch::TRI_DITCH_COMPACTION || _numDocumentDitches > 0) {
if (type == MMFilesDitch::TRI_DITCH_DOCUMENT ||
type == MMFilesDitch::TRI_DITCH_REPLICATION ||
type == MMFilesDitch::TRI_DITCH_COMPACTION || _numMMFilesDocumentMMFilesDitches > 0) {
// did not find anything at the head of the barrier list or found an element
// marker
// this means we must exit and cannot throw away datafiles and can unload
@ -185,11 +185,11 @@ Ditch* Ditches::process(bool& popped,
return nullptr;
}
// no DocumentDitch at the head of the ditches list. This means that there is
// no MMFilesDocumentDitch at the head of the ditches list. This means that there is
// some other action we can perform (i.e. unloading a datafile or a
// collection)
// note that there is no need to check the entire list for a DocumentDitch as
// note that there is no need to check the entire list for a MMFilesDocumentDitch as
// the list is filled up in chronological order. New ditches are always added
// to the
// tail of the list, and if we have the following list
@ -218,7 +218,7 @@ Ditch* Ditches::process(bool& popped,
}
/// @brief return the type name of the ditch at the head of the active ditches
char const* Ditches::head() {
char const* MMFilesDitches::head() {
MUTEX_LOCKER(mutexLocker, _lock);
auto ditch = _begin;
@ -230,19 +230,19 @@ char const* Ditches::head() {
}
/// @brief return the number of document ditches active
uint64_t Ditches::numDocumentDitches() {
uint64_t MMFilesDitches::numMMFilesDocumentMMFilesDitches() {
MUTEX_LOCKER(mutexLocker, _lock);
return _numDocumentDitches;
return _numMMFilesDocumentMMFilesDitches;
}
/// @brief check whether the ditches contain a ditch of a certain type
bool Ditches::contains(Ditch::DitchType type) {
bool MMFilesDitches::contains(MMFilesDitch::DitchType type) {
MUTEX_LOCKER(mutexLocker, _lock);
if (type == Ditch::TRI_DITCH_DOCUMENT) {
if (type == MMFilesDitch::TRI_DITCH_DOCUMENT) {
// shortcut
return (_numDocumentDitches > 0);
return (_numMMFilesDocumentMMFilesDitches > 0);
}
auto const* ptr = _begin;
@ -259,19 +259,19 @@ bool Ditches::contains(Ditch::DitchType type) {
}
/// @brief removes and frees a ditch
void Ditches::freeDitch(Ditch* ditch) {
void MMFilesDitches::freeDitch(MMFilesDitch* ditch) {
TRI_ASSERT(ditch != nullptr);
bool const isDocumentDitch = (ditch->type() == Ditch::TRI_DITCH_DOCUMENT);
bool const isMMFilesDocumentDitch = (ditch->type() == MMFilesDitch::TRI_DITCH_DOCUMENT);
{
MUTEX_LOCKER(mutexLocker, _lock);
unlink(ditch);
if (isDocumentDitch) {
if (isMMFilesDocumentDitch) {
// decrease counter
--_numDocumentDitches;
--_numMMFilesDocumentMMFilesDitches;
}
}
@ -281,7 +281,7 @@ void Ditches::freeDitch(Ditch* ditch) {
/// @brief removes and frees a ditch
/// this is used for ditches used by transactions or by externals to protect
/// the flags by the lock
void Ditches::freeDocumentDitch(DocumentDitch* ditch, bool fromTransaction) {
void MMFilesDitches::freeMMFilesDocumentDitch(MMFilesDocumentDitch* ditch, bool fromTransaction) {
TRI_ASSERT(ditch != nullptr);
// First see who might still be using the ditch:
@ -295,17 +295,17 @@ void Ditches::freeDocumentDitch(DocumentDitch* ditch, bool fromTransaction) {
unlink(ditch);
// decrease counter
--_numDocumentDitches;
--_numMMFilesDocumentMMFilesDitches;
}
delete ditch;
}
/// @brief creates a new document ditch and links it
DocumentDitch* Ditches::createDocumentDitch(bool usedByTransaction,
MMFilesDocumentDitch* MMFilesDitches::createMMFilesDocumentDitch(bool usedByTransaction,
char const* filename, int line) {
try {
auto ditch = new DocumentDitch(this, usedByTransaction, filename, line);
auto ditch = new MMFilesDocumentDitch(this, usedByTransaction, filename, line);
link(ditch);
return ditch;
@ -315,10 +315,10 @@ DocumentDitch* Ditches::createDocumentDitch(bool usedByTransaction,
}
/// @brief creates a new replication ditch and links it
ReplicationDitch* Ditches::createReplicationDitch(char const* filename,
MMFilesReplicationDitch* MMFilesDitches::createMMFilesReplicationDitch(char const* filename,
int line) {
try {
auto ditch = new ReplicationDitch(this, filename, line);
auto ditch = new MMFilesReplicationDitch(this, filename, line);
link(ditch);
return ditch;
@ -328,10 +328,10 @@ ReplicationDitch* Ditches::createReplicationDitch(char const* filename,
}
/// @brief creates a new compaction ditch and links it
CompactionDitch* Ditches::createCompactionDitch(char const* filename,
MMFilesCompactionDitch* MMFilesDitches::createMMFilesCompactionDitch(char const* filename,
int line) {
try {
auto ditch = new CompactionDitch(this, filename, line);
auto ditch = new MMFilesCompactionDitch(this, filename, line);
link(ditch);
return ditch;
@ -341,13 +341,13 @@ CompactionDitch* Ditches::createCompactionDitch(char const* filename,
}
/// @brief creates a new datafile deletion ditch
DropDatafileDitch* Ditches::createDropDatafileDitch(
MMFilesDropDatafileDitch* MMFilesDitches::createMMFilesDropDatafileDitch(
MMFilesDatafile* datafile, LogicalCollection* collection,
std::function<void(MMFilesDatafile*, LogicalCollection*)> const& callback,
char const* filename, int line) {
try {
auto ditch =
new DropDatafileDitch(this, datafile, collection, callback, filename, line);
new MMFilesDropDatafileDitch(this, datafile, collection, callback, filename, line);
link(ditch);
return ditch;
@ -357,13 +357,13 @@ DropDatafileDitch* Ditches::createDropDatafileDitch(
}
/// @brief creates a new datafile rename ditch
RenameDatafileDitch* Ditches::createRenameDatafileDitch(
MMFilesRenameDatafileDitch* MMFilesDitches::createMMFilesRenameDatafileDitch(
MMFilesDatafile* datafile, MMFilesDatafile* compactor, LogicalCollection* collection,
std::function<void(MMFilesDatafile*, MMFilesDatafile*, LogicalCollection*)> const& callback,
char const* filename, int line) {
try {
auto ditch =
new RenameDatafileDitch(this, datafile, compactor, collection, callback, filename, line);
new MMFilesRenameDatafileDitch(this, datafile, compactor, collection, callback, filename, line);
link(ditch);
return ditch;
@ -373,12 +373,12 @@ RenameDatafileDitch* Ditches::createRenameDatafileDitch(
}
/// @brief creates a new collection unload ditch
UnloadCollectionDitch* Ditches::createUnloadCollectionDitch(
MMFilesUnloadCollectionDitch* MMFilesDitches::createMMFilesUnloadCollectionDitch(
LogicalCollection* collection,
std::function<bool(LogicalCollection*)> const& callback,
char const* filename, int line) {
try {
auto ditch = new UnloadCollectionDitch(this, collection, callback,
auto ditch = new MMFilesUnloadCollectionDitch(this, collection, callback,
filename, line);
link(ditch);
@ -389,12 +389,12 @@ UnloadCollectionDitch* Ditches::createUnloadCollectionDitch(
}
/// @brief creates a new datafile drop ditch
DropCollectionDitch* Ditches::createDropCollectionDitch(
MMFilesDropCollectionDitch* MMFilesDitches::createMMFilesDropCollectionDitch(
arangodb::LogicalCollection* collection,
std::function<bool(arangodb::LogicalCollection*)> callback,
char const* filename, int line) {
try {
auto ditch = new DropCollectionDitch(this, collection, callback,
auto ditch = new MMFilesDropCollectionDitch(this, collection, callback,
filename, line);
link(ditch);
@ -405,13 +405,13 @@ DropCollectionDitch* Ditches::createDropCollectionDitch(
}
/// @brief inserts the ditch into the linked list of ditches
void Ditches::link(Ditch* ditch) {
void MMFilesDitches::link(MMFilesDitch* ditch) {
TRI_ASSERT(ditch != nullptr);
ditch->_next = nullptr;
ditch->_prev = nullptr;
bool const isDocumentDitch = (ditch->type() == Ditch::TRI_DITCH_DOCUMENT);
bool const isMMFilesDocumentDitch = (ditch->type() == MMFilesDitch::TRI_DITCH_DOCUMENT);
MUTEX_LOCKER(mutexLocker, _lock); // FIX_MUTEX
@ -428,14 +428,14 @@ void Ditches::link(Ditch* ditch) {
_end = ditch;
if (isDocumentDitch) {
if (isMMFilesDocumentDitch) {
// increase counter
++_numDocumentDitches;
++_numMMFilesDocumentMMFilesDitches;
}
}
/// @brief unlinks the ditch from the linked list of ditches
void Ditches::unlink(Ditch* ditch) {
void MMFilesDitches::unlink(MMFilesDitch* ditch) {
// ditch is at the beginning of the chain
if (ditch->_prev == nullptr) {
_begin = ditch->_next;

View File

@ -32,19 +32,19 @@ struct MMFilesDatafile;
namespace arangodb {
class LogicalCollection;
class Ditches;
class MMFilesDitches;
class Ditch {
friend class Ditches;
class MMFilesDitch {
friend class MMFilesDitches;
protected:
Ditch(Ditch const&) = delete;
Ditch& operator=(Ditch const&) = delete;
MMFilesDitch(MMFilesDitch const&) = delete;
MMFilesDitch& operator=(MMFilesDitch const&) = delete;
Ditch(Ditches*, char const*, int);
MMFilesDitch(MMFilesDitches*, char const*, int);
public:
virtual ~Ditch();
virtual ~MMFilesDitch();
public:
/// @brief ditch type
@ -72,33 +72,33 @@ class Ditch {
int line() const { return _line; }
/// @brief return the next ditch in the linked list
inline Ditch* next() const { return _next; }
inline MMFilesDitch* next() const { return _next; }
/// @brief return the link to all ditches
Ditches* ditches() { return _ditches; }
MMFilesDitches* ditches() { return _ditches; }
/// @brief return the associated collection
LogicalCollection* collection() const;
protected:
Ditches* _ditches;
MMFilesDitches* _ditches;
private:
Ditch* _prev;
Ditch* _next;
MMFilesDitch* _prev;
MMFilesDitch* _next;
char const* _filename;
int _line;
};
/// @brief document ditch
class DocumentDitch final : public Ditch {
friend class Ditches;
class MMFilesDocumentDitch final : public MMFilesDitch {
friend class MMFilesDitches;
public:
DocumentDitch(Ditches* ditches, bool usedByTransaction, char const* filename,
MMFilesDocumentDitch(MMFilesDitches* ditches, bool usedByTransaction, char const* filename,
int line);
~DocumentDitch();
~MMFilesDocumentDitch();
public:
DitchType type() const override final { return TRI_DITCH_DOCUMENT; }
@ -112,11 +112,11 @@ class DocumentDitch final : public Ditch {
};
/// @brief replication ditch
class ReplicationDitch final : public Ditch {
class MMFilesReplicationDitch final : public MMFilesDitch {
public:
ReplicationDitch(Ditches* ditches, char const* filename, int line);
MMFilesReplicationDitch(MMFilesDitches* ditches, char const* filename, int line);
~ReplicationDitch();
~MMFilesReplicationDitch();
public:
DitchType type() const override final { return TRI_DITCH_REPLICATION; }
@ -125,11 +125,11 @@ class ReplicationDitch final : public Ditch {
};
/// @brief compaction ditch
class CompactionDitch final : public Ditch {
class MMFilesCompactionDitch final : public MMFilesDitch {
public:
CompactionDitch(Ditches* ditches, char const* filename, int line);
MMFilesCompactionDitch(MMFilesDitches* ditches, char const* filename, int line);
~CompactionDitch();
~MMFilesCompactionDitch();
public:
DitchType type() const override final { return TRI_DITCH_COMPACTION; }
@ -138,14 +138,14 @@ class CompactionDitch final : public Ditch {
};
/// @brief datafile removal ditch
class DropDatafileDitch final : public Ditch {
class MMFilesDropDatafileDitch final : public MMFilesDitch {
public:
DropDatafileDitch(Ditches* ditches, MMFilesDatafile* datafile,
MMFilesDropDatafileDitch(MMFilesDitches* ditches, MMFilesDatafile* datafile,
LogicalCollection* collection,
std::function<void(MMFilesDatafile*, LogicalCollection*)> const& callback,
char const* filename, int line);
~DropDatafileDitch();
~MMFilesDropDatafileDitch();
public:
DitchType type() const override final { return TRI_DITCH_DATAFILE_DROP; }
@ -161,14 +161,14 @@ class DropDatafileDitch final : public Ditch {
};
/// @brief datafile rename ditch
class RenameDatafileDitch final : public Ditch {
class MMFilesRenameDatafileDitch final : public MMFilesDitch {
public:
RenameDatafileDitch(Ditches* ditches, MMFilesDatafile* datafile,
MMFilesRenameDatafileDitch(MMFilesDitches* ditches, MMFilesDatafile* datafile,
MMFilesDatafile* compactor, LogicalCollection* collection,
std::function<void(MMFilesDatafile*, MMFilesDatafile*, LogicalCollection*)> const& callback,
char const* filename, int line);
~RenameDatafileDitch();
~MMFilesRenameDatafileDitch();
public:
DitchType type() const override final { return TRI_DITCH_DATAFILE_RENAME; }
@ -185,14 +185,14 @@ class RenameDatafileDitch final : public Ditch {
};
/// @brief collection unload ditch
class UnloadCollectionDitch final : public Ditch {
class MMFilesUnloadCollectionDitch final : public MMFilesDitch {
public:
UnloadCollectionDitch(
Ditches* ditches, LogicalCollection* collection,
MMFilesUnloadCollectionDitch(
MMFilesDitches* ditches, LogicalCollection* collection,
std::function<bool(LogicalCollection*)> const& callback,
char const* filename, int line);
~UnloadCollectionDitch();
~MMFilesUnloadCollectionDitch();
DitchType type() const override final { return TRI_DITCH_COLLECTION_UNLOAD; }
@ -206,14 +206,14 @@ class UnloadCollectionDitch final : public Ditch {
};
/// @brief collection drop ditch
class DropCollectionDitch final : public Ditch {
class MMFilesDropCollectionDitch final : public MMFilesDitch {
public:
DropCollectionDitch(
arangodb::Ditches* ditches, arangodb::LogicalCollection* collection,
MMFilesDropCollectionDitch(
arangodb::MMFilesDitches* ditches, arangodb::LogicalCollection* collection,
std::function<bool(arangodb::LogicalCollection*)> callback,
char const* filename, int line);
~DropCollectionDitch();
~MMFilesDropCollectionDitch();
DitchType type() const override final { return TRI_DITCH_COLLECTION_DROP; }
@ -227,14 +227,14 @@ class DropCollectionDitch final : public Ditch {
};
/// @brief doubly linked list of ditches
class Ditches {
class MMFilesDitches {
public:
Ditches(Ditches const&) = delete;
Ditches& operator=(Ditches const&) = delete;
Ditches() = delete;
MMFilesDitches(MMFilesDitches const&) = delete;
MMFilesDitches& operator=(MMFilesDitches const&) = delete;
MMFilesDitches() = delete;
explicit Ditches(LogicalCollection*);
~Ditches();
explicit MMFilesDitches(LogicalCollection*);
~MMFilesDitches();
public:
/// @brief destroy the ditches - to be called on shutdown only
@ -248,75 +248,75 @@ class Ditches {
/// @brief process the first element from the list
/// the list will remain unchanged if the first element is either a
/// DocumentDitch, a ReplicationDitch or a CompactionDitch, or if the list
/// contains any DocumentDitches.
Ditch* process(bool&, std::function<bool(Ditch const*)>);
/// MMFilesDocumentDitch, a MMFilesReplicationDitch or a MMFilesCompactionDitch, or if the list
/// contains any MMFilesDocumentMMFilesDitches.
MMFilesDitch* process(bool&, std::function<bool(MMFilesDitch const*)>);
/// @brief return the type name of the ditch at the head of the active ditches
char const* head();
/// @brief return the number of document ditches active
uint64_t numDocumentDitches();
uint64_t numMMFilesDocumentMMFilesDitches();
/// @brief check whether the ditches contain a ditch of a certain type
bool contains(Ditch::DitchType);
bool contains(MMFilesDitch::DitchType);
/// @brief unlinks and frees a ditch
void freeDitch(Ditch*);
void freeDitch(MMFilesDitch*);
/// @brief unlinks and frees a document ditch
/// this is used for ditches used by transactions or by externals to protect
/// the flags by the lock
void freeDocumentDitch(DocumentDitch*, bool fromTransaction);
void freeMMFilesDocumentDitch(MMFilesDocumentDitch*, bool fromTransaction);
/// @brief creates a new document ditch and links it
DocumentDitch* createDocumentDitch(bool usedByTransaction,
MMFilesDocumentDitch* createMMFilesDocumentDitch(bool usedByTransaction,
char const* filename, int line);
/// @brief creates a new replication ditch and links it
ReplicationDitch* createReplicationDitch(char const* filename, int line);
MMFilesReplicationDitch* createMMFilesReplicationDitch(char const* filename, int line);
/// @brief creates a new compaction ditch and links it
CompactionDitch* createCompactionDitch(char const* filename, int line);
MMFilesCompactionDitch* createMMFilesCompactionDitch(char const* filename, int line);
/// @brief creates a new datafile deletion ditch
DropDatafileDitch* createDropDatafileDitch(
MMFilesDropDatafileDitch* createMMFilesDropDatafileDitch(
MMFilesDatafile* datafile, LogicalCollection* collection,
std::function<void(MMFilesDatafile*, LogicalCollection*)> const& callback,
char const* filename, int line);
/// @brief creates a new datafile rename ditch
RenameDatafileDitch* createRenameDatafileDitch(
MMFilesRenameDatafileDitch* createMMFilesRenameDatafileDitch(
MMFilesDatafile* datafile, MMFilesDatafile* compactor, LogicalCollection* collection,
std::function<void(MMFilesDatafile*, MMFilesDatafile*, LogicalCollection*)> const& callback,
char const* filename, int line);
/// @brief creates a new collection unload ditch
UnloadCollectionDitch* createUnloadCollectionDitch(
MMFilesUnloadCollectionDitch* createMMFilesUnloadCollectionDitch(
LogicalCollection* collection,
std::function<bool(LogicalCollection*)> const& callback,
char const* filename, int line);
/// @brief creates a new collection drop ditch
DropCollectionDitch* createDropCollectionDitch(
MMFilesDropCollectionDitch* createMMFilesDropCollectionDitch(
arangodb::LogicalCollection* collection,
std::function<bool(arangodb::LogicalCollection*)> callback,
char const* filename, int line);
private:
/// @brief inserts the ditch into the linked list of ditches
void link(Ditch*);
void link(MMFilesDitch*);
/// @brief unlinks the ditch from the linked list of ditches
void unlink(Ditch*);
void unlink(MMFilesDitch*);
private:
LogicalCollection* _collection;
arangodb::Mutex _lock;
Ditch* _begin;
Ditch* _end;
uint64_t _numDocumentDitches;
MMFilesDitch* _begin;
MMFilesDitch* _end;
uint64_t _numMMFilesDocumentMMFilesDitches;
};
}

View File

@ -2220,7 +2220,7 @@ char* MMFilesEngine::nextFreeMarkerPosition(
// the compactor will not run during recovery
auto ditch = arangodb::MMFilesCollection::toMMFilesCollection(collection)
->ditches()
->createDocumentDitch(false, __FILE__, __LINE__);
->createMMFilesDocumentDitch(false, __FILE__, __LINE__);
if (ditch == nullptr) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY);

View File

@ -1038,7 +1038,7 @@ int InitialSyncer::handleSyncKeys(arangodb::LogicalCollection* col,
// fetch all local keys from primary index
std::vector<uint8_t const*> markers;
DocumentDitch* ditch = nullptr;
MMFilesDocumentDitch* ditch = nullptr;
// acquire a replication ditch so no datafiles are thrown away from now on
// note: the ditch also protects against unloading the collection
@ -1054,7 +1054,7 @@ int InitialSyncer::handleSyncKeys(arangodb::LogicalCollection* col,
ditch = arangodb::MMFilesCollection::toMMFilesCollection(col)
->ditches()
->createDocumentDitch(false, __FILE__, __LINE__);
->createMMFilesDocumentDitch(false, __FILE__, __LINE__);
if (ditch == nullptr) {
return TRI_ERROR_OUT_OF_MEMORY;

View File

@ -55,7 +55,7 @@ CollectionExport::CollectionExport(TRI_vocbase_t* vocbase,
CollectionExport::~CollectionExport() {
if (_ditch != nullptr) {
_ditch->ditches()->freeDocumentDitch(_ditch, false);
_ditch->ditches()->freeMMFilesDocumentDitch(_ditch, false);
}
}
@ -67,7 +67,7 @@ void CollectionExport::run(uint64_t maxWaitTime, size_t limit) {
// create a ditch under the compaction lock
_ditch = arangodb::MMFilesCollection::toMMFilesCollection(_collection)
->ditches()
->createDocumentDitch(false, __FILE__, __LINE__);
->createMMFilesDocumentDitch(false, __FILE__, __LINE__);
});
// now we either have a ditch or not

View File

@ -34,7 +34,7 @@ struct TRI_vocbase_t;
namespace arangodb {
class CollectionGuard;
class DocumentDitch;
class MMFilesDocumentDitch;
class CollectionExport {
friend class ExportCursor;
@ -63,7 +63,7 @@ class CollectionExport {
private:
std::unique_ptr<arangodb::CollectionGuard> _guard;
LogicalCollection* _collection;
arangodb::DocumentDitch* _ditch;
arangodb::MMFilesDocumentDitch* _ditch;
std::string const _name;
arangodb::CollectionNameResolver _resolver;
Restrictions _restrictions;

View File

@ -74,7 +74,7 @@ CollectionKeys::~CollectionKeys() {
engine->removeCompactionBlocker(_vocbase, _blockerId);
if (_ditch != nullptr) {
_ditch->ditches()->freeDocumentDitch(_ditch, false);
_ditch->ditches()->freeMMFilesDocumentDitch(_ditch, false);
}
}
@ -91,7 +91,7 @@ void CollectionKeys::create(TRI_voc_tick_t maxTick) {
// create a ditch under the compaction lock
_ditch = arangodb::MMFilesCollection::toMMFilesCollection(_collection)
->ditches()
->createDocumentDitch(false, __FILE__, __LINE__);
->createMMFilesDocumentDitch(false, __FILE__, __LINE__);
});
// now we either have a ditch or not

View File

@ -41,7 +41,7 @@ class Slice;
}
class CollectionGuard;
class DocumentDitch;
class MMFilesDocumentDitch;
typedef TRI_voc_tick_t CollectionKeysId;
@ -115,7 +115,7 @@ class CollectionKeys {
TRI_vocbase_t* _vocbase;
std::unique_ptr<arangodb::CollectionGuard> _guard;
arangodb::LogicalCollection* _collection;
arangodb::DocumentDitch* _ditch;
arangodb::MMFilesDocumentDitch* _ditch;
std::string const _name;
arangodb::CollectionNameResolver _resolver;
TRI_voc_tick_t _blockerId;

View File

@ -30,7 +30,7 @@
#include "VocBase/voc-types.h"
namespace arangodb {
class DocumentDitch;
class MMFilesDocumentDitch;
class TransactionContext;
class SingleCollectionTransaction final : public transaction::Methods {

View File

@ -88,7 +88,7 @@ TransactionContext::~TransactionContext() {
for (auto& it : _ditches) {
// we're done with this ditch
auto& ditch = it.second;
ditch->ditches()->freeDocumentDitch(ditch, true /* fromTransaction */);
ditch->ditches()->freeMMFilesDocumentDitch(ditch, true /* fromTransaction */);
// If some external entity is still using the ditch, it is kept!
}
@ -124,7 +124,7 @@ void TransactionContext::pinData(LogicalCollection* collection) {
}
// this method will not throw, but may return a nullptr
auto ditch = arangodb::MMFilesCollection::toMMFilesCollection(collection)->ditches()->createDocumentDitch(true, __FILE__, __LINE__);
auto ditch = arangodb::MMFilesCollection::toMMFilesCollection(collection)->ditches()->createMMFilesDocumentDitch(true, __FILE__, __LINE__);
if (ditch == nullptr) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY);
@ -134,7 +134,7 @@ void TransactionContext::pinData(LogicalCollection* collection) {
_ditches.emplace(cid, ditch);
}
catch (...) {
ditch->ditches()->freeDocumentDitch(ditch, true);
ditch->ditches()->freeMMFilesDocumentDitch(ditch, true);
throw;
}
}

View File

@ -25,7 +25,6 @@
#define ARANGOD_UTILS_TRANSACTION_CONTEXT_H 1
#include "Basics/Common.h"
#include "Basics/Mutex.h"
#include "Basics/SmallVector.h"
#include "VocBase/voc-types.h"
@ -49,7 +48,7 @@ class Methods;
class CollectionNameResolver;
class DocumentDitch;
class MMFilesDocumentDitch;
class LogicalCollection;
class TransactionState;
@ -136,7 +135,7 @@ class TransactionContext {
std::shared_ptr<velocypack::CustomTypeHandler> _customTypeHandler;
std::unordered_map<TRI_voc_cid_t, DocumentDitch*> _ditches;
std::unordered_map<TRI_voc_cid_t, MMFilesDocumentDitch*> _ditches;
SmallVector<arangodb::velocypack::Builder*, 32>::allocator_type::arena_type _arena;
SmallVector<arangodb::velocypack::Builder*, 32> _builders;

View File

@ -608,7 +608,7 @@ int TRI_DumpCollectionReplication(TRI_replication_dump_t* dump,
auto mmfiles = arangodb::MMFilesCollection::toMMFilesCollection(collection);
// create a barrier so the underlying collection is not unloaded
auto b = mmfiles->ditches()->createReplicationDitch(__FILE__, __LINE__);
auto b = mmfiles->ditches()->createMMFilesReplicationDitch(__FILE__, __LINE__);
if (b == nullptr) {
return TRI_ERROR_OUT_OF_MEMORY;

View File

@ -269,9 +269,9 @@ bool TRI_vocbase_t::UnloadCollectionCallback(LogicalCollection* collection) {
auto ditches =
arangodb::MMFilesCollection::toMMFilesCollection(collection)->ditches();
if (ditches->contains(arangodb::Ditch::TRI_DITCH_DOCUMENT) ||
ditches->contains(arangodb::Ditch::TRI_DITCH_REPLICATION) ||
ditches->contains(arangodb::Ditch::TRI_DITCH_COMPACTION)) {
if (ditches->contains(arangodb::MMFilesDitch::TRI_DITCH_DOCUMENT) ||
ditches->contains(arangodb::MMFilesDitch::TRI_DITCH_REPLICATION) ||
ditches->contains(arangodb::MMFilesDitch::TRI_DITCH_COMPACTION)) {
locker.unlock();
// still some ditches left...
@ -433,7 +433,7 @@ int TRI_vocbase_t::loadCollection(arangodb::LogicalCollection* collection,
// check if there is a deferred drop action going on for this collection
if (arangodb::MMFilesCollection::toMMFilesCollection(collection)
->ditches()
->contains(arangodb::Ditch::TRI_DITCH_COLLECTION_DROP)) {
->contains(arangodb::MMFilesDitch::TRI_DITCH_COLLECTION_DROP)) {
// drop call going on, we must abort
locker.unlock();
@ -1000,7 +1000,7 @@ int TRI_vocbase_t::unloadCollection(arangodb::LogicalCollection* collection, boo
// add callback for unload
arangodb::MMFilesCollection::toMMFilesCollection(collection)
->ditches()
->createUnloadCollectionDitch(collection, UnloadCollectionCallback,
->createMMFilesUnloadCollectionDitch(collection, UnloadCollectionCallback,
__FILE__, __LINE__);
} // release locks
@ -1040,7 +1040,7 @@ int TRI_vocbase_t::dropCollection(arangodb::LogicalCollection* collection, bool
// add callback for dropping
arangodb::MMFilesCollection::toMMFilesCollection(collection)
->ditches()
->createDropCollectionDitch(collection, DropCollectionCallback,
->createMMFilesDropCollectionDitch(collection, DropCollectionCallback,
__FILE__, __LINE__);
// wake up the cleanup thread