osaf/services/saf/amf/amfd/include/app.h    |   6 +-
 osaf/services/saf/amf/amfd/include/csi.h    |   2 +-
 osaf/services/saf/amf/amfd/include/sg.h     |  18 +++++++---
 osaf/services/saf/amf/amfd/include/sgtype.h |   8 ++--
 osaf/services/saf/amf/amfd/include/si.h     |   2 +-
 osaf/services/saf/amf/amfd/include/si_dep.h |   2 +-
 osaf/services/saf/amf/amfd/include/su.h     |   7 ++-
 osaf/services/saf/amf/amfd/sg.cc            |  46 ++++++++++++++++++++++++++--
 8 files changed, 68 insertions(+), 23 deletions(-)


diff --git a/osaf/services/saf/amf/amfd/include/app.h 
b/osaf/services/saf/amf/amfd/include/app.h
--- a/osaf/services/saf/amf/amfd/include/app.h
+++ b/osaf/services/saf/amf/amfd/include/app.h
@@ -38,7 +38,7 @@ typedef struct avd_app_tag {
        SaNameT saAmfAppType;
        SaAmfAdminStateT saAmfApplicationAdminState;
        SaUint32T saAmfApplicationCurrNumSGs;
-       struct avd_sg_tag *list_of_sg;
+       AVD_SG *list_of_sg;
        struct avd_si_tag *list_of_si;
        struct avd_app_tag *app_type_list_app_next;
        struct avd_app_type_tag *app_type;
@@ -48,8 +48,8 @@ extern AmfDb<std::string, AVD_APP> *app_
 
 extern void avd_app_add_si(AVD_APP *app, struct avd_si_tag *si);
 extern void avd_app_remove_si(AVD_APP *app, struct avd_si_tag *si);
-extern void avd_app_add_sg(AVD_APP *app, struct avd_sg_tag *sg);
-extern void avd_app_remove_sg(AVD_APP *app, struct avd_sg_tag *sg);
+extern void avd_app_add_sg(AVD_APP *app, AVD_SG *sg);
+extern void avd_app_remove_sg(AVD_APP *app, AVD_SG *sg);
 extern SaAisErrorT avd_app_config_get(void);
 extern void avd_app_constructor(void);
 
diff --git a/osaf/services/saf/amf/amfd/include/csi.h 
b/osaf/services/saf/amf/amfd/include/csi.h
--- a/osaf/services/saf/amf/amfd/include/csi.h
+++ b/osaf/services/saf/amf/amfd/include/csi.h
@@ -160,7 +160,7 @@ extern void avd_compcsi_from_csi_and_sus
 extern void avd_csi_delete(struct avd_csi_tag *csi);
 extern void csi_cmplt_delete(struct avd_csi_tag *csi, bool ckpt);
 extern AVD_CSI *csi_create(const SaNameT *csi_name);
-extern bool csi_assignment_validate(struct avd_sg_tag *sg);
+extern bool csi_assignment_validate(AVD_SG *sg);
 extern SaAisErrorT csi_assign_hdlr(AVD_CSI *csi);
 
 #endif
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
@@ -66,7 +66,9 @@ typedef struct avd_sg_oper_tag {
  * This data structure lives in the AvD and reflects data points
  * associated with the Service group (SG).
  */
-typedef struct avd_sg_tag {
+class AVD_SG {
+public:
+       AVD_SG();
 
        SaNameT name;           /* the service group DN used as the index.
                                 * Checkpointing - Sent as a one time update.
@@ -186,9 +188,9 @@ typedef struct avd_sg_tag {
                                         * of the rank.
                                         */
 
-       struct avd_sg_tag *sg_list_sg_type_next;
+       AVD_SG *sg_list_sg_type_next;
        struct avd_amf_sg_type_tag *sg_type;
-       struct avd_sg_tag *sg_list_app_next;
+       AVD_SG *sg_list_app_next;
        struct avd_app_tag *app;
        bool equal_ranked_su; /* This flag is set when ranks of all SU is the 
same.
                                     It is used in equal distribution of SIs on 
SU 
@@ -209,7 +211,7 @@ typedef struct avd_sg_tag {
        void (*node_fail)(AVD_CL_CB *cb, AVD_SU *su);
 
        // Handle SG realign
-       uint32_t (*realign)(AVD_CL_CB *cb, struct avd_sg_tag *sg);
+       uint32_t (*realign)(AVD_CL_CB *cb, AVD_SG *sg);
 
        // Handle new SI or admin op UNLOCK of SI
        uint32_t (*si_func)(AVD_CL_CB *cb, struct avd_si_tag *si);
@@ -221,7 +223,7 @@ typedef struct avd_sg_tag {
        SaAisErrorT (*si_swap)(struct avd_si_tag *si, SaInvocationT invocation);
 
        // Handle SG admin op LOCK/SHUTDOWN
-       uint32_t (*sg_admin_down)(AVD_CL_CB *cb, struct avd_sg_tag *sg);
+       uint32_t (*sg_admin_down)(AVD_CL_CB *cb, AVD_SG *sg);
 
        // Handle SU inservice event, possibly assign the SU
        uint32_t (*su_insvc)(AVD_CL_CB *cb, AVD_SU *su);
@@ -241,7 +243,11 @@ typedef struct avd_sg_tag {
        uint32_t (*susi_failed)(AVD_CL_CB *cb, AVD_SU *su,
                        struct avd_su_si_rel_tag *susi, AVSV_SUSI_ACT act, 
SaAmfHAStateT state);
 
-} AVD_SG;
+private:
+       // disallow copy and assign, TODO(hafe) add common macro for this
+       AVD_SG(const AVD_SG&);
+       void operator=(const AVD_SG&);
+};
 
 extern AmfDb<std::string, AVD_SG> *sg_db;
 
diff --git a/osaf/services/saf/amf/amfd/include/sgtype.h 
b/osaf/services/saf/amf/amfd/include/sgtype.h
--- a/osaf/services/saf/amf/amfd/include/sgtype.h
+++ b/osaf/services/saf/amf/amfd/include/sgtype.h
@@ -28,7 +28,7 @@
 #include <saAmf.h>
 #include <include/db_template.h>
 
-struct avd_sg_tag;
+class AVD_SG;
 
 typedef struct avd_amf_sg_type_tag {
        SaNameT name;
@@ -46,15 +46,15 @@ typedef struct avd_amf_sg_type_tag {
    /******************** B.04 model 
*************************************************/
 
        uint32_t number_su_type;        /* size of array saAmfSGtValidSuTypes */
-       struct avd_sg_tag *list_of_sg;
+       AVD_SG *list_of_sg;
 
 } AVD_AMF_SG_TYPE;
 
 extern AmfDb<std::string, AVD_AMF_SG_TYPE> *sgtype_db;
 SaAisErrorT avd_sgtype_config_get(void);
 AVD_AMF_SG_TYPE *avd_sgtype_get(const SaNameT *dn);
-void avd_sgtype_add_sg(struct avd_sg_tag *sg);
-void avd_sgtype_remove_sg(struct avd_sg_tag *sg);
+void avd_sgtype_add_sg(AVD_SG *sg);
+void avd_sgtype_remove_sg(AVD_SG *sg);
 void avd_sgtype_constructor(void);
 
 #endif
diff --git a/osaf/services/saf/amf/amfd/include/si.h 
b/osaf/services/saf/amf/amfd/include/si.h
--- a/osaf/services/saf/amf/amfd/include/si.h
+++ b/osaf/services/saf/amf/amfd/include/si.h
@@ -90,7 +90,7 @@ typedef struct avd_si_tag {
                                         * Checkpointing - Updated 
independently.
                                         */
 
-       struct avd_sg_tag *sg_of_si;    /* the service group of this SI */
+       AVD_SG *sg_of_si;       /* the service group of this SI */
        struct avd_csi_tag *list_of_csi;        /* The list of CSIs in the SI */
        struct avd_si_tag *sg_list_of_si_next;  /* next SI in the SG list of 
SIs */
        struct avd_su_si_rel_tag *list_of_sisu; /* the list of su si 
relationship elements */
diff --git a/osaf/services/saf/amf/amfd/include/si_dep.h 
b/osaf/services/saf/amf/amfd/include/si_dep.h
--- a/osaf/services/saf/amf/amfd/include/si_dep.h
+++ b/osaf/services/saf/amf/amfd/include/si_dep.h
@@ -95,7 +95,7 @@ void avd_sidep_tol_tmr_evh(AVD_CL_CB *cb
 void avd_sidep_assign_evh(AVD_CL_CB *cb, struct avd_evt_tag *evt);
 void avd_sidep_unassign_evh(AVD_CL_CB *cb, struct avd_evt_tag *evt);
 void sidep_si_screen_si_dependencies(struct avd_si_tag *si);
-void avd_sidep_update_si_dep_state_for_all_sis(struct avd_sg_tag *sg);
+void avd_sidep_update_si_dep_state_for_all_sis(AVD_SG *sg);
 void sidep_stop_tol_timer(AVD_CL_CB *cb, struct avd_si_tag *si);
 extern SaAisErrorT avd_sidep_config_get(void);
 extern void avd_sidep_constructor(void);
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
@@ -29,12 +29,13 @@
 #include <def.h>
 #include <cb.h>
 #include <node.h>
-#include <sg.h>
 #include <amf_defs.h>
 #include <msg.h>
 #include <comp.h>
 #include "include/db_template.h"
 
+class AVD_SG;
+
 /**
  * AMF director Service Unit representation.
  */
@@ -80,7 +81,7 @@ class AVD_SU {
 
        int su_act_state; // not used, kept for EDU, remove later
 
-       struct avd_sg_tag *sg_of_su;    /* the service group of this SU */
+       AVD_SG *sg_of_su;       /* the service group of this SU */
        struct avd_avnd_tag *su_on_node;        /*  the node on which this SU 
resides */
        struct avd_su_si_rel_tag *list_of_susi; /* the list of su si 
relationship elements */
 
@@ -149,7 +150,7 @@ extern AmfDb<std::string, AVD_SU> *su_db
  * 
  * @return SaAisErrorT
  */
-extern SaAisErrorT avd_su_config_get(const SaNameT *sg_name, struct avd_sg_tag 
*sg);
+extern SaAisErrorT avd_su_config_get(const SaNameT *sg_name, AVD_SG *sg);
 
 /**
  * Class constructor, must be called before any other function
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
@@ -92,17 +92,55 @@ static void sg_remove_from_model(AVD_SG 
        m_AVSV_SEND_CKPT_UPDT_ASYNC_RMV(avd_cb, sg, AVSV_CKPT_AVD_SG_CONFIG);
 }
 
+AVD_SG::AVD_SG():
+               saAmfSGAutoRepair_configured(false),
+               saAmfSGAutoRepair(SA_FALSE),
+               saAmfSGAutoAdjust(SA_FALSE),
+               saAmfSGNumPrefActiveSUs(0),
+               saAmfSGNumPrefStandbySUs(0),
+               saAmfSGNumPrefInserviceSUs(0),
+               saAmfSGNumPrefAssignedSUs(0),
+               saAmfSGMaxActiveSIsperSU(0),
+               saAmfSGMaxStandbySIsperSU(0),
+               saAmfSGAutoAdjustProb(0),
+               saAmfSGCompRestartProb(0),
+               saAmfSGCompRestartMax(0),
+               saAmfSGSuRestartProb(0),
+               saAmfSGSuRestartMax(0),
+               saAmfSGAdminState(SA_AMF_ADMIN_UNLOCKED),
+               saAmfSGNumCurrAssignedSUs(0),
+               saAmfSGNumCurrInstantiatedSpareSUs(0),
+               saAmfSGNumCurrNonInstantiatedSpareSUs(0),
+               adjust_state(AVSV_SG_STABLE),
+               sg_ncs_spec(false),
+               sg_fsm_state(AVD_SG_FSM_STABLE),
+               admin_si(NULL),
+               list_of_su(NULL),
+               list_of_si(NULL),
+               sg_list_sg_type_next(NULL),
+               sg_type(NULL),
+               sg_list_app_next(NULL),
+               app(NULL),
+               equal_ranked_su(false),
+               max_assigned_su(NULL),
+               min_assigned_su(NULL),
+               si_tobe_redistributed(NULL),
+               try_inst_counter(0)
+{
+       memset(&name, 0, sizeof(SaNameT));
+       memset(&saAmfSGType, 0, sizeof(SaNameT));
+       memset(&saAmfSGSuHostNodeGroup, 0, sizeof(SaNameT));
+       su_oper_list.su = NULL;
+       su_oper_list.next = NULL;
+}
+
 AVD_SG *avd_sg_new(const SaNameT *dn)
 {
        AVD_SG *sg;
 
        sg = new AVD_SG();
-
        memcpy(sg->name.value, dn->value, dn->length);
        sg->name.length = dn->length;
-       sg->sg_ncs_spec = false;
-       sg->sg_fsm_state = AVD_SG_FSM_STABLE;
-       sg->adjust_state = AVSV_SG_STABLE;
 
        return sg;
 }

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to