示例#1
0
static SaAisErrorT service_stop(void)
{
	SaAisErrorT rc;
	int status;

	if (pidfile) {
		SaAmfPmErrorsT pmErr = SA_AMF_PM_ZERO_EXIT | SA_AMF_PM_NON_ZERO_EXIT;

		rc = saAmfPmStop(my_amf_hdl, &my_comp_name, SA_AMF_PM_PROC, pid, pmErr);
		if ((SA_AIS_OK != rc) && (SA_AIS_ERR_NOT_EXIST != rc)) {
			syslog(LOG_ERR, "saAmfPmStop FAILED (%u)", rc);
		}
	}

	rc = saAmfHealthcheckStop(my_amf_hdl, &my_comp_name, &my_healthcheck_key);
	if ((rc != SA_AIS_OK) && (rc != SA_AIS_ERR_NOT_EXIST)) {
		syslog(LOG_ERR, "saAmfHealthcheckStop FAILED (%u)", rc);
	}

	status = exec_command(stop_script);
	if (status == 0)
		return SA_AIS_OK;
	else
		return SA_AIS_ERR_FAILED_OPERATION;
}
void HealthcheckCallback (SaInvocationT invocation,
	const SaNameT *compName,
	SaAmfHealthcheckKeyT *healthcheckKey)
{
	SaErrorT res;

	healthcheck_no++;
	printf ("Healthcheck %u for key '%s' for component ",
		healthcheck_no, healthcheckKey->key);

	printSaNameT ((SaNameT *)compName);
	printf ("\n");
	res = saAmfResponse (handle, invocation, SA_AIS_OK);
	if (res != SA_OK) {
		printf ("response res is %d\n", res);
	}
	if (healthcheck_no == 20) {
		res = saAmfHealthcheckStop (handle, &compNameGlobal, &key0);
		stop = 1;
	}
	printf ("done res = %d\n", res);
}
示例#3
0
/* Unregistration and Finalization with AMF Library */
uns32 dts_amf_finalize(DTS_CB *dts_cb_inst)
{
	SaAisErrorT status = SA_AIS_OK;

	/* delete the fd from the select list */
	memset(&dts_cb_inst->dts_amf_sel_obj, 0, sizeof(SaSelectionObjectT));

	/* Disable the health monitoring */
	status = saAmfHealthcheckStop(dts_cb_inst->amf_hdl, &dts_cb_inst->comp_name, &dts_cb_inst->health_chk_key);

	if (status != SA_AIS_OK) {
		/* log the error */
		m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_amf_finalize: Helath Check stop failed");
		/* continue finalization */
	}

	/* Unregister with AMF */
	status = saAmfComponentUnregister(dts_cb_inst->amf_hdl, &dts_cb_inst->comp_name, NULL);
	if (status != SA_AIS_OK) {
		/* log the error */
		m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_amf_finalize: Component unregistered failed!!");
		/* continue finalization */
	}

	/* Finalize */
	status = saAmfFinalize(dts_cb_inst->amf_hdl);
	if (status != SA_AIS_OK) {
		/* log the error */
		return m_DTS_DBG_SINK(NCSCC_RC_FAILURE, "dts_amf_finalize: Component Finalized failed!!");
	}

	dts_cb_inst->amf_init = FALSE;
	m_LOG_DTS_API(DTS_AMF_FINALIZE);

	return NCSCC_RC_SUCCESS;
}
示例#4
0
/****************************************************************************
  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;
    }
}