You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
Simpler OAM
This commit is contained in:
@ -36,39 +36,24 @@ using namespace boost;
|
|||||||
#include "installdir.h"
|
#include "installdir.h"
|
||||||
#include "mcsconfig.h"
|
#include "mcsconfig.h"
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
oam::OamCache* oamCache = nullptr;
|
|
||||||
boost::mutex cacheLock;
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace oam
|
namespace oam
|
||||||
{
|
{
|
||||||
std::atomic_bool hasOAMCache{false};
|
|
||||||
|
|
||||||
|
struct CacheReloaded
|
||||||
|
{
|
||||||
|
CacheReloaded()
|
||||||
|
{
|
||||||
|
oamcache.checkReload();
|
||||||
|
}
|
||||||
|
OamCache oamcache;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
OamCache* OamCache::makeOamCache()
|
OamCache* OamCache::makeOamCache()
|
||||||
{
|
{
|
||||||
if (!hasOAMCache.load(std::memory_order_relaxed))
|
static CacheReloaded cache;
|
||||||
{
|
return &cache.oamcache;
|
||||||
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()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OamCache::checkReload()
|
void OamCache::checkReload()
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include "liboamcpp.h"
|
#include "liboamcpp.h"
|
||||||
|
|
||||||
#define EXPORT
|
|
||||||
|
|
||||||
namespace oam
|
namespace oam
|
||||||
{
|
{
|
||||||
@ -35,30 +34,31 @@ class OamCache
|
|||||||
typedef boost::shared_ptr<std::map<int, int> > dbRootPMMap_t;
|
typedef boost::shared_ptr<std::map<int, int> > dbRootPMMap_t;
|
||||||
typedef std::vector<int> dbRoots;
|
typedef std::vector<int> dbRoots;
|
||||||
typedef boost::shared_ptr<std::map<int, dbRoots> > PMDbrootsMap_t;
|
typedef boost::shared_ptr<std::map<int, dbRoots> > PMDbrootsMap_t;
|
||||||
EXPORT virtual ~OamCache();
|
virtual ~OamCache() = default;
|
||||||
|
|
||||||
EXPORT void checkReload();
|
void checkReload();
|
||||||
EXPORT void forceReload()
|
void forceReload()
|
||||||
{
|
{
|
||||||
mtime = 0;
|
mtime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT dbRootPMMap_t getDBRootToPMMap();
|
dbRootPMMap_t getDBRootToPMMap();
|
||||||
EXPORT dbRootPMMap_t getDBRootToConnectionMap();
|
dbRootPMMap_t getDBRootToConnectionMap();
|
||||||
EXPORT PMDbrootsMap_t getPMToDbrootsMap();
|
PMDbrootsMap_t getPMToDbrootsMap();
|
||||||
EXPORT uint32_t getDBRootCount();
|
uint32_t getDBRootCount();
|
||||||
EXPORT DBRootConfigList& getDBRootNums();
|
DBRootConfigList& getDBRootNums();
|
||||||
EXPORT std::vector<int>& getModuleIds();
|
std::vector<int>& getModuleIds();
|
||||||
EXPORT static OamCache* makeOamCache();
|
static OamCache* makeOamCache();
|
||||||
EXPORT std::string getOAMParentModuleName();
|
std::string getOAMParentModuleName();
|
||||||
EXPORT int getLocalPMId(); // return the PM id of this machine.
|
int getLocalPMId(); // return the PM id of this machine.
|
||||||
EXPORT std::string getSystemName();
|
std::string getSystemName();
|
||||||
EXPORT std::string getModuleName();
|
std::string getModuleName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OamCache();
|
friend struct CacheReloaded;
|
||||||
OamCache(const OamCache&);
|
OamCache() = default;
|
||||||
OamCache& operator=(const OamCache&) const;
|
OamCache(const OamCache&) = delete;
|
||||||
|
OamCache& operator=(const OamCache&) const = delete;
|
||||||
|
|
||||||
dbRootPMMap_t dbRootPMMap;
|
dbRootPMMap_t dbRootPMMap;
|
||||||
dbRootPMMap_t dbRootConnectionMap;
|
dbRootPMMap_t dbRootConnectionMap;
|
||||||
@ -75,4 +75,3 @@ class OamCache
|
|||||||
|
|
||||||
} // namespace oam
|
} // namespace oam
|
||||||
|
|
||||||
#undef EXPORT
|
|
||||||
|
@ -116,8 +116,6 @@ bool gPMProfOn = false;
|
|||||||
uint32_t gSession = 0;
|
uint32_t gSession = 0;
|
||||||
dbbc::Stats pmstats(statsName);
|
dbbc::Stats pmstats(statsName);
|
||||||
|
|
||||||
oam::OamCache* oamCache = oam::OamCache::makeOamCache();
|
|
||||||
|
|
||||||
// FIXME: there is an anon ns burried later in between 2 named namespaces...
|
// FIXME: there is an anon ns burried later in between 2 named namespaces...
|
||||||
namespace primitiveprocessor
|
namespace primitiveprocessor
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "columncommand.h"
|
#include "columncommand.h"
|
||||||
#include "blocksize.h"
|
#include "blocksize.h"
|
||||||
|
#include "oamcache.h"
|
||||||
|
|
||||||
namespace primitiveprocessor
|
namespace primitiveprocessor
|
||||||
{
|
{
|
||||||
@ -77,7 +78,7 @@ void PseudoCC::loadSingleValue(W val)
|
|||||||
template <typename W>
|
template <typename W>
|
||||||
void PseudoCC::loadPMNumber()
|
void PseudoCC::loadPMNumber()
|
||||||
{
|
{
|
||||||
uint32_t pmNum = oamCache->getLocalPMId();
|
uint32_t pmNum = oam::OamCache::makeOamCache()->getLocalPMId();
|
||||||
loadSingleValue<W>(pmNum);
|
loadSingleValue<W>(pmNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user