Patch adds the alarm and security alarm notifications to cold
sync towards the standby NTFD, increase mbcsv version to avoid
confusion with old NTFD
---
 src/ntf/ntfd/NtfAdmin.cc        | 33 +++++++++++++++++++++++++++++-
 src/ntf/ntfd/NtfAdmin.h         |  3 +++
 src/ntf/ntfd/NtfLogger.cc       | 16 +++++++++++++++
 src/ntf/ntfd/NtfLogger.h        |  1 +
 src/ntf/ntfd/NtfNotification.cc | 15 ++++++++++++++
 src/ntf/ntfd/NtfNotification.h  |  1 +
 src/ntf/ntfd/ntfs_com.c         | 11 ++++++++++
 src/ntf/ntfd/ntfs_com.h         |  5 +++++
 src/ntf/ntfd/ntfs_mbcsv.c       | 45 ++++++++++++++++++++++++++++++++++++++++-
 src/ntf/ntfd/ntfs_mbcsv.h       |  3 ++-
 10 files changed, 130 insertions(+), 3 deletions(-)

diff --git a/src/ntf/ntfd/NtfAdmin.cc b/src/ntf/ntfd/NtfAdmin.cc
index cfba836..7e1663f 100644
--- a/src/ntf/ntfd/NtfAdmin.cc
+++ b/src/ntf/ntfd/NtfAdmin.cc
@@ -340,6 +340,30 @@ void NtfAdmin::notificationReceivedColdSync(
   }
   TRACE_LEAVE();
 }
+/**
+ * A cached notification is received in Cold Sync
+ *
+ * @param clientId Node-wide unique id for the client who sent the 
notifiaction.
+ * @param notificationType
+ *                 Type of the notification (alarm, object change etc.).
+ * @param sendNotInfo
+ *                 Pointer to the struct that holds information about the
+ *                 notification.
+ */
+void NtfAdmin::cachedNotificationReceivedColdSync(
+    unsigned int clientId, SaNtfNotificationTypeT notificationType,
+    ntfsv_send_not_req_t *sendNotInfo) {
+  TRACE_ENTER();
+  SaNtfNotificationHeaderT *header;
+  ntfsv_get_ntf_header(sendNotInfo, &header);
+  SaNtfIdentifierT notificationId = *header->notificationId;
+  TRACE_2("cached notification %u received", (unsigned int)notificationId);
+  NtfSmartPtr notification(new NtfNotification(notificationId,
+      notificationType, sendNotInfo));
+  notification->notificationLoggedConfirmed();
+  logger.log(notification, false);
+  TRACE_LEAVE();
+}
 
 /**
  * The notification object is notified that a notification has
@@ -632,6 +656,7 @@ void NtfAdmin::syncRequest(NCS_UBAID *uba) {
     NtfSmartPtr notification = posNot->second;
     notification->syncRequest(uba);
   }
+  logger.syncRequest(uba);
   TRACE_LEAVE();
 }
 
@@ -1020,7 +1045,13 @@ void notificationReceivedColdSync(unsigned int clientId,
   NtfAdmin::theNtfAdmin->notificationReceivedColdSync(
       clientId, notificationType, sendNotInfo);
 }
-
+void cachedNotificationReceivedColdSync(unsigned int clientId,
+                                  SaNtfNotificationTypeT notificationType,
+                                  ntfsv_send_not_req_t *sendNotInfo) {
+  osafassert(NtfAdmin::theNtfAdmin != NULL);
+  NtfAdmin::theNtfAdmin->cachedNotificationReceivedColdSync(
+      clientId, notificationType, sendNotInfo);
+}
 void notificationSentConfirmed(unsigned int clientId,
                                SaNtfSubscriptionIdT subscriptionId,
                                SaNtfIdentifierT notificationId, int discarded) 
{
diff --git a/src/ntf/ntfd/NtfAdmin.h b/src/ntf/ntfd/NtfAdmin.h
index d77e7f7..c3a2da1 100644
--- a/src/ntf/ntfd/NtfAdmin.h
+++ b/src/ntf/ntfd/NtfAdmin.h
@@ -55,6 +55,9 @@ class NtfAdmin {
   void notificationReceivedColdSync(unsigned int clientId,
                                     SaNtfNotificationTypeT notificationType,
                                     ntfsv_send_not_req_t *sendNotInfo);
+  void cachedNotificationReceivedColdSync(unsigned int clientId,
+                                    SaNtfNotificationTypeT notificationType,
+                                    ntfsv_send_not_req_t *sendNotInfo);
   void notificationSentConfirmed(unsigned int clientId,
                                  SaNtfSubscriptionIdT subscriptionId,
                                  SaNtfIdentifierT notificationId,
diff --git a/src/ntf/ntfd/NtfLogger.cc b/src/ntf/ntfd/NtfLogger.cc
index 6e80097..b88f4da 100644
--- a/src/ntf/ntfd/NtfLogger.cc
+++ b/src/ntf/ntfd/NtfLogger.cc
@@ -335,6 +335,22 @@ void logEvent() {
   return;
 }
 
+void NtfLogger::syncRequest(NCS_UBAID *uba) {
+
+  TRACE_ENTER();
+
+  TRACE_2("logger.coll_.size=%u",
+          (unsigned int)coll_.size());
+
+  sendNoOfNotifications(coll_.size(), uba);
+  readerNotificationListT::iterator rpos;
+  for (rpos = coll_.begin(); rpos != coll_.end(); rpos++) {
+    NtfSmartPtr n(*rpos);
+    n->syncRequestAsCached(uba);
+  }
+  TRACE_LEAVE();
+}
+
 void NtfLogger::printInfo() {
   TRACE("Logger Information:");
   TRACE(" logQueueList size:  %u", (unsigned 
int)queuedNotificationList.size());
diff --git a/src/ntf/ntfd/NtfLogger.h b/src/ntf/ntfd/NtfLogger.h
index 424d0f7..cc0ac7d 100644
--- a/src/ntf/ntfd/NtfLogger.h
+++ b/src/ntf/ntfd/NtfLogger.h
@@ -60,6 +60,7 @@ class NtfLogger {
   SaAisErrorT logNotification(NtfSmartPtr& notif);
   void queueNotifcation(NtfSmartPtr& notif);
   void printInfo();
+  void syncRequest(NCS_UBAID *uba);
 
  private:
   SaAisErrorT initLog();
diff --git a/src/ntf/ntfd/NtfNotification.cc b/src/ntf/ntfd/NtfNotification.cc
index 894811a..1060606 100644
--- a/src/ntf/ntfd/NtfNotification.cc
+++ b/src/ntf/ntfd/NtfNotification.cc
@@ -294,6 +294,21 @@ void NtfNotification::syncRequest(NCS_UBAID* uba) {
   }
   syncLoggedConfirm((unsigned int)loggedOk(), uba);
 }
+/**
+ * This method is called to sync a cached notification
+ *
+ */
+void NtfNotification::syncRequestAsCached(NCS_UBAID* uba) {
+  TRACE_1(
+      "NtfNotification::syncRequestAsCached received"
+      " in notification %llu",
+      notificationId_);
+  int retval = sendCachedNotification(0, sendNotInfo_, uba);
+  if (retval != 1) {
+    LOG_ER("sendCachedNotification was not sent, error code is %d",
+        retval);
+  }
+}
 
 void NtfNotification::printInfo() {
   TRACE("Notification information");
diff --git a/src/ntf/ntfd/NtfNotification.h b/src/ntf/ntfd/NtfNotification.h
index 5816db3..f937f8f 100644
--- a/src/ntf/ntfd/NtfNotification.h
+++ b/src/ntf/ntfd/NtfNotification.h
@@ -58,6 +58,7 @@ class NtfNotification {
                           SaNtfSubscriptionIdT subscriptionId);
   ntfsv_send_not_req_t* getNotInfo();
   void syncRequest(NCS_UBAID* uba);
+  void syncRequestAsCached(NCS_UBAID* uba);
   void resetSubscriptionIdList();
   SaAisErrorT getNextSubscription(UniqueSubscriptionId& subId);
   void printInfo();
diff --git a/src/ntf/ntfd/ntfs_com.c b/src/ntf/ntfd/ntfs_com.c
index 5881296..dabd8d4 100644
--- a/src/ntf/ntfd/ntfs_com.c
+++ b/src/ntf/ntfd/ntfs_com.c
@@ -410,6 +410,17 @@ int sendNewNotification(unsigned int connId,
        return ntfsv_enc_not_msg(uba, notificationInfo);
 };
 
+int sendCachedNotification(unsigned int connId,
+      ntfsv_send_not_req_t *notificationInfo, NCS_UBAID *uba)
+{
+  if (ntfs_cb->peer_mbcsv_version > NTFS_MBCSV_VERSION_2) {
+    return ntfsv_enc_not_msg(uba, notificationInfo);
+  }
+
+  return NCSCC_RC_SUCCESS;
+
+};
+
 int sendNoOfClients(uint32_t num_rec, NCS_UBAID *uba)
 {
        TRACE_2("num_rec: %u", num_rec);
diff --git a/src/ntf/ntfd/ntfs_com.h b/src/ntf/ntfd/ntfs_com.h
index 52546f6..4e8155e 100644
--- a/src/ntf/ntfd/ntfs_com.h
+++ b/src/ntf/ntfd/ntfs_com.h
@@ -68,6 +68,9 @@ void notificationReceivedUpdate(unsigned int clientId,
 void notificationReceivedColdSync(unsigned int clientId,
                                   SaNtfNotificationTypeT notificationType,
                                   ntfsv_send_not_req_t *sendNotInfo);
+void cachedNotificationReceivedColdSync(unsigned int clientId,
+                                  SaNtfNotificationTypeT notificationType,
+                                  ntfsv_send_not_req_t *sendNotInfo);
 void notificationSentConfirmed(unsigned int clientId,
                                SaNtfSubscriptionIdT subscriptionId,
                                SaNtfIdentifierT notificationId, int discarded);
@@ -150,6 +153,8 @@ uint32_t send_clm_node_status_lib(SaClmClusterChangesT 
cluster_change,
 int sendSyncGlobals(const struct NtfGlobals *ntfGlobals, NCS_UBAID *uba);
 int sendNewNotification(unsigned int connId,
                         ntfsv_send_not_req_t *notificationInfo, NCS_UBAID 
*uba);
+int sendCachedNotification(unsigned int connId,
+                        ntfsv_send_not_req_t *notificationInfo, NCS_UBAID 
*uba);
 int sendNewClient(unsigned int clientId, MDS_DEST mdsDest, SaVersionT *ver,
                   NCS_UBAID *uba);
 int sendNewSubscription(ntfsv_subscribe_req_t *s, NCS_UBAID *uba);
diff --git a/src/ntf/ntfd/ntfs_mbcsv.c b/src/ntf/ntfd/ntfs_mbcsv.c
index 3a73ec1..4afd5e6 100644
--- a/src/ntf/ntfd/ntfs_mbcsv.c
+++ b/src/ntf/ntfd/ntfs_mbcsv.c
@@ -1109,7 +1109,50 @@ static uint32_t ckpt_decode_cold_sync(ntfs_cb_t *cb, 
NCS_MBCSV_CB_ARG *cbk_arg)
                }
                num_rec--;
        }
-
+  if (ntfs_cb->peer_mbcsv_version > NTFS_MBCSV_VERSION_2) {
+
+    /* Decode the current message header */
+    if ((rc = dec_ckpt_header(&cbk_arg->info.decode.i_uba,
+            &data->header)) != NCSCC_RC_SUCCESS) {
+      goto done;
+    }
+
+    TRACE_2("ckpt_rec_type: %u", data->header.ckpt_rec_type);
+
+    /* Check if the second in the order of records is notification record */
+    if (data->header.ckpt_rec_type != NTFS_CKPT_NOTIFICATION) {
+      TRACE(
+          "FAILED data->header.ckpt_rec_type != NTFS_CKPT_NOTIFICATION");
+      rc = NCSCC_RC_FAILURE;
+      goto done;
+    }
+
+    num_rec = data->header.num_ckpt_records;
+    TRACE_2("Cached Notifications num_rec: %u", num_rec);
+    while (num_rec) {
+      /* freed in NtfNotification destructor */
+      ntfsv_send_not_req_t *notification_rec =
+          calloc(1, sizeof(ntfsv_send_not_req_t));
+
+      if (notification_rec == NULL) {
+        TRACE("calloc FAILED");
+        rc = NCSCC_RC_FAILURE;
+        goto done;
+      }
+
+      rc = ntfsv_dec_not_msg(&cbk_arg->info.decode.i_uba,
+                 notification_rec);
+      if (rc != NCSCC_RC_SUCCESS) {
+        TRACE("decode_subscribe_msg FAILED");
+        goto done;
+      }
+      cachedNotificationReceivedColdSync(notification_rec->client_id,
+                 notification_rec->notificationType,
+                 notification_rec);
+
+      num_rec--;
+    }
+  }
        /* Get the async update count */
        ptr = ncs_dec_flatten_space(&cbk_arg->info.decode.i_uba, data_cnt,
                                    sizeof(uint32_t));
diff --git a/src/ntf/ntfd/ntfs_mbcsv.h b/src/ntf/ntfd/ntfs_mbcsv.h
index 5507f6f..b6bb0e0 100644
--- a/src/ntf/ntfd/ntfs_mbcsv.h
+++ b/src/ntf/ntfd/ntfs_mbcsv.h
@@ -20,8 +20,9 @@
 
 #include <saAmf.h>
 
-#define NTFS_MBCSV_VERSION 2
+#define NTFS_MBCSV_VERSION 3
 #define NTFS_MBCSV_VERSION_1 1
+#define NTFS_MBCSV_VERSION_2 2
 #define NTFS_MBCSV_VERSION_MIN 1
 
 /* Checkpoint message types(Used as 'reotype' w.r.t mbcsv)  */
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to