ClInt32T main(ClInt32T argc, ClCharT *argv[]) { ClRcT rc = CL_OK; clAppConfigure(&clEoConfig,clEoBasicLibs,clEoClientLibs); rc = clEvtInitialize(argc,argv); if( rc != CL_OK ) { CL_DEBUG_PRINT(CL_DEBUG_CRITICAL, ("Event: clEvtInitialize failed [0x%X]\n\r", rc)); return rc; } /* Block on AMF dispatch file descriptor for callbacks. When this function returns its time to quit. */ dispatchLoop(); /* Do the Event Service finalization here. */ saAmfFinalize(gClEvtAmfHandle); return 0; }
ClRcT initializeAmf(void) { SaAmfCallbacksT callbacks; SaVersionT version; ClRcT rc = CL_OK; clLogCompName = (ClCharT*)"GMS"; /* Override generated eo name with a short name for our server */ /* this function overrides the default EO configuration */ clAppConfigure(&clEoConfig,clEoBasicLibs,clEoClientLibs); /* Do the CPM client init/Register */ version.releaseCode = 'B'; version.majorVersion = 0x01; version.minorVersion = 0x01; callbacks.saAmfHealthcheckCallback = NULL; callbacks.saAmfComponentTerminateCallback = clGmsServerTerminate; callbacks.saAmfCSISetCallback = NULL; callbacks.saAmfCSIRemoveCallback = NULL; callbacks.saAmfProtectionGroupTrackCallback = NULL; gmsGlobalInfo.opState = CL_GMS_STATE_STARTING_UP; clLog(INFO,GEN,NA, CL_GMS_SERVER_STARTED); /* Initialize AMF client library. */ rc = saAmfInitialize(&amfHandle, &callbacks, &version); if(rc!= SA_AIS_OK) { clLog(EMER,GEN,NA, "Sa AMF initialization Failed with rc [0x%x]. Booting Aborted",rc); exit(0); } gmsGlobalInfo.cpmHandle=amfHandle; /* * Now register the component with AMF. At this point it is * ready to provide service, i.e. take work assignments. */ rc = saAmfComponentNameGet(amfHandle, &appName); if(rc != SA_AIS_OK) { clLog(EMER,GEN,NA, "saAmfomponentNameGet Failed with rc [0x%x]. Booting Aborted",rc); exit(0); } gmsGlobalInfo.gmsComponentName.length=appName.length; memcpy(gmsGlobalInfo.gmsComponentName.value,appName.value,appName.length); rc = clEoMyEoObjectGet(&gmsGlobalInfo.gmsEoObject); if (rc != CL_OK) { clLog(EMER,GEN,NA, "clEoMyEoObjectGet Failed with rc [0x%x]. Booting Aborted",rc); exit(0); } rc = clDebugPromptSet(GMS_COMMAND_PROMPT); if( CL_OK == rc ) { clLog(NOTICE,GEN,NA, "GMS Server registering with debug service"); rc = clDebugRegister( gmsCliCommandsList, (int)(sizeof(gmsCliCommandsList)/sizeof(ClDebugFuncEntryT)), &gGmsDebugReg); } if( rc != CL_OK ) { clLog(ERROR,GEN,NA, "Failed to register with debug server, error [0x%x]. Debug shell access disabled", rc); } rc = clEoClientInstallTables ( gmsGlobalInfo.gmsEoObject, CL_EO_SERVER_SYM_MOD(gAspFuncTable, GMS)); if ( rc != CL_OK ) { clLog (EMER,GEN,NA, "Eo client install failed with rc [0x%x]. Booting aborted",rc); exit(0); } /* This function never returns the exit is done by causing a signal from * the Terminate function */ return CL_OK; }
static ClRcT initializeAmf(void) { ClRcT rc = CL_OK; ClRcT retCode; ClIocPhysicalAddressT notificationForComp = { CL_IOC_BROADCAST_ADDRESS, 0}; clLogCompName = (ClCharT*) "MSG"; /* Override generated eo name with a short name for our server */ clAppConfigure(&clEoConfig,clEoBasicLibs,clEoClientLibs); clMsgRegisterWithCpm(); if(gClMsgInit == CL_TRUE) { rc = CL_MSG_RC(CL_ERR_INITIALIZED); clLogError("MSG", "INI", "The Message Service is already initialized. error code [0x%x].", rc); goto error_out; } gLocalAddress = clIocLocalAddressGet(); gLocalPortId = CL_IOC_MSG_PORT; /* Initializing a database to maintain client information */ rc = clHandleDatabaseCreate((void (*)(void*))NULL, &gMsgClientHandleDb); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the handle database. error code [0x%x].", rc); goto error_out; } /* Initializing IDL for server to server and server to client communication. */ rc = clMsgCommIdlInitialize(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the IDL. error code [0x%x].", rc); goto error_out_2; } /* Initializing a database for maintaining queues. */ rc = clMsgQueueInitialize(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the queue databases. error code [0x%x].", rc); goto error_out_3; } rc = clMsgReceiverDatabaseInit(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize \"receiver database\". error code [0x%x].", rc); goto error_out_4; } rc = clOsalMutexInit(&gClMsgFinalizeLock); CL_ASSERT(rc == CL_OK); rc = clOsalCondInit(&gClMsgFinalizeCond); CL_ASSERT(rc == CL_OK); /* Initializing the Group-Information */ rc = clOsalMutexInit(&gClGroupDbLock); CL_ASSERT(rc == CL_OK); rc = clCpmNotificationCallbackInstall(notificationForComp, &clMsgNotificationReceiveCallback, NULL, &gMsgNotificationHandle); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to install the notification callback function. error code [0x%x].", rc); goto error_out_5; } /* Initializing the IDL generated code. */ rc = clMsgIdlClientInstall(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to install Server Table. error code [0x%x].", rc); goto error_out_6; } rc = clMsgIdlClientTableRegister(CL_IOC_MSG_PORT); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to register Server Table. error code [0x%x].", rc); goto error_out_7; } rc = clMsgCltClientTableRegister(CL_IOC_MSG_PORT); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to register Client Table. error code [0x%x].", rc); goto error_out_8; } rc = clMsgCltSrvClientInstall(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to install Client Server Table. error code [0x%x].", rc); goto error_out_9; } rc = clMsgCltSrvClientTableRegister(CL_IOC_MSG_PORT); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to register Client Server Table. error code [0x%x].", rc); goto error_out_10; } rc = clMsgFinalizeBlockInit(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the msg-finalize blocker. error code [0x%x].", rc); goto error_out_11; } clMsgDebugCliRegister(); rc = clOsalTaskCreateDetached("MsgCkptInitAsync", CL_OSAL_SCHED_OTHER, CL_OSAL_THREAD_PRI_NOT_APPLICABLE, 0, clMsgCachedCkptInitAsync, NULL); CL_ASSERT(rc == CL_OK); goto out; error_out_11: retCode = clMsgCltSrvClientTableDeregister(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to deregister Client Table. error code [0x%x].", retCode); error_out_10: retCode = clMsgCltSrvClientUninstall(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the just opened handle database. error code [0x%x].", retCode); error_out_9: retCode = clMsgCltClientTableDeregister(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to deregister Client Table. error code [0x%x].", retCode); error_out_8: retCode = clMsgIdlClientTableDeregister(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to deregister Server Table. error code [0x%x].", retCode); error_out_7: retCode = clMsgIdlClientUninstall(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the just opened handle database. error code [0x%x].", retCode); error_out_6: retCode = clCpmNotificationCallbackUninstall(&gMsgNotificationHandle); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to uninstall the notification callback function. error code [0x%x].", retCode); error_out_5: retCode = clOsalMutexDestroy(&gClGroupDbLock); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the group db mutex. error code [0x%x].", retCode); retCode = clOsalCondDestroy(&gClMsgFinalizeCond); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the finalization condition. error code [0x%x].", retCode); retCode = clOsalMutexDestroy(&gClMsgFinalizeLock); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the finalization mutex. error code [0x%x].", retCode); clMsgReceiverDatabaseFin(); error_out_4: retCode = clMsgQueueFinalize(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to finalize the queue databases. error code [0x%x].", retCode); error_out_3: clMsgCommIdlFinalize(); error_out_2: retCode = clHandleDatabaseDestroy(gMsgClientHandleDb); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the handle database. error code [0x%x].", retCode); error_out: out: return rc; }//end of intializeAmf
SaAisErrorT initializeAmf(void) { SaAmfCallbacksT callbacks; ClIocPortT iocPort=0; SaAisErrorT rc = SA_AIS_OK; /*This function overrides the default EO Configuaration */ clAppConfigure(&clEoConfig,clEoBasicLibs,clEoClientLibs); /* * Initialize and register with SAFplus AMF. 'version' specifies the * version of AMF with which this application would like to * interface. 'callbacks' is used to register the callbacks this * component expects to receive. */ /* * Set the supported version. */ gVersion.releaseCode = 'B'; gVersion.majorVersion = 0x01; gVersion.minorVersion = 0x01; /* * Fill the AMS's callback structure. */ callbacks.saAmfHealthcheckCallback = NULL; /* rarely necessary because SAFplus monitors the process */ callbacks.saAmfComponentTerminateCallback = ckptTerminate; callbacks.saAmfCSISetCallback = NULL; callbacks.saAmfCSIRemoveCallback = NULL; callbacks.saAmfProtectionGroupTrackCallback = NULL; /* * Get the port Id from IOC. */ clEoMyEoIocPortGet(&iocPort); /* Initialize AMF client library. */ rc = saAmfInitialize(&amfHandle, &callbacks, &gVersion); /* * Get the component name from AMF. */ rc = saAmfComponentNameGet(amfHandle, &appName); /* * Initialize ckpt server. */ clCkptLeakyBucketInitialize(); clCkptSvrInitialize(); rc = saAmfComponentRegister(amfHandle, &appName, NULL); gCkptSvr->amfHdl = amfHandle; /* * Obtain the component id from cpm. This will be used while registering * ckpt master address with TL. */ clAmfGetComponentId(gCkptSvr->amfHdl, &appName, &gCkptSvr->compId); /* * Register with debug server. */ ckptDebugRegister(gCkptSvr->eoHdl); return rc; }
ClRcT clLogSvrInitialize(ClUint32T argc,ClCharT *argv[]) { SaAmfCallbacksT callbacks = {0}; SaVersionT version; ClRcT rc = CL_OK; ClLogSvrEoDataT *pSvrEoEntry = NULL; ClBoolT *pCookie = NULL; ClIocAddressT invalidAddr = {{0}}; clLogCompName =(ClCharT*) "LOG"; /* Override generated eo name with a short name for our server */ gClLogServer = CL_FALSE; /* Mark me as the log server */ clLogInfo(CL_LOG_AREA_UNSPECIFIED, CL_LOG_CONTEXT_UNSPECIFIED, "Log Server initialization started..."); clAppConfigure(&clEoConfig,clEoBasicLibs,clEoClientLibs); version.releaseCode = 'B'; version.majorVersion = 0x01; version.minorVersion = 0x01; callbacks.saAmfHealthcheckCallback = NULL; /* rarely necessary because SAFplus monitors the process */ callbacks.saAmfComponentTerminateCallback = clLogSvrTerminate; callbacks.saAmfCSISetCallback = NULL; callbacks.saAmfCSIRemoveCallback = NULL; callbacks.saAmfProtectionGroupTrackCallback = NULL; callbacks.saAmfProxiedComponentInstantiateCallback = NULL; callbacks.saAmfProxiedComponentCleanupCallback = NULL; rc = saAmfInitialize(&amfHandle, &callbacks, &version); if( SA_AIS_OK != rc ) { CL_LOG_DEBUG_ERROR(("saAmfInitialize(): rc[0x %x]", rc)); return rc; } #if defined(CL_DEBUG) && defined(CL_DEBUG_START) clLogDebugLevelSet(); #endif CL_LOG_DEBUG_TRACE(("Enter")); clLogSvrMutexModeSet(); /* * Here dummy initialization of Idl handle to avoid mutiple database * Initialization & finalization databases. Keeping this handle alive * will avoid this. coz Idl library will delete the handle database if the * handle count becomes zero. Mutiple times we are initializing & deleting * the handles in our log service usage. */ rc = clLogIdlHandleInitialize(invalidAddr, &shLogDummyIdl); if( CL_OK != rc ) { return rc; } rc = clLogSvrCommonDataInit(); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogSvrCommonDataInit(): rc[0x %x]", rc)); CL_LOG_CLEANUP(clIdlHandleFinalize(shLogDummyIdl), CL_OK); return rc; } rc = clLogStreamOwnerLocalBootup(); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogStreamOwnerLocalInit(): rc[0x %x]", rc)); CL_LOG_CLEANUP(clLogSvrCommonDataFinalize(), CL_OK); CL_LOG_CLEANUP(clIdlHandleFinalize(shLogDummyIdl), CL_OK); return rc; } pCookie = (ClBoolT*) clHeapCalloc(1, sizeof(ClBoolT)); if( NULL == pCookie ) { CL_LOG_DEBUG_ERROR(("clHeapCalloc()")); CL_LOG_CLEANUP(clLogStreamOwnerLocalShutdown(), CL_OK); CL_LOG_CLEANUP(clLogStreamOwnerEoDataFree(), CL_OK); CL_LOG_CLEANUP(clLogSvrCommonDataFinalize(), CL_OK); CL_LOG_CLEANUP(clIdlHandleFinalize(shLogDummyIdl), CL_OK); return CL_LOG_RC(CL_ERR_NO_MEMORY); } *pCookie = CL_FALSE; rc = clLogSvrBootup(pCookie); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogSvrDataInit(): rc[0x %x]", rc)); clHeapFree(pCookie); CL_LOG_CLEANUP(clLogStreamOwnerLocalShutdown(), CL_OK); CL_LOG_CLEANUP(clLogSvrCommonDataFinalize(), CL_OK); CL_LOG_CLEANUP(clIdlHandleFinalize(shLogDummyIdl), CL_OK); return rc; } clLogInfo(CL_LOG_AREA_UNSPECIFIED, CL_LOG_CONTEXT_UNSPECIFIED, "Log server boot type is [%s]", (*pCookie == 1)? "Restart": "Normal"); rc = clLogSvrEoEntryGet(&pSvrEoEntry, NULL); if( CL_OK != rc ) { CL_LOG_CLEANUP(clLogSvrEoDataFinalize(), CL_OK); CL_LOG_CLEANUP(clLogSvrEoDataFree(), CL_OK); clHeapFree(pCookie); CL_LOG_CLEANUP(clLogStreamOwnerLocalShutdown(), CL_OK); CL_LOG_CLEANUP(clLogStreamOwnerEoDataFree(), CL_OK); CL_LOG_CLEANUP(clLogSvrCommonDataFinalize(), CL_OK); CL_LOG_CLEANUP(clIdlHandleFinalize(shLogDummyIdl), CL_OK); return rc; } pSvrEoEntry->hCpm = amfHandle; rc = saAmfComponentNameGet(amfHandle, &logServerName); if( SA_AIS_OK != rc ) { CL_LOG_DEBUG_ERROR(("saAmfComponentNameGet(): rc[0x %x]", rc)); saAmfFinalize(amfHandle); CL_LOG_CLEANUP(clLogSvrEoDataFinalize(), CL_OK); CL_LOG_CLEANUP(clLogSvrEoDataFree(), CL_OK); clHeapFree(pCookie); CL_LOG_CLEANUP(clLogStreamOwnerLocalShutdown(), CL_OK); CL_LOG_CLEANUP(clLogStreamOwnerEoDataFree(), CL_OK); CL_LOG_CLEANUP(clLogSvrCommonDataFinalize(), CL_OK); CL_LOG_CLEANUP(clIdlHandleFinalize(shLogDummyIdl), CL_OK); return rc; } rc = saAmfComponentRegister(amfHandle, &logServerName, NULL); if( SA_AIS_OK != rc ) { CL_LOG_DEBUG_ERROR(("saAmfComponentRegister(): rc[0x %x]", rc)); CL_LOG_CLEANUP(clLogSvrEoDataFinalize(), CL_OK); CL_LOG_CLEANUP(clLogSvrEoDataFree(), CL_OK); clHeapFree(pCookie); CL_LOG_CLEANUP(clLogStreamOwnerLocalShutdown(), CL_OK); CL_LOG_CLEANUP(clLogStreamOwnerEoDataFree(), CL_OK); CL_LOG_CLEANUP(clLogSvrCommonDataFinalize(), CL_OK); CL_LOG_CLEANUP(clIdlHandleFinalize(shLogDummyIdl), CL_OK); saAmfFinalize(amfHandle); return rc; } pSvrEoEntry->hTimer = CL_HANDLE_INVALID_VALUE; if( CL_FALSE == *pCookie ) { rc = clLogSvrTimerDeleteNStart(pSvrEoEntry, pCookie); } else { rc = clLogTimerCallback((void *) pCookie); } if( CL_OK != rc ) { saAmfComponentUnregister(amfHandle, &logServerName, NULL); CL_LOG_CLEANUP(clLogSvrEoDataFinalize(), CL_OK); CL_LOG_CLEANUP(clLogSvrEoDataFree(), CL_OK); clHeapFree(pCookie); CL_LOG_CLEANUP(clLogStreamOwnerLocalShutdown(), CL_OK); CL_LOG_CLEANUP(clLogStreamOwnerEoDataFree(), CL_OK); CL_LOG_CLEANUP(clLogSvrCommonDataFinalize(), CL_OK); CL_LOG_CLEANUP(clIdlHandleFinalize(shLogDummyIdl), CL_OK); saAmfFinalize(amfHandle); return rc; } rc = clLogDebugRegister(); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogDebugRegister(): rc[0x %x]", rc)); } clLogNotice(CL_LOG_AREA_UNSPECIFIED, CL_LOG_CONTEXT_UNSPECIFIED, "Log Server partially up"); CL_LOG_DEBUG_TRACE(("Exit")); return CL_OK; }
ClRcT clLogSvrInitialize(ClUint32T argc,ClCharT *argv[]) { SaAmfCallbacksT callbacks = {0}; SaVersionT version; ClRcT rc = CL_OK; ClBoolT *pCookie = NULL; clLogCompName =(ClCharT*) "LOG"; /* Override generated eo name with a short name for our server */ gClLogServer = CL_FALSE; /* Mark me as the log server */ clLogInfo(CL_LOG_AREA_UNSPECIFIED, CL_LOG_CONTEXT_UNSPECIFIED, "Log Server initialization started..."); clAppConfigure(&clEoConfig,clEoBasicLibs,clEoClientLibs); version.releaseCode = 'B'; version.majorVersion = 0x01; version.minorVersion = 0x01; callbacks.saAmfHealthcheckCallback = NULL; /* rarely necessary because SAFplus monitors the process */ callbacks.saAmfComponentTerminateCallback = clLogSvrTerminate; callbacks.saAmfCSISetCallback = NULL; callbacks.saAmfCSIRemoveCallback = NULL; callbacks.saAmfProtectionGroupTrackCallback = NULL; callbacks.saAmfProxiedComponentInstantiateCallback = NULL; callbacks.saAmfProxiedComponentCleanupCallback = NULL; rc = saAmfInitialize(&amfHandle, &callbacks, &version); if( SA_AIS_OK != rc ) { CL_LOG_DEBUG_ERROR(("saAmfInitialize(): rc[0x %x]", rc)); return rc; } rc = saAmfComponentNameGet(amfHandle, &logServerName); if( SA_AIS_OK != rc ) { CL_LOG_DEBUG_ERROR(("saAmfComponentNameGet(): rc[0x %x]", rc)); saAmfFinalize(amfHandle); CL_LOG_CLEANUP(clLogSvrEoDataFinalize(), CL_OK); CL_LOG_CLEANUP(clLogSvrEoDataFree(), CL_OK); clHeapFree(pCookie); CL_LOG_CLEANUP(clLogStreamOwnerLocalShutdown(), CL_OK); CL_LOG_CLEANUP(clLogStreamOwnerEoDataFree(), CL_OK); CL_LOG_CLEANUP(clLogSvrCommonDataFinalize(), CL_OK); CL_LOG_CLEANUP(clIdlHandleFinalize(shLogDummyIdl), CL_OK); return rc; } rc = saAmfComponentRegister(amfHandle, &logServerName, NULL); if( SA_AIS_OK != rc ) { CL_LOG_DEBUG_ERROR(("saAmfComponentRegister(): rc[0x %x]", rc)); CL_LOG_CLEANUP(clLogSvrEoDataFinalize(), CL_OK); CL_LOG_CLEANUP(clLogSvrEoDataFree(), CL_OK); clHeapFree(pCookie); CL_LOG_CLEANUP(clLogStreamOwnerLocalShutdown(), CL_OK); CL_LOG_CLEANUP(clLogStreamOwnerEoDataFree(), CL_OK); CL_LOG_CLEANUP(clLogSvrCommonDataFinalize(), CL_OK); CL_LOG_CLEANUP(clIdlHandleFinalize(shLogDummyIdl), CL_OK); saAmfFinalize(amfHandle); return rc; } clLogNotice(CL_LOG_AREA_UNSPECIFIED, CL_LOG_CONTEXT_UNSPECIFIED, "Log Server partially up"); CL_LOG_DEBUG_TRACE(("Exit")); return CL_OK; }