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); } }
/** * 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 nodeFail(const char* node) { SaNameT nodeName; strncpy((char*) nodeName.value,node,SA_MAX_NAME_LENGTH); nodeName.value[SA_MAX_NAME_LENGTH-1] = 0; nodeName.length = strlen((char*)nodeName.value); saAmfComponentErrorReport(amfHandle, &nodeName, 0, SA_AMF_NODE_SWITCHOVER, SA_NTF_IDENTIFIER_UNUSED); }
/**************************************************************************** * Name : dts_saf_CSI_set_callback * * Description : This function 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 state the Availability * Management Framework is setting. * csiName - A pointer to the name of the new component * service instance to be supported by the * component or of an alreadt supported * component service instance whose HA state * is to be changed. * csiFlags - A value of the choiceflag type which * indicates whether the HA state change must * be applied to a new component service * instance or to all component service * instance currently supported by the * component. * haState - The new HA state to be assumeb by the * component service instance identified by * csiName. * activeCompName - A pointer to the name of the component that * currently has the active state or had the * active state for this component serivce * insance previously. * transitionDesc - This will indicate whether or not the * component service instance for * ativeCompName went through quiescing. * * Return Values : None. * * Notes : None. *****************************************************************************/ static void dts_saf_CSI_set_callback(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { DTS_CB *dts_cb_inst = &dts_cb; SaAisErrorT error = SA_AIS_OK; SaAmfHAStateT prev_haState = dts_cb_inst->ha_state; if (((SA_AMF_CSI_ADD_ONE == csiDescriptor.csiFlags) && (dts_cb_inst->csi_set == TRUE)) || (((SA_AMF_CSI_ADD_ONE != csiDescriptor.csiFlags) && (dts_cb_inst->csi_set == FALSE)))) { m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_saf_CSI_set_callback: ERROR in operation!!"); return; } else { if (FALSE == dts_cb_inst->csi_set) { dts_cb_inst->csi_set = TRUE; } /* Store CSI set cb invocation hdl to dts_cb for use of giving * SaAmfResponse for Act to Quiesced transition */ dts_cb_inst->csi_cb_invocation = invocation; /* Invoke dts_role_change to do valid role change action */ if (dts_role_change(dts_cb_inst, haState) != NCSCC_RC_SUCCESS) { m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_saf_CSI_set_callback: Role change failed"); saAmfResponse(dts_cb_inst->amf_hdl, invocation, SA_AIS_ERR_FAILED_OPERATION); fflush(stdout); return; } /* Change ha_state of dts_cb now. Change now done in dts_role_change */ /*dts_cb_inst->ha_state = haState; */ /* Smik - Need to verify if saAmfResponse shud be sent before or * after msg is dispatched to DTS mbx. * Also check whether the transition is frm Act to Quiesced. For this * case don't send SaAmfResponse now. */ if ((dts_cb_inst->ha_state == SA_AMF_HA_ACTIVE) && (haState == SA_AMF_HA_QUIESCED)) { /* No SaAmfResponse. Do nothing. Usually it would be the same. */ } else { saAmfResponse(dts_cb_inst->amf_hdl, invocation, error); m_LOG_DTS_API(DTS_CSI_SET_CB_RESP); fflush(stdout); } if (((prev_haState == SA_AMF_HA_STANDBY) || (prev_haState == SA_AMF_HA_QUIESCED)) && (haState == SA_AMF_HA_ACTIVE)) { if (dts_stby_update_dta_config() != NCSCC_RC_SUCCESS) { if (saAmfComponentErrorReport (dts_cb_inst->amf_hdl, &dts_cb_inst->comp_name, 0, SA_AMF_COMPONENT_RESTART, 0) != SA_AIS_OK) { m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_saf_CSI_set_callback: Failed to send Error report to AMF"); } m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_saf_CSI_set_callback: Failed to update dta config"); return; } } } fflush(stdout); return; }
/**************************************************************************** Name : avsv_amf_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 avsv_amf_healthcheck_callback(SaInvocationT inv, const SaNameT *comp_name, SaAmfHealthcheckKeyT *health_check_key) { SaAisErrorT rc; static int healthcheck_count = 0; syslog(LOG_INFO, "\n Dispatched 'HealthCheck' Callback \n Component: %s \n HealthCheckKey: %s ", comp_name->value, health_check_key->key); /* Respond immediately */ rc = saAmfResponse(gl_amf_hdl, inv, SA_AIS_OK); if ( SA_AIS_OK != rc ) { syslog(LOG_ERR, "saAmfResponse FAILED - %u", rc); saAmfComponentUnregister(gl_amf_hdl, &gl_comp_name, 0); saAmfFinalize(gl_amf_hdl); return; } /* Increment healthcheck count */ healthcheck_count++; /* Send the Error Report */ if (AMF_HEALTHCHECK_CALLBACK_MAX_COUNT == healthcheck_count) { /*###################################################################### Demonstrating the use of saAmfHealthcheckStop() ######################################################################*/ rc = saAmfHealthcheckStop(gl_amf_hdl, &gl_comp_name, &gl_healthcheck_key); if ( SA_AIS_OK != rc ) { syslog(LOG_ERR, "saAmfHealthcheckStop FAILED - %u", rc); saAmfComponentUnregister(gl_amf_hdl, &gl_comp_name, 0); saAmfFinalize(gl_amf_hdl); return; } syslog(LOG_INFO, "\n Stopped HealthCheck for Comp: %s with HealthCheckKey: %s ", gl_comp_name.value, gl_healthcheck_key.key); /*###################################################################### Demonstrating the use of saAmfComponentErrorReport() ######################################################################*/ syslog(LOG_INFO, "\n\n DEMONSTRATING COMPONENT FAILOVER THROUGH ERROR REPORT !!! "); sleep(2); rc = saAmfComponentErrorReport(gl_amf_hdl, &gl_comp_name, 0, SA_AMF_COMPONENT_FAILOVER, 0); if ( SA_AIS_OK != rc ) { syslog(LOG_ERR, "saAmfComponentErrorReport FAILED - %u", rc); saAmfComponentUnregister(gl_amf_hdl, &gl_comp_name, 0); saAmfFinalize(gl_amf_hdl); return; } syslog(LOG_INFO, "\n Sent Error Report for Comp: %s with CompFailover as the recommended recovery ", gl_comp_name.value); /* Reset the ha state */ gl_ha_state = 0; } }