Пример #1
0
void CCommandPra::CmdAppLogLevel(CProtocol& a_clsRecvP, CProcessManager& a_clsPM)
{
	CConfigPra& clsCfg = CConfigPra::Instance();
	CAppQueue& clsQ = CAppQueue::Instance();
	
	CCmdAppLogLevel clsLog;				// Notify parsing
	string strBody;

	CCmdAppCtl clsCtl;					// APP에 보낼 body 메세지
	CProtocol clsSendP;					// APP에 보낼 message


	if (a_clsRecvP.IsFlagNotify() == false) {
		g_pclsLogPra->WARNING("CMD, 'LOG_LEVEL' not set notify flag");
	}

	if (clsLog.NotifyParse(a_clsRecvP.GetPayload().c_str()) == false) {
		g_pclsLogPra->ERROR("CMD, 'LOG_LEVEL' invalied body format");
		return;
	}
	
	// 프로세스 보낼 메세지 구성
	clsCtl.m_strAction = "LOG_LEVEL";
	clsCtl.m_nOption = clsLog.m_nLogLevel;

	clsSendP.SetCommand(CMD_APP_CTL);
	clsSendP.SetFlagRequest();
	clsSendP.SetSource(clsCfg.m_nNodeNo, clsCfg.m_nProcNo);
	clsSendP.SetSequence();
	clsSendP.SetPayload(clsCtl.RequestGen());

	if (clsLog.m_bIsAll) {
		// 전체 프로세스 loglevel 변경 요청
		vector<CProcessManager::ST_APPINFO> vecInfo;
		a_clsPM.GetAppInfo(vecInfo, CProcStatus::RUNNING);
		for (size_t i=0; i < vecInfo.size(); ++i) {
			clsSendP.SetDestination(clsCfg.m_nNodeNo, vecInfo[i].m_nProcNo);
			
			if (clsQ.SendCmd(clsSendP, vecInfo[i].m_strProcName.c_str()) == false) {
				g_pclsLogPra->ERROR("APP loglevel send failed");
			}
		}

	} else {
		// 지정 프로세스의 loglevel 변경 요청
		list<pair<int, string> >::iterator iter = clsLog.m_lstTarget.begin();
		for (; iter != clsLog.m_lstTarget.end(); ++iter) {
			clsSendP.SetDestination(clsCfg.m_nNodeNo, iter->first);
			
			if (clsQ.SendCmd(clsSendP, iter->second.c_str()) == false) {
				g_pclsLogPra->ERROR("APP loglevel send failed");
			}
		}
	}

	return;
}
Пример #2
0
int CEmsInfo::SendProcess(int a_nCmdCode, int a_nFlag, char *a_chMessageBuffer, int a_nMessageBufferLen)
{
    bool blnRet = true;
    char strCmdCode[11];
    int nNodeNo = 0;
    int nProcNo = 0;
    CGlobal *cGlob = NULL;
    CModuleIPC *cIpc = NULL;
    CProtocol cProto;

    DEBUG_LOG("SEND PROCESS\n");

    cGlob = CGlobal::GetInstance();

    nNodeNo = cGlob->GetLocalNodeNo();
    nProcNo =  cGlob->GetLocalProcNo();

    cProto.SetSource(nNodeNo, nProcNo);

    /* TEST */
    cProto.SetDestination(m_nAtomNodeNo, m_nStmNo);

    /* flag setting */
    switch(a_nFlag){
        case CProtocol::FLAG_REQUEST:   cProto.SetFlagRequest();    break;
        case CProtocol::FLAG_RESPONSE:  cProto.SetFlagResponse();   break;
        case CProtocol::FLAG_NOTIFY:    cProto.SetFlagNotify();     break;
        case CProtocol::FLAG_RETRNS:    cProto.SetFlagRetransmit(); break;
        case CProtocol::FLAG_BROAD:     cProto.SetFlagBroadcast();  break;
        case CProtocol::FLAG_ERROR:     cProto.SetFlagError();      break;
        default:
                                        STA_LOG(STA_ERR,"Invalid Message flag(%d)\n",a_nFlag);
                                        return STA_NOK;
    }

    /* PKG CLASS ACTION 
     * 000 003 XXXX
     */
    snprintf(strCmdCode, 11,"00000%d",a_nCmdCode);
    strCmdCode[11] = '\0';
    cProto.SetCommand(strCmdCode);

    cProto.SetPayload(a_chMessageBuffer, a_nMessageBufferLen);

    cIpc = cGlob->GetModuleIPC();

    blnRet = cIpc->SendMesg(cProto);
    if(blnRet != true){
        STA_LOG(STA_ERR,"IPC Send failed(cmdCode=%d, flag=%d)\n", a_nCmdCode, a_nFlag);
        return STA_NOK;
    }

    m_nMessageBufferLen = 0;

    return STA_OK;
}
Пример #3
0
void CProcessManager::CheckAlive(void)
{
	CConfigPra& clsCfg = CConfigPra::Instance();
	CAppQueue& clsQ = CAppQueue::Instance();
	
	// Alive check를 위한 Ping 메세지 생성
	CProtocol clsProto;
	clsProto.SetCommand(CMD_PING);
	clsProto.SetFlagRequest();
	clsProto.SetSource(clsCfg.m_nNodeNo, clsCfg.m_nProcNo);
	clsProto.SetPayload(NULL, 0);
	
	time_t curtime = time(NULL);

	auto iter = m_mapProcess.begin();
	for (; iter != m_mapProcess.end(); iter++) {

		if (iter->second.m_pclsApp->GetStatus() != CProcStatus::RUNNING) {
			continue;
		}
		
		// Alive 체크
		// 조건1) 마지막 alive 시간 + hangup 시간 이내 인가?
		// 조건2) alive 체크 주기 인가?
		if (curtime <= (iter->second.m_nAliveTime + m_nHangupTime)) {
			if (curtime >= (iter->second.m_nAliveTime + m_nAlivePeriod)) {
				clsProto.SetDestination(clsCfg.m_nNodeNo, iter->first);
				clsProto.SetSequence();
				
				auto miter = m_mapProcess.find(iter->first);
				if (miter == m_mapProcess.end()) {
					continue;
				}
				
				if (clsQ.SendCmd(clsProto, 
						miter->second.m_stAppInfo.m_strProcName.c_str()) == false) {
					g_pclsLogPra->ERROR("PM, CMD 'PING' send failed");
					continue;
				}
			}
			continue;
		}

		// HANGUP 처리
		g_pclsLogPra->CRITICAL("PM, process hangup, pno: %d, pname: %s",
							iter->first, 
							iter->second.m_stAppInfo.m_strProcName.c_str());
		iter->second.m_pclsApp->SetStatus(CProcStatus::HANGUP);
		iter->second.m_pclsApp->SendSignal(SIGSEGV);
	}
	
	return;
}
Пример #4
0
int CClaInterface::RegReqFunc(CProtocol &cProto)
{
	CCliRegReqApi cReqApi;
	string strPayload;

	/* send reg message */

	cReqApi.Init(m_strUserId);
	cReqApi.EncodeMessage(strPayload);

	cProto.SetCommand("0000080002");
	cProto.SetFlagRequest();
	cProto.SetSource(0, 0);
	cProto.SetDestination(0, 0);
	cProto.SetPayload(strPayload);

	return RESULT_OK;
}