static ClRcT clMsgEventInitialize(void) { ClRcT rc, retCode; ClVersionT version = CL_EVENT_VERSION; ClEventCallbacksT msgEvtCallbacks = { NULL, clMsgEventCallbackFunc }; ClNameT cpmEvtCh = {0}; ClEventChannelOpenFlagsT cpmChOpenFlags = CL_EVENT_CHANNEL_SUBSCRIBER | CL_EVENT_GLOBAL_CHANNEL; ClUint32T nodeDepPattern = htonl(CL_CPM_NODE_DEPART_PATTERN); ClEventFilterT nodeDepFilter[] = {{CL_EVENT_EXACT_FILTER, {0, (ClSizeT)sizeof(nodeDepPattern), (ClUint8T*)&nodeDepPattern}}}; ClEventFilterArrayT nodeDepFltArray = {sizeof(nodeDepFilter)/sizeof(nodeDepFilter[0]), nodeDepFilter}; rc = clEventInitialize(&gMsgEvtHdl, &msgEvtCallbacks, &version); if(rc != CL_OK) { clLogError("EVT", "INI", "Failed to initialize the event client. error code [0x%x].", rc); goto error_out; } clNameSet(&cpmEvtCh, CL_CPM_NODE_EVENT_CHANNEL_NAME); rc = clEventChannelOpen(gMsgEvtHdl, &cpmEvtCh, cpmChOpenFlags, SA_TIME_MAX, &gCpmChHdl); if(rc != CL_OK) { clLogError("EVT", "INI", "Failed to open event channel. error code [0x%x].", rc); goto error_out_1; } rc = clEventSubscribe(gCpmChHdl, &nodeDepFltArray, 0, NULL); if(rc != CL_OK) { clLogError("EVT", "INI", "Failed to subscribe for node departure event. error code [0x%x].", rc); goto error_out_2; } goto out; error_out_2: retCode = clEventChannelClose(gCpmChHdl); if(retCode != CL_OK) clLogError("EVT", "INI", "Failed to close CPM event channel. error code [0x%x].", retCode); error_out_1: retCode = clEventFinalize(gMsgEvtHdl); if(retCode != CL_OK) clLogError("EVT", "INI", "Failed to finalize event library. error code [0x%x].", retCode); error_out: out: return rc; }
static ClRcT clSubsEventLibrayInitialize(void) { ClRcT rc = CL_OK; ClVersionT version = CL_EVENT_VERSION; ClNameT channelName = {sizeof(CL_EO_EVENT_CHANNEL_NAME)-1, CL_EO_EVENT_CHANNEL_NAME}; const ClEventCallbacksT evtCallbacks = { NULL, // clSubsAsyncChannelOpenCb for Async Channel Open clSubEoEventWaterMarkCb, // Event Delivery Callback }; ClEventChannelOpenFlagsT evtFlags = CL_EVENT_CHANNEL_SUBSCRIBER | CL_EVENT_LOCAL_CHANNEL; rc = clEventInitialize(&gSubsEventInfo.initHandle, &evtCallbacks, &version); if(CL_OK != rc) { clOsalPrintf("clEventInitialize() failed [%#X]\n",rc); goto failure; } rc = clEventChannelOpen(gSubsEventInfo.initHandle, &channelName, evtFlags, CL_RMD_DEFAULT_TIMEOUT, &gSubsEventInfo.channelHandle); if(CL_OK != rc) { clOsalPrintf("clEventChannelOpen() failed [%#X]\n",rc); goto init_done; } rc = clEventSubscribe(gSubsEventInfo.channelHandle, CL_EVENT_DEFAULT_SUBS_FILTER, UNIQUE_SUBSCRIPTION_ID, "User Specified Argument (cookie) for the event delivery callback"); if(CL_OK != rc) { clOsalPrintf("clEventSubscribe() failed [%#X]\n",rc); goto channel_opened; } return CL_OK; channel_opened: clEventChannelClose(gSubsEventInfo.channelHandle); init_done: clEventFinalize(gSubsEventInfo.initHandle); failure: return rc; }
static ClRcT clPubsEventLibrayInitialize(void) { ClRcT rc = CL_OK; ClVersionT version = CL_EVENT_VERSION; SaNameT channelName = {sizeof(CL_EO_EVENT_CHANNEL_NAME)-1, CL_EO_EVENT_CHANNEL_NAME}; const ClEventCallbacksT evtCallbacks = { clPubsAsyncChannelOpenCb, // Can be NULL if sync call is used NULL, // Since it is not a subscriber }; ClEventChannelOpenFlagsT evtFlags = CL_EVENT_CHANNEL_PUBLISHER | CL_EVENT_LOCAL_CHANNEL; ClInvocationT invocation = UNIQUE_INVOCATION_ID; // To identify the callback rc = clEventInitialize(&gPubsEventInfo.initHandle, &evtCallbacks, &version); if(CL_OK != rc) { clOsalPrintf("clEventInitialize() failed [%#X]\n",rc); goto failure; } rc = clEventChannelOpenAsync(gPubsEventInfo.initHandle, invocation, &channelName, evtFlags); if(CL_OK != rc) { clOsalPrintf("clEventChannelOpen() failed [%#X]\n",rc); goto init_done; } return CL_OK; init_done: clEventFinalize(gPubsEventInfo.initHandle); failure: return rc; }
/** * Initialize COR notification module. * * This routine initializes COR notification module. It creates * the COR event channel in EM. This routine is called during * COR initialization from corInit. This is not an external API. * * @param N/A * * @returns CL_OK on success<br> * value returned by #emEventCreate on failure. */ ClRcT corEventInit(void) { ClRcT rc; ClNameT evtChannelName; ClVersionT ver = CL_EVENT_VERSION; ClUint32T compDeathPattern = htonl(CL_CPM_COMP_DEATH_PATTERN); ClUint32T compDeparturePattern = htonl(CL_CPM_COMP_DEPART_PATTERN); ClUint32T nodeDeathPattern = htonl(CL_CPM_NODE_DEATH_PATTERN); ClUint32T nodeDeparturePattern = htonl(CL_CPM_NODE_DEPART_PATTERN); ClEventFilterT compDeathFilter[] = {{CL_EVENT_EXACT_FILTER, {0, (ClSizeT)sizeof(compDeathPattern), (ClUint8T*)&compDeathPattern}} }; ClEventFilterArrayT compDeathFilterArray = {sizeof(compDeathFilter)/sizeof(compDeathFilter[0]), compDeathFilter }; ClEventFilterT compDepartureFilter[] = {{CL_EVENT_EXACT_FILTER, {0, (ClSizeT)sizeof(compDeparturePattern), (ClUint8T*)&compDeparturePattern}} }; ClEventFilterArrayT compDepartureFilterArray = {sizeof(compDepartureFilter)/sizeof(compDepartureFilter[0]), compDepartureFilter }; ClEventFilterT nodeDeathFilter[] = { {CL_EVENT_EXACT_FILTER, {0, (ClSizeT)sizeof(nodeDeathPattern), (ClUint8T*)&nodeDeathPattern}} }; ClEventFilterArrayT nodeDeathFilterArray = {sizeof(nodeDeathFilter)/sizeof(nodeDeathFilter[0]), nodeDeathFilter }; ClEventFilterT nodeDepartureFilter[] = { {CL_EVENT_EXACT_FILTER, {0, (ClSizeT)sizeof(nodeDeparturePattern), (ClUint8T*)&nodeDeparturePattern}} }; ClEventFilterArrayT nodeDepartureFilterArray = {sizeof(nodeDepartureFilter)/sizeof(nodeDepartureFilter[0]), nodeDepartureFilter }; CL_FUNC_ENTER(); /* First call the function to initialize COR events */ rc = clEventInitialize(&corEventHandle,&corEvtCallbacks, &ver); if(CL_OK != rc) { clLogWrite(CL_LOG_HANDLE_APP, CL_LOG_ALERT, NULL, CL_LOG_MESSAGE_2_INIT, "Event Client", rc); CL_DEBUG_PRINT (CL_DEBUG_ERROR, ("Event Client init failed rc => [0x%x]\n", rc)); return rc; } /**** Open Publish Channel for COR */ evtChannelName.length = strlen(clCorEventName); memcpy(evtChannelName.value, clCorEventName, evtChannelName.length+1); rc = clEventChannelOpen(corEventHandle, &evtChannelName, CL_EVENT_GLOBAL_CHANNEL | CL_EVENT_CHANNEL_PUBLISHER, COR_EVT_TIMEOUT, &corEventChannelHandle); if(CL_OK != rc) { clLogWrite(CL_LOG_HANDLE_APP, CL_LOG_ALERT, NULL, CL_LOG_MESSAGE_1_EVENT_PUBLISH_CHANNEL_OPEN, rc); CL_DEBUG_PRINT (CL_DEBUG_ERROR, ("\n Event Publish Channel Open failed for COR rc => [0x%x]\n", rc)); return rc; } /** * Open component event channel of CPM */ evtChannelName.length = strlen(CL_CPM_EVENT_CHANNEL_NAME); strcpy(evtChannelName.value, CL_CPM_EVENT_CHANNEL_NAME); rc = clEventChannelOpen(corEventHandle, &evtChannelName, CL_EVENT_GLOBAL_CHANNEL | CL_EVENT_CHANNEL_SUBSCRIBER, (ClTimeT)-1, &cpmEventChannelHandle); if(CL_OK != rc) { clLogWrite(CL_LOG_HANDLE_APP, CL_LOG_ALERT, NULL, CL_LOG_MESSAGE_1_CHANNEL_OPEN_COMP_TERMINATION, rc); CL_DEBUG_PRINT (CL_DEBUG_ERROR, ("\n Event Subscribe Channel Open failed for CPM rc => [0x%x]\n", rc)); return rc; } /* * Subscribe for component death event. */ rc = clEventSubscribe(cpmEventChannelHandle, &compDeathFilterArray, CL_COR_COMP_DEATH_SUBSCRIPTION_ID, NULL); if(CL_OK != rc) { clLogError("NOTIFY", "SUBSCRIBE", "Failed to subscribe for component death event. rc [0x%x]", rc); return rc; } /* * Subscribe for component departure event. */ rc = clEventSubscribe(cpmEventChannelHandle, &compDepartureFilterArray, CL_COR_COMP_DEPARTURE_SUBSCRIPTION_ID, NULL); if(CL_OK != rc) { clLogError("NOTIFY", "SUBSCRIBE", "Failed to subscribe for component departure event. rc [0x%x]", rc); return rc; } /** * Open node event channel of CPM. */ evtChannelName.length = strlen(CL_CPM_NODE_EVENT_CHANNEL_NAME); strcpy(evtChannelName.value, CL_CPM_NODE_EVENT_CHANNEL_NAME); rc = clEventChannelOpen(corEventHandle, &evtChannelName, CL_EVENT_GLOBAL_CHANNEL | CL_EVENT_CHANNEL_SUBSCRIBER, (ClTimeT)-1, &cpmEventNodeChannelHandle); if(CL_OK != rc) { clLogWrite(CL_LOG_HANDLE_APP, CL_LOG_ALERT, NULL, CL_LOG_MESSAGE_1_CHANNEL_OPEN_NODE_ARRIVAL, rc); CL_DEBUG_PRINT (CL_DEBUG_ERROR, ("\n Event Subscribe Channel Open failed for CPM rc => [0x%x]\n", rc)); return rc; } /* * Subscribe for node death event. */ rc = clEventSubscribe(cpmEventNodeChannelHandle, &nodeDeathFilterArray, CL_COR_NODE_DEATH_SUBSCRIPTION_ID, NULL); if(CL_OK != rc) { clLogError("NOTIFY", "SUBSCRIBE", "Failed to subscribe for node death event. rc [0x%x]", rc); return rc; } /* * Subscribe for node departure event. */ rc = clEventSubscribe(cpmEventNodeChannelHandle, &nodeDepartureFilterArray, CL_COR_NODE_DEPARTURE_SUBSCRIPTION_ID, NULL); if(CL_OK != rc) { clLogError("NOTIFY", "SUBSCRIBE", "Failed to subscribe for node departure event. rc [0x%x]", rc); return rc; } CL_FUNC_EXIT(); return (rc); }