You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kp...@apache.org on 2012/05/09 16:19:33 UTC

svn commit: r1336220 [5/6] - in /qpid/branches/asyncstore/cpp/src: ./ qpid/asyncStore/ qpid/asyncStore/jrnl2/ qpid/broker/ tests/ tests/storePerfTools/ tests/storePerfTools/asyncPerf/ tests/storePerfTools/common/ tests/storePerfTools/jrnlPerf/

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockPersistableQueue.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockPersistableQueue.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockPersistableQueue.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockPersistableQueue.h Wed May  9 14:19:28 2012
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file MockPersistableQueue.h
+ */
+
+#ifndef tests_storePerfTools_asyncPerf_MockPersistableQueue_h_
+#define tests_storePerfTools_asyncPerf_MockPersistableQueue_h_
+
+#include "qpid/asyncStore/AsyncOperation.h"
+#include "qpid/broker/AsyncStore.h" // qpid::broker::DataSource
+#include "qpid/broker/BrokerContext.h"
+#include "qpid/broker/PersistableQueue.h"
+#include "qpid/broker/QueueHandle.h"
+#include "qpid/sys/Condition.h"
+#include "qpid/sys/Mutex.h"
+
+#include <boost/shared_ptr.hpp>
+#include <deque>
+
+namespace qpid {
+namespace asyncStore {
+class AsyncStoreImpl;
+}
+namespace framing {
+class FieldTable;
+}}
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+class QueuedMessage;
+class TestOptions;
+
+typedef boost::shared_ptr<qpid::asyncStore::AsyncStoreImpl> AsyncStoreImplPtr;
+typedef boost::shared_ptr<QueuedMessage> QueuedMessagePtr;
+
+class MockPersistableQueue : public qpid::broker::PersistableQueue, qpid::broker::DataSource
+{
+public:
+    class QueueContext : public qpid::broker::BrokerContext
+    {
+    public:
+        QueueContext(MockPersistableQueue* q,
+                     const qpid::asyncStore::AsyncOperation::opCode op);
+        virtual ~QueueContext();
+        const char* getOp() const;
+        void destroy();
+        MockPersistableQueue* m_q;
+        const qpid::asyncStore::AsyncOperation::opCode m_op;
+    };
+
+    MockPersistableQueue(const std::string& name,
+                         const qpid::framing::FieldTable& args,
+                         AsyncStoreImplPtr store,
+                         const TestOptions& perfTestParams,
+                         const char* msgData);
+    virtual ~MockPersistableQueue();
+
+    // --- Async functionality ---
+    static void handleAsyncResult(const qpid::broker::AsyncResult* res,
+                                  qpid::broker::BrokerContext* bc);
+    qpid::broker::QueueHandle& getHandle();
+
+    // --- Performance test thread entry points ---
+    void* runEnqueues();
+    void* runDequeues();
+    static void* startEnqueues(void* ptr);
+    static void* startDequeues(void* ptr);
+
+    // --- Interface qpid::broker::Persistable ---
+    virtual void encode(qpid::framing::Buffer& buffer) const;
+    virtual uint32_t encodedSize() const;
+    virtual uint64_t getPersistenceId() const;
+    virtual void setPersistenceId(uint64_t persistenceId) const;
+
+    // --- Interface qpid::broker::PersistableQueue ---
+    virtual void flush();
+    virtual const std::string& getName() const;
+    virtual void setExternalQueueStore(qpid::broker::ExternalQueueStore* inst);
+
+    // --- Interface DataStore ---
+    virtual uint64_t getSize();
+    virtual void write(char* target);
+
+protected:
+    const std::string m_name;
+    AsyncStoreImplPtr m_store;
+    mutable uint64_t m_persistenceId;
+    std::string m_persistableData;
+    qpid::broker::QueueHandle m_queueHandle;
+
+    // Test params
+    const TestOptions& m_perfTestOpts;
+    const char* m_msgData;
+
+    typedef std::deque<QueuedMessagePtr> MsgEnqList;
+    typedef MsgEnqList::iterator MsgEnqListItr;
+    MsgEnqList m_enqueuedMsgs;
+    qpid::sys::Mutex m_enqueuedMsgsMutex;
+    qpid::sys::Condition m_dequeueCondition;
+
+    // --- Ascnc op completions (called through handleAsyncResult) ---
+    void createComplete(const QueueContext* qc);
+    void flushComplete(const QueueContext* qc);
+    void destroyComplete(const QueueContext* qc);
+
+    // --- Queue functionality ---
+    void push(QueuedMessagePtr& msg);
+    void pop(QueuedMessagePtr& msg);
+};
+
+}}} // namespace tests::storePerftools::asyncPerf
+
+#endif // tests_storePerfTools_asyncPerf_MockPersistableQueue_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockTransactionContext.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockTransactionContext.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockTransactionContext.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockTransactionContext.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file MockTransactionContext.cpp
+ */
+
+#include "MockTransactionContext.h"
+
+#include "QueuedMessage.h"
+
+#include "qpid/asyncStore/AsyncStoreImpl.h"
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+// --- Inner class MockTransactionContext::QueueContext ---
+
+MockTransactionContext::TransactionContext::TransactionContext(MockTransactionContext* tc,
+                                                               const qpid::asyncStore::AsyncOperation::opCode op) :
+        m_tc(tc),
+        m_op(op)
+{}
+
+MockTransactionContext::TransactionContext::~TransactionContext()
+{}
+
+const char*
+MockTransactionContext::TransactionContext::getOp() const
+{
+    return qpid::asyncStore::AsyncOperation::getOpStr(m_op);
+}
+
+void
+MockTransactionContext::TransactionContext::destroy()
+{
+    delete this;
+}
+
+// --- Class MockTransactionContext ---
+
+
+MockTransactionContext::MockTransactionContext(AsyncStoreImplPtr store,
+                                               const std::string& xid) :
+        m_store(store),
+        m_txnHandle(store->createTxnHandle(xid)),
+        m_prepared(false),
+        m_enqueuedMsgs()
+{
+//std::cout << "*TXN* begin: xid=" << getXid() << "; 2PC=" << (is2pc()?"T":"F") << std::endl;
+}
+
+MockTransactionContext::~MockTransactionContext()
+{}
+
+// static
+void
+MockTransactionContext::handleAsyncResult(const qpid::broker::AsyncResult* res,
+                                          qpid::broker::BrokerContext* bc)
+{
+    if (bc && res) {
+        TransactionContext* tc = dynamic_cast<TransactionContext*>(bc);
+        if (tc->m_tc) {
+            if (res->errNo) {
+                // TODO: Handle async failure here
+                std::cerr << "Transaction xid=\"" << tc->m_tc->getXid() << "\": Operation " << tc->getOp() << ": failure "
+                          << res->errNo << " (" << res->errMsg << ")" << std::endl;
+            } else {
+                // Handle async success here
+                switch(tc->m_op) {
+                case qpid::asyncStore::AsyncOperation::TXN_PREPARE:
+                    tc->m_tc->prepareComplete(tc);
+                    break;
+                case qpid::asyncStore::AsyncOperation::TXN_COMMIT:
+                    tc->m_tc->commitComplete(tc);
+                    break;
+                case qpid::asyncStore::AsyncOperation::TXN_ABORT:
+                    tc->m_tc->abortComplete(tc);
+                    break;
+                default:
+                    std::ostringstream oss;
+                    oss << "tests::storePerftools::asyncPerf::MockTransactionContext::handleAsyncResult(): Unknown async operation: " << tc->m_op;
+                    throw qpid::Exception(oss.str());
+                };
+            }
+        }
+    }
+    if (bc) delete bc;
+    if (res) delete res;
+}
+
+qpid::broker::TxnHandle&
+MockTransactionContext::getHandle()
+{
+    return m_txnHandle;
+}
+
+bool
+MockTransactionContext::is2pc() const
+{
+    return m_txnHandle.is2pc();
+}
+
+const std::string&
+MockTransactionContext::getXid() const
+{
+    return m_txnHandle.getXid();
+}
+
+void
+MockTransactionContext::addEnqueuedMsg(QueuedMessage* qm)
+{
+    qpid::sys::ScopedLock<qpid::sys::Mutex> l(m_enqueuedMsgsMutex);
+    m_enqueuedMsgs.push_back(qm);
+}
+
+void
+MockTransactionContext::prepare()
+{
+    if (m_txnHandle.is2pc()) {
+        localPrepare();
+        m_prepared = true;
+    }
+    std::ostringstream oss;
+    oss << "MockTransactionContext::prepare(): xid=\"" << getXid()
+        << "\": Transaction Error: called prepare() on local transaction";
+    throw qpid::Exception(oss.str());
+}
+
+void
+MockTransactionContext::abort()
+{
+    // TODO: Check the following XA transaction semantics:
+    // Assuming 2PC aborts can occur without a prepare. Do local prepare if not already prepared.
+    if (!m_prepared) {
+        localPrepare();
+    }
+    m_store->submitAbort(m_txnHandle,
+                         &handleAsyncResult,
+                         dynamic_cast<qpid::broker::BrokerContext*>(new TransactionContext(this, qpid::asyncStore::AsyncOperation::TXN_ABORT)));
+//std::cout << "*TXN* abort: xid=" << m_txnHandle.getXid() << "; 2PC=" << (m_txnHandle.is2pc()?"T":"F") << std::endl;
+}
+
+void
+MockTransactionContext::commit()
+{
+    if (is2pc()) {
+        if (!m_prepared) {
+            std::ostringstream oss;
+            oss << "MockTransactionContext::abort(): xid=\"" << getXid()
+                    << "\": Transaction Error: called commit() without prepare() on 2PC transaction";
+            throw qpid::Exception(oss.str());
+        }
+    } else {
+        localPrepare();
+    }
+    m_store->submitCommit(m_txnHandle,
+                          &handleAsyncResult,
+                          dynamic_cast<qpid::broker::BrokerContext*>(new TransactionContext(this, qpid::asyncStore::AsyncOperation::TXN_COMMIT)));
+//std::cout << "*TXN* commit: xid=" << m_txnHandle.getXid() << "; 2PC=" << (m_txnHandle.is2pc()?"T":"F") << std::endl;
+}
+
+
+// protected
+void
+MockTransactionContext::localPrepare()
+{
+    m_store->submitPrepare(m_txnHandle,
+                           &handleAsyncResult,
+                           dynamic_cast<qpid::broker::BrokerContext*>(new TransactionContext(this, qpid::asyncStore::AsyncOperation::TXN_PREPARE)));
+//std::cout << "*TXN* localPrepare: xid=" << m_txnHandle.getXid() << "; 2PC=" << (m_txnHandle.is2pc()?"T":"F") << std::endl;
+}
+
+// protected
+void
+MockTransactionContext::prepareComplete(const TransactionContext* /*tc*/)
+{
+    qpid::sys::ScopedLock<qpid::sys::Mutex> l(m_enqueuedMsgsMutex);
+    while (!m_enqueuedMsgs.empty()) {
+        m_enqueuedMsgs.front()->clearTransaction();
+        m_enqueuedMsgs.pop_front();
+    }
+//std::cout << "~~~~~ Transaction xid=\"" << getXid() << "\": prepareComplete()" << std::endl;
+}
+
+
+// protected
+void
+MockTransactionContext::abortComplete(const TransactionContext* /*tc*/)
+{
+//std::cout << "~~~~~ Transaction xid=\"" << getXid() << "\": abortComplete()" << std::endl;
+}
+
+
+// protected
+void
+MockTransactionContext::commitComplete(const TransactionContext* /*tc*/)
+{
+//std::cout << "~~~~~ Transaction xid=\"" << getXid() << "\": commitComplete()" << std::endl;
+}
+
+}}} // namespace tests::storePerftools::asyncPerf

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockTransactionContext.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockTransactionContext.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockTransactionContext.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/MockTransactionContext.h Wed May  9 14:19:28 2012
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file MockTransactionContext.h
+ */
+
+#ifndef tests_storePerfTools_asyncPerf_MockTransactionContext_h_
+#define tests_storePerfTools_asyncPerf_MockTransactionContext_h_
+
+#include "qpid/asyncStore/AsyncOperation.h"
+
+#include "qpid/broker/BrokerContext.h"
+#include "qpid/broker/TransactionalStore.h" // qpid::broker::TransactionContext
+#include "qpid/broker/TxnHandle.h"
+#include "qpid/sys/Mutex.h"
+
+#include <boost/shared_ptr.hpp>
+#include <deque>
+
+namespace qpid {
+namespace asyncStore {
+class AsyncStoreImpl;
+}}
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+class QueuedMessage;
+
+typedef boost::shared_ptr<qpid::asyncStore::AsyncStoreImpl> AsyncStoreImplPtr;
+
+class MockTransactionContext : public qpid::broker::TransactionContext
+{
+public:
+    // NOTE: TransactionContext - Bad naming? This context is the async return handling context for class
+    //       MockTransactionContext async ops. Other classes using this pattern simply use XXXContext for this class
+    //       (e.g. QueueContext in MockPersistableQueue), but in this case it may be confusing.
+    class TransactionContext : public qpid::broker::BrokerContext
+    {
+    public:
+        TransactionContext(MockTransactionContext* tc,
+                           const qpid::asyncStore::AsyncOperation::opCode op);
+        virtual ~TransactionContext();
+        const char* getOp() const;
+        void destroy();
+        MockTransactionContext* m_tc;
+        const qpid::asyncStore::AsyncOperation::opCode m_op;
+    };
+
+    MockTransactionContext(AsyncStoreImplPtr store,
+                           const std::string& xid = std::string());
+    virtual ~MockTransactionContext();
+    static void handleAsyncResult(const qpid::broker::AsyncResult* res,
+                                  qpid::broker::BrokerContext* bc);
+
+    qpid::broker::TxnHandle& getHandle();
+    bool is2pc() const;
+    const std::string& getXid() const;
+    void addEnqueuedMsg(QueuedMessage* qm);
+
+    void prepare();
+    void abort();
+    void commit();
+
+protected:
+    AsyncStoreImplPtr m_store;
+    qpid::broker::TxnHandle m_txnHandle;
+    bool m_prepared;
+    std::deque<QueuedMessage*> m_enqueuedMsgs;
+    qpid::sys::Mutex m_enqueuedMsgsMutex;
+
+    void localPrepare();
+
+    // --- Ascnc op completions (called through handleAsyncResult) ---
+    void prepareComplete(const TransactionContext* tc);
+    void abortComplete(const TransactionContext* tc);
+    void commitComplete(const TransactionContext* tc);
+
+};
+
+}}} // namespace tests:storePerftools::asyncPerf
+
+#endif // tests_storePerfTools_asyncPerf_MockTransactionContext_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/PerfTest.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/PerfTest.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/PerfTest.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/PerfTest.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file PerfTest.cpp
+ */
+
+#include "PerfTest.h"
+
+#include "MockPersistableQueue.h"
+
+#include "tests/storePerfTools/version.h"
+#include "tests/storePerfTools/common/ScopedTimer.h"
+#include "tests/storePerfTools/common/Thread.h"
+
+#include "qpid/asyncStore/AsyncStoreImpl.h"
+
+#include <iomanip>
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+PerfTest::PerfTest(const TestOptions& to,
+                   const qpid::asyncStore::AsyncStoreOptions& aso) :
+        m_testOpts(to),
+        m_storeOpts(aso),
+        m_testResult(to),
+        m_msgData(new char[to.m_msgSize]),
+        m_poller(new qpid::sys::Poller),
+        m_pollingThread(m_poller.get())
+{
+    std::memset((void*)m_msgData, 0, (size_t)to.m_msgSize);
+}
+
+PerfTest::~PerfTest()
+{
+    m_poller->shutdown();
+    m_pollingThread.join();
+    delete[] m_msgData;
+}
+
+AsyncStoreImplPtr
+PerfTest::prepareStore()
+{
+    AsyncStoreImplPtr store(new qpid::asyncStore::AsyncStoreImpl(m_poller, m_storeOpts));
+    store->initialize();
+    return store;
+}
+
+void
+PerfTest::prepareQueues(std::deque<MockPersistableQueuePtr>& jrnlList,
+                        AsyncStoreImplPtr store)
+{
+    for (uint16_t i = 0; i < m_testOpts.m_numQueues; ++i) {
+        std::ostringstream qname;
+        qname << "queue_" << std::setw(4) << std::setfill('0') << i;
+        MockPersistableQueuePtr mpq(new MockPersistableQueue(qname.str(), m_queueArgs, store, m_testOpts, m_msgData));
+        jrnlList.push_back(mpq);
+    }
+}
+
+void
+PerfTest::destroyQueues(std::deque<MockPersistableQueuePtr>& jrnlList)
+{
+    jrnlList.clear();
+}
+
+void
+PerfTest::run()
+{
+    typedef boost::shared_ptr<tests::storePerftools::common::Thread> ThreadPtr; // TODO - replace with qpid threads
+
+    AsyncStoreImplPtr store = prepareStore();
+
+    std::deque<MockPersistableQueuePtr> queueList;
+    prepareQueues(queueList, store);
+
+    std::deque<ThreadPtr> threads;
+    { // --- Start of timed section ---
+        tests::storePerftools::common::ScopedTimer st(m_testResult);
+
+        for (uint16_t q = 0; q < m_testOpts.m_numQueues; q++) {
+            for (uint16_t t = 0; t < m_testOpts.m_numEnqThreadsPerQueue; t++) { // TODO - replace with qpid threads
+                ThreadPtr tp(new tests::storePerftools::common::Thread(queueList[q]->startEnqueues,
+                                                                       reinterpret_cast<void*>(queueList[q].get())));
+                threads.push_back(tp);
+            }
+            for (uint16_t dt = 0; dt < m_testOpts.m_numDeqThreadsPerQueue; ++dt) { // TODO - replace with qpid threads
+                ThreadPtr tp(new tests::storePerftools::common::Thread(queueList[q]->startDequeues,
+                                                                       reinterpret_cast<void*>(queueList[q].get())));
+                threads.push_back(tp);
+            }
+        }
+        while (threads.size()) {
+            threads.front()->join();
+            threads.pop_front();
+        }
+    } // --- End of timed section ---
+
+    destroyQueues(queueList);
+// DEBUG MEASURE - REMOVE WHEN FIXED
+//::sleep(2);
+}
+
+void
+PerfTest::toStream(std::ostream& os) const
+{
+    m_testOpts.printVals(os);
+    os << std::endl;
+    m_storeOpts.printVals(os);
+    os << std::endl;
+    os << m_testResult << std::endl;
+}
+
+}}} // namespace tests::storePerftools::asyncPerf
+
+// -----------------------------------------------------------------
+
+int
+main(int argc, char** argv)
+{
+    qpid::CommonOptions co;
+    qpid::asyncStore::AsyncStoreOptions aso;
+    tests::storePerftools::asyncPerf::TestOptions to;
+    qpid::Options opts;
+    opts.add(co).add(aso).add(to);
+    try {
+        opts.parse(argc, argv);
+        aso.validate();
+        to.validate();
+    }
+    catch (std::exception& e) {
+        std::cerr << e.what() << std::endl;
+        return 1;
+    }
+
+    // Handle options that just print information then exit.
+    if (co.version) {
+        std::cout << tests::storePerftools::name() << " v." << tests::storePerftools::version() << std::endl;
+        return 0;
+    }
+    if (co.help) {
+        std::cout << tests::storePerftools::name() << ": asyncPerf" << std::endl;
+        std::cout << "Performance test for the async store through the qpid async store interface." << std::endl;
+        std::cout << "Usage: asyncPerf [options]" << std::endl;
+        std::cout << opts << std::endl;
+        return 0;
+    }
+
+    // Create and start test
+    tests::storePerftools::asyncPerf::PerfTest apt(to, aso);
+    apt.run();
+
+    // Print test result
+    std::cout << apt << std::endl;
+    ::sleep(1);
+    return 0;
+}

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/PerfTest.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/PerfTest.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/PerfTest.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/PerfTest.h Wed May  9 14:19:28 2012
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file PerfTest.h
+ */
+
+#ifndef tests_storePerfTools_asyncPerf_PerfTest_h_
+#define tests_storePerfTools_asyncPerf_PerfTest_h_
+
+#include "TestResult.h"
+
+#include "tests/storePerfTools/common/Streamable.h"
+
+#include "qpid/framing/FieldTable.h"
+#include "qpid/sys/Poller.h"
+#include "qpid/sys/Thread.h"
+
+#include <boost/shared_ptr.hpp>
+#include <deque>
+
+namespace qpid {
+namespace asyncStore {
+class AsyncStoreImpl;
+class AsyncStoreOptions;
+}}
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+class MockPersistableQueue;
+class TestOptions;
+
+typedef boost::shared_ptr<qpid::asyncStore::AsyncStoreImpl> AsyncStoreImplPtr;
+typedef boost::shared_ptr<MockPersistableQueue> MockPersistableQueuePtr;
+
+class PerfTest : public tests::storePerftools::common::Streamable
+{
+public:
+    PerfTest(const TestOptions& to,
+             const qpid::asyncStore::AsyncStoreOptions& aso);
+    virtual ~PerfTest();
+    void run();
+    void toStream(std::ostream& os = std::cout) const;
+
+protected:
+    const TestOptions& m_testOpts;
+    const qpid::asyncStore::AsyncStoreOptions& m_storeOpts;
+    TestResult m_testResult;
+    qpid::framing::FieldTable m_queueArgs;
+    const char* m_msgData;
+    boost::shared_ptr<qpid::sys::Poller> m_poller;
+    qpid::sys::Thread m_pollingThread;
+
+    AsyncStoreImplPtr prepareStore();
+    void prepareQueues(std::deque<MockPersistableQueuePtr>& jrnlList,
+                       AsyncStoreImplPtr store);
+    void destroyQueues(std::deque<MockPersistableQueuePtr>& jrnlList);
+
+};
+
+}}} // namespace tests::storePerftools::asyncPerf
+
+#endif // tests_storePerfTools_asyncPerf_PerfTest_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/QueuedMessage.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/QueuedMessage.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/QueuedMessage.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/QueuedMessage.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file QueuedMessage.cpp
+ */
+
+#include "QueuedMessage.h"
+
+#include "MockTransactionContext.h"
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+QueuedMessage::QueuedMessage(MockPersistableMessagePtr msg,
+                             qpid::broker::EnqueueHandle& enqHandle,
+                             MockTransactionContextPtr txn) :
+        m_msg(msg),
+        m_enqHandle(enqHandle),
+        m_txn(txn)
+{
+    if (txn) {
+        txn->addEnqueuedMsg(this);
+    }
+}
+
+QueuedMessage::~QueuedMessage()
+{}
+
+MockPersistableMessagePtr
+QueuedMessage::getMessage() const
+{
+    return m_msg;
+}
+
+qpid::broker::EnqueueHandle
+QueuedMessage::getEnqueueHandle() const
+{
+    return m_enqHandle;
+}
+
+MockTransactionContextPtr
+QueuedMessage::getTransactionContext() const
+{
+    return m_txn;
+}
+
+bool
+QueuedMessage::isTransactional() const
+{
+    return m_txn.get() != 0;
+}
+
+void
+QueuedMessage::clearTransaction()
+{
+    m_txn.reset(static_cast<MockTransactionContext*>(0));
+}
+
+}}} // namespace tests::storePerfTools

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/QueuedMessage.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/QueuedMessage.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/QueuedMessage.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/QueuedMessage.h Wed May  9 14:19:28 2012
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file QueuedMessage.h
+ */
+
+#ifndef tests_storePerfTools_asyncPerf_QueuedMessage_h_
+#define tests_storePerfTools_asyncPerf_QueuedMessage_h_
+
+#include "qpid/broker/EnqueueHandle.h"
+#include <boost/shared_ptr.hpp>
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+class MockPersistableMessage;
+class MockTransactionContext;
+
+typedef boost::shared_ptr<MockPersistableMessage> MockPersistableMessagePtr;
+typedef boost::shared_ptr<MockTransactionContext> MockTransactionContextPtr;
+
+class QueuedMessage
+{
+public:
+    QueuedMessage(MockPersistableMessagePtr msg,
+                  qpid::broker::EnqueueHandle& enqHandle,
+                  MockTransactionContextPtr txn);
+    virtual ~QueuedMessage();
+    MockPersistableMessagePtr getMessage() const;
+    qpid::broker::EnqueueHandle getEnqueueHandle() const;
+    MockTransactionContextPtr getTransactionContext() const;
+    bool isTransactional() const;
+    void clearTransaction();
+
+protected:
+    MockPersistableMessagePtr m_msg;
+    qpid::broker::EnqueueHandle m_enqHandle;
+    MockTransactionContextPtr m_txn;
+};
+
+}}} // namespace tests::storePerfTools
+
+#endif // tests_storePerfTools_asyncPerf_QueuedMessage_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestOptions.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestOptions.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestOptions.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestOptions.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file TestOptions.cpp
+ */
+
+#include "TestOptions.h"
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+// static declarations
+uint16_t TestOptions::s_defaultEnqTxnBlkSize = 0;
+uint16_t TestOptions::s_defaultDeqTxnBlkSize = 0;
+
+TestOptions::TestOptions(const std::string& name) :
+        tests::storePerftools::common::TestOptions(name),
+        m_enqTxnBlockSize(s_defaultEnqTxnBlkSize),
+        m_deqTxnBlockSize(s_defaultDeqTxnBlkSize)
+{
+    doAddOptions();
+}
+
+TestOptions::TestOptions(const uint32_t numMsgs,
+                         const uint32_t msgSize,
+                         const uint16_t numQueues,
+                         const uint16_t numEnqThreadsPerQueue,
+                         const uint16_t numDeqThreadsPerQueue,
+                         const uint16_t enqTxnBlockSize,
+                         const uint16_t deqTxnBlockSize,
+                         const std::string& name) :
+        tests::storePerftools::common::TestOptions(numMsgs, msgSize, numQueues, numEnqThreadsPerQueue, numDeqThreadsPerQueue, name),
+        m_enqTxnBlockSize(enqTxnBlockSize),
+        m_deqTxnBlockSize(deqTxnBlockSize)
+{
+    doAddOptions();
+}
+
+TestOptions::~TestOptions()
+{}
+
+void
+TestOptions::printVals(std::ostream& os) const
+{
+    tests::storePerftools::common::TestOptions::printVals(os);
+    os << "          Num enqueus per transaction [-t, --enq-txn-size]: " << m_enqTxnBlockSize << std::endl;
+    os << "         Num dequeues per transaction [-d, --deq-txn-size]: " << m_deqTxnBlockSize << std::endl;
+}
+
+void
+TestOptions::doAddOptions()
+{
+    addOptions()
+            ("enq-txn-size,t", qpid::optValue(m_enqTxnBlockSize, "N"),
+                    "Num enqueus per transaction (0 = no transactions)")
+            ("deq-txn-size,d", qpid::optValue(m_deqTxnBlockSize, "N"),
+                    "Num dequeues per transaction (0 = no transactions)")
+    ;
+}
+
+}}} // namespace tests::storePerftools::asyncPerf

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestOptions.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestOptions.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestOptions.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestOptions.h Wed May  9 14:19:28 2012
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file TestOptions.h
+ */
+
+#ifndef tests_storePerfTools_asyncPerf_TestOptions_h_
+#define tests_storePerfTools_asyncPerf_TestOptions_h_
+
+#include "tests/storePerfTools/common/TestOptions.h"
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+class TestOptions : public tests::storePerftools::common::TestOptions
+{
+public:
+    TestOptions(const std::string& name="Test Options");
+    TestOptions(const uint32_t numMsgs,
+                const uint32_t msgSize,
+                const uint16_t numQueues,
+                const uint16_t numEnqThreadsPerQueue,
+                const uint16_t numDeqThreadsPerQueue,
+                const uint16_t enqTxnBlockSize,
+                const uint16_t deqTxnBlockSize,
+                const std::string& name="Test Options");
+    virtual ~TestOptions();
+    void printVals(std::ostream& os) const;
+
+    uint16_t m_enqTxnBlockSize;                     ///< Transaction block size for enqueues
+    uint16_t m_deqTxnBlockSize;                     ///< Transaction block size for dequeues
+
+protected:
+    static uint16_t s_defaultEnqTxnBlkSize;         ///< Default transaction block size for enqueues
+    static uint16_t s_defaultDeqTxnBlkSize;         ///< Default transaction block size for dequeues
+
+    void doAddOptions();
+};
+
+}}} // namespace tests::storePerftools::asyncPerf
+
+#endif // tests_storePerfTools_asyncPerf_TestOptions_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestResult.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestResult.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestResult.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestResult.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file TestResult.cpp
+ */
+
+#include "TestResult.h"
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+TestResult::TestResult(const TestOptions& to) :
+        tests::storePerftools::common::TestResult(),
+        m_testOpts(to)
+{}
+
+TestResult::~TestResult()
+{}
+
+void
+TestResult::toStream(std::ostream& os) const
+{
+    double msgsRate;
+    os << "TEST RESULTS:" << std::endl;
+    os << "         Msgs per thread: " << m_testOpts.m_numMsgs << std::endl;
+    os << "                Msg size: " << m_testOpts.m_msgSize << std::endl;
+    os << "              No. queues: " << m_testOpts.m_numQueues << std::endl;
+    os << "   No. enq threads/queue: " << m_testOpts.m_numEnqThreadsPerQueue << std::endl;
+    os << "   No. deq threads/queue: " << m_testOpts.m_numDeqThreadsPerQueue << std::endl;
+    os << "              Time taken: " << m_elapsed << " sec" << std::endl;
+    uint32_t msgsPerQueue = m_testOpts.m_numMsgs * m_testOpts.m_numEnqThreadsPerQueue;
+    if (m_testOpts.m_numQueues > 1) {
+        msgsRate = double(msgsPerQueue) / m_elapsed;
+        os << "      No. msgs per queue: " << msgsPerQueue << std::endl;
+        os << "Per queue msg throughput: " << (msgsRate / 1e3) << " kMsgs/sec" << std::endl;
+        os << "                          " << (msgsRate * m_testOpts.m_msgSize / 1e6) << " MB/sec" << std::endl;
+    }
+    uint32_t totalMsgs = msgsPerQueue * m_testOpts.m_numQueues;
+    msgsRate = double(totalMsgs) / m_elapsed;
+    os << "          Total no. msgs: " << totalMsgs << std::endl;
+    os << "   Broker msg throughput: " << (msgsRate / 1e3) << " kMsgs/sec" << std::endl;
+    os << "                          " << (msgsRate * m_testOpts.m_msgSize / 1e6) << " MB/sec" << std::endl;
+}
+
+}}} // namespace tests::storePerftools::asyncPerf

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestResult.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestResult.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestResult.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/asyncPerf/TestResult.h Wed May  9 14:19:28 2012
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file TestResult.h
+ */
+
+#ifndef tests_storePerfTools_asyncPerf_TestResult_h_
+#define tests_storePerfTools_asyncPerf_TestResult_h_
+
+#include "TestOptions.h"
+
+#include "tests/storePerfTools/common/TestResult.h"
+
+namespace tests {
+namespace storePerftools {
+namespace asyncPerf {
+
+class TestOptions;
+
+/**
+ * \brief Results class that accepts an elapsed time to calculate the rate of message throughput in the journal.
+ *
+ * This class (being subclassed from ScopedTimable) is passed to a ScopedTimer object on construction, and the
+ * inherited _elapsed member will be written with the calculated elapsed time (in seconds) on destruction of the
+ * ScopedTimer object. This time (initially set to 0.0) is used to calculate message and message byte throughput.
+ * The message number and size information comes from the JrnlPerfTestParameters object passed to the constructor.
+ *
+ * Results are available through the use of toStream(), toString() or the << operators.
+ *
+ * Output is in the following format:
+ * <pre>
+ * TEST RESULTS:
+ *     Msgs per thread: 10000
+ *            Msg size: 2048
+ *          No. queues: 2
+ *   No. threads/queue: 2
+ *          Time taken: 1.6626 sec
+ *      Total no. msgs: 40000
+ *      Msg throughput: 24.0587 kMsgs/sec
+ *                      49.2723 MB/sec
+ * </pre>
+ */
+class TestResult : public tests::storePerftools::common::TestResult
+{
+public:
+    /**
+     * \brief Constructor
+     *
+     * Constructor. Will start the time interval measurement.
+     *
+     * \param tp Test parameter details used to calculate the performance results.
+     */
+    TestResult(const TestOptions& to);
+
+    /**
+     * \brief Virtual destructor
+     */
+    virtual ~TestResult();
+
+    /**
+     * \brief Stream the performance test results to an output stream
+     *
+     * Convenience feature which streams a multi-line performance result an output stream.
+     *
+     * \param os Output stream to which the results are to be streamed
+     */
+    void toStream(std::ostream& os = std::cout) const;
+
+protected:
+    TestOptions m_testOpts;     ///< Test parameters used for performance calculations
+
+};
+
+}}} // namespace tests::storePerftools::asyncPerf
+
+#endif // tests_storePerfTools_asyncPerf_TestResult_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Parameters.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Parameters.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Parameters.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Parameters.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file Parameters.cpp
+ */
+
+#include "Parameters.h"
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+Parameters::~Parameters()
+{}
+
+}}} // namespace tests::storePerftools::common

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Parameters.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Parameters.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Parameters.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Parameters.h Wed May  9 14:19:28 2012
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file Parameters.h
+ */
+#ifndef tests_storePerfTools_common_Parameters_h_
+#define tests_storePerfTools_common_Parameters_h_
+
+#include "Streamable.h"
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+class Parameters: public Streamable
+{
+public:
+    virtual ~Parameters();
+    virtual bool parseArg(const int arg,
+                          const char* optarg) = 0;
+
+};
+
+}}} // namespace tests::storePerfTools::common
+
+#endif // tests_storePerfTools_common_Parameters_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/PerftoolError.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/PerftoolError.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/PerftoolError.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/PerftoolError.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file PerftoolError.cpp
+ */
+
+#include "PerftoolError.h"
+
+#include <iomanip> // std::setfill(), std::setw()
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+// private
+PerftoolError::PerftoolError() :
+        std::runtime_error(std::string())
+{}
+
+PerftoolError::PerftoolError(const uint32_t errCode) throw () :
+        std::runtime_error(std::string()),
+        m_errCode(errCode)
+{
+    formatWhatStr();
+}
+
+PerftoolError::PerftoolError(const std::string& errMsg) throw () :
+        std::runtime_error(std::string()),
+        m_errCode(0),
+        m_errMsg(errMsg)
+{
+    formatWhatStr();
+}
+
+PerftoolError::PerftoolError(const uint32_t errCode,
+                             const std::string& errMsg) throw () :
+        std::runtime_error(std::string()),
+        m_errCode(errCode),
+        m_errMsg(errMsg)
+{
+    formatWhatStr();
+}
+
+PerftoolError::PerftoolError(const uint32_t errCode,
+                             const std::string& throwingClass,
+                             const std::string& throwingFunction) throw () :
+        std::runtime_error(std::string()),
+        m_errCode(errCode),
+        m_throwingClass(throwingClass),
+        m_throwingFunction(throwingFunction)
+{
+    formatWhatStr();
+}
+
+PerftoolError::PerftoolError(const std::string& errMsg,
+                             const std::string& throwingClass,
+                             const std::string& throwingFunction) throw () :
+        std::runtime_error(std::string()),
+        m_errCode(0),
+        m_errMsg(errMsg),
+        m_throwingClass(throwingClass),
+        m_throwingFunction(throwingFunction)
+{
+    formatWhatStr();
+}
+
+PerftoolError::PerftoolError(const uint32_t errCode,
+                             const std::string& errMsg,
+                             const std::string& throwingClass,
+                             const std::string& throwingFunction) throw () :
+        std::runtime_error(std::string()),
+        m_errCode(errCode),
+        m_errMsg(errMsg),
+        m_throwingClass(throwingClass),
+        m_throwingFunction(throwingFunction)
+{}
+
+PerftoolError::~PerftoolError() throw()
+{}
+
+const char*
+PerftoolError::what() const throw ()
+{
+    return m_what.c_str();
+}
+
+uint32_t
+PerftoolError::getErrorCode() const throw ()
+{
+    return m_errCode;
+}
+
+const std::string
+PerftoolError::getAdditionalInfo() const throw ()
+{
+    return m_errMsg;
+}
+
+const std::string
+PerftoolError::getThrowingClass() const throw ()
+{
+    return m_throwingClass;
+}
+
+const std::string
+PerftoolError::getThrowingFunction() const throw ()
+{
+    return m_throwingFunction;
+}
+
+void
+PerftoolError::toStream(std::ostream& os) const
+{
+    os << what();
+}
+
+// protected
+void
+PerftoolError::formatWhatStr() throw ()
+{
+    try {
+        const bool ai = !m_errMsg.empty();
+        const bool tc = !m_throwingClass.empty();
+        const bool tf = !m_throwingFunction.empty();
+        std::ostringstream oss;
+        oss << className() << " 0x" << std::hex << std::setfill('0') << std::setw(4) << m_errCode << " ";
+        if (tc) {
+            oss << m_throwingClass;
+            if (tf) {
+                oss << "::";
+            } else {
+                oss << " ";
+            }
+        }
+        if (tf) {
+            oss << m_throwingFunction << "() ";
+        }
+        if (tc || tf) {
+            oss << "threw " << s_errorMessage(m_errCode);
+        }
+        if (ai) {
+            oss << " (" << m_errMsg << ")";
+        }
+        m_what.assign(oss.str());
+    } catch (...) {}
+}
+
+// protected
+const char*
+PerftoolError::className()
+{
+    return s_className;
+}
+
+//static
+const char* PerftoolError::s_className = "PerftoolError";
+
+// --- Static definitions ---
+PerftoolError::errorMap_t PerftoolError::s_errorMap;
+PerftoolError::errorMapCitr_t PerftoolError::s_errorMapIterator;
+bool PerftoolError::s_initializedFlag = PerftoolError::s_initialize();
+
+// --- Generic and system errors ---
+const uint32_t PerftoolError::PERR_PTHREAD          = 0x0001;
+
+// static
+const char*
+PerftoolError::s_errorMessage(const uint32_t err_no) throw ()
+{
+    s_errorMapIterator = s_errorMap.find(err_no);
+    if (s_errorMapIterator == s_errorMap.end())
+        return "<Unknown error code>";
+    return s_errorMapIterator->second;
+}
+
+// protected static
+bool
+PerftoolError::s_initialize()
+{
+    s_errorMap[PERR_PTHREAD] = "ERR_PTHREAD: pthread operation failure";
+
+    return true;
+}
+
+}}} // namespace tests::storePerftools::common

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/PerftoolError.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/PerftoolError.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/PerftoolError.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/PerftoolError.h Wed May  9 14:19:28 2012
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file PerftoolError.h
+ */
+
+#ifndef tests_storePerfTools_common_PerftoolError_h_
+#define tests_storePerfTools_common_PerftoolError_h_
+
+#include "Streamable.h"
+
+#include <map>
+#include <stdexcept> // std::runtime_error
+#include <stdint.h> // uint32_t
+
+// Macro definitions
+
+#include <cstring> // std::strerror()
+#include <sstream> // std::ostringstream
+
+/**
+ * \brief Macro to retrieve and format the C errno value as a string.
+ *
+ * \param errno Value of errno to be formatted.
+ */
+#define FORMAT_SYSERR(errno) " errno=" << errno << " (" << std::strerror(errno) << ")"
+
+/**
+ * \brief Macro to check for a clean pthread creation and throwing a JournalException with code JERR_PTHREAD if
+ * thread creation failed.
+ *
+ * \param err Value or errno.
+ * \param pfn Name of system call that failed.
+ * \param cls Name of class in which function failed.
+ * \param fn Name of class function that failed.
+ */
+#define PTHREAD_CHK(err, pfn, cls, fn) if(err != 0) { \
+    std::ostringstream oss; \
+    oss << pfn << " failed: " << FORMAT_SYSERR(err); \
+    throw tests::storePerftools::common::PerftoolError(tests::storePerftools::common::PerftoolError::PERR_PTHREAD, oss.str(), cls, fn); \
+    }
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+class PerftoolError: public std::runtime_error, public Streamable
+{
+public:
+    // --- Constructors & destructors ---
+    PerftoolError(const uint32_t errCode) throw ();
+    PerftoolError(const std::string& errMsg) throw ();
+    PerftoolError(const uint32_t errCode,
+                  const std::string& errMsg) throw ();
+    PerftoolError(const uint32_t errCode,
+                  const std::string& throwingClass,
+                  const std::string& throwingFunction) throw ();
+    PerftoolError(const std::string& errMsg,
+                  const std::string& throwingClass,
+                  const std::string& throwingFunction) throw ();
+    PerftoolError(const uint32_t errCode,
+                  const std::string& errMsg,
+                  const std::string& throwingClass,
+                  const std::string& throwingFunction) throw ();
+    virtual ~PerftoolError() throw();
+
+    const char* what() const throw (); // overrides std::runtime_error::what()
+    uint32_t getErrorCode() const throw ();
+    const std::string getAdditionalInfo() const throw ();
+    const std::string getThrowingClass() const throw ();
+    const std::string getThrowingFunction() const throw ();
+
+    // --- Implementation of class Streamable ---
+    virtual void toStream(std::ostream& os = std::cout) const;
+
+    // --- Generic and system errors ---
+    static const uint32_t PERR_PTHREAD;                 ///< pthread operation failure
+
+
+    static const char* s_errorMessage(const uint32_t err_no) throw ();
+
+
+protected:
+    uint32_t m_errCode;                                 ///< Error or failure code, taken from JournalErrors.
+    std::string m_errMsg;                               ///< Additional information pertaining to the error or failure.
+    std::string m_throwingClass;                        ///< Name of the class throwing the error.
+    std::string m_throwingFunction;                     ///< Name of the function throwing the error.
+    std::string m_what;                                 ///< Standard error of failure message, taken from JournalErrors.
+
+    void formatWhatStr() throw ();
+    virtual const char* className();
+
+    typedef std::map<uint32_t, const char*> errorMap_t; ///< Type for map of error messages
+    typedef errorMap_t::const_iterator errorMapCitr_t;  ///< Const iterator for map of error messages
+
+    static errorMap_t s_errorMap;                       ///< Map of error messages
+    static errorMapCitr_t s_errorMapIterator;           ///< Const iterator
+
+private:
+    static const char* s_className;                     ///< Name of this class, used in formatting error messages.
+    static bool s_initializedFlag;                      ///< Dummy flag, used to initialize map.
+
+    PerftoolError();
+    static bool s_initialize();                         ///< Static fn for initializing static data
+
+};
+
+}}} // namespace tests::stprePerftools::common
+
+#endif // tests_storePerfTools_common_PerftoolError_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimable.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimable.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimable.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimable.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file ScopedTimable.cpp
+ */
+
+#include "ScopedTimable.h"
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+ScopedTimable::ScopedTimable() :
+    m_elapsed(0.0)
+{}
+
+ScopedTimable::~ScopedTimable()
+{}
+
+double&
+ScopedTimable::getElapsedRef()
+{
+    return m_elapsed;
+}
+
+}}} // namespace tests::storePerftools::common

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimable.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimable.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimable.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimable.h Wed May  9 14:19:28 2012
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file ScopedTimable.h
+ */
+
+#ifndef tests_storePerfTools_common_ScopedTimable_h_
+#define tests_storePerfTools_common_ScopedTimable_h_
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+/**
+ * \brief Scoped timer class that starts timing on construction and finishes on destruction.
+ *
+ * This class is designed to be the parent class for a performance result class which depends on the elapsed
+ * time of some process or event. By passing this (or its subclasses) to ScopedTimer (which only exists within
+ * the scope of the event), the _elapsed member of this class will be written with the elapsed time when the
+ * ScopedTimer object goes out of scope or is destroyed.
+ *
+ * Subclasses may be aware of the parameters being timed, and may thus print and/or display performance and/or
+ * rate information for these parameters.
+ */
+class ScopedTimable
+{
+public:
+    ScopedTimable();
+    virtual ~ScopedTimable();
+    double& getElapsedRef();
+
+protected:
+    double m_elapsed;   ///< Elapsed time, will be written on destruction of ScopedTimer instances
+
+};
+
+}}} // namespace tests::storePerftools::common
+
+#endif // tests_storePerfTools_common_ScopedTimable_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimer.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimer.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimer.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimer.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file ScopedTimer.cpp
+ */
+
+#include "ScopedTimer.h"
+
+#include "ScopedTimable.h"
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+ScopedTimer::ScopedTimer(double& elapsed) :
+        m_elapsed(elapsed)
+{
+    ::clock_gettime(CLOCK_REALTIME, &m_startTime);
+}
+
+ScopedTimer::ScopedTimer(ScopedTimable& st) :
+        m_elapsed(st.getElapsedRef())
+{
+    ::clock_gettime(CLOCK_REALTIME, &m_startTime);
+}
+
+ScopedTimer::~ScopedTimer()
+{
+    ::timespec stopTime;
+    ::clock_gettime(CLOCK_REALTIME, &stopTime);
+    m_elapsed = _s_getDoubleTime(stopTime) - _s_getDoubleTime(m_startTime);
+}
+
+// static
+double ScopedTimer::_s_getDoubleTime(const ::timespec& ts)
+{
+    return ts.tv_sec + (double(ts.tv_nsec) / 1e9);
+}
+
+
+}}} // namespace tests::storePerftools::common

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimer.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimer.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimer.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/ScopedTimer.h Wed May  9 14:19:28 2012
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file ScopedTimer.h
+ */
+
+#ifndef tests_storePerfTools_common_ScopedTimer_h_
+#define tests_storePerfTools_common_ScopedTimer_h_
+
+#include <ctime>
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+class ScopedTimable;
+
+/**
+ * \brief Scoped timer class that starts timing on construction and finishes on destruction.
+ *
+ * The scoped timer will take the current time on construction and again on destruction. The destructor
+ * will calculate the elapsed time from the difference between these two times and write the result
+ * as a double to the double ref supplied to the constructor. A second constructor will accept a class (or
+ * subclass) of ScopedTimable, which contains a double to which the result may be written and accessed at a
+ * later time.
+ */
+class ScopedTimer
+{
+public:
+    /**
+     * \brief Constructor
+     *
+     * Constructor which accepts a ref to a double. Will start the time interval measurement.
+     *
+     * \param elapsed A ref to a double which will contain the elapsed time in seconds after this class instance
+     *                is destroyed.
+     */
+    ScopedTimer(double& elapsed);
+
+    /**
+     * \brief Constructor
+     *
+     * Constructor which accepts a ref to a ScopedTimable. Will start the time interval measurement.
+     *
+     * \param st A ref to a ScopedTimable into which the result of the ScopedTimer can be written.
+     */
+    ScopedTimer(ScopedTimable& st);
+
+    /**
+     * \brief Destructor
+     *
+     * Destructor. Will stop the time interval measurement and write the calculated elapsed time into _elapsed.
+     */
+    virtual ~ScopedTimer();
+
+protected:
+    double& m_elapsed;      ///< Ref to elapsed time, will be written on destruction of ScopedTimer instances
+    ::timespec m_startTime; ///< Start time, set on construction
+
+    /**
+     * \brief Convert ::timespec to seconds
+     *
+     * Static function to convert a ::timespec struct into a double representation in seconds.
+     *
+     * \param ts std::timespec struct containing the time to be converted.
+     * \return A double which represents the time in parameter ts in seconds.
+     */
+    static double _s_getDoubleTime(const ::timespec& ts);
+
+};
+
+}}} // namespace tests::storePerftools::common
+
+#endif // tests_storePerfTools_common_ScopedTimer_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Streamable.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Streamable.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Streamable.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Streamable.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file Streamable.cpp
+ */
+
+#include "Streamable.h"
+
+#include <sstream>
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+std::string
+Streamable::toString() const
+{
+    std::ostringstream oss;
+    toStream(oss);
+    return oss.str();
+}
+
+std::ostream&
+operator<<(std::ostream& os, const Streamable& s)
+{
+    s.toStream(os);
+    return os;
+}
+
+std::ostream&
+operator<<(std::ostream& os, const Streamable* sPtr)
+{
+    sPtr->toStream(os);
+    return os;
+}
+
+}}} // namespace tests::storePerftools::common

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Streamable.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Streamable.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Streamable.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/Streamable.h Wed May  9 14:19:28 2012
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file Streamable.h
+ */
+
+#ifndef tests_storePerfTools_common_Streamable_h_
+#define tests_storePerfTools_common_Streamable_h_
+
+#include <iostream>
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+/**
+ * \brief Abstract class which provides the mechanisms to stream
+ *
+ * An abstract class which provides stream functions. The toStream() function must be implemented by subclasses,
+ * and is used by the remaining functions. For convenience, toString() returns a std::string object.
+ */
+class Streamable
+{
+public:
+    /**
+     * \brief Virtual destructor
+     */
+    virtual ~Streamable() {}
+
+    /***
+     * \brief Stream some representation of the object to an output stream
+     *
+     * \param os Output stream to which the class data is to be streamed
+     */
+    virtual void toStream(std::ostream& os = std::cout) const = 0;
+
+    /**
+     * \brief Creates a string representation of the test parameters
+     *
+     * Convenience feature which creates and returns a std::string object containing the content of toStream().
+     *
+     * \return Content of toStream()
+     */
+     std::string toString() const;
+
+    /**
+     * \brief Stream the object to an output stream
+     */
+    friend std::ostream& operator<<(std::ostream& os,
+                                    const Streamable& s);
+
+    /**
+     * \brief Stream the object to an output stream through an object pointer
+     */
+    friend std::ostream& operator<<(std::ostream& os,
+                                    const Streamable* sPtr);
+
+};
+
+}}} // namespace tests::storePerftools::common
+
+#endif // tests_storePerfTools_common_Streamable_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestOptions.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestOptions.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestOptions.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestOptions.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file TestOptions.cpp
+ */
+
+#include "TestOptions.h"
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+// static declarations
+uint32_t TestOptions::s_defaultNumMsgs = 1024;
+uint32_t TestOptions::s_defaultMsgSize = 1024;
+uint16_t TestOptions::s_defaultNumQueues = 1;
+uint16_t TestOptions::s_defaultEnqThreadsPerQueue = 1;
+uint16_t TestOptions::s_defaultDeqThreadsPerQueue = 1;
+
+TestOptions::TestOptions(const std::string& name) :
+        qpid::Options(name),
+        m_numMsgs(s_defaultNumMsgs),
+        m_msgSize(s_defaultMsgSize),
+        m_numQueues(s_defaultNumQueues),
+        m_numEnqThreadsPerQueue(s_defaultEnqThreadsPerQueue),
+        m_numDeqThreadsPerQueue(s_defaultDeqThreadsPerQueue)
+{
+    doAddOptions();
+}
+
+TestOptions::TestOptions(const uint32_t numMsgs,
+                         const uint32_t msgSize,
+                         const uint16_t numQueues,
+                         const uint16_t numEnqThreadsPerQueue,
+                         const uint16_t numDeqThreadsPerQueue,
+                         const std::string& name) :
+        qpid::Options(name),
+        m_numMsgs(numMsgs),
+        m_msgSize(msgSize),
+        m_numQueues(numQueues),
+        m_numEnqThreadsPerQueue(numEnqThreadsPerQueue),
+        m_numDeqThreadsPerQueue(numDeqThreadsPerQueue)
+{
+    doAddOptions();
+}
+
+TestOptions::~TestOptions()
+{}
+
+void
+TestOptions::printVals(std::ostream& os) const
+{
+    os << "TEST OPTIONS:" << std::endl;
+    os << "                       Number of queues [-q, --num-queues]: " << m_numQueues << std::endl;
+    os << "       Number of producers per queue [-p, --num-producers]: " << m_numEnqThreadsPerQueue << std::endl;
+    os << "       Number of consumers per queue [-c, --num-consumers]: " << m_numDeqThreadsPerQueue << std::endl;
+    os << "  Number of messages to send per producer [-m, --num-msgs]: " << m_numMsgs << std::endl;
+    os << "             Size of each message (bytes) [-s, --msg-size]: " << m_msgSize << std::endl;
+}
+
+void
+TestOptions::validate()
+{
+    if (((m_numEnqThreadsPerQueue * m_numMsgs) % m_numDeqThreadsPerQueue) != 0) {
+        throw qpid::Exception("Parameter Error: (num-producers * num-msgs) must be a multiple of num-consumers.");
+    }
+}
+
+void
+TestOptions::doAddOptions()
+{
+    addOptions()
+            ("num-queues,q", qpid::optValue(m_numQueues, "N"),
+                    "Number of queues")
+            ("num-producers,p", qpid::optValue(m_numEnqThreadsPerQueue, "N"),
+                    "Number of producers per queue")
+            ("num-consumers,c", qpid::optValue(m_numDeqThreadsPerQueue, "N"),
+                    "Number of consumers per queue")
+            ("num-msgs,m", qpid::optValue(m_numMsgs, "N"),
+                    "Number of messages to send per producer")
+            ("msg-size,s", qpid::optValue(m_msgSize, "N"),
+                    "Size of each message (bytes)")
+    ;
+}
+
+}}} // namespace tests::storePerftools::common

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestOptions.h
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestOptions.h?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestOptions.h (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestOptions.h Wed May  9 14:19:28 2012
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file TestOptions.h
+ */
+
+#ifndef tests_storePerfTools_common_TestOptions_h_
+#define tests_storePerfTools_common_TestOptions_h_
+
+#include "qpid/Options.h"
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+class TestOptions : public qpid::Options
+{
+public:
+    TestOptions(const std::string& name="Test Options");
+    TestOptions(const uint32_t numMsgs,
+                const uint32_t msgSize,
+                const uint16_t numQueues,
+                const uint16_t numEnqThreadsPerQueue,
+                const uint16_t numDeqThreadsPerQueue,
+                const std::string& name="Test Options");
+    virtual ~TestOptions();
+    void printVals(std::ostream& os) const;
+    void validate();
+
+    uint32_t m_numMsgs;                             ///< Number of messages to be sent
+    uint32_t m_msgSize;                             ///< Message size in bytes
+    uint16_t m_numQueues;                           ///< Number of queues to test simultaneously
+    uint16_t m_numEnqThreadsPerQueue;               ///< Number of enqueue threads per queue
+    uint16_t m_numDeqThreadsPerQueue;               ///< Number of dequeue threads per queue
+
+protected:
+    static uint32_t s_defaultNumMsgs;               ///< Default number of messages to be sent
+    static uint32_t s_defaultMsgSize;               ///< Default message size in bytes
+    static uint16_t s_defaultNumQueues;             ///< Default number of queues to test simultaneously
+    static uint16_t s_defaultEnqThreadsPerQueue;    ///< Default number of enqueue threads per queue
+    static uint16_t s_defaultDeqThreadsPerQueue;    ///< Default number of dequeue threads per queue
+
+    void doAddOptions();
+
+};
+
+}}} // namespace tests::storePerftools::common
+
+#endif // tests_storePerfTools_common_TestOptions_h_

Added: qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestParameters.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestParameters.cpp?rev=1336220&view=auto
==============================================================================
--- qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestParameters.cpp (added)
+++ qpid/branches/asyncstore/cpp/src/tests/storePerfTools/common/TestParameters.cpp Wed May  9 14:19:28 2012
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * \file TestParameters.cpp
+ */
+
+#include "TestParameters.h"
+
+#include <cstdlib> // std::atoi, std::atol
+
+namespace tests {
+namespace storePerftools {
+namespace common {
+
+// static declarations
+uint32_t TestParameters::s_defaultNumMsgs = 1024;
+uint32_t TestParameters::s_defaultMsgSize = 1024;
+uint16_t TestParameters::s_defaultNumQueues = 1;
+uint16_t TestParameters::s_defaultEnqThreadsPerQueue = 1;
+uint16_t TestParameters::s_defaultDeqThreadsPerQueue = 1;
+
+TestParameters::TestParameters():
+        Parameters(),
+        m_numMsgs(s_defaultNumMsgs),
+        m_msgSize(s_defaultMsgSize),
+        m_numQueues(s_defaultNumQueues),
+        m_numEnqThreadsPerQueue(s_defaultEnqThreadsPerQueue),
+        m_numDeqThreadsPerQueue(s_defaultDeqThreadsPerQueue)//,
+{}
+
+TestParameters::TestParameters(const uint32_t numMsgs,
+                               const uint32_t msgSize,
+                               const uint16_t numQueues,
+                               const uint16_t numEnqThreadsPerQueue,
+                               const uint16_t numDeqThreadsPerQueue) :
+        Parameters(),
+        m_numMsgs(numMsgs),
+        m_msgSize(msgSize),
+        m_numQueues(numQueues),
+        m_numEnqThreadsPerQueue(numEnqThreadsPerQueue),
+        m_numDeqThreadsPerQueue(numDeqThreadsPerQueue)
+{}
+
+TestParameters::TestParameters(const TestParameters& tp):
+        Parameters(),
+        m_numMsgs(tp.m_numMsgs),
+        m_msgSize(tp.m_msgSize),
+        m_numQueues(tp.m_numQueues),
+        m_numEnqThreadsPerQueue(tp.m_numEnqThreadsPerQueue),
+        m_numDeqThreadsPerQueue(tp.m_numDeqThreadsPerQueue)
+{}
+
+TestParameters::~TestParameters()
+{}
+
+void
+TestParameters::toStream(std::ostream& os) const
+{
+    os << "Test Parameters:" << std::endl;
+    os << "  num_msgs = " << m_numMsgs << std::endl;
+    os << "  msg_size = " << m_msgSize << std::endl;
+    os << "  num_queues = " << m_numQueues << std::endl;
+    os << "  num_enq_threads_per_queue = " << m_numEnqThreadsPerQueue << std::endl;
+    os << "  num_deq_threads_per_queue = " << m_numDeqThreadsPerQueue << std::endl;
+}
+
+bool
+TestParameters::parseArg(const int arg,
+                         const char* optarg)
+{
+    switch(arg) {
+    case 'm':
+        m_numMsgs = uint32_t(std::atol(optarg));
+        break;
+    case 'S':
+        m_msgSize = uint32_t(std::atol(optarg));
+        break;
+    case 'q':
+        m_numQueues = uint16_t(std::atoi(optarg));
+        break;
+    case 'e':
+        m_numEnqThreadsPerQueue = uint16_t(std::atoi(optarg));
+        break;
+    case 'd':
+        m_numDeqThreadsPerQueue = uint16_t(std::atoi(optarg));
+        break;
+    default:
+        return false;
+    }
+    return true;
+}
+
+// static
+void
+TestParameters::printArgs(std::ostream& os)
+{
+    os << "Test parameters:" << std::endl;
+    os << " -m --num_msgs:                   Number of messages to send per enqueue thread ["
+       << TestParameters::s_defaultNumMsgs << "]" << std::endl;
+    os << " -S --msg_size:                   Size of each message to be sent ["
+       << TestParameters::s_defaultMsgSize << "]" << std::endl;
+    os << " -q --num_queues:                 Number of simultaneous queues ["
+       << TestParameters::s_defaultNumQueues << "]" << std::endl;
+    os << " -e --num_enq_threads_per_queue:  Number of enqueue threads per queue ["
+       << TestParameters::s_defaultEnqThreadsPerQueue << "]" << std::endl;
+    os << " -d --num_deq_threads_per_queue:  Number of dequeue threads per queue ["
+       << TestParameters::s_defaultDeqThreadsPerQueue << "]" << std::endl;
+    os << std::endl;
+}
+
+// static
+std::string
+TestParameters::shortArgs()
+{
+    return "m:S:q:e:d:";
+}
+
+}}} // namespace tests::storePerftools::common



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org