Date   

[PATCH 2/2] [mama] Stats wrapper class

Ian Bell <IBell@...>
 

From 1cc93a8f2a0889650b91a1e6b57e871b7821dee7 Mon Sep 17 00:00:00 2001

Message-Id: <1cc93a8f2a0889650b91a1e6b57e871b7821dee7.1348677184.git.ibell@...>

In-Reply-To: <47121238854a5b7c5049bf869c7cb28c11404552.1348677184.git.ibell@...>

References: <47121238854a5b7c5049bf869c7cb28c11404552.1348677184.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 17:32:41 +0100

Subject: [PATCH 2/2] [mama] Stats wrapper class

 

Added c++ stats wrapper classes

 

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

---

mama/c_cpp/src/cpp/MamaStat.cpp              |  139 ++++++++++++++++++++++++++

mama/c_cpp/src/cpp/MamaStatImpl.h            |   73 ++++++++++++++

mama/c_cpp/src/cpp/MamaStatsCollector.cpp    |  126 +++++++++++++++++++++++

mama/c_cpp/src/cpp/MamaStatsCollectorImpl.h  |   72 +++++++++++++

mama/c_cpp/src/cpp/mama/MamaStat.h           |   70 +++++++++++++

mama/c_cpp/src/cpp/mama/MamaStatsCollector.h |   63 ++++++++++++

6 files changed, 543 insertions(+)

 

diff --git a/mama/c_cpp/src/cpp/MamaStat.cpp b/mama/c_cpp/src/cpp/MamaStat.cpp

new file mode 100644

index 0000000..f12fc51

--- /dev/null

+++ b/mama/c_cpp/src/cpp/MamaStat.cpp

@@ -0,0 +1,139 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#include "MamaStatImpl.h"

+#include "mamacppinternal.h"

+

+namespace Wombat

+{

+

+    MamaStat::~MamaStat (void)

+    {

+        if (mSimpl)

+        {

+            delete mSimpl;

+            mSimpl = NULL;

+        }

+    }

+

+    MamaStat::MamaStat (MamaStatImpl* impl)

+        : mSimpl (impl)

+    {

+    }

+

+    MamaStat::MamaStat (void)

+        : mSimpl (new MamaStatImpl (this))

+    {

+    }

+

+    void MamaStat::create (MamaStatsCollector*  statsCollector,

+                           int                  lockable,

+                           const char*          name,

+                           mama_fid_t           fid)

+    {

+        mSimpl->create (statsCollector, lockable, name, fid);

+    }

+

+    void MamaStat::increment ()

+    {

+        mSimpl->increment ();

+    }

+

+    void MamaStat::decrement ()

+    {

+        mSimpl->decrement ();

+    }

+

+    void MamaStat::reset ()

+    {

+        mSimpl->reset ();

+    }

+

+    void MamaStat::setLog (int log)

+    {

+        mSimpl->setLog (log);

+    }

+

+    void MamaStat::setPublish (int publish)

+    {

+        mSimpl->setPublish (publish);

+    }

+

+    void MamaStat::destroy ()

+    {

+        mSimpl->destroy();

+    }

+

+    void MamaStatImpl::create (MamaStatsCollector* statsCollector,

+                               int                 lockable,

+                               const char*         name,

+                               mama_fid_t          fid)

+    {

+        if (mStat)

+        {

+            throw MamaStatus (MAMA_STATUS_INVALID_ARG);

+        }

+

+        mamaTry (mamaStat_create (&mStat,

+                                  statsCollector->getStatsCollector(),

+                                  lockable,

+                                  name,

+                                  fid));

+

+    }

+

+    void MamaStatImpl::increment ()

+    {

+        mamaTry (mamaStat_increment (mStat));

+    }

+

+    void MamaStatImpl::decrement ()

+    {

+        mamaTry (mamaStat_decrement (mStat));

+    }

+

+    void MamaStatImpl::reset ()

+    {

+        mamaTry (mamaStat_reset (mStat));

+    }

+

+    void MamaStatImpl::setLog (int log)

+    {

+        mamaTry (mamaStat_setLog (mStat, log));

+    }

+

+    void MamaStatImpl::setPublish (int publish)

+    {

+        mamaTry (mamaStat_setPublish (mStat, publish));

+    }

+

+    void MamaStatImpl::destroy ()

+    {

+        if (mStat)

+        {

+            mamaTry (mamaStat_destroy (mStat));

+            mStat = NULL;

+        }

+    }

+

+} //namespace Wombat

+

+

diff --git a/mama/c_cpp/src/cpp/MamaStatImpl.h b/mama/c_cpp/src/cpp/MamaStatImpl.h

new file mode 100644

index 0000000..6ea5810

--- /dev/null

+++ b/mama/c_cpp/src/cpp/MamaStatImpl.h

@@ -0,0 +1,73 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#ifndef MAMA_STAT_IMPL_CPP_H__

+#define MAMA_STAT_IMPL_CPP_H__

+

+#include <mama/MamaStat.h>

+

+namespace Wombat

+{

+    class MamaStatImpl

+    {

+    public:

+        MamaStatImpl  (void)

+            : mParent (NULL)

+            , mStat   (0)

+        {

+        };

+

+        MamaStatImpl  (MamaStat* stat)

+            : mParent (stat)

+            , mStat   (0)

+        {

+        };

+

+        virtual ~MamaStatImpl (void)

+        {

+            destroy ();

+        }

+        virtual void create             (MamaStatsCollector*    statsCollector,

+                                         int                    lockable,

+                                         const char*            name,

+                                         mama_fid_t             fid);

+

+        virtual void increment          ();

+

+        virtual void decrement          ();

+

+        virtual void reset              ();

+

+        virtual void setLog             (int                    log);

+

+        virtual void setPublish         (int                    publish);

+

+        virtual void destroy            ();

+

+    protected:

+        MamaStat*    mParent;

+

+        mamaStat     mStat;

+    };

+

+} //namespace Wombat

+

+#endif //MAMA_STAT_IMPL_CPP_H__

diff --git a/mama/c_cpp/src/cpp/MamaStatsCollector.cpp b/mama/c_cpp/src/cpp/MamaStatsCollector.cpp

new file mode 100644

index 0000000..65ba303

--- /dev/null

+++ b/mama/c_cpp/src/cpp/MamaStatsCollector.cpp

@@ -0,0 +1,126 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#include "MamaStatsCollectorImpl.h"

+#include "mamacppinternal.h"

+

+namespace Wombat

+{

+    MamaStatsCollector::~MamaStatsCollector (void)

+    {

+        if (mSimpl)

+        {

+            delete mSimpl;

+            mSimpl = NULL;

+        }

+    }

+

+    MamaStatsCollector::MamaStatsCollector (MamaStatsCollectorImpl* impl)

+        : mSimpl (impl)

+    {

+    }

+

+    MamaStatsCollector::MamaStatsCollector (void)

+        : mSimpl (new MamaStatsCollectorImpl (this))

+    {

+    }

+

+    void MamaStatsCollector::create (mamaStatsCollectorType type,

+                                     const char*            name,

+                                     const char*            middleware)

+    {

+        mSimpl->create (type, name, middleware);

+    }

+

+    void MamaStatsCollector::incrementStat (mama_fid_t   identifier)

+    {

+        mSimpl->incrementStat (identifier);

+    }

+

+    void MamaStatsCollector::setName (const char* name)

+    {

+        mSimpl->setName (name);

+    }

+

+    void MamaStatsCollector::setLog (int log)

+    {

+        mSimpl->setLog (log);

+    }

+

+    void MamaStatsCollector::setPublish (int publish)

+    {

+        mSimpl->setPublish (publish);

+    }

+

+    void MamaStatsCollector::destroy ()

+    {

+        mSimpl->destroy ();

+    }

+

+    mamaStatsCollector MamaStatsCollector::getStatsCollector ()

+    {

+        return (mSimpl->mStatsCollector);

+    }

+

+    void MamaStatsCollectorImpl::create (mamaStatsCollectorType   type,

+                                         const char*              name,

+                                         const char*              middleware)

+    {

+        mamaTry (mamaStatsCollector_create (&mStatsCollector,

+                                            type,

+                                            name,

+                                            middleware));

+    }

+

+    void MamaStatsCollectorImpl::incrementStat (mama_fid_t identifier)

+    {

+        mamaTry (mamaStatsCollector_incrementStat (mStatsCollector,

+                                                   identifier));

+    }

+

+    void MamaStatsCollectorImpl::setName (const char* name)

+    {

+        mamaTry (mamaStatsCollector_setName (mStatsCollector,

+                                             name));

+    }

+

+    void MamaStatsCollectorImpl::setLog (int log)

+    {

+        mamaTry (mamaStatsCollector_setLog (mStatsCollector,

+                                             log));

+    }

+

+    void MamaStatsCollectorImpl::setPublish (int publish)

+    {

+        mamaTry (mamaStatsCollector_setPublish (mStatsCollector,

+                                                publish));

+    }

+

+    void MamaStatsCollectorImpl::destroy (void)

+    {

+        if (mStatsCollector)

+        {

+            mamaTry (mamaStatsCollector_destroy (mStatsCollector));

+            mStatsCollector = NULL;

+        }

+    }

+

+} //namespace Wombat

diff --git a/mama/c_cpp/src/cpp/MamaStatsCollectorImpl.h b/mama/c_cpp/src/cpp/MamaStatsCollectorImpl.h

new file mode 100644

index 0000000..c35be1c

--- /dev/null

+++ b/mama/c_cpp/src/cpp/MamaStatsCollectorImpl.h

@@ -0,0 +1,72 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#ifndef MAMA_STATS_COLLECTOR_IMPL_H__

+#define MAMA_STATS_COLLECTOR_IMPL_H__

+

+#include <mama/MamaStatsCollector.h>

+

+namespace Wombat

+{

+

+    class MamaStatsCollectorImpl

+    {

+    public:

+        MamaStatsCollectorImpl (void)

+            : mParent          (NULL)

+            , mStatsCollector  (0)

+        {

+        };

+

+        MamaStatsCollectorImpl (MamaStatsCollector* statsCollector)

+            : mParent          (statsCollector)

+            , mStatsCollector  (0)

+        {

+        };

+

+        virtual ~MamaStatsCollectorImpl (void)

+        {

+            destroy ();

+        }

+

+        virtual void create          (mamaStatsCollectorType type,

+                                      const char*            name,

+                                      const char*            middleware);

+

+        virtual void incrementStat   (mama_fid_t             identifier);

+

+        virtual void setName         (const char*            name);

+

+        virtual void setLog          (int                    log);

+

+        virtual void setPublish      (int                    publish);

+

+        virtual void destroy         ();

+

+        MamaStatsCollector*          mParent;

+

+

+        mamaStatsCollector         mStatsCollector;

+    };

+

+} //namespace Wombat

+

+#endif //MAMA_STATS_COLLECTOR_IMPL_H__

diff --git a/mama/c_cpp/src/cpp/mama/MamaStat.h b/mama/c_cpp/src/cpp/mama/MamaStat.h

new file mode 100644

index 0000000..1ea7647

--- /dev/null

+++ b/mama/c_cpp/src/cpp/mama/MamaStat.h

@@ -0,0 +1,70 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#ifndef MAMA_STAT_CPP_H__

+#define MAMA_STAT_CPP_H__

+

+#include "mama/types.h"

+#include "mama/mamacpp.h"

+#include "mama/stat.h"

+#include "mama/statfields.h"

+#include "mama/statscollector.h"

+#include "mama/MamaStatsCollector.h"

+

+namespace Wombat

+{

+

+    class MamaStatImpl;

+

+    class MAMACPPExpDLL MamaStat

+    {

+    public:

+        MamaStat (void);

+

+        virtual ~MamaStat (void);

+

+        virtual void create             (MamaStatsCollector*    statsCollector,

+                                         int                    lockable,

+                                         const char*            name,

+                                         mama_fid_t             fid);

+

+        virtual void increment          ();

+

+        virtual void decrement          ();

+

+        virtual void reset              ();

+       

+        virtual void setLog             (int                    log);

+

+        virtual void setPublish         (int                    publish);

+

+        virtual void destroy            (void);

+

+    protected:

+        MamaStat      (MamaStatImpl*);

+       

+        MamaStatImpl* mSimpl;

+

+    };

+

+} //namespace Wombat

+

+#endif //MAMA_STAT_CPP_H__

diff --git a/mama/c_cpp/src/cpp/mama/MamaStatsCollector.h b/mama/c_cpp/src/cpp/mama/MamaStatsCollector.h

new file mode 100644

index 0000000..795cdf9

--- /dev/null

+++ b/mama/c_cpp/src/cpp/mama/MamaStatsCollector.h

@@ -0,0 +1,63 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#ifndef MAMA_STATS_COLLECTOR_CPP_H__

+#define MAMA_STATS_COLLECTOR_CPP_H__

+

+#include "mama/types.h"

+#include "mama/statscollector.h"

+

+namespace Wombat

+{

+    class MamaStatsCollectorImpl;

+

+    class MAMACPPExpDLL MamaStatsCollector

+    {

+        public:

+            MamaStatsCollector (void);

+

+            virtual ~MamaStatsCollector (void);

+

+            virtual void create          (mamaStatsCollectorType type,

+                                          const char*            name,

+                                          const char*            middleware);

+

+            virtual void incrementStat   (mama_fid_t             identifier);

+

+            virtual void setName         (const char*            name);

+

+            virtual void setLog          (int                    log);

+

+            virtual void setPublish      (int                    publish);

+

+            virtual void destroy         (void);

+

+            virtual mamaStatsCollector  getStatsCollector       ();

+

+        protected:

+            MamaStatsCollector      (MamaStatsCollectorImpl*);

+

+            MamaStatsCollectorImpl* mSimpl;

+    };

+

+} // namespace Wombat

+

+#endif //MAMA_STATS_COLLECTOR_CPP_H__

--

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.


[PATCH 1/2] [mama] Iterator operator added

Ian Bell <IBell@...>
 

From 47121238854a5b7c5049bf869c7cb28c11404552 Mon Sep 17 00:00:00 2001

Message-Id: <47121238854a5b7c5049bf869c7cb28c11404552.1348677184.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 17:31:35 +0100

Subject: [PATCH 1/2] [mama] Iterator operator added

 

Added -> operator to msg iterator.

 

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

---

mama/c_cpp/src/cpp/MamaMsg.cpp    |    5 +++++

mama/c_cpp/src/cpp/mama/MamaMsg.h |    1 +

2 files changed, 6 insertions(+)

 

diff --git a/mama/c_cpp/src/cpp/MamaMsg.cpp b/mama/c_cpp/src/cpp/MamaMsg.cpp

index bbdb1c9..b413bef 100644

--- a/mama/c_cpp/src/cpp/MamaMsg.cpp

+++ b/mama/c_cpp/src/cpp/MamaMsg.cpp

@@ -2490,6 +2490,11 @@ void MamaMsg::method (const MamaFieldDescriptor* field, fType value)   \

         return (mMsgField);

     }

+    MamaMsgField* MamaMsgIterator::operator->()

+    {

+        return &mMsgField;

+    }

+

     MamaMsgIterator& MamaMsgIterator::operator++()

     {

         mMsgField.set (mamaMsgIterator_next((mamaMsgIterator)myImpl));

diff --git a/mama/c_cpp/src/cpp/mama/MamaMsg.h b/mama/c_cpp/src/cpp/mama/MamaMsg.h

index 4c13163..c37680c 100644

--- a/mama/c_cpp/src/cpp/mama/MamaMsg.h

+++ b/mama/c_cpp/src/cpp/mama/MamaMsg.h

@@ -65,6 +65,7 @@ namespace Wombat

        bool operator!=(const MamaMsgIterator&) const;

         MamaMsgField&    operator*();

+        MamaMsgField*    operator->();

         MamaMsgIterator& operator++();

     protected:

--

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.


[PATCH 6/6] [mama] Negative Stats support

Ian Bell <IBell@...>
 

From fdd24468d25d4796bf59dc519b8f967ceeac78d3 Mon Sep 17 00:00:00 2001

Message-Id: <fdd24468d25d4796bf59dc519b8f967ceeac78d3.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:44:03 +0100

Subject: [PATCH 6/6] [mama] Negative Stats support

 

Added ability ot handle negative interval stats

 

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

---

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

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

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

3 files changed, 7 insertions(+), 6 deletions(-)

 

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

index 5b94bb5..8ada0c8 100644

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

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

@@ -197,7 +197,7 @@ mamaStat_getTotalValue (mamaStat stat);

  */

MAMAExpDLL

extern void

-mamaStat_getStats (mamaStat stat, mama_u32_t* intervalValue, mama_u32_t* maxValue, mama_u32_t* totalValue);

+mamaStat_getStats (mamaStat stat, mama_i32_t* intervalValue, mama_u32_t* maxValue, mama_u32_t* totalValue);

 /**

  * Get the name of the stat

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

index 245917f..416a458 100644

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

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

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

     const char*         mName;

     mama_fid_t          mFid;

     mamaStatsCollector  mStatsCollector;

-    mama_u32_t          mIntervalValue;

+    mama_i32_t          mIntervalValue;

     mama_u32_t          mMaxValue;

     mama_u32_t          mTotalValue;

     int                 mLockable;

@@ -125,6 +125,7 @@ mamaStat_decrement (mamaStat stat)

     }

     impl->mIntervalValue--;

+    impl->mTotalValue--;

     if (impl->mLockable)

     {

@@ -298,7 +299,7 @@ mamaStat_getTotalValue (mamaStat stat)

}

 void

-mamaStat_getStats (mamaStat stat, mama_u32_t* intervalValue, mama_u32_t* maxValue, mama_u32_t* totalValue)

+mamaStat_getStats (mamaStat stat, mama_i32_t* intervalValue, mama_u32_t* maxValue, mama_u32_t* totalValue)

{

     mamaStatImpl* impl = (mamaStatImpl*)stat;

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

index 83ddff5..3c3147f 100644

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

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

@@ -115,7 +115,7 @@ mamaStatsCollector_populateMsg /*And string logging */ (mamaStatsCollector stats

     mama_fid_t  fid;

     const char* name = NULL;

     const char* type = NULL;

-    mama_u32_t  intervalValue = 0;

+    mama_i32_t  intervalValue = 0;

     mama_u32_t  maxValue      = 0;

     mama_u32_t  totalValue    = 0;

     int i;

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

                 name  = mamaStat_getName (impl->mMamaStats[i]);

                 mamaStat_getStats (impl->mMamaStats[i], &intervalValue, &maxValue, &totalValue);

-                mamaMsg_addU32 (msg, name, fid, intervalValue);

+                mamaMsg_addI32 (msg, name, fid, intervalValue);

             }

             if (impl->mLogStats && mamaStat_getLog (impl->mMamaStats[i]))

@@ -159,7 +159,7 @@ mamaStatsCollector_populateMsg /*And string logging */ (mamaStatsCollector stats

                 {

                     /* Stats are logged at WARN so that users don't have to enable NORMAL (or higher)

                        logging, even though they aren't actually warnings...*/

-                       mama_log (MAMA_LOG_LEVEL_WARN, "%24.24s | %9.9s | %10.10s | %15.15s | %10u | %10u | %10u |",

+                       mama_log (MAMA_LOG_LEVEL_WARN, "%24.24s | %9.9s | %10.10s | %15.15s | %10i | %10u | %10u |",

                                                       logHeader ? impl->mName : "",

                                                       logHeader ? type : "",

                                                       logHeader ? impl->mMiddleware : "",

--

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.


[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.


[PATCH 4/6] [mama] Add User Stats

Ian Bell <IBell@...>
 

From 7f06542eeec6b21b9cf1fc476be15314fc3cd0c9 Mon Sep 17 00:00:00 2001

Message-Id: <7f06542eeec6b21b9cf1fc476be15314fc3cd0c9.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:15:53 +0100

Subject: [PATCH 4/6] [mama] Add User Stats

 

Added ability to create a user stats collector object and attach stats

to it.  Mama then logs / publishes these stats along with its own

 

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

---

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

mama/c_cpp/src/c/mama/mama.h              |   13 +++++

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

mama/c_cpp/src/c/mama/statscollector.h    |    3 +-

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

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

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

7 files changed, 191 insertions(+), 21 deletions(-)

 

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

index c7b08fb..f511994 100644

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

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

@@ -101,16 +101,19 @@ int gLogQueueStats          = 1;

int gLogTransportStats      = 1;

int gLogGlobalStats         = 1;

int gLogLbmStats            = 1;

+int gLogUserStats           = 1;

 int gGenerateQueueStats     = 0;

int gGenerateTransportStats = 0;

int gGenerateGlobalStats    = 0;

int gGenerateLbmStats       = 0;

+int gGenerateUserStats       = 0;

 int gPublishQueueStats      = 0;

int gPublishTransportStats  = 0;

int gPublishGlobalStats     = 0;

int gPublishLbmStats        = 0;

+int gPublishUserStats       = 0;

 static mamaStatsLogger  gStatsPublisher  = NULL;

@@ -310,7 +313,8 @@ static int mamaInternal_statsPublishingEnabled (void)

     return (gPublishGlobalStats

          || gPublishTransportStats

          || gPublishQueueStats

-         || gPublishLbmStats);

+         || gPublishLbmStats

+         || gPublishUserStats);

}

 static mama_status

@@ -527,7 +531,7 @@ mamaInternal_enableStatsLogging (void)

         mamaStatsGenerator_addStatsCollector (gStatsGenerator, gGlobalStatsCollector);

     }

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

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

     {

         mamaStatsGenerator_setLogStats (gStatsGenerator, 1);

     }

@@ -796,41 +800,50 @@ mama_statsInit (void)

            generate stats (and neither log nor publish). */

         propVal           = properties_Get (gProperties, "mama.statslogging.global.logging");

-         if ( propVal != NULL)

+        if ( propVal != NULL)

             gLogGlobalStats = strtobool(propVal);

-          propVal           = properties_Get (gProperties, "mama.statslogging.global.publishing");

-         if ( propVal != NULL)

+        propVal           = properties_Get (gProperties, "mama.statslogging.global.publishing");

+        if ( propVal != NULL)

             gPublishGlobalStats = strtobool(propVal);

-         propVal           = properties_Get (gProperties, "mama.statslogging.transport.logging");

-         if ( propVal != NULL)

+        propVal           = properties_Get (gProperties, "mama.statslogging.transport.logging");

+        if ( propVal != NULL)

             gLogTransportStats = strtobool(propVal);

         propVal           = properties_Get (gProperties, "mama.statslogging.transport.publishing");

-         if ( propVal != NULL)

+        if ( propVal != NULL)

             gPublishTransportStats = strtobool(propVal);

-          propVal           = properties_Get (gProperties, "mama.statslogging.queue.logging");

-         if ( propVal != NULL)

+        propVal           = properties_Get (gProperties, "mama.statslogging.queue.logging");

+        if ( propVal != NULL)

             gLogQueueStats = strtobool(propVal);

-          propVal           = properties_Get (gProperties, "mama.statslogging.queue.publishing");

-         if ( propVal != NULL)

+        propVal           = properties_Get (gProperties, "mama.statslogging.queue.publishing");

+        if ( propVal != NULL)

             gPublishQueueStats = strtobool(propVal);

         propVal           = properties_Get (gProperties, "mama.statslogging.lbm.logging");

-         if ( propVal != NULL)

+        if ( propVal != NULL)

             gLogLbmStats = strtobool(propVal);

-          propVal           = properties_Get (gProperties, "mama.statslogging.lbm.publishing");

-         if ( propVal != NULL)

+        propVal           = properties_Get (gProperties, "mama.statslogging.lbm.publishing");

+        if ( propVal != NULL)

             gPublishLbmStats = strtobool(propVal);

+        propVal           = properties_Get (gProperties, "mama.statslogging.user.logging");

+        if ( propVal != NULL)

+            gLogUserStats = strtobool(propVal);

+

+        propVal           = properties_Get (gProperties, "mama.statslogging.user.publishing");

+        if ( propVal != NULL)

+            gPublishUserStats = strtobool(propVal);

+       

         if (gLogGlobalStats || gPublishGlobalStats) gGenerateGlobalStats=1;

         if (gLogTransportStats || gPublishTransportStats) gGenerateTransportStats=1;

         if (gLogQueueStats || gPublishQueueStats) gGenerateQueueStats=1;

         if (gLogLbmStats || gPublishLbmStats) gGenerateLbmStats=1;

+        if (gLogUserStats || gPublishUserStats) gGenerateUserStats=1;

          

         mama_setupStatsGenerator();

@@ -2071,3 +2084,49 @@ mama_setBridgeInfoCallback (mamaBridge bridgeImpl, bridgeInfoCallback callback)

     return MAMA_STATUS_OK;

}

+

+mama_status

+mama_addStatsCollector (mamaStatsCollector statsCollector)

+{

+    mama_status status = MAMA_STATUS_NOT_FOUND;

+

+    if (!gStatsGenerator)

+        mama_statsInit();

+

+    if (MAMA_STATUS_OK != (

+            status = mamaStatsGenerator_addStatsCollector (

+                        gStatsGenerator,

+                        statsCollector)))

+    {

+        mama_log (MAMA_LOG_LEVEL_ERROR, "mama_addStatsCollector (): "

+                    "Could not add User stats collector.");

+        return status;

+    }

+

+    return status;

+}

+

+mama_status

+mama_removeStatsCollector (mamaStatsCollector statsCollector)

+{

+    mama_status status = MAMA_STATUS_NOT_FOUND;

+

+    if (gStatsGenerator)

+    {

+        if (MAMA_STATUS_OK != (

+                status = mamaStatsGenerator_removeStatsCollector (

+                            mamaInternal_getStatsGenerator(),

+                            statsCollector)))

+        {

+            mama_log (MAMA_LOG_LEVEL_ERROR, "mama_removeStatsCollector (): "

+                     "Could not remove User stats collector.");

+            return status;

+        }

+    }

+    else

+    {

+        mama_log (MAMA_LOG_LEVEL_ERROR, "mamaInternal_getStatsGenerator (): "

+                  "Could not find stats generator.");

+    }

+    return status;

+}

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

index 597164f..a574f36 100644

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

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

@@ -574,6 +574,19 @@ extern "C"

     extern mama_status

     mama_setBridgeInfoCallback (mamaBridge         bridgeImpl,

                                 bridgeInfoCallback callback);

+    /**

+     * Add a user stats collector

+     */

+    MAMAExpDLL

+    extern mama_status

+    mama_addStatsCollector (mamaStatsCollector  statsCollector);

+

+    /**

+     * Remove a user stats collector

+     */

+    MAMAExpDLL

+    extern mama_status

+    mama_removeStatsCollector (mamaStatsCollector  statsCollector);

 #if defined(__cplusplus)

}

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

index 0d60c27..55b171c 100644

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

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

@@ -103,6 +103,35 @@ mamaStat_decrement (mamaStat stat);

MAMAExpDLL

extern mama_status

mamaStat_reset (mamaStat stat);

+/**

+ * Adds the stats object counter with the value

+ *

+ * @param stat  The stats object to added

+ * @param value The value to be added to be stat

+ */

+MAMAExpDLL

+extern mama_status

+mamaStat_add (mamaStat stat, int value);

+

+/**

+ * Subtract the stats object counter with the value

+ *

+ * @param stat  The stats object to subtracted

+ * @param value the value to be subtracted from stat

+ */

+MAMAExpDLL

+extern mama_status

+mamaStat_subtract (mamaStat stat, int value);

+

+/**

+ * set the Interval value

+ *

+ * @param stat  The stats object to be changed

+ * @param value the value to be used

+ */

+MAMAExpDLL

+extern mama_status

+mamaStat_setIntervalValue (mamaStat stat, int value);

 /**

  * Get the FID used when publishing the

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

index 930161c..a50405d 100644

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

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

@@ -32,7 +32,8 @@ typedef enum mamaStatsCollectorType

{

     MAMA_STATS_COLLECTOR_TYPE_QUEUE     = 0,

     MAMA_STATS_COLLECTOR_TYPE_TRANSPORT = 1,

-    MAMA_STATS_COLLECTOR_TYPE_GLOBAL    = 2

+    MAMA_STATS_COLLECTOR_TYPE_USER      = 2,

+    MAMA_STATS_COLLECTOR_TYPE_GLOBAL    = 3

} mamaStatsCollectorType;

 /**

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

index 75e41fd..a4297a2 100644

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

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

@@ -154,6 +154,71 @@ mamaStat_reset (mamaStat stat)

     return MAMA_STATUS_OK;

}

+mama_status

+mamaStat_add (mamaStat stat, int value)

+{

+    mamaStatImpl* impl = (mamaStatImpl*)stat;

+    if (!impl) return MAMA_STATUS_NULL_ARG;

+

+    if (impl->mLockable)

+        wthread_mutex_lock (&impl->mUpdateMutex);

+

+    impl->mIntervalValue += value;

+    if (impl->mIntervalValue > impl->mMaxValue)

+    {

+        impl->mMaxValue = impl->mIntervalValue;

+    }

+    impl->mTotalValue += value;

+

+    if (impl->mLockable)

+        wthread_mutex_unlock (&impl->mUpdateMutex);

+

+    return MAMA_STATUS_OK;

+}

+

+mama_status

+mamaStat_subtract (mamaStat stat, int value)

+{

+    mamaStatImpl* impl = (mamaStatImpl*)stat;

+    if (!impl) return MAMA_STATUS_NULL_ARG;

+

+    if (impl->mLockable)

+    {

+        wthread_mutex_lock (&impl->mUpdateMutex);

+    }

+

+    impl->mIntervalValue -= value;

+    impl->mTotalValue -= value;

+

+    if (impl->mLockable)

+    {

+        wthread_mutex_unlock (&impl->mUpdateMutex);

+    }

+

+    return MAMA_STATUS_OK;

+}

+

+

+mama_status

+mamaStat_setIntervalValue (mamaStat stat, int value)

+{

+      mamaStatImpl* impl = (mamaStatImpl*)stat;

+    if (!impl) return MAMA_STATUS_NULL_ARG;

+

+    if (impl->mLockable)

+    {

+        wthread_mutex_lock (&impl->mUpdateMutex);

+    }

+

+    impl->mIntervalValue = value;

+

+    if (impl->mLockable)

+    {

+        wthread_mutex_unlock (&impl->mUpdateMutex);

+    }

+

+    return MAMA_STATUS_OK;

+}

mama_fid_t

mamaStat_getFid (mamaStat stat)

{

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

index 739d6a1..83ddff5 100644

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

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

@@ -42,6 +42,7 @@ mamaStatsCollector_create (mamaStatsCollector* statsCollector, mamaStatsCollecto

     impl->mPollClosure  = NULL;

     /* Default behaviour is to log, but not publish, stats */

     impl->mPublishStats = 0;

+    impl->mOffset = 0;

     impl->mLogStats     = 1;

     memset (impl->mMamaStats, 0, MAMA_STAT_MAX_STATS*sizeof(mamaStat));

@@ -74,7 +75,8 @@ mamaStatsCollector_addStat (mamaStatsCollector statsCollector, mamaStat stat)

     mamaStatsCollectorImpl* impl = (mamaStatsCollectorImpl*)statsCollector;

     if (impl == NULL) return MAMA_STATUS_NULL_ARG;

-    index = mamaStat_getFid (stat) - MAMA_STAT_ARRAY_OFFSET;

+    if (impl->mOffset==0) impl->mOffset=mamaStat_getFid (stat);

+    index = mamaStat_getFid (stat) - impl->mOffset;

     impl->mMamaStats[index] = stat;

     return MAMA_STATUS_OK;

@@ -87,7 +89,7 @@ mamaStatsCollector_incrementStat (mamaStatsCollector statsCollector, mama_fid_t

     mamaStatsCollectorImpl* impl = (mamaStatsCollectorImpl*)statsCollector;

     if (impl == NULL) return MAMA_STATUS_NULL_ARG;

-    index = identifier - MAMA_STAT_ARRAY_OFFSET;

+    index = identifier - impl->mOffset;

     mamaStat_increment (impl->mMamaStats[index]);

     return MAMA_STATUS_OK;

@@ -100,7 +102,7 @@ mamaStatsCollector_setStatIntervalValueFromTotal (mamaStatsCollector statsCollec

     mamaStatsCollectorImpl* impl = (mamaStatsCollectorImpl*)statsCollector;

     if (impl == NULL) return MAMA_STATUS_NULL_ARG;

-    index = identifer - MAMA_STAT_ARRAY_OFFSET;

+    index = identifer - impl->mOffset;

     mamaStat_setIntervalValueFromTotal (impl->mMamaStats[index], value);

     return MAMA_STATUS_OK;

@@ -251,6 +253,7 @@ mamaStatsCollectorType_stringForType (mamaStatsCollectorType type)

     {

         case MAMA_STATS_COLLECTOR_TYPE_QUEUE     : return "Queue";

         case MAMA_STATS_COLLECTOR_TYPE_TRANSPORT : return "Transport";

+        case MAMA_STATS_COLLECTOR_TYPE_USER      : return "User";

         case MAMA_STATS_COLLECTOR_TYPE_GLOBAL    : return "Global";

         default : return "Unknown";

     }

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

index b368f60..5ee0118 100644

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

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

@@ -31,8 +31,7 @@ extern "C" {

typedef void (

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

-#define MAMA_STAT_ARRAY_OFFSET                                105

-#define MAMA_STAT_MAX_STATS                      30

+#define MAMA_STAT_MAX_STATS                     35

 typedef struct mamaStatsCollectorImpl__

{

@@ -44,6 +43,7 @@ typedef struct mamaStatsCollectorImpl__

     void*                                                mPollClosure;

     int                                                      mPublishStats;

     int                                                      mLogStats;

+     int                                                   mOffset;

     void*                                                mHandle;

} mamaStatsCollectorImpl;

--

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.


[PATCH 3/6] [mama] Modified stats startup

Ian Bell <IBell@...>
 

From ad67e1fc07c7bb007b2d76145726552aa92f9bbb Mon Sep 17 00:00:00 2001

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

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

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

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 15:44:42 +0100

Subject: [PATCH 3/6] [mama] Modified stats startup

 

Modified the stats init code to allow user to override stats properties.

 

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

---

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

1 file changed, 121 insertions(+), 185 deletions(-)

 

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

index 0db3710..c7b08fb 100644

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

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

@@ -96,14 +96,17 @@ static const char*        gEntitled = "entitled";

static const char*        gEntitled = "not entitled";

#endif /*WITH_ENTITLEMENTS */

+/* Sats Configuration*/

+int gLogQueueStats          = 1;

+int gLogTransportStats      = 1;

+int gLogGlobalStats         = 1;

+int gLogLbmStats            = 1;

+

int gGenerateQueueStats     = 0;

int gGenerateTransportStats = 0;

int gGenerateGlobalStats    = 0;

int gGenerateLbmStats       = 0;

-int gLogQueueStats          = 0;

-int gLogTransportStats      = 0;

-int gLogGlobalStats         = 0;

-int gLogLbmStats            = 0;

+

int gPublishQueueStats      = 0;

int gPublishTransportStats  = 0;

int gPublishGlobalStats     = 0;

@@ -113,6 +116,8 @@ static mamaStatsLogger  gStatsPublisher  = NULL;

 mamaStatsGenerator      gStatsGenerator         = NULL;

mamaStatsCollector      gGlobalStatsCollector   = NULL;

+

+/* Global Stats */

mamaStat                gInitialStat;

mamaStat                gRecapStat;

mamaStat                gUnknownMsgStat;

@@ -124,6 +129,9 @@ mamaStat                gWombatMsgsStat;

mamaStat                gFastMsgsStat;

mamaStat                gRvMsgsStat;

+mama_status mama_statsInit (void);

+mama_status mama_setupStatsGenerator (void);

+

int gCatchCallbackExceptions = 0;

 wproperty_t             gProperties      = 0;

@@ -297,7 +305,7 @@ mamaInternal_loadProperties (const char *path,

    gProperties =  fileProperties;

}

-static int mamaInternal_statsPublishingEnabled ()

+static int mamaInternal_statsPublishingEnabled (void)

{

     return (gPublishGlobalStats

          || gPublishTransportStats

@@ -305,38 +313,7 @@ static int mamaInternal_statsPublishingEnabled ()

          || gPublishLbmStats);

}

-static mama_status mamaInternal_loadStatsPublisher ()

-{

-    mamaBridge      bridge                  = NULL;

-    mama_status     status                  = MAMA_STATUS_OK;

-    const char*     statsLogMiddlewareName  = NULL;

-

-    statsLogMiddlewareName = properties_Get (gProperties,

-                                             "mama.statslogging.middleware");

-

-    if (!statsLogMiddlewareName)

-    {

-        statsLogMiddlewareName = "wmw";

-    }

-

-    /* Will load the bridge if its not already loaded */

-    /* Lock is alread acquired at this point */

-    if (MAMA_STATUS_OK !=

-       (status = mama_loadBridgeWithPathInternal (&bridge,

-                                                  statsLogMiddlewareName,

-                                                  NULL)))

-    {

-        mama_log (MAMA_LOG_LEVEL_ERROR,

-                  "mamaInternal_loadStatsLogger(): ",

-                  "No bridge loaded for middleware [%s]",

-                   statsLogMiddlewareName);

-        return status;

-    }

-

-    return MAMA_STATUS_OK;

-}

-

-mama_status

+static mama_status

mamaInternal_createStatsPublisher (void)

{

     mama_status     result                  = MAMA_STATUS_OK;

@@ -638,12 +615,10 @@ mama_openWithPropertiesCount (const char* path,

     mama_status     result                                                       = MAMA_STATUS_OK;

     mama_size_t     numBridges              = 0;

     mamaMiddleware  middleware              = 0;

-    mamaQueue       statsGenQueue           = NULL;

     const char*     appString               = NULL;

-    const char*     statsLogging            = "false";

-              const char*                         catchCallbackExceptions = NULL;

-    char**                                                            payloadName;

-    char*                                                               payloadId;

+    const char*                  catchCallbackExceptions = NULL;

+    char**                                           payloadName;

+    char*                                              payloadId;

     wthread_static_mutex_lock (&gImpl.myLock);

@@ -736,132 +711,7 @@ mama_openWithPropertiesCount (const char* path,

                               gCatchCallbackExceptions = 1;

               }

-    statsLogging = properties_Get (gProperties, "mama.statslogging.enable");

-

-    if ( (statsLogging != NULL) && strtobool (statsLogging))

-    {

-        const char*     globalLogging           = NULL;

-        const char*     globalPublishing        = NULL;

-        const char*     transportLogging        = NULL;

-        const char*     transportPublishing     = NULL;

-        const char*     queueLogging            = NULL;

-        const char*     queuePublishing         = NULL;

-        const char*     lbmLogging              = NULL;

-        const char*     lbmPublishing           = NULL;

-        const char*     statsIntervalStr        = NULL;

-

-        statsIntervalStr = properties_Get (gProperties,

-                                        "mama.statslogging.interval");

-

-        if (MAMA_STATUS_OK != (result = mamaStatsGenerator_create(

-                                &gStatsGenerator,

-                                statsIntervalStr ? atof (statsIntervalStr) : DEFAULT_STATS_INTERVAL)))

-        {

-            mama_log (MAMA_LOG_LEVEL_ERROR,

-                      "mama_openWithProperties(): "

-                      "Could not create stats generator.");

-            if (count)

-                *count = gImpl.myRefCount;

-           

-            wthread_static_mutex_unlock (&gImpl.myLock);

-            return result;

-        }

-

-        globalLogging           = properties_Get (gProperties, "mama.statslogging.global.logging");

-        globalPublishing        = properties_Get (gProperties, "mama.statslogging.global.publishing");

-        transportLogging        = properties_Get (gProperties, "mama.statslogging.transport.logging");

-        transportPublishing     = properties_Get (gProperties, "mama.statslogging.transport.publishing");

-        queueLogging            = properties_Get (gProperties, "mama.statslogging.queue.logging");

-        queuePublishing         = properties_Get (gProperties, "mama.statslogging.queue.publishing");

-        lbmLogging              = properties_Get (gProperties, "mama.statslogging.lbm.logging");

-        lbmPublishing           = properties_Get (gProperties, "mama.statslogging.lbm.publishing");

-

-        /* If logging has been explicitly set false, and publishing is also set false, then don't

-           generate stats (and neither log nor publish).

-

-           If logging has not been specified (or has been set true), then generate and log stats.

-           Publish stats if it has been set true. */

-        if ( globalLogging != NULL && !(strtobool(globalLogging)) )

-        {

-            if ( globalPublishing != NULL && strtobool(globalPublishing) )

-            {

-                gGenerateGlobalStats = 1;

-                gPublishGlobalStats  = 1;

-            }

-        }

-        else

-        {

-            gGenerateGlobalStats = 1;

-            gLogGlobalStats      = 1;

-

-            if ( globalPublishing != NULL && strtobool(globalPublishing) )

-            {

-                gPublishGlobalStats = 1;

-            }

-        }

-

-        if ( queueLogging != NULL && !(strtobool(queueLogging)) )

-        {

-            if ( queuePublishing != NULL && strtobool(queuePublishing) )

-            {

-                gGenerateQueueStats = 1;

-                gPublishQueueStats  = 1;

-            }

-        }

-        else

-        {

-            gGenerateQueueStats = 1;

-            gLogQueueStats      = 1;

-

-            if ( queuePublishing != NULL && strtobool(queuePublishing) )

-            {

-                gPublishQueueStats = 1;

-            }

-        }

-

-        if ( transportLogging != NULL && !(strtobool(transportLogging)) )

-        {

-            if ( transportPublishing != NULL && strtobool(transportPublishing) )

-            {

-                gGenerateTransportStats = 1;

-                gPublishTransportStats  = 1;

-            }

-        }

-        else

-        {

-            gGenerateTransportStats = 1;

-            gLogTransportStats      = 1;

-

-            if ( transportPublishing != NULL && strtobool(transportPublishing) )

-            {

-                gPublishTransportStats = 1;

-            }

-        }

-

-        if ( lbmLogging != NULL && !(strtobool(lbmLogging)) )

-        {

-            if ( lbmPublishing != NULL && strtobool(lbmPublishing) )

-            {

-                gGenerateLbmStats = 1;

-                gPublishLbmStats  = 1;

-            }

-        }

-        else

-        {

-            gGenerateLbmStats = 1;

-            gLogLbmStats      = 1;

-

-            if ( lbmPublishing != NULL && strtobool(lbmPublishing) )

-            {

-                gPublishLbmStats = 1;

-            }

-        }

-

-        if (mamaInternal_statsPublishingEnabled())

-        {

-            mamaInternal_loadStatsPublisher();

-        }

-    }

+    mama_log (MAMA_LOG_LEVEL_FINE, "%s (gEntitled)",mama_version, gEntitled);

     /* Look for a bridge for each of the middlewares and open them */

     for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)

@@ -870,7 +720,6 @@ mama_openWithPropertiesCount (const char* path,

         if (impl)

         {

             mama_log (MAMA_LOG_LEVEL_FINE, impl->bridgeGetVersion ());

-            mamaQueue_enableStats(impl->mDefaultEventQueue);

             ++numBridges;

         }

     }

@@ -922,8 +771,109 @@ mama_openWithPropertiesCount (const char* path,

     }

#endif /* WITH_ENTITLEMENTS */

-    if (strtobool(statsLogging))

+    mama_statsInit();

+

+

+    gImpl.myRefCount++;

+    if (count)

+        *count = gImpl.myRefCount;

+    wthread_static_mutex_unlock (&gImpl.myLock);

+    return result;

+}

+

+

+mama_status

+mama_statsInit (void)

+    {

+    mamaMiddleware middleware = 0;

+    char* statsLogging = (char*) properties_Get (gProperties, "mama.statslogging.enable");

+

+    if ( (statsLogging != NULL) && strtobool (statsLogging))

     {

+        const char*     propVal           = NULL;

+

+        /* If logging has been explicitly set false, and publishing is also set false, then don't

+           generate stats (and neither log nor publish). */

+

+        propVal           = properties_Get (gProperties, "mama.statslogging.global.logging");

+         if ( propVal != NULL)

+            gLogGlobalStats = strtobool(propVal);

+

+          propVal           = properties_Get (gProperties, "mama.statslogging.global.publishing");

+         if ( propVal != NULL)

+            gPublishGlobalStats = strtobool(propVal);

+

+         propVal           = properties_Get (gProperties, "mama.statslogging.transport.logging");

+         if ( propVal != NULL)

+            gLogTransportStats = strtobool(propVal);

+

+        propVal           = properties_Get (gProperties, "mama.statslogging.transport.publishing");

+         if ( propVal != NULL)

+            gPublishTransportStats = strtobool(propVal);

+

+          propVal           = properties_Get (gProperties, "mama.statslogging.queue.logging");

+         if ( propVal != NULL)

+            gLogQueueStats = strtobool(propVal);

+

+          propVal           = properties_Get (gProperties, "mama.statslogging.queue.publishing");

+         if ( propVal != NULL)

+            gPublishQueueStats = strtobool(propVal);

+

+        propVal           = properties_Get (gProperties, "mama.statslogging.lbm.logging");

+         if ( propVal != NULL)

+            gLogLbmStats = strtobool(propVal);

+

+          propVal           = properties_Get (gProperties, "mama.statslogging.lbm.publishing");

+         if ( propVal != NULL)

+            gPublishLbmStats = strtobool(propVal);

+

+        if (gLogGlobalStats || gPublishGlobalStats) gGenerateGlobalStats=1;

+        if (gLogTransportStats || gPublishTransportStats) gGenerateTransportStats=1;

+        if (gLogQueueStats || gPublishQueueStats) gGenerateQueueStats=1;

+        if (gLogLbmStats || gPublishLbmStats) gGenerateLbmStats=1;

+         

+        mama_setupStatsGenerator();

+

+        mamaInternal_enableStatsLogging();

+

+        /* Look for a bridge for each of the middlewares and open them */

+        for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)

+        {

+            mamaBridgeImpl* impl = (mamaBridgeImpl*) gImpl.myBridges [middleware];

+            if (impl)

+            {

+                mamaQueue_enableStats(impl->mDefaultEventQueue);

+            }

+        }

+    }

+

+    return MAMA_STATUS_OK;

+}

+

+mama_status

+mama_setupStatsGenerator (void)

+{

+             mama_status result = MAMA_STATUS_OK;

+

+             unsigned int*    count                                                    = NULL;

+             const char*         statsIntervalStr                 = NULL;

+             mamaQueue       statsGenQueue       = NULL;

+

+             statsIntervalStr = properties_Get (gProperties, "mama.statslogging.interval");

+

+             if (MAMA_STATUS_OK != (result = mamaStatsGenerator_create(

+                                             &gStatsGenerator,

+                                             statsIntervalStr ? atof (statsIntervalStr) : DEFAULT_STATS_INTERVAL)))

+             {

+                             mama_log (MAMA_LOG_LEVEL_ERROR,

+                                                               "mama_openWithProperties(): "

+                                                               "Could not create stats generator.");

+                             if (count)

+                                             *count = gImpl.myRefCount;

+

+                             wthread_static_mutex_unlock (&gImpl.myLock);

+                             return result;

+             }

         /* No publishing, therefore no middleware needs to be specified

            in mama.properties.  Instead, check through loaded bridges */

         if (!mamaInternal_statsPublishingEnabled())

@@ -972,22 +922,8 @@ mama_openWithPropertiesCount (const char* path,

             return result;

         }

-        if (MAMA_STATUS_OK != (result=mamaInternal_enableStatsLogging()))

-        {

-            mama_log (MAMA_LOG_LEVEL_ERROR,

-                      "mama_openWithProperties(): "

-                      "Failed to enable stats logging");

-            if (count)

-                *count = gImpl.myRefCount;

-            wthread_static_mutex_unlock (&gImpl.myLock);

-            return result;

-        }

-    }

+             mamaStatsGenerator_setLogStats (gStatsGenerator, 1);

-    gImpl.myRefCount++;

-    if (count)

-        *count = gImpl.myRefCount;

-    wthread_static_mutex_unlock (&gImpl.myLock);

     return result;

}

--

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.


[PATCH 2/6] [mama] Fix stats shutdown

Ian Bell <IBell@...>
 

From 6c7e0abf58fcca6cdf8e7f1760b4388d55153107 Mon Sep 17 00:00:00 2001

Message-Id: <6c7e0abf58fcca6cdf8e7f1760b4388d55153107.1348674366.git.ibell@...>

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

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

From: Ian Bell <ibell@...>

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

Subject: [PATCH 2/6] [mama] Fix stats shutdown

 

Modified the stats shutdown code to avoid a core on shutdown

 

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

---

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

1 file changed, 23 insertions(+), 37 deletions(-)

 

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

index d6ca7fa..0db3710 100644

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

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

@@ -1144,41 +1144,12 @@ mama_closeCount (unsigned int* count)

             mamaStatsGenerator_stopReportTimer(gStatsGenerator);

         }

-        if (gGlobalStatsCollector)

-        {

-            if (gStatsGenerator)

-            {

-                mamaStatsGenerator_removeStatsCollector (gStatsGenerator, gGlobalStatsCollector);

-            }

-            mamaStatsCollector_destroy (gGlobalStatsCollector);

-            gGlobalStatsCollector = NULL;

-        }

-

-        if (gStatsPublisher)

-        {

-            mamaStatsLogger_destroy (gStatsPublisher);

-            gStatsPublisher = NULL;

-        }

         for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)

         {

             mamaBridge bridge = gImpl.myBridges[middleware];

             if (bridge)

                mamaBridgeImpl_stopInternalEventQueue (bridge);

         }

-        /* Look for a bridge for each of the payloads and close them */

-        for (payload = 0; payload != MAMA_PAYLOAD_MAX; ++payload)

-        {

-              /* mamaPayloadBridgeImpl* impl = (mamaPayloadBridgeImpl*)

-             * gImpl.myPayloads [(uint8_t)payload];*/

-            gImpl.myPayloads[(uint8_t)payload] = NULL;

-            if(gImpl.myPayloadLibraries[(uint8_t)payload])

-            {

-                closeSharedLib (gImpl.myPayloadLibraries[(uint8_t)payload]);

-                gImpl.myPayloadLibraries[(uint8_t)payload] = NULL;

-            }

-        }

-

-        gDefaultPayload = NULL;

         if (gInitialStat)

         {

@@ -1256,8 +1227,31 @@ mama_closeCount (unsigned int* count)

             gStatsPublisher = NULL;

         }

+                /* Destroy the stats generator after the bridge is closed so we will

+           have removed the default queue stats collector */

+        if (gStatsGenerator)

+        {

+            mamaStatsGenerator_destroy (gStatsGenerator);

+            gStatsGenerator = NULL;

+        }

+

         cleanupReservedFields();

+         /* Look for a bridge for each of the payloads and close them */

+        for (payload = 0; payload != MAMA_PAYLOAD_MAX; ++payload)

+        {

+             /* mamaPayloadBridgeImpl* impl = (mamaPayloadBridgeImpl*)

+             * gImpl.myPayloads [(uint8_t)payload];*/

+            gImpl.myPayloads[(uint8_t)payload] = NULL;

+            if(gImpl.myPayloadLibraries[(uint8_t)payload])

+            {

+                closeSharedLib (gImpl.myPayloadLibraries[(uint8_t)payload]);

+                gImpl.myPayloadLibraries[(uint8_t)payload] = NULL;

+            }

+        }

+       

+       gDefaultPayload = NULL;

+

         /* Look for a bridge for each of the middlewares and close them */

         for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)

         {

@@ -1285,14 +1279,6 @@ mama_closeCount (unsigned int* count)

             gProperties = 0;

         }

-        /* Destroy the stats generator after the bridge is closed so we will

-           have removed the default queue stats collector */

-        if (gStatsGenerator)

-        {

-            mamaStatsGenerator_destroy (gStatsGenerator);

-            gStatsGenerator = NULL;

-        }

-

         /* Destroy logging */

         mama_logDestroy();

--

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.


[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.


Test Email

Jacobraj Benet <JBenet@...>
 



Please consider the environment before printing this email.

Visit our website at http://www.nyse.com
*****************************************************************************
Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system. Thank you. NYSE Euronext.


Re: [PATCH] [mama] Add pre-recap cache

Ian Bell <IBell@...>
 

Small addition to patch.  Attached new version

 

 

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

index 7978c63..011436d 100644

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

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

@@ -384,6 +384,10 @@ dqStrategy_checkSeqNum (dqStrategy      strategy,

     case MAMA_MSG_TYPE_RECAP        :

     case MAMA_MSG_TYPE_BOOK_RECAP   :

+        if (mamaTransportImpl_preRecapCacheEnabled (tport))

+        {

+            self->mTryToFillGap = 1;

+        }

         mamaSubscription_unsetAllPossiblyStale (subscription);

         resetDqState (strategy, ctx);

         dqStrategyImpl_resetDqContext (ctx, seqNum, senderId);

 

 

From: openmama-dev-bounces@... [mailto:openmama-dev-bounces@...] On Behalf Of Ian Bell
Sent: 26 September 2012 12:19
To: openmama-dev@...
Subject: [Openmama-dev] [PATCH] [mama] Add pre-recap cache

 

From 257b9d3c406f7e419263ff229611f9009063d66a Mon Sep 17 00:00:00 2001

Message-Id: <257b9d3c406f7e419263ff229611f9009063d66a.1348658266.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 12:17:40 +0100

Subject: [PATCH] [mama] Add pre-recap cache

 

Modified the pre-initial cache to also work for recaps.  This is

configurable via properties.

mama.transport.%s.prerecapcache.enable=true

 

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

---

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

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

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

3 files changed, 40 insertions(+), 5 deletions(-)

 

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

index ca9db2c..fedcc49 100644

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

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

@@ -189,7 +189,8 @@ static void processPointToPointMessage (msgCallback*    callback,

     if (PRE_INITIAL_SCHEME_ON_INITIAL==

             mamaTransportImpl_getPreInitialScheme (tport))

     {

-        if (msgType==MAMA_MSG_TYPE_INITIAL || msgType == MAMA_MSG_TYPE_BOOK_INITIAL)

+        if (msgType==MAMA_MSG_TYPE_INITIAL || msgType == MAMA_MSG_TYPE_BOOK_INITIAL ||

+           (mamaTransportImpl_preRecapCacheEnabled (tport) &&  (msgType == MAMA_MSG_TYPE_RECAP || msgType == MAMA_MSG_TYPE_BOOK_RECAP )))

         {

             dqContext_applyPreInitialCache (&ctx->mDqContext, self->mSubscription);

@@ -255,6 +256,8 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

     mamaStatsCollector* queueStatsCollector = NULL;

     mamaStatsCollector* tportStatsCollector = NULL;

     const char* userSymbol = NULL;

+             dqState state = DQ_STATE_NOT_ESTABLISHED;

+    mamaSubscription_getTransport (subscription, &transport);

     if (!ctx)

     {

@@ -275,7 +278,6 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

     if (gGenerateTransportStats)

     {

-        mamaSubscription_getTransport (subscription, &transport);

         tportStatsCollector = mamaTransport_getStatsCollector (transport);

     }

@@ -446,15 +448,17 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

      */

     mamaSubscription_getExpectingInitial (subscription, &expectingInitial);

+    dqStrategy_getDqState (ctx->mDqContext, &state);

     /*While we are waiting for initial values we also check whether we have an

      * initial for an individual context.

       If we are no longer waiting for initials we assume that it is ok to pass

      on the update - (probably a new symbol for a group)*/

-    if (expectingInitial && !ctx->mInitialArrived

+    if ((expectingInitial && !ctx->mInitialArrived) ||

+        (state == DQ_STATE_WAITING_FOR_RECAP && mamaTransportImpl_preRecapCacheEnabled (transport)

         && msgType != MAMA_MSG_TYPE_DELETE

         && msgType != MAMA_MSG_TYPE_EXPIRE

-        && msgType != MAMA_MSG_TYPE_UNKNOWN)

+        && msgType != MAMA_MSG_TYPE_UNKNOWN))

     {

         /*Add this message to the cache. If the message after the initial

          * results in a gap we will attempt to fill the gap from this cache

@@ -471,7 +475,7 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

             mama_log (MAMA_LOG_LEVEL_FINE,

                            "%s%s %s%s"

                            " Subscription ignoring message received prior"

-                           " to initial update. Type: %d %s %p",

+                           " to initial or recap. Type: %d %d %p",

                            userSymbolFormatted, ctxSymbolFormatted,

                            msgType, mamaMsg_toString(msg), ctx);

         }

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

index c54a94c..b9c1a9b 100644

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

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

@@ -42,6 +42,7 @@

#include "mama/statfields.h"

#include "statsgeneratorinternal.h"

#include "mama/statscollector.h"

+#include "wombat/strutils.h"

 extern int gGenerateTransportStats;

extern int gGenerateLbmStats;

@@ -169,6 +170,7 @@ typedef struct transportImpl_

     uint8_t                 mInternal;

     uint8_t                 mDisableDisconnectCb;

     preInitialScheme         mPreInitialScheme;

+    mama_bool_t             mPreRecapCacheEnabled;

     void*                   mClosure;

} transportImpl;

@@ -449,6 +451,19 @@ static void setFtStrategy (mamaTransport transport)

     }

}

+static void enablePreRecapCache (mamaTransport transport)

+{

+    char propNameBuf[256];

+

+    if (!self) return;

+

+    snprintf (propNameBuf, 256, "mama.transport.%s.prerecapcache.enable", self->mName);

+

+    self->mPreRecapCacheEnabled = strtobool (mama_getProperty (propNameBuf));

+

+    mama_log (MAMA_LOG_LEVEL_NORMAL,

+              "%s: Pre-Recap cache %s", self->mName, self->mPreRecapCacheEnabled ? "enabled" : "disabled");

+}   

 void mamaTransport_disableRefresh(mamaTransport transport, uint8_t disable)

{

     self->mDisableRefresh=disable;

@@ -846,6 +861,7 @@ mamaTransport_create (mamaTransport transport,

     setPreInitialStrategy ((mamaTransport)self);

     setDQStrategy ((mamaTransport)self);

     setFtStrategy ((mamaTransport)self);

+    enablePreRecapCache ((mamaTransport)self);

     if (mamaTransportImpl_disableDisconnectCb (name))

     {

@@ -1735,6 +1751,17 @@ mamaTransportImpl_getFtStrategyScheme (mamaTransport transport)

     }

     return DQ_FT_DO_NOT_WAIT_FOR_RECAP;

}

+

+mama_bool_t

+mamaTransportImpl_preRecapCacheEnabled (mamaTransport transport)

+{

+    if (self)

+    {

+        return self->mPreRecapCacheEnabled;

+    }

+    return 0;

+}

+

/* Process an advisory message and invokes callbacks

  *                    on all listeners.

  * @param transport The transport.

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

index ac4c3c2..764d0a0 100644

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

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

@@ -298,6 +298,10 @@ extern mama_status

mamaTransportImpl_forceClientDisconnect (mamaTransport   transport,

                                          const char*     ipAddress,

                                          uint16_t        port);

+

+extern mama_bool_t

+mamaTransportImpl_preRecapCacheEnabled (mamaTransport transport);

+

#if defined(__cplusplus)

}

#endif

--

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.




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.


[PATCH] [mama] Add pre-recap cache

Ian Bell <IBell@...>
 

From 257b9d3c406f7e419263ff229611f9009063d66a Mon Sep 17 00:00:00 2001

Message-Id: <257b9d3c406f7e419263ff229611f9009063d66a.1348658266.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 12:17:40 +0100

Subject: [PATCH] [mama] Add pre-recap cache

 

Modified the pre-initial cache to also work for recaps.  This is

configurable via properties.

mama.transport.%s.prerecapcache.enable=true

 

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

---

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

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

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

3 files changed, 40 insertions(+), 5 deletions(-)

 

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

index ca9db2c..fedcc49 100644

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

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

@@ -189,7 +189,8 @@ static void processPointToPointMessage (msgCallback*    callback,

     if (PRE_INITIAL_SCHEME_ON_INITIAL==

             mamaTransportImpl_getPreInitialScheme (tport))

     {

-        if (msgType==MAMA_MSG_TYPE_INITIAL || msgType == MAMA_MSG_TYPE_BOOK_INITIAL)

+        if (msgType==MAMA_MSG_TYPE_INITIAL || msgType == MAMA_MSG_TYPE_BOOK_INITIAL ||

+           (mamaTransportImpl_preRecapCacheEnabled (tport) &&  (msgType == MAMA_MSG_TYPE_RECAP || msgType == MAMA_MSG_TYPE_BOOK_RECAP )))

         {

             dqContext_applyPreInitialCache (&ctx->mDqContext, self->mSubscription);

@@ -255,6 +256,8 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

     mamaStatsCollector* queueStatsCollector = NULL;

     mamaStatsCollector* tportStatsCollector = NULL;

     const char* userSymbol = NULL;

+             dqState state = DQ_STATE_NOT_ESTABLISHED;

+    mamaSubscription_getTransport (subscription, &transport);

     if (!ctx)

     {

@@ -275,7 +278,6 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

     if (gGenerateTransportStats)

     {

-        mamaSubscription_getTransport (subscription, &transport);

         tportStatsCollector = mamaTransport_getStatsCollector (transport);

     }

@@ -446,15 +448,17 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

      */

     mamaSubscription_getExpectingInitial (subscription, &expectingInitial);

+    dqStrategy_getDqState (ctx->mDqContext, &state);

     /*While we are waiting for initial values we also check whether we have an

      * initial for an individual context.

       If we are no longer waiting for initials we assume that it is ok to pass

      on the update - (probably a new symbol for a group)*/

-    if (expectingInitial && !ctx->mInitialArrived

+    if ((expectingInitial && !ctx->mInitialArrived) ||

+        (state == DQ_STATE_WAITING_FOR_RECAP && mamaTransportImpl_preRecapCacheEnabled (transport)

         && msgType != MAMA_MSG_TYPE_DELETE

         && msgType != MAMA_MSG_TYPE_EXPIRE

-        && msgType != MAMA_MSG_TYPE_UNKNOWN)

+        && msgType != MAMA_MSG_TYPE_UNKNOWN))

     {

         /*Add this message to the cache. If the message after the initial

          * results in a gap we will attempt to fill the gap from this cache

@@ -471,7 +475,7 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

             mama_log (MAMA_LOG_LEVEL_FINE,

                            "%s%s %s%s"

                            " Subscription ignoring message received prior"

-                           " to initial update. Type: %d %s %p",

+                           " to initial or recap. Type: %d %d %p",

                            userSymbolFormatted, ctxSymbolFormatted,

                            msgType, mamaMsg_toString(msg), ctx);

         }

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

index c54a94c..b9c1a9b 100644

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

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

@@ -42,6 +42,7 @@

#include "mama/statfields.h"

#include "statsgeneratorinternal.h"

#include "mama/statscollector.h"

+#include "wombat/strutils.h"

 extern int gGenerateTransportStats;

extern int gGenerateLbmStats;

@@ -169,6 +170,7 @@ typedef struct transportImpl_

     uint8_t                 mInternal;

     uint8_t                 mDisableDisconnectCb;

     preInitialScheme         mPreInitialScheme;

+    mama_bool_t             mPreRecapCacheEnabled;

     void*                   mClosure;

} transportImpl;

@@ -449,6 +451,19 @@ static void setFtStrategy (mamaTransport transport)

     }

}

+static void enablePreRecapCache (mamaTransport transport)

+{

+    char propNameBuf[256];

+

+    if (!self) return;

+

+    snprintf (propNameBuf, 256, "mama.transport.%s.prerecapcache.enable", self->mName);

+

+    self->mPreRecapCacheEnabled = strtobool (mama_getProperty (propNameBuf));

+

+    mama_log (MAMA_LOG_LEVEL_NORMAL,

+              "%s: Pre-Recap cache %s", self->mName, self->mPreRecapCacheEnabled ? "enabled" : "disabled");

+}   

 void mamaTransport_disableRefresh(mamaTransport transport, uint8_t disable)

{

     self->mDisableRefresh=disable;

@@ -846,6 +861,7 @@ mamaTransport_create (mamaTransport transport,

     setPreInitialStrategy ((mamaTransport)self);

     setDQStrategy ((mamaTransport)self);

     setFtStrategy ((mamaTransport)self);

+    enablePreRecapCache ((mamaTransport)self);

     if (mamaTransportImpl_disableDisconnectCb (name))

     {

@@ -1735,6 +1751,17 @@ mamaTransportImpl_getFtStrategyScheme (mamaTransport transport)

     }

     return DQ_FT_DO_NOT_WAIT_FOR_RECAP;

}

+

+mama_bool_t

+mamaTransportImpl_preRecapCacheEnabled (mamaTransport transport)

+{

+    if (self)

+    {

+        return self->mPreRecapCacheEnabled;

+    }

+    return 0;

+}

+

/* Process an advisory message and invokes callbacks

  *                    on all listeners.

  * @param transport The transport.

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

index ac4c3c2..764d0a0 100644

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

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

@@ -298,6 +298,10 @@ extern mama_status

mamaTransportImpl_forceClientDisconnect (mamaTransport   transport,

                                          const char*     ipAddress,

                                          uint16_t        port);

+

+extern mama_bool_t

+mamaTransportImpl_preRecapCacheEnabled (mamaTransport transport);

+

#if defined(__cplusplus)

}

#endif

--

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.


[PATCH 6/6] [mama] Moved IssueSymbol delete

Ian Bell <IBell@...>
 

From 0487c0c7c7101e484418306b80017a26822f1b23 Mon Sep 17 00:00:00 2001

Message-Id: <0487c0c7c7101e484418306b80017a26822f1b23.1348657454.git.ibell@...>

In-Reply-To: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

References: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 11:59:26 +0100

Subject: [PATCH 6/6] [mama] Moved IssueSymbol delete

 

delayed the delete of the IssueSymbol in a subscirption so that it

is available during the onDestroy callback.

 

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

---

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

1 file changed, 6 insertions(+), 6 deletions(-)

 

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

index a13e499..b3f814c 100644

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

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

@@ -1470,12 +1470,6 @@ void mamaSubscriptionImpl_cleanup(mamaSubscriptionImpl *impl)

         impl->mUserSymbol = NULL;

     }

-    /* The subscription symbol. */

-    if(NULL != impl->mSubscSymbol)

-    {

-        free(impl->mSubscSymbol);

-        impl->mSubscSymbol = NULL;

-    }

}

 

@@ -1834,6 +1828,12 @@ void mamaSubscriptionImpl_deallocate(mamaSubscriptionImpl *impl)

     /* Destroy the state. */

        wInterlocked_destroy(&impl->mState);

+    /* The subscription symbol. */

+    if(NULL != impl->mSubscSymbol)

+    {

+        free(impl->mSubscSymbol);

+        impl->mSubscSymbol = NULL;

+    }

     /* Free the subscription impl. */

     free(impl);

}

--

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.


[PATCH 5/6] [mama] Warnings fixes

Ian Bell <IBell@...>
 

From 8250a8224a3453dde3a2fb700120934fa4ebfc70 Mon Sep 17 00:00:00 2001

Message-Id: <8250a8224a3453dde3a2fb700120934fa4ebfc70.1348657454.git.ibell@...>

In-Reply-To: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

References: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 11:54:11 +0100

Subject: [PATCH 5/6] [mama] Warnings fixes

 

Fixed some warnings in listenermsgcallback

 

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

---

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

1 file changed, 4 insertions(+), 4 deletions(-)

 

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

index 9630b39..ca9db2c 100644

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

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

@@ -50,7 +50,7 @@ void listenerMsgCallback_invokeErrorCallback(listenerMsgCallback callback,

         SubjectContext *ctx, mama_status mamaStatus, mamaSubscription

         subscription, const char *userSymbol);

-void listenerMsgCallbackImpl_logUnknownStatus(SubjectContext *ctx, int status,

+void listenerMsgCallbackImpl_logUnknownStatus(SubjectContext *ctx, mamaMsgStatus status,

         mamaSubscription subscription);

 /**

@@ -246,7 +246,7 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

                                 SubjectContext *ctx)

{

     int               msgType           = mamaMsgType_typeForMsg (msg);

-    int               status            = mamaMsgImpl_getStatusFromMsg (msg);

+    mamaMsgStatus     status            = mamaMsgImpl_getStatusFromMsg (msg);

     msgCallback*      impl              = (msgCallback*)callback;

     mamaSubscription  subscription      = impl->mSubscription;

     int               expectingInitial  = 0;

@@ -369,7 +369,7 @@ listenerMsgCallback_processMsg( listenerMsgCallback callback, mamaMsg msg,

                     (*(mamaInternal_getGlobalStatsCollector()),

                      MamaStatUnknownMsgs.mFid);

             }

-            return; //throw away msg

+            return; /* throw away msg */

             break;

         }

         default:

@@ -621,7 +621,7 @@ checkEntitlement( msgCallback *callback, mamaMsg msg, SubjectContext* ctx )

#endif /* WITH_ENTITLEMENTS */

}

-void listenerMsgCallbackImpl_logUnknownStatus(SubjectContext *ctx, int status,

+void listenerMsgCallbackImpl_logUnknownStatus(SubjectContext *ctx, mamaMsgStatus status,

         mamaSubscription subscription)

{

     /* Write the log at fine level. */

--

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.


[PATCH 4/6] [mama] Fixed ft destroy

Ian Bell <IBell@...>
 

From 1d28c3c3bc4ff0451050efb225143cf8dfaa5d16 Mon Sep 17 00:00:00 2001

Message-Id: <1d28c3c3bc4ff0451050efb225143cf8dfaa5d16.1348657454.git.ibell@...>

In-Reply-To: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

References: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 11:51:02 +0100

Subject: [PATCH 4/6] [mama] Fixed ft destroy

 

This patch addresses some issues in destroying an ftmember instance.

 

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

---

mama/c_cpp/src/c/ft.c |   23 +++++++++++++++++------

1 file changed, 17 insertions(+), 6 deletions(-)

 

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

index f73ab2b..c5b2c85 100644

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

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

@@ -322,7 +322,11 @@ mamaFtMember_deactivate (

         return ret;

     /* cancel timer. */

+    if (impl->myHeartbeatTimer)

+    {

     mamaTimer_destroy (impl->myHeartbeatTimer);

+        impl->myHeartbeatTimer=NULL;

+    }

     stopTimeoutTimer (impl);

     impl->myIsActive = 0;

     impl->myIncarnation = 0;

@@ -624,7 +628,7 @@ ftHeartbeatTimerCb (mamaTimer          timer,

                          void*              closure)

{

     mamaFtMemberImpl* impl = (mamaFtMemberImpl*)closure;

-    mama_log (MAMA_LOG_LEVEL_FINE, "MAMA multicast FT: heartbeat timer has fired");

+    mama_log (MAMA_LOG_LEVEL_FINEST, "MAMA multicast FT: heartbeat timer has fired");

     impl->myHeartbeatTick++;

     impl->ftSendHeartbeat (impl);

}

@@ -666,8 +670,11 @@ mama_status stopTimeoutTimer (mamaFtMemberImpl* impl)

{

     mama_status status;

     mama_log (MAMA_LOG_LEVEL_FINE, "MAMA FT: stopping timeout timer");

-    status = mamaTimer_destroy (impl->myTimeoutTimer);

-    impl->myTimeoutTimer = NULL;

+    if (impl->myTimeoutTimer)

+    {

+        status = mamaTimer_destroy (impl->myTimeoutTimer);

+        impl->myTimeoutTimer = NULL;

+    }

     return status;

}

@@ -677,6 +684,7 @@ mama_status resetTimeoutTimer (mamaFtMemberImpl* impl)

     return mamaTimer_reset (impl->myTimeoutTimer);

}

+static

int mamaBetterCredentials (mamaFtMemberImpl*  impl, unsigned int weight,

                                                                                  unsigned int incarnation, in_addr_t ipAddr, int pid)

{

@@ -729,14 +737,14 @@ void mamaCheckHeartbeat (mamaFtMemberImpl*  impl,

     if ((hbPid == impl->myPid) && (hbIpAddr == impl->myIP))

     {

         /* We sent this one ourselves. */

-         mama_log (MAMA_LOG_LEVEL_FINER, "MAMA multicast FT: received own heartbeat");

+         mama_log (MAMA_LOG_LEVEL_FINEST, "MAMA multicast FT: received own heartbeat");

         return;

     }

 

     if (mamaBetterCredentials(impl, hbWeight,hbIncarnation,hbIpAddr,hbPid) == 0)

     {

-        mama_log (MAMA_LOG_LEVEL_FINER,

+        mama_log (MAMA_LOG_LEVEL_FINEST,

                                   "MAMA NATIVE FT: received heartbeat");

         if (hbIncarnation >= impl->myNextIncarnation)

@@ -751,7 +759,7 @@ void mamaCheckHeartbeat (mamaFtMemberImpl*  impl,

     }

     else

     {

-        mama_log (MAMA_LOG_LEVEL_FINER,

+        mama_log (MAMA_LOG_LEVEL_FINEST,

                 "MAMA NATIVE FT: received heartbeat from an instance with lower"

                   " priority (ignored)");

         return ;

@@ -1086,7 +1094,10 @@ mama_status multicastFt_deactivate (mamaFtMember member)

     {

         /* unsubscribe from io */

         if (gReadHandler != NULL)

+        {

             mamaIo_destroy (gReadHandler);

+            gReadHandler = NULL;

+        }

     }

     return MAMA_STATUS_OK;

--

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.


[PATCH 3/6] [mama] Fix wait for recap ft scheme

Ian Bell <IBell@...>
 

From 5e6c7fee601d04dc82de2b3d86fb61576671e5fd Mon Sep 17 00:00:00 2001

Message-Id: <5e6c7fee601d04dc82de2b3d86fb61576671e5fd.1348657454.git.ibell@...>

In-Reply-To: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

References: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 11:47:58 +0100

Subject: [PATCH 3/6] [mama] Fix wait for recap ft scheme

 

Fixed an issue where messages were forwarded during an ft takeover when

the WAIT_FOR_RECAP scheme was active

 

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

---

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

1 file changed, 15 insertions(+), 11 deletions(-)

 

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

index 6dbf4bb..7978c63 100644

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

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

@@ -154,7 +154,7 @@ handleFTTakeover (dqStrategy        strategy,

     if (recoverOnRecap)

     {

-        ctx->mSeqNum = senderId;

+        ctx->mSeqNum = seqNum;

         ctx->mDQState = DQ_STATE_WAITING_FOR_RECAP_AFTER_FT;

     }

     else

@@ -219,6 +219,7 @@ dqStrategy_checkSeqNum (dqStrategy      strategy,

         }

         if (DQ_FT_WAIT_FOR_RECAP==mamaTransportImpl_getFtStrategyScheme(tport))

         {

+            ctx->mDoNotForward = 1;

             handleFTTakeover (strategy, msg, msgType, ctx, seqNum, senderId, 1);

         }

         else

@@ -227,12 +228,12 @@ dqStrategy_checkSeqNum (dqStrategy      strategy,

         }

     }

-    if (gMamaLogLevel >= MAMA_LOG_LEVEL_FINER)

+    if (gMamaLogLevel >= MAMA_LOG_LEVEL_FINEST)

     {

         const char*  symbol = NULL;

         mamaSubscription_getSymbol (subscription, &symbol);

         symbol = symbol == NULL ? "" : symbol;

-        mama_log (MAMA_LOG_LEVEL_FINER,

+        mama_log (MAMA_LOG_LEVEL_FINEST,

                   "dqStrategy_checkSeqNum(): %s : seq# %ld",

                   symbol,

                   seqNum);

@@ -276,14 +277,16 @@ dqStrategy_checkSeqNum (dqStrategy      strategy,

             /* If the sequence numbers for a message are correct then the

                subscription is OK. */

                

-        msgStatus = mamaMsgStatus_statusForMsg (msg);

-        /* Check the status of the message.  If it is stale,

-           do not request a recap and do not set status OK. */

-        if (msgStatus == MAMA_MSG_STATUS_OK)

-            resetDqState (strategy, ctx);

-

-            ctx->mSeqNum = seqNum;

-            return MAMA_STATUS_OK;

+            msgStatus = mamaMsgStatus_statusForMsg (msg);

+            /* Check the status of the message.  If it is stale,

+               do not request a recap and do not set status OK. */

+            if (msgStatus == MAMA_MSG_STATUS_OK)

+                                 {

+                resetDqState (strategy, ctx);

+

+                ctx->mSeqNum = seqNum;

+                return MAMA_STATUS_OK;

+            }

         }

         /* For late joins or middlewares that support a publish cache, it is possible that you will get old updates

@@ -384,6 +387,7 @@ dqStrategy_checkSeqNum (dqStrategy      strategy,

         mamaSubscription_unsetAllPossiblyStale (subscription);

         resetDqState (strategy, ctx);

         dqStrategyImpl_resetDqContext (ctx, seqNum, senderId);

+        ctx->mDoNotForward = 0;

         return MAMA_STATUS_OK;

     case MAMA_MSG_TYPE_DDICT_SNAPSHOT : /*No DQ checking for Datadictionary*/

         return MAMA_STATUS_OK;

--

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.


[PATCH 2/6] [mama] Rethread Quality callback

Ian Bell <IBell@...>
 

From ba6d46d3c1c54571f32ddb79593ed78b53e7e21c Mon Sep 17 00:00:00 2001

Message-Id: <ba6d46d3c1c54571f32ddb79593ed78b53e7e21c.1348657454.git.ibell@...>

In-Reply-To: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

References: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 11:34:46 +0100

Subject: [PATCH 2/6] [mama] Rethread Quality callback

 

The subscription OnQuality callback always fired off the transport thread

due to a disconnect, and off the subscription thread due to a gap.  This

patch re-enqueues the callback for transport disconnect so that all

subscription callacks happen from the subscription thread.

 

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

---

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

1 file changed, 12 insertions(+), 1 deletion(-)

 

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

index 5319999..c54a94c 100644

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

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

@@ -1678,11 +1678,22 @@ mamaTransportImpl_getTransportTopicCallback (mamaTransport transport,

}

 static void

+staleEventCallback (mamaQueue queue, void* closure)

+{

+    mamaSubscription sub = (mamaSubscription) closure;

+    mamaSubscription_setPossiblyStale (sub);

+}

+

+static void

setStaleListenerIterator (wList list, void* element, void* closure)

{

     SubscriptionInfo* subsc = (SubscriptionInfo*)element;

     if (mamaSubscription_isTportDisconnected (subsc->mSubscription))

-            mamaSubscription_setPossiblyStale (subsc->mSubscription);

+    {

+            mamaQueue queue = NULL;

+            mamaSubscription_getQueue (subsc->mSubscription, &queue);

+            mamaQueue_enqueueEvent (queue, (mamaQueueEventCB)staleEventCallback, subsc->mSubscription);

+    }

}

 static void

--

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.


[PATCH 1/6] [mama] Add transport closure

Ian Bell <IBell@...>
 

From 6456222f7ea01be922ce869d84b615bcc03cc79c Mon Sep 17 00:00:00 2001

Message-Id: <6456222f7ea01be922ce869d84b615bcc03cc79c.1348657454.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Wed, 26 Sep 2012 11:31:13 +0100

Subject: [PATCH 1/6] [mama] Add transport closure

 

Added a get/set closure on a transport

 

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

---

mama/c_cpp/src/c/mama/transport.h |   22 ++++++++++++++++++++++

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

2 files changed, 44 insertions(+)

 

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

index 6a31570..d7f06ef 100644

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

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

@@ -600,6 +600,28 @@ MAMAExpDLL

extern mamaStatsCollector*

mamaTransport_getStatsCollector (mamaTransport transport);

+/**

+ * Return the closure.

+ *

+ * @param transport The transport.

+ * @param closure holds the result.

+ */

+MAMAExpDLL

+extern mama_status

+mamaTransport_getClosure (mamaTransport transport,

+                          void**        closure);

+

+/**

+ * Set a closure.

+ *

+ * @param transport The transport.

+ * @param closure holds the closure to be added.

+ */

+MAMAExpDLL

+extern mama_status

+mamaTransport_setClosure (mamaTransport transport,

+                          void*         closure);

+

#if defined(__cplusplus)

}

#endif

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

index ae1ffca..5319999 100644

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

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

@@ -169,6 +169,7 @@ typedef struct transportImpl_

     uint8_t                 mInternal;

     uint8_t                 mDisableDisconnectCb;

     preInitialScheme         mPreInitialScheme;

+    void*                   mClosure;

} transportImpl;

 static mama_status

@@ -186,6 +187,7 @@ init (transportImpl* transport, int createResponder)

     self->mDQStratScheme    = DQ_SCHEME_DELIVER_ALL;

     self->mFTStratScheme    = DQ_FT_DO_NOT_WAIT_FOR_RECAP;

+    self->mClosure          = NULL;

     mama_log (MAMA_LOG_LEVEL_FINEST,

              "%screating CmResponder for transport [%s]",

@@ -2452,6 +2454,26 @@ void mamaTransportImpl_invokeTransportCallback (mamaTransport transport,

     }

}

+mama_status

+mamaTransport_setClosure (mamaTransport transport, void* closure)

+{

+    if (!self) return MAMA_STATUS_NULL_ARG;

+

+    self->mClosure = closure;

+

+    return MAMA_STATUS_OK;

+}

+

+mama_status

+mamaTransport_getClosure (mamaTransport transport, void** closure)

+{

+    if ((!self) || (!closure))

+        return MAMA_STATUS_NULL_ARG;

+

+    *closure = self->mClosure;

+

+    return MAMA_STATUS_OK;

+}

/* *************************************************** */

/* Private Functions. */

/* *************************************************** */

--

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.


[PATCH] [mama] Extend startcallback

Ian Bell <IBell@...>
 

From c4030019d9d2fdc57288a60b63214d26dfd10f62 Mon Sep 17 00:00:00 2001

Message-Id: <c4030019d9d2fdc57288a60b63214d26dfd10f62.1348588330.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Tue, 25 Sep 2012 16:51:43 +0100

Subject: [PATCH] [mama] Extend startcallback

 

Added a new version of htestart callback called stop callback

as its more accurate.  Also extended it to take a closure so

that a different callback can be called for each bridge.  It

also passes back the bridge in teh callback.

 

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

---

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

mama/c_cpp/src/c/mama/mama.h     |   30 +++++++++++++++++++++

mama/c_cpp/src/c/transportimpl.h |    5 ++++

mama/c_cpp/src/cpp/mamacpp.cpp   |   12 +++------

4 files changed, 80 insertions(+), 21 deletions(-)

 

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

index 9218aee..78ecc92 100644

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

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

@@ -44,6 +44,7 @@

#include <statsgeneratorinternal.h>

#include <statsgeneratorinternal.h>

#include <mama/statscollector.h>

+#include "transportimpl.h"

 #define PROPERTY_FILE "mama.properties"

#define WOMBAT_PATH_ENV "WOMBAT_PATH"

@@ -1360,13 +1361,14 @@ mama_start (mamaBridge bridgeImpl)

 struct startBackgroundClosure

{

-    mamaStartCB mStartCallback;

-    mamaBridge  mBridgeImpl;

+    mamaStopCB   mStopCallback;

+    mamaStopCBEx mStopCallbackEx;

+    mamaBridge   mBridgeImpl;

+    void*        mClosure;

};

 static void* mamaStartThread (void* closure)

{

-    /* size_t cast prevents compiler warning */

     struct startBackgroundClosure* cb =

                 (struct startBackgroundClosure*)closure;

     mama_status rval = MAMA_STATUS_OK;

@@ -1375,7 +1377,11 @@ static void* mamaStartThread (void* closure)

     rval = mama_start (cb->mBridgeImpl);

-    cb->mStartCallback (rval);

+    if (cb->mStopCallback)

+        cb->mStopCallback (rval);

+

+    if (cb->mStopCallbackEx)

+        cb->mStopCallbackEx (rval, cb->mBridgeImpl, cb->mClosure);

     /* Free the closure object */

     free(cb);

@@ -1383,24 +1389,33 @@ static void* mamaStartThread (void* closure)

     return NULL;

}

-mama_status

-mama_startBackground (mamaBridge   bridgeImpl,

-                      mamaStartCB callback)

+static mama_status

+mama_startBackgroundHelper (mamaBridge   bridgeImpl,

+                            mamaStopCB   callback,

+                            mamaStopCBEx exCallback,

+                            void*        closure)

{

     struct startBackgroundClosure*  closureData;

     wthread_t       t = 0;

     if (!bridgeImpl)

     {

-        mama_log (MAMA_LOG_LEVEL_ERROR, "mama_startBackground(): NULL bridge "

+        mama_log (MAMA_LOG_LEVEL_ERROR, "mama_startBackgroundHelper(): NULL bridge "

                   " impl.");

         return MAMA_STATUS_NO_BRIDGE_IMPL;

     }

-    if (!callback)

+    if (!callback && !exCallback)

+    {

+        mama_log (MAMA_LOG_LEVEL_ERROR, "mama_startBackgroundHelper(): No "

+                  "stop callback or extended stop callback specified.");

+        return MAMA_STATUS_INVALID_ARG;

+    }

+

+    if (callback && exCallback)

     {

-        mama_log (MAMA_LOG_LEVEL_ERROR, "mama_startBackground(): No "

-                  "callback specified.");

+        mama_log (MAMA_LOG_LEVEL_ERROR, "mama_startBackgroundHelper(): Both "

+                "stop callback and extended stop callback specified.");

         return MAMA_STATUS_INVALID_ARG;

     }

@@ -1409,8 +1424,10 @@ mama_startBackground (mamaBridge   bridgeImpl,

     if (!closureData)

         return MAMA_STATUS_NOMEM;

-    closureData->mStartCallback = callback;

+    closureData->mStopCallback   = callback;

+    closureData->mStopCallbackEx = exCallback;

     closureData->mBridgeImpl    = bridgeImpl;

+    closureData->mClosure        = closure;

     if (0 != wthread_create(&t, NULL, mamaStartThread, (void*) closureData))

     {

@@ -1422,6 +1439,19 @@ mama_startBackground (mamaBridge   bridgeImpl,

     return MAMA_STATUS_OK;

}

+mama_status

+mama_startBackground (mamaBridge bridgeImpl, mamaStartCB callback)

+{

+    /* Passing these NULLs tells mama_startBackgroundHelper to use old functionality */

+    return mama_startBackgroundHelper (bridgeImpl, (mamaStopCB)callback, NULL, NULL);

+}

+

+mama_status

+mama_startBackgroundEx (mamaBridge bridgeImpl, mamaStopCBEx exCallback, void* closure)

+{

+    /* Passing this NULL tells mama_StartBackgroundHelper to use new functionality */

+    return mama_startBackgroundHelper (bridgeImpl, NULL, exCallback, closure);

+}

/**

  * Stop processing messages

  */

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

index 8be6752..597164f 100644

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

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

@@ -324,9 +324,18 @@ extern "C"

     typedef void (MAMACALLTYPE *mamaStartCB) (mama_status status);

     /**

+     * Callback invoked when default thread for middleware has finished processing.

+     */

+    typedef void (MAMACALLTYPE *mamaStopCB) (mama_status);

+

+    /**

      * Start Mama in the background. This method invokes mama_start() in a

      * separate thread.

      *

+     * This API uses the deprecated mamaStartCB callback type. mama_startBackgroundEx

+     * uses the replacement type mamaStopCBEx. To retain backward compatability

+     * mama_startBackground casts callback to mamaStopCB for further processing.

+     *

      * @param bridgeImpl The bridge specific structure.

      * @param callback The callback for asynchronous status.

      * @return MAMA_STATUS_OK if successful.

@@ -335,6 +344,27 @@ extern "C"

     extern mama_status

     mama_startBackground (mamaBridge    bridgeImpl,

                           mamaStartCB   callback);

+    /**

+     * Extended stop callback that improves on mamaStopCB by including a bridge impl

+     * pointer and closure in the signature.

+     */

+    typedef void (MAMACALLTYPE *mamaStopCBEx) (mama_status, mamaBridge, void*);

+

+    /**

+     * Start Mama in the background, with extended parameters.

+     *

+     * This method performs the same functionality as mama_startBackground accept it

+     * provides the facility to pass in a closure. The C++ wrapper layer uses this

+     * version of the function, and stores the MamaStartCallback object in the closure.

+     *

+     * @param[in] bridgeImpl The bridge specific structure.

+     * @param[in] callback The extended callback for asynchronous status.

+     * @return MAMA_STATUS_OK if successful.

+     */

+    MAMAExpDLL

+    extern mama_status mama_startBackgroundEx (mamaBridge   bridgeImpl,

+                                               mamaStopCBEx callback,

+                                               void*        closure);

     /**

      * Stop dispatching on the default event queue for the specified bridge.

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

index a3115b1..ac4c3c2 100644

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

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

@@ -252,6 +252,11 @@ mama_status mamaTransport_addPublisher(mamaTransport transport, mamaPublisher pu

mama_status mamaTransport_removePublisher(mamaTransport transport, void *handle);

preInitialScheme mamaTransportImpl_getPreInitialScheme (mamaTransport transport);

+dqStartegyScheme

+mamaTransportImpl_getDqStrategyScheme (mamaTransport transport);

+

+dqftStrategyScheme

+mamaTransportImpl_getFtStrategyScheme (mamaTransport transport);

/**

  * This function will allocate an internal transport for use with the internal event queue, this sort

  * of transport is limited and does not support certain features, including

diff --git a/mama/c_cpp/src/cpp/mamacpp.cpp b/mama/c_cpp/src/cpp/mamacpp.cpp

index ddfd3a0..5494300 100644

--- a/mama/c_cpp/src/cpp/mamacpp.cpp

+++ b/mama/c_cpp/src/cpp/mamacpp.cpp

@@ -162,24 +162,18 @@ namespace Wombat

         mamaTry (mama_start (bridgeImpl));

     }

-    static MamaStartCallback* gMamaStartCallback = NULL;

-

     extern "C"

     {

-        void MAMACALLTYPE startCb (mama_status status)

+        void MAMACALLTYPE stopCb (mama_status status, mamaBridge, void* closure)

         {

-            if (gMamaStartCallback != NULL)

-            {

-                gMamaStartCallback->onStartComplete (MamaStatus (status));

-            }

+            static_cast<MamaStartCallback*>(closure)->onStartComplete(MamaStatus(status));

         }

     }

     void Mama::startBackground (mamaBridge bridgeImpl,

                                 MamaStartCallback* cb)

     {

-        gMamaStartCallback = cb;

-        mamaTry (mama_startBackground (bridgeImpl, startCb));

+        mamaTry (mama_startBackgroundEx (bridgeImpl, mamaStopCBEx(stopCb), static_cast<void*>(cb)));

     }

     void Mama::stop (mamaBridge bridgeImpl)

--

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.


[PATCH 3/3] [mama] C compiler fixes

Ian Bell <IBell@...>
 

From 83cf7354eadd3e22378782f61601f5333755af66 Mon Sep 17 00:00:00 2001

Message-Id: <83cf7354eadd3e22378782f61601f5333755af66.1348585382.git.ibell@...>

In-Reply-To: <3c8e82cf69e524a83415677a43c2161d849d10df.1348585382.git.ibell@...>

References: <3c8e82cf69e524a83415677a43c2161d849d10df.1348585382.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Tue, 25 Sep 2012 16:02:40 +0100

Subject: [PATCH 3/3] [mama] C compiler fixes

 

Fixed some compiler warnings

 

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

---

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

1 file changed, 26 insertions(+), 23 deletions(-)

 

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

index 15a153b..9218aee 100644

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

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

@@ -107,11 +107,7 @@ int gPublishQueueStats      = 0;

int gPublishTransportStats  = 0;

int gPublishGlobalStats     = 0;

int gPublishLbmStats        = 0;

-int gCatchCallbackExceptions = 0;

-

-static void lookupIPAddress (void);

-wproperty_t             gProperties      = 0;

static mamaStatsLogger  gStatsPublisher  = NULL;

 mamaStatsGenerator      gStatsGenerator         = NULL;

@@ -127,6 +123,10 @@ mamaStat                gWombatMsgsStat;

mamaStat                gFastMsgsStat;

mamaStat                gRvMsgsStat;

+int gCatchCallbackExceptions = 0;

+

+wproperty_t             gProperties      = 0;

+

static mamaPayloadBridge    gDefaultPayload = NULL;

 static wthread_key_t last_err_key;

@@ -336,7 +336,7 @@ static mama_status mamaInternal_loadStatsPublisher ()

}

 mama_status

-mamaInternal_createStatsPublisher ()

+mamaInternal_createStatsPublisher (void)

{

     mama_status     result                  = MAMA_STATUS_OK;

     mamaBridge      bridge                  = NULL;

@@ -414,7 +414,7 @@ mamaInternal_createStatsPublisher ()

}

 static mama_status

-mamaInternal_enableStatsLogging ()

+mamaInternal_enableStatsLogging (void)

{

     mama_status     result                  = MAMA_STATUS_OK;

     const char*     statsLogIntervalStr     = NULL;

@@ -631,7 +631,7 @@ mamaInternal_getDefaultPayload (void)

     return gDefaultPayload;

}

-mama_status

+static mama_status

mama_openWithPropertiesCount (const char* path,

                               const char* filename,

                               unsigned int* count)

@@ -709,8 +709,6 @@ mama_openWithPropertiesCount (const char* path,

     initReservedFields();

     mama_loginit();

-    /* Do not call mamaInternal_loadStatsPublisher here.

-       It only needs to be called if we are publishing */

     /* Look for a bridge for each of the middlewares and open them */

     for (middleware = 0; middleware != MAMA_MIDDLEWARE_MAX; ++middleware)

     {

@@ -720,7 +718,7 @@ mama_openWithPropertiesCount (const char* path,

                                               if (impl->bridgeGetDefaultPayloadId(&payloadName, &payloadId) == MAMA_STATUS_OK)

                                               {

                                                               uint8_t i=0;

-                                                              while (payloadId[i] != NULL)

+                                                             while (payloadId[i] != '\0')

                                                               {

                                                                               if (!gImpl.myPayloads [(uint8_t)payloadId[i]])

                                                                               {

@@ -872,7 +870,7 @@ mama_openWithPropertiesCount (const char* path,

         mamaBridgeImpl* impl = (mamaBridgeImpl*) gImpl.myBridges [middleware];

         if (impl)

         {

-            mama_log (MAMA_LOG_LEVEL_FINE, mama_getVersion (gImpl.myBridges[middleware]));

+            mama_log (MAMA_LOG_LEVEL_FINE, impl->bridgeGetVersion ());

             mamaQueue_enableStats(impl->mDefaultEventQueue);

             ++numBridges;

         }

@@ -952,7 +950,7 @@ mama_openWithPropertiesCount (const char* path,

                 statsMiddleware = "wmw";

             }

-            bridge = gImpl.myBridges[mamaMiddleware_convertFromString (statsMiddleware)];

+                                 mama_loadBridge(&bridge, statsMiddleware);

             if (MAMA_STATUS_OK != (result = mamaBridgeImpl_getInternalEventQueue (bridge,

                                                                &statsGenQueue)))

@@ -1114,7 +1112,7 @@ mama_getVersion (mamaBridge bridgeImpl)

     return mama_ver_string;

}

-mama_status

+static mama_status

mama_closeCount (unsigned int* count)

{

     mama_status    result     = MAMA_STATUS_OK;

@@ -1824,7 +1822,8 @@ mama_loadPayloadBridgeInternal  (mamaPayloadBridge* impl,

     LIB_HANDLE              bridgeLib       = NULL;

     msgPayload_createImpl   initFunc        = NULL;

     mama_status             status          = MAMA_STATUS_OK;

-    char                    payloadChar ='/0';

+    char                    payloadChar   ='\0';

+             void*                                                                     vp                                                           = NULL;

     if (!impl || !payloadName)

         return MAMA_STATUS_NULL_ARG;

@@ -1842,7 +1841,7 @@ mama_loadPayloadBridgeInternal  (mamaPayloadBridge* impl,

        mama_log (MAMA_LOG_LEVEL_ERROR,

                 "mama_loadPayloadBridge(): "

                 "Could not open payload bridge library [%s] [%s]",

-                 bridgeImplName ? bridgeImplName : "",

+                 bridgeImplName,

                  getLibError());

         wthread_static_mutex_unlock (&gImpl.myLock);

         return MAMA_STATUS_NO_BRIDGE_IMPL;

@@ -1851,15 +1850,16 @@ mama_loadPayloadBridgeInternal  (mamaPayloadBridge* impl,

     snprintf (initFuncName, 256, "%sPayload_createImpl",  payloadName);

     /* Gives a warning - casting from void* to bridge_createImpl func */

-    initFunc  = (msgPayload_createImpl) loadLibFunc (bridgeLib, initFuncName);

+             vp = loadLibFunc (bridgeLib, initFuncName);

+             initFunc  = *(msgPayload_createImpl*) &vp;

     if (!initFunc)

     {

         mama_log (MAMA_LOG_LEVEL_ERROR,

                   "mama_loadPayloadBridge(): "

                   "Could not find function [%s] in library [%s]",

-                   initFuncName ? initFuncName : "",

-                   bridgeImplName ? bridgeImplName : "");

+                   initFuncName,

+                   bridgeImplName);

         closeSharedLib (bridgeLib);

       

         wthread_static_mutex_unlock (&gImpl.myLock);

@@ -1940,6 +1940,7 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,

     bridge_createImpl   initFunc        = NULL;

     mama_status                               result                                    = MAMA_STATUS_OK;

     mamaMiddleware      middleware      = 0;

+             void*                                                     vp                                                           = NULL;

     if (!impl)

         return MAMA_STATUS_NULL_ARG;

@@ -1951,6 +1952,7 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,

         mama_log (MAMA_LOG_LEVEL_ERROR,

                   "mama_loadBridge(): Invalid middleware [%s]",

                   middlewareName);

+             return MAMA_STATUS_NO_BRIDGE_IMPL;

     }

   

     wthread_static_mutex_lock (&gImpl.myLock);

@@ -1976,7 +1978,7 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,

                 "mama_loadmamaPayload(): "

                 "Could not open middleware bridge library [%s] [%s] [%s]",

                 path,

-                bridgeImplName ? bridgeImplName : "",

+                      bridgeImplName,

                 getLibError());

         }

         else

@@ -1984,7 +1986,7 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,

                 mama_log (MAMA_LOG_LEVEL_ERROR,

                 "mama_loadmamaPayload(): "

                 "Could not open middleware bridge library [%s] [%s]",

-                bridgeImplName ? bridgeImplName : "",

+                      bridgeImplName,

                 getLibError());

         }

         wthread_static_mutex_unlock (&gImpl.myLock);

@@ -1994,15 +1996,16 @@ mama_loadBridgeWithPathInternal (mamaBridge* impl,

     snprintf (initFuncName, 256, "%sBridge_createImpl",  middlewareName);

     /* Gives a warning - casting from void* to bridge_createImpl func */

-    initFunc  = (bridge_createImpl) loadLibFunc (bridgeLib, initFuncName);

+    vp = loadLibFunc (bridgeLib, initFuncName);

+    initFunc  = *(bridge_createImpl*) &vp;

     if (!initFunc)

     {

         mama_log (MAMA_LOG_LEVEL_ERROR,

                   "mama_loadBridge(): "

                   "Could not find function [%s] in library [%s]",

-                   initFuncName ? initFuncName : "",

-                   bridgeImplName ? bridgeImplName : "");

+                   initFuncName,

+                   bridgeImplName);

         closeSharedLib (bridgeLib);

         wthread_static_mutex_unlock (&gImpl.myLock);

         return MAMA_STATUS_NO_BRIDGE_IMPL;

--

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.


[PATCH 2/3] Fix properties merge

Ian Bell <IBell@...>
 

From 582a851ec3647df2f5f994833b810a0398aaa070 Mon Sep 17 00:00:00 2001

Message-Id: <582a851ec3647df2f5f994833b810a0398aaa070.1348585382.git.ibell@...>

In-Reply-To: <3c8e82cf69e524a83415677a43c2161d849d10df.1348585382.git.ibell@...>

References: <3c8e82cf69e524a83415677a43c2161d849d10df.1348585382.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Tue, 25 Sep 2012 15:36:06 +0100

Subject: [PATCH 2/3] Fix properties merge

 

Properties set via setproperty before open take priority.

 

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

---

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

1 file changed, 8 insertions(+), 4 deletions(-)

 

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

index f7d2e2c..15a153b 100644

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

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

@@ -286,12 +286,14 @@ mamaInternal_loadProperties (const char *path,

     /* We've got file properties, so we need to merge 'em into

      * anything we've already gotten */

-    properties_Merge( gProperties, fileProperties );

+    properties_Merge( fileProperties, gProperties );

     /* Free the file properties, note that FreeEx2 is called to ensure that the data

      * isn't freed as the pointers have been copied over to gProperties.

      */

-    properties_FreeEx2(fileProperties);

+    properties_FreeEx2(gProperties);

+   

+   gProperties =  fileProperties;

}

 static int mamaInternal_statsPublishingEnabled ()

@@ -1067,12 +1069,14 @@ mama_setPropertiesFromFile (const char *path,

     /* We've got file properties, so we need to merge 'em into

      * anything we've already gotten */

-    properties_Merge( gProperties, fileProperties );

+    properties_Merge( fileProperties, gProperties );

     /* Free the file properties, note that FreeEx2 is called to ensure that the data

      * isn't freed as the pointers have been copied over to gProperties.

      */

-    properties_FreeEx2(fileProperties);

+    properties_FreeEx2(gProperties);

+   

+    gProperties = fileProperties;

     return MAMA_STATUS_OK;

}

--

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.

2021 - 2040 of 2312