/**
- * @brief constractor
+ * @brief constructor
*/
CicoSCSysResourceController::CicoSCSysResourceController()
{
g_samplingWaitTimer = m_rConf->m_sampling;
}
}
+ if (false == m_rConf->m_bDoIt) {
+ ICO_TRA("end");
+ return ;
+ }
// cpu,cpuacct cgroup init
init_cgroup(); // cgroup
m_monitor = new CicoSCSysResourceMonitor();
int cpu = m_monitor->getCPUuser(); // application cpu
if (-1 != cpu) {
cpu /= 100;
- if (g_RC_LOG) ICO_TRA("cpu %d -> %d", m_cpu, cpu);
CicoEvent ev(gEV1000, cpu);
- m_stt->eventEntry(ev);
+ bool b = m_stt->eventEntry(ev);
+ if (g_RC_LOG) ICO_TRA("cpu %c, %d->%d", b? 't': 'f', m_cpu, cpu);
m_cpu = cpu;
r = true;
}
*/
void CicoSCSysResourceController::resourceControlCPUShares(bool bHight)
{
- ICO_TRA("start %s",
- bHight? "true": "false");
+ ICO_TRA("start %s", bHight? "true": "false");
if ((NULL == m_rConf) || (false == m_rConf->m_bDoIt)) {
ICO_TRA("end");
return;
/**
- * @breif
+ * @brief
*
*/
bool CicoSCSysResourceController::entryCgroupCPU(int pid, int grpNo)
}
/**
- * @breif initialize cgroup
+ * @brief initialize cgroup
*/
void CicoSCSysResourceController::init_cgroup()
{
}
/**
- * @breif initialize cgroup cpu
+ * @brief initialize cgroup cpu
*/
void CicoSCSysResourceController::init_cgroup_cpu()
{
ICO_TRA("start");
- if (NULL == m_rConf) {
+ if ((NULL == m_rConf) || (false == m_rConf->m_bDoIt)) {
ICO_TRA("end");
return;
}
}
/**
- * @breif initialize cgroup memory
+ * @brief initialize cgroup memory
*/
void CicoSCSysResourceController::init_cgroup_memory()
{
ICO_TRA("start");
- if (NULL == m_rConf) {
+ if ((NULL == m_rConf) || (false == m_rConf->m_bDoIt)) {
ICO_TRA("end error config class");
return;
}
}
/**
- * @breif make directory
+ * @brief make directory
* @param d create directory target
*/
void CicoSCSysResourceController::make_directorys(std::vector<std::string> dir)
ICO_TRA("constructor");
m_val = -1; // cpu or memory usage value
m_baseVal = -1; // cpu or memory base usage value
+ m_cnt = 0;
+ m_rConf = CicoSCSystemConfig::getInstance()->getResourceConf();
}
/**
* @param ev event data
* @param stt state object
*/
-void CicoSRCCPU_LOW::onEnttry(const CicoEvent& ev, const CicoState* stt, int)
+void CicoSRCCPU_LOW::onEntry(const CicoEvent& ev, const CicoState* stt, int)
{
- ICO_TRA("start %s,%d,%d", stt->getName().c_str(),
- ev.getEV(),ev.getGCVi());
- m_baseVal = ev.getGCVi();
+ int v1 = ev.getEV();
+ int v2 = ev.getGCVi();
+ if (g_RC_LOG) ICO_TRA("start %s,%d,%d CicoSRCCPU_LOW::", stt->getName().c_str(), v1, v2);
+ m_baseVal = v2;
m_val = m_baseVal;
+ m_cnt = m_rConf->m_retryCnt;
+ if (g_RC_LOG) ICO_TRA("end cnt(%d) CicoSRCCPU_LOW::", m_cnt);
}
/**
void CicoSRCCPU_LOW::onDo(const CicoEvent& ev, const CicoState* stt, int)
{
int valN = ev.getGCVi();
- ICO_TRA("start o(%d), n(%d)", m_val, valN);
- if (valN >= m_val) {
+ if (g_RC_LOG) ICO_TRA("start o(%d), n(%d)CicoSRCCPU_LOW::", m_val, valN);
+#if 0
+ if (valN > m_val) {
// When the value is greater than the previous
- ICO_TRA("end n(%d) >= o(%d)", m_val, valN);
+ if (g_RC_LOG) ICO_TRA("end n(%d)->o(%d) CicoSRCCPU_LOW::", m_val, valN);
return;
}
// When the value is less than the previous
int t = ((double)valN / (double)m_baseVal)*100;
if (50 <= t) {
m_cntlr->resourceControlCPUShares(false);
- ICO_DBG("BASE CHG %d->%d",m_baseVal, valN);
+ if (g_RC_LOG) ICO_DBG("CHG %d->%d CicoSRCCPU_LOW::",m_baseVal, valN);
m_baseVal = valN;
}
+#else
+ if (valN < m_rConf->m_lowLimitVal) {
+ m_cnt--;
+ if (0 >= m_cnt) {
+ m_cntlr->resourceControlCPUShares(false);
+ if (g_RC_LOG) ICO_DBG("CHG %d->%d CicoSRCCPU_LOW::",m_baseVal, valN);
+ m_cnt = m_rConf->m_retryCnt;
+ m_baseVal = valN;
+ }
+ }
+ else {
+ if (g_RC_LOG) ICO_DBG("cnt rst V(%d) CicoSRCCPU_LOW::", valN);
+ m_cnt = m_rConf->m_retryCnt;
+ }
+#endif
m_val = valN;
- ICO_TRA("end");
+ if (g_RC_LOG) ICO_TRA("end CicoSRCCPU_LOW::");
}
*/
void CicoSRCCPU_LOW::onExit(const CicoEvent&, const CicoState*, int)
{
- ICO_TRA("start");
+ if (g_RC_LOG) ICO_TRA("start CicoSRCCPU_LOW::");
m_baseVal = -1;
m_val = -1;
- ICO_TRA("end");
+ if (g_RC_LOG) ICO_TRA("end CicoSRCCPU_LOW::");
}
/**
void CicoSRCCPU_HIGH::onDo(const CicoEvent& ev, const CicoState* stt, int)
{
int valN = ev.getGCVi();
- ICO_TRA("start o(%d), n(%d)", m_val, valN);
+ if (g_RC_LOG) ICO_TRA("start o(%d), n(%d) CicoSRCCPU_HIGH::", m_val, valN);
+#if 0
if (valN <= m_val) {
// When the value is less than the previous
- ICO_TRA("end n(%d)<=o(%d)", valN, m_val);
+ if (g_RC_LOG) ICO_TRA("n(%d)<=o(%d) CicoSRCCPU_HIGH::", valN, m_val);
return;
}
// When the value is greater than the previous
int t = ((double)(100-valN) / (double)(100-m_baseVal))*100;
if (50 <= t) {
m_cntlr->resourceControlCPUShares(true);
- ICO_DBG("BASE CHG %d -> %d", m_baseVal, valN);
+ if (g_RC_LOG) ICO_DBG("%d->%d CicoSRCCPU_HIGH::", m_baseVal, valN);
m_baseVal = valN;
}
+#else
+ if (valN > m_rConf->m_highLimitVal) {
+ m_cnt--;
+ if (g_RC_LOG) ICO_DBG("cnt(%d) CicoSRCCPU_HIGH::", m_cnt);
+ if (0 >= m_cnt) {
+ m_cntlr->resourceControlCPUShares(true);
+ if (g_RC_LOG) ICO_DBG("CicoSRCCPU_HIGH:: %d->%d",m_baseVal, valN);
+ m_cnt = m_rConf->m_retryCnt;
+ m_baseVal = valN;
+ }
+ }
+ else {
+ if (g_RC_LOG) ICO_DBG("CicoSRCCPU_HIGH:: (%d)", valN);
+ m_cnt = m_rConf->m_retryCnt;
+ }
+#endif
m_val = valN;
- ICO_TRA("end");
+ if (g_RC_LOG) ICO_TRA("end CicoSRCCPU_HIGH::");
}
/**
CicoSRCMEM_LOW::CicoSRCMEM_LOW(CicoSCSysResourceController* obj):
CicoSRCCPU_LOW(obj)
{
- ICO_TRA("constructor");
+ ICO_TRA("constructor CicoSRCMEM_LOW::");
}
/**
*/
CicoSRCMEM_LOW::~CicoSRCMEM_LOW()
{
- ICO_TRA("destructor");
+ ICO_TRA("destructor CicoSRCMEM_LOW::");
}
/**
void CicoSRCMEM_LOW::onDo(const CicoEvent& ev, const CicoState* stt, int)
{
int valN = ev.getGCVi();
- ICO_TRA("start o(%d), n(%d)", m_val, valN);
+ if (g_RC_LOG) ICO_TRA("start o(%d), n(%d)", m_val, valN);
if (valN >= m_val) {
// When the value is greater than the previous
- ICO_TRA("n(%d)>=o(%d)", valN, m_val);
+ if (g_RC_LOG) ICO_TRA("n(%d)>=o(%d)", valN, m_val);
return;
}
// When the value is less than the previous
int t = ((double)valN / (double)m_baseVal)*100;
if (50 <= t) {
m_cntlr->resourceControlMemLimit(false);
- ICO_TRA("BASE CHG %d->%d",m_baseVal, valN);
+ if (g_RC_LOG) ICO_TRA("BASE CHG %d->%d",m_baseVal, valN);
m_baseVal = valN;
}
m_val = valN;
- ICO_TRA("end");
+ if (g_RC_LOG) ICO_TRA("end");
}
void CicoSRCMEM_HIGH::onDo(const CicoEvent& ev, const CicoState* stt, int)
{
int valN = ev.getGCVi();
- ICO_TRA("start o(%d), n(%d)", m_val, valN);
+ if (g_RC_LOG) ICO_TRA("start o(%d), n(%d)", m_val, valN);
if (valN <= m_val) {
// When the value is less than the previous
ICO_TRA("end");
int t = ((double)(100-valN) / (double)(100-m_baseVal))*100;
if (50 <= t) {
m_cntlr->resourceControlMemLimit(true);
- ICO_TRA("BASE CHG %d -> %d", m_baseVal, valN);
+ if (g_RC_LOG) ICO_TRA("BASE CHG %d -> %d", m_baseVal, valN);
m_baseVal = valN;
}
m_val = valN;
- ICO_TRA("end");
+ if (g_RC_LOG) ICO_TRA("end");
}