Example #1
0
bool CCommandPra::ProcMesgModule(CProtocol& a_clsRecvP, CProcessManager& a_clsPM)
{
	CConfigPra& clsCfg = CConfigPra::Instance();

	#ifdef PRA_DEBUG
	g_pclsLogPra->DEBUG("Recvive message form Module");
	a_clsRecvP.Print(g_pclsLogPra, LV_DEBUG, true);
	#endif
	
	int nDstNode = 0;
	int nDstProc = 0; 
	a_clsRecvP.GetDestination(nDstNode, nDstProc);

	// PRA가 처리해 할 명령인가?
	if (nDstProc == clsCfg.m_nProcNo) {
		return Command(a_clsRecvP, a_clsPM);
	}

	// 메세지를 전송할 APP를 찾는다.
	string strProcName;
	if (a_clsPM.GetProcName(nDstProc, &strProcName) != NULL) {
		CAppQueue& clsQ = CAppQueue::Instance();
		if (clsQ.SendCmd(a_clsRecvP, strProcName.c_str()) == false) {
			g_pclsLogPra->ERROR("message send faile, to app");
			a_clsRecvP.Print(g_pclsLogPra, LV_INFO);
			return false;
		}
	} else {
		g_pclsLogPra->ERROR("not found target app process");
		a_clsRecvP.Print(g_pclsLogPra, LV_INFO);
	}

	return true;
}
Example #2
0
bool CModuleIPC::SendMesg(CProtocol& a_cMesg)
{
	int nDstNodeNo = -1;
	int nDstProcNo = -1;
	a_cMesg.GetDestination(nDstNodeNo, nDstProcNo);
	

	int nToProcNo = -1;
	if (m_clsRoute.Lookup(nDstNodeNo, nDstProcNo, nToProcNo) == false) {
		m_strErrorMsg = "not found routing table";
		return false;
	}

	modipc_t::iterator iter = m_mapIPC.find(nToProcNo);
	if (iter == m_mapIPC.end()) {
		m_strErrorMsg = "not found procno";
		return false;
	}

	pthread_mutex_lock(&iter->second.m_tMutex);

	iter->second.m_deqMsg.push_back(a_cMesg);
	pthread_cond_signal(&iter->second.m_tCond);

	pthread_mutex_unlock(&iter->second.m_tMutex);

	return true;
}
Example #3
0
bool CCommandPra::ProcMesgApp(CProtocol& a_clsRecvP, CProcessManager& a_clsPM)
{
	CConfigPra& clsCfg = CConfigPra::Instance();

	#ifdef PRA_DEBUG
	g_pclsLogPra->DEBUG("Recvive message form App");
	a_clsRecvP.Print(g_pclsLogPra, LV_DEBUG, true);
	#endif
	
	int nDstNode = 0;
	int nDstProc = 0; 
	a_clsRecvP.GetDestination(nDstNode, nDstProc);
	
	// TODO
	// APP에서 ATOM node, proc no을 알수 없어 0으로 지정한 경우
	// command에 따라 ATOM node, procno을 재지정 해준다.
	// 이럴 경우 APP에서 추가 명령이 발생할 때 마다 수정이 필요하므로
	// 향후 개선이 필요하다.
	if (nDstNode == 0 && nDstProc == 0) {
		int nCmd = atoi(a_clsRecvP.GetCommand().c_str());
		switch (nCmd) {
			case CMD_NODELIST :
				CAddress::Instance().LookupAtom("ATOM_NM", nDstNode, nDstProc);
				a_clsRecvP.SetDestination(nDstNode, nDstProc);
				break;
		}
	}

	// PRA가 처리해 할 명령인가?
	if (nDstProc == clsCfg.m_nProcNo) {
		return Command(a_clsRecvP, a_clsPM);
	}

	// agent에 메세지 전송
	CModuleIPC& clsIPC = CModuleIPC::Instance();
	if (clsIPC.SendMesg(a_clsRecvP) == false) {
		g_pclsLogPra->ERROR("CMD, mode ipc send failed");
		a_clsRecvP.Print(g_pclsLogPra, LV_INFO);
		return false;
	}

	// APP의 Alive 주기적 검사를 줄이기 위해 APP에서 메세지가 왔다면
	// 이를 APP가 정상적으로 Alive 중인것으로 판단.
	int nSrcNode = 0;
	int nSrcProc = 0;
	a_clsRecvP.GetSource(nSrcNode, nSrcProc);
	if (nSrcProc > 0) {
		a_clsPM.AliveOk(nSrcProc);
	}

	return true;
}