From a65c8e454421f74b023e0540eecb6abae3b2be17 Mon Sep 17 00:00:00 2001 From: Patrick LeBlanc Date: Fri, 13 Mar 2020 15:18:55 -0400 Subject: [PATCH] MCOL-3251 Moved the new logic into we_fileop to maintain existing encapsulation. --- primitives/blockcache/iomanager.cpp | 55 +---------------------------- primitives/blockcache/iomanager.h | 6 ---- writeengine/shared/we_fileop.cpp | 23 ++++++++++++ writeengine/shared/we_fileop.h | 6 ++++ 4 files changed, 30 insertions(+), 60 deletions(-) diff --git a/primitives/blockcache/iomanager.cpp b/primitives/blockcache/iomanager.cpp index 92b3fb28f..3aa3f4c09 100644 --- a/primitives/blockcache/iomanager.cpp +++ b/primitives/blockcache/iomanager.cpp @@ -1356,69 +1356,16 @@ ioManager::ioManager(FileBufferMgr& fbm, } fThreadCount = thrCount; - lastConfigMTime = 0; - loadDBRootCache(); go(); } -void ioManager::loadDBRootCache() -{ - if (fConfig->getLastMTime() == lastConfigMTime) - return; - - char buf[100]; - dbRootCache.clear(); - - // this will grab all of the dbroots on the cluster, not just the ones on this node - // for simplicity. - oam::Oam OAM; - oam::DBRootConfigList dbRoots; - OAM.getSystemDbrootConfig(dbRoots); - for (auto _dbroot : dbRoots) - { - sprintf(buf, "DBRoot%d", _dbroot); - string location = fConfig->getConfig("SystemConfig", buf); - dbRootCache[_dbroot] = location; - } -} - void ioManager::buildOidFileName(const BRM::OID_t oid, uint16_t dbRoot, const uint16_t partNum, const uint32_t segNum, char* file_name) { // when it's a request for the version buffer, the dbroot comes in as 0 for legacy reasons if (dbRoot == 0 && oid < 1000) dbRoot = fdbrm.getDBRootOfVBOID(oid); - - boost::unique_lock lock(dbRootCacheLock); - loadDBRootCache(); - string dbRootPath; - auto it = dbRootCache.find(dbRoot); - if (it == dbRootCache.end()) - { - ostringstream oss; - oss << "(dbroot " << dbRoot << " offline)"; - dbRootPath = oss.str(); - } - else - dbRootPath = it->second; - lock.unlock(); - // different filenames for the version buffer files - if (oid < 1000) - snprintf(file_name, WriteEngine::FILE_NAME_SIZE, "%s/versionbuffer.cdf", dbRootPath.c_str()); - else - snprintf(file_name, WriteEngine::FILE_NAME_SIZE, "%s/%03u.dir/%03u.dir/%03u.dir/%03u.dir/%03u.dir/FILE%03d.cdf", - dbRootPath.c_str(), oid >> 24, (oid & 0x00ff0000) >> 16, (oid & 0x0000ff00) >> 8, - oid & 0x000000ff, partNum, segNum); - - - /* old version - if (fFileOp.getFileName(oid, file_name, dbRoot, partNum, segNum) != WriteEngine::NO_ERROR) - { - file_name[0] = 0; - throw std::runtime_error("fileOp.getFileName failed"); - } - //cout << "Oid2Filename o: " << oid << " n: " << file_name << endl; - */ + fFileOp.getFileNameForPrimProc(oid, file_name, dbRoot, partNum, segNum); } const int ioManager::localLbidLookup(BRM::LBID_t lbid, diff --git a/primitives/blockcache/iomanager.h b/primitives/blockcache/iomanager.h index ad09fd0db..eb7a9f1af 100644 --- a/primitives/blockcache/iomanager.h +++ b/primitives/blockcache/iomanager.h @@ -153,12 +153,6 @@ private: uint32_t fDecreaseOpenFilesCount; bool fFDCacheTrace; std::ofstream fFDTraceFile; - - std::map dbRootCache; - boost::mutex dbRootCacheLock; - void loadDBRootCache(); - time_t lastConfigMTime; - }; // @bug2631, for remount filesystem by loadBlock() in primitiveserver diff --git a/writeengine/shared/we_fileop.cpp b/writeengine/shared/we_fileop.cpp index f4c65ed52..d81a1927f 100644 --- a/writeengine/shared/we_fileop.cpp +++ b/writeengine/shared/we_fileop.cpp @@ -2412,6 +2412,29 @@ int FileOp::oid2FileName( FID fid, return NO_ERROR; } +void FileOp::getFileNameForPrimProc(FID fid, + char* fullFileName, + uint16_t dbRoot, + uint32_t partition, + uint16_t segment) const +{ + string dbRootPath = Config::getDBRootByNum(dbRoot); + if (dbRootPath.empty()) + { + ostringstream oss; + oss << "(dbroot " << dbRoot << " offline)"; + dbRootPath = oss.str(); + } + + // different filenames for the version buffer files + if (fid < 1000) + snprintf(fullFileName, FILE_NAME_SIZE, "%s/versionbuffer.cdf", dbRootPath.c_str()); + else + snprintf(fullFileName, FILE_NAME_SIZE, "%s/%03u.dir/%03u.dir/%03u.dir/%03u.dir/%03u.dir/FILE%03d.cdf", + dbRootPath.c_str(), fid >> 24, (fid & 0x00ff0000) >> 16, (fid & 0x0000ff00) >> 8, + fid & 0x000000ff, partition, segment); +} + /*********************************************************** * DESCRIPTION: * Search for directory path associated with specified OID. diff --git a/writeengine/shared/we_fileop.h b/writeengine/shared/we_fileop.h index e7f2fa576..4ddc7513f 100644 --- a/writeengine/shared/we_fileop.h +++ b/writeengine/shared/we_fileop.h @@ -310,6 +310,12 @@ public: uint32_t partition, uint16_t segment ) const; + /* Added for MCOL-3251 */ + void getFileNameForPrimProc(FID fid, char* fileName, + uint16_t dbRoot, + uint32_t partition, + uint16_t segment ) const; + /** * @brief Construct directory path for the specified fid (OID), DBRoot, and * partition number. Directory does not have to exist, nor is it created.