/** handle packet*/ bool ExpRootServer::handlePacketQueue(tbnet::Packet *packet, void *args) { bool bret = BaseService::handlePacketQueue(packet, args); if (bret) { int32_t pcode = packet->getPCode(); int32_t iret = LOCAL_PACKET == pcode ? TFS_ERROR : common::TFS_SUCCESS; if (TFS_SUCCESS == iret) { TBSYS_LOG(DEBUG, "PCODE: %d", pcode); common::BasePacket* msg = dynamic_cast<common::BasePacket*>(packet); switch (pcode) { case REQ_RT_FINISH_TASK_MESSAGE: iret = handle_finish_task(dynamic_cast<ReqFinishTaskFromEsMessage*>(msg)); break; case REQ_QUERY_TASK_MESSAGE: iret = query_task(dynamic_cast<ReqQueryTaskMessage*>(msg)); break; default: iret = EXIT_UNKNOWN_MSGTYPE; TBSYS_LOG(ERROR, "unknown msg type: %d", pcode); break; } if (common::TFS_SUCCESS != iret) { msg->reply_error_packet(TBSYS_LOG_LEVEL(ERROR), iret, "execute message failed, pcode: %d", pcode); } } } return bret; }
// libeasy handle packet int ExpRootServer::handle(common::BasePacket* packet) { assert(NULL != packet); int ret = TFS_SUCCESS; int32_t pcode = packet->getPCode(); switch (pcode) { case REQ_RT_ES_KEEPALIVE_MESSAGE: ret = rt_es_keepalive(dynamic_cast<BasePacket*>(packet)); break; case REQ_RT_FINISH_TASK_MESSAGE: ret = handle_finish_task(dynamic_cast<ReqFinishTaskFromEsMessage*>(packet)); break; case REQ_QUERY_TASK_MESSAGE: ret = query_task(dynamic_cast<ReqQueryTaskMessage*>(packet)); break; default: ret = EXIT_UNKNOWN_MSGTYPE; TBSYS_LOG(ERROR, "unknown msg type: %d", pcode); break; } if (common::TFS_SUCCESS != ret) { packet->reply_error_packet(TBSYS_LOG_LEVEL(ERROR), ret, "execute message failed, pcode: %d", pcode); } return EASY_OK; }
static void query_tasks(void) { int pid; for (pid = 0; pid < PID_MAX; pid++) if (bm_test(pid)) { query_task(pid); receive_taskstats(); } }