1
0
Fork 0

refactoring

This commit is contained in:
jsteemann 2016-08-02 14:01:04 +02:00
parent 3664511e36
commit f1596fa459
3 changed files with 17 additions and 13 deletions

View File

@ -150,7 +150,7 @@ void DatabaseManagerThread::run() {
// remove apps directory for database // remove apps directory for database
auto appPath = dealer->appPath(); auto appPath = dealer->appPath();
if (database->_isOwnAppsDirectory && !appPath.empty()) { if (database->isOwnAppsDirectory() && !appPath.empty()) {
path = arangodb::basics::FileUtils::buildFilename( path = arangodb::basics::FileUtils::buildFilename(
arangodb::basics::FileUtils::buildFilename(appPath, "_db"), arangodb::basics::FileUtils::buildFilename(appPath, "_db"),
database->name()); database->name());
@ -687,7 +687,7 @@ int DatabaseFeature::dropDatabase(std::string const& name, bool writeMarker, boo
_databasesProtector.scan(); _databasesProtector.scan();
delete oldLists; delete oldLists;
vocbase->_isOwnAppsDirectory = removeAppsDirectory; vocbase->isOwnAppsDirectory(removeAppsDirectory);
// invalidate all entries for the database // invalidate all entries for the database
arangodb::aql::QueryCache::instance()->invalidate(vocbase); arangodb::aql::QueryCache::instance()->invalidate(vocbase);

View File

@ -1530,10 +1530,11 @@ TRI_vocbase_t::TRI_vocbase_t(TRI_vocbase_type_e type, TRI_voc_tick_t id,
_name(name), _name(name),
_type(type), _type(type),
_refCount(0), _refCount(0),
_isOwnAppsDirectory(true),
_deadlockDetector(false), _deadlockDetector(false),
_userStructures(nullptr), _userStructures(nullptr),
_hasCompactor(false), _hasCompactor(false) {
_isOwnAppsDirectory(true) {
_queries.reset(new arangodb::aql::QueryList(this)); _queries.reset(new arangodb::aql::QueryList(this));
_cursorRepository.reset(new arangodb::CursorRepository(this)); _cursorRepository.reset(new arangodb::CursorRepository(this));
_collectionKeys.reset(new arangodb::CollectionKeysRepository()); _collectionKeys.reset(new arangodb::CollectionKeysRepository());

View File

@ -177,10 +177,8 @@ struct TRI_vocbase_t {
std::string _name; // database name std::string _name; // database name
TRI_vocbase_type_e _type; // type (normal or coordinator) TRI_vocbase_type_e _type; // type (normal or coordinator)
std::atomic<uint64_t> _refCount; std::atomic<uint64_t> _refCount;
public: bool _isOwnAppsDirectory;
arangodb::basics::DeadlockDetector<TRI_collection_t>
_deadlockDetector;
private:
arangodb::basics::ReadWriteLock _collectionsLock; // collection iterator lock arangodb::basics::ReadWriteLock _collectionsLock; // collection iterator lock
std::vector<TRI_vocbase_col_t*> _collections; // pointers to ALL collections std::vector<TRI_vocbase_col_t*> _collections; // pointers to ALL collections
std::vector<TRI_vocbase_col_t*> _deadCollections; // pointers to collections std::vector<TRI_vocbase_col_t*> _deadCollections; // pointers to collections
@ -189,20 +187,22 @@ struct TRI_vocbase_t {
std::unordered_map<std::string, TRI_vocbase_col_t*> _collectionsByName; // collections by name std::unordered_map<std::string, TRI_vocbase_col_t*> _collectionsByName; // collections by name
std::unordered_map<TRI_voc_cid_t, TRI_vocbase_col_t*> _collectionsById; // collections by id std::unordered_map<TRI_voc_cid_t, TRI_vocbase_col_t*> _collectionsById; // collections by id
std::unique_ptr<arangodb::aql::QueryList> _queries;
std::unique_ptr<arangodb::CursorRepository> _cursorRepository;
std::unique_ptr<arangodb::CollectionKeysRepository> _collectionKeys;
public: public:
arangodb::basics::DeadlockDetector<TRI_collection_t>
_deadlockDetector;
arangodb::basics::ReadWriteLock _inventoryLock; // object lock needed when arangodb::basics::ReadWriteLock _inventoryLock; // object lock needed when
// replication is assessing // replication is assessing
// the state of the vocbase // the state of the vocbase
// structures for user-defined volatile data // structures for user-defined volatile data
void* _userStructures; void* _userStructures;
private:
std::unique_ptr<arangodb::aql::QueryList> _queries;
std::unique_ptr<arangodb::CursorRepository> _cursorRepository;
std::unique_ptr<arangodb::CollectionKeysRepository> _collectionKeys;
public: public:
bool _hasCompactor; bool _hasCompactor;
bool _isOwnAppsDirectory;
std::unique_ptr<TRI_replication_applier_t> _replicationApplier; std::unique_ptr<TRI_replication_applier_t> _replicationApplier;
@ -245,6 +245,9 @@ struct TRI_vocbase_t {
arangodb::CursorRepository* cursorRepository() const { return _cursorRepository.get(); } arangodb::CursorRepository* cursorRepository() const { return _cursorRepository.get(); }
arangodb::CollectionKeysRepository* collectionKeys() const { return _collectionKeys.get(); } arangodb::CollectionKeysRepository* collectionKeys() const { return _collectionKeys.get(); }
bool isOwnAppsDirectory() const { return _isOwnAppsDirectory; }
void isOwnAppsDirectory(bool value) { _isOwnAppsDirectory = value; }
/// @brief whether or not the vocbase has been marked as deleted /// @brief whether or not the vocbase has been marked as deleted
inline bool isDropped() const { inline bool isDropped() const {
auto refCount = _refCount.load(); auto refCount = _refCount.load();