1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-18 21:44:02 +03:00

Simpler OAM

This commit is contained in:
Leonid Fedorov 2023-04-25 18:25:01 +00:00
parent bab29ff495
commit aead012f9f
4 changed files with 33 additions and 50 deletions

View File

@ -36,39 +36,24 @@ using namespace boost;
#include "installdir.h"
#include "mcsconfig.h"
namespace
{
oam::OamCache* oamCache = nullptr;
boost::mutex cacheLock;
} // namespace
namespace oam
{
std::atomic_bool hasOAMCache{false};
struct CacheReloaded
{
CacheReloaded()
{
oamcache.checkReload();
}
OamCache oamcache;
};
OamCache* OamCache::makeOamCache()
{
if (!hasOAMCache.load(std::memory_order_relaxed))
{
boost::mutex::scoped_lock lk(cacheLock);
if (oamCache == nullptr)
{
oamCache = new OamCache();
oamCache->checkReload();
hasOAMCache.store(true, std::memory_order_relaxed);
}
}
return oamCache;
}
OamCache::OamCache() : mtime(0), mLocalPMId(0)
{
}
OamCache::~OamCache()
{
static CacheReloaded cache;
return &cache.oamcache;
}
void OamCache::checkReload()

View File

@ -25,7 +25,6 @@
#include "liboamcpp.h"
#define EXPORT
namespace oam
{
@ -35,30 +34,31 @@ class OamCache
typedef boost::shared_ptr<std::map<int, int> > dbRootPMMap_t;
typedef std::vector<int> dbRoots;
typedef boost::shared_ptr<std::map<int, dbRoots> > PMDbrootsMap_t;
EXPORT virtual ~OamCache();
virtual ~OamCache() = default;
EXPORT void checkReload();
EXPORT void forceReload()
void checkReload();
void forceReload()
{
mtime = 0;
}
EXPORT dbRootPMMap_t getDBRootToPMMap();
EXPORT dbRootPMMap_t getDBRootToConnectionMap();
EXPORT PMDbrootsMap_t getPMToDbrootsMap();
EXPORT uint32_t getDBRootCount();
EXPORT DBRootConfigList& getDBRootNums();
EXPORT std::vector<int>& getModuleIds();
EXPORT static OamCache* makeOamCache();
EXPORT std::string getOAMParentModuleName();
EXPORT int getLocalPMId(); // return the PM id of this machine.
EXPORT std::string getSystemName();
EXPORT std::string getModuleName();
dbRootPMMap_t getDBRootToPMMap();
dbRootPMMap_t getDBRootToConnectionMap();
PMDbrootsMap_t getPMToDbrootsMap();
uint32_t getDBRootCount();
DBRootConfigList& getDBRootNums();
std::vector<int>& getModuleIds();
static OamCache* makeOamCache();
std::string getOAMParentModuleName();
int getLocalPMId(); // return the PM id of this machine.
std::string getSystemName();
std::string getModuleName();
private:
OamCache();
OamCache(const OamCache&);
OamCache& operator=(const OamCache&) const;
friend struct CacheReloaded;
OamCache() = default;
OamCache(const OamCache&) = delete;
OamCache& operator=(const OamCache&) const = delete;
dbRootPMMap_t dbRootPMMap;
dbRootPMMap_t dbRootConnectionMap;
@ -75,4 +75,3 @@ class OamCache
} // namespace oam
#undef EXPORT

View File

@ -116,8 +116,6 @@ bool gPMProfOn = false;
uint32_t gSession = 0;
dbbc::Stats pmstats(statsName);
oam::OamCache* oamCache = oam::OamCache::makeOamCache();
// FIXME: there is an anon ns burried later in between 2 named namespaces...
namespace primitiveprocessor
{

View File

@ -19,6 +19,7 @@
#include "columncommand.h"
#include "blocksize.h"
#include "oamcache.h"
namespace primitiveprocessor
{
@ -77,7 +78,7 @@ void PseudoCC::loadSingleValue(W val)
template <typename W>
void PseudoCC::loadPMNumber()
{
uint32_t pmNum = oamCache->getLocalPMId();
uint32_t pmNum = oam::OamCache::makeOamCache()->getLocalPMId();
loadSingleValue<W>(pmNum);
}