osaf/libs/common/avsv/avsv_d2nedu.c | 7 + osaf/libs/common/avsv/include/avsv_d2nmsg.h | 1 + osaf/services/saf/avsv/avd/avd_util.c | 20 +++++ osaf/services/saf/avsv/avnd/avnd_comp.c | 51 +------------- osaf/services/saf/avsv/avnd/avnd_sidb.c | 92 ++++++++++++++++++------ osaf/services/saf/avsv/avnd/avnd_su.c | 16 +++- osaf/services/saf/avsv/avnd/include/avnd_comp.h | 2 +- 7 files changed, 112 insertions(+), 77 deletions(-)
When the AMF node director receives the SUSI ASGN message, for each CSI it reads the saAmfCSType attribute from IMM. When the AMF node director receives the SUSI MOD message, for each CSI it reads the saAmfCtCompCapability attribute from the comp and csi associated SaAmfCtCsType instance. In any of these cases if IMM does not respond in a timely manner the amfnd process will be aborted and the node restarted. By including component capability (an int) in the SUSI ASG msg, these reads from IMM can be completely skipped in the node director. diff --git a/osaf/libs/common/avsv/avsv_d2nedu.c b/osaf/libs/common/avsv/avsv_d2nedu.c --- a/osaf/libs/common/avsv/avsv_d2nedu.c +++ b/osaf/libs/common/avsv/avsv_d2nedu.c @@ -750,6 +750,7 @@ uint32_t avsv_edp_susi_asgn(EDU_HDL *hdl { uint32_t rc = NCSCC_RC_SUCCESS; AVSV_SUSI_ASGN *struct_ptr = NULL, **d_ptr = NULL; + uint16_t ver5 = AVSV_AVD_AVND_MSG_FMT_VER_5; EDU_INST_SET avsv_susi_asgn_rules[] = { {EDU_START, avsv_edp_susi_asgn, EDQ_LNKLIST, 0, 0, @@ -767,6 +768,12 @@ uint32_t avsv_edp_susi_asgn(EDU_HDL *hdl (long)&((AVSV_SUSI_ASGN *)0)->stdby_rank, 0, NULL}, {EDU_EXEC, m_NCS_EDP_SAAMFCSITRANSITIONDESCRIPTORT, 0, 0, 0, (long)&((AVSV_SUSI_ASGN *)0)->active_comp_dsc, 0, NULL}, + + /* Include comp capability in version 5 and higher */ + {EDU_VER_GE, NULL, 0, 0, 2, 0, 0, (EDU_EXEC_RTINE)((uint16_t *)(&(ver5)))}, + {EDU_EXEC, ncs_edp_uns32, 0, 0, 0, + (long)&((AVSV_SUSI_ASGN *)0)->capability, 0, NULL}, + {EDU_EXEC, avsv_edp_csi_attr_info, 0, 0, 0, (long)&((AVSV_SUSI_ASGN *)0)->attrs, 0, NULL}, diff --git a/osaf/libs/common/avsv/include/avsv_d2nmsg.h b/osaf/libs/common/avsv/include/avsv_d2nmsg.h --- a/osaf/libs/common/avsv/include/avsv_d2nmsg.h +++ b/osaf/libs/common/avsv/include/avsv_d2nmsg.h @@ -290,6 +290,7 @@ typedef struct avsv_susi_asgn { uint32_t csi_rank; /* The rank of the CSI in the SI */ uint32_t stdby_rank; SaAmfCSITransitionDescriptorT active_comp_dsc; + SaAmfCompCapabilityModelT capability; AVSV_CSI_ATTRS attrs; /* Inside the struct there is a * array of param vals.*/ struct avsv_susi_asgn *next; diff --git a/osaf/services/saf/avsv/avd/avd_util.c b/osaf/services/saf/avsv/avd/avd_util.c --- a/osaf/services/saf/avsv/avd/avd_util.c +++ b/osaf/services/saf/avsv/avd/avd_util.c @@ -770,6 +770,24 @@ static uint32_t avd_prep_csi_attr_info(A return NCSCC_RC_SUCCESS; } +/** + * Get saAmfCtCompCapability from the SaAmfCtCsType instance associated with the + * types of csi and comp. + * @param csi + * @param comp + * @return SaAmfCompCapabilityModelT + */ +static SaAmfCompCapabilityModelT get_comp_capability(const AVD_CSI *csi, + const AVD_COMP *comp) +{ + SaNameT dn; + avsv_create_association_class_dn(&csi->cstype->name, + &comp->comp_type->name, "safSupportedCsType", &dn); + AVD_CTCS_TYPE *ctcs_type = avd_ctcstype_get(&dn); + osafassert(ctcs_type); + return ctcs_type->saAmfCtCompCapability; +} + /***************************************************************************** * Function: avd_snd_susi_msg * @@ -1001,6 +1019,8 @@ uint32_t avd_snd_susi_msg(AVD_CL_CB *cb, compcsi_info->csi_name = l_compcsi->csi->name; compcsi_info->csi_rank = l_compcsi->csi->rank; compcsi_info->active_comp_dsc = trans_dsc; + compcsi_info->capability = + get_comp_capability(l_compcsi->csi, l_compcsi->comp); /* fill the Attributes for the CSI if new. */ if (actn == AVSV_SUSI_ACT_ASGN) { diff --git a/osaf/services/saf/avsv/avnd/avnd_comp.c b/osaf/services/saf/avsv/avnd/avnd_comp.c --- a/osaf/services/saf/avsv/avnd/avnd_comp.c +++ b/osaf/services/saf/avsv/avnd/avnd_comp.c @@ -876,54 +876,6 @@ uint32_t avnd_comp_unreg_prc(AVND_CB *cb } /**************************************************************************** - Name : avnd_comp_cap_x_act_or_1_act_check - - Description : This routine checks the capability of component wrt cs type. - - Arguments : comp - ptr to the comp - csi - ptr to the csi - - Return Values : true if comp cap is either x_act or 1_act , else false. - -******************************************************************************/ -static bool avnd_comp_cap_x_act_or_1_act_check(SaNameT *comp_type, SaNameT *csi_type) -{ - bool rc = false; - SaAisErrorT error; - SaNameT dn; - SaImmAccessorHandleT accessorHandle; - const SaImmAttrValuesT_2 **attributes; - SaAmfCompCapabilityModelT comp_cap; - SaImmAttrNameT attributeNames[2] = {"saAmfCtCompCapability", NULL}; - SaImmHandleT immOmHandle; - SaVersionT immVersion = { 'A', 2, 1 }; - - TRACE_ENTER2("comptype = '%s' : csitype = '%s'", comp_type->value, csi_type->value); - - avsv_create_association_class_dn(csi_type, comp_type, "safSupportedCsType", &dn); - - immutil_saImmOmInitialize(&immOmHandle, NULL, &immVersion); - immutil_saImmOmAccessorInitialize(immOmHandle, &accessorHandle); - - if ((error = immutil_saImmOmAccessorGet_2(accessorHandle, &dn, attributeNames, (SaImmAttrValuesT_2 ***)&attributes)) != SA_AIS_OK) { - LOG_ER("saImmOmAccessorGet FAILED %u for'%s'", error, dn.value); - goto done; - } - - if (immutil_getAttr("saAmfCtCompCapability", attributes, 0, &comp_cap) != SA_AIS_OK) - osafassert(0); - - if((SA_AMF_COMP_X_ACTIVE == comp_cap) || (SA_AMF_COMP_1_ACTIVE == comp_cap)) - rc = true; -done: - immutil_saImmOmAccessorFinalize(accessorHandle); - immutil_saImmOmFinalize(immOmHandle); - - TRACE_LEAVE2("%u", rc); - return rc; -} - -/**************************************************************************** Name : avnd_comp_csi_assign Description : This routine assigns the CSI to the component. It is @@ -1009,7 +961,8 @@ uint32_t avnd_comp_csi_assign(AVND_CB *c /* skip standby assignment to x_active or 1_active capable comp */ curr_csi = (csi) ? csi : m_AVND_CSI_REC_FROM_COMP_DLL_NODE_GET(m_NCS_DBLIST_FIND_FIRST(&comp->csi_list)); if (curr_csi && (SA_AMF_HA_STANDBY == curr_csi->si->curr_state) && - (true == avnd_comp_cap_x_act_or_1_act_check(&comp->saAmfCompType, &curr_csi->saAmfCSType))) { + ((curr_csi->capability == SA_AMF_COMP_X_ACTIVE) || + (curr_csi->capability == SA_AMF_COMP_1_ACTIVE))) { m_AVND_COMP_CSI_CURR_ASSIGN_STATE_SET(curr_csi, AVND_COMP_CSI_ASSIGN_STATE_ASSIGNED); m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(cb, curr_csi, AVND_CKPT_COMP_CSI_CURR_ASSIGN_STATE); rc = avnd_comp_csi_assign_done(cb, comp, csi); diff --git a/osaf/services/saf/avsv/avnd/avnd_sidb.c b/osaf/services/saf/avsv/avnd/avnd_sidb.c --- a/osaf/services/saf/avsv/avnd/avnd_sidb.c +++ b/osaf/services/saf/avsv/avnd/avnd_sidb.c @@ -246,6 +246,68 @@ AVND_SU_SI_REC *avnd_su_si_rec_add(AVND_ return 0; } +static void get_cstype(SaImmHandleT immOmHandle, + SaImmAccessorHandleT accessorHandle, + const SaNameT *csi_name, SaNameT *cstype) +{ + SaAisErrorT error; + const SaImmAttrValuesT_2 **attributes; + SaImmAttrNameT attributeNames[2] = {"saAmfCSType", NULL}; + + // TODO remove, just for test + LOG_NO("get_cstype: csi = '%s'", csi_name->value); + + if ((error = immutil_saImmOmAccessorGet_2(accessorHandle, csi_name, + attributeNames, (SaImmAttrValuesT_2 ***)&attributes)) != SA_AIS_OK) { + LOG_ER("saImmOmAccessorGet FAILED %u for %s", error, csi_name->value); + osafassert(0); + } + + if (immutil_getAttr("saAmfCSType", attributes, 0, cstype) != SA_AIS_OK) + osafassert(0); +} + +static SaAmfCompCapabilityModelT get_comp_capability(const SaNameT *comp_type, + const SaNameT *csi_name) +{ + SaAisErrorT error; + SaNameT dn; + SaImmAccessorHandleT accessorHandle = 0; + const SaImmAttrValuesT_2 **attributes; + SaAmfCompCapabilityModelT comp_cap; + SaImmAttrNameT attributeNames[2] = {"saAmfCtCompCapability", NULL}; + SaImmHandleT immOmHandle = 0; + SaVersionT immVersion = { 'A', 2, 1 }; + SaNameT cs_type; + + // TODO remove, just for test + LOG_NO("get_comp_capability: comptype = '%s' : csi = '%s'", comp_type->value, csi_name->value); + + TRACE_ENTER2("comptype = '%s' : csi = '%s'", comp_type->value, csi_name->value); + + immutil_saImmOmInitialize(&immOmHandle, NULL, &immVersion); + immutil_saImmOmAccessorInitialize(immOmHandle, &accessorHandle); + + get_cstype(immOmHandle, accessorHandle, csi_name, &cs_type); + avsv_create_association_class_dn(&cs_type, comp_type, "safSupportedCsType", &dn); + + if ((error = immutil_saImmOmAccessorGet_2(accessorHandle, &dn, attributeNames, + (SaImmAttrValuesT_2 ***)&attributes)) != SA_AIS_OK) { + LOG_ER("saImmOmAccessorGet FAILED %u for'%s'", error, dn.value); + goto done; + } + + if (immutil_getAttr("saAmfCtCompCapability", attributes, 0, &comp_cap) != SA_AIS_OK) + osafassert(0); + +done: + immutil_saImmOmAccessorFinalize(accessorHandle); + immutil_saImmOmFinalize(immOmHandle); + + TRACE_LEAVE2("%u", comp_cap); + return comp_cap; +} + /**************************************************************************** Name : avnd_su_si_csi_rec_add @@ -315,30 +377,12 @@ AVND_COMP_CSI_REC *avnd_su_si_csi_rec_ad memcpy(&csi_rec->name, ¶m->csi_name, sizeof(SaNameT)); csi_rec->rank = param->csi_rank; - { - /* Fill the cs type param from imm db, it will be used in finding comp capability */ - SaAisErrorT error; - SaImmAccessorHandleT accessorHandle; - const SaImmAttrValuesT_2 **attributes; - SaImmAttrNameT attributeNames[2] = {"saAmfCSType", NULL}; - SaImmHandleT immOmHandle; - SaVersionT immVersion = { 'A', 2, 1 }; - - immutil_saImmOmInitialize(&immOmHandle, NULL, &immVersion); - immutil_saImmOmAccessorInitialize(immOmHandle, &accessorHandle); - - if ((error = immutil_saImmOmAccessorGet_2(accessorHandle, ¶m->csi_name, attributeNames, - (SaImmAttrValuesT_2 ***)&attributes)) != SA_AIS_OK) { - LOG_ER("saImmOmAccessorGet FAILED %u for %s", error, param->csi_name.value); - osafassert(0); - } - - if (immutil_getAttr("saAmfCSType", attributes, 0, &csi_rec->saAmfCSType) != SA_AIS_OK) - osafassert(0); - - immutil_saImmOmAccessorFinalize(accessorHandle); - immutil_saImmOmFinalize(immOmHandle); - } + /* If CSI capability is not valid, read it from IMM */ + if (param->capability == ~0) + csi_rec->capability = + get_comp_capability(&comp->saAmfCompType, &csi_rec->name); + else + csi_rec->capability = param->capability; /* update the assignment related parameters */ memcpy(&csi_rec->act_comp_name, ¶m->active_comp_name, sizeof(SaNameT)); diff --git a/osaf/services/saf/avsv/avnd/avnd_su.c b/osaf/services/saf/avsv/avnd/avnd_su.c --- a/osaf/services/saf/avsv/avnd/avnd_su.c +++ b/osaf/services/saf/avsv/avnd/avnd_su.c @@ -306,10 +306,20 @@ uint32_t avnd_evt_avd_info_su_si_assign_ cb->rcv_msg_id = info->msg_id; if (info->msg_act == AVSV_SUSI_ACT_ASGN) { - /* SI rank was introduced in version 5 of the amfnd protocol, if the - * message version is older then that, read SI rank from IMM */ - if (evt->msg_fmt_ver < 5) + /* SI rank and CSI capability (originally from SaAmfCtCsType) was + * introduced in version 5 of the amfnd protocol. If the + * message version is older, take action. */ + if (evt->msg_fmt_ver < 5) { + AVSV_SUSI_ASGN *csi; + + /* indicate that capability is invalid for later use when + * creating CSI_REC */ + for (csi = info->list; csi != NULL; csi = csi->next) { + csi->capability = ~0; + } + info->si_rank = get_sirank(&info->si_name); + } } else { if (info->si_name.length > 0) { if (avnd_su_si_rec_get(cb, &info->su_name, &info->si_name) == NULL) diff --git a/osaf/services/saf/avsv/avnd/include/avnd_comp.h b/osaf/services/saf/avsv/avnd/include/avnd_comp.h --- a/osaf/services/saf/avsv/avnd/include/avnd_comp.h +++ b/osaf/services/saf/avsv/avnd/include/avnd_comp.h @@ -164,7 +164,7 @@ typedef struct avnd_comp_csi_rec { NCS_DB_LINK_LIST_NODE si_dll_node; /* node in the si dll */ NCS_DB_LINK_LIST_NODE comp_dll_node; /* node in the comp-csi dll */ SaNameT name; /* csi name */ - SaNameT saAmfCSType; /* cs type name */ + SaAmfCompCapabilityModelT capability; /* capability for this CSI */ uint32_t rank; /* csi rank */ /* state info */ ------------------------------------------------------------------------------ Put Bad Developers to Shame Dominate Development with Jenkins Continuous Integration Continuously Automate Build, Test & Deployment Start a new project now. Try Jenkins in the cloud. http://p.sf.net/sfu/13600_Cloudbees_APR _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel