[PATCH 1/6] [mama] Tidy stats code


Ian Bell <IBell@...>
 

From ec11f834aa5ee941affd12c0baa32480c39efabd Mon Sep 17 00:00:00 2001

Message-Id: <ec11f834aa5ee941affd12c0baa32480c39efabd.1348674366.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 14:27:18 +0100

Subject: [PATCH 1/6] [mama] Tidy stats code

 

Modified the stats code to correct the pointer indirection in

preparation for add user stats functionality

 

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

---

mama/c_cpp/src/c/dqstrategy.c             |    6 ++---

mama/c_cpp/src/c/imagerequest.c           |   10 ++++-----

mama/c_cpp/src/c/listenermsgcallback.c    |   34 ++++++++++++++---------------

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

mama/c_cpp/src/c/mama/stat.h              |    2 +-

mama/c_cpp/src/c/mama/transport.h         |    2 +-

mama/c_cpp/src/c/mamainternal.h           |    2 +-

mama/c_cpp/src/c/queue.c                  |   15 ++++++-------

mama/c_cpp/src/c/queueimpl.h              |    2 +-

mama/c_cpp/src/c/stat.c                   |    6 ++---

mama/c_cpp/src/c/statscollector.c         |   25 +++++----------------

mama/c_cpp/src/c/statscollectorinternal.h |   20 ++++++++++++++++-

mama/c_cpp/src/c/statsgenerator.c         |   29 ++++++++++++------------

mama/c_cpp/src/c/statsgeneratorinternal.h |    4 ++--

mama/c_cpp/src/c/subscription.c           |   10 ++++-----

mama/c_cpp/src/c/transport.c              |   17 ++++++---------

16 files changed, 100 insertions(+), 102 deletions(-)

 

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

index 011436d..bd31c78 100644

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

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

@@ -183,7 +183,7 @@ dqStrategy_checkSeqNum (dqStrategy      strategy,

     mama_u16_t       conflateCnt    = 1;

     wombat_subscriptionGapCB onGap  = NULL;

     mamaTransport    transport;

-    mamaStatsCollector* transportStatsCollector = NULL;

+    mamaStatsCollector transportStatsCollector = NULL;

     wombat_subscriptionQualityCB onQuality = NULL;

     mamaMsgStatus    msgStatus      = MAMA_MSG_STATUS_UNKNOWN;

     mamaTransport    tport        = NULL;

@@ -209,12 +209,12 @@ dqStrategy_checkSeqNum (dqStrategy      strategy,

             mamaSubscription_getTransport (subscription, &transport);

             transportStatsCollector = mamaTransport_getStatsCollector (transport);

-            mamaStatsCollector_incrementStat (*transportStatsCollector,

+            mamaStatsCollector_incrementStat (transportStatsCollector,

                                               MamaStatFtTakeovers.mFid);

         }

         if (mamaInternal_getGlobalStatsCollector() != NULL)

         {

-            mamaStatsCollector_incrementStat (*(mamaInternal_getGlobalStatsCollector()),

+            mamaStatsCollector_incrementStat (mamaInternal_getGlobalStatsCollector(),

                                               MamaStatFtTakeovers.mFid);

         }

         if (DQ_FT_WAIT_FOR_RECAP==mamaTransportImpl_getFtStrategyScheme(tport))

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

index b46c85f..25db94f 100644

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

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

@@ -544,8 +544,8 @@ static void MAMACALLTYPE imageRequestImpl_processTimeout (imageReqImpl *impl)

         int                 isRecap      = impl->mIsRecapRequest;

         mamaQueue           queue;

         mamaTransport       transport;

-        mamaStatsCollector* queueStatsCollector = NULL;

-        mamaStatsCollector* transportStatsCollector = NULL;

+        mamaStatsCollector queueStatsCollector = NULL;

+        mamaStatsCollector transportStatsCollector = NULL;

         /* We do not want to process any more messages if initial does not

          * arrive. For recaps we continue to process messages.

@@ -565,7 +565,7 @@ static void MAMACALLTYPE imageRequestImpl_processTimeout (imageReqImpl *impl)

             mamaSubscription_getQueue (subscription, &queue);

             queueStatsCollector = mamaQueueImpl_getStatsCollector (queue);

-            mamaStatsCollector_incrementStat (*queueStatsCollector,

+            mamaStatsCollector_incrementStat (queueStatsCollector,

                     MamaStatTimeouts.mFid);

         }

         if (gGenerateTransportStats)

@@ -573,13 +573,13 @@ static void MAMACALLTYPE imageRequestImpl_processTimeout (imageReqImpl *impl)

             mamaSubscription_getTransport (subscription, &transport);

             transportStatsCollector = mamaTransport_getStatsCollector (transport);

-            mamaStatsCollector_incrementStat (*transportStatsCollector,

+            mamaStatsCollector_incrementStat (transportStatsCollector,

                     MamaStatTimeouts.mFid);

         }

         if (mamaInternal_getGlobalStatsCollector () != NULL)

         {

             mamaStatsCollector_incrementStat

-                (*(mamaInternal_getGlobalStatsCollector ()),

+                (mamaInternal_getGlobalStatsCollector (),

                  MamaStatTimeouts.mFid);

         }

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

index fedcc49..81ff1fa 100644

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

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

@@ -253,8 +253,8 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

     int               expectingInitial  = 0;

     mamaQueue           queue;

     mamaTransport       transport;

-    mamaStatsCollector* queueStatsCollector = NULL;

-    mamaStatsCollector* tportStatsCollector = NULL;

+    mamaStatsCollector queueStatsCollector = NULL;

+    mamaStatsCollector tportStatsCollector = NULL;

     const char* userSymbol = NULL;

               dqState state = DQ_STATE_NOT_ESTABLISHED;

     mamaSubscription_getTransport (subscription, &transport);

@@ -282,13 +282,13 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

     }

     if (queueStatsCollector)

-        mamaStatsCollector_incrementStat (*queueStatsCollector, MamaStatNumMessages.mFid);

+        mamaStatsCollector_incrementStat (queueStatsCollector, MamaStatNumMessages.mFid);

     if (tportStatsCollector)

-        mamaStatsCollector_incrementStat (*tportStatsCollector, MamaStatNumMessages.mFid);

+        mamaStatsCollector_incrementStat (tportStatsCollector, MamaStatNumMessages.mFid);

     if (mamaInternal_getGlobalStatsCollector() != NULL)

-        mamaStatsCollector_incrementStat (*(mamaInternal_getGlobalStatsCollector()),

+        mamaStatsCollector_incrementStat (mamaInternal_getGlobalStatsCollector(),

                                           MamaStatNumMessages.mFid);

     /* Get the user symbol from the subscription. */

@@ -357,18 +357,18 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

             if (queueStatsCollector)

             {

-                mamaStatsCollector_incrementStat (*queueStatsCollector,

+                mamaStatsCollector_incrementStat (queueStatsCollector,

                         MamaStatUnknownMsgs.mFid);

             }

             if (tportStatsCollector)

             {

-                mamaStatsCollector_incrementStat (*tportStatsCollector,

+                mamaStatsCollector_incrementStat (tportStatsCollector,

                         MamaStatUnknownMsgs.mFid);

             }

             if (mamaInternal_getGlobalStatsCollector())

             {

                 mamaStatsCollector_incrementStat

-                    (*(mamaInternal_getGlobalStatsCollector()),

+                (mamaInternal_getGlobalStatsCollector(),

                      MamaStatUnknownMsgs.mFid);

             }

             return; /* throw away msg */

@@ -387,15 +387,15 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

         case MAMA_MSG_TYPE_INITIAL :

              if (queueStatsCollector)

              {

-                mamaStatsCollector_incrementStat (*queueStatsCollector, MamaStatInitials.mFid);

+                mamaStatsCollector_incrementStat (queueStatsCollector, MamaStatInitials.mFid);

              }

              if (tportStatsCollector)

              {

-                mamaStatsCollector_incrementStat (*tportStatsCollector, MamaStatInitials.mFid);

+                mamaStatsCollector_incrementStat (tportStatsCollector, MamaStatInitials.mFid);

              }

              if (mamaInternal_getGlobalStatsCollector() != NULL)

              {

-                mamaStatsCollector_incrementStat (*(mamaInternal_getGlobalStatsCollector()),

+                mamaStatsCollector_incrementStat (mamaInternal_getGlobalStatsCollector(),

                                                   MamaStatInitials.mFid);

              }

              break;

@@ -403,30 +403,30 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

         case MAMA_MSG_TYPE_BOOK_RECAP :

              if (queueStatsCollector)

              {

-                mamaStatsCollector_incrementStat (*queueStatsCollector, MamaStatRecaps.mFid);

+                mamaStatsCollector_incrementStat (queueStatsCollector, MamaStatRecaps.mFid);

              }

              if (tportStatsCollector)

              {

-                mamaStatsCollector_incrementStat (*tportStatsCollector, MamaStatRecaps.mFid);

+                mamaStatsCollector_incrementStat (tportStatsCollector, MamaStatRecaps.mFid);

              }

              if (mamaInternal_getGlobalStatsCollector())

              {

-                mamaStatsCollector_incrementStat (*(mamaInternal_getGlobalStatsCollector()),

+                mamaStatsCollector_incrementStat (mamaInternal_getGlobalStatsCollector(),

                                                   MamaStatRecaps.mFid);

              }

              break;

         case MAMA_MSG_TYPE_UNKNOWN :

              if (queueStatsCollector)

              {

-                mamaStatsCollector_incrementStat (*queueStatsCollector, MamaStatUnknownMsgs.mFid);

+                mamaStatsCollector_incrementStat (queueStatsCollector, MamaStatUnknownMsgs.mFid);

              }

              if (tportStatsCollector)

              {

-                mamaStatsCollector_incrementStat (*tportStatsCollector, MamaStatUnknownMsgs.mFid);

+                mamaStatsCollector_incrementStat (tportStatsCollector, MamaStatUnknownMsgs.mFid);

              }

              if (mamaInternal_getGlobalStatsCollector())

              {

-                mamaStatsCollector_incrementStat (*(mamaInternal_getGlobalStatsCollector()),

+                mamaStatsCollector_incrementStat (mamaInternal_getGlobalStatsCollector(),

                                                   MamaStatUnknownMsgs.mFid);

              }

              break;

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

index 78ecc92..d6ca7fa 100644

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

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

@@ -112,7 +112,7 @@ int gPublishLbmStats        = 0;

static mamaStatsLogger  gStatsPublisher  = NULL;

 mamaStatsGenerator      gStatsGenerator         = NULL;

-mamaStatsCollector*     gGlobalStatsCollector   = NULL;

+mamaStatsCollector      gGlobalStatsCollector   = NULL;

mamaStat                gInitialStat;

mamaStat                gRecapStat;

mamaStat                gUnknownMsgStat;

@@ -448,10 +448,8 @@ mamaInternal_enableStatsLogging (void)

         const char* appName;

         mama_getApplicationName (&appName);

-        gGlobalStatsCollector = (mamaStatsCollector*)mamaStatsGenerator_allocateStatsCollector (gStatsGenerator);

-

         if (MAMA_STATUS_OK != (result =

-            mamaStatsCollector_create (gGlobalStatsCollector,

+            mamaStatsCollector_create (&gGlobalStatsCollector,

                                        MAMA_STATS_COLLECTOR_TYPE_GLOBAL,

                                        appName,

                                        "-----")))

@@ -462,7 +460,7 @@ mamaInternal_enableStatsLogging (void)

         if (!gLogGlobalStats)

         {

             if (MAMA_STATUS_OK != (result =

-                mamaStatsCollector_setLog (*gGlobalStatsCollector, 0)))

+                mamaStatsCollector_setLog (gGlobalStatsCollector, 0)))

             {

                 return MAMA_STATUS_OK;

             }

@@ -471,7 +469,7 @@ mamaInternal_enableStatsLogging (void)

         if (gPublishGlobalStats)

         {

             if (MAMA_STATUS_OK != (result =

-                mamaStatsCollector_setPublish (*gGlobalStatsCollector, 1)))

+                mamaStatsCollector_setPublish (gGlobalStatsCollector, 1)))

             {

                 return MAMA_STATUS_OK;

             }

@@ -552,7 +550,7 @@ mamaInternal_enableStatsLogging (void)

         mamaStatsGenerator_addStatsCollector (gStatsGenerator, gGlobalStatsCollector);

     }

-    if (gLogQueueStats || gLogTransportStats || gLogGlobalStats)

+    if (gLogQueueStats || gLogTransportStats || gLogGlobalStats || gLogLbmStats)

     {

         mamaStatsGenerator_setLogStats (gStatsGenerator, 1);

     }

@@ -579,7 +577,7 @@ mamaInternal_getStatsGenerator()

     return gStatsGenerator;

}

-mamaStatsCollector*

+mamaStatsCollector

mamaInternal_getGlobalStatsCollector()

{

     return gGlobalStatsCollector;

@@ -1152,7 +1150,7 @@ mama_closeCount (unsigned int* count)

             {

                 mamaStatsGenerator_removeStatsCollector (gStatsGenerator, gGlobalStatsCollector);

             }

-            mamaStatsCollector_destroy (*gGlobalStatsCollector);

+            mamaStatsCollector_destroy (gGlobalStatsCollector);

             gGlobalStatsCollector = NULL;

         }

@@ -1248,7 +1246,7 @@ mama_closeCount (unsigned int* count)

             {

                 mamaStatsGenerator_removeStatsCollector (gStatsGenerator, gGlobalStatsCollector);

             }

-            mamaStatsCollector_destroy (*gGlobalStatsCollector);

+            mamaStatsCollector_destroy (gGlobalStatsCollector);

             gGlobalStatsCollector = NULL;

         }

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

index 998f794..0d60c27 100644

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

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

@@ -66,7 +66,7 @@ typedef enum mamaStatType

  */

MAMAExpDLL

extern mama_status

-mamaStat_create (mamaStat* stat, mamaStatsCollector* collector, int lockable, const char* name, mama_fid_t type);

+mamaStat_create (mamaStat* stat, mamaStatsCollector collector, int lockable, const char* name, mama_fid_t type);

 /**

  * Destroy a mamaStats object

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

index d7f06ef..485fb09 100644

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

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

@@ -597,7 +597,7 @@ mamaTransport_getNativeTransportNamingCtx (mamaTransport transport,

                                            void** nativeTportNamingCtx);

 MAMAExpDLL

-extern mamaStatsCollector*

+extern mamaStatsCollector

mamaTransport_getStatsCollector (mamaTransport transport);

 /**

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

index 99df523..db74a7e 100644

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

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

@@ -63,7 +63,7 @@ extern mamaStatsGenerator

mamaInternal_getStatsGenerator (void);

 MAMAExpDLL

-extern mamaStatsCollector*

+extern mamaStatsCollector

mamaInternal_getGlobalStatsCollector (void);

 MAMAExpDLL

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

index c617b3d..4052421 100644

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

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

@@ -79,7 +79,7 @@ typedef struct mamaQueueImpl_

     size_t                      mLowWatermark;

     size_t                      mHighWatermark;

     int                         mIsDefaultQueue;

-    mamaStatsCollector*         mStatsCollector;

+    mamaStatsCollector          mStatsCollector;

     mamaStat                    mInitialStat;

     mamaStat                    mRecapStat;

     mamaStat                    mUnknownMsgStat;

@@ -266,9 +266,8 @@ mamaQueue_enableStats(mamaQueue queue)

     {

         middleware = impl->mBridgeImpl->bridgeGetName();

-        impl->mStatsCollector = (mamaStatsCollector*)mamaStatsGenerator_allocateStatsCollector (mamaInternal_getStatsGenerator());

         if (MAMA_STATUS_OK != (status=mamaStatsCollector_create (

-                                    impl->mStatsCollector,

+                                   &(impl->mStatsCollector),

                                     MAMA_STATS_COLLECTOR_TYPE_QUEUE,

                                     impl->mQueueName, middleware)))

         {

@@ -283,7 +282,7 @@ mamaQueue_enableStats(mamaQueue queue)

         if (!gLogQueueStats)

         {

             if (MAMA_STATUS_OK != (status=mamaStatsCollector_setLog (

-                                   *impl->mStatsCollector, 0)))

+                                   impl->mStatsCollector, 0)))

             {

                 return status;

             }

@@ -294,7 +293,7 @@ mamaQueue_enableStats(mamaQueue queue)

         if (gPublishQueueStats)

         {

             if (MAMA_STATUS_OK != (status=mamaStatsCollector_setPublish (

-                                   *impl->mStatsCollector, 1)))

+                                   impl->mStatsCollector, 1)))

             {

                return status;

             }

@@ -735,7 +734,7 @@ mamaQueue_destroy (mamaQueue queue)

         if (impl->mStatsCollector)

         {

             mamaStatsGenerator_removeStatsCollector  (mamaInternal_getStatsGenerator(), impl->mStatsCollector);

-            mamaStatsCollector_destroy (*impl->mStatsCollector);

+            mamaStatsCollector_destroy (impl->mStatsCollector);

             impl->mStatsCollector = NULL;

         }

          if (impl->mQueueName)

@@ -1025,7 +1024,7 @@ mamaQueue_setQueueName (mamaQueue   queue,

     if (impl->mStatsCollector)

     {

-        mamaStatsCollector_setName (*impl->mStatsCollector, impl->mQueueName);

+        mamaStatsCollector_setName (impl->mStatsCollector, impl->mQueueName);

     }

     return MAMA_STATUS_OK;

@@ -1119,7 +1118,7 @@ mamaQueue_getQueueBridgeName (mamaQueue    queue,

     return MAMA_STATUS_OK;

}

-mamaStatsCollector*

+mamaStatsCollector

mamaQueueImpl_getStatsCollector (mamaQueue queue)

{

     mamaQueueImpl* impl = (mamaQueueImpl*)queue;

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

index bbe1a6d..da085c6 100644

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

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

@@ -104,7 +104,7 @@ extern mama_status

mamaQueueImpl_lowWatermarkExceeded (mamaQueue queue, size_t size);

 MAMAExpDLL

-extern mamaStatsCollector*

+extern mamaStatsCollector

 mamaQueueImpl_getStatsCollector (mamaQueue queue);

 #if defined(__cplusplus)

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

index a996d80..75e41fd 100644

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

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

@@ -33,7 +33,7 @@ typedef struct mamaStatImpl__

{

     const char*         mName;

     mama_fid_t          mFid;

-    mamaStatsCollector* mStatsCollector;

+    mamaStatsCollector  mStatsCollector;

     mama_u32_t          mIntervalValue;

     mama_u32_t          mMaxValue;

     mama_u32_t          mTotalValue;

@@ -46,7 +46,7 @@ typedef struct mamaStatImpl__

} mamaStatImpl;

 mama_status

-mamaStat_create (mamaStat* stat, mamaStatsCollector* statsCollector, int lockable, const char* name, mama_fid_t fid)

+mamaStat_create (mamaStat* stat, mamaStatsCollector statsCollector, int lockable, const char* name, mama_fid_t fid)

{

     mamaStatImpl* impl = (mamaStatImpl*) malloc (sizeof(mamaStatImpl));

     if (impl == NULL) return MAMA_STATUS_NOMEM;

@@ -66,7 +66,7 @@ mamaStat_create (mamaStat* stat, mamaStatsCollector* statsCollector, int lockabl

         wthread_mutex_init (&impl->mUpdateMutex, NULL);

     *stat = (mamaStat)impl;

-    mamaStatsCollector_addStat (*impl->mStatsCollector, *stat);

+    mamaStatsCollector_addStat (impl->mStatsCollector, *stat);

     return MAMA_STATUS_OK;

}

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

index 87ba012..739d6a1 100644

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

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

@@ -29,21 +29,6 @@

#include "mama/statscollector.h"

#include "mama/statfields.h"

-#define MAMA_STAT_ARRAY_OFFSET                                105

-#define MAMA_STAT_MAX_STATS                      30

-

-typedef struct mamaStatsCollectorImpl__

-{

-    mamaStatsCollectorType        mType;

-    const char*                                   mName;

-    mamaStat                                      mMamaStats[MAMA_STAT_MAX_STATS];

-    const char*                                   mMiddleware;

-    collectorPollStatCb    mPollCb;

-    void*                                               mPollClosure;

-    int                                                     mPublishStats;

-    int                                                     mLogStats;

-} mamaStatsCollectorImpl;

-

mama_status

mamaStatsCollector_create (mamaStatsCollector* statsCollector, mamaStatsCollectorType type, const char* name, const char* middleware)

{

@@ -71,9 +56,9 @@ mamaStatsCollector_destroy (mamaStatsCollector statsCollector)

     mamaStatsCollectorImpl* impl = (mamaStatsCollectorImpl*)statsCollector;

     if (!impl) return MAMA_STATUS_NULL_ARG;

-    free ((char*)impl->mName);

+    free (impl->mName);

     impl->mName         = NULL;

-    free ((char*)impl->mMiddleware);

+    free (impl->mMiddleware);

     impl->mMiddleware   = NULL;

     impl->mPollCb       = NULL;

     impl->mPollClosure  = NULL;

@@ -122,9 +107,9 @@ mamaStatsCollector_setStatIntervalValueFromTotal (mamaStatsCollector statsCollec

}

 void

-mamaStatsCollector_populateMsg /*And string logging */ (mamaStatsCollector* statsCollector, mamaMsg msg, int* wasLogged)

+mamaStatsCollector_populateMsg /*And string logging */ (mamaStatsCollector statsCollector, mamaMsg msg, int* wasLogged)

{

-    mamaStatsCollectorImpl* impl = (mamaStatsCollectorImpl*)*statsCollector;

+    mamaStatsCollectorImpl* impl = (mamaStatsCollectorImpl*)statsCollector;

     mama_fid_t  fid;

     const char* name = NULL;

     const char* type = NULL;

@@ -150,7 +135,7 @@ mamaStatsCollector_populateMsg /*And string logging */ (mamaStatsCollector* stat

     if (impl->mPollCb != NULL)

     {

-        impl->mPollCb (*statsCollector, impl->mPollClosure);

+        impl->mPollCb (statsCollector, impl->mPollClosure);

     }

     for (i=0;i<MAMA_STAT_MAX_STATS;i++)

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

index e3ddfba..b368f60 100644

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

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

@@ -22,6 +22,8 @@

#ifndef MamaStatsCollectorInternalH__

#define MamaStatsCollectorInternalH__

+#include "mama/statscollector.h"

+

#if defined(__cplusplus)

extern "C" {

#endif

@@ -29,6 +31,22 @@ extern "C" {

typedef void (

*collectorPollStatCb) (mamaStatsCollector statsCollector, void* closure);

+#define MAMA_STAT_ARRAY_OFFSET                               105

+#define MAMA_STAT_MAX_STATS                     30

+

+typedef struct mamaStatsCollectorImpl__

+{

+    mamaStatsCollectorType       mType;

+    char*                                                      mName;

+    mamaStat                                     mMamaStats[MAMA_STAT_MAX_STATS];

+    char*                                                      mMiddleware;

+    collectorPollStatCb   mPollCb;

+    void*                                              mPollClosure;

+    int                                                    mPublishStats;

+    int                                                    mLogStats;

+    void*                                              mHandle;

+} mamaStatsCollectorImpl;

+

MAMAExpDLL

extern mama_status

mamaStatsCollector_setPollCallback (mamaStatsCollector statsCollector, collectorPollStatCb cb, void* closure);

@@ -44,7 +62,7 @@ mamaStatsCollector_setPollCallback (mamaStatsCollector statsCollector, collector

  */

MAMAExpDLL

extern void

-mamaStatsCollector_populateMsg (mamaStatsCollector* statsCollector, mamaMsg msg, int* wasLogged);

+mamaStatsCollector_populateMsg (mamaStatsCollector statsCollector, mamaMsg msg, int* wasLogged);

 MAMAExpDLL

extern mama_status

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

index 96daad1..2372d77 100644

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

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

@@ -123,28 +123,37 @@ mamaStatsGenerator_setQueue (mamaStatsGenerator statsGenerator, mamaQueue queue)

}

 mama_status

-mamaStatsGenerator_addStatsCollector (mamaStatsGenerator statsGenerator, mamaStatsCollector* statsCollector)

+mamaStatsGenerator_addStatsCollector (mamaStatsGenerator statsGenerator, mamaStatsCollector statsCollector)

{

     mamaStatsGeneratorImpl* impl = (mamaStatsGeneratorImpl*)statsGenerator;

+    mamaStatsCollector* element = NULL;

+    mamaStatsCollectorImpl* collectorImpl = (mamaStatsCollectorImpl*)statsCollector;

     if (impl==NULL) return MAMA_STATUS_NULL_ARG;

     if (statsCollector == NULL) return MAMA_STATUS_NULL_ARG;

-    list_push_back (impl->mStatsCollectors, statsCollector);

+    element = list_allocate_element (impl->mStatsCollectors);

+

+    *element = statsCollector;

+

+    list_push_back (impl->mStatsCollectors, element);

+

+     collectorImpl->mHandle = element;

     return MAMA_STATUS_OK;

}

 mama_status

-mamaStatsGenerator_removeStatsCollector (mamaStatsGenerator statsGenerator, mamaStatsCollector* statsCollector)

+mamaStatsGenerator_removeStatsCollector (mamaStatsGenerator statsGenerator, mamaStatsCollector statsCollector)

{

     mamaStatsGeneratorImpl* impl = (mamaStatsGeneratorImpl*)statsGenerator;

+     mamaStatsCollectorImpl* collectorImpl = (mamaStatsCollectorImpl*)statsCollector;

     if (impl==NULL) return MAMA_STATUS_NULL_ARG;

     if (statsCollector==NULL) return MAMA_STATUS_NULL_ARG;

-    list_remove_element (impl->mStatsCollectors, (void*)statsCollector);

-    list_free_element (impl->mStatsCollectors, (void*)statsCollector);

+    list_remove_element (impl->mStatsCollectors, collectorImpl->mHandle);

+    list_free_element (impl->mStatsCollectors, collectorImpl->mHandle);

     return MAMA_STATUS_OK;

}

@@ -172,7 +181,7 @@ mamaStatsGenerator_generateStats (mamaStatsGenerator statsGenerator)

    {

         wasLogged = 0;

-        mamaStatsCollector_populateMsg (current, impl->mStatMsg, &wasLogged);

+        mamaStatsCollector_populateMsg (*current, impl->mStatMsg, &wasLogged);

         if (impl->mStatsLogger && mamaStatsCollector_getPublish(*current))

         {

@@ -233,14 +242,6 @@ mamaStatsGenerator_onReportTimer (mamaTimer timer, void* closure)

     mamaStatsGenerator_generateStats (statsgenerator);

}

-void*

-mamaStatsGenerator_allocateStatsCollector (mamaStatsGenerator statsGenerator)

-{

-    mamaStatsGeneratorImpl* impl = (mamaStatsGeneratorImpl*)statsGenerator;

-

-    return list_allocate_element (impl->mStatsCollectors);

-}

-

mama_status mamaStatsGenerator_stopReportTimer(mamaStatsGenerator statsGenerator)

{

     /* Returns. */

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

index be1944d..c05a1b5 100644

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

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

@@ -51,7 +51,7 @@ mamaStatsGenerator_destroy (mamaStatsGenerator statsGenerator);

 MAMAExpDLL

extern mama_status

-mamaStatsGenerator_removeStatsCollector (mamaStatsGenerator statsGenerator, mamaStatsCollector* statsCollector);

+mamaStatsGenerator_removeStatsCollector (mamaStatsGenerator statsGenerator, mamaStatsCollector statsCollector);

 MAMAExpDLL

extern mama_status

@@ -75,7 +75,7 @@ mamaStatsGenerator_allocateStatsCollector (mamaStatsGenerator statsGenerator);

 MAMAExpDLL

extern mama_status

-mamaStatsGenerator_addStatsCollector (mamaStatsGenerator statsGenerator, mamaStatsCollector* statsCollector);

+mamaStatsGenerator_addStatsCollector (mamaStatsGenerator statsGenerator, mamaStatsCollector statsCollector);

 #if defined (__cplusplus)

}

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

index b3f814c..7987eb2 100644

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

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

@@ -2029,19 +2029,19 @@ void mamaSubscriptionImpl_initialize(mamaSubscriptionImpl *impl)

     /* Increment the appropriate stats. */

     if(gGenerateQueueStats)

     {

-        mamaStatsCollector *queueStatsCollector = mamaQueueImpl_getStatsCollector(impl->mQueue);

-        mamaStatsCollector_incrementStat (*queueStatsCollector, MamaStatNumSubscriptions.mFid);

+        mamaStatsCollector queueStatsCollector = mamaQueueImpl_getStatsCollector(impl->mQueue);

+        mamaStatsCollector_incrementStat (queueStatsCollector, MamaStatNumSubscriptions.mFid);

     }

     if(gGenerateTransportStats)

     {

-        mamaStatsCollector *transportStatsCollector = mamaTransport_getStatsCollector(impl->mTransport);

-        mamaStatsCollector_incrementStat(*transportStatsCollector, MamaStatNumSubscriptions.mFid);

+        mamaStatsCollector transportStatsCollector = mamaTransport_getStatsCollector(impl->mTransport);

+        mamaStatsCollector_incrementStat(transportStatsCollector, MamaStatNumSubscriptions.mFid);

     }

     if(mamaInternal_getGlobalStatsCollector() != NULL)

     {

-        mamaStatsCollector_incrementStat(*(mamaInternal_getGlobalStatsCollector()), MamaStatNumSubscriptions.mFid);

+        mamaStatsCollector_incrementStat(mamaInternal_getGlobalStatsCollector(), MamaStatNumSubscriptions.mFid);

     }

}

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

index b9c1a9b..3639956 100644

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

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

@@ -123,7 +123,7 @@ typedef struct transportImpl_

     char*                    mDescription;

     int                     mDeactivateSubscriptionOnError;

-    mamaStatsCollector*     mStatsCollector;

+    mamaStatsCollector      mStatsCollector;

     mamaStat                mRecapStat;

     mamaStat                mUnknownMsgStat;

     mamaStat                mMessageStat;

@@ -891,11 +891,8 @@ mamaTransport_initStats (mamaTransport transport)

     middleware = self->mBridgeImpl->bridgeGetName ();

-    self->mStatsCollector = (mamaStatsCollector*) mamaStatsGenerator_allocateStatsCollector

-                                                            (mamaInternal_getStatsGenerator ());

-

     if (MAMA_STATUS_OK != (status=mamaStatsCollector_create (

-                               self->mStatsCollector,

+                               &(self->mStatsCollector),

                                 MAMA_STATS_COLLECTOR_TYPE_TRANSPORT,

                                 self->mName, middleware)))

     {

@@ -909,7 +906,7 @@ mamaTransport_initStats (mamaTransport transport)

     if (!gLogTransportStats)

     {

         if (MAMA_STATUS_OK != (status=mamaStatsCollector_setLog (

-                                    *self->mStatsCollector, 0)))

+                                    self->mStatsCollector, 0)))

         {

             return status;

         }

@@ -923,7 +920,7 @@ mamaTransport_initStats (mamaTransport transport)

     if (gPublishTransportStats)

     {

         if (MAMA_STATUS_OK != (status=mamaStatsCollector_setPublish (

-                                    *self->mStatsCollector, 1)))

+                                    self->mStatsCollector, 1)))

         {

             return status;

         }

@@ -1323,7 +1320,7 @@ mamaTransport_destroy (mamaTransport transport)

     if (self->mStatsCollector)

     {

         mamaStatsGenerator_removeStatsCollector  (mamaInternal_getStatsGenerator (), self->mStatsCollector);

-        mamaStatsCollector_destroy (*self->mStatsCollector);

+        mamaStatsCollector_destroy (self->mStatsCollector);

         self->mStatsCollector = NULL;

     }

@@ -1350,7 +1347,7 @@ mamaTransport_setName (mamaTransport transport,

     if (self->mStatsCollector)

     {

-        mamaStatsCollector_setName (*self->mStatsCollector, self->mName);

+        mamaStatsCollector_setName (self->mStatsCollector, self->mName);

     }

     return MAMA_STATUS_OK;

@@ -2267,7 +2264,7 @@ mamaTransport_getNativeTransportNamingCtx (mamaTransport transport,

}

 

-mamaStatsCollector*

+mamaStatsCollector

mamaTransport_getStatsCollector (mamaTransport transport)

{

     if (!self) return 0;

--

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.