/**************************************************************************** * Name : plms_amf_comp_terminate_callback * * Description : This is the callback function which will be called * when the AMF framework needs to terminate PLMS. This does * all required operations to destroy PLMS(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 : At present we are just support a simple liveness check. *****************************************************************************/ void plms_amf_comp_terminate_callback(SaInvocationT invocation, const SaNameT *compName) { PLMS_CB *cb = plms_cb; SaAisErrorT error = SA_AIS_OK; TRACE_ENTER(); m_NCS_LOCK(&cb->cb_lock,NCS_LOCK_WRITE); saAmfResponse(cb->amf_hdl, invocation, error); /* FIXME : Clean up all internal structures */ /* Detach from IPC */ m_NCS_IPC_DETACH(&cb->mbx, NULL, cb); /* Disconnect from MDS */ plms_mds_unregister(); m_NCS_UNLOCK(&cb->cb_lock,NCS_LOCK_WRITE); /* Destroy the cb */ sleep(1); LOG_NO("Received AMF component terminate callback, exiting"); exit(0); }
/**************************************************************************** Name : plms_mds_register Description : This routine registers the PLMS Service with MDS. Arguments : NULL Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ****************************************************************************/ SaUint32T plms_mds_register() { uns32 rc = NCSCC_RC_SUCCESS; NCSMDS_INFO svc_info; MDS_SVC_ID svc_id[1] = { NCSMDS_SVC_ID_PLMA }; MDS_SVC_ID plms_id[1] = { NCSMDS_SVC_ID_PLMS }; MDS_SVC_ID plms_hrb_id[1] = { NCSMDS_SVC_ID_PLMS_HRB }; PLMS_CB *cb = plms_cb; TRACE_ENTER(); /* Create the virtual Destination for PLMS */ rc = plms_mds_vdest_create(); if (NCSCC_RC_SUCCESS != rc) { LOG_ER("PLMS - VDEST CREATE FAILED"); return rc; } /* Set the role of MDS */ if (cb->ha_state == SA_AMF_HA_ACTIVE) { TRACE_5("Set MDS role to ACTIVE"); cb->mds_role = V_DEST_RL_ACTIVE; } else if (cb->ha_state == SA_AMF_HA_STANDBY) { TRACE_5("Set MDS role to STANDBY"); cb->mds_role = V_DEST_RL_STANDBY; } else { TRACE_5("Could not set MDS role"); } if (NCSCC_RC_SUCCESS != (rc = plms_mds_change_role())) { LOG_ER("MDS role change to %d FAILED", cb->mds_role); return rc; } memset(&svc_info, 0, sizeof(NCSMDS_INFO)); /* STEP 2 : Install with MDS with service ID NCSMDS_SVC_ID_PLMS. */ svc_info.i_mds_hdl = cb->mds_hdl; svc_info.i_svc_id = NCSMDS_SVC_ID_PLMS; svc_info.i_op = MDS_INSTALL; svc_info.info.svc_install.i_yr_svc_hdl = 0; svc_info.info.svc_install.i_install_scope = NCSMDS_SCOPE_NONE; /*node specific */ svc_info.info.svc_install.i_svc_cb = plms_mds_callback; /* callback */ svc_info.info.svc_install.i_mds_q_ownership = FALSE; svc_info.info.svc_install.i_mds_svc_pvt_ver = PLMS_MDS_PVT_SUBPART_VERSION; if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) { LOG_ER("PLMS - MDS Install Failed"); return NCSCC_RC_FAILURE; } /* STEP 3: Subscribe to PLMS for redundancy events */ memset(&svc_info, 0, sizeof(NCSMDS_INFO)); svc_info.i_mds_hdl = cb->mds_hdl; svc_info.i_svc_id = NCSMDS_SVC_ID_PLMS; svc_info.i_op = MDS_RED_SUBSCRIBE; svc_info.info.svc_subscribe.i_num_svcs = 1; svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE; svc_info.info.svc_subscribe.i_svc_ids = plms_id; if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) { LOG_ER("PLMS - MDS Subscribe for redundancy Failed"); plms_mds_unregister(); return NCSCC_RC_FAILURE; } /* STEP 4: Subscribe to PLMA up/down events */ memset(&svc_info, 0, sizeof(NCSMDS_INFO)); svc_info.i_mds_hdl = cb->mds_hdl; svc_info.i_svc_id = NCSMDS_SVC_ID_PLMS; svc_info.i_op = MDS_SUBSCRIBE; svc_info.info.svc_subscribe.i_num_svcs = 1; svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE; svc_info.info.svc_subscribe.i_svc_ids = svc_id; if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) { LOG_ER("PLMS - MDS Subscribe for PLMA up/down Failed"); plms_mds_unregister(); return NCSCC_RC_FAILURE; } /* STEP 5: Subscribe to HRB up/down events */ memset(&svc_info, 0, sizeof(NCSMDS_INFO)); svc_info.i_mds_hdl = cb->mds_hdl; svc_info.i_svc_id = NCSMDS_SVC_ID_PLMS; svc_info.i_op = MDS_SUBSCRIBE; svc_info.info.svc_subscribe.i_num_svcs = 1; svc_info.info.svc_subscribe.i_scope = NCSMDS_SCOPE_NONE; svc_info.info.svc_subscribe.i_svc_ids = plms_hrb_id; if (ncsmds_api(&svc_info) == NCSCC_RC_FAILURE) { LOG_ER("PLMS - MDS Subscribe for PLMS_HRB up/down Failed"); plms_mds_unregister(); return NCSCC_RC_FAILURE; } /* Get the node id of local PLMS */ cb->node_id = m_NCS_GET_NODE_ID; cb->plms_self_id = plms_get_slot_and_subslot_id_from_node_id(cb->node_id); TRACE_5("NodeId:%x SelfId:%x", cb->node_id, cb->plms_self_id); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }