Ejemplo n.º 1
0
int main(int argc, char **argv) {
	RPCCLIENT *client;
	client = Clnt_Create("127.0.0.1", 8011);
	if (NULL == client)
		return FAILED;
	RpcCall(client, "date", printdate);
}
Ejemplo n.º 2
0
// 关闭服务器
// 向BaseappMgr 发送 关闭消息
int world::ShutdownServer(T_VECTOR_OBJECT* p)
{
	LogInfo("world::shutdown_server", "");

	//回应cwmd,本进程已经退出
	RpcCall(SERVER_BASEAPPMGR, MSGID_BASEAPPMGR_ON_SERVER_SHUTDOWN, GetMailboxId());
	//设置服务器退出标记
	GetServer()->Shutdown();

	return 0;
}
Ejemplo n.º 3
0
    int CWorldMgrD::CreateBaseAnywhere(T_VECTOR_OBJECT* p)
    {
        if(p->size() != 2)
        {
            return -1;
        }

        const char* pszEntityType = VOBJECT_GET_STR((*p)[0]);
#ifdef __USE_MSGPACK
        charArrayDummy* d = (charArrayDummy*)VOBJECT_GET_BLOB((*p)[1]);
        uint16_t nBaseappId = ChooseABaseApp(pszEntityType);
        RpcCall(nBaseappId, MSGID_BASEAPP_CREATE_BASE_ANYWHERE, pszEntityType, *d);
#else
        const char* pszParam = VOBJECT_GET_STR((*p)[1]);
        uint16_t nBaseappId = ChooseABaseApp(pszEntityType);
        LogDebug("CWorldMgrD::CreateBaseAnywhere", "pszEntityType=%s;pszParam=%s", pszEntityType, pszParam);
        RpcCall(nBaseappId, MSGID_BASEAPP_CREATE_BASE_ANYWHERE, pszEntityType, pszParam);
#endif
        return 0;
    }
AllocateResponse ApplicationMasterProtocol::allocate(AllocateRequest &request) {
    try {
        AllocateRequestProto requestProto = request.getProto();
        AllocateResponseProto responseProto;
        invoke(RpcCall(true, "allocate", &requestProto, &responseProto));
        return AllocateResponse(responseProto);
    } catch (const YarnRpcServerException & e) {
        UnWrapper<ApplicationMasterNotRegisteredException, YarnIOException> unwrapper(e);
        unwrapper.unwrap(__FILE__, __LINE__);
    }
}
GetContainerStatusesResponse ContainerManagementProtocol::getContainerStatuses(GetContainerStatusesRequest &request){
	try {
		GetContainerStatusesRequestProto requestProto = request.getProto();
		GetContainerStatusesResponseProto responseProto;
		invoke(RpcCall(true, "getContainerStatuses", &requestProto, &responseProto));
		return GetContainerStatusesResponse(responseProto);
	} catch (const YarnRpcServerException & e) {
		UnWrapper<UnresolvedLinkException, YarnIOException> unwrapper(e);
		unwrapper.unwrap(__FILE__, __LINE__);
	} catch (...) {
		THROW(YarnIOException,
			  "Unexpected exception: when calling "
			  "ContainerManagementProtocol::getContainerStatuses in %s: %d",
			  __FILE__, __LINE__);
	}
}
void ApplicationClientProtocol::submitApplication(
		SubmitApplicationRequest &request) {
	try {
		SubmitApplicationResponseProto responseProto;
		SubmitApplicationRequestProto requestProto = request.getProto();
		invoke(RpcCall(true, "submitApplication", &requestProto, &responseProto));
	} catch (const YarnRpcServerException & e) {
		UnWrapper<UnresolvedLinkException, YarnIOException> unwrapper(e);
		unwrapper.unwrap(__FILE__, __LINE__);
	} catch (...) {
		THROW(YarnIOException,
			  "Unexpected exception: when calling "
			  "ApplicationClientProtocol::submitApplication in %s: %d",
			  __FILE__, __LINE__);
	}
}
/*
 rpc getQueueInfo (GetQueueInfoRequestProto) returns (GetQueueInfoResponseProto);

 message GetQueueInfoRequestProto {
 optional string queueName = 1;
 optional bool includeApplications = 2;
 optional bool includeChildQueues = 3;
 optional bool recursive = 4;
 }

 message GetQueueInfoResponseProto {
 optional QueueInfoProto queueInfo = 1;
 }

 message QueueInfoProto {
 optional string queueName = 1;
 optional float capacity = 2;
 optional float maximumCapacity = 3;
 optional float currentCapacity = 4;
 optional QueueStateProto state = 5;
 repeated QueueInfoProto childQueues = 6;
 repeated ApplicationReportProto applications = 7;
 }
 */
GetQueueInfoResponse ApplicationClientProtocol::getQueueInfo(
		GetQueueInfoRequest &request) {
	try {
		GetQueueInfoResponseProto responseProto;
		GetQueueInfoRequestProto requestProto = request.getProto();
		invoke(RpcCall(true, "getQueueInfo", &requestProto, &responseProto));
		return GetQueueInfoResponse(responseProto);
	} catch (const YarnRpcServerException & e) {
		UnWrapper<UnresolvedLinkException, YarnIOException> unwrapper(e);
		unwrapper.unwrap(__FILE__, __LINE__);
	} catch (...) {
		THROW(YarnIOException,
			  "Unexpected exception: when calling "
			  "ApplicationClientProtocol::getQueueInfo in %s: %d",
			  __FILE__, __LINE__);
	}
}
Ejemplo n.º 8
0
    //其他服务器进程退出后的回调方法
    int CWorldMgrD::OnServerShutdown(T_VECTOR_OBJECT* p)
    {
        if(p->size() != 1)
        {
            return -1;
        }

        //标记这个进程已经退出
        uint16_t nServerId = VOBJECT_GET_U16((*p)[0]);
        m_setShutdown.set(nServerId);

        LogDebug("CWorldMgrD::OnServerShutdown", "nServerId=%d", nServerId);

        //检查是否除dbmgr之外的进程都已经退出
        bool bQuitAll = true;
        vector<CMailBox*>& mbs = GetServer()->GetAllServerMbs();
        vector<CMailBox*>::iterator iter = mbs.begin();
        for(; iter != mbs.end(); ++iter)
        {
            CMailBox* basemb = *iter;
            if(basemb && basemb->GetServerMbType() != SERVER_DBMGR)
            {
                if(!m_setShutdown.test(basemb->GetMailboxId()))
                {
                    bQuitAll = false;
                    break;
                }
            }
        }

        if(bQuitAll)
        {
            //通知dbmgr退出
            RpcCall(SERVER_DBMGR, MSGID_DBMGR_SHUTDOWN_SERVER, (uint8_t)1);

            //cwmd退出
            GetServer()->Shutdown();
        }

        return 0;
    }
KillApplicationResponse ApplicationClientProtocol::forceKillApplication(
        KillApplicationRequest &request) {
    try {
        KillApplicationResponseProto responseProto;
        KillApplicationRequestProto requestProto = request.getProto();
        invoke(
                RpcCall(true, "forceKillApplication", &requestProto,
                        &responseProto));
        return KillApplicationResponse(responseProto);
    } catch (const YarnFailoverException & e) {
         throw;
    } catch (const YarnRpcServerException & e) {
        UnWrapper<UnresolvedLinkException, YarnIOException> unwrapper(e);
        unwrapper.unwrap(__FILE__, __LINE__);
    } catch (...) {
        THROW(YarnIOException,
              "Unexpected exception: when calling "
              "ApplicationClientProtocol::forceKillApplication in %s: %d",
              __FILE__, __LINE__);
    }
}