--- src/amf/amfd/imm.cc | 2 + src/amf/amfd/node.cc | 114 ++++++++++++++++++++++++++++++--------------------- src/amf/amfd/node.h | 1 + 3 files changed, 71 insertions(+), 46 deletions(-)
diff --git a/src/amf/amfd/imm.cc b/src/amf/amfd/imm.cc index 82d2b13..03a91cc 100644 --- a/src/amf/amfd/imm.cc +++ b/src/amf/amfd/imm.cc @@ -41,6 +41,7 @@ #include "amf/common/amf_defs.h" #include "amf/amfd/imm.h" #include "amf/amfd/cluster.h" +#include "amf/amfd/node.h" #include "amf/amfd/app.h" #include "amf/amfd/sgtype.h" #include "amf/amfd/sg.h" @@ -2167,6 +2168,7 @@ static void *avd_imm_reinit_bg_thread(void *_cb) { osaf_mutex_unlock_ordie(&imm_reinit_mutex); exit(EXIT_FAILURE); } + avd_check_nodes_after_renit_imm(); } else { /* become applier and re-read the config */ rc = avd_imm_applier_set(); diff --git a/src/amf/amfd/node.cc b/src/amf/amfd/node.cc index 0ffcfb7..3a78a7e 100644 --- a/src/amf/amfd/node.cc +++ b/src/amf/amfd/node.cc @@ -46,6 +46,32 @@ bool NodeNameCompare::operator()(const AVD_AVND *lhs, const AVD_AVND *rhs) { return *lhs < *rhs; } +void avd_check_nodes_after_renit_imm() { + TRACE_ENTER(); + SaImmAccessorHandleT accessorHandle; + immutil_saImmOmAccessorInitialize(avd_cb->immOmHandle, &accessorHandle); + + AmfDb<std::string, AVD_AVND>::iterator it; + for (it = node_name_db->begin(); it != node_name_db->end(); it++) + { + const SaImmAttrValuesT_2 **attributes; + const std::string dn = it->first.c_str(); + SaImmAttrNameT attrName = const_cast<SaImmAttrNameT>("saAmfNodeClmNode"); + SaImmAttrNameT attributeNames[] = {attrName, nullptr}; + SaAisErrorT rc = + immutil_saImmOmAccessorGet_o2(accessorHandle, dn.c_str(), + attributeNames, + (SaImmAttrValuesT_2 ***)&attributes); + if (rc == SA_AIS_ERR_NOT_EXIST) { + LOG_WA("Remove node %s after reinit IMM", dn.c_str()); + avd_node_delete_nodeid(it->second); + avd_node_delete(it->second); + } + } + immutil_saImmOmAccessorFinalize(accessorHandle); + TRACE_LEAVE(); +} + uint32_t avd_node_add_nodeid(AVD_AVND *node) { if ((node_id_db->find(node->node_info.nodeId) == nullptr) && (node->node_info.nodeId != 0)) { @@ -152,56 +178,52 @@ AVD_AVND *avd_node_new(const std::string &dn) { void avd_node_delete(AVD_AVND *node) { TRACE_ENTER(); osafassert(node->pg_csi_list.n_nodes == 0); - if (node->node_info.nodeId) avd_node_delete_nodeid(node); - /* Check if the SUs and related objects are still left. This can - happen on Standby Amfd when it has just read the configuration - and before it becomes applier, Act Amfd deletes SUs. Those SUs - will be left out at Standby Amfd. Though this could be rare.*/ - if (avd_cb->avail_state_avd != SA_AMF_HA_ACTIVE) { - if (node->list_of_su.empty() != true) { - std::set<std::string> su_list; - std::set<std::string> comp_list; - for (const auto &su : node->list_of_su) su_list.insert(su->name); - for (std::set<std::string>::const_iterator iter = su_list.begin(); - iter != su_list.end(); ++iter) { - AVD_SU *su = su_db->find(*iter); - TRACE("Standby Amfd, su '%s' not deleted", su->name.c_str()); - for (const auto &comp : su->list_of_comp) - comp_list.insert(Amf::to_string(&comp->comp_info.name)); - for (std::set<std::string>::const_iterator iter1 = comp_list.begin(); - iter1 != comp_list.end(); ++iter1) { - AVD_COMP *comp = comp_db->find(*iter1); - TRACE("Standby Amfd, comp '%s' not deleted", - osaf_extended_name_borrow(&comp->comp_info.name)); - - std::map<std::string, AVD_COMPCS_TYPE *>::iterator it = - compcstype_db->begin(); - while (it != compcstype_db->end()) { - AVD_COMPCS_TYPE *compcstype = it->second; - if (compcstype->comp == comp) { - TRACE("Standby Amfd, compcstype '%s' not deleted", - compcstype->name.c_str()); - it = compcstype_db->erase(it); - delete compcstype; - } else - ++it; - } - - /* Delete the Comp. */ - struct CcbUtilOperationData opdata; - osaf_extended_name_alloc( - osaf_extended_name_borrow(&comp->comp_info.name), - &opdata.objectName); - comp_ccb_apply_delete_hdlr(&opdata); + if (node->node_info.nodeId) { + avd_node_delete_nodeid(node); + } + if (node->list_of_su.empty() != true) { + std::set<std::string> su_list; + std::set<std::string> comp_list; + for (const auto &su : node->list_of_su) su_list.insert(su->name); + for (std::set<std::string>::const_iterator iter = su_list.begin(); + iter != su_list.end(); ++iter) { + AVD_SU *su = su_db->find(*iter); + TRACE("su '%s' not deleted", su->name.c_str()); + for (const auto &comp : su->list_of_comp) + comp_list.insert(Amf::to_string(&comp->comp_info.name)); + for (std::set<std::string>::const_iterator iter1 = comp_list.begin(); + iter1 != comp_list.end(); ++iter1) { + AVD_COMP *comp = comp_db->find(*iter1); + TRACE("comp '%s' not deleted", + osaf_extended_name_borrow(&comp->comp_info.name)); + + std::map<std::string, AVD_COMPCS_TYPE *>::iterator it = + compcstype_db->begin(); + while (it != compcstype_db->end()) { + AVD_COMPCS_TYPE *compcstype = it->second; + if (compcstype->comp == comp) { + TRACE("compcstype '%s' not deleted", + compcstype->name.c_str()); + it = compcstype_db->erase(it); + delete compcstype; + } else + ++it; } - comp_list.clear(); - /* Delete the SU. */ + + /* Delete the Comp. */ struct CcbUtilOperationData opdata; - opdata.userData = su; - su_ccb_apply_delete_hdlr(&opdata); + osaf_extended_name_alloc( + osaf_extended_name_borrow(&comp->comp_info.name), + &opdata.objectName); + comp_ccb_apply_delete_hdlr(&opdata); } - su_list.clear(); + comp_list.clear(); + /* Delete the SU. */ + struct CcbUtilOperationData opdata; + opdata.userData = su; + su_ccb_apply_delete_hdlr(&opdata); } + su_list.clear(); } m_AVSV_SEND_CKPT_UPDT_ASYNC_RMV(avd_cb, node, AVSV_CKPT_AVD_NODE_CONFIG); node_name_db->erase(node->name); diff --git a/src/amf/amfd/node.h b/src/amf/amfd/node.h index e64bf8c..9fe9f19 100644 --- a/src/amf/amfd/node.h +++ b/src/amf/amfd/node.h @@ -240,5 +240,6 @@ extern bool are_all_ngs_in_unlocked_state(const AVD_AVND *node); extern bool any_ng_in_locked_in_state(const AVD_AVND *node); void avd_ng_restore_headless_states(AVD_CL_CB *cb, struct avd_su_si_rel_tag *susi); +void avd_check_nodes_after_renit_imm(); #endif // AMF_AMFD_NODE_H_ -- 2.7.4 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel