[PATCH 5/6] [mama] Add publisher stats


Ian Bell <IBell@...>
 

From 0a3b8617f562f6982f88ab6edc585e6096a4f61c Mon Sep 17 00:00:00 2001

Message-Id: <0a3b8617f562f6982f88ab6edc585e6096a4f61c.1348674366.git.ibell@...>

In-Reply-To: <ec11f834aa5ee941affd12c0baa32480c39efabd.1348674366.git.ibell@...>

References: <ec11f834aa5ee941affd12c0baa32480c39efabd.1348674366.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 16:37:09 +0100

Subject: [PATCH 5/6] [mama] Add publisher stats

 

Added publisher side stats to the global and trasnport stats collectors.

 

Signed-off-by: Ian Bell <ibell@...>

---

mama/c_cpp/src/c/mama.c            |   40 ++++++++++++++

mama/c_cpp/src/c/mama/stat.h       |    4 ++

mama/c_cpp/src/c/mama/statfields.h |    6 ++

mama/c_cpp/src/c/publisher.c       |  106 ++++++++++++++++++++++++++++++++++--

mama/c_cpp/src/c/stat.c            |   18 ++++++

mama/c_cpp/src/c/statfields.c      |    6 ++

mama/c_cpp/src/c/transport.c       |   42 ++++++++++++++

7 files changed, 217 insertions(+), 5 deletions(-)

 

diff --git a/mama/c_cpp/src/c/mama.c b/mama/c_cpp/src/c/mama.c

index f511994..c3799fd 100644

--- a/mama/c_cpp/src/c/mama.c

+++ b/mama/c_cpp/src/c/mama.c

@@ -131,6 +131,9 @@ mamaStat                gTimeoutStat;

mamaStat                gWombatMsgsStat;

mamaStat                gFastMsgsStat;

mamaStat                gRvMsgsStat;

+mamaStat                gPublisherSend;

+mamaStat                gPublisherInboxSend;

+mamaStat                gPublisherReplySend;

 mama_status mama_statsInit (void);

mama_status mama_setupStatsGenerator (void);

@@ -528,6 +531,26 @@ mamaInternal_enableStatsLogging (void)

                                   MamaStatRvMsgs.mFid);

         if (result != MAMA_STATUS_OK) return result;

+        result = mamaStat_create (&gPublisherSend,

+                                  gGlobalStatsCollector,

+                                  MAMA_STAT_LOCKABLE,

+                                  MamaStatPublisherSend.mName,

+                                  MamaStatPublisherSend.mFid);

+        if (result != MAMA_STATUS_OK) return result;

+

+        result = mamaStat_create (&gPublisherInboxSend,

+                                  gGlobalStatsCollector,

+                                  MAMA_STAT_LOCKABLE,

+                                  MamaStatPublisherInboxSend.mName,

+                                  MamaStatPublisherInboxSend.mFid);

+        if (result != MAMA_STATUS_OK) return result;

+

+        result = mamaStat_create (&gPublisherReplySend,

+                                  gGlobalStatsCollector,

+                                  MAMA_STAT_LOCKABLE,

+                                  MamaStatPublisherReplySend.mName,

+                                  MamaStatPublisherReplySend.mFid);

+        if (result != MAMA_STATUS_OK) return result;

         mamaStatsGenerator_addStatsCollector (gStatsGenerator, gGlobalStatsCollector);

     }

@@ -1160,6 +1183,23 @@ mama_closeCount (unsigned int* count)

             gRvMsgsStat = NULL;

         }

+        if (gPublisherSend)

+        {

+            mamaStat_destroy (gPublisherSend);

+            gPublisherSend = NULL;

+        }

+

+        if (gPublisherInboxSend)

+        {

+            mamaStat_destroy (gPublisherInboxSend);

+            gPublisherInboxSend = NULL;

+        }

+

+        if (gPublisherReplySend)

+        {

+            mamaStat_destroy (gPublisherReplySend);

+            gPublisherReplySend = NULL;

+        }

         if (gGlobalStatsCollector)

         {

             if (gStatsGenerator)

diff --git a/mama/c_cpp/src/c/mama/stat.h b/mama/c_cpp/src/c/mama/stat.h

index 55b171c..5b94bb5 100644

--- a/mama/c_cpp/src/c/mama/stat.h

+++ b/mama/c_cpp/src/c/mama/stat.h

@@ -56,6 +56,10 @@ typedef enum mamaStatType

     MAMA_STAT_TYPE_WOMBAT_MSGS                   =  125,

     MAMA_STAT_TYPE_RV_MSGS                       =  126,

     MAMA_STAT_TYPE_FAST_MSGS                     =  127,

+    MAMA_STAT_TYPE_UNKNOWN_MSGS                  =  128,

+    MAMA_STAT_TYPE_PUBLISHER_SEND                =  129,

+    MAMA_STAT_TYPE_PUBLISHER_INBOX_SEND          =  130,

+    MAMA_STAT_TYPE_PUBLISHER_REPLY_SEND          =  131,

     MAMA_STAT_TYPE_UNKNOWN                       =  999

}mamaStatType;

diff --git a/mama/c_cpp/src/c/mama/statfields.h b/mama/c_cpp/src/c/mama/statfields.h

index c558d9e..d6e4bb3 100644

--- a/mama/c_cpp/src/c/mama/statfields.h

+++ b/mama/c_cpp/src/c/mama/statfields.h

@@ -84,6 +84,12 @@ MAMAExpDLL

extern const MamaReservedField  MamaStatFastMsgs;                       /* FID 127 */

MAMAExpDLL

extern const MamaReservedField  MamaStatUnknownMsgs;                    /* FID 128 */

+MAMAExpDLL

+extern const MamaReservedField  MamaStatPublisherSend;                  /* FID 129 */

+MAMAExpDLL

+extern const MamaReservedField  MamaStatPublisherInboxSend;             /* FID 130 */

+MAMAExpDLL

+extern const MamaReservedField  MamaStatPublisherReplySend;             /* FID 131 */

 #if defined(__cplusplus)

}

diff --git a/mama/c_cpp/src/c/publisher.c b/mama/c_cpp/src/c/publisher.c

index 222a94d..4612d17 100644

--- a/mama/c_cpp/src/c/publisher.c

+++ b/mama/c_cpp/src/c/publisher.c

@@ -28,9 +28,15 @@

 #include "msgimpl.h"

#include "publisherimpl.h"

+#include "mama/statscollector.h"

+#include "mama/statfields.h"

 #include "list.h"

+/* For Stats */

+extern int gGenerateTransportStats;

+extern int gGenerateGlobalStats;

+

/*Main mamaPublisher structure for the API*/

typedef struct mamaPublisherImpl_

{

@@ -232,14 +238,32 @@ mamaPublisher_send (mamaPublisher publisher,

                     mamaMsg       msg)

{

     mamaPublisherImpl* impl     = (mamaPublisherImpl*)publisher;

+    mama_status        status;

+    mamaStatsCollector tportStatsCollector = NULL;

     if (!impl) return MAMA_STATUS_NULL_ARG;

     if (!impl->mMamaPublisherBridgeImpl) return MAMA_STATUS_INVALID_ARG;

     if (!impl->mBridgeImpl) return MAMA_STATUS_NO_BRIDGE_IMPL;

-    return impl->mBridgeImpl->bridgeMamaPublisherSend

+    status = impl->mBridgeImpl->bridgeMamaPublisherSend

         (impl->mMamaPublisherBridgeImpl,

          msg);

+    if (status == MAMA_STATUS_OK)

+    {

+        if (gGenerateTransportStats)

+        {

+            tportStatsCollector = mamaTransport_getStatsCollector (impl->mTport);

+        }

+        if (tportStatsCollector)

+            mamaStatsCollector_incrementStat (tportStatsCollector, MamaStatPublisherSend.mFid);

+

+        if (mamaInternal_getGlobalStatsCollector() != NULL)

+            mamaStatsCollector_incrementStat (mamaInternal_getGlobalStatsCollector(),

+                    MamaStatPublisherSend.mFid);

+

+    }

+

+    return status;

}

 mama_status

@@ -248,15 +272,33 @@ mamaPublisher_sendFromInbox (mamaPublisher  publisher,

                              mamaMsg        msg)

{

     mamaPublisherImpl* impl     = (mamaPublisherImpl*)publisher;

+    mama_status        status;

+    mamaStatsCollector tportStatsCollector = NULL;

     if (!impl) return MAMA_STATUS_NULL_ARG;

     if (!impl->mMamaPublisherBridgeImpl) return MAMA_STATUS_INVALID_ARG;

     if (!impl->mBridgeImpl) return MAMA_STATUS_NO_BRIDGE_IMPL;

-    return impl->mBridgeImpl->bridgeMamaPublisherSendFromInbox

+    status = impl->mBridgeImpl->bridgeMamaPublisherSendFromInbox

         (impl->mMamaPublisherBridgeImpl,

          inbox,

          msg);

+    if (status == MAMA_STATUS_OK)

+    {

+        if (gGenerateTransportStats)

+        {

+            tportStatsCollector = mamaTransport_getStatsCollector (impl->mTport);

+        }

+        if (tportStatsCollector)

+            mamaStatsCollector_incrementStat (tportStatsCollector, MamaStatPublisherInboxSend.mFid);

+

+        if (mamaInternal_getGlobalStatsCollector() != NULL)

+            mamaStatsCollector_incrementStat (mamaInternal_getGlobalStatsCollector(),

+                    MamaStatPublisherInboxSend.mFid);

+

+    }

+

+    return status;

}

 mama_status

@@ -266,16 +308,34 @@ mamaPublisher_sendFromInboxByIndex (mamaPublisher  publisher,

                                     mamaMsg        msg)

{

     mamaPublisherImpl* impl     = (mamaPublisherImpl*)publisher;

+    mama_status        status;

+    mamaStatsCollector tportStatsCollector = NULL;

     if (!impl) return MAMA_STATUS_NULL_ARG;

     if (!impl->mMamaPublisherBridgeImpl) return MAMA_STATUS_INVALID_ARG;

     if (!impl->mBridgeImpl) return MAMA_STATUS_NO_BRIDGE_IMPL;

-    return impl->mBridgeImpl->bridgeMamaPublisherSendFromInboxByIndex

+    status = impl->mBridgeImpl->bridgeMamaPublisherSendFromInboxByIndex

         (impl->mMamaPublisherBridgeImpl,

          tportIndex,

          inbox,

          msg);

+    if (status == MAMA_STATUS_OK)

+    {

+        if (gGenerateTransportStats)

+        {

+            tportStatsCollector = mamaTransport_getStatsCollector (impl->mTport);

+        }

+        if (tportStatsCollector)

+            mamaStatsCollector_incrementStat (tportStatsCollector, MamaStatPublisherInboxSend.mFid);

+

+        if (mamaInternal_getGlobalStatsCollector() != NULL)

+            mamaStatsCollector_incrementStat (mamaInternal_getGlobalStatsCollector(),

+                    MamaStatPublisherInboxSend.mFid);

+

+    }

+

+    return status;

}

 mama_status

@@ -285,6 +345,8 @@ mamaPublisher_sendReplyToInboxHandle (mamaPublisher publisher,

{

     mamaPublisherImpl*  impl        = (mamaPublisherImpl*)publisher;

     mamaMsgReplyImpl*   replyStruct = ( mamaMsgReplyImpl *)replyAddress;

+    mama_status         status;

+    mamaStatsCollector tportStatsCollector = NULL;

 

     if (!impl) return MAMA_STATUS_NULL_ARG;

@@ -306,10 +368,26 @@ mamaPublisher_sendReplyToInboxHandle (mamaPublisher publisher,

     }

 

-    return impl->mBridgeImpl->bridgeMamaPublisherSendReplyToInboxHandle

+    status = impl->mBridgeImpl->bridgeMamaPublisherSendReplyToInboxHandle

         (impl->mMamaPublisherBridgeImpl,

          replyStruct->replyHandle,

          reply);

+    if (status == MAMA_STATUS_OK)

+    {

+        if (gGenerateTransportStats)

+        {

+            tportStatsCollector = mamaTransport_getStatsCollector (impl->mTport);

+        }

+        if (tportStatsCollector)

+            mamaStatsCollector_incrementStat (tportStatsCollector, MamaStatPublisherReplySend.mFid);

+

+        if (mamaInternal_getGlobalStatsCollector() != NULL)

+            mamaStatsCollector_incrementStat (mamaInternal_getGlobalStatsCollector(),

+                    MamaStatPublisherReplySend.mFid);

+

+    }

+

+    return status;

}

 mama_status

@@ -318,6 +396,8 @@ mamaPublisher_sendReplyToInbox (mamaPublisher publisher,

                                 mamaMsg       reply)

{

     mamaPublisherImpl* impl     = (mamaPublisherImpl*)publisher;

+    mama_status         status;

+    mamaStatsCollector tportStatsCollector = NULL;

     if (!impl) return MAMA_STATUS_NULL_ARG;

     if (!impl->mMamaPublisherBridgeImpl) return MAMA_STATUS_INVALID_ARG;

@@ -342,10 +422,26 @@ mamaPublisher_sendReplyToInbox (mamaPublisher publisher,

                   "Request message not from an inbox.");

         return MAMA_STATUS_INVALID_ARG;

     }

-    return impl->mBridgeImpl->bridgeMamaPublisherSendReplyToInbox

+    status = impl->mBridgeImpl->bridgeMamaPublisherSendReplyToInbox

         (impl->mMamaPublisherBridgeImpl,

          request,

          reply);

+    if (status == MAMA_STATUS_OK)

+    {

+        if (gGenerateTransportStats)

+        {

+            tportStatsCollector = mamaTransport_getStatsCollector (impl->mTport);

+        }

+        if (tportStatsCollector)

+            mamaStatsCollector_incrementStat (tportStatsCollector, MamaStatPublisherReplySend.mFid);

+

+        if (mamaInternal_getGlobalStatsCollector() != NULL)

+            mamaStatsCollector_incrementStat (mamaInternal_getGlobalStatsCollector(),

+                    MamaStatPublisherReplySend.mFid);

+

+    }

+

+    return status;

}

 /*Action function used with sendWithThrottle*/

diff --git a/mama/c_cpp/src/c/stat.c b/mama/c_cpp/src/c/stat.c

index a4297a2..245917f 100644

--- a/mama/c_cpp/src/c/stat.c

+++ b/mama/c_cpp/src/c/stat.c

@@ -467,6 +467,18 @@ mamaStatType_fromString (const char* statTypeString)

     {

         return MAMA_STAT_TYPE_FAST_MSGS;

     }

+    if ((strcmp (statTypeString, "Publisher Send Msgs")) == 0)

+    {

+        return MAMA_STAT_TYPE_PUBLISHER_SEND;

+    }

+    if ((strcmp (statTypeString, "Publisher Inbox Send Msgs")) == 0)

+    {

+        return MAMA_STAT_TYPE_PUBLISHER_INBOX_SEND;

+    }

+    if ((strcmp (statTypeString, "Publisher Reply Send Msgs")) == 0)

+    {

+        return MAMA_STAT_TYPE_PUBLISHER_REPLY_SEND;

+    }

     return MAMA_STAT_TYPE_UNKNOWN;

}

@@ -523,6 +535,12 @@ mamaStatType_toString (mamaStatType statType)

                                                            break;

         case MAMA_STAT_TYPE_FAST_MSGS                    : return "FAST Messages";

                                                            break;

+        case MAMA_STAT_TYPE_PUBLISHER_SEND               : return "Publisher Send Msgs";

+                                                           break;

+        case MAMA_STAT_TYPE_PUBLISHER_INBOX_SEND         : return "Publisher Inbox Send Msgs";

+                                                           break;

+        case MAMA_STAT_TYPE_PUBLISHER_REPLY_SEND         : return "Publisher Reply Send Msgs";

+                                                           break;

         default                                          : return "Unknown";

                                                            break;

     }

diff --git a/mama/c_cpp/src/c/statfields.c b/mama/c_cpp/src/c/statfields.c

index 2150081..a33954d 100644

--- a/mama/c_cpp/src/c/statfields.c

+++ b/mama/c_cpp/src/c/statfields.c

@@ -78,3 +78,9 @@ const MamaReservedField  MamaStatFastMsgs

     = {"FAST Msgs", 127};

const MamaReservedField  MamaStatUnknownMsgs

     = {"Unknown Msgs", 128};

+const MamaReservedField  MamaStatPublisherSend

+    = {"Publisher Send Msgs", 129};

+const MamaReservedField  MamaStatPublisherInboxSend

+    = {"Publisher Inbox Send Msgs", 130};

+const MamaReservedField  MamaStatPublisherReplySend

+    = {"Publisher Reply Send Msgs", 131};

diff --git a/mama/c_cpp/src/c/transport.c b/mama/c_cpp/src/c/transport.c

index 3639956..b2472fc 100644

--- a/mama/c_cpp/src/c/transport.c

+++ b/mama/c_cpp/src/c/transport.c

@@ -160,6 +160,10 @@ typedef struct transportImpl_

     mamaStat                mLbmMsgsReceivedNoTopic;

     /*! Number of LBM requests received by LBT-RM transport */

     mamaStat                mLbmRequestsReceived;

+    /* Publisher Stats */

+    mamaStat                mPublisherSend;

+    mamaStat                mPublisherInboxSend;

+    mamaStat                mPublisherReplySend;

     int                     mGroupSizeHint;

@@ -1000,6 +1004,26 @@ mamaTransport_initStats (mamaTransport transport)

                                   MamaStatRvMsgs.mName,

                                   MamaStatRvMsgs.mFid);

         if (status != MAMA_STATUS_OK) return status;

+        status = mamaStat_create (&self->mPublisherSend,

+                                  self->mStatsCollector,

+                                  MAMA_STAT_NOT_LOCKABLE,

+                                  MamaStatPublisherSend.mName,

+                                  MamaStatPublisherSend.mFid);

+        if (status != MAMA_STATUS_OK) return status;

+

+        status = mamaStat_create (&self->mPublisherInboxSend,

+                                  self->mStatsCollector,

+                                  MAMA_STAT_NOT_LOCKABLE,

+                                  MamaStatPublisherInboxSend.mName,

+                                  MamaStatPublisherInboxSend.mFid);

+        if (status != MAMA_STATUS_OK) return status;

+

+        status = mamaStat_create (&self->mPublisherReplySend,

+                                  self->mStatsCollector,

+                                  MAMA_STAT_NOT_LOCKABLE,

+                                  MamaStatPublisherReplySend.mName,

+                                  MamaStatPublisherReplySend.mFid);

+        if (status != MAMA_STATUS_OK) return status;

     }

     if (gGenerateLbmStats)

@@ -1245,6 +1269,24 @@ mamaTransport_destroy (mamaTransport transport)

         self->mRvMsgsStat = NULL;

     }

+    if (self->mPublisherSend)

+    {

+        mamaStat_destroy (self->mPublisherSend);

+        self->mPublisherSend = NULL;

+    }

+

+    if (self->mPublisherInboxSend)

+    {

+        mamaStat_destroy (self->mPublisherInboxSend);

+        self->mPublisherInboxSend = NULL;

+    }

+

+    if (self->mPublisherReplySend)

+    {

+        mamaStat_destroy (self->mPublisherReplySend);

+        self->mPublisherReplySend = NULL;

+    }

+

     if (self->mNakPacketsSent)

     {

         mamaStat_destroy (self->mNakPacketsSent);

--

1.7.9.5

 




Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Join Openmama-dev@lists.openmama.org to automatically receive all group messages.