osaf/services/saf/amf/amfd/include/sg.h |   7 +++++++
 osaf/services/saf/amf/amfd/sg.cc        |  21 +++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)


After SG lock, immlist <sg> does not show correct value of 
saAmfSGNumCurrAssignedSUs.

AMFD is not calculcating dynamically the values of following runtime
attributes:
saAmfSGNumCurrNonInstantiatedSpareSUs,
saAmfSGNumCurrInstantiatedSpareSUs and
saAmfSGNumCurrAssignedSUs
in sg_rt_attr_cb().

Patch fixes the problem by  providing updated values in IMM callback.

diff --git a/osaf/services/saf/amf/amfd/include/sg.h 
b/osaf/services/saf/amf/amfd/include/sg.h
--- a/osaf/services/saf/amf/amfd/include/sg.h
+++ b/osaf/services/saf/amf/amfd/include/sg.h
@@ -417,6 +417,13 @@ public:
        bool ng_using_saAmfSGAdminState;
        
        uint32_t term_su_list_in_reverse();
+       //Runtime calculates value of saAmfSGNumCurrAssignedSUs;
+       uint32_t curr_assigned_sus();
+       //Runtime calculates value of saAmfSGNumCurrInstantiatedSpareSUs;
+       uint32_t curr_instantiated_spare_sus();
+       //Runtime calculates value of saAmfSGNumCurrNonInstantiatedSpareSUs;
+       uint32_t curr_non_instantiated_spare_sus();
+
 private:
        // disallow copy and assign, TODO(hafe) add common macro for this
        AVD_SG(const AVD_SG&);
diff --git a/osaf/services/saf/amf/amfd/sg.cc b/osaf/services/saf/amf/amfd/sg.cc
--- a/osaf/services/saf/amf/amfd/sg.cc
+++ b/osaf/services/saf/amf/amfd/sg.cc
@@ -1428,12 +1428,15 @@ static SaAisErrorT sg_rt_attr_cb(SaImmOi
 
        while ((attributeName = attributeNames[i++]) != NULL) {
                if (!strcmp("saAmfSGNumCurrAssignedSUs", attributeName)) {
+                       sg->saAmfSGNumCurrAssignedSUs = sg->curr_assigned_sus();
                        avd_saImmOiRtObjectUpdate_sync(objectName, 
attributeName,
                                SA_IMM_ATTR_SAUINT32T, 
&sg->saAmfSGNumCurrAssignedSUs);
                } else if (!strcmp("saAmfSGNumCurrNonInstantiatedSpareSUs", 
attributeName)) {
+                       sg->saAmfSGNumCurrNonInstantiatedSpareSUs = 
sg->curr_non_instantiated_spare_sus();
                        avd_saImmOiRtObjectUpdate_sync(objectName, 
attributeName,
                                SA_IMM_ATTR_SAUINT32T, 
&sg->saAmfSGNumCurrNonInstantiatedSpareSUs);
                } else if (!strcmp("saAmfSGNumCurrInstantiatedSpareSUs", 
attributeName)) {
+                       sg->saAmfSGNumCurrInstantiatedSpareSUs = 
sg->curr_instantiated_spare_sus();
                        avd_saImmOiRtObjectUpdate_sync(objectName, 
attributeName,
                                SA_IMM_ATTR_SAUINT32T, 
&sg->saAmfSGNumCurrInstantiatedSpareSUs);
                } else {
@@ -1987,3 +1990,21 @@ AVD_SU* AVD_SG::first_su()
                return NULL;
        }
 }
+
+uint32_t AVD_SG::curr_assigned_sus()
+{
+       return (std::count_if (list_of_su.begin(), list_of_su.end(),
+                [](AVD_SU *su) -> bool { return (su->list_of_susi != 
nullptr);}));
+}
+uint32_t AVD_SG::curr_instantiated_spare_sus()
+{
+       return (std::count_if (list_of_su.begin(), list_of_su.end(),
+                [](AVD_SU *su) -> bool { return ((su->list_of_susi == nullptr) 
&&
+                        (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_INSTANTIATED));}));
+}
+uint32_t AVD_SG::curr_non_instantiated_spare_sus()
+{
+       return (std::count_if (list_of_su.begin(), list_of_su.end(),
+               [](AVD_SU *su) -> bool { return ((su->list_of_susi == nullptr) 
&&
+                       (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_UNINSTANTIATED));}));      
+}

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to