Esempio n. 1
0
void CCommandPra::CmdPing(CProtocol& a_clsRecvP)
{
	CProtocol clsResp;
	clsResp.SetResponse(a_clsRecvP);

	CCmdBase clsBase;
	string strBody;
	if (a_clsRecvP.IsFlagRequest()) {
		strBody = clsBase.ErrorGen(0, "ok i am alive");
	} else { 
		strBody = clsBase.ErrorGen(0, "not set requst flag");
		clsResp.SetFlagError();
		g_pclsLogPra->ERROR("MSGP, ping, not set request flag");
	}
	
	clsResp.SetPayload(strBody);

	if (CModuleIPC::Instance().SendMesg(clsResp) == false) {
		g_pclsLogPra->ERROR("CMD, send message failed, %s", 
								CModuleIPC::Instance().m_strErrorMsg.c_str());
		clsResp.Print(g_pclsLogPra, LV_ERROR, true);
	}

	#ifdef PRA_DEBUG
	g_pclsLogPra->DEBUG("Send message");
	clsResp.Print(g_pclsLogPra, LV_DEBUG, true);
	#endif
	
	return;
}
Esempio n. 2
0
void CCommandPra::CmdAppStatus(CProtocol& a_clsRecvP, CProcessManager& a_clsPM)
{
	CCmdBase clsBase;
	bool bIsError = false;
	string strBody;


	if (a_clsRecvP.IsFlagRequest() == false) {
		strBody = clsBase.ErrorGen(1, "not set request flag");
		bIsError = true;
		goto JumpSend;
	}

	if (clsBase.RequestParse(a_clsRecvP.GetPayload().c_str()) == false) {
		strBody = clsBase.ErrorGen(1, "invalied body format");
		bIsError = true;
		goto JumpSend;
	}

	GetAppStatus(a_clsPM, clsBase);
	strBody = clsBase.ResponseGen();

JumpSend:
	CProtocol clsResp;
	clsResp.SetResponse(a_clsRecvP);
	if (bIsError) {
		clsResp.SetFlagError();
	}
	clsResp.SetPayload(strBody);

	if (CModuleIPC::Instance().SendMesg(clsResp) == false) {
		g_pclsLogPra->ERROR("CMD, send message failed, %s", 
								CModuleIPC::Instance().m_strErrorMsg.c_str());
		clsResp.Print(g_pclsLogPra, LV_ERROR, true);
	}

	#ifdef PRA_DEBUG
	g_pclsLogPra->DEBUG("Send message");
	clsResp.Print(g_pclsLogPra, LV_DEBUG, true);
	#endif
	
	return;
}
Esempio n. 3
0
void CCommandPra::CmdBatchStart(CProtocol& a_clsRecvP, CProcessManager& a_clsPM)
{
	CCmdBatchStart clsBatch;
	bool bIsError = false;
	string strBody;
	CProcStatus::EN_STATUS nStatus = CProcStatus::NONE;


	if (a_clsRecvP.IsFlagRequest() == false) {
		strBody = clsBatch.ErrorGen(1, "not set request flag");
		bIsError = true;
		goto JumpSend;
	}

	if (clsBatch.RequestParse(a_clsRecvP.GetPayload().c_str()) == false) {
		strBody = clsBatch.ErrorGen(1, "invalied body format");
		bIsError = true;
		goto JumpSend;
	}

	// 배치 프로세스 실행
	a_clsPM.Run(clsBatch.m_nProcNo);

	// batch exit wait
	usleep(100);
	a_clsPM.CheckExit(clsBatch.m_nProcNo);


	nStatus = a_clsPM.GetStatus(clsBatch.m_nProcNo);
	switch (nStatus) {
		case CProcStatus::RUNNING :
			clsBatch.m_strStatus = "pending";
			break;
		case CProcStatus::STOPPED :
			clsBatch.m_strStatus = "normal";
			clsBatch.m_nExitCd = a_clsPM.GetExitCode(clsBatch.m_nProcNo);
			break;
		default :
			clsBatch.m_strStatus = "failed";
	}
	strBody = clsBatch.ResponseGen();

JumpSend:
	CProtocol clsResp;
	clsResp.SetResponse(a_clsRecvP);
	if (bIsError) {
		clsResp.SetFlagError();
	}
	clsResp.SetPayload(strBody);

	if (CModuleIPC::Instance().SendMesg(clsResp) == false) {
		g_pclsLogPra->ERROR("CMD, send message failed, %s", 
								CModuleIPC::Instance().m_strErrorMsg.c_str());
		clsResp.Print(g_pclsLogPra, LV_ERROR, true);
	}

	#ifdef PRA_DEBUG
	g_pclsLogPra->DEBUG("Send message");
	clsResp.Print(g_pclsLogPra, LV_DEBUG, true);
	#endif

	return;
}
Esempio n. 4
0
void CCommandPra::CmdAppInit(CProtocol& a_clsRecvP, CProcessManager& a_clsPM)
{
	CConfigPra& clsCfg = CConfigPra::Instance();
	CAppQueue& clsQ = CAppQueue::Instance();
	
	CCmdAppInit clsInit;				// Request body parsing
	CCmdAppInit::ST_RESPONSE stResponse;
	string strBody;
	bool bIsError = false;
			
	CCmdAppCtl clsCtl;					// APP에 보낼 body 메세지
	CProtocol clsSendP;					// APP에 보낼 message


	if (a_clsRecvP.IsFlagRequest() == false) {
		strBody = clsInit.ErrorGen(1, "CMD 'APP_INIT', not set request flag");
		bIsError = true;
		goto JumpSend;
	}

	if (clsInit.RequestParse(a_clsRecvP.GetPayload().c_str()) == false) {
		strBody = clsInit.ErrorGen(1, "CMD 'APP_INIT', invalied body format");
		bIsError = true;
		goto JumpSend;
	}
	
	// 프로세스 보낼 메세지 구성
	clsCtl.m_strAction = "INIT";
	clsSendP.SetCommand(CMD_APP_CTL);
	clsSendP.SetFlagNotify();
	clsSendP.SetSource(clsCfg.m_nNodeNo, clsCfg.m_nProcNo);
	clsSendP.SetSequence();
	clsSendP.SetPayload(clsCtl.RequestGen());

	if (clsInit.m_bIsAll) {
		// 전체 프로세스 init 요청
		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);
			
			stResponse.m_nProcNo = vecInfo[i].m_nProcNo;
			stResponse.m_strProcName = vecInfo[i].m_strProcName;
			stResponse.m_bSuccess = true;
			
			if (clsQ.SendCmd(clsSendP, vecInfo[i].m_strProcName.c_str()) == false) {
				g_pclsLogPra->ERROR("APP init send failed");
				stResponse.m_bSuccess = false;
			}
			
			clsInit.m_lstResponse.push_back(stResponse);
		}

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

			clsInit.m_lstResponse.push_back(stResponse);
		}
	}
	strBody = clsInit.ResponseGen();

JumpSend:
	CProtocol clsResp;
	clsResp.SetResponse(a_clsRecvP);
	if (bIsError) {
		clsResp.SetFlagError();
	}
	clsResp.SetPayload(strBody);

	if (CModuleIPC::Instance().SendMesg(clsResp) == false) {
		g_pclsLogPra->ERROR("CMD, send message failed, %s", 
								CModuleIPC::Instance().m_strErrorMsg.c_str());
		clsResp.Print(g_pclsLogPra, LV_ERROR, true);
	}

	#ifdef PRA_DEBUG
	g_pclsLogPra->DEBUG("Send message");
	clsResp.Print(g_pclsLogPra, LV_DEBUG, true);
	#endif
	
	return;
}