Ack with minor comments inlined with [Nagu]. Not tested, please share the test results if possible.
Thanks -Nagu > -----Original Message----- > From: Hans Nordeback [mailto:hans.nordeb...@ericsson.com] > Sent: 11 August 2014 17:50 > 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 V3 [#819] > > osaf/libs/common/amf/include/amf_defs.h | 7 + > osaf/services/saf/amf/amfd/comptype.cc | 66 ++++++++++++- > osaf/services/saf/amf/amfnd/compdb.cc | 120 > ++++++++++++++++++++++++ > 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 | 19 +++ > 6 files changed, 215 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,13 @@ typedef enum > saAmfCompType_ID, > } AVSV_AMF_COMP_ATTR_ID; > > +/* Attribute ID enum for the saAmfCompType class */ > +typedef enum > +{ [Nagu]: White spaces here below. > + saAmfCtDefCallbackTimeout_ID = 1, > + saAmfCtDefClcCliTimeout_ID = 2 > +} 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,66 @@ 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, [Nagu]: White spaces below. > + opdata->objectName.value, (*it)- > >name.value); > + param.attr_id = > saAmfCtDefCallbackTimeout_ID; > + avd_snd_op_req_msg(avd_cb, *it, ¶m); > + } else if (!strcmp(attribute->attrName, > "saAmfCtDefClcCliTimeout")) { > + TRACE("saAmfCtDefClcCliTimeout to '%llu' for > compType '%s' on node '%s'", *param_val, [Nagu]: White spaces below. > + opdata->objectName.value, (*it)- > >name.value); > + param.attr_id = saAmfCtDefClcCliTimeout_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 +475,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,116 @@ 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; > + SaTimeT saAmfCtDefClcCliTimeout = 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; > + case saAmfCtDefClcCliTimeout_ID: > + AVND_COMP_CLC_CMD_PARAM > *cmd; > + saAmfCtDefClcCliTimeout = > *((SaTimeT *) param->value); > + if (comp- > >use_comptype_attr.test(CompInstantiateTimeout)) { > > + cmd = &comp- > >clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE - 1]; > + cmd->timeout = > saAmfCtDefClcCliTimeout; > + TRACE("cmd->timeout > (Instantiate) modified to '%llu'", cmd->timeout); > > + } > + if (comp- > >use_comptype_attr.test(CompTerminateTimeout)) { > > + cmd = &comp- > >clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_TERMINATE - 1]; > + cmd->timeout = > saAmfCtDefClcCliTimeout; > + TRACE("cmd->timeout > (Terminate) modified to '%llu'", cmd->timeout); > > + } > + if (comp- > >use_comptype_attr.test(CompCleanupTimeout)) { > > + cmd = &comp- > >clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_CLEANUP - 1]; > + cmd->timeout = > saAmfCtDefClcCliTimeout; > + TRACE("cmd->timeout > (Cleanup) modified to '%llu'", cmd->timeout); > > + } > + if (comp- > >use_comptype_attr.test(CompAmStartTimeout)) { > > + cmd = &comp- > >clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTART - 1]; > + cmd->timeout = > saAmfCtDefClcCliTimeout; > + TRACE("cmd->timeout (AM > Start) modified to '%llu'", cmd->timeout); > > + } > + if (comp- > >use_comptype_attr.test(CompAmStopTimeout)) { > > + cmd = &comp- > >clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTOP - 1]; > + cmd->timeout = > saAmfCtDefClcCliTimeout; > + TRACE("cmd->timeout (AM > Stop) modified to '%llu'", cmd->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 +1380,8 @@ 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); > + comp->use_comptype_attr.set(CompInstantiateTimeout); > } else { > comp->pxied_inst_cbk_timeout = cmd->timeout; > } > @@ -1286,6 +1398,8 @@ 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); > + comp- > >use_comptype_attr.set(CompTerminateTimeout); > } > else > cmd->timeout = comptype->saAmfCtDefClcCliTimeout; > @@ -1302,6 +1416,8 @@ 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); > + comp->use_comptype_attr.set(CompCleanupTimeout); > } else { > comp->pxied_clean_cbk_timeout = cmd->timeout; > } > @@ -1317,6 +1433,7 @@ static void init_clc_cli_attributes(AVND > if > (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompAmStartTimeout > "), > attributes, 0, &cmd->timeout) != SA_AIS_OK) { > cmd->timeout = comptype->saAmfCtDefClcCliTimeout; > + comp->use_comptype_attr.set(CompAmStartTimeout); > } > > cmd = &comp- > >clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTOP - 1]; > @@ -1329,6 +1446,7 @@ static void init_clc_cli_attributes(AVND > if > (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompAmStopTimeout" > ), > attributes, 0, &cmd->timeout) != SA_AIS_OK) { > cmd->timeout = comptype->saAmfCtDefClcCliTimeout; > + comp->use_comptype_attr.set(CompAmStopTimeout); > } > > cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_HC - 1]; > @@ -1412,10 +1530,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,20 @@ typedef struct avnd_pxied_rec { > > typedef AVSV_COMP_INFO AVND_COMP_PARAM; > [Nagu]: White spaces below at each enum and after it also. > +enum UsedComptypeAttrs { > + PxiedInstCallbackTimeout, > + PxiedCleanupCallbackTimeout, > + TerminateCallbackTimeout, > + CsiSetCallbackTimeout, > + CsiRemoveCallbackTimeout, > + CompInstantiateTimeout, > + CompTerminateTimeout, > + CompCleanupTimeout, > + CompAmStartTimeout, > + CompAmStopTimeout, > + 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) > */ > @@ -364,6 +380,8 @@ typedef struct avnd_comp_tag { > bool error_report_sent; /* true when error is repoted on component > using > saAmfComponentErrorReport() or > saAmfComponentErrorReport_4()*/ > > + std::bitset<NumAttrs> use_comptype_attr; > + > } AVND_COMP; > > #define AVND_COMP_NULL ((AVND_COMP *)0) > @@ -876,6 +894,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); ------------------------------------------------------------------------------ _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel