/**************************************************************************** * Name : cpd_evt_proc_timer_expiry * * Description : Function to process the Timer expiry events at CPD. * * Arguments : CPD_CB *cb - CPD CB pointer * CPSV_EVT *evt - Received Event structure * * Return Values : NCSCC_RC_SUCCESS/Error. * * Notes : None. *****************************************************************************/ static uns32 cpd_evt_proc_timer_expiry(CPD_CB *cb, CPD_EVT *evt) { uns32 rc; CPD_CPND_INFO_NODE *node_info = NULL; CPD_TMR_INFO *tmr_info = &evt->info.tmr_info; switch (tmr_info->type) { case CPD_TMR_TYPE_CPND_RETENTION: if (cb->ha_state == SA_AMF_HA_ACTIVE) { cpd_cpnd_info_node_get(&cb->cpnd_tree, &tmr_info->info.cpnd_dest, &node_info); if (node_info) { rc = cpd_process_cpnd_down(cb, &tmr_info->info.cpnd_dest); } } if (cb->ha_state == SA_AMF_HA_STANDBY) { cpd_cpnd_info_node_get(&cb->cpnd_tree, &tmr_info->info.cpnd_dest, &node_info); if (node_info) { node_info->timer_state = 2; } } break; default: break; } return NCSCC_RC_SUCCESS; }
void cpd_clm_cluster_track_cb(const SaClmClusterNotificationBufferT *notificationBuffer, SaUint32T numberOfMembers, SaAisErrorT error) { CPD_CB *cb; SaClmNodeIdT node_id; CPD_CPND_INFO_NODE *cpnd_info_node = NULL; NODE_ID key; uns32 counter = 0; /* 1. Get the CPD_CB */ m_CPD_RETRIEVE_CB(cb); if (cb == NULL) { return; } else { /* 2. Check the HA_STATE */ for (counter = 0; counter < notificationBuffer->numberOfItems; counter++) { if (notificationBuffer->notification[counter].clusterChange == SA_CLM_NODE_LEFT) { if (cb->ha_state == SA_AMF_HA_ACTIVE) { node_id = notificationBuffer->notification[counter].clusterNode.nodeId; key = node_id; cpnd_info_node = (CPD_CPND_INFO_NODE *) ncs_patricia_tree_get(&cb->cpnd_tree, (uns8 *)&key); if (cpnd_info_node) { cpd_process_cpnd_down(cb, &cpnd_info_node->cpnd_dest); } } else if (cb->ha_state == SA_AMF_HA_STANDBY) { node_id = notificationBuffer->notification[counter].clusterNode.nodeId; key = node_id; cpnd_info_node = (CPD_CPND_INFO_NODE *) ncs_patricia_tree_get(&cb->cpnd_tree, (uns8 *)&key); if (cpnd_info_node) { cpnd_info_node->timer_state = 2; } } } } } m_CPD_GIVEUP_CB; return; }
void cpd_saf_csi_set_cb(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { CPD_CB *cb = 0; SaAisErrorT saErr = SA_AIS_OK; V_DEST_RL mds_role; /* V_CARD_QA anchor; */ NCSVDA_INFO vda_info; uint32_t rc = NCSCC_RC_SUCCESS; CPD_CPND_INFO_NODE *node_info = NULL; MDS_DEST prev_dest; TRACE_ENTER(); cb = ncshm_take_hdl(NCS_SERVICE_ID_CPD, gl_cpd_cb_hdl); if (cb) { if ((cb->ha_state == SA_AMF_HA_STANDBY) && (haState == SA_AMF_HA_ACTIVE)) { if (cb->cold_or_warm_sync_on == true) { TRACE("STANDBY cpd_saf_csi_set_cb -cb->cold_or_warm_sync_on == true "); saErr = SA_AIS_ERR_TRY_AGAIN; saAmfResponse(cb->amf_hdl, invocation, saErr); ncshm_give_hdl(cb->cpd_hdl); TRACE_4("cpd vdest change role failed"); m_CPSV_DBG_SINK(NCSCC_RC_FAILURE, "cpd_role_change: Failed to send Error report to AMF for Active role assignment during Cold-Sync"); return; } } if ((cb->ha_state == SA_AMF_HA_ACTIVE) && (haState == SA_AMF_HA_QUIESCED)) { if (cb->cold_or_warm_sync_on == true) { TRACE("ACTIVE cpd_saf_csi_set_cb -cb->cold_or_warm_sync_on == true "); } } /* cb->ha_state = haState; */ /* saAmfResponse(cb->amf_hdl, invocation, saErr); */ if (SA_AMF_HA_ACTIVE == haState) { /** Change the MDS role **/ cb->ha_state = haState; mds_role = V_DEST_RL_ACTIVE; TRACE("ACTIVE STATE"); /* If this is the active server, become implementer again. */ /* If this is the active Director, become implementer */ saErr = immutil_saImmOiImplementerSet(cb->immOiHandle, implementer_name); if (saErr != SA_AIS_OK){ LOG_ER("cpd immOiImplmenterSet failed with err = %u",saErr); exit(EXIT_FAILURE); } /* anchor = cb->cpd_anc; */ } else if (SA_AMF_HA_QUIESCED == haState) { mds_role = V_DEST_RL_QUIESCED; cb->amf_invocation = invocation; cb->is_quiesced_set = true; memset(&vda_info, 0, sizeof(vda_info)); vda_info.req = NCSVDA_VDEST_CHG_ROLE; vda_info.info.vdest_chg_role.i_vdest = cb->cpd_dest_id; /* vda_info.info.vdest_chg_role.i_anc = anchor; */ vda_info.info.vdest_chg_role.i_new_role = mds_role; rc = ncsvda_api(&vda_info); if (NCSCC_RC_SUCCESS != rc) { m_LEAP_DBG_SINK_VOID; LOG_ER("cpd vdest change role failed"); ncshm_give_hdl(cb->cpd_hdl); TRACE_LEAVE(); return; } ncshm_give_hdl(cb->cpd_hdl); TRACE_2("cpd csi set cb success"); TRACE_LEAVE(); return; } else { /** Change the MDS role **/ cb->ha_state = haState; mds_role = V_DEST_RL_STANDBY; TRACE("STANDBY STATE"); /* anchor = cb->cpd_anc; */ } memset(&vda_info, 0, sizeof(vda_info)); vda_info.req = NCSVDA_VDEST_CHG_ROLE; vda_info.info.vdest_chg_role.i_vdest = cb->cpd_dest_id; /* vda_info.info.vdest_chg_role.i_anc = anchor; */ vda_info.info.vdest_chg_role.i_new_role = mds_role; rc = ncsvda_api(&vda_info); if (NCSCC_RC_SUCCESS != rc) { m_LEAP_DBG_SINK_VOID; LOG_ER("cpd vdest change role failed"); ncshm_give_hdl(cb->cpd_hdl); TRACE_LEAVE(); return; } if (cpd_mbcsv_chgrole(cb) != NCSCC_RC_SUCCESS) { TRACE_4("cpd mbcsv chgrole failed"); } /** Set the CB's anchor value */ /* cb->cpd_anc= anchor; */ saAmfResponse(cb->amf_hdl, invocation, saErr); ncshm_give_hdl(cb->cpd_hdl); if (SA_AMF_HA_ACTIVE == cb->ha_state) { cpd_cpnd_info_node_getnext(&cb->cpnd_tree, NULL, &node_info); while (node_info) { prev_dest = node_info->cpnd_dest; if (node_info->timer_state == 2) { TRACE ("THE TIMER STATE IS 2 MEANS TIMER EXPIRED BUT STILL DID NOT GET ACTIVE STATE"); cpd_process_cpnd_down(cb, &node_info->cpnd_dest); } cpd_cpnd_info_node_getnext(&cb->cpnd_tree, &prev_dest, &node_info); } TRACE_2("cpd csi set cb success I AM ACTIVE "); } if (SA_AMF_HA_STANDBY == cb->ha_state) TRACE_2("cpd csi set cb success I AM STANDBY"); } else { TRACE_4("cpd donot exist"); } TRACE_LEAVE(); return; } /* End of cpd_saf_csi_set_cb() */