/****************************************************************************\ PROCEDURE NAME : immd_saf_csi_set_cb DESCRIPTION : This is a SAF callback function which will be called when there is any change in the HA state. 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. haState - The new HA state to be assumeb by the component service instance identified by csiName. csiDescriptor - RETURNS : Nothing. \*****************************************************************************/ static void immd_saf_csi_set_cb(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT new_haState, SaAmfCSIDescriptorT csiDescriptor) { SaAisErrorT error = SA_AIS_OK; SaAmfHAStateT prev_ha_state; bool role_change = true; uint32_t rc = NCSCC_RC_SUCCESS; IMMD_CB *cb = immd_cb; TRACE_ENTER(); prev_ha_state = cb->ha_state; /* Invoke the appropriate state handler routine */ switch (new_haState) { case SA_AMF_HA_ACTIVE: error = amf_active_state_handler(cb, invocation); break; case SA_AMF_HA_STANDBY: error = amf_standby_state_handler(cb, invocation); break; case SA_AMF_HA_QUIESCED: /* switch over */ error = amf_quiesced_state_handler(cb, invocation); break; case SA_AMF_HA_QUIESCING: /* shut down */ error = amf_quiescing_state_handler(cb, invocation); break; default: LOG_WA("invalid state: %d ", new_haState); error = SA_AIS_ERR_FAILED_OPERATION; break; } if (error != SA_AIS_OK) goto response; if (new_haState == SA_AMF_HA_QUIESCED) { /*Note: should we not change state in cb->ha_state here. This is done in immd_mds_quiesced_ack_process */ goto done; } /* Update control block */ cb->ha_state = new_haState; TRACE_5("New-state: %s, prev-state: %s", ha_state_name(new_haState), ha_state_name(prev_ha_state)); /* Handle active to active role change. */ if (prev_ha_state == new_haState) { TRACE_5("No role change!"); /* bug? */ role_change = false; } if (role_change) { if ((rc = immd_mds_change_role(cb)) != NCSCC_RC_SUCCESS) { LOG_WA("immd_mds_change_role FAILED"); error = SA_AIS_ERR_FAILED_OPERATION; goto response; } TRACE_5("Inform MBCSV of HA state change to %s", (new_haState == SA_AMF_HA_ACTIVE) ? "ACTIVE" : "STANDBY"); if (immd_mbcsv_chgrole(cb) != NCSCC_RC_SUCCESS) { LOG_WA("immd_mbcsv_chgrole FAILED"); error = SA_AIS_ERR_FAILED_OPERATION; goto response; } if (new_haState == SA_AMF_HA_ACTIVE) { /* Change of role to active => We may need to elect new coord */ if(immd_cb->m2PbeCanLoad) { LOG_IN("Electing coord in immd_saf_csi_set_cb() to ACTIVE"); immd_proc_elect_coord(cb, true); } immd_db_purge_fevs(cb); } } response: saAmfResponse(cb->amf_hdl, invocation, error); done: TRACE_LEAVE(); }
/**************************************************************************** * Name : amf_csi_set_callback * * Description : AMF callback function called * when there is any change in the HA state. * * 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. * haState - The new HA state to be assumeb by the * component service instance identified by * csiName. * csiDescriptor - This will indicate whether or not the * component service instance for * ativeCompName went through quiescing. * * Return Values : None. * * Notes : None. *****************************************************************************/ static void amf_csi_set_callback(SaInvocationT invocation, const SaNameT * compName, SaAmfHAStateT new_haState, SaAmfCSIDescriptorT csiDescriptor) { SaAisErrorT result = SA_AIS_OK; SaAmfHAStateT prev_haState; bool role_change = true; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* * Handle Active to Active role change. */ prev_haState = smfd_cb->ha_state; /* Invoke the appropriate state handler routine */ switch (new_haState) { case SA_AMF_HA_ACTIVE: result = amf_active_state_handler(smfd_cb, invocation); break; case SA_AMF_HA_STANDBY: result = amf_standby_state_handler(smfd_cb, invocation); break; case SA_AMF_HA_QUIESCED: result = amf_quiesced_state_handler(smfd_cb, invocation); break; case SA_AMF_HA_QUIESCING: result = amf_quiescing_state_handler(smfd_cb, invocation); break; default: LOG_WA("invalid state: %d ", new_haState); result = SA_AIS_ERR_BAD_OPERATION; break; } if (result != SA_AIS_OK) goto response; if (new_haState == SA_AMF_HA_QUIESCED) /* AMF response will be done later when MDS quiesced ack has been received */ goto done; /* Update control block */ smfd_cb->ha_state = new_haState; /* Handle active to active role change. */ if ((prev_haState == SA_AMF_HA_ACTIVE) && (new_haState == SA_AMF_HA_ACTIVE)) role_change = false; /* Handle Stby to Stby role change. */ if ((prev_haState == SA_AMF_HA_STANDBY) && (new_haState == SA_AMF_HA_STANDBY)) role_change = false; if (role_change == true) { if ((rc = smfd_mds_change_role(smfd_cb)) != NCSCC_RC_SUCCESS) { TRACE("smfd_mds_change_role FAILED"); result = SA_AIS_ERR_FAILED_OPERATION; goto response; } } response: saAmfResponse(smfd_cb->amf_hdl, invocation, result); done: TRACE_LEAVE(); }
/**************************************************************************** * Name : amf_csi_set_callback * * Description : AMF callback function called * when there is any change in the HA state. * * 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. * haState - The new HA state to be assumeb by the * component service instance identified by * csiName. * csiDescriptor - This will indicate whether or not the * component service instance for * ativeCompName went through quiescing. * * Return Values : None. * * Notes : None. *****************************************************************************/ static void amf_csi_set_callback(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT new_haState, SaAmfCSIDescriptorT csiDescriptor) { SaAisErrorT error = SA_AIS_OK; SaAmfHAStateT prev_haState; bool role_change = true; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* * Handle Active to Active role change. */ prev_haState = ntfs_cb->ha_state; if (prev_haState == SA_AMF_HA_STANDBY && new_haState == SA_AMF_HA_ACTIVE && ntfs_cb->ckpt_state != COLD_SYNC_COMPLETE) { /* We are not synched and cannot take over */ LOG_ER("NTFS cannot take over not cold synched"); error = SA_AIS_ERR_FAILED_OPERATION; goto response; } /* Invoke the appropriate state handler routine */ switch (new_haState) { case SA_AMF_HA_ACTIVE: error = amf_active_state_handler(invocation); break; case SA_AMF_HA_STANDBY: error = amf_standby_state_handler(invocation); break; case SA_AMF_HA_QUIESCED: error = amf_quiesced_state_handler(invocation); break; case SA_AMF_HA_QUIESCING: error = amf_quiescing_state_handler(invocation); break; default: LOG_WA("invalid state: %d ", new_haState); error = SA_AIS_ERR_BAD_OPERATION; break; } if (error != SA_AIS_OK) goto response; if (new_haState == SA_AMF_HA_QUIESCED) goto done; /* Update control block */ ntfs_cb->ha_state = new_haState; if (ntfs_cb->csi_assigned == false) { ntfs_cb->csi_assigned = true; /* We shall open checkpoint only once in our life time. currently doing at lib init */ } else if ((new_haState == SA_AMF_HA_ACTIVE) || (new_haState == SA_AMF_HA_STANDBY)) { /* It is a switch over */ /* NOTE: This behaviour has to be checked later, when scxb redundancy is available * Also, change role of mds, mbcsv during quiesced has to be done after mds * supports the same. TBD */ } /* Handle active to active role change. */ if ((prev_haState == SA_AMF_HA_ACTIVE) && (new_haState == SA_AMF_HA_ACTIVE)) role_change = false; /* Handle Stby to Stby role change. */ if ((prev_haState == SA_AMF_HA_STANDBY) && (new_haState == SA_AMF_HA_STANDBY)) role_change = false; if (role_change == true) { if ((rc = ntfs_mds_change_role()) != NCSCC_RC_SUCCESS) { LOG_ER("ntfs_mds_change_role FAILED"); error = SA_AIS_ERR_FAILED_OPERATION; } /* Inform MBCSV of HA state change */ if (NCSCC_RC_SUCCESS != (error = ntfs_mbcsv_change_HA_state(ntfs_cb))) error = SA_AIS_ERR_FAILED_OPERATION; TRACE("%s NTFS changing HA role from %s to %s", __FUNCTION__, ha_state_str(prev_haState), ha_state_str(new_haState)); } response: saAmfResponse(ntfs_cb->amf_hdl, invocation, error); if ((new_haState == SA_AMF_HA_ACTIVE) && (role_change == true)) { /* check for unsent notifictions and if notifiction is not logged */ checkNotificationList(); } done: /* Kills the osafntfimcnd process if current state is Active or Standby and * the process is not already running in this state. * The process will be restarted by the process surveillance * thread. * This function will not return until the process is terminated. */ handle_state_ntfimcn(ntfs_cb->ha_state); TRACE_LEAVE(); }
/**************************************************************************** * Name : amf_csi_set_callback * * Description : AMF callback function called * when there is any change in the HA state. * * 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 state the Availability * Management Framework is setting. * haState - The new HA state to be assumed by the * component service instance identified by * csiName. * csiDescriptor - This will indicate whether or not the * component service instance for * ativeCompName went through quiescing. * * Return Values : None. * * Notes : None. *****************************************************************************/ static void amf_csi_set_callback(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT new_haState, SaAmfCSIDescriptorT csiDescriptor) { SaAisErrorT error = SA_AIS_OK; SaAmfHAStateT prev_haState; bool role_change = true; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); /* * Handle Active to Active role change. */ prev_haState = lgs_cb->ha_state; /* Invoke the appropriate state handler routine */ switch (new_haState) { case SA_AMF_HA_ACTIVE: error = amf_active_state_handler(lgs_cb, invocation); break; case SA_AMF_HA_STANDBY: error = amf_standby_state_handler(lgs_cb, invocation); break; case SA_AMF_HA_QUIESCED: /* switch-over */ error = amf_quiesced_state_handler(lgs_cb, invocation); break; case SA_AMF_HA_QUIESCING: /* shutdown admin op */ error = amf_quiescing_state_handler(lgs_cb, invocation); break; default: LOG_WA("invalid state: %d ", new_haState); error = SA_AIS_ERR_FAILED_OPERATION; break; } if (error != SA_AIS_OK) goto response; if (new_haState == SA_AMF_HA_QUIESCED) { /* AMF response will be done later when MDS quiesced ack has been received */ goto done; } /* Update control block */ lgs_cb->ha_state = new_haState; if (lgs_cb->csi_assigned == false) { lgs_cb->csi_assigned = true; /* We shall open checkpoint only once in our life time. currently doing at lib init */ } else if ((new_haState == SA_AMF_HA_ACTIVE) || (new_haState == SA_AMF_HA_STANDBY)) { /* It is a switch over */ lgs_cb->ckpt_state = COLD_SYNC_IDLE; /* NOTE: This behaviour has to be checked later, when scxb redundancy is available * Also, change role of mds, mbcsv during quiesced has to be done after mds * supports the same. TBD */ } /* Handle active to active role change. */ if ((prev_haState == SA_AMF_HA_ACTIVE) && (new_haState == SA_AMF_HA_ACTIVE)) role_change = false; /* Handle Stby to Stby role change. */ if ((prev_haState == SA_AMF_HA_STANDBY) && (new_haState == SA_AMF_HA_STANDBY)) role_change = false; if (role_change == true) { if ((rc = lgs_mds_change_role(lgs_cb)) != NCSCC_RC_SUCCESS) { LOG_ER("lgs_mds_change_role FAILED"); error = SA_AIS_ERR_FAILED_OPERATION; goto response; } /* Inform MBCSV of HA state change */ if (NCSCC_RC_SUCCESS != (error = lgs_mbcsv_change_HA_state(lgs_cb))) error = SA_AIS_ERR_FAILED_OPERATION; } response: saAmfResponse(lgs_cb->amf_hdl, invocation, error); done: TRACE_LEAVE(); }