void ReadinessStateSetCallback (SaInvocationT invocation, const SaNameT *compName, SaAmfReadinessStateT readinessState) { switch (readinessState) { case SA_AMF_IN_SERVICE: printf ("ReadinessStateSetCallback: '"); printSaNameT ((SaNameT *)compName); printf ("' requested to enter operational state SA_AMF_IN_SERVICE.\n"); saAmfResponse (invocation, SA_OK); break; case SA_AMF_OUT_OF_SERVICE: printf ("ReadinessStateSetCallback: '"); printSaNameT ((SaNameT *)compName); printf ("' requested to enter operational state SA_AMF_OUT_OF_SERVICE.\n"); saAmfResponse (invocation, SA_OK); break; case SA_AMF_STOPPING: printf ("ReadinessStateSetCallback: '"); printSaNameT ((SaNameT *)compName); printf ("' requested to enter operational state SA_AMF_STOPPING.\n"); saAmfStoppingComplete (invocation, SA_OK); break; } }
void CSISetCallback ( SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT *csiDescriptor) { int res; switch (haState) { case SA_AMF_HA_ACTIVE: printf ("CSISetCallback:"); printf ("for CSI '"); printSaNameT ((SaNameT *)&csiDescriptor->csiName); printf ("' for component "); printSaNameT ((SaNameT *)compName); printf ("'"); printf (" requested to enter hastate SA_AMF_ACTIVE.\n"); res = saAmfResponse (handle, invocation, SA_AIS_OK); break; case SA_AMF_HA_STANDBY: printf ("CSISetCallback:"); printf ("for CSI '"); printSaNameT ((SaNameT *)compName); printf ("' for component "); printSaNameT ((SaNameT *)compName); printf ("'"); printf (" requested to enter hastate SA_AMF_STANDBY.\n"); saAmfResponse (handle, invocation, SA_AIS_OK); break; } }
/** * AMF invoked this callback periodically to assess our health. * * @param inv * @param comp_name * @param health_check_key */ static void amf_healthcheck_callback(SaInvocationT inv, const SaNameT *comp_name, SaAmfHealthcheckKeyT *health_check_key) { SaAisErrorT rc, status = SA_AIS_OK; static int healthcheck_count = 0; healthcheck_count++; syslog(LOG_DEBUG, "Health check %u", healthcheck_count); /* Check the status of our service but only if active */ if ((my_ha_state == SA_AMF_HA_ACTIVE) && (foo_healthcheck() != 0)) { /* 7.8.2 - an error report should be done before returning failed op */ rc = saAmfComponentErrorReport(my_amf_hdl, &my_comp_name, 0, SA_AMF_COMPONENT_RESTART, SA_NTF_IDENTIFIER_UNUSED); if (rc != SA_AIS_OK) { syslog(LOG_ERR, "saAmfComponentErrorReport FAILED - %u", rc); exit(1); } status = SA_AIS_ERR_FAILED_OPERATION; } rc = saAmfResponse(my_amf_hdl, inv, status); if (rc != SA_AIS_OK) { syslog(LOG_ERR, "saAmfResponse FAILED - %u", rc); exit(1); } }
void ckptTerminate(SaInvocationT invocation, const SaNameT *compName) { SaAisErrorT rc = SA_AIS_OK; clLogWarning(CL_LOG_AREA_UNSPECIFIED, CL_LOG_CONTEXT_UNSPECIFIED,"Checkpoint service is stopping."); /* * Deregister with debug server. */ ckptDebugDeregister(gCkptSvr->eoHdl); /* * Wait for all the other threads to finalize */ clEoQueuesQuiesce(); /* * Deregister with cpm. */ rc = saAmfComponentUnregister(amfHandle, compName, NULL); /* * Cleanup the persistent DB information. */ /* Feature not supported -- see bug 6017 -- don't forget to uncomment ckptDataBackupInitialize()! ckptDataBackupFinalize(); */ /* * Cleanup resources taken by ckpt server. */ ckptShutDown(); /* Ok tell SAFplus that we handled it properly */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); unblockNow = CL_TRUE; }
void clCompAppAMFCSIRemove( SaInvocationT invocation, const SaNameT *compName, const SaNameT *csiName, SaAmfCSIFlagsT csiFlags) { /* * Print information about the CSI Remove */ clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. CSI Remove Received\n", compName->length, compName->value, mypid); clprintf (CL_LOG_SEV_INFO, " CSI : %.*s\n", csiName->length, csiName->value); clprintf (CL_LOG_SEV_INFO, " CSI Flags : 0x%d\n", csiFlags); /* * Add application specific logic for removing the work for this CSI. */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); return; }
static void clCompAppAMFCSIRemove(SaInvocationT invocation, const SaNameT *compName, const SaNameT *csiName, SaAmfCSIFlagsT csiFlags) { clprintf (CL_LOG_SEV_INFO, "Node Addr [%d] Component [%s] : PID [%d]. CSI Remove Received\n", ASP_NODEADDR, compName->value, mypid); clprintf (CL_LOG_SEV_INFO, " CSI : %s\n", csiName->value); clprintf (CL_LOG_SEV_INFO, " CSI Flags : 0x%d\n", csiFlags); /* * Add application specific logic for removing the work for this CSI. */ /* * ---BEGIN_APPLICATION_CODE--- */ clPyGlueCsiRemove(compName, csiName, csiFlags); /* * ---END_APPLICATION_CODE--- */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); return; }
static void clCompAppAMFCSISet(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { /* * ---BEGIN_APPLICATION_CODE--- */ clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%d]. CSISet called\n", compName->value, mypid); clPyGlueCsiSet(compName, haState,&csiDescriptor); clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%d]. PyGlueCsiSet() returned OK\n", compName->value, mypid); /* if (haState != SA_AMF_HA_QUIESCING) */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); /* GAS TODO: put in a separate python-visible callback */ if (haState == SA_AMF_HA_QUIESCING) saAmfCSIQuiescingComplete(amfHandle, invocation, SA_AIS_OK); /* * ---END_APPLICATION_CODE--- */ /* * Print information about the CSI Set */ clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%d]. CSI Set Received\n", compName->value, mypid); clCompAppAMFPrintCSI(csiDescriptor, haState); }
/**************************************************************************** * Name : gld_quisced_process * * Description : Instruction from the GLND to set the orphan flag * * Arguments : evt - Event structure * * Return Values : NCSCC_RC_SUCCESS/ NCSCC_RC_FAILURE * * Notes : None. *****************************************************************************/ static uint32_t gld_quisced_process(GLSV_GLD_EVT *evt) { GLSV_GLD_CB *gld_cb = evt->gld_cb; SaAisErrorT saErr = SA_AIS_OK; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); if ((evt == GLSV_GLD_EVT_NULL) || (gld_cb == NULL)){ rc = NCSCC_RC_FAILURE; goto end; } if (gld_cb->is_quiasced) { gld_cb->ha_state = SA_AMF_HA_QUIESCED; /* Give up our IMM OI implementer role */ rc = immutil_saImmOiImplementerClear(gld_cb->immOiHandle); if (rc != SA_AIS_OK) { LOG_ER("saImmOiImplementerClear failed: err = %d", rc); } gld_cb->is_impl_set = false; rc = glsv_gld_mbcsv_chgrole(gld_cb); if (rc != NCSCC_RC_SUCCESS) { m_LEAP_DBG_SINK(NCSCC_RC_FAILURE); goto end; } saAmfResponse(gld_cb->amf_hdl, gld_cb->invocation, saErr); gld_cb->is_quiasced = false; } end: TRACE_LEAVE(); return rc; }
/**************************************************************************** Name : proxied_healthcheck_callback Description : This routine is a callback to perform the healthcheck and report any healthcheck failure to AMF. It is specified as a part of AMF initialization. It demonstrates the use of following AMF APIs: a) saAmfHealthcheckStop() b) saAmfComponentErrorReport() Arguments : inv - particular invocation of this callback function comp_name - ptr to the component name health_check_key - ptr to the healthcheck key for which the healthcheck is to be performed. Return Values : None. Notes : This routine responds to the healhcheck callbacks for AVSV_HEALTHCHECK_CALLBACK_MAX_COUNT times after which it sends an error report. ******************************************************************************/ void proxied_healthcheck_callback(SaInvocationT inv, const SaNameT *comp_name, SaAmfHealthcheckKeyT *health_check_key) { SaAisErrorT rc; static int healthcheck_count = 0; uns32 index = 0; printf("\n Dispatched 'HealthCheck' Callback \n Component: %s \n HealthCheckKey: %s \n", comp_name->value, health_check_key->key); for(index=0; index<PXY_PXD_NUM_OF_PROXIED_COMP; index++) { if(0 == strcmp(comp_name->value, pxy_pxd_cb.pxd_info[index].compName.value)) break; } if(PXY_PXD_NUM_OF_PROXIED_COMP == index) printf("\n Component not found, index\n"); else printf("\n Component %s, index %d\n", pxy_pxd_cb.pxd_info[index].compName.value, index); /* Respond immediately */ rc = saAmfResponse(pxy_pxd_cb.pxd_info[index].amfHandle, inv, SA_AIS_OK); if ( SA_AIS_OK != rc ) { printf("\nsaAmfResponse failure for HC. Comp %s,Result %d\n", pxy_pxd_cb.pxd_info[index].compName.value, rc); return; } return; }
/**************************************************************************** * Name : cpnd_saf_health_chk_callback * * Description : This function SAF callback function which will be called * when the AMF framework needs to health for the component. * * Arguments : invocation - This parameter designated a particular * invocation of this callback function. The * invoke process return invocation when it * responds to the Availability Management * FrameWork using the saAmfResponse() * function. * compName - A pointer to the name of the component * whose readiness stae the Availability * Management Framework is setting. * checkType - The type of healthcheck to be executed. * * Return Values : None * * Notes : At present we are just support a simple liveness check. *****************************************************************************/ void cpnd_saf_health_chk_callback(SaInvocationT invocation, const SaNameT *compName, const SaAmfHealthcheckKeyT *checkType) { CPND_CB *cpnd_cb = NULL; SaAisErrorT error = SA_AIS_OK; uns32 cb_hdl = m_CPND_GET_CB_HDL; /* Get the CB from the handle */ cpnd_cb = ncshm_take_hdl(NCS_SERVICE_ID_CPND, cb_hdl); if (!cpnd_cb) { m_LOG_CPND_CL(CPND_CB_HDL_TAKE_FAILED, CPND_FC_HDLN, NCSFL_SEV_ERROR, __FILE__, __LINE__); return; } if (saAmfResponse(cpnd_cb->amf_hdl, invocation, error) != SA_AIS_OK) { m_LOG_CPND_CL(CPND_AMF_RESPONSE_FAILED, CPND_FC_HDLN, NCSFL_SEV_ERROR, __FILE__, __LINE__); ncshm_give_hdl(cb_hdl); return; } /* giveup the handle */ ncshm_give_hdl(cb_hdl); return; }
/**************************************************************************** * Name : eds_proc_quiesced_ack_evt * * Description : This is the function which is called when eds receives an * quiesced ack event from MDS * * Arguments : evt - Message that was posted to the EDS Mail box. * * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE * * Notes : None. *****************************************************************************/ static uint32_t eds_proc_quiesced_ack_evt(EDSV_EDS_EVT *evt) { EDS_CB *cb; TRACE_ENTER(); /* Retrieve the cb handle */ if (NULL == (cb = (EDS_CB *)ncshm_take_hdl(NCS_SERVICE_ID_EDS, evt->cb_hdl))) { TRACE_LEAVE(); return NCSCC_RC_FAILURE; } if (cb->is_quisced_set == true) { cb->ha_state = SA_AMF_HA_QUIESCED; /* Inform MBCSV of HA state change */ if (eds_mbcsv_change_HA_state(cb) != NCSCC_RC_SUCCESS) { TRACE("EDS-MBCSV change role failed"); } /* Update control block */ saAmfResponse(cb->amf_hdl, cb->amf_invocation_id, SA_AIS_OK); cb->is_quisced_set = false; /* Give the cb handle back */ ncshm_give_hdl(evt->cb_hdl); } else { TRACE("Quiesced set is false"); ncshm_give_hdl(evt->cb_hdl); } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : proxy_healthcheck_callback Description : This routine is a callback to perform the healthcheck and report any healthcheck failure to AMF. It is specified as a part of AMF initialization. It demonstrates the use of following AMF APIs: a) saAmfHealthcheckStop() b) saAmfComponentErrorReport() Arguments : inv - particular invocation of this callback function comp_name - ptr to the component name health_check_key - ptr to the healthcheck key for which the healthcheck is to be performed. Return Values : None. Notes : This routine responds to the healhcheck callbacks for AVSV_HEALTHCHECK_CALLBACK_MAX_COUNT times after which it sends an error report. ******************************************************************************/ void proxy_healthcheck_callback(SaInvocationT inv, const SaNameT *comp_name, SaAmfHealthcheckKeyT *health_check_key) { SaAisErrorT rc; static int healthcheck_count = 0; printf("\n Dispatched 'HealthCheck' Callback \n Component: %s \n HealthCheckKey: %s \n", comp_name->value, health_check_key->key); /* Respond immediately */ rc = saAmfResponse(pxy_pxd_cb.pxy_info.amfHandle, inv, SA_AIS_OK); if ( SA_AIS_OK != rc ) { saAmfComponentUnregister(pxy_pxd_cb.pxy_info.amfHandle, &pxy_pxd_cb.pxy_info.compName, 0); saAmfFinalize(pxy_pxd_cb.pxy_info.amfHandle); printf("\nsaAmfResponse returned failure for Health Check. Result %d\n",rc); return; } /* Increment healthcheck count */ healthcheck_count++; return; }
/**************************************************************************** Name : proxied_csi_remove_callback Description : This routine is a callback to remove the CSI (or all the CSIs) that is/are assigned to the component. It is specified as a part of AMF initialization. Arguments : inv - particular invocation of this callback function comp_name - ptr to the component name csi_name - ptr to the CSI name that is being removed csi_flags - specifies if one or more CSIs are affected Return Values : None. Notes : None ******************************************************************************/ void proxied_csi_remove_callback(SaInvocationT inv, const SaNameT *comp_name, const SaNameT *csi_name, SaAmfCSIFlagsT csi_flags) { SaAisErrorT rc; uns32 index = 0; printf("\n Proxied 'CSI Remove' Callback \n Component: %s \n CSI: %s \n CSIFlags: %s \n", comp_name->value, csi_name->value, csi_flag_str[csi_flags]); for(index=0; index<PXY_PXD_NUM_OF_PROXIED_COMP; index++) { if(0 == strcmp(comp_name->value, pxy_pxd_cb.pxd_info[index].compName.value)) break; } if(PXY_PXD_NUM_OF_PROXIED_COMP == index) printf("\n Component not found, index\n"); else printf("\n Component %s, index %d\n", pxy_pxd_cb.pxd_info[index].compName.value, index); /* Reset the ha state */ pxy_pxd_cb.pxd_info[index].haState = 0; /* Respond immediately */ rc = saAmfResponse(pxy_pxd_cb.pxd_info[index].amfHandle, inv, SA_AIS_OK); if ( SA_AIS_OK != rc ) { printf("\nsaAmfResponse failure for CSI Rem. Comp %s,Result %d\n", pxy_pxd_cb.pxd_info[index].compName.value, rc); } return; }
void clCompAppTerminate(SaInvocationT invocation, const SaNameT *compName) { SaAisErrorT rc = SA_AIS_OK; clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. Terminating\n", compName->length, compName->value, mypid); /* * Unregister with AMF and respond to AMF saying whether the * termination was successful or not. */ if ( (rc = saAmfComponentUnregister(amfHandle, compName, NULL)) != SA_AIS_OK) goto errorexit; saAmfResponse(amfHandle, invocation, SA_AIS_OK); clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. Terminated\n", compName->length, compName->value, mypid); unblockNow = CL_TRUE; return; errorexit: clprintf (CL_LOG_SEV_ERROR, "Component [%.*s] : PID [%d]. Termination error [0x%x]\n", compName->length, compName->value, mypid, rc); return; }
void safTerminate(SaInvocationT invocation, const SaNameT *compName) { SaAisErrorT rc = SA_AIS_OK; clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. Terminating\n", compName->length, compName->value, mypid); /* * Unregister with AMF and respond to AMF saying whether the * termination was successful or not. */ if ( (rc = saAmfComponentUnregister(amfHandle, compName, NULL)) != SA_AIS_OK) { clprintf (CL_LOG_SEV_ERROR, "Component [%.*s] : PID [%d]. Unregister failed with error [0x%x]\n", compName->length, compName->value, mypid, rc); return; } /* Ok tell SAFplus that we handled it properly */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. Terminated\n", compName->length, compName->value, mypid); clEvalAppLogStreamClose(gEvalLogStream); unblockNow = CL_TRUE; }
/**************************************************************************** * Name : amf_csi_rmv_callback * * Description : This callback routine is invoked by AMF during a * CSI set removal operation. * * Arguments : invocation - This parameter designated a particular * invocation of this callback function. The * invoke process return invocation when it * responds to the Avilability Management * FrameWork using the saAmfResponse() * function. * compName - A pointer to the name of the component * whose readiness stae the Availability * Management Framework is setting. * csiName - A const pointer to csiName * csiFlags - csi Flags * Return Values : None *****************************************************************************/ static void amf_csi_rmv_callback(SaInvocationT invocation, const SaNameT *compName, const SaNameT *csiName, const SaAmfCSIFlagsT csiFlags) { TRACE_ENTER(); saAmfResponse(ntfs_cb->amf_hdl, invocation, SA_AIS_OK); TRACE_LEAVE(); }
void clLogSvrTerminate(SaInvocationT invocation, const SaNameT *compName) { ClRcT rc = CL_OK; ClLogSvrEoDataT *pSvrEoEntry = NULL; //ClHandleT hCpm = CL_HANDLE_INVALID_VALUE; CL_LOG_DEBUG_TRACE(("Enter")); clLogInfo("SVR", "MAI", "Unregistering with cpm...... [%.*s]\n", compName->length, compName->value); gClLogSvrExiting = CL_TRUE; rc = clLogSvrEoEntryGet(&pSvrEoEntry, NULL); if( CL_OK != rc ) { return ; } //hCpm = pSvrEoEntry->hCpm; saAmfComponentUnregister(amfHandle,compName, NULL); #if 1 CL_LOG_CLEANUP(clLogSvrShutdown(), CL_OK); #endif saAmfResponse(amfHandle, invocation, SA_AIS_OK); CL_LOG_DEBUG_TRACE(("Exit")); unblockNow = CL_TRUE; //(void)hCpm; }
/**************************************************************************** Name : proxied_comp_cleanup_callback Description : This routine is a callback to clean proxied comp. It is specified as a part of AMF initialization. Arguments : inv - particular invocation of this callback function comp_name - ptr to the component name Return Values : None. Notes : None ******************************************************************************/ void proxied_comp_cleanup_callback(SaInvocationT inv, const SaNameT *comp_name) { SaAisErrorT error=SA_AIS_OK; SaAisErrorT rc; uns32 index = 0; printf("\n Proxied 'Pxied Comp Cleanup ' Callback \n Component: %s \n", comp_name->value); for(index=0; index<PXY_PXD_NUM_OF_PROXIED_COMP; index++) { if(0 == strcmp(comp_name->value, pxy_pxd_cb.pxd_info[index].compName.value)) break; } if(PXY_PXD_NUM_OF_PROXIED_COMP == index) printf("\n Component not found, index\n"); else printf("\n Component %s, index %d\n", pxy_pxd_cb.pxd_info[index].compName.value, index); rc = saAmfResponse(pxy_pxd_cb.pxd_info[index].amfHandle, inv, error); if ( SA_AIS_OK != rc ) { printf("\nsaAmfResponse failure for Pxd Comp Term. Comp %s,Result %d\n", pxy_pxd_cb.pxd_info[index].compName.value, rc); } return; }
static void healthcheck_callback(SaInvocationT inv, const SaNameT *comp_name, SaAmfHealthcheckKeyT *health_check_key) { int status; SaAisErrorT rc = SA_AIS_OK; status = exec_command(health_script); if (status != 0) { rc = saAmfComponentErrorReport(my_amf_hdl, &my_comp_name, 0, SA_AMF_NO_RECOMMENDATION, SA_NTF_IDENTIFIER_UNUSED); if (rc != SA_AIS_OK) { syslog(LOG_ERR, "HC callback: saAmfComponentErrorReport FAILED (%u)", rc); exit(1); } rc = SA_AIS_ERR_FAILED_OPERATION; } rc = saAmfResponse(my_amf_hdl, inv, rc); if (rc != SA_AIS_OK) { syslog(LOG_ERR, "HC callback: saAmfResponse FAILED (%u)", rc); exit(1); } }
static void csi_set_callback(SaInvocationT invocation, const SaNameT *comp_name, SaAmfHAStateT ha_state, SaAmfCSIDescriptorT csi_desc) { SaAisErrorT rc, status = SA_AIS_OK; SaAmfCSIAttributeT *attr; int i; if (csi_desc.csiFlags == SA_AMF_CSI_ADD_ONE) { syslog(LOG_DEBUG, "CSI Set - add '%s' HAState %s", csi_desc.csiName.value, ha_state_name[ha_state]); for (i = 0; i < csi_desc.csiAttr.number; i++) { attr = &csi_desc.csiAttr.attr[i]; syslog(LOG_DEBUG, " name: %s, value: %s", attr->attrName, attr->attrValue); setenv((char*)attr->attrName, (char*)attr->attrValue, 1); } } else { assert(csi_desc.csiFlags == SA_AMF_CSI_TARGET_ALL); syslog(LOG_DEBUG, "CSI Set - HAState %s", ha_state_name[ha_state]); } switch (ha_state) { case SA_AMF_HA_ACTIVE: status = service_start(); break; case SA_AMF_HA_STANDBY: break; case SA_AMF_HA_QUIESCED: status = service_stop(); break; case SA_AMF_HA_QUIESCING: break; default: syslog(LOG_ERR, "CSI Set: unknown HA state (%u)", ha_state); exit(1); break; } my_ha_state = ha_state; rc = saAmfResponse(my_amf_hdl, invocation, status); if (rc != SA_AIS_OK) { syslog(LOG_ERR, "CSI Set: saAmfResponse FAILED (%u)", rc); exit(1); } if (ha_state == SA_AMF_HA_QUIESCING) { status = service_stop(); rc = saAmfCSIQuiescingComplete(my_amf_hdl, invocation, status); if (rc != SA_AIS_OK) { syslog(LOG_ERR, "CSI Set: saAmfCSIQuiescingComplete FAILED (%u)", rc); exit(1); } } }
static uns32 cpd_evt_mds_quiesced_ack_rsp(CPD_CB *cb, CPD_EVT *evt, CPSV_SEND_INFO *sinfo) { uns32 rc = NCSCC_RC_SUCCESS; SaAisErrorT saErr = SA_AIS_OK; cpd_mbcsv_chgrole(cb); saAmfResponse(cb->amf_hdl, cb->amf_invocation, saErr); return rc; }
void rde_saf_comp_terminate_callback(SaInvocationT invocation, const SaNameT *compName) { RDE_AMF_CB *rde_amf_cb = rde_amf_get_cb(); TRACE_ENTER(); (void) saAmfResponse(rde_amf_cb->amf_hdl, invocation, SA_AIS_OK); }
/**************************************************************************** Name : proxied_csi_set_callback Description : This routine is a callback to set (add/modify) the HA state of a CSI (or all the CSIs) that is newly/already assigned to the component. It is specified as a part of AMF initialization. Arguments : inv - particular invocation of this callback function comp_name - ptr to the component name ha_state - ha state to be assumed by the CSI (or all the CSIs) csi_desc - CSI descriptor Return Values : None. Notes : None. ******************************************************************************/ void proxied_csi_set_callback(SaInvocationT inv, const SaNameT *comp_name, SaAmfHAStateT ha_state, SaAmfCSIDescriptorT csi_desc) { SaAmfHAStateT ha_st; SaAisErrorT rc = SA_AIS_OK; SaAmfHealthcheckInvocationT hc_inv; SaAmfRecommendedRecoveryT rec_rcvr; SaNameT *csi_name; uns8 trk_flags; SaAisErrorT error=SA_AIS_OK; uns32 index = 0; printf("\n'Proxied CSI Set' Callback \n Component: %s \n CSIName: %s \n HAState: %s \n CSIFlags: %s \n", comp_name->value, csi_desc.csiName.value, ha_state_str[ha_state], csi_flag_str[csi_desc.csiFlags]); for(index=0; index<PXY_PXD_NUM_OF_PROXIED_COMP; index++) { if(0 == strcmp(comp_name->value, pxy_pxd_cb.pxd_info[index].compName.value)) break; } if(PXY_PXD_NUM_OF_PROXIED_COMP == index) printf("\n Component not found, index\n"); else printf("\n Component %s, index %d\n", pxy_pxd_cb.pxd_info[index].compName.value, index); switch(ha_state) { case SA_AMF_HA_ACTIVE: /* We need to register all the proxied component when becoming ACT */ pxy_pxd_cb.pxd_info[index].haState = ha_state; break; case SA_AMF_HA_STANDBY: case SA_AMF_HA_QUIESCED: /* We need to unregister to all proxied components, if going to STDBY from ACT.*/ pxy_pxd_cb.pxd_info[index].haState = ha_state; break; default: rc=SA_AIS_ERR_FAILED_OPERATION; break; }; rc = saAmfResponse(pxy_pxd_cb.pxd_info[index].amfHandle, inv, error); if ( SA_AIS_OK != rc ) { printf("\nsaAmfResponse failure for CSI Set. Comp %s,Result %d\n", pxy_pxd_cb.pxd_info[index].compName.value, rc); return; } return; }
static void rde_saf_health_chk_callback(SaInvocationT invocation, const SaNameT *compName, SaAmfHealthcheckKeyT *checkType) { RDE_AMF_CB *rde_amf_cb = rde_amf_get_cb(); TRACE_ENTER(); (void) saAmfResponse(rde_amf_cb->amf_hdl, invocation, SA_AIS_OK); }
void rde_saf_CSI_rem_callback(SaInvocationT invocation, const SaNameT *compName, const SaNameT *csiName, const SaAmfCSIFlagsT csiFlags) { RDE_AMF_CB *rde_amf_cb = rde_amf_get_cb(); TRACE_ENTER(); (void) saAmfResponse(rde_amf_cb->amf_hdl, invocation, SA_AIS_OK); }
static void rde_saf_CSI_set_callback(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { RDE_AMF_CB *rde_amf_cb = rde_amf_get_cb(); TRACE_ENTER(); (void) saAmfResponse(rde_amf_cb->amf_hdl, invocation, SA_AIS_OK); }
static void safTerminate(SaInvocationT invocation, const SaNameT *compName) { SaAisErrorT rc = SA_AIS_OK; if(gClMsgInit) { ClBoolT lockStatus = CL_TRUE; ClTimerTimeOutT timeout = {.tsSec = 0, .tsMilliSec = 0}; clOsalMutexLock(&gClMsgFinalizeLock); while(gClMsgSvcRefCnt > 0) { clOsalCondWait(&gClMsgFinalizeCond, &gClMsgFinalizeLock, timeout); } safMsgFinalize(&lockStatus); if(lockStatus) { clOsalMutexUnlock(&gClMsgFinalizeLock); } } rc = saAmfComponentUnregister(amfHandle, compName, NULL); clCpmClientFinalize(amfHandle); //clCpmResponse(cpmHandle, invocation, CL_OK); saAmfResponse(amfHandle, invocation, SA_AIS_OK); return; } static void clMsgRegisterWithCpm(void) { SaAisErrorT rc = SA_AIS_OK; SaAmfCallbacksT callbacks = {0}; SaVersionT version = {0}; version.releaseCode = 'B'; version.majorVersion = 0x01; version.minorVersion = 0x01; callbacks.saAmfHealthcheckCallback = NULL; callbacks.saAmfComponentTerminateCallback = safTerminate; callbacks.saAmfCSISetCallback = NULL; callbacks.saAmfCSIRemoveCallback = NULL; callbacks.saAmfProtectionGroupTrackCallback = NULL; rc = saAmfInitialize(&amfHandle, &callbacks, &version); if( rc != SA_AIS_OK) { clLogError("MSG", "INI", "saAmfInitialize failed with error code [0x%x].", rc); return ; } rc = saAmfComponentNameGet(amfHandle, &appName); rc = saAmfComponentRegister(amfHandle, &appName, NULL); }
/**************************************************************************** * Name : amf_comp_terminate_callback * * Description : This is the callback function which will be called * when the AMF framework want to terminate SMFND. This does * all required to destroy SMFND(except to unregister from AMF) * * Arguments : invocation - This parameter designated a particular * invocation of this callback function. The * invoke process return invocation when it * responds to the Avilability Management * FrameWork using the saAmfResponse() * function. * compName - A pointer to the name of the component * whose readiness stae the Availability * Management Framework is setting. * * Return Values : None * * Notes : None *****************************************************************************/ static void amf_comp_terminate_callback(SaInvocationT invocation, const SaNameT * compName) { TRACE_ENTER(); saAmfResponse(smfnd_cb->amf_hdl, invocation, SA_AIS_OK); TRACE_LEAVE(); sleep(1); exit(0); }
SaUint32T plms_invalid_state_handler(SaInvocationT invocation) { PLMS_CB * cb = plms_cb; TRACE_ENTER(); m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_READ); saAmfResponse(cb->amf_hdl, invocation, SA_AIS_ERR_BAD_OPERATION); m_NCS_UNLOCK(&cb->cb_lock,NCS_LOCK_READ); TRACE_LEAVE(); return NCSCC_RC_FAILURE; }
/**************************************************************************** * Name : immd_amf_csi_rmv_callback * * Description : TBD * * * Return Values : None *****************************************************************************/ static void immd_amf_csi_rmv_callback(SaInvocationT invocation, const SaNameT *compName, const SaNameT *csiName, SaAmfCSIFlagsT csiFlags) { IMMD_CB *cb = immd_cb; SaAisErrorT saErr = SA_AIS_OK; TRACE_ENTER(); LOG_IN("IMMD - AMF CSI Remove Callback Invoked"); saAmfResponse(cb->amf_hdl, invocation, saErr); TRACE_LEAVE(); }