Skip to content

Commit

Permalink
Merge pull request #1 from raghavendra-nataraj/cmake_fix
Browse files Browse the repository at this point in the history
Refactoring config info storage, cmake fix, readme update
  • Loading branch information
juen1jp committed Aug 28, 2019
2 parents 618c375 + 199af38 commit 6b6e70f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ add_custom_target(build

add_custom_target(testbuild
COMMAND ${CMAKE_MAKE_PROGRAM}
COMMAND ${CMAKE_MAKE_PROGRAM} -C tests
COMMAND ${CMAKE_MAKE_PROGRAM} configparsertests
COMMAND ${CMAKE_MAKE_PROGRAM} coretests
COMMAND ${CMAKE_MAKE_PROGRAM} externalio
COMMAND ${CMAKE_MAKE_PROGRAM} logtests
COMMAND ${CMAKE_MAKE_PROGRAM} storetests
COMMAND ${CMAKE_MAKE_PROGRAM} worktests
COMMAND ${CMAKE_MAKE_PROGRAM} test ARGS="-V"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Other dependencies can be installed via package utilities.
For example, on Fedora/CentOS:

```
dnf install openssl-devel c-ares c-ares-devel yaml-cpp yaml-cpp-devel libevent libevent-devel
dnf install openssl-devel c-ares c-ares-devel yaml-cpp yaml-cpp-devel libevent libevent-devel make cmake gcc-c++ rapidxml-devel curl-devel cppunit-devel lcov
make build
sudo make install
Expand Down
7 changes: 7 additions & 0 deletions include/internal/HMState.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ class HMState
*/
bool setupDaemonstate();

//! Computes Hash and stores the config info.
/*
Computes hash for the entire config and stores in the config Info.
\return true if the successful.
*/
bool storeConfigInfo();

//! Get the current master config loaded.
/*!
Get the current master config loaded.
Expand Down
30 changes: 18 additions & 12 deletions src/internal/HMState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,34 @@ HMState::setupDaemonstate()

bool bConfigLoadOk = loadAllConfigs();

HMConfigInfo configInfo;
HMHashMD5 configHash;
configInfo.m_version = HM_MDBM_VERSION;
configInfo.m_configLoadTime = HMTimeStamp::now();
configInfo.m_configStatus = (bConfigLoadOk) ? HM_CONFIG_STATUS_OK : HM_CONFIG_STATUS_ERROR;
if(configHash.init())
{
HashHostGroupMap(configHash, configInfo.m_hash);
}
if(!bConfigLoadOk)
{
HMLog(HM_LOG_CRITICAL, "[CORE] Failure loading configs");
return false;
}
setHash(configInfo.m_hash);
m_datastore->storeConfigInfo(configInfo);

generateHostCheckList();
generateDNSCheckList();
return true;
}

bool
HMState::storeConfigInfo()
{
HMConfigInfo configInfo;
HMHashMD5 configHash;
configInfo.m_version = HM_MDBM_VERSION;
configInfo.m_configLoadTime = HMTimeStamp::now();
configInfo.m_configStatus = HM_CONFIG_STATUS_OK;
if (!configHash.init())
{
HMLog(HM_LOG_CRITICAL, "[CORE] Failure Initializing Hashing function");
return false;
}
HashHostGroupMap(configHash, configInfo.m_hash);
setHash(configInfo.m_hash);
return m_datastore->storeConfigInfo(configInfo);
}

const std::string&
HMState::getMasterConfig() const
{
Expand Down
2 changes: 2 additions & 0 deletions src/internal/HMStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ HMStateManager::loadDaemonState(const string& masterConfig, HM_LOG_LEVEL logLeve
return false;
}
m_newState->m_datastore->storeConfigs(*m_newState);
m_newState->storeConfigInfo();
m_currentState.swap(m_newState);
m_newState.reset();

Expand Down Expand Up @@ -353,6 +354,7 @@ HMStateManager::reloadDaemonConfigs(const string& masterConfig)

m_currentState.swap(m_newState);
m_currentState->m_datastore->storeConfigs(*m_currentState);
m_newState->storeConfigInfo();
m_currentState->resheduleDNSChecks(m_newState, m_workQueue);
m_currentState->resheduleHealthChecks(m_newState, m_workQueue);
m_currentState->m_dnsCache.queueDNSLookups(m_workQueue, *m_eventLoop, false);
Expand Down

0 comments on commit 6b6e70f

Please sign in to comment.