Hi Praveen, One correction related to the condition below:
/** * @brief Checks if all comps of SU are in a given presence state. * @return true/false */ bool AVD_SU::all_comps_in_presence_state(SaAmfPresenceStateT pres) { if (std::all_of(list_of_comp.begin(), list_of_comp.end(), [&](AVD_COMP *comp) -> bool {return comp->saAmfCompPresenceState == pres;})) { return true; } else { return false; } } /Thanks HansN -----Original Message----- From: Hans Nordebäck [mailto:hans.nordeb...@ericsson.com] Sent: den 27 oktober 2015 15:28 To: praveen.malv...@oracle.com; nagendr...@oracle.com; Quyen Quoc Dao Cc: opensaf-devel@lists.sourceforge.net Subject: Re: [devel] [PATCH 1 of 2] amfd: fix SU presence state transition during restart admin op [#1518] ack, code review only. Some comments below. /Thanks HansN On 10/21/2015 02:38 PM, praveen.malv...@oracle.com wrote: > osaf/services/saf/amf/amfd/comp.cc | 10 + > osaf/services/saf/amf/amfd/include/comp.h | 1 + > osaf/services/saf/amf/amfd/include/su.h | 4 +- > osaf/services/saf/amf/amfd/ndproc.cc | 24 ++- > osaf/services/saf/amf/amfd/su.cc | 18 ++ > osaf/services/saf/amf/amfnd/clc.cc | 5 +- > osaf/services/saf/amf/amfnd/include/avnd_su.h | 2 + > osaf/services/saf/amf/amfnd/su.cc | 11 + > osaf/services/saf/amf/amfnd/susm.cc | 165 > +++++++++++++++++++------ > 9 files changed, 186 insertions(+), 54 deletions(-) > > > Note:Issue is valid for a restartable SU only. > > When RESTART operation is invoked on a restartable SU, its presence state > transtions: > INSTANTIATED => RESTARTING => INSTANTIATING => INSTANTIATED. > which is incorrect as per AIS-AMF-B.04.01-Table 5 Page 74. > > At present, when all the components are in RESTARTING state, SU is marked as > RESTARTING. > As soon as AMF starts instantiating first comp by keeping it in > RESTARTING state, AMF is marking SU INSTANTIATING. Here AMF must wait > for the instantiation of component and should not mark SU > INSTANTIATING. When first comp gets successfully instantiated, AMF > imust mark first comp INSTANTIATED and SU will also be marked INSTANTIATED as > per AIS-AMF-B.04.01-Table 5 Page 74. > > Patch fixes the problem by marking the SU INSTANTIATED as soons as > first component enters into INSTANTIATED state. During the > instantiation of other components, SU will remain in INSTANTIATED > state. AMF will reply to IMM for the operation when all the components enters > into INSTATANTIATED state. > > diff --git a/osaf/services/saf/amf/amfd/comp.cc > b/osaf/services/saf/amf/amfd/comp.cc > --- a/osaf/services/saf/amf/amfd/comp.cc > +++ b/osaf/services/saf/amf/amfd/comp.cc > @@ -1711,3 +1711,13 @@ SaAisErrorT check_comp_stability(const A > } > return SA_AIS_OK; > } > +/** > + * @brief CHeck if component is SA_AWARE. > + * @Return true/false. > + */ > +bool AVD_COMP::saaware() > +{ > + AVD_COMP_TYPE *comptype = > comptype_db->find(Amf::to_string(&saAmfCompType)); > + return (IS_COMP_SAAWARE(comptype->saAmfCtCompCategory)); > +} > + > diff --git a/osaf/services/saf/amf/amfd/include/comp.h > b/osaf/services/saf/amf/amfd/include/comp.h > --- a/osaf/services/saf/amf/amfd/include/comp.h > +++ b/osaf/services/saf/amf/amfd/include/comp.h > @@ -125,6 +125,7 @@ class AVD_COMP { > > void set_assigned(bool assigned) {assign_flag = assigned;} > bool assigned() const {return assign_flag;} [HansN] use bool saaware() const; > + bool saaware(); > private: > void initialize(); > // disallow copy and assign > 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 > @@ -145,7 +145,9 @@ class AVD_SU { > bool is_any_non_restartable_comp_assigned(); > bool all_pi_comps_restartable(); > bool all_pi_comps_nonrestartable(); > - [HansN] use SaAmfAdminOperationIdT get_admin_op_id() const; > + SaAmfAdminOperationIdT get_admin_op_id(); [HansN] use bool all_comps_in_presence_state(SaAmfPresenceStateT pres) const; > + bool all_comps_in_presence_state(SaAmfPresenceStateT pres); > + > private: > void initialize(); > void send_attribute_update(AVSV_AMF_SU_ATTR_ID attrib_id); diff > --git a/osaf/services/saf/amf/amfd/ndproc.cc > b/osaf/services/saf/amf/amfd/ndproc.cc > --- a/osaf/services/saf/amf/amfd/ndproc.cc > +++ b/osaf/services/saf/amf/amfd/ndproc.cc > @@ -369,20 +369,18 @@ static void surestart_admin_op_report_to > if ((su->saAmfSUPresenceState == SA_AMF_PRESENCE_INSTANTIATED) > && > (pres != SA_AMF_PRESENCE_RESTARTING)) > rc = SA_AIS_ERR_BAD_OPERATION; > - else if ((su->saAmfSUPresenceState == > SA_AMF_PRESENCE_RESTARTING) && > - (pres != SA_AMF_PRESENCE_INSTANTIATING)) > - rc = SA_AIS_ERR_BAD_OPERATION; > - else if (su->saAmfSUPresenceState == > SA_AMF_PRESENCE_INSTANTIATING) { > - if (pres == SA_AMF_PRESENCE_INSTANTIATED) > - rc = SA_AIS_OK; > + else if ((su->saAmfSUPresenceState == > SA_AMF_PRESENCE_RESTARTING) && > + (pres != SA_AMF_PRESENCE_INSTANTIATED)) > + rc = SA_AIS_ERR_REPAIR_PENDING; > + else if (pres == SA_AMF_PRESENCE_INSTANTIATED) { > + if > (su->all_comps_in_presence_state(SA_AMF_PRESENCE_INSTANTIATED) == true) > + rc = SA_AIS_OK; > else > - rc = SA_AIS_ERR_REPAIR_PENDING; > - } else if ((pres == SA_AMF_PRESENCE_RESTARTING) || > - (pres == SA_AMF_PRESENCE_INSTANTIATING)) { > + goto done; > + } else if (pres == SA_AMF_PRESENCE_RESTARTING) { > TRACE("Valid state transition, wait for final > transition."); > goto done; > } > - > } else { > if ((su->saAmfSUPresenceState == SA_AMF_PRESENCE_INSTANTIATED) > && > (pres != SA_AMF_PRESENCE_TERMINATING)) @@ > -795,6 +793,12 @@ void > avd_data_update_req_evh(AVD_CL_CB * > if (comp->admin_pend_cbk.invocation != > 0) > > comp_admin_op_report_to_imm(comp, static_cast<SaAmfPresenceStateT>(l_val)); > avd_comp_pres_state_set(comp, > static_cast<SaAmfPresenceStateT>(l_val)); > + [HansN] Can these if stmts be simplified? E.g if (comp->isInstantiated() && comp->getSu()->isInstantiated() ? > + if ((comp->su->get_admin_op_id() == > SA_AMF_ADMIN_RESTART) && > + (comp->saAmfCompPresenceState == > SA_AMF_PRESENCE_INSTANTIATED) && > + (comp->su->saAmfSUPresenceState == > SA_AMF_PRESENCE_INSTANTIATED) && > + > (comp->su->all_comps_in_presence_state(SA_AMF_PRESENCE_INSTANTIATED) == true)) > + > comp->su->complete_admin_op(SA_AIS_OK); > } else { > /* log error that a the value len is > invalid */ > LOG_ER("%s:%u: %u", __FILE__, __LINE__, > n2d_msg->msg_info.n2d_data_req.param_info. > 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 > @@ -2363,4 +2363,22 @@ bool AVD_SU::all_pi_comps_nonrestartable > } > return true; > } > +/** > + * @brief Returns Operation Id of the admin operation on SU. > + */ > +SaAmfAdminOperationIdT AVD_SU::get_admin_op_id() { return > +pend_cbk.admin_oper; } > > +/** > + * @brief Checks if all comps of SU are in a given presnece state. > + * @return true/false > + */ [HansN] Maybe the algorithm all_of can be used? (not tested) : /** * @brief Checks if all comps of SU are in a given presence state. * @return true/false */ bool AVD_SU::all_comps_in_presence_state(SaAmfPresenceStateT pres) { if (std::all_of(list_of_comp.begin(), list_of_comp.end(), [&](AVD_COMP *comp) -> bool {return comp->saAmfCompPresenceState != pres;})) { return true; } else { return false; } } > +bool AVD_SU::all_comps_in_presence_state(SaAmfPresenceStateT pres) { > + auto iter = std::find_if (list_of_comp.begin(), list_of_comp.end(), > + [&](AVD_COMP *comp) -> bool { return > comp->saAmfCompPresenceState != pres;}); > + if (iter == list_of_comp.end()) > + return true; > + return false; > +} > + > diff --git a/osaf/services/saf/amf/amfnd/clc.cc > b/osaf/services/saf/amf/amfnd/clc.cc > --- a/osaf/services/saf/amf/amfnd/clc.cc > +++ b/osaf/services/saf/amf/amfnd/clc.cc > @@ -1334,7 +1334,10 @@ uint32_t avnd_comp_clc_st_chng_prc(AVND_ > m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(comp)) || > !m_AVND_SU_IS_PREINSTANTIABLE(comp->su)) { > if (SA_AMF_PRESENCE_UNINSTANTIATED == final_st) > ev = AVND_SU_PRES_FSM_EV_COMP_UNINSTANTIATED; > - else if (SA_AMF_PRESENCE_INSTANTIATED == final_st && > SA_AMF_PRESENCE_ORPHANED != prv_st) > + else if ((SA_AMF_PRESENCE_INSTANTIATED == final_st) && > (SA_AMF_PRESENCE_ORPHANED != prv_st) && > + ((prv_st == SA_AMF_PRESENCE_INSTANTIATING) || > + (prv_st == SA_AMF_PRESENCE_TERMINATING) || > + (comp->su->admin_op_Id == > SA_AMF_ADMIN_RESTART))) > ev = AVND_SU_PRES_FSM_EV_COMP_INSTANTIATED; > else if (SA_AMF_PRESENCE_INSTANTIATION_FAILED == final_st) > ev = AVND_SU_PRES_FSM_EV_COMP_INST_FAIL; > diff --git a/osaf/services/saf/amf/amfnd/include/avnd_su.h > b/osaf/services/saf/amf/amfnd/include/avnd_su.h > --- a/osaf/services/saf/amf/amfnd/include/avnd_su.h > +++ b/osaf/services/saf/amf/amfnd/include/avnd_su.h > @@ -418,4 +418,6 @@ bool su_all_comps_restartable(const AVND > void su_send_suRestart_recovery_msg(AVND_SU *su); > bool pi_su_all_comps_uninstantiated (const AVND_SU& su); > bool is_any_non_restartable_comp_assigned(const AVND_SU& su); [HansN] Use const for these functions > +bool su_all_pi_comps_instantiated(const AVND_SU *su); bool > +all_csis_in_assigned_state(const AVND_SU *su); > #endif > diff --git a/osaf/services/saf/amf/amfnd/su.cc > b/osaf/services/saf/amf/amfnd/su.cc > --- a/osaf/services/saf/amf/amfnd/su.cc > +++ b/osaf/services/saf/amf/amfnd/su.cc > @@ -838,3 +838,14 @@ bool is_any_non_restartable_comp_assigne > return false; > } > > +/** > + * @brief Checks if all PI comps of SU are in INSTANTIATED state. > + * @return true/false > + */ > +bool su_all_pi_comps_instantiated(const AVND_SU *su) { > + bool su_is_instantiated; > + m_AVND_SU_IS_INSTANTIATED(su, su_is_instantiated); > + TRACE("All PI comps instantiated :'%u'",su_is_instantiated); > + return su_is_instantiated; > +} > diff --git a/osaf/services/saf/amf/amfnd/susm.cc > b/osaf/services/saf/amf/amfnd/susm.cc > --- a/osaf/services/saf/amf/amfnd/susm.cc > +++ b/osaf/services/saf/amf/amfnd/susm.cc > @@ -45,6 +45,7 @@ static uint32_t avnd_su_pres_inst_suterm > static uint32_t avnd_su_pres_inst_surestart_hdler(AVND_CB *, AVND_SU *, > AVND_COMP *); > static uint32_t avnd_su_pres_inst_comprestart_hdler(AVND_CB *, AVND_SU *, > AVND_COMP *); > static uint32_t avnd_su_pres_inst_compterming_hdler(AVND_CB *, > AVND_SU *, AVND_COMP *); > +static uint32_t avnd_su_pres_inst_compinst_hdler(AVND_CB *cb, AVND_SU > +*su, AVND_COMP *comp); > static uint32_t avnd_su_pres_terming_compinst_hdler(AVND_CB *, AVND_SU *, > AVND_COMP *); > static uint32_t avnd_su_pres_terming_comptermfail_hdler(AVND_CB *, AVND_SU > *, AVND_COMP *); > static uint32_t avnd_su_pres_terming_compuninst_hdler(AVND_CB *, > AVND_SU *, AVND_COMP *); @@ -96,7 +97,7 @@ static AVND_SU_PRES_FSM_FN > avnd_su_pres_ > 0, /* SU INST */ > avnd_su_pres_inst_suterm_hdler, /* SU TERM */ > avnd_su_pres_inst_surestart_hdler, /* SU RESTART */ > - 0, /* COMP INSTANTIATED */ > + avnd_su_pres_inst_compinst_hdler, /* COMP INSTANTIATED */ > avnd_su_pres_inst_compinstfail_hdler, /* COMP INST_FAIL */ > avnd_su_pres_inst_comprestart_hdler, /* COMP RESTARTING */ > avnd_su_pres_terming_comptermfail_hdler, /* COMP TERM_FAIL */ > @@ -1562,7 +1563,8 @@ uint32_t avnd_su_pres_fsm_run(AVND_CB *c > > > /** > - * @brief Reset flags when a NPI SU moves from INSTANTIATING to > INSTANTIATED state. > + * @brief Reset flags when a NPI SU moves from INSTANTIATING/RESTARTING > + * to INSTANTIATED state. > * @param su > * @return NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE > */ > @@ -1576,6 +1578,7 @@ static uint32_t npi_su_instantiating_to_ > m_AVND_SU_FAILED_RESET(su); > reset_suRestart_flag(su); > m_AVND_SEND_CKPT_UPDT_ASYNC_UPDT(avnd_cb, su, > AVND_CKPT_SU_FLAG_CHANGE); > + su->admin_op_Id = static_cast<SaAmfAdminOperationIdT>(0); > } else { > AVND_SU_SI_REC *si = 0; > si = (AVND_SU_SI_REC *)m_NCS_DBLIST_FIND_FIRST(&su->si_list); > @@ -1591,7 +1594,8 @@ static uint32_t npi_su_instantiating_to_ > > > /** > - * @brief Reset flags when a PI SU moves from Instantiating to INSTANTIATED > state. > + * @brief Reset flags when a PI SU moves from INSTANTIATING/RESTARTING > + * to INSTANTIATED state. > * @param su > * @return NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE > */ > @@ -1670,7 +1674,8 @@ uint32_t avnd_su_pres_st_chng_prc(AVND_C > TRACE("PI SU :'%s'",su->name.value); > /* instantiating/restarting -> instantiated */ > if (((SA_AMF_PRESENCE_INSTANTIATING == prv_st) || > (SA_AMF_PRESENCE_RESTARTING == prv_st)) > - && (SA_AMF_PRESENCE_INSTANTIATED == final_st)) { > + && (SA_AMF_PRESENCE_INSTANTIATED == final_st) && > + (su_all_pi_comps_instantiated(su) == true)) { > rc = pi_su_instantiating_to_instantiated(su); > if (NCSCC_RC_SUCCESS != rc) > goto done; > @@ -1800,7 +1805,8 @@ uint32_t avnd_su_pres_st_chng_prc(AVND_C > > /* instantiating/restarting -> instantiated */ > if (((SA_AMF_PRESENCE_INSTANTIATING == prv_st) || > (SA_AMF_PRESENCE_RESTARTING == prv_st)) > - && (SA_AMF_PRESENCE_INSTANTIATED == final_st)) { > + && (SA_AMF_PRESENCE_INSTANTIATED == final_st) && > + (all_csis_in_assigned_state(su) == true)) { > rc = npi_su_instantiating_to_instantiated(su); > } > /* instantiating/instantiated/restarting -> inst-failed */ @@ > -2749,25 +2755,26 @@ uint32_t avnd_su_pres_terming_comptermfa > * > * @returns true/false > **/ > -static bool all_csis_in_assigned_state(const AVND_SU *su) > +bool all_csis_in_assigned_state(const AVND_SU *su) > { > + TRACE_ENTER2("'%s'",su->name.value); > AVND_COMP_CSI_REC *curr_csi; > AVND_SU_SI_REC *curr_si; > - bool all_csi_removed = true; > + bool all_csi_assigned = true; > > for (curr_si = (AVND_SU_SI_REC > *)m_NCS_DBLIST_FIND_FIRST(&su->si_list); > - curr_si && all_csi_removed; > + curr_si && all_csi_assigned; > curr_si = (AVND_SU_SI_REC > *)m_NCS_DBLIST_FIND_NEXT(&curr_si->su_dll_node)) { > for (curr_csi = (AVND_COMP_CSI_REC > *)m_NCS_DBLIST_FIND_FIRST(&curr_si->csi_list); > curr_csi; curr_csi = (AVND_COMP_CSI_REC > *)m_NCS_DBLIST_FIND_NEXT(&curr_csi->si_dll_node)) { > if > (!m_AVND_COMP_CSI_CURR_ASSIGN_STATE_IS_ASSIGNED(curr_csi)) { > - all_csi_removed= false; > + all_csi_assigned = false; > break; > } > } > } > - > - return all_csi_removed; > + TRACE_LEAVE2("all_csi_assigned:%u",all_csi_assigned); > + return all_csi_assigned; > } > > > /********************************************************************* > ******* @@ -3071,7 +3078,6 @@ uint32_t avnd_su_pres_restart_comprestar > goto done; > } > } > - avnd_su_pres_state_set(su, SA_AMF_PRESENCE_INSTANTIATING); > done: > TRACE_LEAVE(); > return rc; > @@ -3094,43 +3100,43 @@ uint32_t avnd_su_pres_restart_compinst_h > { > AVND_COMP *curr_comp = 0; > AVND_COMP_CSI_REC *curr_csi = 0; > - bool all_inst = true; > uint32_t rc = NCSCC_RC_SUCCESS; > const char *compname = comp ? (char*)comp->name.value : "none"; > TRACE_ENTER2("ComponentInstantiated event in the Restarting state:'%s' > : '%s'", > su->name.value, compname); > - > + SaAmfPresenceStateT pres_init = su->pres; > /* > - * If pi su, pick the next pi comp & trigger it's FSM with RestartEv. > + * If pi su, pick the next pi comp & trigger it's FSM with Inst Event. > */ > if (m_AVND_SU_IS_PREINSTANTIABLE(su)) { > + TRACE("PI SU:'%s'", su->name.value); > + /* Mark SU instantiated if atleast one PI comp is in > instantiated state.*/ > + for (curr_comp = > m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_FIRST(&su->comp_list)); > + curr_comp && (su->pres != SA_AMF_PRESENCE_INSTANTIATED); > + curr_comp = > m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) > { > + if ((curr_comp->pres == SA_AMF_PRESENCE_INSTANTIATED) && > + > (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp))) > + avnd_su_pres_state_set(su, > SA_AMF_PRESENCE_INSTANTIATED); > + } > for (curr_comp = > m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node)); > - curr_comp; > - curr_comp = > m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) > { > - TRACE("PI SU:'%s'", su->name.value); > - /* restart the pi comp */ > + curr_comp; > + curr_comp = > m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) > { > + if (curr_comp->pres == SA_AMF_PRESENCE_INSTANTIATED) > + continue; > if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp) && > + (curr_comp->pres == > SA_AMF_PRESENCE_RESTARTING) && > (m_AVND_SU_IS_RESTART(su))) { > - rc = avnd_comp_clc_fsm_run(cb, curr_comp, > AVND_COMP_CLC_PRES_FSM_EV_RESTART); > + rc = avnd_comp_clc_fsm_run(cb, curr_comp, > +AVND_COMP_CLC_PRES_FSM_EV_INST); > if (NCSCC_RC_SUCCESS != rc) > goto done; > break; > } > } /* for */ > > - /* check whether all comp's are instantiated */ > - for (curr_comp = > m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_FIRST(&su->comp_list)); > - curr_comp; > - curr_comp = > m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) > { > - if ((curr_comp->pres != SA_AMF_PRESENCE_INSTANTIATED) && > - (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp))) > - all_inst = false; > - } > - > - /* OK, all are instantiated */ > - if (all_inst == true) { > - avnd_su_pres_state_set(su, > SA_AMF_PRESENCE_INSTANTIATED); > - } > + /*If all comps are instantiated then reassign the SU execpt in > a single comp case.*/ > + if ((pres_init == SA_AMF_PRESENCE_INSTANTIATED) && > + (su_all_pi_comps_instantiated(su) == true)) > + rc = pi_su_instantiating_to_instantiated(su); > } > > /* > @@ -3145,28 +3151,28 @@ uint32_t avnd_su_pres_restart_compinst_h > /* mark the csi state assigned */ > 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); > + if (su->pres != SA_AMF_PRESENCE_INSTANTIATED) > + avnd_su_pres_state_set(su, > SA_AMF_PRESENCE_INSTANTIATED); > > /* get the next csi */ > curr_csi = (AVND_COMP_CSI_REC > *)m_NCS_DBLIST_FIND_NEXT(&curr_csi->si_dll_node); > > /* Restart next component associated with unassigned CSI and if > the component > is not already in RESTARTING state. > - TODO: SU FSM in restarting state should also not restart a > component which > - is in INSTANTIATING state. > */ > if ((curr_csi != NULL) && > - > (m_AVND_COMP_CSI_CURR_ASSIGN_STATE_IS_UNASSIGNED(curr_csi) == true) && > - (curr_csi->comp->pres != SA_AMF_PRESENCE_RESTARTING) && > + > (m_AVND_COMP_CSI_CURR_ASSIGN_STATE_IS_RESTARTING(curr_csi) == > +true) && > (m_AVND_SU_IS_RESTART(su))) { > - /* we have another csi. trigger the comp fsm with > RestartEv */ > + /* we have another csi. trigger the comp fsm with Inst > event*/ > rc = avnd_comp_clc_fsm_trigger(cb, curr_csi->comp, > - > AVND_COMP_CLC_PRES_FSM_EV_RESTART); > + > AVND_COMP_CLC_PRES_FSM_EV_INST); > if (NCSCC_RC_SUCCESS != rc) > goto done; > - } else if (all_csis_in_assigned_state(su) == true) { > - /* => si assignment done */ > - avnd_su_pres_state_set(su, > SA_AMF_PRESENCE_INSTANTIATED); > } > + /*If all comps are instantiated then reset SU params.*/ > + if ((pres_init == SA_AMF_PRESENCE_INSTANTIATED) && > + (all_csis_in_assigned_state(su) == true)) > + rc = npi_su_instantiating_to_instantiated(su); > } > > done: > @@ -3662,3 +3668,78 @@ uint32_t avnd_su_pres_terming_suinst_hdl > TRACE_LEAVE2("%u", rc); > return rc; > } > + > +/** > + * @brief During restart admin op on SU, a SU enters into INSTANTIATED state > + * as soon as the first component is succesfully instantiated. For all > other > + * components in SU, this handler will take care of their instantiation > honoring > + * instantiation-level. > + * @param ptr to avnd_cb. > + * @param ptr to su. > + * @param ptr to comp. > + * @return NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. > + */ > +uint32_t avnd_su_pres_inst_compinst_hdler(AVND_CB *cb, AVND_SU *su, > +AVND_COMP *comp) { > + AVND_COMP *curr_comp = 0; > + AVND_COMP_CSI_REC *curr_csi = 0; > + uint32_t rc = NCSCC_RC_SUCCESS; > + const char *compname = comp ? (char*)comp->name.value : "none"; > + TRACE_ENTER2("Component Instantiated event in the Instantiated > state:'%s' : '%s'", > + su->name.value, compname); > + > + if (m_AVND_SU_IS_PREINSTANTIABLE(su)) { > + TRACE("PI SU"); > + for (curr_comp = > m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node)); > + curr_comp; > + curr_comp = > + > m_AVND_COMP_FROM_SU_DLL_NODE_GET(m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) > { > + if (curr_comp->pres == SA_AMF_PRESENCE_INSTANTIATED) > + continue; > + if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp) && > + (curr_comp->pres == > SA_AMF_PRESENCE_RESTARTING) && > + (m_AVND_SU_IS_RESTART(su))) { > + TRACE("Running the component clc FSM for '%s'", > curr_comp->name.value); > + rc = avnd_comp_clc_fsm_run(cb, curr_comp, > AVND_COMP_CLC_PRES_FSM_EV_INST); > + if (NCSCC_RC_SUCCESS != rc) > + goto done; > + break; > + } > + } > + if (su_all_pi_comps_instantiated(su) == true) > + rc = pi_su_instantiating_to_instantiated(su); > + } > + > + if (!m_AVND_SU_IS_PREINSTANTIABLE(su)) { > + TRACE("NPI SU"); > + /* get the only csi rec */ > + curr_csi = > m_AVND_CSI_REC_FROM_COMP_DLL_NODE_GET(m_NCS_DBLIST_FIND_FIRST(&comp->csi_list)); > + osafassert(curr_csi); > + > + 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); > + > + if (su->pres != SA_AMF_PRESENCE_INSTANTIATED) > + avnd_su_pres_state_set(su, > SA_AMF_PRESENCE_INSTANTIATED); > + > + /* get the next csi */ > + curr_csi = (AVND_COMP_CSI_REC > *)m_NCS_DBLIST_FIND_NEXT(&curr_csi->si_dll_node); > + if ((curr_csi != NULL) && > + > (m_AVND_COMP_CSI_CURR_ASSIGN_STATE_IS_RESTARTING(curr_csi) == true) && > + (m_AVND_SU_IS_RESTART(su))) { > + /* we have another csi. trigger the comp fsm with > InstEv */ > + TRACE("There's another CSI:'%s', Running the component > clc FSM for comp:'%s'", > + > curr_csi->name.value,curr_csi->comp->name.value); > + rc = avnd_comp_clc_fsm_trigger(cb, curr_csi->comp, > AVND_COMP_CLC_PRES_FSM_EV_INST); > + if (NCSCC_RC_SUCCESS != rc) > + goto done; > + } > + /*If all comps are instantiated then reset SU params.*/ > + if (all_csis_in_assigned_state(su) == true) { > + rc = npi_su_instantiating_to_instantiated(su); > + } > + } > +done: > + TRACE_LEAVE2("%u", rc); > + return rc; > +} ------------------------------------------------------------------------------ _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel ------------------------------------------------------------------------------ _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel