You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
clang format apply
This commit is contained in:
@ -38,9 +38,9 @@ using namespace boost;
|
||||
|
||||
namespace
|
||||
{
|
||||
oam::OamCache* oamCache = nullptr;
|
||||
boost::mutex cacheLock;
|
||||
}
|
||||
oam::OamCache* oamCache = nullptr;
|
||||
boost::mutex cacheLock;
|
||||
} // namespace
|
||||
|
||||
namespace oam
|
||||
{
|
||||
@ -48,209 +48,213 @@ std::atomic_bool hasOAMCache{false};
|
||||
|
||||
OamCache* OamCache::makeOamCache()
|
||||
{
|
||||
if (!hasOAMCache.load(std::memory_order_relaxed))
|
||||
if (!hasOAMCache.load(std::memory_order_relaxed))
|
||||
{
|
||||
boost::mutex::scoped_lock lk(cacheLock);
|
||||
|
||||
if (oamCache == nullptr)
|
||||
{
|
||||
boost::mutex::scoped_lock lk(cacheLock);
|
||||
|
||||
if (oamCache == nullptr)
|
||||
{
|
||||
oamCache = new OamCache();
|
||||
oamCache->checkReload();
|
||||
hasOAMCache.store(true, std::memory_order_relaxed);
|
||||
}
|
||||
oamCache = new OamCache();
|
||||
oamCache->checkReload();
|
||||
hasOAMCache.store(true, std::memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
return oamCache;
|
||||
return oamCache;
|
||||
}
|
||||
|
||||
OamCache::OamCache() : mtime(0), mLocalPMId(0)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
OamCache::~OamCache()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void OamCache::checkReload()
|
||||
{
|
||||
Oam oam;
|
||||
config::Config* config = config::Config::makeConfig();
|
||||
int temp;
|
||||
Oam oam;
|
||||
config::Config* config = config::Config::makeConfig();
|
||||
int temp;
|
||||
|
||||
if (config->getCurrentMTime() == mtime)
|
||||
return;
|
||||
if (config->getCurrentMTime() == mtime)
|
||||
return;
|
||||
|
||||
dbroots.clear();
|
||||
oam.getSystemDbrootConfig(dbroots);
|
||||
dbroots.clear();
|
||||
oam.getSystemDbrootConfig(dbroots);
|
||||
|
||||
string txt = config->getConfig("SystemConfig", "DBRootCount");
|
||||
mtime = config->getLastMTime(); // get 'last' after the first access; quicker than 'current'
|
||||
idbassert(txt != "");
|
||||
numDBRoots = config->fromText(txt);
|
||||
string txt = config->getConfig("SystemConfig", "DBRootCount");
|
||||
mtime = config->getLastMTime(); // get 'last' after the first access; quicker than 'current'
|
||||
idbassert(txt != "");
|
||||
numDBRoots = config->fromText(txt);
|
||||
|
||||
dbRootPMMap.reset(new map<int, int>());
|
||||
dbRootPMMap.reset(new map<int, int>());
|
||||
|
||||
//cerr << "reloading oamcache\n";
|
||||
for (uint32_t i = 0; i < dbroots.size(); i++)
|
||||
{
|
||||
oam.getDbrootPmConfig(dbroots[i], temp);
|
||||
//cout << " dbroot " << dbroots[i] << " -> PM " << temp << endl;
|
||||
(*dbRootPMMap)[dbroots[i]] = temp;
|
||||
}
|
||||
// cerr << "reloading oamcache\n";
|
||||
for (uint32_t i = 0; i < dbroots.size(); i++)
|
||||
{
|
||||
oam.getDbrootPmConfig(dbroots[i], temp);
|
||||
// cout << " dbroot " << dbroots[i] << " -> PM " << temp << endl;
|
||||
(*dbRootPMMap)[dbroots[i]] = temp;
|
||||
}
|
||||
|
||||
ModuleTypeConfig moduletypeconfig;
|
||||
std::set<int> uniquePids;
|
||||
oam.getSystemConfig("pm", moduletypeconfig);
|
||||
int moduleID = 0;
|
||||
ModuleTypeConfig moduletypeconfig;
|
||||
std::set<int> uniquePids;
|
||||
oam.getSystemConfig("pm", moduletypeconfig);
|
||||
int moduleID = 0;
|
||||
|
||||
for (unsigned i = 0; i < moduletypeconfig.ModuleCount; i++)
|
||||
{
|
||||
moduleID = atoi((moduletypeconfig.ModuleNetworkList[i]).DeviceName.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE).c_str());
|
||||
uniquePids.insert(moduleID);
|
||||
}
|
||||
for (unsigned i = 0; i < moduletypeconfig.ModuleCount; i++)
|
||||
{
|
||||
moduleID = atoi((moduletypeconfig.ModuleNetworkList[i])
|
||||
.DeviceName.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE)
|
||||
.c_str());
|
||||
uniquePids.insert(moduleID);
|
||||
}
|
||||
|
||||
std::set<int>::const_iterator it = uniquePids.begin();
|
||||
moduleIds.clear();
|
||||
uint32_t i = 0;
|
||||
map<int, int> pmToConnectionMap;
|
||||
std::set<int>::const_iterator it = uniquePids.begin();
|
||||
moduleIds.clear();
|
||||
uint32_t i = 0;
|
||||
map<int, int> pmToConnectionMap;
|
||||
#ifdef _MSC_VER
|
||||
moduleIds.push_back(*it);
|
||||
pmToConnectionMap[*it] = i++;
|
||||
moduleIds.push_back(*it);
|
||||
pmToConnectionMap[*it] = i++;
|
||||
#else
|
||||
|
||||
// Restore for Windows when we support multiple PMs
|
||||
while (it != uniquePids.end())
|
||||
{
|
||||
pmToConnectionMap[*it] = i++;
|
||||
moduleIds.push_back(*it);
|
||||
it++;
|
||||
}
|
||||
// Restore for Windows when we support multiple PMs
|
||||
while (it != uniquePids.end())
|
||||
{
|
||||
pmToConnectionMap[*it] = i++;
|
||||
moduleIds.push_back(*it);
|
||||
it++;
|
||||
}
|
||||
|
||||
#endif
|
||||
dbRootConnectionMap.reset(new map<int, int>());
|
||||
dbRootConnectionMap.reset(new map<int, int>());
|
||||
|
||||
for (i = 0; i < dbroots.size(); i++)
|
||||
for (i = 0; i < dbroots.size(); i++)
|
||||
{
|
||||
map<int, int>::iterator pmIter = pmToConnectionMap.find((*dbRootPMMap)[dbroots[i]]);
|
||||
|
||||
if (pmIter != pmToConnectionMap.end())
|
||||
{
|
||||
map<int, int>::iterator pmIter = pmToConnectionMap.find((*dbRootPMMap)[dbroots[i]]);
|
||||
|
||||
if (pmIter != pmToConnectionMap.end())
|
||||
{
|
||||
(*dbRootConnectionMap)[dbroots[i]] = (*pmIter).second;
|
||||
}
|
||||
(*dbRootConnectionMap)[dbroots[i]] = (*pmIter).second;
|
||||
}
|
||||
}
|
||||
|
||||
pmDbrootsMap.reset(new OamCache::PMDbrootsMap_t::element_type());
|
||||
systemStorageInfo_t t;
|
||||
t = oam.getStorageConfig();
|
||||
DeviceDBRootList moduledbrootlist = boost::get<2>(t);
|
||||
DeviceDBRootList::iterator pt = moduledbrootlist.begin();
|
||||
pmDbrootsMap.reset(new OamCache::PMDbrootsMap_t::element_type());
|
||||
systemStorageInfo_t t;
|
||||
t = oam.getStorageConfig();
|
||||
DeviceDBRootList moduledbrootlist = boost::get<2>(t);
|
||||
DeviceDBRootList::iterator pt = moduledbrootlist.begin();
|
||||
|
||||
for ( ; pt != moduledbrootlist.end() ; pt++)
|
||||
for (; pt != moduledbrootlist.end(); pt++)
|
||||
{
|
||||
moduleID = (*pt).DeviceID;
|
||||
DBRootConfigList::iterator pt1 = (*pt).dbrootConfigList.begin();
|
||||
|
||||
for (; pt1 != (*pt).dbrootConfigList.end(); pt1++)
|
||||
{
|
||||
moduleID = (*pt).DeviceID;
|
||||
DBRootConfigList::iterator pt1 = (*pt).dbrootConfigList.begin();
|
||||
|
||||
for ( ; pt1 != (*pt).dbrootConfigList.end(); pt1++)
|
||||
{
|
||||
(*pmDbrootsMap)[moduleID].push_back(*pt1);
|
||||
}
|
||||
(*pmDbrootsMap)[moduleID].push_back(*pt1);
|
||||
}
|
||||
}
|
||||
|
||||
oamModuleInfo_t tm;
|
||||
tm = oam.getModuleInfo();
|
||||
OAMParentModuleName = boost::get<3>(tm);
|
||||
systemName = config->getConfig("SystemConfig", "SystemName");
|
||||
oamModuleInfo_t tm;
|
||||
tm = oam.getModuleInfo();
|
||||
OAMParentModuleName = boost::get<3>(tm);
|
||||
systemName = config->getConfig("SystemConfig", "SystemName");
|
||||
}
|
||||
|
||||
OamCache::dbRootPMMap_t OamCache::getDBRootToPMMap()
|
||||
{
|
||||
return dbRootPMMap;
|
||||
return dbRootPMMap;
|
||||
}
|
||||
|
||||
OamCache::dbRootPMMap_t OamCache::getDBRootToConnectionMap()
|
||||
{
|
||||
return dbRootConnectionMap;
|
||||
return dbRootConnectionMap;
|
||||
}
|
||||
|
||||
OamCache::PMDbrootsMap_t OamCache::getPMToDbrootsMap()
|
||||
{
|
||||
return pmDbrootsMap;
|
||||
return pmDbrootsMap;
|
||||
}
|
||||
|
||||
uint32_t OamCache::getDBRootCount()
|
||||
{
|
||||
return numDBRoots;
|
||||
return numDBRoots;
|
||||
}
|
||||
|
||||
DBRootConfigList& OamCache::getDBRootNums()
|
||||
{
|
||||
return dbroots;
|
||||
return dbroots;
|
||||
}
|
||||
|
||||
std::vector<int>& OamCache::getModuleIds()
|
||||
{
|
||||
return moduleIds;
|
||||
return moduleIds;
|
||||
}
|
||||
|
||||
std::string OamCache::getOAMParentModuleName()
|
||||
{
|
||||
return OAMParentModuleName;
|
||||
return OAMParentModuleName;
|
||||
}
|
||||
|
||||
int OamCache::getLocalPMId()
|
||||
{
|
||||
// This comes from the file /var/lib/columnstore/local/module, not from the xml.
|
||||
// Thus, it's not refreshed during checkReload().
|
||||
if (mLocalPMId > 0)
|
||||
{
|
||||
return mLocalPMId;
|
||||
}
|
||||
|
||||
string localModule;
|
||||
string moduleType;
|
||||
string fileName = "/var/lib/columnstore/local/module";
|
||||
ifstream moduleFile (fileName.c_str());
|
||||
char line[400];
|
||||
|
||||
while (moduleFile.getline(line, 400))
|
||||
{
|
||||
localModule = line;
|
||||
break;
|
||||
}
|
||||
|
||||
moduleFile.close();
|
||||
|
||||
if (localModule.empty() )
|
||||
{
|
||||
mLocalPMId = 0;
|
||||
return mLocalPMId;
|
||||
}
|
||||
|
||||
moduleType = localModule.substr(0, MAX_MODULE_TYPE_SIZE);
|
||||
mLocalPMId = atoi(localModule.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE).c_str());
|
||||
|
||||
if (moduleType != "pm")
|
||||
{
|
||||
mLocalPMId = 0;
|
||||
}
|
||||
|
||||
// This comes from the file /var/lib/columnstore/local/module, not from the xml.
|
||||
// Thus, it's not refreshed during checkReload().
|
||||
if (mLocalPMId > 0)
|
||||
{
|
||||
return mLocalPMId;
|
||||
}
|
||||
|
||||
string localModule;
|
||||
string moduleType;
|
||||
string fileName = "/var/lib/columnstore/local/module";
|
||||
ifstream moduleFile(fileName.c_str());
|
||||
char line[400];
|
||||
|
||||
while (moduleFile.getline(line, 400))
|
||||
{
|
||||
localModule = line;
|
||||
break;
|
||||
}
|
||||
|
||||
moduleFile.close();
|
||||
|
||||
if (localModule.empty())
|
||||
{
|
||||
mLocalPMId = 0;
|
||||
return mLocalPMId;
|
||||
}
|
||||
|
||||
moduleType = localModule.substr(0, MAX_MODULE_TYPE_SIZE);
|
||||
mLocalPMId = atoi(localModule.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE).c_str());
|
||||
|
||||
if (moduleType != "pm")
|
||||
{
|
||||
mLocalPMId = 0;
|
||||
}
|
||||
|
||||
return mLocalPMId;
|
||||
}
|
||||
|
||||
string OamCache::getSystemName()
|
||||
{
|
||||
return systemName;
|
||||
return systemName;
|
||||
}
|
||||
|
||||
string OamCache::getModuleName()
|
||||
{
|
||||
if (!moduleName.empty())
|
||||
return moduleName;
|
||||
|
||||
string fileName = "/var/lib/columnstore/local/module";
|
||||
ifstream moduleFile(fileName.c_str());
|
||||
getline(moduleFile, moduleName);
|
||||
moduleFile.close();
|
||||
|
||||
if (!moduleName.empty())
|
||||
return moduleName;
|
||||
|
||||
string fileName = "/var/lib/columnstore/local/module";
|
||||
ifstream moduleFile(fileName.c_str());
|
||||
getline(moduleFile, moduleName);
|
||||
moduleFile.close();
|
||||
|
||||
return moduleName;
|
||||
}
|
||||
|
||||
} /* namespace oam */
|
||||
|
Reference in New Issue
Block a user