1. Is changing saAmfCtDefCallbackTimeout, scope of this ticket ? The other attributes remain untouched. 2. Ideally, if saAmfCompCSISetCallbackTimeout is set, changing saAmfCtDefCallbackTimeout should not be affecting saAmfCompCSISetCallbackTimeout. So is true for other Timeouts attributes.
Thanks -Nagu > -----Original Message----- > From: Hans Nordeback [mailto:hans.nordeb...@ericsson.com] > Sent: 15 July 2014 18:04 > To: hans.fe...@ericsson.com; Praveen Malviya; Nagendra Kumar > Cc: opensaf-devel@lists.sourceforge.net > Subject: [PATCH 1 of 1] AMF: support immediate effect when changing comp- > type attributes V2 [#819] > > osaf/libs/common/amf/include/amf_defs.h | 6 + > osaf/services/saf/amf/amfd/comptype.cc | 61 +++++++++++++++++- > osaf/services/saf/amf/amfnd/compdb.cc | 85 > +++++++++++++++++++++++++ > osaf/services/saf/amf/amfnd/di.cc | 3 + > osaf/services/saf/amf/amfnd/hcdb.cc | 4 +- > osaf/services/saf/amf/amfnd/include/avnd_comp.h | 14 ++++ > 6 files changed, 169 insertions(+), 4 deletions(-) > > > diff --git a/osaf/libs/common/amf/include/amf_defs.h > b/osaf/libs/common/amf/include/amf_defs.h > --- a/osaf/libs/common/amf/include/amf_defs.h > +++ b/osaf/libs/common/amf/include/amf_defs.h > @@ -247,6 +247,12 @@ typedef enum > saAmfCompType_ID, > } AVSV_AMF_COMP_ATTR_ID; > > +/* Attribute ID enum for the saAmfCompType class */ > +typedef enum > +{ > + saAmfCtDefCallbackTimeout_ID = 1 > +} AVSV_AMF_COMPTYPE_ATTR_ID; > + > /* Attribute ID enum for the SaAmfHealthcheck class */ > typedef enum > { > diff --git a/osaf/services/saf/amf/amfd/comptype.cc > b/osaf/services/saf/amf/amfd/comptype.cc > --- a/osaf/services/saf/amf/amfd/comptype.cc > +++ b/osaf/services/saf/amf/amfd/comptype.cc > @@ -15,7 +15,9 @@ > * Ericsson > * > */ > - > +#include <set> > +#include <string.h> > +#include "node.h" > #include <saImmOm.h> > #include <immutil.h> > #include <logtrace.h> > @@ -396,6 +398,61 @@ done1: > return rc; > } > > +static void ccb_apply_modify_hdlr(const CcbUtilOperationData_t *opdata) > +{ > + const SaImmAttrModificationT_2 *attr_mod; > + int i; > + const AVD_COMP_TYPE *comp_type; > + SaNameT comp_type_name; > + > + TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, opdata- > >objectName.value); > + > + // input example: opdata.objectName.value, > safVersion=1,safCompType=AmfDemo1 > + comp_type_name = opdata->objectName; > + > + if ((comp_type = comptype_db- > >find(Amf::to_string(&comp_type_name))) == 0) { > + LOG_ER("Internal error: %s not found", > comp_type_name.value); > + return; > + } > + > + // Create a set of nodes where components "may" be using the given > comp_type attributes. > + // A msg will be sent to the related node regarding this change. If a > component has an > + // comp_type attribute that overrides this comp_type attribute it will > be > handled by the amfnd. > + std::set<AVD_AVND*, NodeNameCompare> node_set; > + > + AVD_COMP *comp = comp_type->list_of_comp; > + while (comp != NULL) { > + node_set.insert(comp->su->su_on_node); > + TRACE("comp name %s on node %s", comp- > >comp_info.name.value, comp->su->su_on_node->name.value); > + comp = comp->comp_type_list_comp_next; > + } > + > + std::set<AVD_AVND*>::iterator it; > + for (it = node_set.begin(); it != node_set.end(); ++it) { > + i = 0; > + while ((attr_mod = opdata->param.modify.attrMods[i++]) != > NULL) { > + AVSV_PARAM_INFO param; > + const SaImmAttrValuesT_2 *attribute = &attr_mod- > >modAttr; > + SaTimeT *param_val = (SaTimeT *)attribute- > >attrValues[0]; > + > + memset(¶m, 0, sizeof(param)); > + param.class_id = AVSV_SA_AMF_COMP_TYPE; > + param.act = AVSV_OBJ_OPR_MOD; > + param.name = opdata->objectName; > + param.value_len = sizeof(*param_val); > + memcpy(param.value, param_val, param.value_len); > + > + if (!strcmp(attribute->attrName, > "saAmfCtDefCallbackTimeout")) { > + TRACE("saAmfCtDefCallbackTimeout to '%llu' > for compType '%s' on node '%s'", *param_val, > + opdata->objectName.value, (*it)- > >name.value); > + param.attr_id = > saAmfCtDefCallbackTimeout_ID; > + avd_snd_op_req_msg(avd_cb, *it, ¶m); > + } else > + LOG_WA("Unexpected attribute name: %s", > attribute->attrName); > + } > + } > +} > + > static void comptype_ccb_apply_cb(CcbUtilOperationData_t *opdata) > { > AVD_COMP_TYPE *comp_type; > @@ -413,7 +470,7 @@ static void comptype_ccb_apply_cb(CcbUti > comptype_delete(static_cast<AVD_COMP_TYPE*>(opdata- > >userData)); > break; > case CCBUTIL_MODIFY: > - // values not used, no need to reinitialize type > + ccb_apply_modify_hdlr(opdata); > break; > default: > osafassert(0); > diff --git a/osaf/services/saf/amf/amfnd/compdb.cc > b/osaf/services/saf/amf/amfnd/compdb.cc > --- a/osaf/services/saf/amf/amfnd/compdb.cc > +++ b/osaf/services/saf/amf/amfnd/compdb.cc > @@ -888,6 +888,86 @@ done: > return rc; > } > > +uint32_t avnd_comptype_oper_req(AVND_CB *cb, AVSV_PARAM_INFO > *param) > +{ > + uint32_t rc = NCSCC_RC_FAILURE; > + > + AVND_COMP * comp; > + const char* comp_type_name; > + SaTimeT saAmfCtDefCallbackTimeout = 0; > + > + TRACE_ENTER2("Op %u, %s", param->act, param->name.value); > + > + switch (param->act) { > + case AVSV_OBJ_OPR_MOD: > + { > + osafassert(sizeof(SaTimeT) == param->value_len); > + > + // 1. find component from componentType, > + // input example, param->name.value = > safVersion=1,safCompType=AmfDemo1 > + comp_type_name = (char *) param->name.value; > + TRACE("comp_type_name: %s", comp_type_name); > + osafassert(comp_type_name); > + // 2. search each component for a matching compType > + > + comp = (AVND_COMP *) ncs_patricia_tree_getnext(&cb- > >compdb, (uint8_t *) 0); > + while (comp != 0) { > + if (strncmp((const char*) comp- > >saAmfCompType.value, comp_type_name, comp->saAmfCompType.length) > == 0) { > + // 3. comptype found, check if component uses > this comptype attribute value or if > + // component has specialized this attribute > value. > + TRACE("comp name: %s , comp_type: %s", > comp->name.value, comp->saAmfCompType.value); > + > + switch (param->attr_id) { > + case saAmfCtDefCallbackTimeout_ID: > + saAmfCtDefCallbackTimeout = > *((SaTimeT *) param->value); > + if (comp- > >use_comptype_attr.test(PxiedInstCallbackTimeout)) { > + comp- > >pxied_inst_cbk_timeout = saAmfCtDefCallbackTimeout; > + TRACE("comp- > >pxied_inst_cbk_timeout modified to '%llu'", comp->pxied_inst_cbk_timeout); > + } > + if (comp- > >use_comptype_attr.test(TerminateCallbackTimeout)) { > + comp->term_cbk_timeout = > saAmfCtDefCallbackTimeout; > + TRACE("comp- > >term_cbk_timeout modified to '%llu'", comp->term_cbk_timeout); > + } > + if (comp- > >use_comptype_attr.test(PxiedCleanupCallbackTimeout)) { > + comp- > >pxied_clean_cbk_timeout = saAmfCtDefCallbackTimeout; > + TRACE("comp- > >pxied_clean_cbk_timeout modified to '%llu'", comp- > >pxied_clean_cbk_timeout); > + } > + if (comp- > >use_comptype_attr.test(CsiSetCallbackTimeout)) { > + comp->csi_set_cbk_timeout = > saAmfCtDefCallbackTimeout; > + TRACE("comp- > >csi_set_cbk_timeout modified to '%llu'", comp->csi_set_cbk_timeout); > > + } > + if (comp- > >use_comptype_attr.test(CsiRemoveCallbackTimeout)) { > + comp->csi_rmv_cbk_timeout > = saAmfCtDefCallbackTimeout; > + TRACE("comp- > >csi_rmv_cbk_timeout modified to '%llu'", comp->csi_rmv_cbk_timeout); > > + } > + break; > + default: > + LOG_WA("Unexpected attribute id: > %d", param->attr_id); > + } > + } > + comp = (AVND_COMP *) > ncs_patricia_tree_getnext(&cb->compdb, (uint8_t *) & comp->name); > + } > + } > + case AVSV_OBJ_OPR_DEL: > + { > + // Do nothing > + break; > + } > + default: > + LOG_NO("%s: Unsupported action %u", __FUNCTION__, > param->act); > + goto done; > + } > + > + rc = NCSCC_RC_SUCCESS; > + > +done: > + rc = NCSCC_RC_SUCCESS; > + > + TRACE_LEAVE(); > + > + return rc; > +} > + > static void avnd_comptype_delete(amf_comp_type_t *compt) > { > int arg_counter; > @@ -1270,6 +1350,7 @@ static void init_clc_cli_attributes(AVND > attributes, 0, &cmd->timeout) != SA_AIS_OK) { > cmd->timeout = comptype->saAmfCtDefClcCliTimeout; > comp->pxied_inst_cbk_timeout = comptype- > >saAmfCtDefCallbackTimeout; > + comp->use_comptype_attr.set(PxiedInstCallbackTimeout); > } else { > comp->pxied_inst_cbk_timeout = cmd->timeout; > } > @@ -1286,6 +1367,7 @@ static void init_clc_cli_attributes(AVND > if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(comp)) { > cmd->timeout = comptype- > >saAmfCtDefCallbackTimeout; > comp->term_cbk_timeout = cmd->timeout; > + comp- > >use_comptype_attr.set(TerminateCallbackTimeout); > } > else > cmd->timeout = comptype->saAmfCtDefClcCliTimeout; > @@ -1302,6 +1384,7 @@ static void init_clc_cli_attributes(AVND > attributes, 0, &cmd->timeout) != SA_AIS_OK) { > cmd->timeout = comptype->saAmfCtDefClcCliTimeout; > comp->pxied_clean_cbk_timeout = comptype- > >saAmfCtDefCallbackTimeout; > + comp->use_comptype_attr.set(PxiedCleanupCallbackTimeout); > } else { > comp->pxied_clean_cbk_timeout = cmd->timeout; > } > @@ -1412,10 +1495,12 @@ static int comp_init(AVND_COMP *comp, co > if > (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompCSISetCallbackTi > meout"), attributes, > 0, &comp->csi_set_cbk_timeout) != SA_AIS_OK) > comp->csi_set_cbk_timeout = comptype- > >saAmfCtDefCallbackTimeout; > + comp->use_comptype_attr.set(CsiSetCallbackTimeout); > > if > (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompCSIRmvCallbackT > imeout"), attributes, > 0, &comp->csi_rmv_cbk_timeout) != SA_AIS_OK) > comp->csi_rmv_cbk_timeout = comptype- > >saAmfCtDefCallbackTimeout; > + comp->use_comptype_attr.set(CsiRemoveCallbackTimeout); > > if > (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompQuiescingComple > teTimeout"), attributes, > 0, &comp->quies_complete_cbk_timeout) != > SA_AIS_OK) > diff --git a/osaf/services/saf/amf/amfnd/di.cc > b/osaf/services/saf/amf/amfnd/di.cc > --- a/osaf/services/saf/amf/amfnd/di.cc > +++ b/osaf/services/saf/amf/amfnd/di.cc > @@ -225,6 +225,9 @@ uint32_t avnd_evt_avd_operation_request_ > case AVSV_SA_AMF_COMP: > rc = avnd_comp_oper_req(cb, param); > break; > + case AVSV_SA_AMF_COMP_TYPE: > + rc = avnd_comptype_oper_req(cb, param); > + break; > case AVSV_SA_AMF_HEALTH_CHECK: > rc = avnd_hc_oper_req(cb, param); > break; > diff --git a/osaf/services/saf/amf/amfnd/hcdb.cc > b/osaf/services/saf/amf/amfnd/hcdb.cc > --- a/osaf/services/saf/amf/amfnd/hcdb.cc > +++ b/osaf/services/saf/amf/amfnd/hcdb.cc > @@ -368,7 +368,7 @@ static void comp_hctype_update_compdb(AV > { > AVND_COMP_HC_REC *comp_hc_rec; > AVND_COMP * comp; > - char *comp_type_name; > + const char *comp_type_name; > AVSV_HLT_KEY hlt_chk; > AVND_COMP_HC_REC tmp_hc_rec; > > @@ -385,7 +385,7 @@ static void comp_hctype_update_compdb(AV > > // 3. matching compType found, check that component > does not have a SaAmfHealthcheck rec (specialization) > std::string hlt_chk_key = search_key((const char*) > param->name.value, "safHealthcheckKey="); > - if (hlt_chk_key.size() == 0) { > + if (hlt_chk_key.empty()) { > LOG_ER("%s: failed to get healthcheckKey > from %s", __FUNCTION__, param->name.value); > return; > } > diff --git a/osaf/services/saf/amf/amfnd/include/avnd_comp.h > b/osaf/services/saf/amf/amfnd/include/avnd_comp.h > --- a/osaf/services/saf/amf/amfnd/include/avnd_comp.h > +++ b/osaf/services/saf/amf/amfnd/include/avnd_comp.h > @@ -30,6 +30,8 @@ > #ifndef AVND_COMP_H > #define AVND_COMP_H > > +#include <bitset> > + > struct avnd_cb_tag; > struct avnd_su_si_rec; > struct avnd_su_tag; > @@ -279,6 +281,15 @@ typedef struct avnd_pxied_rec { > > typedef AVSV_COMP_INFO AVND_COMP_PARAM; > > +enum UsedComptypeAttrs { > + PxiedInstCallbackTimeout, > + PxiedCleanupCallbackTimeout, > + TerminateCallbackTimeout, > + CsiSetCallbackTimeout, > + CsiRemoveCallbackTimeout, > + NumAttrs > +}; > + > typedef struct avnd_comp_tag { > NCS_PATRICIA_NODE tree_node; /* comp tree node (key is > comp name) */ > NCS_DB_LINK_LIST_NODE su_dll_node; /* su dll node (key is > inst-level) > */ > @@ -362,6 +373,8 @@ typedef struct avnd_comp_tag { > bool pending_delete; /* Used in deleting component when su is in > instantiated state.*/ > > + std::bitset<NumAttrs> use_comptype_attr; > + > } AVND_COMP; > > #define AVND_COMP_NULL ((AVND_COMP *)0) > @@ -874,6 +887,7 @@ extern AVND_COMP_HC_REC *avnd_mbcsv_comp > extern void avnd_mbcsv_comp_hc_rec_del(struct avnd_cb_tag *cb, > AVND_COMP *comp, AVND_COMP_HC_REC *rec); > > extern uint32_t avnd_comp_oper_req(struct avnd_cb_tag *cb, > AVSV_PARAM_INFO *param); > +extern uint32_t avnd_comptype_oper_req(struct avnd_cb_tag *cb, > AVSV_PARAM_INFO *param); > extern unsigned int avnd_comp_config_get_su(struct avnd_su_tag *su); > extern int avnd_comp_config_reinit(AVND_COMP *comp); > extern void avnd_comp_delete(AVND_COMP *comp); ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel