ClRcT clEvtCpmInit() { ClNameT appName; ClCpmCallbacksT callbacks; ClVersionT version; ClIocPortT iocPort; ClRcT rc = CL_OK; /****************************************************************** CPM Related stuff ******************************************************************/ /* * Do the CPM client init/Register */ version.releaseCode = 'B'; version.majorVersion = 0x1; version.minorVersion = 0x1; callbacks.appHealthCheck = NULL; callbacks.appTerminate = clEventTerminate; callbacks.appCSISet = NULL; callbacks.appCSIRmv = NULL; callbacks.appProtectionGroupTrack = NULL; callbacks.appProxiedComponentInstantiate = NULL; callbacks.appProxiedComponentCleanup = NULL; clEoMyEoIocPortGet(&iocPort); rc = clCpmClientInitialize(&gClEvtTestContCpmHandle, &callbacks, &version); rc = clCpmComponentNameGet(gClEvtTestContCpmHandle, &appName); rc = clCpmComponentRegister(gClEvtTestContCpmHandle, &appName, NULL); return CL_OK; }
/* exec init function is called as soon as this service object is loaded. */ static int gms_exec_init_fn (struct objdb_iface_ver0 *objdb) { ClRcT rc = CL_OK; extern ClRcT clCpmComponentRegister(ClCpmHandleT ,const SaNameT *,const SaNameT *); log_init ("GMS"); clLog (DBG,OPN,AIS,"Initializing clovis GMS service"); gAspNativeLeaderElection = clAspNativeLeaderElection(); rc = clCpmComponentRegister( gmsGlobalInfo.cpmHandle, &gmsGlobalInfo.gmsComponentName, NULL ); if(rc) { clLog(ERROR,OPN,AIS, "clCpmComponent register failed with rc 0x%x",rc); } clLogMultiline(DBG,OPN,AIS, "clCpmComponentRegister successful. Updating GMS state as RUNNING"); gmsGlobalInfo.opState = CL_GMS_STATE_RUNNING; /* Initialize my ip address */ memset(&myAddress, 0, sizeof(ClGmsNodeAddressT)); clGmsWrapperUpdateMyIP(); return (0); }
ClRcT clEvtCpmInit() { ClNameT appName; ClCpmCallbacksT callbacks; ClVersionT version; ClIocPortT iocPort; ClRcT rc = CL_OK; version.releaseCode = 'B'; version.majorVersion = 0x1; version.minorVersion = 0x1; callbacks.appHealthCheck = NULL; callbacks.appTerminate = clEventTerminate; callbacks.appCSISet = NULL; callbacks.appCSIRmv = NULL; callbacks.appProtectionGroupTrack = NULL; callbacks.appProxiedComponentInstantiate = NULL; callbacks.appProxiedComponentCleanup = NULL; clEoMyEoIocPortGet(&iocPort); rc = clCpmClientInitialize(&gClEvtCpmHandle, &callbacks, &version); if (CL_OK != rc) { clLogWrite(CL_LOG_HANDLE_APP, CL_LOG_CRITICAL, NULL, CL_LOG_MESSAGE_2_LIBRARY_INIT_FAILED, "CPM Library", rc); } rc = clCpmComponentNameGet(gClEvtCpmHandle, &appName); rc = clCpmComponentRegister(gClEvtCpmHandle, &appName, NULL); return CL_OK; }
SaAisErrorT saAmfComponentRegister(SaAmfHandleT amfHandle, const SaNameT *compName, const SaNameT *proxyCompName) { ClRcT rc; SaNameT compNameInternal = {0}; SaNameT proxyCompNameInternal = {0}; SaNameT *proxy = (SaNameT*)proxyCompName; if(!compName) return SA_AIS_ERR_INVALID_PARAM; clNameCopy((ClNameT*)&compNameInternal, (const ClNameT*)compName); if(proxyCompName) { clNameCopy((ClNameT*)&proxyCompNameInternal, (const ClNameT*)proxyCompName); proxy = &proxyCompNameInternal; } rc = clCpmComponentRegister(amfHandle, (const ClNameT*)&compNameInternal, (const ClNameT*)proxy); return clClovisToSafError(rc); }
ClRcT clCompAppInitialize( ClUint32T argc, ClCharT *argv[]) { SaNameT appName; ClCpmCallbacksT callbacks; ClVersionT version; ClIocPortT iocPort; ClRcT rc = CL_OK; /* * Get the pid for the process and store it in global variable. */ mypid = getpid(); /* * Initialize and register with CPM. '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. */ version.releaseCode = 'B'; version.majorVersion = 01; version.minorVersion = 01; callbacks.appHealthCheck = NULL; callbacks.appTerminate = clCompAppTerminate; callbacks.appCSISet = clCompAppAMFCSISet; callbacks.appCSIRmv = clCompAppAMFCSIRemove; callbacks.appProtectionGroupTrack = NULL; /* * Get IOC Address, Port and Name. Register with AMF. */ clEoMyEoIocPortGet(&iocPort); if ( (rc = clCpmClientInitialize(&cpmHandle, &callbacks, &version)) ) goto errorexit; /* * If this component will provide a service, register it now. */ #if HAS_EO_SERVICES rc = clSAFComponent0EO0ClientInstall(); #endif /* * Do the application specific initialization here. */ /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ /* * Now register the component with AMF. At this point it is * ready to provide service, i.e. take work assignments. */ if ( (rc = clCpmComponentNameGet(cpmHandle, &appName)) ) goto errorexit; if ( (rc = clCpmComponentRegister(cpmHandle, &appName, NULL)) ) goto errorexit; /* * Print out standard information for this component. */ clprintf ("Component [%s] : PID [%d]. Initializing\n", appName.value, mypid); clprintf (" IOC Address : 0x%x\n", clIocLocalAddressGet()); clprintf (" IOC Port : 0x%x\n", iocPort); /* * This is where the application code starts. If the main thread usage * policy is CL_EO_USE_THREAD_FOR_APP, then return from this fn only * after the application terminates. If the main thread usage policy is * CL_EO_USE_THREAD_FOR_RECV, then return from this fn after doing the * application specific initialization and registration. */ /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ return rc; errorexit: clprintf ("Component [%s] : PID [%d]. Initialization error [0x%x]\n", appName.value, mypid, rc); return rc; }
ClRcT clCompAppInitialize( ClUint32T argc, ClCharT *argv[]) { ClNameT appName; ClCpmCallbacksT callbacks; ClVersionT version; ClIocPortT iocPort; ClRcT rc = CL_OK; /* * ---BEGIN_APPLICATION_CODE--- */ /* * Declare other local variables here. */ /* * ---END_APPLICATION_CODE--- */ /* * Get the pid for the process and store it in global variable. */ mypid = getpid(); /* * Initialize and register with CPM. '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. */ version.releaseCode = 'B'; version.majorVersion = 01; version.minorVersion = 01; callbacks.appHealthCheck = NULL; callbacks.appTerminate = clCompAppTerminate; callbacks.appCSISet = clCompAppAMFCSISet; callbacks.appCSIRmv = clCompAppAMFCSIRemove; callbacks.appProtectionGroupTrack = NULL; /* * Get IOC Address, Port and Name. Register with AMF. */ clEoMyEoIocPortGet(&iocPort); if ( (rc = clCpmClientInitialize(&cpmHandle, &callbacks, &version)) ) goto errorexit; /* * If this component will provide a service, register it now. */ #if HAS_EO_SERVICES /* Uncomment the following line if the EO is providing services and the method implementations are available for all the methods defined for this EO. rc = clcsa102CompEOClientInstall(void); */ #endif /* * Do the application specific initialization here. */ /* * ---BEGIN_APPLICATION_CODE--- */ clprintf(CL_LOG_SEV_INFO,"csa102: Initializing and registering with CPM..."); /* * ---END_APPLICATION_CODE--- */ /* * Now register the component with AMF. At this point it is * ready to provide service, i.e. take work assignments. */ if ( (rc = clCpmComponentNameGet(cpmHandle, &appName)) ) goto errorexit; if ( (rc = clCpmComponentRegister(cpmHandle, &appName, NULL)) ) goto errorexit; /* * Initialize the log stream */ clEvalAppLogStreamOpen(appName.value, &gEvalLogStream); /* * Print out standard information for this component. */ clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%ld]. Initializing", appName.value, mypid); clprintf (CL_LOG_SEV_INFO, " IOC Address : 0x%x", clIocLocalAddressGet()); clprintf (CL_LOG_SEV_INFO, " IOC Port : 0x%x", iocPort); /* * This is where the application code starts. If the main thread usage * policy is CL_EO_USE_THREAD_FOR_APP, then return from this fn only * after the application terminates. If the main thread usage policy is * CL_EO_USE_THREAD_FOR_RECV, then return from this fn after doing the * application specific initialization and registration. Main thread usage * policy can be set through IDE from Component porperty -> Eo properties. */ /* * ---BEGIN_APPLICATION_CODE--- */ clprintf(CL_LOG_SEV_INFO,"csa102: Instantiated as component instance %s.", appName.value); clprintf(CL_LOG_SEV_INFO,"%s: Waiting for CSI assignment...", appName.value); while (!exiting) { if (running) { clprintf(CL_LOG_SEV_INFO,"csa102: Hello World! %s", show_progress()); } sleep(1); } /* * ---END_APPLICATION_CODE--- */ return rc; errorexit: clprintf (CL_LOG_SEV_ERROR, "Component [%s] : PID [%ld]. Initialization error [0x%x]", appName.value, mypid, rc); return rc; }