ack, code review and tested with AmfDemo configured n-way with 3 SU's 1 
SI,  saAmfSIPrefStandbyAssignments=2,
(SaAmfSIRankedSU configured).

before si-swap:

safSi=AmfDemo1A,safApp=AmfDemo2 ACTIVE on SC-1
safSi=AmfDemo1A,safApp=AmfDemo2 STANDBY on SC-2
safSi=AmfDemo1A,safApp=AmfDemo2 STANDBY on PL-3


# amf-adm si-swap safSi=AmfDemo1A,safApp=AmfDemo2

safSi=AmfDemo1A,safApp=AmfDemo2 STANDBY on SC-1
safSi=AmfDemo1A,safApp=AmfDemo2 ACTIVE on SC-2
safSi=AmfDemo1A,safApp=AmfDemo2 STANDBY on PL-3

looks good.

/Thanks HansN

On 09/16/2015 12:50 PM, [email protected] wrote:
>   osaf/services/saf/amf/amfd/include/sg.h   |    1 +
>   osaf/services/saf/amf/amfd/include/su.h   |    2 +
>   osaf/services/saf/amf/amfd/sg.cc          |    2 +
>   osaf/services/saf/amf/amfd/sg_nway_fsm.cc |  101 
> ++++++++++++++++++++++++++++-
>   osaf/services/saf/amf/amfd/si.cc          |    2 +-
>   osaf/services/saf/amf/amfd/su.cc          |   32 +++++++++
>   6 files changed, 135 insertions(+), 5 deletions(-)
>
>
> Currently si-swap is allowed on a SI that is protected by a 2N SG.
> As per spec, operation is valid for NWAY and NPM model also.
> This patch supports si-swap admin op for Nway model with following 
> restrictions:
> 1)Operation will be rejected if Equal distribution feature is enabled.
> 2)operation will be rejected if SIRankedSU is configured and AutoAdjust flag 
> is
> enabled. However it will be allowed if AutoAdjust is disabled.
>
> Reason for rejecting the operation in above two cases:
> In both of these cases AutoAdjust flag is eanbled and is used to partially
> adjust the SG. At the same time, autoadjust feature is used without
> using autoadjustprob timer. In the equal distribution cases both active
> assignments and standby assignments are equally distributed among the
> available SUs without waiting for any autoadjustprob timer expiry.
> Thus if si-swap is supported in this case, SG will be adjusted to
> same configuration.
> Same explanation is valid for other case also.
>
> diff --git a/osaf/services/saf/amf/amfd/include/sg.h 
> b/osaf/services/saf/amf/amfd/include/sg.h
> --- a/osaf/services/saf/amf/amfd/include/sg.h
> +++ b/osaf/services/saf/amf/amfd/include/sg.h
> @@ -546,6 +546,7 @@ public:
>       uint32_t susi_failed(AVD_CL_CB *cb, AVD_SU *su,
>               struct avd_su_si_rel_tag *susi, AVSV_SUSI_ACT act, 
> SaAmfHAStateT state);
>       void node_fail_si_oper(AVD_SU *su);
> +     SaAisErrorT si_swap(AVD_SI *si, SaInvocationT invocation);
>   
>   private:
>       uint32_t susi_success_su_oper(AVD_CL_CB *cb, AVD_SU *su, struct 
> avd_su_si_rel_tag *susi,
> diff --git a/osaf/services/saf/amf/amfd/include/su.h 
> b/osaf/services/saf/amf/amfd/include/su.h
> --- a/osaf/services/saf/amf/amfd/include/su.h
> +++ b/osaf/services/saf/amf/amfd/include/su.h
> @@ -137,6 +137,8 @@ class AVD_SU {
>       bool any_susi_fsm_in_unasgn();
>       bool any_susi_fsm_in_modify();
>       SaAisErrorT check_su_stability();
> +     uint32_t curr_num_standby_sis();
> +     uint32_t curr_num_active_sis();
>    private:
>       void initialize();
>       void send_attribute_update(AVSV_AMF_SU_ATTR_ID attrib_id);
> diff --git a/osaf/services/saf/amf/amfd/sg.cc 
> b/osaf/services/saf/amf/amfd/sg.cc
> --- a/osaf/services/saf/amf/amfd/sg.cc
> +++ b/osaf/services/saf/amf/amfd/sg.cc
> @@ -1675,12 +1675,14 @@ void AVD_SG::set_fsm_state(AVD_SG_FSM_ST
>       if (state == AVD_SG_FSM_STABLE) {
>               osafassert(su_oper_list.empty() == true);
>               if (adminOp_invocationId != 0) {
> +                     TRACE("Admin operation finishes on SG:'%s'",name.value);
>                       avd_saImmOiAdminOperationResult(avd_cb->immOiHandle, 
> adminOp_invocationId, SA_AIS_OK);
>                       adminOp_invocationId = 0;
>                       adminOp = static_cast<SaAmfAdminOperationIdT>(0);
>               }
>               for (AVD_SI* si = list_of_si; si != NULL; si = 
> si->sg_list_of_si_next) {
>                       if (si->invocation != 0) {
> +                             TRACE("Admin operation finishes on 
> SI:'%s'",si->name.value);
>                               
> avd_saImmOiAdminOperationResult(avd_cb->immOiHandle,
>                                               si->invocation, SA_AIS_OK);
>                               si->invocation = 0;
> diff --git a/osaf/services/saf/amf/amfd/sg_nway_fsm.cc 
> b/osaf/services/saf/amf/amfd/sg_nway_fsm.cc
> --- a/osaf/services/saf/amf/amfd/sg_nway_fsm.cc
> +++ b/osaf/services/saf/amf/amfd/sg_nway_fsm.cc
> @@ -2764,8 +2764,7 @@ uint32_t avd_sg_nway_susi_succ_si_oper(A
>               } else if (AVSV_SI_TOGGLE_SWITCH == susi->si->si_switch) {
>                       /* si switch semantics in progress..
>                          identify the most preferred standby su & assign it 
> active */
> -                     for (curr_susi = susi->si->list_of_sisu;
> -                          curr_susi && (SA_AMF_HA_STANDBY != 
> curr_susi->state); curr_susi = curr_susi->si_next) ;
> +                     curr_susi = find_pref_standby_susi(susi);
>   
>                       if (curr_susi) {
>                               /* send active assignment */
> @@ -2853,8 +2852,14 @@ uint32_t avd_sg_nway_susi_succ_si_oper(A
>                                       curr_susi && (SA_AMF_HA_QUIESCED != 
> curr_susi->state); curr_susi = curr_susi->si_next) ;
>   
>                       if (curr_susi) {
> -                             /* send standby assignment */
> -                             rc = avd_susi_mod_send(curr_susi, 
> SA_AMF_HA_STANDBY);
> +                             /* send standby assignment if SU satisfies 
> saAmfSGMaxStandbySIsperSU*/
> +                             if (curr_susi->su->curr_num_standby_sis() < 
> sg->saAmfSGMaxStandbySIsperSU) {
> +                                     rc = avd_susi_mod_send(curr_susi, 
> SA_AMF_HA_STANDBY);
> +                             } else {
> +                                     TRACE_2("'%s' cannot accomodate more 
> standby, remove quiesced",
> +                                                     
> curr_susi->su->name.value);
> +                                     rc = avd_susi_del_send(curr_susi);
> +                             }
>                               if (NCSCC_RC_SUCCESS != rc)
>                                       goto done;
>   
> @@ -3314,6 +3319,7 @@ void SG_NWAY::node_fail_si_oper(AVD_SU *
>               }
>       } else if (AVSV_SI_TOGGLE_SWITCH == sg->admin_si->si_switch) {
>               if (!susi) {
> +                     /* no relationship between SU with the SI undergoing 
> si-swap.*/
>                       /* identify the quiesced assigning assignment for the 
> admin si ptr */
>                       for (curr_sisu = sg->admin_si->list_of_sisu;
>                            curr_sisu && !((SA_AMF_HA_QUIESCED == 
> curr_sisu->state) &&
> @@ -3340,8 +3346,12 @@ void SG_NWAY::node_fail_si_oper(AVD_SU *
>                       /* transition to sg-realign state */
>                       m_AVD_SET_SG_FSM(avd_cb, sg, AVD_SG_FSM_SG_REALIGN);
>               } else {
> +                     /* relationship exists between SU with the SI 
> undergoing si-swap.*/
> +                     TRACE("For susi, su:'%s', si:'%s', state:%u, fsm:%u"
> +                                     
> ,susi->su->name.value,susi->si->name.value,susi->state,susi->fsm);
>                       if (((SA_AMF_HA_QUIESCED == susi->state) && 
> (AVD_SU_SI_STATE_MODIFY == susi->fsm)) ||
>                           ((SA_AMF_HA_ACTIVE == susi->state) && 
> (AVD_SU_SI_STATE_ASGN == susi->fsm)) ||
> +                         ((SA_AMF_HA_ACTIVE == susi->state) && 
> (AVD_SU_SI_STATE_MODIFY == susi->fsm)) ||
>                           ((SA_AMF_HA_QUIESCED == susi->state) && 
> (AVD_SU_SI_STATE_ASGND == susi->fsm)) ||
>                           ((SA_AMF_HA_STANDBY == susi->state) && 
> (AVD_SU_SI_STATE_ASGND == susi->fsm))
>                           ) {
> @@ -3363,6 +3373,16 @@ void SG_NWAY::node_fail_si_oper(AVD_SU *
>                                               if (SA_AMF_HA_QUIESCED == 
> curr_sisu->state)
>                                                       break;
>   
> +                                     if ((SA_AMF_HA_ACTIVE == susi->state) &&
> +                                                     (AVD_SU_SI_STATE_MODIFY 
> == susi->fsm))
> +                                             if (SA_AMF_HA_QUIESCED == 
> curr_sisu->state) {
> +                                                     TRACE("For curr_sisu, 
> su:'%s', si:'%s', state:%u, fsm:%u",
> +                                                                     
> curr_sisu->su->name.value,
> +                                                                     
> curr_sisu->si->name.value,
> +                                                                     
> curr_sisu->state,curr_sisu->fsm);
> +                                                     break;
> +                                             }
> +
>                                       if ((SA_AMF_HA_QUIESCED == susi->state) 
> && (AVD_SU_SI_STATE_ASGND == susi->fsm))
>                                               if (SA_AMF_HA_ACTIVE == 
> curr_sisu->state)
>                                                       break;
> @@ -3493,6 +3513,79 @@ void avd_sg_nway_node_fail_sg_realign(AV
>       TRACE_LEAVE();
>       return;
>   }
> +SaAisErrorT SG_NWAY::si_swap(AVD_SI *si, SaInvocationT invocation) {
> +     SaAisErrorT rc = SA_AIS_OK;
> +     AVD_SU_SI_REL *actv_susi = NULL, *stdby_susi = NULL;
> +     AVD_SG *sg = si->sg_of_si;
> +
> +     TRACE_ENTER2("'%s' sg_fsm_state=%u", si->name.value, 
> si->sg_of_si->sg_fsm_state);
> +
> +     if (si->saAmfSIAdminState != SA_AMF_ADMIN_UNLOCKED) {
> +             LOG_NO("%s SWAP failed - wrong admin state=%u", si->name.value,
> +                     si->saAmfSIAdminState);
> +             rc = SA_AIS_ERR_TRY_AGAIN;
> +             goto done;
> +     }
> +
> +     if (avd_cb->init_state != AVD_APP_STATE) {
> +             LOG_NO("%s SWAP failed - not in app state (%u)", si->name.value,
> +                     avd_cb->init_state);
> +             rc = SA_AIS_ERR_TRY_AGAIN;
> +             goto done;
> +     }
> +
> +     if (si->sg_of_si->sg_fsm_state != AVD_SG_FSM_STABLE) {
> +             LOG_NO("%s SWAP failed - SG not stable (%u)", si->name.value,
> +                     si->sg_of_si->sg_fsm_state);
> +             rc = SA_AIS_ERR_TRY_AGAIN;
> +             goto done;
> +     }
> +
> +     if (si->list_of_sisu == NULL) {
> +             LOG_NO("%s SWAP failed - no assignments to swap", 
> si->name.value);
> +             rc = SA_AIS_ERR_BAD_OPERATION;
> +             goto done;
> +     }
> +
> +     if ((sg->equal_ranked_su == true) && (sg->saAmfSGAutoAdjust == 
> SA_TRUE)) {
> +             LOG_NO("%s Equal distribution is enabled, si-swap not allowed", 
> si->name.value);
> +             rc = SA_AIS_ERR_BAD_OPERATION;
> +             goto done;
> +     }
> +     if ((si->rankedsu_list_head != NULL) && (sg->saAmfSGAutoAdjust == 
> SA_TRUE)) {
> +             LOG_NO("%s SIRankedSU configured and autoadjust enabled, 
> si-swap not allowed", si->name.value);
> +             rc = SA_AIS_ERR_BAD_OPERATION;
> +             goto done;
> +     }
> +     if (si->list_of_sisu->si_next == NULL) {
> +             LOG_NO("%s SWAP failed - only one assignment", si->name.value);
> +             rc = SA_AIS_ERR_BAD_OPERATION;
> +             goto done;
> +     }
> +
> +     /*
> +        After SI swap, there should not be violation of 
> saAmfSGMaxActiveSIsperSU.
> +        After swap standby SU will receive one more active.
> +      */
> +     for (actv_susi = si->list_of_sisu;
> +                     actv_susi && (actv_susi->state != SA_AMF_HA_ACTIVE);
> +                     actv_susi = actv_susi->si_next);
> +     stdby_susi = find_pref_standby_susi(actv_susi);
> +     if (stdby_susi == NULL) {
> +             LOG_NO("%s SWAP not allowed, it will violate 
> saAmfSGMaxActiveSIsperSU",
> +                             si->name.value);
> +             rc = SA_AIS_ERR_BAD_OPERATION;
> +             goto done;
> +     }
> +     if ((avd_sg_nway_siswitch_func(avd_cb, si)) == NCSCC_RC_FAILURE) {
> +             rc = SA_AIS_ERR_BAD_OPERATION;
> +             goto done;
> +     }
> +     si->invocation = invocation;
> +done:
> +     TRACE_LEAVE2("sg_fsm_state=%u", si->sg_of_si->sg_fsm_state);
> +     return rc;
> +}
>   
>   SG_NWAY::~SG_NWAY() {
>   }
> diff --git a/osaf/services/saf/amf/amfd/si.cc 
> b/osaf/services/saf/amf/amfd/si.cc
> --- a/osaf/services/saf/amf/amfd/si.cc
> +++ b/osaf/services/saf/amf/amfd/si.cc
> @@ -948,7 +948,7 @@ static void si_admin_op_cb(SaImmOiHandle
>               if (rc != SA_AIS_OK) {
>                       report_admin_op_error(immOiHandle, invocation,
>                               rc, NULL,
> -                             "SI Swap of %s failed", objectName->value);
> +                             "SI Swap of %s failed, syslog has details", 
> objectName->value);
>                       goto done;
>               } else
>                       ;  // response done later
> diff --git a/osaf/services/saf/amf/amfd/su.cc 
> b/osaf/services/saf/amf/amfd/su.cc
> --- a/osaf/services/saf/amf/amfd/su.cc
> +++ b/osaf/services/saf/amf/amfd/su.cc
> @@ -2189,3 +2189,35 @@ SaAisErrorT AVD_SU::check_su_stability()
>   done:
>       return rc;
>   }
> +/**
> + * @brief    Calculates number of standby assignments in a SU even
> + *        when SG is unstable.
> + * @return   count
> + */
> +uint32_t AVD_SU::curr_num_standby_sis()
> +{
> +     uint32_t count = 0;
> +     for (AVD_SU_SI_REL *susi = list_of_susi; susi != NULL; susi = 
> susi->su_next)
> +             if ((susi->state == SA_AMF_HA_STANDBY) &&
> +                             ((susi->fsm == AVD_SU_SI_STATE_ASGN) ||
> +                              (susi->fsm == AVD_SU_SI_STATE_ASGND) ||
> +                              (susi->fsm == AVD_SU_SI_STATE_MODIFY)))
> +                     count++;
> +     return count;
> +}
> +/**
> + * @brief    Calculates number of standby assignments in a SU even
> + *           when SG is unstable.
> + * @return   count
> + */
> +uint32_t AVD_SU::curr_num_active_sis()
> +{
> +     uint32_t count = 0;
> +     for (AVD_SU_SI_REL *susi = list_of_susi; susi != NULL; susi = 
> susi->su_next)
> +             if ((susi->state == SA_AMF_HA_ACTIVE) &&
> +                             ((susi->fsm == AVD_SU_SI_STATE_ASGN) ||
> +                              (susi->fsm == AVD_SU_SI_STATE_ASGND) ||
> +                              (susi->fsm == AVD_SU_SI_STATE_MODIFY)))
> +                     count++;
> +     return count;
> +}


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to