Hi Zoran and Neel,

I included your comments to the patch when pushing.


Thanks,

Hung Nguyen - DEK Technologies


--------------------------------------------------------------------------------
From: Zoran Milinkovic [email protected]
Sent: Tuesday, March 15, 2016 11:17PM
To: Hung Nguyen, Neelakanta Reddy
     [email protected], [email protected]
Cc: Opensaf-devel
     [email protected]
Subject: RE: [PATCH 1 of 1] imm: Send all writable attributes to applier in 
OiCcbObjectModifyCallback [#1651]


Hi Hung,

Ack with a minor inline comment.

-----Original Message-----
From: Hung Nguyen [mailto:[email protected]]
Sent: Friday, February 05, 2016 10:57 AM
To: Zoran Milinkovic; [email protected]
Cc: [email protected]
Subject: [PATCH 1 of 1] imm: Send all writable attributes to applier in 
OiCcbObjectModifyCallback [#1651]

  osaf/services/saf/immsv/immnd/ImmModel.cc  |  143 ++++++++++++++++++++++++----
  osaf/services/saf/immsv/immnd/ImmModel.hh  |   11 ++-
  osaf/services/saf/immsv/immnd/immnd_evt.c  |   28 ++++-
  osaf/services/saf/immsv/immnd/immnd_init.h |    4 +
  4 files changed, 157 insertions(+), 29 deletions(-)


This feature is only for appliers with version A.2.17 or later.
Appliers which are initialized as A.2.17 or later MUST support 
SA_IMM_ATTR_VALUES_REPLACE in their callbacks.

diff --git a/osaf/services/saf/immsv/immnd/ImmModel.cc 
b/osaf/services/saf/immsv/immnd/ImmModel.cc
--- a/osaf/services/saf/immsv/immnd/ImmModel.cc
+++ b/osaf/services/saf/immsv/immnd/ImmModel.cc
@@ -723,6 +723,12 @@ immModel_canonicalizeAttrModification(IM
      return 
ImmModel::instance(&cb->immModel)->canonicalizeAttrModification(req);
  }
  
+struct immsv_attr_mods_list*
+immModel_getAllWritableAttributes(IMMND_CB *cb, const ImmsvOmCcbObjectModify 
*req, bool* hasLongDn)
+{
+    return ImmModel::instance(&cb->immModel)->getAllWritableAttributes(req, 
hasLongDn);
+}
+
  SaUint32T
  immModel_getLocalAppliersForObj(IMMND_CB *cb,
      const SaNameT* objName,
@@ -776,6 +782,11 @@ immModel_getLocalAppliersForCcb(IMMND_CB
      return arrSize;
  }
  
+SaUint32T immModel_getPbeApplierConn(IMMND_CB *cb)
+{
+       return ImmModel::instance(&cb->immModel)->getPbeApplierConn();
+}
+
  SaAisErrorT
  immModel_ccbObjectModify(IMMND_CB *cb,
      const struct ImmsvOmCcbObjectModify* req,
@@ -6607,6 +6618,15 @@ void ImmModel::getLocalAppliersForObj(co
      }
  }
  
+SaUint32T ImmModel::getPbeApplierConn()
+{
+       SaUint32T conn = 0;
+       unsigned int nodeId = 0;
+       getPbeBSlave(&conn, &nodeId);
+
+       return conn;
+}
+
  /*
    Checks if the there is any local special applier AND if the CCB op callbacks
    have not yet included information about admin-owner-name.
@@ -7024,12 +7044,49 @@ ImmModel::specialApplierTrimCreate(SaUin
      return attrValues;
  }
  
+/* Get after image of an object in a specific CCB */
+ObjectInfo*
+ImmModel::getObjectAfterImageInCcb(const std::string& objName, SaUint32T ccbId)
+{
+    CcbVector::iterator ci;
+    CcbInfo* ccb = NULL;
+    ObjectInfo* afim = NULL;
+    ObjectMutationMap::iterator omuti;
+    ObjectMutation* oMut = NULL;
+
+    osafassert(!objName.empty());
+
+    /* Get ccb info */
+    ci = std::find_if(sCcbVector.begin(), sCcbVector.end(), CcbIdIs(ccbId));
+    osafassert(ci != sCcbVector.end());
+    ccb = *ci;
+
+    /* Get object mutation */
+    omuti = ccb->mMutations.find(objName);
+    osafassert(omuti != ccb->mMutations.end());
+    oMut = omuti->second;
+
+    /* Get after image */
+    if (oMut->mOpType == IMM_CREATE) { /* Chained operation */
+        ObjectMap::iterator oi = sObjectMap.find(objName);
+        osafassert(oi != sObjectMap.end());
+        afim = oi->second;

[Zoran] The upper code can be replaced with the code from "IMM_MODIFY". No need 
for look up in sObjectMap.
"IF" statement for IMM_MODIFY could look like "if (oMut->mOpType == IMM_MODIFY 
|| oMut->mOpType == IMM_CREATE)"

Thanks,
Zoran

+    } else if (oMut->mOpType == IMM_MODIFY) {
+        afim = oMut->mAfterImage;
+    } /* return NULL for IMM_DELETE */
+
+    return afim;
+}
+
  /* This function converts value(s) of an attribute into a single attr-mod.
   * attrModType is always SA_IMM_ATTR_VALUES_REPLACE.
+ *
+ * 'hasLongDns' is set to true when there's at least one value is long dn.
+ * If it's NULL or 'true', no checking for long DNs will be done.
   */
  immsv_attr_mods_list*
  ImmModel::attrValueToAttrMod(const ObjectInfo* obj, const std::string& 
attrName,
-                             SaUint32T attrType)
+                             SaUint32T attrType, SaImmAttrFlagsT attrFlags, 
bool* hasLongDn)
  {
      ImmAttrValueMap::const_iterator avi = obj->mAttrValueMap.find(attrName);
      osafassert(avi != obj->mAttrValueMap.end());
@@ -7059,6 +7116,26 @@ ImmModel::attrValueToAttrMod(const Objec
          attrMod->attrValue.attrValuesNumber = 1 + attrValue->extraValues();
      } /* else, attrValuesNumber is already set to 0 */
  
+    /* Check for long DN when attribute type is
+     * 'SA_IMM_ATTR_SANAMET' or 'SA_IMM_ATTR_SASTRINGT with SA_IMM_ATTR_DN'.
+     * Will be skipped if hasLongDn is NULL or already 'true'. */
+    if (hasLongDn && !(*hasLongDn) && !attrValue->empty() &&
+            (attrType == SA_IMM_ATTR_SANAMET ||
+                    (attrType == SA_IMM_ATTR_SASTRINGT && (attrFlags & 
SA_IMM_ATTR_DN)))) {
+        if (strlen(attrValue->getValueC_str()) >= 
SA_MAX_UNEXTENDED_NAME_LENGTH) { /* Check head value */
+            *hasLongDn = true; /* Found! Skip checking more values */
+        } else if (attrValue->extraValues()) { /* Check more values */
+            ImmAttrMultiValue* multiVal = ((ImmAttrMultiValue *) 
attrValue)->getNextAttrValue();
+            while (multiVal) {
+                if (!multiVal->empty() && strlen(multiVal->getValueC_str()) >= 
SA_MAX_UNEXTENDED_NAME_LENGTH) {
+                    *hasLongDn = true; /* Found! Stop checking */
+                    break; /* while */
+                }
+                multiVal = multiVal->getNextAttrValue();
+            }
+        }
+    }
+
      return attrMod;
  }
  
@@ -7072,36 +7149,16 @@ ImmModel::canonicalizeAttrModification(c
      TRACE_ENTER();
      immsv_attr_mods_list* result = NULL;
      std::string objectName;
-    CcbVector::iterator ci;
-    CcbInfo* ccb = NULL;
      ObjectInfo* afim = NULL;
-    ObjectMutationMap::iterator omuti;
-    ObjectMutation* oMut = NULL;
  
      /* Get object Name */
      size_t sz = strnlen(req->objectName.buf, (size_t) req->objectName.size);
      objectName.append((const char*) req->objectName.buf, sz);
      osafassert(!objectName.empty());
  
-    /* Get ccb info */
-    ci = std::find_if(sCcbVector.begin(), sCcbVector.end(), 
CcbIdIs(req->ccbId));
-    osafassert(ci != sCcbVector.end());
-    ccb = *ci;
-
-    /* Get object mutation */
-    omuti = ccb->mMutations.find(objectName);
-    osafassert(omuti != ccb->mMutations.end());
-    oMut = omuti->second;
-
      /* Get after image */
-    osafassert(oMut->mOpType != IMM_DELETE);
-    if (oMut->mOpType == IMM_CREATE) { /* Chained operation */
-        ObjectMap::iterator oi = sObjectMap.find(objectName);
-        osafassert(oi != sObjectMap.end());
-        afim = oi->second;
-    } else if (oMut->mOpType == IMM_MODIFY) {
-        afim = oMut->mAfterImage;
-    }
+    afim = getObjectAfterImageInCcb(objectName, req->ccbId);
+    osafassert(afim);
  
      /* Build canonicalized attr-mod list */
      immsv_attr_mods_list* reqAttrMods = req->attrMods;
@@ -7119,6 +7176,46 @@ ImmModel::canonicalizeAttrModification(c
      return result;
  }
  
+/* This function allocates new memory for attribute-modifications
+ * for all writable attributes of object.
+ * Remember to free the memory with immsv_free_attrmods().
+ */
+immsv_attr_mods_list*
+ImmModel::getAllWritableAttributes(const ImmsvOmCcbObjectModify *req, bool* 
hasLongDn)
+{
+    TRACE_ENTER();
+    immsv_attr_mods_list* result = NULL;
+    std::string objectName;
+    ObjectInfo* afim = NULL;
+    AttrMap::iterator ai;
+
+    /* Get object Name */
+    size_t sz = strnlen(req->objectName.buf, (size_t) req->objectName.size);
+    objectName.append((const char*) req->objectName.buf, sz);
+    osafassert(!objectName.empty());
+
+    /* Get after image */
+    afim = getObjectAfterImageInCcb(objectName, req->ccbId);
+    osafassert(afim);
+
+    /* Build attr-mod list for all writable attributes */
+    osafassert(hasLongDn);
+    ClassInfo* classInfo = afim->mClassInfo;
+    ai = classInfo->mAttrMap.begin();
+    for (; ai != classInfo->mAttrMap.end(); ai++) {
+        if (ai->second->mFlags & SA_IMM_ATTR_WRITABLE) {
+            immsv_attr_mods_list* attrMod = attrValueToAttrMod(afim, 
(std::string&) ai->first,
+                                                               
ai->second->mValueType,
+                                                               
ai->second->mFlags, hasLongDn);
+            attrMod->next = result;
+            result = attrMod;
+        }
+    }
+
+    TRACE_LEAVE();
+    return result;
+}
+
  /**
   * Creates an object
   */
diff --git a/osaf/services/saf/immsv/immnd/ImmModel.hh 
b/osaf/services/saf/immsv/immnd/ImmModel.hh
--- a/osaf/services/saf/immsv/immnd/ImmModel.hh
+++ b/osaf/services/saf/immsv/immnd/ImmModel.hh
@@ -240,9 +240,13 @@ public:
                                          ConnVector& connVector,
                                        SaUint32T* appCtnPtr);
  
+    SaUint32T getPbeApplierConn();
+
      immsv_attr_mods_list* canonicalizeAttrModification(
              const struct ImmsvOmCcbObjectModify *req);
      
+    immsv_attr_mods_list* getAllWritableAttributes(const 
ImmsvOmCcbObjectModify *req, bool* hasLongDn);
+
      SaAisErrorT         ccbObjectModify(
                                          const ImmsvOmCcbObjectModify* req,
                                          SaUint32T* implConn,
@@ -712,9 +716,14 @@ private:
                              ObjectInfo *obj,
                              const char *noDanglingRef);
  
+    ObjectInfo* getObjectAfterImageInCcb(const std::string& objName,
+                                         SaUint32T ccbId);
+
      immsv_attr_mods_list* attrValueToAttrMod(const ObjectInfo* obj,
                                               const std::string& attrName,
-                                             SaUint32T attrType);
+                                             SaUint32T attrType,
+                                             SaImmAttrFlagsT attrFlags = 0,
+                                             bool* hasLongDn = NULL);
  
  };
  
diff --git a/osaf/services/saf/immsv/immnd/immnd_evt.c 
b/osaf/services/saf/immsv/immnd/immnd_evt.c
--- a/osaf/services/saf/immsv/immnd/immnd_evt.c
+++ b/osaf/services/saf/immsv/immnd/immnd_evt.c
@@ -6213,7 +6213,11 @@ static void immnd_evt_proc_object_modify
        SaNameT objName;
        osaf_extended_name_clear(&objName);
        bool hasLongDns=false;
+       /* These 2 attr-mods lists will only be generated on demand */
        IMMSV_ATTR_MODS_LIST* canonicalizedAttrMod = NULL;
+       IMMSV_ATTR_MODS_LIST* allWritableAttr = NULL;
+       /* Used when canonicalizing all writable attributes */
+       bool writableAttrHasLongDns = false;
  
        TRACE_ENTER();
  #if 0                         /*ABT DEBUG PRINTOUTS START */
@@ -6246,6 +6250,9 @@ static void immnd_evt_proc_object_modify
        err = immModel_ccbObjectModify(cb, &(evt->info.objModify), &implConn, 
&implNodeId,
                &continuationId, &pbeConn, pbeNodeIdPtr, &objName, &hasLongDns);
  
+       /* If 'hasLongDns' is true, allWritableAttr will also contains long DN 
*/
+       writableAttrHasLongDns = hasLongDns;
+
        if(pbeNodeIdPtr && pbeConn && err == SA_AIS_OK) {
                /*The persistent back-end is present and executing at THIS 
node. */
                osafassert(cb->mIsCoord);
@@ -6362,12 +6369,11 @@ static void immnd_evt_proc_object_modify
                SaUint32T arrSize =
                        immModel_getLocalAppliersForObj(cb, &objName,
                                evt->info.objModify.ccbId, &applConnArr, 
SA_FALSE);
+               SaUint32T pbeApplierConn = immModel_getPbeApplierConn(cb); /* 0 
if not local or not exist */
  
                if(arrSize) {
                        memset(&send_evt, '\0', sizeof(IMMSV_EVT));
                        send_evt.type = IMMSV_EVT_TYPE_IMMA;
-                       send_evt.info.imma.type = hasLongDns ? 
IMMA_EVT_ND2A_OI_OBJ_MODIFY_LONG_UC :
-                               IMMA_EVT_ND2A_OI_OBJ_MODIFY_UC;
                        send_evt.info.imma.info.objModify = evt->info.objModify;
                        send_evt.info.imma.info.objModify.adminOwnerId = 0;
                        /* Re-use the adminOwner member of the ccbModify 
message to hold the
@@ -6376,6 +6382,8 @@ static void immnd_evt_proc_object_modify
                        for (; ix < arrSize && err == SA_AIS_OK; ++ix) {
                                bool isSpecialApplier = false;
                                send_evt.info.imma.info.objModify.attrMods = 
evt->info.objModify.attrMods;
+                               send_evt.info.imma.type = hasLongDns ? 
IMMA_EVT_ND2A_OI_OBJ_MODIFY_LONG_UC :
+                                       IMMA_EVT_ND2A_OI_OBJ_MODIFY_UC;
                                implHandle = 
m_IMMSV_PACK_HANDLE(applConnArr[ix], cb->node_id);
                                send_evt.info.imma.info.objModify.immHandle = 
implHandle;
  
@@ -6405,10 +6413,18 @@ static void immnd_evt_proc_object_modify
                                                
oi_cl_node->version.minorVersion >= 0x11 &&
                                                
oi_cl_node->version.majorVersion == 0x2 &&
                                                oi_cl_node->version.releaseCode 
== 'A') {
-                                       if (!canonicalizedAttrMod) { /* Check 
if canonicalizedAttrMod is already built */
-                                               canonicalizedAttrMod = 
immModel_canonicalizeAttrModification(cb, &(evt->info.objModify));
+                                       if (applConnArr[ix] == pbeApplierConn) 
{ /* Slave pbe */
+                                               
osafassert(canonicalizedAttrMod); /* Must already be built for primary pbe */
+                                               
send_evt.info.imma.info.objModify.attrMods = canonicalizedAttrMod;
+                                       } else {
+                                               if (!allWritableAttr) { /* 
Check if allWritableAttr is already built */
+                                                       allWritableAttr = 
immModel_getAllWritableAttributes(cb, &(evt->info.objModify),
+                                                                               
                                                                                
         &writableAttrHasLongDns);
+                                               }
+                                               
send_evt.info.imma.info.objModify.attrMods = allWritableAttr;
+                                               send_evt.info.imma.type = 
writableAttrHasLongDns ?
+                                                       
IMMA_EVT_ND2A_OI_OBJ_MODIFY_LONG_UC : IMMA_EVT_ND2A_OI_OBJ_MODIFY_UC;
                                        }
-                                       
send_evt.info.imma.info.objModify.attrMods = canonicalizedAttrMod;
                                }
                                /* Slave pbe is initialized with latest OI api 
version,
                                 * it will also receive canonicalized attrMod 
like the primary pbe
@@ -6458,6 +6474,8 @@ static void immnd_evt_proc_object_modify
        /* Free the canonicalized attr mods */
        immsv_free_attrmods(canonicalizedAttrMod);
        canonicalizedAttrMod = NULL;
+       immsv_free_attrmods(allWritableAttr);
+       allWritableAttr = NULL;
        osaf_extended_name_free(&objName);
        TRACE_LEAVE();
  }
diff --git a/osaf/services/saf/immsv/immnd/immnd_init.h 
b/osaf/services/saf/immsv/immnd/immnd_init.h
--- a/osaf/services/saf/immsv/immnd/immnd_init.h
+++ b/osaf/services/saf/immsv/immnd/immnd_init.h
@@ -170,6 +170,7 @@ extern "C" {
                  SaUint32T **aplConnArr, SaBoolT externalRep);
        SaUint32T immModel_getLocalAppliersForCcb(IMMND_CB *cb, SaUint32T 
ccbId, SaUint32T **aplConnArr,
                SaUint32T* applCtnPtr);
+       SaUint32T immModel_getPbeApplierConn(IMMND_CB *cb);
  
        SaAisErrorT
            immModel_ccbObjectModify(IMMND_CB *cb,
@@ -299,6 +300,9 @@ extern "C" {
        struct immsv_attr_mods_list*
        immModel_canonicalizeAttrModification(IMMND_CB *cb, const struct 
ImmsvOmCcbObjectModify *req);
  
+       struct immsv_attr_mods_list*
+       immModel_getAllWritableAttributes(IMMND_CB *cb, const struct 
ImmsvOmCcbObjectModify *req, bool* hasLongDn);
+
        SaBoolT immModel_protocol41Allowed(IMMND_CB *cb);
        SaBoolT immModel_protocol43Allowed(IMMND_CB *cb);
        SaBoolT immModel_protocol45Allowed(IMMND_CB *cb);



------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to