rhmessaging commits: r4437 - store/branches/java/0.5.x-dev/etc/scripts.
by rhmessaging-commits@lists.jboss.org
Author: rgemmell
Date: 2010-12-17 06:06:36 -0500 (Fri, 17 Dec 2010)
New Revision: 4437
Modified:
store/branches/java/0.5.x-dev/etc/scripts/bdbbackuptest.sh
Log:
update script lib paths
Modified: store/branches/java/0.5.x-dev/etc/scripts/bdbbackuptest.sh
===================================================================
--- store/branches/java/0.5.x-dev/etc/scripts/bdbbackuptest.sh 2010-12-10 20:52:48 UTC (rev 4436)
+++ store/branches/java/0.5.x-dev/etc/scripts/bdbbackuptest.sh 2010-12-17 11:06:36 UTC (rev 4437)
@@ -9,4 +9,8 @@
fi
done
-java -Xms256m -Dlog4j.configuration=perftests.log4j -Xmx256m -Dbadger.level=warn -Damqj.test.logging.level=warn -Damqj.logging.level=warn ${JAVA_OPTS} -cp qpid-bdbstore-1.0-incubating-M2-SNAPSHOT-all-test-deps.jar org.apache.qpid.server.store.berkeleydb.testclient.BackupTestClient -o $QPID_WORK/results numMessagesToAction=55 ${ARGS}
+VERSION=0.5
+
+MODULE_JARS=$QPID_HOME/lib/qpid-bdbstore-$VERSION.jar:$QPID_HOME/lib/qpid-systests-$VERSION.jar:$QPID_HOME/lib/qpid-perftests-$VERSION.jar:$QPID_HOME/lib/qpid-junit-toolkit-$VERSION.jar:$QPID_HOME/lib/qpid-all.jar:$QPID_HOME/lib/slf4j-log4j12-1.4.0.jar:$QPID_HOME/lib/log4j-1.2.12.jar
+
+java -Xms256m -Dlog4j.configuration=perftests.log4j -Xmx256m -Dbadger.level=warn -Damqj.test.logging.level=warn -Damqj.logging.level=warn ${JAVA_OPTS} -cp $MODULE_JARS org.apache.qpid.server.store.berkeleydb.testclient.BackupTestClient -o $QPID_WORK/results numMessagesToAction=55 ${ARGS}
14 years
rhmessaging commits: r4436 - in store/trunk/cpp: perf and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2010-12-10 15:52:48 -0500 (Fri, 10 Dec 2010)
New Revision: 4436
Added:
store/trunk/cpp/lib/jrnl2/Journal.cpp
store/trunk/cpp/lib/jrnl2/Journal.hpp
store/trunk/cpp/lib/jrnl2/JournalState.cpp
store/trunk/cpp/lib/jrnl2/JournalState.hpp
store/trunk/cpp/lib/jrnl2/ScopedLock.hpp
Removed:
store/trunk/cpp/lib/jrnl2/jrnl.cpp
store/trunk/cpp/lib/jrnl2/jrnl.hpp
store/trunk/cpp/lib/jrnl2/jrnl_state.cpp
store/trunk/cpp/lib/jrnl2/jrnl_state.hpp
store/trunk/cpp/lib/jrnl2/slock.cpp
store/trunk/cpp/lib/jrnl2/slock.hpp
store/trunk/cpp/lib/jrnl2/smutex.cpp
store/trunk/cpp/lib/jrnl2/smutex.hpp
store/trunk/cpp/lib/jrnl2/txn_ctxt.hpp
Modified:
store/trunk/cpp/lib/jrnl2/DataToken.cpp
store/trunk/cpp/lib/jrnl2/DataToken.hpp
store/trunk/cpp/lib/jrnl2/JournalErrors.hpp
store/trunk/cpp/lib/jrnl2/JournalException.hpp
store/trunk/cpp/lib/jrnl2/JournalParameters.cpp
store/trunk/cpp/lib/jrnl2/JournalParameters.hpp
store/trunk/cpp/lib/jrnl2/Makefile.am
store/trunk/cpp/perf/JournalInstance.cpp
store/trunk/cpp/perf/JournalInstance.hpp
store/trunk/cpp/perf/JournalPerformanceTest.cpp
store/trunk/cpp/perf/m
Log:
Additional code tidy-up and refactoring in lib/jrnl2
Modified: store/trunk/cpp/lib/jrnl2/DataToken.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/DataToken.cpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/DataToken.cpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -40,7 +40,7 @@
recordId_t AtomicRecordIdCounter::_recordId;
// static
- smutex AtomicRecordIdCounter::_recordIdMutex;
+ ScopedMutex AtomicRecordIdCounter::_recordIdMutex;
DataToken::DataToken() :
_dataTokenState(),
Modified: store/trunk/cpp/lib/jrnl2/DataToken.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/DataToken.hpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/DataToken.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -33,11 +33,10 @@
#define mrg_journal2_DataToken_hpp
#include <string>
-#include <sys/types.h> // u_int16_t, u_int32_t
+#include <sys/types.h> // u_int64_t
#include "DataTokenState.hpp"
-#include "slock.hpp"
-#include "smutex.hpp"
+#include "ScopedLock.hpp"
namespace mrg
{
@@ -49,9 +48,13 @@
class AtomicRecordIdCounter
{
static recordId_t _recordId;
- static smutex _recordIdMutex;
+ static ScopedMutex _recordIdMutex;
public:
- inline static recordId_t s_getNextRecordId() { slock l(_recordIdMutex); return ++_recordId; }
+ inline static recordId_t s_getNextRecordId()
+ { // --- START OF CRITICAL SECTION ---
+ ScopedLock l(_recordIdMutex);
+ return ++_recordId;
+ } // --- START OF CRITICAL SECTION ---
};
class DataToken
Copied: store/trunk/cpp/lib/jrnl2/Journal.cpp (from rev 4435, store/trunk/cpp/lib/jrnl2/jrnl.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/Journal.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/Journal.cpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -0,0 +1,188 @@
+/**
+ * \file Journal.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "Journal.hpp"
+
+// --- temp code ---
+#include <iostream>
+// --- end temp code ---
+
+namespace mrg
+{
+namespace journal2
+{
+
+ std::string
+ g_ioResAsString(const ioRes /*res*/)
+ {
+ // TODO - provide implementation
+ return ".[g_ioResAsString].";
+ }
+
+ // static
+ u_int32_t Journal::_s_listSizeThreshold = 50;
+
+ Journal::Journal(const std::string& jrnlId,
+ const std::string& jrnlDir,
+ const std::string& baseFileName) :
+ _jrnlId(jrnlId),
+ _jrnlDir(jrnlDir),
+ _baseFileName(baseFileName),
+ _jrnlParamsPtr(0),
+ _aioCallbackPtr(0)
+ // --- temp code ---
+ , _callBackDataTokenListSwitch(false)
+ // --- end temp code ---
+ {}
+
+ void
+ Journal::initialize(const JournalParameters* jpPtr, AioCallback* const aiocbPtr)
+ {
+ _jrnlParamsPtr = jpPtr;
+ _aioCallbackPtr = aiocbPtr;
+ }
+
+ ioRes
+ Journal::enqueue(const void* const /*msgPtr*/, const std::size_t /*msgSize*/, DataToken* const dtokPtr)
+ {
+ dtokPtr->getDataTokenState().setOpStateToEnqueue();
+ // --- temp code ---
+ bool flushFlag;
+ { // --- START OF CRITICAL SECTION ---
+ ScopedLock l(_writeDataTokenListLock);
+ _writeDataTokenList.push_back(dtokPtr);
+ flushFlag = _writeDataTokenList.size() >= _s_listSizeThreshold;
+ if (flushFlag) flushNoLock(false);
+ } // --- END OF CRITICAL SECTION ---
+ if (flushFlag) processCompletedAioWriteEvents(0);
+ // --- end temp code ---
+ return 0;
+ }
+
+ ioRes
+ Journal::dequeue(DataToken* const dtokPtr)
+ {
+ dtokPtr->getDataTokenState().setOpStateToDequeue();
+ dtokPtr->setDequeueRecordId(dtokPtr->getRecordId());
+ // --- temp code ---
+ bool flushFlag;
+ { // --- START OF CRITICAL SECTION ---
+ ScopedLock l(_writeDataTokenListLock);
+ _writeDataTokenList.push_back(dtokPtr);
+ flushFlag = _writeDataTokenList.size() >= _s_listSizeThreshold;
+ if (flushFlag) flushNoLock(false);
+ } // --- END OF CRITICAL SECTION ---
+ if (flushFlag) processCompletedAioWriteEvents(0);
+ // --- end temp code ---
+ return 0;
+ }
+
+ ioRes
+ Journal::commit()
+ {
+ // TODO
+ return 0;
+ }
+
+ ioRes
+ Journal::abort()
+ {
+ // TODO
+ return 0;
+ }
+
+ u_int32_t
+ Journal::getWriteAioEventsRemaining() const
+ {
+ while (true) { // --- START OF CRITICAL SECTION ---
+ ScopedTryLock l1(_callBackDataTokenListLock);
+ ScopedTryLock l2(_writeDataTokenListLock);
+ if (l1.isLocked() && l2.isLocked()) {
+ return _callBackDataTokenList[0].size() + _callBackDataTokenList[1].size();
+ } else {
+ //::usleep(10);
+ }
+ }; // --- END OF CRITICAL SECTION ---
+ }
+
+ void
+ Journal::flush(const bool blockTillAioCompleteFlag)
+ {
+ // --- temp code ---
+ // --- START OF CRITICAL SECTION ---
+ ScopedTryLock l(_writeDataTokenListLock);
+ if (l.isLocked()) {
+ flushNoLock(blockTillAioCompleteFlag);
+ }
+ // --- END OF CRITICAL SECTION ---
+ // --- end temp code ---
+ }
+
+ // protected
+ void
+ Journal::flushNoLock(const bool /*blockTillAioCompleteFlag*/)
+ {
+ // --- temp code ---
+ int i = _callBackDataTokenListSwitch ? 1 : 0;
+ while (_writeDataTokenList.size()) {
+ _callBackDataTokenList[i].push_back(_writeDataTokenList.back());
+ _writeDataTokenList.pop_back();
+ }
+ // --- end temp code ---
+ }
+
+ void
+ Journal::processCompletedAioWriteEvents(timespec* const /*timeout*/)
+ {
+ // --- temp code ---
+ // --- START OF CRITICAL SECTION 1 ---
+ ScopedTryLock l1(_callBackDataTokenListLock);
+ if (l1.isLocked()) {
+ int i = _callBackDataTokenListSwitch ? 0 : 1;
+ if (_callBackDataTokenList[i].size() && _aioCallbackPtr) {
+ // NOTE: Callback made with _callBackDataTokenListLock isLocked
+ _aioCallbackPtr->writeAioCompleteCallback(_callBackDataTokenList[i]);
+ }
+ _callBackDataTokenList[i].clear();
+
+ // take both locks before allowing switch to change
+ { // --- START OF CRITICAL SECTION 2 ---
+ ScopedLock l2(_writeDataTokenListLock);
+ _callBackDataTokenListSwitch = !_callBackDataTokenListSwitch;
+ } // --- END OF CRITICAL SECTION 2 ---
+ }
+ // --- END OF CRITICAL SECTION 1 ---
+ // --- end temp code ---
+ }
+
+} // namespace journal2
+} // namespace mrg
+
Copied: store/trunk/cpp/lib/jrnl2/Journal.hpp (from rev 4435, store/trunk/cpp/lib/jrnl2/jrnl.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/Journal.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/Journal.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -0,0 +1,112 @@
+/**
+ * \file Journal.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_journal2_Journal_hpp
+#define mrg_journal2_Journal_hpp
+
+#include <string>
+#include <sys/types.h> // u_int64_t, u_int32_t, etc.
+#include <time.h> // timespec
+
+#include "AioCallback.hpp"
+#include "DataToken.hpp"
+#include "JournalState.hpp"
+#include "JournalParameters.hpp"
+
+// --- temp code ---
+#include "ScopedLock.hpp" // ScopedMutex
+#include <vector>
+// --- end temp code ---
+
+namespace mrg
+{
+namespace journal2
+{
+
+ // TODO - decide if this is the right place to expose these codes and flags
+ typedef u_int64_t ioRes; // TODO - this needs to be expressed as flags
+ const ioRes RHM_IORES_ENQCAPTHRESH = 0x1;
+ const ioRes RHM_IORES_BUSY = 0x2;
+ std::string g_ioResAsString(const ioRes /*res*/);
+
+ class Journal
+ {
+ protected:
+ std::string _jrnlId;
+ std::string _jrnlDir;
+ std::string _baseFileName;
+ JournalState _jrnlState;
+ const JournalParameters* _jrnlParamsPtr;
+ AioCallback* _aioCallbackPtr;
+
+ // --- temp code ---
+ static u_int32_t _s_listSizeThreshold;
+ std::vector<DataToken*> _writeDataTokenList;
+ std::vector<DataToken*> _callBackDataTokenList[2];
+ bool _callBackDataTokenListSwitch;
+ ScopedMutex _writeDataTokenListLock;
+ ScopedMutex _callBackDataTokenListLock;
+ // --- end temp code ---
+
+ void flushNoLock(const bool blockTillAioCompleteFlag);
+
+ public:
+ Journal(const std::string& jrnlId, const std::string& jrnlDir, const std::string& baseFileName);
+
+ // get functions
+ inline std::string getJournalId() { return _jrnlId; }
+ inline std::string getJournalDir() { return _jrnlDir; }
+ inline std::string getBaseFileName() { return _baseFileName; }
+ inline const JournalState& getJournalState() { return _jrnlState; }
+ inline const JournalParameters* getJournalParameters() const { return _jrnlParamsPtr; }
+
+ // msg ops
+ void initialize(const JournalParameters* jpPtr, AioCallback* const aiocbPtr);
+ ioRes enqueue(const void* const msgPtr, const std::size_t msgSize, DataToken* const dtokPtr);
+ ioRes dequeue(DataToken* const dtokPtr);
+ ioRes commit();
+ ioRes abort();
+
+ // aio ops and status
+ // --- temp code ---
+ u_int32_t getWriteAioEventsRemaining() const;
+ // --- end of temp code ---
+ void flush(const bool blockTillAioCompleteFlag);
+ void processCompletedAioWriteEvents(timespec* const timeout);
+ };
+
+
+} // namespace journal2
+} // namespace mrg
+
+
+#endif // mrg_journal2_Journal_hpp
+
Modified: store/trunk/cpp/lib/jrnl2/JournalErrors.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalErrors.hpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/JournalErrors.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -33,7 +33,7 @@
#define mrg_journal2_JournalErrors_hpp
#include <map>
-#include <sys/types.h> // u_int16_t, u_int32_t
+#include <sys/types.h> // u_int32_t
namespace mrg
{
Modified: store/trunk/cpp/lib/jrnl2/JournalException.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalException.hpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/JournalException.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -32,10 +32,10 @@
#ifndef mrg_journal2_JournalException_hpp
#define mrg_journal2_JournalException_hpp
-#include <cstring>
+#include <cstring> // std::strerror
#include <sstream>
#include <string>
-#include <sys/types.h> // u_int16_t, u_int32_t
+#include <sys/types.h> // u_int32_t
#include "JournalErrors.hpp"
Modified: store/trunk/cpp/lib/jrnl2/JournalParameters.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalParameters.cpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/JournalParameters.cpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -38,92 +38,91 @@
namespace journal2
{
-// static declarations
-std::string JournalParameters::_s_defaultJrnlDir = "/tmp/store";
-std::string JournalParameters::_s_defaultJrnlBaseFileName = "JournalData";
-u_int16_t JournalParameters::_s_defaultNumJrnlFiles = 8;
-u_int32_t JournalParameters::_s_defaultJrnlFileSize_sblks = 3072;
-bool JournalParameters::_s_defaultAutoExpand = false;
-u_int16_t JournalParameters::_s_defaultAutoExpandMaxJrnlFiles = 0;
-u_int16_t JournalParameters::_s_defaultWriteBuffNumPgs = 32;
-u_int32_t JournalParameters::_s_defaultWriteBuffPgSize_sblks = 128;
+ // static declarations
+ std::string JournalParameters::_s_defaultJrnlDir = "/tmp/store";
+ std::string JournalParameters::_s_defaultJrnlBaseFileName = "JournalData";
+ u_int16_t JournalParameters::_s_defaultNumJrnlFiles = 8;
+ u_int32_t JournalParameters::_s_defaultJrnlFileSize_sblks = 3072;
+ bool JournalParameters::_s_defaultAutoExpand = false;
+ u_int16_t JournalParameters::_s_defaultAutoExpandMaxJrnlFiles = 0;
+ u_int16_t JournalParameters::_s_defaultWriteBuffNumPgs = 32;
+ u_int32_t JournalParameters::_s_defaultWriteBuffPgSize_sblks = 128;
-JournalParameters::JournalParameters() :
- _jrnlDir(_s_defaultJrnlDir),
- _jrnlBaseFileName(_s_defaultJrnlBaseFileName),
- _numJrnlFiles(_s_defaultNumJrnlFiles),
- _jrnlFileSize_sblks(_s_defaultJrnlFileSize_sblks),
- _autoExpand(_s_defaultAutoExpand),
- _autoExpandMaxJrnlFiles(_s_defaultAutoExpandMaxJrnlFiles),
- _writeBuffNumPgs(_s_defaultWriteBuffNumPgs),
- _writeBuffPgSize_sblks(_s_defaultWriteBuffPgSize_sblks)
-{}
+ JournalParameters::JournalParameters() :
+ _jrnlDir(_s_defaultJrnlDir),
+ _jrnlBaseFileName(_s_defaultJrnlBaseFileName),
+ _numJrnlFiles(_s_defaultNumJrnlFiles),
+ _jrnlFileSize_sblks(_s_defaultJrnlFileSize_sblks),
+ _autoExpand(_s_defaultAutoExpand),
+ _autoExpandMaxJrnlFiles(_s_defaultAutoExpandMaxJrnlFiles),
+ _writeBuffNumPgs(_s_defaultWriteBuffNumPgs),
+ _writeBuffPgSize_sblks(_s_defaultWriteBuffPgSize_sblks)
+ {}
-JournalParameters::JournalParameters(const std::string& jrnlDir,
- const std::string& jrnlBaseFileName,
- const u_int16_t numJrnlFiles,
- const bool autoExpand,
- const u_int16_t autoExpandMaxJrnlFiles,
- const u_int32_t jrnlFileSize_sblks,
- const u_int16_t writeBuffNumPgs,
- const u_int32_t writeBuffPgSize_sblks) :
- _jrnlDir(jrnlDir),
- _jrnlBaseFileName(jrnlBaseFileName),
- _numJrnlFiles(numJrnlFiles),
- _jrnlFileSize_sblks(jrnlFileSize_sblks),
- _autoExpand(autoExpand),
- _autoExpandMaxJrnlFiles(autoExpandMaxJrnlFiles),
- _writeBuffNumPgs(writeBuffNumPgs),
- _writeBuffPgSize_sblks(writeBuffPgSize_sblks)
-{}
+ JournalParameters::JournalParameters(const std::string& jrnlDir,
+ const std::string& jrnlBaseFileName,
+ const u_int16_t numJrnlFiles,
+ const bool autoExpand,
+ const u_int16_t autoExpandMaxJrnlFiles,
+ const u_int32_t jrnlFileSize_sblks,
+ const u_int16_t writeBuffNumPgs,
+ const u_int32_t writeBuffPgSize_sblks) :
+ _jrnlDir(jrnlDir),
+ _jrnlBaseFileName(jrnlBaseFileName),
+ _numJrnlFiles(numJrnlFiles),
+ _jrnlFileSize_sblks(jrnlFileSize_sblks),
+ _autoExpand(autoExpand),
+ _autoExpandMaxJrnlFiles(autoExpandMaxJrnlFiles),
+ _writeBuffNumPgs(writeBuffNumPgs),
+ _writeBuffPgSize_sblks(writeBuffPgSize_sblks)
+ {}
-JournalParameters::JournalParameters(const JournalParameters& sp) :
- _jrnlDir(sp._jrnlDir),
- _jrnlBaseFileName(sp._jrnlBaseFileName),
- _numJrnlFiles(sp._numJrnlFiles),
- _jrnlFileSize_sblks(sp._jrnlFileSize_sblks),
- _autoExpand(sp._autoExpand),
- _autoExpandMaxJrnlFiles(sp._autoExpandMaxJrnlFiles),
- _writeBuffNumPgs(sp._writeBuffNumPgs),
- _writeBuffPgSize_sblks(sp._writeBuffPgSize_sblks)
+ JournalParameters::JournalParameters(const JournalParameters& sp) :
+ _jrnlDir(sp._jrnlDir),
+ _jrnlBaseFileName(sp._jrnlBaseFileName),
+ _numJrnlFiles(sp._numJrnlFiles),
+ _jrnlFileSize_sblks(sp._jrnlFileSize_sblks),
+ _autoExpand(sp._autoExpand),
+ _autoExpandMaxJrnlFiles(sp._autoExpandMaxJrnlFiles),
+ _writeBuffNumPgs(sp._writeBuffNumPgs),
+ _writeBuffPgSize_sblks(sp._writeBuffPgSize_sblks)
+ {}
-{}
+ void
+ JournalParameters::toStream(std::ostream& os) const
+ {
+ os << "Store Parameters:" << std::endl;
+ os << " jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
+ os << " jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
+ os << " numJrnlFiles = " << _numJrnlFiles << std::endl;
+ os << " jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
+ os << " autoExpand = " << _autoExpand << std::endl;
+ os << " autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
+ os << " writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
+ os << " writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
+ }
-void
-JournalParameters::toStream(std::ostream& os) const
-{
- os << "Store Parameters:" << std::endl;
- os << " jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
- os << " jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
- os << " numJrnlFiles = " << _numJrnlFiles << std::endl;
- os << " jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
- os << " autoExpand = " << _autoExpand << std::endl;
- os << " autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
- os << " writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
- os << " writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
-}
+ std::string
+ JournalParameters::toString() const
+ {
+ std::ostringstream oss;
+ toStream(oss);
+ return oss.str();
+ }
-std::string
-JournalParameters::toString() const
-{
- std::ostringstream oss;
- toStream(oss);
- return oss.str();
-}
+ std::ostream&
+ operator<<(std::ostream& os, const JournalParameters& jp)
+ {
+ jp.toStream(os);
+ return os;
+ }
-std::ostream&
-operator<<(std::ostream& os, const JournalParameters& jp)
-{
- jp.toStream(os);
- return os;
-}
+ std::ostream&
+ operator<<(std::ostream& os, const JournalParameters* jpPtr)
+ {
+ jpPtr->toStream(os);
+ return os;
+ }
-std::ostream&
-operator<<(std::ostream& os, const JournalParameters* jpPtr)
-{
- jpPtr->toStream(os);
- return os;
-}
-
} // namespace journal2
} // namespace mrg
Modified: store/trunk/cpp/lib/jrnl2/JournalParameters.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalParameters.hpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/JournalParameters.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -34,7 +34,7 @@
#include <iostream>
#include <string>
-#include <sys/types.h>
+#include <sys/types.h> // u_int16_t, u_int32_t
namespace mrg
{
Copied: store/trunk/cpp/lib/jrnl2/JournalState.cpp (from rev 4435, store/trunk/cpp/lib/jrnl2/jrnl_state.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalState.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/JournalState.cpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -0,0 +1,171 @@
+/**
+ * \file JournalState.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "JournalState.hpp"
+
+#include "JournalException.hpp"
+
+namespace mrg
+{
+namespace journal2
+{
+
+ JournalState::JournalState() :
+ _journalState(JS_NONE)
+ {}
+
+ JournalState::JournalState(const JournalState& s) :
+ _journalState(s._journalState)
+ {}
+
+ JournalState::JournalState(const journalState_t s) :
+ _journalState(s)
+ {}
+
+ const journalState_t&
+ JournalState::get() const
+ {
+ return _journalState;
+ }
+
+ void
+ JournalState::set(const journalState_t s)
+ {
+ _journalState = s;
+ }
+
+ void
+ JournalState::reset()
+ {
+ _journalState = JS_NONE;
+ }
+
+ void
+ JournalState::setStateInitializing()
+ {
+ if (_journalState != JS_NONE)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
+ s_getStateAsString(JS_INITIALIZING),
+ s_getStateAsString(_journalState),
+ "JournalState",
+ "setStateInitializing");
+ _journalState = JS_INITIALIZING;
+ }
+
+ void
+ JournalState::setStateRecoverPhase1()
+ {
+ if (_journalState != JS_NONE)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
+ s_getStateAsString(JS_RECOVERING_PHASE_1),
+ s_getStateAsString(_journalState),
+ "JournalState",
+ "setStateRecoverPhase1");
+ _journalState = JS_RECOVERING_PHASE_1;
+ }
+
+ void
+ JournalState::setStateRecoverPhase2()
+ {
+ if (_journalState != JS_RECOVERING_PHASE_1)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
+ s_getStateAsString(JS_RECOVERING_PHASE_2),
+ s_getStateAsString(_journalState),
+ "JournalState",
+ "setStateRecoverPhase2");
+ _journalState = JS_RECOVERING_PHASE_2;
+ }
+
+ void
+ JournalState::setStateRunning()
+ {
+ if (_journalState != JS_INITIALIZING ||_journalState != JS_RECOVERING_PHASE_2 )
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
+ s_getStateAsString(JS_RUNNING),
+ s_getStateAsString(_journalState),
+ "JournalState",
+ "setStateRunning");
+ _journalState = JS_RUNNING;
+ }
+
+ void
+ JournalState::setStateStopping()
+ {
+ if (_journalState != JS_RUNNING)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
+ s_getStateAsString(JS_STOPPING),
+ s_getStateAsString(_journalState),
+ "JournalState",
+ "setStateStopping");
+ _journalState = JS_STOPPING;
+ }
+
+ void
+ JournalState::setStateStopped()
+ {
+ if (_journalState != JS_STOPPING)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
+ s_getStateAsString(JS_STOPPED),
+ s_getStateAsString(_journalState),
+ "JournalState",
+ "setStateStopped");
+ _journalState = JS_STOPPED;
+ }
+
+ //static
+ std::string
+ JournalState::s_getStateAsString(journalState_t s)
+ {
+ switch (s) {
+ case JS_NONE:
+ return "JS_NONE";
+ case JS_RECOVERING_PHASE_1:
+ return "JS_RECOVERING_PHASE_1";
+ case JS_RECOVERING_PHASE_2:
+ return "JS_RECOVERING_PHASE_2";
+ case JS_INITIALIZING:
+ return "JS_INITIALIZING";
+ case JS_RUNNING:
+ return "JS_RUNNING";
+ case JS_STOPPING:
+ return "JS_STOPPING";
+ case JS_STOPPED:
+ return "JS_STOPPED";
+ default:
+ std::ostringstream oss;
+ oss << "<unknown state (" << "s" << ")>";
+ return oss.str();
+ }
+ }
+
+} // namespace journal2
+} // namespace mrg
+
Copied: store/trunk/cpp/lib/jrnl2/JournalState.hpp (from rev 4435, store/trunk/cpp/lib/jrnl2/jrnl_state.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalState.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/JournalState.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -0,0 +1,103 @@
+/**
+ * \file JournalState.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_journal2_JournalState_hpp
+#define mrg_journal2_JournalState_hpp
+
+#include <string>
+
+namespace mrg
+{
+namespace journal2
+{
+
+ /**
+ * Journal state machine
+ *
+ * JS_NONE *
+ * / \
+ * / v
+ * | o JS_RECOVERING_PHASE_1
+ * v |
+ * JS_INITIALIZING o v
+ * | o JS_RECOVERING_PHASE_2
+ * \ /
+ * v v
+ * JS_RUNNING o
+ * |
+ * v
+ * JS_STOPPING o
+ * |
+ * v
+ * JS_STOPPED *
+ */
+ typedef enum
+ {
+ JS_NONE = 0,
+ JS_RECOVERING_PHASE_1,
+ JS_RECOVERING_PHASE_2,
+ JS_INITIALIZING,
+ JS_RUNNING,
+ JS_STOPPING,
+ JS_STOPPED
+ } journalState_t;
+
+ class JournalState
+ {
+ protected:
+ journalState_t _journalState;
+ public:
+ JournalState();
+ JournalState(const JournalState& s);
+ JournalState(const journalState_t s);
+
+ // Raw state get/set functions
+ const journalState_t& get() const;
+ void set(const journalState_t s);
+
+ // State change functions
+ void reset();
+ void setStateInitializing();
+ void setStateRecoverPhase1();
+ void setStateRecoverPhase2();
+ void setStateRunning();
+ void setStateStopping();
+ void setStateStopped();
+
+ static std::string s_getStateAsString(journalState_t s);
+ };
+
+} // namespace journal2
+} // namespace mrg
+
+
+#endif // mrg_journal2_JournalState_hpp
+
Modified: store/trunk/cpp/lib/jrnl2/Makefile.am
===================================================================
--- store/trunk/cpp/lib/jrnl2/Makefile.am 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/Makefile.am 2010-12-10 20:52:48 UTC (rev 4436)
@@ -23,27 +23,23 @@
lib_LTLIBRARIES = libasyncjrnl2.la
-libasyncjrnl2_la_SOURCES = \
- DataToken.cpp \
- DataTokenState.cpp \
- JournalDirectory.cpp \
- JournalErrors.cpp \
- JournalException.cpp \
- jrnl.cpp \
- jrnl_state.cpp \
- slock.cpp \
- smutex.cpp \
- JournalParameters.cpp \
- AioCallback.hpp \
- dtok.hpp \
- DataTokenState.hpp \
- JournalDirectory.hpp \
- JournalErrors.hpp \
- JournalException.hpp \
- jrnl.hpp \
- jrnl_state.hpp \
- slock.hpp \
- smutex.hpp \
- JournalParameters.hpp \
- txn_ctxt.hpp
+libasyncjrnl2_la_SOURCES = \
+ DataToken.cpp \
+ DataTokenState.cpp \
+ Journal.cpp \
+ JournalDirectory.cpp \
+ JournalErrors.cpp \
+ JournalException.cpp \
+ JournalParameters.cpp \
+ JournalState.cpp \
+ AioCallback.hpp \
+ DataToken.hpp \
+ DataTokenState.hpp \
+ Journal.hpp \
+ JournalDirectory.hpp \
+ JournalErrors.hpp \
+ JournalException.hpp \
+ JournalParameters.hpp \
+ JournalState.hpp \
+ ScopedLock.hpp
Copied: store/trunk/cpp/lib/jrnl2/ScopedLock.hpp (from rev 4435, store/trunk/cpp/lib/jrnl2/slock.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/ScopedLock.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/ScopedLock.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -0,0 +1,110 @@
+/**
+ * \file ScopedLock.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_journal2_ScopedLock_hpp
+#define mrg_journal2_ScopedLock_hpp
+
+#include <cerrno> // EBUSY
+#include <pthread.h>
+
+#include "JournalException.hpp"
+
+namespace mrg
+{
+namespace journal2
+{
+
+ // Ultra-simple scoped mutex class that allows a posix mutex to be initialized and destroyed with error checks
+ class ScopedMutex
+ {
+ protected:
+ mutable pthread_mutex_t _m;
+ public:
+ inline ScopedMutex()
+ {
+ PTHREAD_CHK(::pthread_mutex_init(&_m, 0), "::pthread_mutex_init", "smutex", "smutex");
+ }
+ inline ~ScopedMutex()
+ {
+ PTHREAD_CHK(::pthread_mutex_destroy(&_m), "::pthread_mutex_destroy", "smutex", "~smutex");
+ }
+ inline pthread_mutex_t* get() const { return &_m; }
+ };
+
+ // Scoped-mutex (sm) container, superclass for scoped lock classes
+ class ScopedMutexContainer
+ {
+ protected:
+ const ScopedMutex& _sm;
+ public:
+ ScopedMutexContainer(const ScopedMutex& sm) : _sm(sm) {}
+ virtual ~ScopedMutexContainer() {}
+ inline const ScopedMutex& get() const { return _sm; }
+ };
+
+ // Ultra-simple scoped lock class, auto-releases mutex when it goes out-of-scope
+ class ScopedLock : public ScopedMutexContainer
+ {
+ public:
+ inline ScopedLock(const ScopedMutex& sm) : ScopedMutexContainer(sm)
+ {
+ PTHREAD_CHK(::pthread_mutex_lock(_sm.get()), "::pthread_mutex_lock", "slock", "slock");
+ }
+ virtual inline ~ScopedLock()
+ {
+ PTHREAD_CHK(::pthread_mutex_unlock(_sm.get()), "::pthread_mutex_unlock", "slock", "~slock");
+ }
+ };
+
+ // Ultra-simple scoped try-lock class, auto-releases mutex when it goes out-of-scope
+ class ScopedTryLock : public ScopedMutexContainer
+ {
+ protected:
+ bool _lockedFlag;
+ public:
+ inline ScopedTryLock(const ScopedMutex& sm) : ScopedMutexContainer(sm), _lockedFlag(false)
+ {
+ int ret = ::pthread_mutex_trylock(_sm.get());
+ _lockedFlag = (ret == 0); // check if lock obtained
+ if (!_lockedFlag && ret != EBUSY) PTHREAD_CHK(ret, "::pthread_mutex_trylock", "stlock", "stlock");
+ }
+ virtual inline ~ScopedTryLock()
+ {
+ if (_lockedFlag)
+ PTHREAD_CHK(::pthread_mutex_unlock(_sm.get()), "::pthread_mutex_unlock", "stlock", "~stlock");
+ }
+ inline bool isLocked() const { return _lockedFlag; }
+ };
+
+} // namespace journal2
+} // namespace mrg
+
+#endif // ifndef mrg_journal2_ScopedLock_hpp
Deleted: store/trunk/cpp/lib/jrnl2/jrnl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jrnl.cpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/jrnl.cpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -1,184 +0,0 @@
-/**
- * \file jrnl.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "jrnl.hpp"
-
-// --- temp code ---
-#include <iostream>
-#include <vector>
-// --- end temp code ---
-
-namespace mrg
-{
-namespace journal2
-{
-
-std::string
-iores_str(const iores /*res*/)
-{
- // TODO - provide implementation
- return ".[iores_str].";
-}
-
-// static
-u_int32_t jrnl::list_thresh = 50;
-
-jrnl::jrnl(const std::string& jid,
- const std::string& jdir,
- const std::string& base_filename) :
- _jid(jid),
- _jdir(jdir),
- _base_filename(base_filename),
- _store_params_ptr(0),
- _cbp(0)
- // --- temp code ---
- , cb_dtok_list_switch(false)
- // --- end temp code ---
-{}
-
-void
-jrnl::initialize(const JournalParameters* sp, AioCallback* const cbp)
-{
- _store_params_ptr = sp;
- _cbp = cbp;
-}
-
-iores
-jrnl::enqueue(const void* const /*msg_ptr*/, const std::size_t /*msg_size*/, DataToken* const dtokp)
-{
- dtokp->getDataTokenState().setOpStateToEnqueue();
- // --- temp code ---
- bool flush_flag;
- {
- slock l(wr_dtok_list_lock);
- wr_dtok_list.push_back(dtokp);
- flush_flag = wr_dtok_list.size() >= list_thresh;
- if (flush_flag) flush_nl(false);
- }
- if (flush_flag) get_wr_events(0);
- // --- end temp code ---
- return 0;
-}
-
-iores
-jrnl::dequeue(DataToken* const dtokp)
-{
- dtokp->getDataTokenState().setOpStateToDequeue();
- dtokp->setDequeueRecordId(dtokp->getRecordId());
- // --- temp code ---
- bool flush_flag;
- {
- slock l(wr_dtok_list_lock);
- wr_dtok_list.push_back(dtokp);
- flush_flag = wr_dtok_list.size() >= list_thresh;
- if (flush_flag) flush_nl(false);
- }
- if (flush_flag) get_wr_events(0);
- // --- end temp code ---
- return 0;
-}
-
-iores
-jrnl::commit()
-{
- // TODO
- return 0;
-}
-
-iores
-jrnl::abort()
-{
- // TODO
- return 0;
-}
-
-u_int32_t
-jrnl::get_wr_aio_evt_rem() const
-{
- while (true) {
- stlock l1(cb_dtok_list_lock);
- stlock l2(wr_dtok_list_lock);
- if (l1.locked() && l2.locked()) {
- return cb_dtok_list[0].size() + cb_dtok_list[1].size();
- } else {
- //::usleep(10);
- }
- };
-}
-
-void
-jrnl::flush(const bool block_till_aio_cmpl)
-{
- // --- temp code ---
- stlock l(wr_dtok_list_lock);
- if (l.locked()) {
- flush_nl(block_till_aio_cmpl);
- }
- // --- end temp code ---
-}
-
-// protected
-void
-jrnl::flush_nl(const bool /*block_till_aio_cmpl*/)
-{
- // --- temp code ---
- int i = cb_dtok_list_switch ? 1 : 0;
- while (wr_dtok_list.size()) {
- cb_dtok_list[i].push_back(wr_dtok_list.back());
- wr_dtok_list.pop_back();
- }
- // --- end temp code ---
-}
-
-void
-jrnl::get_wr_events(timespec* const /*timeout*/)
-{
- // --- temp code ---
- stlock l1(cb_dtok_list_lock);
- if (l1.locked()) {
- int i = cb_dtok_list_switch ? 0 : 1;
- if (cb_dtok_list[i].size() && _cbp) {
- _cbp->writeAioCompleteCallback(cb_dtok_list[i]);
- }
- cb_dtok_list[i].clear();
-
- // take both locks before allowing switch to change
- {
- slock l2(wr_dtok_list_lock);
- cb_dtok_list_switch = !cb_dtok_list_switch;
- }
- }
- // --- end temp code ---
-}
-
-} // namespace journal2
-} // namespace mrg
-
Deleted: store/trunk/cpp/lib/jrnl2/jrnl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jrnl.hpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/jrnl.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -1,112 +0,0 @@
-/**
- * \file jrnl.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_journal2_jnrl_hpp
-#define mrg_journal2_jnrl_hpp
-
-#include <string>
-#include <sys/types.h> // u_int64_t, u_int32_t, etc.
-#include <time.h> // timespec
-
-#include "AioCallback.hpp"
-#include "DataToken.hpp"
-#include "jrnl_state.hpp"
-#include "JournalParameters.hpp"
-
-// --- temp code ---
-#include "slock.hpp"
-#include "smutex.hpp"
-#include <vector>
-// --- end temp code ---
-
-namespace mrg
-{
-namespace journal2
-{
-
- // TODO - decide if this is the right place to expose these codes and flags
- typedef u_int64_t iores; // TODO - this needs to be expressed as flags
- const iores RHM_IORES_ENQCAPTHRESH = 0x1;
- const iores RHM_IORES_BUSY = 0x2;
- std::string iores_str(const iores /*res*/);
-
- class jrnl
- {
- protected:
- std::string _jid;
- std::string _jdir;
- std::string _base_filename;
- jrnl_state _jrnl_state;
- const JournalParameters* _store_params_ptr;
- AioCallback* _cbp;
-
- // --- temp code ---
- static u_int32_t list_thresh;
- std::vector<DataToken*> wr_dtok_list;
- std::vector<DataToken*> cb_dtok_list[2];
- bool cb_dtok_list_switch;
- smutex wr_dtok_list_lock;
- smutex cb_dtok_list_lock;
- // --- end temp code ---
-
- void flush_nl(const bool block_till_aio_cmpl);
- public:
- jrnl(const std::string& jid, const std::string& jdir, const std::string& base_filename);
-
- // get functions
- inline std::string get_id() { return _jid; }
- inline std::string get_dir() { return _jdir; }
- inline std::string get_base_filename() { return _base_filename; }
- inline const jrnl_state& get_jrnl_state() { return _jrnl_state; }
- inline const JournalParameters* get_store_params() const { return _store_params_ptr; }
-
- // msg ops
- void initialize(const JournalParameters* sp, AioCallback* const cbp);
- iores enqueue(const void* const msg_ptr, const std::size_t msg_size, DataToken* const dtokp);
- iores dequeue(DataToken* const dtokp);
- iores commit();
- iores abort();
-
- // aio ops and status
- // --- temp code ---
- u_int32_t get_wr_aio_evt_rem() const;
- // --- end of temp code ---
- void flush(const bool block_till_aio_cmpl);
- void get_wr_events(timespec* const timeout);
- };
-
-
-} // namespace journal2
-} // namespace mrg
-
-
-#endif // mrg_journal2_jnrl_hpp
-
Deleted: store/trunk/cpp/lib/jrnl2/jrnl_state.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jrnl_state.cpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/jrnl_state.cpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -1,180 +0,0 @@
-/**
- * \file jrnl_state.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "jrnl_state.hpp"
-
-#include "JournalException.hpp"
-
-namespace mrg
-{
-namespace journal2
-{
-
-jrnl_state::jrnl_state() : _jrnl_state(JS_NONE)
-{}
-
-jrnl_state::jrnl_state(const jrnl_state& s) : _jrnl_state(s._jrnl_state)
-{}
-
-jrnl_state::jrnl_state(const jrnl_state_t s) : _jrnl_state(s)
-{}
-
-const jrnl_state_t&
-jrnl_state::get() const
-{
- return _jrnl_state;
-}
-
-void
-jrnl_state::set(const jrnl_state_t s)
-{
- _jrnl_state = s;
-}
-
-void
-jrnl_state::reset()
-{
- _jrnl_state = JS_NONE;
-}
-
-void
-jrnl_state::initialize()
-{
- if (_jrnl_state != JS_NONE)
- THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
- get_state_str(JS_INITIALIZING),
- get_state_str(_jrnl_state),
- "jrnl_state",
- "initialize");
- _jrnl_state = JS_INITIALIZING;
-}
-
-void
-jrnl_state::initialize_compl()
-{
- if (_jrnl_state != JS_INITIALIZING)
- THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
- get_state_str(JS_RUNNING),
- get_state_str(_jrnl_state),
- "jrnl_state",
- "initialize_compl");
- _jrnl_state = JS_RUNNING;
-}
-
-void
-jrnl_state::recover_phase_1()
-{
- if (_jrnl_state != JS_NONE)
- THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
- get_state_str(JS_RECOVERING_PHASE_1),
- get_state_str(_jrnl_state),
- "jrnl_state",
- "recover_phase_1");
- _jrnl_state = JS_RECOVERING_PHASE_1;
-}
-
-void
-jrnl_state::recover_phase_2()
-{
- if (_jrnl_state != JS_RECOVERING_PHASE_1)
- THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
- get_state_str(JS_RECOVERING_PHASE_2),
- get_state_str(_jrnl_state),
- "jrnl_state",
- "recover_phase_2");
- _jrnl_state = JS_RECOVERING_PHASE_2;
-}
-
-void
-jrnl_state::recover_compl()
-{
- if (_jrnl_state != JS_RECOVERING_PHASE_2)
- THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
- get_state_str(JS_RUNNING),
- get_state_str(_jrnl_state),
- "jrnl_state",
- "recover_compl");
- _jrnl_state = JS_RUNNING;
-}
-
-void
-jrnl_state::stop()
-{
- if (_jrnl_state != JS_RUNNING)
- THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
- get_state_str(JS_STOPPING),
- get_state_str(_jrnl_state),
- "jrnl_state",
- "stop");
- _jrnl_state = JS_STOPPING;
-}
-
-void
-jrnl_state::stop_compl()
-{
- if (_jrnl_state != JS_STOPPING)
- THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
- get_state_str(JS_STOPPED),
- get_state_str(_jrnl_state),
- "jrnl_state",
- "stop_compl");
- _jrnl_state = JS_STOPPED;
-}
-
-//static
-std::string
-jrnl_state::get_state_str(jrnl_state_t s)
-{
- switch (s) {
- case JS_NONE:
- return "JS_NONE";
- case JS_RECOVERING_PHASE_1:
- return "JS_RECOVERING_PHASE_1";
- case JS_RECOVERING_PHASE_2:
- return "JS_RECOVERING_PHASE_2";
- case JS_INITIALIZING:
- return "JS_INITIALIZING";
- case JS_RUNNING:
- return "JS_RUNNING";
- case JS_STOPPING:
- return "JS_STOPPING";
- case JS_STOPPED:
- return "JS_STOPPED";
- default:
- std::ostringstream oss;
- oss << "<unknown state (" << "s" << ")>";
- return oss.str();
- }
-}
-
-} // namespace journal2
-} // namespace mrg
-
Deleted: store/trunk/cpp/lib/jrnl2/jrnl_state.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jrnl_state.hpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/jrnl_state.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -1,104 +0,0 @@
-/**
- * \file jrnl_state.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_journal2_jrnl_state_hpp
-#define mrg_journal2_jrnl_state_hpp
-
-#include <string>
-
-namespace mrg
-{
-namespace journal2
-{
-
- /**
- * Journal state machine
- *
- * JS_NONE *
- * / \
- * / v
- * | o JS_RECOVERING_PHASE_1
- * v |
- * JS_INITIALIZING o v
- * | o JS_RECOVERING_PHASE_2
- * \ /
- * v v
- * JS_RUNNING o
- * |
- * v
- * JS_STOPPING o
- * |
- * v
- * JS_STOPPED *
- */
- typedef enum
- {
- JS_NONE = 0,
- JS_RECOVERING_PHASE_1,
- JS_RECOVERING_PHASE_2,
- JS_INITIALIZING,
- JS_RUNNING,
- JS_STOPPING,
- JS_STOPPED
- } jrnl_state_t;
-
- class jrnl_state
- {
- protected:
- jrnl_state_t _jrnl_state;
- public:
- jrnl_state();
- jrnl_state(const jrnl_state& s);
- jrnl_state(const jrnl_state_t s);
-
- // Raw state get/set functions
- const jrnl_state_t& get() const;
- void set(const jrnl_state_t s);
-
- // State change functions
- void reset();
- void initialize();
- void initialize_compl();
- void recover_phase_1();
- void recover_phase_2();
- void recover_compl();
- void stop();
- void stop_compl();
-
- static std::string get_state_str(jrnl_state_t s);
- };
-
-} // namespace journal2
-} // namespace mrg
-
-
-#endif // mrg_journal2_jrnl_state_hpp
-
Deleted: store/trunk/cpp/lib/jrnl2/slock.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/slock.cpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/slock.cpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -1,32 +0,0 @@
-/**
- * \file slock.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "slock.hpp"
Deleted: store/trunk/cpp/lib/jrnl2/slock.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/slock.hpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/slock.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -1,94 +0,0 @@
-/**
- * \file slock.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_journal2_slock_hpp
-#define mrg_journal2_slock_hpp
-
-#include <cerrno> // EBUSY
-#include <pthread.h>
-
-#include "JournalException.hpp"
-#include "smutex.hpp"
-
-namespace mrg
-{
-namespace journal2
-{
-
- // Scoped-mutex (sm) container, superclass for scoped lock classes
- class sm_cntnr
- {
- protected:
- const smutex& _sm;
- public:
- sm_cntnr(const smutex& sm) : _sm(sm) {}
- virtual ~sm_cntnr() {}
- inline const smutex& get() const { return _sm; }
- };
-
- // Ultra-simple scoped lock class, auto-releases mutex when it goes out-of-scope
- class slock : public sm_cntnr
- {
- public:
- inline slock(const smutex& sm) : sm_cntnr(sm)
- {
- PTHREAD_CHK(::pthread_mutex_lock(_sm.get()), "::pthread_mutex_lock", "slock", "slock");
- }
- virtual inline ~slock()
- {
- PTHREAD_CHK(::pthread_mutex_unlock(_sm.get()), "::pthread_mutex_unlock", "slock", "~slock");
- }
- };
-
- // Ultra-simple scoped try-lock class, auto-releases mutex when it goes out-of-scope
- class stlock : public sm_cntnr
- {
- protected:
- bool _locked;
- public:
- inline stlock(const smutex& sm) : sm_cntnr(sm), _locked(false)
- {
- int ret = ::pthread_mutex_trylock(_sm.get());
- _locked = (ret == 0); // check if lock obtained
- if (!_locked && ret != EBUSY) PTHREAD_CHK(ret, "::pthread_mutex_trylock", "stlock", "stlock");
- }
- virtual inline ~stlock()
- {
- if (_locked)
- PTHREAD_CHK(::pthread_mutex_unlock(_sm.get()), "::pthread_mutex_unlock", "stlock", "~stlock");
- }
- inline bool locked() const { return _locked; }
- };
-
-} // namespace journal2
-} // namespace mrg
-
-#endif // ifndef mrg_journal2_slock_hpp
Deleted: store/trunk/cpp/lib/jrnl2/smutex.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/smutex.cpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/smutex.cpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -1,32 +0,0 @@
-/**
- * \file smutex.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "smutex.hpp"
Deleted: store/trunk/cpp/lib/jrnl2/smutex.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/smutex.hpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/smutex.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -1,64 +0,0 @@
-/**
- * \file smutex.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_journal2_smutex_hpp
-#define mrg_journal2_smutex_hpp
-
-#include <pthread.h>
-
-#include "JournalException.hpp"
-
-namespace mrg
-{
-namespace journal2
-{
-
- // Ultra-simple scoped mutex class that allows a posix mutex to be initialized and destroyed with error checks
- class smutex
- {
- protected:
- mutable pthread_mutex_t _m;
- public:
- inline smutex()
- {
- PTHREAD_CHK(::pthread_mutex_init(&_m, 0), "::pthread_mutex_init", "smutex", "smutex");
- }
- inline ~smutex()
- {
- PTHREAD_CHK(::pthread_mutex_destroy(&_m), "::pthread_mutex_destroy", "smutex", "~smutex");
- }
- inline pthread_mutex_t* get() const { return &_m; }
- };
-
-} // namespace journal2
-} // namespace mrg
-
-#endif // ifndef mrg_journal2_smutex_hpp
Deleted: store/trunk/cpp/lib/jrnl2/txn_ctxt.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/txn_ctxt.hpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/lib/jrnl2/txn_ctxt.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -1,54 +0,0 @@
-/**
- * \file txn_ctxt.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_test_txn_ctxt_hpp
-#define mrg_test_txn_ctxt_hpp
-
-#include <string>
-
-namespace mrg
-{
-namespace journal2
-{
-
- class txn_ctxt
- {
- public:
- virtual ~txn_ctxt() {}
- virtual std::string& tid() = 0;
- virtual bool is_dist_txn() = 0;
- };
-
-} // namespace journal2
-} // namespace mrg
-
-
-#endif // mrg_test_txn_ctxt_hpp
Modified: store/trunk/cpp/perf/JournalInstance.cpp
===================================================================
--- store/trunk/cpp/perf/JournalInstance.cpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/perf/JournalInstance.cpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -42,7 +42,7 @@
const uint32_t msgSize,
const char* msgData,
#ifdef JOURNAL2
- mrg::journal2::jrnl* const jrnlPtr) :
+ mrg::journal2::Journal* const jrnlPtr) :
#else
mrg::journal::jcntl* const jrnlPtr) :
#endif
@@ -70,7 +70,7 @@
while (i < _numMsgs) {
#ifdef JOURNAL2
mrg::journal2::DataToken* dtokPtr = new mrg::journal2::DataToken();
- mrg::journal2::iores jrnlIoRes = _jrnlPtr->enqueue(_msgData, _msgSize, dtokPtr);
+ mrg::journal2::ioRes jrnlIoRes = _jrnlPtr->enqueue(_msgData, _msgSize, dtokPtr);
#else
mrg::journal::data_tok* dtokPtr = new mrg::journal::data_tok();
mrg::journal::iores jrnlIoRes = _jrnlPtr->enqueue_data_record(_msgData, _msgSize, _msgSize, dtokPtr);
@@ -108,7 +108,7 @@
default:
delete dtokPtr;
#ifdef JOURNAL2
- std::cerr << "enqueue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << std::endl;
+ std::cerr << "enqueue_data_record FAILED with " << mrg::journal2::g_ioResAsString(jrnlIoRes) << std::endl;
#else
std::cerr << "enqueue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << std::endl;
#endif
@@ -132,24 +132,28 @@
mrg::journal::data_tok* dtokPtr = 0;
#endif
while (!dtokPtr) {
- bool getEventsFlag; // thread local
+ bool aioEventsFlag; // thread local
{ // --- START OF CRITICAL SECTION ---
std::lock_guard<std::mutex> l(_unprocCallbackListMutex);
- getEventsFlag = _unprocCallbackList.size() == 0;
- if (!getEventsFlag) {
+ aioEventsFlag = _unprocCallbackList.size() == 0;
+ if (!aioEventsFlag) {
dtokPtr = _unprocCallbackList.front();
_unprocCallbackList.pop();
}
} // --- END OF CRITICAL SECTION ---
- if (getEventsFlag) {
+ if (aioEventsFlag) {
+#ifdef JOURNAL2
+ _jrnlPtr->processCompletedAioWriteEvents(0);
+#else
_jrnlPtr->get_wr_events(0);
+#endif
::usleep(1);
}
}
bool done = false;
while (!done) {
#ifdef JOURNAL2
- mrg::journal2::iores jrnlIoRes = _jrnlPtr->dequeue(dtokPtr);
+ mrg::journal2::ioRes jrnlIoRes = _jrnlPtr->dequeue(dtokPtr);
#else
mrg::journal::iores jrnlIoRes = _jrnlPtr->dequeue_data_record(dtokPtr);
#endif
@@ -171,7 +175,7 @@
break;
default:
#ifdef JOURNAL2
- std::cerr << "dequeue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << ": "
+ std::cerr << "dequeue_data_record FAILED with " << mrg::journal2::g_ioResAsString(jrnlIoRes) << ": "
<< dtokPtr->statusStr() << std::endl;
#else
std::cerr << "dequeue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << ": "
@@ -181,7 +185,11 @@
done = true;
}
}
+#ifdef JOURNAL2
+ _jrnlPtr->processCompletedAioWriteEvents(0);
+#else
_jrnlPtr->get_wr_events(0);
+#endif
}
_jrnlPtr->flush(true);
}
Modified: store/trunk/cpp/perf/JournalInstance.hpp
===================================================================
--- store/trunk/cpp/perf/JournalInstance.hpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/perf/JournalInstance.hpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -39,7 +39,7 @@
#ifdef JOURNAL2
#include "jrnl2/AioCallback.hpp"
#include "jrnl2/DataToken.hpp"
-#include "jrnl2/jrnl.hpp"
+#include "jrnl2/Journal.hpp"
#else
#include "jrnl/aio_callback.hpp"
#include "jrnl/data_tok.hpp"
@@ -68,7 +68,7 @@
const uint32_t _msgSize; ///< Size of each message (in bytes)
const char* _msgData; ///< Pointer to message content to be used for each message.
#ifdef JOURNAL2
- mrg::journal2::jrnl* const _jrnlPtr; ///< Journal instance pointer
+ mrg::journal2::Journal* const _jrnlPtr; ///< Journal instance pointer
std::queue<mrg::journal2::DataToken*> _unprocCallbackList; ///< Queue of unprocessed callbacks to be dequeued
#else
mrg::journal::jcntl* const _jrnlPtr; ///< Journal instance pointer
@@ -114,7 +114,7 @@
JournalInstance(const uint32_t numMsgs,
const uint32_t msgSize,
const char* msgData,
- mrg::journal2::jrnl* const jrnlPtr);
+ mrg::journal2::Journal* const jrnlPtr);
#else
JournalInstance(const uint32_t numMsgs,
const uint32_t msgSize,
Modified: store/trunk/cpp/perf/JournalPerformanceTest.cpp
===================================================================
--- store/trunk/cpp/perf/JournalPerformanceTest.cpp 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/perf/JournalPerformanceTest.cpp 2010-12-10 20:52:48 UTC (rev 4436)
@@ -81,7 +81,7 @@
mrg::journal2::JournalDirectory::s_delete(_jrnlParams._jrnlDir);
}
mrg::journal2::JournalDirectory::s_create(_jrnlParams._jrnlDir);
- mrg::journal2::jrnl* jp;
+ mrg::journal2::Journal* jp;
#else
if (mrg::journal::jdir::exists(_jrnlParams._jrnlDir)) {
mrg::journal::jdir::delete_dir(_jrnlParams._jrnlDir);
@@ -96,7 +96,7 @@
std::ostringstream jdir;
jdir << _jrnlParams._jrnlDir << "/" << jname.str();
#ifdef JOURNAL2
- jp = new mrg::journal2::jrnl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
+ jp = new mrg::journal2::Journal(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
#else
jp = new mrg::journal::jcntl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
#endif
Modified: store/trunk/cpp/perf/m
===================================================================
--- store/trunk/cpp/perf/m 2010-12-09 14:33:48 UTC (rev 4435)
+++ store/trunk/cpp/perf/m 2010-12-10 20:52:48 UTC (rev 4436)
@@ -5,7 +5,7 @@
# The variable JOURNAL2, if defined, will link with the new journal2 namespace journal. Otherwise the old journal
# namespace will be used.
-JOURNAL2=1
+#JOURNAL2=1
# Optimization options
#OPT="-O0 -ggdb"
@@ -58,16 +58,14 @@
DEFINES=-DJOURNAL2
-JRNL_FILES="../lib/jrnl2/DataToken.cpp \
+JRNL_FILES="../lib/jrnl2/DataTokenState.cpp \
+ ../lib/jrnl2/DataToken.cpp \
+ ../lib/jrnl2/Journal.cpp \
../lib/jrnl2/JournalDirectory.cpp \
- ../lib/jrnl2/JournalException.cpp \
- ../lib/jrnl2/jrnl_state.cpp \
- ../lib/jrnl2/smutex.cpp \
- ../lib/jrnl2/DataTokenState.cpp \
../lib/jrnl2/JournalErrors.cpp \
- ../lib/jrnl2/jrnl.cpp \
- ../lib/jrnl2/slock.cpp \
- ../lib/jrnl2/JournalParameters.cpp"
+ ../lib/jrnl2/JournalException.cpp \
+ ../lib/jrnl2/JournalParameters.cpp \
+ ../lib/jrnl2/JournalState.cpp"
WARN="${WARN_COMMON} ${WARN_OTHER} -Wshadow -Wunsafe-loop-optimizations"
fi
14 years
rhmessaging commits: r4435 - in store/trunk/cpp: perf and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2010-12-09 09:33:48 -0500 (Thu, 09 Dec 2010)
New Revision: 4435
Added:
store/trunk/cpp/lib/jrnl2/AioCallback.hpp
store/trunk/cpp/lib/jrnl2/DataToken.cpp
store/trunk/cpp/lib/jrnl2/DataToken.hpp
store/trunk/cpp/lib/jrnl2/DataTokenState.cpp
store/trunk/cpp/lib/jrnl2/DataTokenState.hpp
store/trunk/cpp/lib/jrnl2/JournalDirectory.cpp
store/trunk/cpp/lib/jrnl2/JournalDirectory.hpp
store/trunk/cpp/lib/jrnl2/JournalErrors.cpp
store/trunk/cpp/lib/jrnl2/JournalErrors.hpp
store/trunk/cpp/lib/jrnl2/JournalException.cpp
store/trunk/cpp/lib/jrnl2/JournalException.hpp
Removed:
store/trunk/cpp/lib/jrnl2/aio_callback.hpp
store/trunk/cpp/lib/jrnl2/dtok.cpp
store/trunk/cpp/lib/jrnl2/dtok.hpp
store/trunk/cpp/lib/jrnl2/dtok_state.cpp
store/trunk/cpp/lib/jrnl2/dtok_state.hpp
store/trunk/cpp/lib/jrnl2/jdir.cpp
store/trunk/cpp/lib/jrnl2/jdir.hpp
store/trunk/cpp/lib/jrnl2/jerrno.cpp
store/trunk/cpp/lib/jrnl2/jerrno.hpp
store/trunk/cpp/lib/jrnl2/jexception.cpp
store/trunk/cpp/lib/jrnl2/jexception.hpp
Modified:
store/trunk/cpp/lib/jrnl2/JournalParameters.hpp
store/trunk/cpp/lib/jrnl2/Makefile.am
store/trunk/cpp/lib/jrnl2/jrnl.cpp
store/trunk/cpp/lib/jrnl2/jrnl.hpp
store/trunk/cpp/lib/jrnl2/jrnl_state.cpp
store/trunk/cpp/lib/jrnl2/slock.hpp
store/trunk/cpp/lib/jrnl2/smutex.hpp
store/trunk/cpp/perf/JournalInstance.cpp
store/trunk/cpp/perf/JournalInstance.hpp
store/trunk/cpp/perf/JournalParameters.cpp
store/trunk/cpp/perf/JournalPerformanceTest.cpp
store/trunk/cpp/perf/PerformanceResult.cpp
store/trunk/cpp/perf/TestParameters.cpp
store/trunk/cpp/perf/m
Log:
Further code tidy-up and refactorization in lib/jrnl2
Copied: store/trunk/cpp/lib/jrnl2/AioCallback.hpp (from rev 4429, store/trunk/cpp/lib/jrnl2/aio_callback.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/AioCallback.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/AioCallback.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,57 @@
+/**
+ * \file AioCallback.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_journal2_AioCallback_hpp
+#define mrg_journal2_AioCallback_hpp
+
+#include "DataToken.hpp"
+#include <sys/types.h> // u_int16_t, u_int32_t
+#include <vector>
+
+namespace mrg
+{
+namespace journal2
+{
+
+ class AioCallback
+ {
+ public:
+ virtual ~AioCallback() {}
+ virtual void writeAioCompleteCallback(std::vector<DataToken*>& dataTokenList) = 0;
+ virtual void readAioCompleteCallback(std::vector<u_int16_t>& buffPageCtrlBlkIndexList) = 0;
+ };
+
+} // namespace journal2
+} // namespace mrg
+
+
+#endif // mrg_journal2_AioCallback_hpp
+
Copied: store/trunk/cpp/lib/jrnl2/DataToken.cpp (from rev 4429, store/trunk/cpp/lib/jrnl2/dtok.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/DataToken.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/DataToken.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,78 @@
+/**
+ * \file DataToken.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "DataToken.hpp"
+
+namespace mrg
+{
+namespace journal2
+{
+
+ // static
+ recordId_t AtomicRecordIdCounter::_recordId;
+
+ // static
+ smutex AtomicRecordIdCounter::_recordIdMutex;
+
+ DataToken::DataToken() :
+ _dataTokenState(),
+ _recordId(AtomicRecordIdCounter::s_getNextRecordId()),
+ _externalRecordIdFlag(false)
+ {}
+
+ DataToken::DataToken(const recordId_t rid) :
+ _dataTokenState(),
+ _recordId(rid),
+ _externalRecordIdFlag(true)
+ {}
+
+ void
+ DataToken::setRecordId(const recordId_t rid)
+ {
+ _recordId = rid;
+ _externalRecordIdFlag = true;
+ }
+
+ void
+ DataToken::setDequeueRecordId(const recordId_t drid)
+ {
+ _dequeueRecordId = drid;
+ }
+
+ std::string
+ DataToken::statusStr()
+ {
+ return "status string";
+ }
+
+} // namespace journal2
+} // namespace mrg
+
Copied: store/trunk/cpp/lib/jrnl2/DataToken.hpp (from rev 4429, store/trunk/cpp/lib/jrnl2/dtok.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/DataToken.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/DataToken.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,90 @@
+/**
+ * \file DataToken.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_journal2_DataToken_hpp
+#define mrg_journal2_DataToken_hpp
+
+#include <string>
+#include <sys/types.h> // u_int16_t, u_int32_t
+
+#include "DataTokenState.hpp"
+#include "slock.hpp"
+#include "smutex.hpp"
+
+namespace mrg
+{
+namespace journal2
+{
+
+ typedef u_int64_t recordId_t;
+
+ class AtomicRecordIdCounter
+ {
+ static recordId_t _recordId;
+ static smutex _recordIdMutex;
+ public:
+ inline static recordId_t s_getNextRecordId() { slock l(_recordIdMutex); return ++_recordId; }
+ };
+
+ class DataToken
+ {
+ DataTokenState _dataTokenState;
+ bool _transientFlag;
+ bool _externalFlag;
+ std::string _externalPath;
+ recordId_t _recordId;
+ bool _externalRecordIdFlag;
+ recordId_t _dequeueRecordId;
+
+ public:
+ DataToken();
+ DataToken(const recordId_t rid);
+
+ inline DataTokenState& getDataTokenState() { return _dataTokenState; }
+ inline bool isTransient() const { return _transientFlag; }
+ inline bool isExternal() const { return _externalFlag; }
+ inline std::string& getExternalPath() { return _externalPath; }
+ void setRecordId(const recordId_t rid);
+ inline recordId_t getRecordId() const { return _recordId; }
+ inline bool isRecordIdExternal() { return _externalRecordIdFlag; }
+ void setDequeueRecordId(const recordId_t drid);
+ inline recordId_t getDequeueRecordId() const { return _dequeueRecordId; }
+
+ // debug aids
+ std::string statusStr();
+ };
+
+} // namespace journal2
+} // namespace mrg
+
+
+#endif // mrg_journal2_DataToken_hpp
+
Copied: store/trunk/cpp/lib/jrnl2/DataTokenState.cpp (from rev 4429, store/trunk/cpp/lib/jrnl2/dtok_state.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/DataTokenState.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/DataTokenState.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,237 @@
+/**
+ * \file DataTokenState.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "DataTokenState.hpp"
+
+#include "JournalException.hpp"
+
+namespace mrg
+{
+namespace journal2
+{
+
+ DataTokenState::DataTokenState() :
+ _opState(OP_NONE),
+ _txnState(TX_NONE),
+ _bufferWriteState(IO_NONE),
+ _aioSubmissionState(IO_NONE),
+ _aioCompletionState(IO_NONE)
+ {}
+
+ DataTokenState::DataTokenState(const DataTokenState& s) :
+ _opState(s._opState),
+ _txnState(s._txnState),
+ _bufferWriteState(s._bufferWriteState),
+ _aioSubmissionState(s._aioSubmissionState),
+ _aioCompletionState(s._aioCompletionState)
+ {}
+
+ DataTokenState::DataTokenState(const opState_t o,
+ const txnState_t t,
+ const aioState_t b,
+ const aioState_t s,
+ const aioState_t c) :
+ _opState(o),
+ _txnState(t),
+ _bufferWriteState(b),
+ _aioSubmissionState(s),
+ _aioCompletionState(c)
+ {}
+
+ void
+ DataTokenState::reset()
+ {
+ _opState = OP_NONE;
+ _txnState = TX_NONE;
+ _bufferWriteState = IO_NONE;
+ _aioSubmissionState = IO_NONE;
+ _aioCompletionState = IO_NONE;
+ }
+
+ void
+ DataTokenState::setOpStateToEnqueue()
+ {
+ if (_opState != OP_NONE)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADDTOKOPSTATE,
+ s_getStateAsString(OP_ENQUEUE),
+ s_getStateAsString(_opState),
+ "dtok_state",
+ "set_enqueue");
+ _opState = OP_ENQUEUE;
+ }
+
+ void
+ DataTokenState::setOpStateToDequeue()
+ {
+ if (_opState != OP_ENQUEUE)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADDTOKOPSTATE,
+ s_getStateAsString(OP_DEQUEUE),
+ s_getStateAsString(_opState),
+ "dtok_state",
+ "set_dequeue");
+ _opState = OP_DEQUEUE;
+ }
+
+ void
+ DataTokenState::setTxnStateToCommit()
+ {
+ if (_txnState != TX_NONE)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADDTOKTXNSTATE,
+ s_getStateAsString(TX_COMMIT),
+ s_getStateAsString(_txnState),
+ "dtok_state",
+ "set_txn_commit");
+ _txnState = TX_COMMIT;
+ }
+
+ void
+ DataTokenState::setTxnStateToAbort()
+ {
+ if (_txnState != TX_NONE)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADDTOKTXNSTATE,
+ s_getStateAsString(TX_ABORT),
+ s_getStateAsString(_txnState),
+ "dtok_state",
+ "set_txn_abort");
+ _txnState = TX_ABORT;
+ }
+
+ void
+ DataTokenState::setBufferWriteStateToPart()
+ {
+ if (_bufferWriteState != IO_NONE)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADDTOKIOSTATE,
+ s_getStateAsString(IO_PART),
+ s_getStateAsString(_bufferWriteState),
+ "dtok_state",
+ "set_buff_part");
+ _bufferWriteState = IO_PART;
+ }
+
+ void
+ DataTokenState::setBufferWriteStateToComplete()
+ {
+ _bufferWriteState = IO_COMPLETE;
+ }
+
+ void
+ DataTokenState::setAioSubmissionStateToPart()
+ {
+ if (_aioSubmissionState != IO_NONE)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADDTOKIOSTATE,
+ s_getStateAsString(IO_PART),
+ s_getStateAsString(_aioSubmissionState),
+ "dtok_state",
+ "set_iosubm_part");
+ _aioSubmissionState = IO_PART;
+ }
+
+ void
+ DataTokenState::setAioSubmissionStateToComplete()
+ {
+ _aioSubmissionState = IO_COMPLETE;
+ }
+
+ void
+ DataTokenState::setAioCompletionStateToPart()
+ {
+ if (_aioCompletionState != IO_NONE)
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADDTOKIOSTATE,
+ s_getStateAsString(IO_PART),
+ s_getStateAsString(_aioCompletionState),
+ "dtok_state",
+ "set_iocompl_part");
+ _aioCompletionState = IO_PART;
+ }
+
+ void
+ DataTokenState::setAioCompletionStateToComplete()
+ {
+ _aioCompletionState = IO_COMPLETE;
+ }
+
+ //static
+ std::string
+ DataTokenState::s_getStateAsString(opState_t s)
+ {
+ switch (s) {
+ case OP_NONE:
+ return "OP_NONE";
+ case OP_ENQUEUE:
+ return "OP_ENQUEUE";
+ case OP_DEQUEUE:
+ return "OP_DEQUEUE";
+ default:
+ std::ostringstream oss;
+ oss << "<unknown state (" << s << ")>";
+ return oss.str();
+ }
+ }
+
+ //static
+ std::string
+ DataTokenState::s_getStateAsString(txnState_t s)
+ {
+ switch (s) {
+ case TX_NONE:
+ return "TX_NONE";
+ case TX_COMMIT:
+ return "TX_COMMIT";
+ case TX_ABORT:
+ return "TX_ABORT";
+ default:
+ std::ostringstream oss;
+ oss << "<unknown state (" << s << ")>";
+ return oss.str();
+ }
+ }
+
+ //static
+ std::string
+ DataTokenState::s_getStateAsString(aioState_t s)
+ {
+ switch (s) {
+ case IO_NONE:
+ return "IO_NONE";
+ case IO_PART:
+ return "IO_PART";
+ case IO_COMPLETE:
+ return "IO_COMPLETE";
+ default:
+ std::ostringstream oss;
+ oss << "<unknown state (" << s << ")>";
+ return oss.str();
+ }
+ }
+
+} // namespace journal2
+} // namespace mrg
+
Copied: store/trunk/cpp/lib/jrnl2/DataTokenState.hpp (from rev 4429, store/trunk/cpp/lib/jrnl2/dtok_state.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/DataTokenState.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/DataTokenState.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,123 @@
+/**
+ * \file DataTokenState.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_journal2_DataTokenState_hpp
+#define mrg_journal2_DataTokenState_hpp
+
+#include <string>
+
+namespace mrg
+{
+namespace journal2
+{
+
+ typedef enum
+ {
+ OP_NONE = 0,
+ OP_ENQUEUE,
+ OP_DEQUEUE
+ } opState_t;
+
+ typedef enum
+ {
+ TX_NONE = 0,
+ TX_COMMIT,
+ TX_ABORT
+ } txnState_t;
+
+ typedef enum
+ {
+ IO_NONE = 0,
+ IO_PART,
+ IO_COMPLETE
+ } aioState_t;
+
+ class DataTokenState
+ {
+ opState_t _opState;
+ txnState_t _txnState;
+ aioState_t _bufferWriteState;
+ aioState_t _aioSubmissionState;
+ aioState_t _aioCompletionState;
+ public:
+ DataTokenState();
+ DataTokenState(const DataTokenState& s);
+ DataTokenState(const opState_t o,
+ const txnState_t t,
+ const aioState_t b,
+ const aioState_t s,
+ const aioState_t c);
+
+ // Raw state get/set functions
+ inline opState_t getOpState() const { return _opState; }
+ inline void setOpState(const opState_t s) { _opState = s; }
+ inline txnState_t getTxnState() const { return _txnState; }
+ inline void setTxnState(const txnState_t t) { _txnState = t; }
+ inline aioState_t getBufferWriteState() const { return _bufferWriteState; }
+ inline void setBufferWriteState(const aioState_t b) { _bufferWriteState = b; }
+ inline aioState_t getAioSubmissionState() const { return _aioSubmissionState; }
+ inline void setAioSubmissionState(const aioState_t s) { _aioSubmissionState = s; }
+ inline aioState_t getAioCompletionState() const { return _aioCompletionState; }
+ inline void setAioCompletionState(const aioState_t c) { _aioCompletionState = c; }
+
+ // State change functions
+ void reset();
+ void setOpStateToEnqueue();
+ void setOpStateToDequeue();
+ void setTxnStateToCommit();
+ void setTxnStateToAbort();
+ void setBufferWriteStateToPart();
+ void setBufferWriteStateToComplete();
+ void setAioSubmissionStateToPart();
+ void setAioSubmissionStateToComplete();
+ void setAioCompletionStateToPart();
+ void setAioCompletionStateToComplete();
+
+ // State query functions
+ inline bool isEnqueueable() const { return _opState == OP_NONE; }
+ inline bool isDequeueable() const { return _opState == OP_ENQUEUE; }
+ inline bool isTxnOpen() const { return _txnState == TX_NONE; }
+ inline bool isBufferWriteStateComplete() const { return _bufferWriteState == IO_COMPLETE; }
+ inline bool isAioSubmissionStateComplete() const { return _aioSubmissionState == IO_COMPLETE; }
+ inline bool isAioCompletionStateComplete() const { return _aioCompletionState == IO_COMPLETE; }
+
+ // State-to-string function(s)
+ static std::string s_getStateAsString(opState_t s);
+ static std::string s_getStateAsString(txnState_t s);
+ static std::string s_getStateAsString(aioState_t s);
+ };
+
+} // namespace journal2
+} // namespace mrg
+
+
+#endif // mrg_journal2_DataTokenState_hpp
+
Copied: store/trunk/cpp/lib/jrnl2/JournalDirectory.cpp (from rev 4429, store/trunk/cpp/lib/jrnl2/jdir.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalDirectory.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/JournalDirectory.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,83 @@
+/**
+ * \file JournalDirectory.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "JournalDirectory.hpp"
+
+namespace mrg
+{
+namespace journal2
+{
+
+ // static
+ bool
+ JournalDirectory::s_exists(const std::string& name)
+ {
+ return s_exists(name.c_str());
+ }
+
+ // static
+ bool
+ JournalDirectory::s_exists(const char* /*name*/)
+ {
+ // TODO - add impl here
+ return false;
+ }
+
+ // static
+ void
+ JournalDirectory::s_create(const std::string& name)
+ {
+ s_create(name.c_str());
+ }
+
+ // static
+ void
+ JournalDirectory::s_create(const char* /*name*/)
+ {
+ // TODO - add impl here
+ }
+
+ // static
+ void
+ JournalDirectory::s_delete(const std::string& name)
+ {
+ s_delete(name.c_str());
+ }
+
+ // static
+ void
+ JournalDirectory::s_delete(const char* /*name*/)
+ {
+ // TODO - add impl here
+ }
+
+} // namespace journal2
+} // namespace mrg
Copied: store/trunk/cpp/lib/jrnl2/JournalDirectory.hpp (from rev 4429, store/trunk/cpp/lib/jrnl2/jdir.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalDirectory.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/JournalDirectory.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,59 @@
+/**
+ * \file JournalDirectory.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_journal2_JournalDirectory_hpp
+#define mrg_journal2_JournalDirectory_hpp
+
+#include <string>
+
+namespace mrg
+{
+namespace journal2
+{
+
+ class JournalDirectory
+ {
+ public:
+ static bool s_exists(const std::string& name);
+ static bool s_exists(const char* name);
+ static void s_create(const std::string& name);
+ static void s_create(const char* name);
+ static void s_delete(const std::string& name);
+ static void s_delete(const char* name);
+ };
+
+
+} // namespace journal2
+} // namespace mrg
+
+
+#endif // mrg_journal2_JournalDirectory_hpp
+
Copied: store/trunk/cpp/lib/jrnl2/JournalErrors.cpp (from rev 4429, store/trunk/cpp/lib/jrnl2/jerrno.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalErrors.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/JournalErrors.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,73 @@
+/**
+ * \file JournalErrors.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "JournalErrors.hpp"
+
+namespace mrg
+{
+namespace journal2
+{
+
+ std::map<u_int32_t, const char*> JournalErrors::_s_errorMap;
+ std::map<u_int32_t, const char*>::iterator JournalErrors::_s_errorMapIterator;
+ bool JournalErrors::_s_initializedFlag = JournalErrors::_s_initialize();
+
+ // generic errors
+ const u_int32_t JournalErrors::JERR_PTHREAD = 0x0001;
+
+ // illegal states
+ const u_int32_t JournalErrors::JERR_BADJRNLSTATE = 0x0101;
+ const u_int32_t JournalErrors::JERR_BADDTOKOPSTATE = 0x0102;
+ const u_int32_t JournalErrors::JERR_BADDTOKTXNSTATE = 0x0103;
+ const u_int32_t JournalErrors::JERR_BADDTOKIOSTATE = 0x0104;
+
+ bool
+ JournalErrors::_s_initialize()
+ {
+ _s_errorMap[JERR_PTHREAD] = "JERR_PTHREAD: pthread operation failure";
+ _s_errorMap[JERR_BADJRNLSTATE] = "JERR_BADJRNLSTATE: Illegal journal state";
+ _s_errorMap[JERR_BADDTOKOPSTATE] = "JERR_BADDTOKOPSTATE: Illegal data token op state";
+ _s_errorMap[JERR_BADDTOKTXNSTATE] = "JERR_BADDTOKTXNSTATE: Illegal data token txn state";
+ _s_errorMap[JERR_BADDTOKIOSTATE] = "JERR_BADDTOKIOSTATE: Illegal data token io state";
+ return true;
+ }
+
+ const char*
+ JournalErrors::s_errorMessage(const u_int32_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;
+ }
+
+} // namespace journal2
+} // namespace mrg
Copied: store/trunk/cpp/lib/jrnl2/JournalErrors.hpp (from rev 4429, store/trunk/cpp/lib/jrnl2/jerrno.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalErrors.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/JournalErrors.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,66 @@
+/**
+ * \file JournalErrors.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_journal2_JournalErrors_hpp
+#define mrg_journal2_JournalErrors_hpp
+
+#include <map>
+#include <sys/types.h> // u_int16_t, u_int32_t
+
+namespace mrg
+{
+namespace journal2
+{
+
+ class JournalErrors
+ {
+ static std::map<u_int32_t, const char*> _s_errorMap; ///< Map of error messages
+ static std::map<u_int32_t, const char*>::iterator _s_errorMapIterator; ///< Iterator
+ static bool _s_initializedFlag; ///< Dummy flag, used to initialize map.
+ static bool _s_initialize(); ///< Static fn for initializing static data
+ public:
+ // generic errors
+ static const u_int32_t JERR_PTHREAD; ///< pthread operation failure
+
+ // illegal states
+ static const u_int32_t JERR_BADJRNLSTATE; ///< Illegal journal state
+ static const u_int32_t JERR_BADDTOKOPSTATE; ///< Illegal data token op state
+ static const u_int32_t JERR_BADDTOKTXNSTATE; ///< Illegal data token txn state
+ static const u_int32_t JERR_BADDTOKIOSTATE; ///< Illegal data token io state
+
+
+ static const char* s_errorMessage(const u_int32_t err_no) throw ();
+ };
+
+} // namespace journal2
+} // namespace mrg
+
+#endif // mrg_journal2_JournalErrors_hpp
Copied: store/trunk/cpp/lib/jrnl2/JournalException.cpp (from rev 4429, store/trunk/cpp/lib/jrnl2/jexception.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalException.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/JournalException.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,190 @@
+/**
+ * \file JournalException.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "JournalException.hpp"
+
+#include <iomanip>
+
+namespace mrg
+{
+namespace journal2
+{
+
+ JournalException::JournalException() throw ():
+ std::exception(),
+ _errorCode(0)
+ {
+ _formatWhatStr();
+ }
+
+ JournalException::JournalException(const u_int32_t errorCode) throw ():
+ std::exception(),
+ _errorCode(errorCode)
+ {
+ _formatWhatStr();
+ }
+
+ JournalException::JournalException(const char* additionalInfo) throw ():
+ std::exception(),
+ _errorCode(0),
+ _additionalInfo(additionalInfo)
+ {
+ _formatWhatStr();
+ }
+
+ JournalException::JournalException(const std::string& additionalInfo) throw ():
+ std::exception(),
+ _errorCode(0),
+ _additionalInfo(additionalInfo)
+ {
+ _formatWhatStr();
+ }
+
+ JournalException::JournalException(const u_int32_t errorCode,
+ const char* additionalInfo) throw ():
+ std::exception(),
+ _errorCode(errorCode),
+ _additionalInfo(additionalInfo)
+ {
+ _formatWhatStr();
+ }
+
+ JournalException::JournalException(const u_int32_t errorCode,
+ const std::string& additionalInfo) throw ():
+ std::exception(),
+ _errorCode(errorCode),
+ _additionalInfo(additionalInfo)
+ {
+ _formatWhatStr();
+ }
+
+ JournalException::JournalException(const u_int32_t errorCode,
+ const char* throwingClass,
+ const char* throwingFunction) throw ():
+ std::exception(),
+ _errorCode(errorCode),
+ _throwingClass(throwingClass),
+ _throwingFunction(throwingFunction)
+ {
+ _formatWhatStr();
+ }
+
+ JournalException::JournalException(const u_int32_t errorCode,
+ const std::string& throwingClass,
+ const std::string& throwingFunction) throw ():
+ std::exception(),
+ _errorCode(errorCode),
+ _throwingClass(throwingClass),
+ _throwingFunction(throwingFunction)
+ {
+ _formatWhatStr();
+ }
+
+ JournalException::JournalException(const u_int32_t errorCode,
+ const char* additionalInfo,
+ const char* throwingClass,
+ const char* throwingFunction) throw ():
+ std::exception(),
+ _errorCode(errorCode),
+ _additionalInfo(additionalInfo),
+ _throwingClass(throwingClass),
+ _throwingFunction(throwingFunction)
+ {
+ _formatWhatStr();
+ }
+
+ JournalException::JournalException(const u_int32_t errorCode,
+ const std::string& additionalInfo,
+ const std::string& throwingClass,
+ const std::string& throwingFunction) throw ():
+ std::exception(),
+ _errorCode(errorCode),
+ _additionalInfo(additionalInfo),
+ _throwingClass(throwingClass),
+ _throwingFunction(throwingFunction)
+ {
+ _formatWhatStr();
+ }
+
+ void
+ JournalException::_formatWhatStr() throw ()
+ {
+ try {
+ const bool ai = !_additionalInfo.empty();
+ const bool tc = !_throwingClass.empty();
+ const bool tf = !_throwingFunction.empty();
+ std::ostringstream oss;
+ oss << "JournalException 0x" << std::hex << std::setfill('0') << std::setw(4) << _errorCode << " ";
+ if (tc) {
+ oss << _throwingClass;
+ if (tf) {
+ oss << "::";
+ } else {
+ oss << " ";
+ }
+ }
+ if (tf) {
+ oss << _throwingFunction << "() ";
+ }
+ if (tc || tf) {
+ oss << "threw " << JournalErrors::s_errorMessage(_errorCode);
+ }
+ if (ai) {
+ oss << " (" << _additionalInfo << ")";
+ }
+ _what.assign(oss.str());
+ } catch (...) {}
+ }
+
+ const char*
+ JournalException::what() const throw ()
+ {
+ return _what.c_str();
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os,
+ const JournalException& je)
+ {
+ os << je.what();
+ return os;
+ }
+
+ std::ostream&
+ operator<<(std::ostream& os,
+ const JournalException* jePtr)
+ {
+ os << jePtr->what();
+ return os;
+ }
+
+} // namespace journal2
+} // namespace mrg
Copied: store/trunk/cpp/lib/jrnl2/JournalException.hpp (from rev 4429, store/trunk/cpp/lib/jrnl2/jexception.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalException.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl2/JournalException.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -0,0 +1,118 @@
+/**
+ * \file JournalException.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains async journal code (v.2).
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_journal2_JournalException_hpp
+#define mrg_journal2_JournalException_hpp
+
+#include <cstring>
+#include <sstream>
+#include <string>
+#include <sys/types.h> // u_int16_t, u_int32_t
+
+#include "JournalErrors.hpp"
+
+// Macro definitions
+
+#define FORMAT_SYSERR(errno) " errno=" << errno << " (" << std::strerror(errno) << ")"
+
+#define PTHREAD_CHK(err, pfn, cls, fn) if(err != 0) { \
+ std::ostringstream oss; \
+ oss << pfn << " failed: " << FORMAT_SYSERR(err); \
+ throw JournalException(JournalErrors::JERR_PTHREAD, oss.str(), cls, fn); \
+ }
+
+#define THROW_STATE_EXCEPTION(jerrno, target_st, curr_st, cls, fn) { \
+ std::ostringstream oss; \
+ oss << cls << "::" << fn << "() in state " << curr_st << " cannot be moved to state " << target_st << "."; \
+ throw JournalException(jerrno, oss.str(), cls, fn); \
+ }
+
+namespace mrg
+{
+namespace journal2
+{
+
+ class JournalException : public std::exception
+ {
+ protected:
+ u_int32_t _errorCode;
+ std::string _additionalInfo;
+ std::string _throwingClass;
+ std::string _throwingFunction;
+ std::string _what;
+
+ void _formatWhatStr() throw ();
+
+ public:
+ JournalException() throw ();
+
+ JournalException(const u_int32_t errorCode) throw ();
+
+ JournalException(const char* additionalInfo) throw ();
+ JournalException(const std::string& additionalInfo) throw ();
+
+ JournalException(const u_int32_t errorCode,
+ const char* additionalInfo) throw ();
+ JournalException(const u_int32_t errorCode,
+ const std::string& additionalInfo) throw ();
+
+ JournalException(const u_int32_t errorCode,
+ const char* throwingClass,
+ const char* throwingFunction) throw ();
+ JournalException(const u_int32_t errorCode,
+ const std::string& throwingClass,
+ const std::string& throwingFunction) throw ();
+
+ JournalException(const u_int32_t errorCode,
+ const char* additionalInfo,
+ const char* throwingClass,
+ const char* throwingFunction) throw ();
+ JournalException(const u_int32_t errorCode,
+ const std::string& additionalInfo,
+ const std::string& throwingClass,
+ const std::string& throwingFunction) throw ();
+
+ virtual ~JournalException() throw () {}
+ const char* what() const throw (); // override std::exception::what()
+
+ inline u_int32_t getErrorCode() const throw () { return _errorCode; }
+ inline const std::string getAdditionalInfo() const throw () { return _additionalInfo; }
+ inline const std::string getThrowingClass() const throw () { return _throwingClass; }
+ inline const std::string getThrowingFunction() const throw () { return _throwingFunction; }
+
+ friend std::ostream& operator<<(std::ostream& os, const JournalException& je);
+ friend std::ostream& operator<<(std::ostream& os, const JournalException* jePtr);
+ }; // class JournalException
+
+} // namespace journal2
+} // namespace mrg
+
+#endif // mrg_journal2_JournalException_hpp
Modified: store/trunk/cpp/lib/jrnl2/JournalParameters.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalParameters.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/JournalParameters.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -61,6 +61,7 @@
u_int16_t _autoExpandMaxJrnlFiles;
u_int16_t _writeBuffNumPgs;
u_int32_t _writeBuffPgSize_sblks;
+
JournalParameters();
JournalParameters(const std::string& jrnlDir,
const std::string& jrnlBaseFileName,
Modified: store/trunk/cpp/lib/jrnl2/Makefile.am
===================================================================
--- store/trunk/cpp/lib/jrnl2/Makefile.am 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/Makefile.am 2010-12-09 14:33:48 UTC (rev 4435)
@@ -24,22 +24,22 @@
lib_LTLIBRARIES = libasyncjrnl2.la
libasyncjrnl2_la_SOURCES = \
- dtok.cpp \
- dtok_state.cpp \
- jdir.cpp \
- jerrno.cpp \
- jexception.cpp \
+ DataToken.cpp \
+ DataTokenState.cpp \
+ JournalDirectory.cpp \
+ JournalErrors.cpp \
+ JournalException.cpp \
jrnl.cpp \
jrnl_state.cpp \
slock.cpp \
smutex.cpp \
JournalParameters.cpp \
- aio_callback.hpp \
+ AioCallback.hpp \
dtok.hpp \
- dtok_state.hpp \
- jdir.hpp \
- jerrno.hpp \
- jexception.hpp \
+ DataTokenState.hpp \
+ JournalDirectory.hpp \
+ JournalErrors.hpp \
+ JournalException.hpp \
jrnl.hpp \
jrnl_state.hpp \
slock.hpp \
Deleted: store/trunk/cpp/lib/jrnl2/aio_callback.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/aio_callback.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/aio_callback.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,57 +0,0 @@
-/**
- * \file aio_callback.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_journal2_aio_callback_hpp
-#define mrg_journal2_aio_callback_hpp
-
-#include "dtok.hpp"
-#include <sys/types.h> // u_int16_t, u_int32_t
-#include <vector>
-
-namespace mrg
-{
-namespace journal2
-{
-
- class aio_callback
- {
- public:
- virtual ~aio_callback() {}
- virtual void wr_aio_cb(std::vector<dtok*>& dtokl) = 0;
- virtual void rd_aio_cb(std::vector<u_int16_t>& pil) = 0;
- };
-
-} // namespace journal2
-} // namespace mrg
-
-
-#endif // mrg_journal2_aio_callback_hpp
-
Deleted: store/trunk/cpp/lib/jrnl2/dtok.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/dtok.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/dtok.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,69 +0,0 @@
-/**
- * \file dtok.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "dtok.hpp"
-
-namespace mrg
-{
-namespace journal2
-{
-// static
-rec_id rid_counter::_rid;
-
-// static
-smutex rid_counter::_rid_mutex;
-
-dtok::dtok() : _dtok_state(), _rid(rid_counter::get_next_rid()), _external_rid(false) {}
-
-dtok::dtok(const rec_id rid) : _dtok_state(), _rid(rid), _external_rid(true) {}
-
-void
-dtok::set_rid(const rec_id rid)
-{
- _rid = rid;
- _external_rid = true;
-}
-
-void
-dtok::set_drid(const rec_id drid)
-{
- _drid = drid;
-}
-
-std::string
-dtok::status_str()
-{
- return "status string";
-}
-
-} // namespace journal2
-} // namespace mrg
-
Deleted: store/trunk/cpp/lib/jrnl2/dtok.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/dtok.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/dtok.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,92 +0,0 @@
-/**
- * \file dtok.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_journal2_dtok_hpp
-#define mrg_journal2_dtok_hpp
-
-#include <string>
-#include <sys/types.h> // u_int16_t, u_int32_t
-
-#include "dtok_state.hpp"
-#include "slock.hpp"
-#include "smutex.hpp"
-
-namespace mrg
-{
-namespace journal2
-{
-
- typedef u_int64_t rec_id;
-
- class rid_counter
- {
- protected:
- static rec_id _rid;
- static smutex _rid_mutex;
- public:
- inline static rec_id get_next_rid() { slock l(_rid_mutex); return ++_rid; }
- };
-
- class dtok
- {
- protected:
- dtok_state _dtok_state;
- bool _transient;
- bool _external;
- std::string _external_location;
- rec_id _rid;
- bool _external_rid;
- rec_id _drid;
-
- public:
- dtok();
- dtok(const rec_id rid);
-
- inline dtok_state& get_dtok_state() { return _dtok_state; }
- inline bool is_transient() const { return _transient; }
- inline bool is_external() const { return _external; }
- inline std::string& get_external_location() { return _external_location; }
- void set_rid(const rec_id rid);
- inline rec_id get_rid() const { return _rid; }
- inline bool is_external_rid() { return _external_rid; }
- void set_drid(const rec_id drid);
- inline rec_id get_drid() const { return _drid; }
-
- // debug aids
- std::string status_str();
- };
-
-} // namespace journal2
-} // namespace mrg
-
-
-#endif // mrg_journal2_dtok_hpp
-
Deleted: store/trunk/cpp/lib/jrnl2/dtok_state.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/dtok_state.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/dtok_state.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,237 +0,0 @@
-/**
- * \file dtok_state.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "dtok_state.hpp"
-
-#include "jexception.hpp"
-
-namespace mrg
-{
-namespace journal2
-{
-
-dtok_state::dtok_state() :
- _op_state(OP_NONE),
- _txn_state(TX_NONE),
- _buff_state(IO_NONE),
- _iosubm_state(IO_NONE),
- _iocmpl_state(IO_NONE)
-{}
-
-dtok_state::dtok_state(const dtok_state& s) :
- _op_state(s._op_state),
- _txn_state(s._txn_state),
- _buff_state(s._buff_state),
- _iosubm_state(s._iosubm_state),
- _iocmpl_state(s._iocmpl_state)
-{}
-
-dtok_state::dtok_state(const opstate_t o,
- const txnstate_t t,
- const iostate_t b,
- const iostate_t s,
- const iostate_t c) :
- _op_state(o),
- _txn_state(t),
- _buff_state(b),
- _iosubm_state(s),
- _iocmpl_state(c)
-{}
-
-void
-dtok_state::reset()
-{
- _op_state = OP_NONE;
- _txn_state = TX_NONE;
- _buff_state = IO_NONE;
- _iosubm_state = IO_NONE;
- _iocmpl_state = IO_NONE;
-}
-
-void
-dtok_state::set_enqueue()
-{
- if (_op_state != OP_NONE)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADDTOKOPSTATE,
- get_state_str(OP_ENQUEUE),
- get_state_str(_op_state),
- "dtok_state",
- "set_enqueue");
- _op_state = OP_ENQUEUE;
-}
-
-void
-dtok_state::set_dequeue()
-{
- if (_op_state != OP_ENQUEUE)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADDTOKOPSTATE,
- get_state_str(OP_DEQUEUE),
- get_state_str(_op_state),
- "dtok_state",
- "set_dequeue");
- _op_state = OP_DEQUEUE;
-}
-
-void
-dtok_state::set_txn_commit()
-{
- if (_txn_state != TX_NONE)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADDTOKTXNSTATE,
- get_state_str(TX_COMMIT),
- get_state_str(_txn_state),
- "dtok_state",
- "set_txn_commit");
- _txn_state = TX_COMMIT;
-}
-
-void
-dtok_state::set_txn_abort()
-{
- if (_txn_state != TX_NONE)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADDTOKTXNSTATE,
- get_state_str(TX_ABORT),
- get_state_str(_txn_state),
- "dtok_state",
- "set_txn_abort");
- _txn_state = TX_ABORT;
-}
-
-void
-dtok_state::set_buff_part()
-{
- if (_buff_state != IO_NONE)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADDTOKIOSTATE,
- get_state_str(IO_PART),
- get_state_str(_buff_state),
- "dtok_state",
- "set_buff_part");
- _buff_state = IO_PART;
-}
-
-void
-dtok_state::set_buff_compl()
-{
- _buff_state = IO_COMPLETE;
-}
-
-void
-dtok_state::set_iosubm_part()
-{
- if (_iosubm_state != IO_NONE)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADDTOKIOSTATE,
- get_state_str(IO_PART),
- get_state_str(_iosubm_state),
- "dtok_state",
- "set_iosubm_part");
- _iosubm_state = IO_PART;
-}
-
-void
-dtok_state::set_iosubm_compl()
-{
- _iosubm_state = IO_COMPLETE;
-}
-
-void
-dtok_state::set_iocompl_part()
-{
- if (_iocmpl_state != IO_NONE)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADDTOKIOSTATE,
- get_state_str(IO_PART),
- get_state_str(_iocmpl_state),
- "dtok_state",
- "set_iocompl_part");
- _iocmpl_state = IO_PART;
-}
-
-void
-dtok_state::set_iocompl_compl()
-{
- _iocmpl_state = IO_COMPLETE;
-}
-
-//static
-std::string
-dtok_state::get_state_str(opstate_t s)
-{
- switch (s) {
- case OP_NONE:
- return "OP_NONE";
- case OP_ENQUEUE:
- return "OP_ENQUEUE";
- case OP_DEQUEUE:
- return "OP_DEQUEUE";
- default:
- std::ostringstream oss;
- oss << "<unknown state (" << s << ")>";
- return oss.str();
- }
-}
-
-//static
-std::string
-dtok_state::get_state_str(txnstate_t s)
-{
- switch (s) {
- case TX_NONE:
- return "TX_NONE";
- case TX_COMMIT:
- return "TX_COMMIT";
- case TX_ABORT:
- return "TX_ABORT";
- default:
- std::ostringstream oss;
- oss << "<unknown state (" << s << ")>";
- return oss.str();
- }
-}
-
-//static
-std::string
-dtok_state::get_state_str(iostate_t s)
-{
- switch (s) {
- case IO_NONE:
- return "IO_NONE";
- case IO_PART:
- return "IO_PART";
- case IO_COMPLETE:
- return "IO_COMPLETE";
- default:
- std::ostringstream oss;
- oss << "<unknown state (" << s << ")>";
- return oss.str();
- }
-}
-
-} // namespace journal2
-} // namespace mrg
-
Deleted: store/trunk/cpp/lib/jrnl2/dtok_state.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/dtok_state.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/dtok_state.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,124 +0,0 @@
-/**
- * \file dtok_state.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_journal2_dtok_state_hpp
-#define mrg_journal2_dtok_state_hpp
-
-#include <string>
-
-namespace mrg
-{
-namespace journal2
-{
-
- typedef enum
- {
- OP_NONE = 0,
- OP_ENQUEUE,
- OP_DEQUEUE
- } opstate_t;
-
- typedef enum
- {
- TX_NONE = 0,
- TX_COMMIT,
- TX_ABORT
- } txnstate_t;
-
- typedef enum
- {
- IO_NONE = 0,
- IO_PART,
- IO_COMPLETE
- } iostate_t;
-
- class dtok_state
- {
- protected:
- opstate_t _op_state;
- txnstate_t _txn_state;
- iostate_t _buff_state;
- iostate_t _iosubm_state;
- iostate_t _iocmpl_state;
- public:
- dtok_state();
- dtok_state(const dtok_state& s);
- dtok_state(const opstate_t o,
- const txnstate_t t,
- const iostate_t b,
- const iostate_t s,
- const iostate_t c);
-
- // Raw state get/set functions
- inline opstate_t get_op_state() const { return _op_state; }
- inline void set_op_state(const opstate_t s) { _op_state = s; }
- inline txnstate_t get_txn_state() const { return _txn_state; }
- inline void set_txn_state(const txnstate_t t) { _txn_state = t; }
- inline iostate_t get_buff_state() const { return _buff_state; }
- inline void set_buff_state(const iostate_t b) { _buff_state = b; }
- inline iostate_t get_iosubm_state() const { return _iosubm_state; }
- inline void set_iosubm_state(const iostate_t s) { _iosubm_state = s; }
- inline iostate_t get_iocompl_state() const { return _iocmpl_state; }
- inline void set_iocompl_state(const iostate_t c) { _iocmpl_state = c; }
-
- // State change functions
- void reset();
- void set_enqueue();
- void set_dequeue();
- void set_txn_commit();
- void set_txn_abort();
- void set_buff_part();
- void set_buff_compl();
- void set_iosubm_part();
- void set_iosubm_compl();
- void set_iocompl_part();
- void set_iocompl_compl();
-
- // State query functions
- inline bool is_enqueueable() const { return _op_state == OP_NONE; }
- inline bool is_dequeueable() const { return _op_state == OP_ENQUEUE; }
- inline bool is_txn_open() const { return _txn_state == TX_NONE; }
- inline bool is_buff_write_compl() const { return _buff_state == IO_COMPLETE; }
- inline bool is_iosubm_compl() const { return _iosubm_state == IO_COMPLETE; }
- inline bool is_iocompl_compl() const { return _iocmpl_state == IO_COMPLETE; }
-
- // State-to-string function(s)
- static std::string get_state_str(opstate_t s);
- static std::string get_state_str(txnstate_t s);
- static std::string get_state_str(iostate_t s);
- };
-
-} // namespace journal2
-} // namespace mrg
-
-
-#endif // mrg_journal2_dtok_state_hpp
-
Deleted: store/trunk/cpp/lib/jrnl2/jdir.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jdir.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/jdir.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,84 +0,0 @@
-/**
- * \file jdir.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "jdir.hpp"
-
-namespace mrg
-{
-namespace journal2
-{
-
-// static
-bool
-jdir::exists(const std::string& name)
-{
- return exists(name.c_str());
-}
-
-// static
-bool
-jdir::exists(const char* /*name*/)
-{
- // TODO - add impl here
- return false;
-}
-
-// static
-void
-jdir::create_dir(const std::string& name)
-{
- return create_dir(name.c_str());
-}
-
-// static
-void
-jdir::create_dir(const char* /*name*/)
-{
- // TODO - add impl here
-}
-
-// static
-void
-jdir::delete_dir(const std::string& name)
-{
- return delete_dir(name.c_str());
-}
-
-// static
-void
-jdir::delete_dir(const char* /*name*/)
-{
- // TODO - add impl here
-}
-
-
-} // namespace journal2
-} // namespace mrg
Deleted: store/trunk/cpp/lib/jrnl2/jdir.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jdir.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/jdir.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,59 +0,0 @@
-/**
- * \file jdir.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_journal2_jdir_hpp
-#define mrg_journal2_jdir_hpp
-
-#include <string>
-
-namespace mrg
-{
-namespace journal2
-{
-
- class jdir
- {
- public:
- static bool exists(const std::string& name);
- static bool exists(const char* name);
- static void create_dir(const std::string& name);
- static void create_dir(const char* name);
- static void delete_dir(const std::string& name);
- static void delete_dir(const char* name);
- };
-
-
-} // namespace journal2
-} // namespace mrg
-
-
-#endif // mrg_journal2_jdir_hpp
-
Deleted: store/trunk/cpp/lib/jrnl2/jerrno.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jerrno.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/jerrno.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,74 +0,0 @@
-/**
- * \file jerrno.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "jerrno.hpp"
-
-namespace mrg
-{
-namespace journal2
-{
-
-std::map<u_int32_t, const char*> jerrno::_err_map;
-std::map<u_int32_t, const char*>::iterator jerrno::_err_map_itr;
-bool jerrno::_initialized = jerrno::__init();
-
-// generic errors
-const u_int32_t jerrno::JERR_PTHREAD = 0x0001;
-
-// illegal states
-const u_int32_t jerrno::JERR_BADJRNLSTATE = 0x0101;
-const u_int32_t jerrno::JERR_BADDTOKOPSTATE = 0x0102;
-const u_int32_t jerrno::JERR_BADDTOKTXNSTATE = 0x0103;
-const u_int32_t jerrno::JERR_BADDTOKIOSTATE = 0x0104;
-
-bool
-jerrno::__init()
-{
- _err_map[JERR_PTHREAD] = "JERR_PTHREAD: pthread operation failure";
- _err_map[JERR_BADJRNLSTATE] = "JERR_BADJRNLSTATE: Illegal journal state";
- _err_map[JERR_BADDTOKOPSTATE] = "JERR_BADDTOKOPSTATE: Illegal data token op state";
- _err_map[JERR_BADDTOKTXNSTATE] = "JERR_BADDTOKTXNSTATE: Illegal data token txn state";
- _err_map[JERR_BADDTOKIOSTATE] = "JERR_BADDTOKIOSTATE: Illegal data token io state";
-
- return true;
-}
-
-const char*
-jerrno::err_msg(const u_int32_t err_no) throw ()
-{
- _err_map_itr = _err_map.find(err_no);
- if (_err_map_itr == _err_map.end())
- return "<Unknown error code>";
- return _err_map_itr->second;
-}
-
-} // namespace journal2
-} // namespace mrg
Deleted: store/trunk/cpp/lib/jrnl2/jerrno.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jerrno.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/jerrno.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,67 +0,0 @@
-/**
- * \file jerrno.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_journal2_jerrno_hpp
-#define mrg_journal2_jerrno_hpp
-
-#include <map>
-#include <sys/types.h> // u_int16_t, u_int32_t
-
-namespace mrg
-{
-namespace journal2
-{
-
- class jerrno
- {
- protected:
- static std::map<u_int32_t, const char*> _err_map; ///< Map of error messages
- static std::map<u_int32_t, const char*>::iterator _err_map_itr; ///< Iterator
- static bool _initialized; ///< Dummy flag, used to initialize map.
- static bool __init(); ///< Static fn for initializing static data
- public:
- // generic errors
- static const u_int32_t JERR_PTHREAD; ///< pthread operation failure
-
- // illegal states
- static const u_int32_t JERR_BADJRNLSTATE; ///< Illegal journal state
- static const u_int32_t JERR_BADDTOKOPSTATE; ///< Illegal data token op state
- static const u_int32_t JERR_BADDTOKTXNSTATE; ///< Illegal data token txn state
- static const u_int32_t JERR_BADDTOKIOSTATE; ///< Illegal data token io state
-
-
- static const char* err_msg(const u_int32_t err_no) throw ();
- };
-
-} // namespace journal2
-} // namespace mrg
-
-#endif // mrg_journal2_jerrno_hpp
Deleted: store/trunk/cpp/lib/jrnl2/jexception.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jexception.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/jexception.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,187 +0,0 @@
-/**
- * \file jexception.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "jexception.hpp"
-
-#include <iomanip>
-#include "jerrno.hpp"
-
-namespace mrg
-{
-namespace journal2
-{
-
-jexception::jexception() throw ():
- std::exception(),
- _err_code(0)
-{
- format();
-}
-
-jexception::jexception(const u_int32_t err_code) throw ():
- std::exception(),
- _err_code(err_code)
-{
- format();
-}
-
-jexception::jexception(const char* additional_info) throw ():
- std::exception(),
- _err_code(0),
- _additional_info(additional_info)
-{
- format();
-}
-
-jexception::jexception(const std::string& additional_info) throw ():
- std::exception(),
- _err_code(0),
- _additional_info(additional_info)
-{
- format();
-}
-
-jexception::jexception(const u_int32_t err_code,
- const char* additional_info) throw ():
- std::exception(),
- _err_code(err_code),
- _additional_info(additional_info)
-{
- format();
-}
-
-jexception::jexception(const u_int32_t err_code,
- const std::string& additional_info) throw ():
- std::exception(),
- _err_code(err_code),
- _additional_info(additional_info)
-{
- format();
-}
-
-jexception::jexception(const u_int32_t err_code,
- const char* throwing_class,
- const char* throwing_fn) throw ():
- std::exception(),
- _err_code(err_code),
- _throwing_class(throwing_class),
- _throwing_fn(throwing_fn)
-{
- format();
-}
-
-jexception::jexception(const u_int32_t err_code,
- const std::string& throwing_class,
- const std::string& throwing_fn) throw ():
- std::exception(),
- _err_code(err_code),
- _throwing_class(throwing_class),
- _throwing_fn(throwing_fn)
-{
- format();
-}
-
-jexception::jexception(const u_int32_t err_code,
- const char* additional_info,
- const char* throwing_class,
- const char* throwing_fn) throw ():
- std::exception(),
- _err_code(err_code),
- _additional_info(additional_info),
- _throwing_class(throwing_class),
- _throwing_fn(throwing_fn)
-{
- format();
-}
-
-jexception::jexception(const u_int32_t err_code,
- const std::string& additional_info,
- const std::string& throwing_class,
- const std::string& throwing_fn) throw ():
- std::exception(),
- _err_code(err_code),
- _additional_info(additional_info),
- _throwing_class(throwing_class),
- _throwing_fn(throwing_fn)
-{
- format();
-}
-
-jexception::~jexception() throw ()
-{}
-
-void
-jexception::format()
-{
- const bool ai = !_additional_info.empty();
- const bool tc = !_throwing_class.empty();
- const bool tf = !_throwing_fn.empty();
- std::ostringstream oss;
- oss << "jexception 0x" << std::hex << std::setfill('0') << std::setw(4) << _err_code << " ";
- if (tc)
- {
- oss << _throwing_class;
- if (tf)
- oss << "::";
- else
- oss << " ";
- }
- if (tf)
- oss << _throwing_fn << "() ";
- if (tc || tf)
- oss << "threw " << jerrno::err_msg(_err_code);
- if (ai)
- oss << " (" << _additional_info << ")";
- _what.assign(oss.str());
-}
-
-const char*
-jexception::what() const throw ()
-{
- return _what.c_str();
-}
-
-std::ostream&
-operator<<(std::ostream& os, const jexception& je)
-{
- os << je.what();
- return os;
-}
-
-std::ostream&
-operator<<(std::ostream& os, const jexception* jePtr)
-{
- os << jePtr->what();
- return os;
-}
-
-} // namespace journal2
-} // namespace mrg
Deleted: store/trunk/cpp/lib/jrnl2/jexception.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jexception.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/jexception.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -1,118 +0,0 @@
-/**
- * \file jexception.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains async journal code (v.2).
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_journal2_jexception_hpp
-#define mrg_journal2_jexception_hpp
-
-#include <cstring>
-#include <sstream>
-#include <string>
-#include <sys/types.h> // u_int16_t, u_int32_t
-
-#include "jerrno.hpp"
-
-// Macro definitions
-
-#define FORMAT_SYSERR(errno) " errno=" << errno << " (" << std::strerror(errno) << ")"
-
-#define PTHREAD_CHK(err, pfn, cls, fn) if(err != 0) { \
- std::ostringstream oss; \
- oss << pfn << " failed: " << FORMAT_SYSERR(err); \
- throw jexception(jerrno::JERR_PTHREAD, oss.str(), cls, fn); \
- }
-
-#define THROW_STATE_EXCEPTION(jerrno, target_st, curr_st, cls, fn) { \
- std::ostringstream oss; \
- oss << cls << "::" << fn << "() in state " << curr_st << " cannot be moved to state " << target_st << "."; \
- throw jexception(jerrno, oss.str(), cls, fn); \
- }
-
-namespace mrg
-{
-namespace journal2
-{
-
- class jexception : public std::exception
- {
- protected:
- u_int32_t _err_code;
- std::string _additional_info;
- std::string _throwing_class;
- std::string _throwing_fn;
- std::string _what;
- void format();
-
- public:
- jexception() throw ();
-
- jexception(const u_int32_t err_code) throw ();
-
- jexception(const char* additional_info) throw ();
- jexception(const std::string& additional_info) throw ();
-
- jexception(const u_int32_t err_code,
- const char* additional_info) throw ();
- jexception(const u_int32_t err_code,
- const std::string& additional_info) throw ();
-
- jexception(const u_int32_t err_code,
- const char* throwing_class,
- const char* throwing_fn) throw ();
- jexception(const u_int32_t err_code,
- const std::string& throwing_class,
- const std::string& throwing_fn)
- throw ();
-
- jexception(const u_int32_t err_code,
- const char* additional_info,
- const char* throwing_class,
- const char* throwing_fn) throw ();
- jexception(const u_int32_t err_code,
- const std::string& additional_info,
- const std::string& throwing_class,
- const std::string& throwing_fn) throw ();
-
- virtual ~jexception() throw ();
- const char* what() const throw (); // override std::exception::what()
-
- inline u_int32_t get_err_code() const throw () { return _err_code; }
- inline const std::string get_additional_info() const throw () { return _additional_info; }
- inline const std::string get_throwing_class() const throw () { return _throwing_class; }
- inline const std::string get_throwing_fn() const throw () { return _throwing_fn; }
-
- friend std::ostream& operator<<(std::ostream& os, const jexception& je);
- friend std::ostream& operator<<(std::ostream& os, const jexception* jePtr);
- }; // class jexception
-
-} // namespace journal2
-} // namespace mrg
-
-#endif // mrg_journal2_jexception_hpp
Modified: store/trunk/cpp/lib/jrnl2/jrnl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jrnl.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/jrnl.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -65,16 +65,16 @@
{}
void
-jrnl::initialize(const JournalParameters* sp, aio_callback* const cbp)
+jrnl::initialize(const JournalParameters* sp, AioCallback* const cbp)
{
_store_params_ptr = sp;
_cbp = cbp;
}
iores
-jrnl::enqueue(const void* const /*msg_ptr*/, const std::size_t /*msg_size*/, dtok* const dtokp)
+jrnl::enqueue(const void* const /*msg_ptr*/, const std::size_t /*msg_size*/, DataToken* const dtokp)
{
- dtokp->get_dtok_state().set_enqueue();
+ dtokp->getDataTokenState().setOpStateToEnqueue();
// --- temp code ---
bool flush_flag;
{
@@ -89,10 +89,10 @@
}
iores
-jrnl::dequeue(dtok* const dtokp)
+jrnl::dequeue(DataToken* const dtokp)
{
- dtokp->get_dtok_state().set_dequeue();
- dtokp->set_drid(dtokp->get_rid());
+ dtokp->getDataTokenState().setOpStateToDequeue();
+ dtokp->setDequeueRecordId(dtokp->getRecordId());
// --- temp code ---
bool flush_flag;
{
@@ -166,7 +166,7 @@
if (l1.locked()) {
int i = cb_dtok_list_switch ? 0 : 1;
if (cb_dtok_list[i].size() && _cbp) {
- _cbp->wr_aio_cb(cb_dtok_list[i]);
+ _cbp->writeAioCompleteCallback(cb_dtok_list[i]);
}
cb_dtok_list[i].clear();
Modified: store/trunk/cpp/lib/jrnl2/jrnl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jrnl.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/jrnl.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -36,8 +36,8 @@
#include <sys/types.h> // u_int64_t, u_int32_t, etc.
#include <time.h> // timespec
-#include "aio_callback.hpp"
-#include "dtok.hpp"
+#include "AioCallback.hpp"
+#include "DataToken.hpp"
#include "jrnl_state.hpp"
#include "JournalParameters.hpp"
@@ -66,12 +66,12 @@
std::string _base_filename;
jrnl_state _jrnl_state;
const JournalParameters* _store_params_ptr;
- aio_callback* _cbp;
+ AioCallback* _cbp;
// --- temp code ---
static u_int32_t list_thresh;
- std::vector<dtok*> wr_dtok_list;
- std::vector<dtok*> cb_dtok_list[2];
+ std::vector<DataToken*> wr_dtok_list;
+ std::vector<DataToken*> cb_dtok_list[2];
bool cb_dtok_list_switch;
smutex wr_dtok_list_lock;
smutex cb_dtok_list_lock;
@@ -89,9 +89,9 @@
inline const JournalParameters* get_store_params() const { return _store_params_ptr; }
// msg ops
- void initialize(const JournalParameters* sp, aio_callback* const cbp);
- iores enqueue(const void* const msg_ptr, const std::size_t msg_size, dtok* const dtokp);
- iores dequeue(dtok* const dtokp);
+ void initialize(const JournalParameters* sp, AioCallback* const cbp);
+ iores enqueue(const void* const msg_ptr, const std::size_t msg_size, DataToken* const dtokp);
+ iores dequeue(DataToken* const dtokp);
iores commit();
iores abort();
Modified: store/trunk/cpp/lib/jrnl2/jrnl_state.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/jrnl_state.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/jrnl_state.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -31,7 +31,7 @@
#include "jrnl_state.hpp"
-#include "jexception.hpp"
+#include "JournalException.hpp"
namespace mrg
{
@@ -69,7 +69,7 @@
jrnl_state::initialize()
{
if (_jrnl_state != JS_NONE)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADJRNLSTATE,
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
get_state_str(JS_INITIALIZING),
get_state_str(_jrnl_state),
"jrnl_state",
@@ -81,7 +81,7 @@
jrnl_state::initialize_compl()
{
if (_jrnl_state != JS_INITIALIZING)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADJRNLSTATE,
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
get_state_str(JS_RUNNING),
get_state_str(_jrnl_state),
"jrnl_state",
@@ -93,7 +93,7 @@
jrnl_state::recover_phase_1()
{
if (_jrnl_state != JS_NONE)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADJRNLSTATE,
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
get_state_str(JS_RECOVERING_PHASE_1),
get_state_str(_jrnl_state),
"jrnl_state",
@@ -105,7 +105,7 @@
jrnl_state::recover_phase_2()
{
if (_jrnl_state != JS_RECOVERING_PHASE_1)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADJRNLSTATE,
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
get_state_str(JS_RECOVERING_PHASE_2),
get_state_str(_jrnl_state),
"jrnl_state",
@@ -117,7 +117,7 @@
jrnl_state::recover_compl()
{
if (_jrnl_state != JS_RECOVERING_PHASE_2)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADJRNLSTATE,
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
get_state_str(JS_RUNNING),
get_state_str(_jrnl_state),
"jrnl_state",
@@ -129,7 +129,7 @@
jrnl_state::stop()
{
if (_jrnl_state != JS_RUNNING)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADJRNLSTATE,
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
get_state_str(JS_STOPPING),
get_state_str(_jrnl_state),
"jrnl_state",
@@ -141,7 +141,7 @@
jrnl_state::stop_compl()
{
if (_jrnl_state != JS_STOPPING)
- THROW_STATE_EXCEPTION(jerrno::JERR_BADJRNLSTATE,
+ THROW_STATE_EXCEPTION(JournalErrors::JERR_BADJRNLSTATE,
get_state_str(JS_STOPPED),
get_state_str(_jrnl_state),
"jrnl_state",
Modified: store/trunk/cpp/lib/jrnl2/slock.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/slock.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/slock.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -35,7 +35,7 @@
#include <cerrno> // EBUSY
#include <pthread.h>
-#include "jexception.hpp"
+#include "JournalException.hpp"
#include "smutex.hpp"
namespace mrg
Modified: store/trunk/cpp/lib/jrnl2/smutex.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/smutex.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/lib/jrnl2/smutex.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -34,7 +34,7 @@
#include <pthread.h>
-#include "jexception.hpp"
+#include "JournalException.hpp"
namespace mrg
{
Modified: store/trunk/cpp/perf/JournalInstance.cpp
===================================================================
--- store/trunk/cpp/perf/JournalInstance.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/perf/JournalInstance.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -46,11 +46,11 @@
#else
mrg::journal::jcntl* const jrnlPtr) :
#endif
- _numMsgs(numMsgs),
- _msgSize(msgSize),
- _msgData(msgData),
- _jrnlPtr(jrnlPtr),
- _threadSwitch(false)
+ _numMsgs(numMsgs),
+ _msgSize(msgSize),
+ _msgData(msgData),
+ _jrnlPtr(jrnlPtr),
+ _threadSwitch(false)
{}
JournalInstance::~JournalInstance()
@@ -69,7 +69,7 @@
uint32_t i = 0;
while (i < _numMsgs) {
#ifdef JOURNAL2
- mrg::journal2::dtok* dtokPtr = new mrg::journal2::dtok();
+ mrg::journal2::DataToken* dtokPtr = new mrg::journal2::DataToken();
mrg::journal2::iores jrnlIoRes = _jrnlPtr->enqueue(_msgData, _msgSize, dtokPtr);
#else
mrg::journal::data_tok* dtokPtr = new mrg::journal::data_tok();
@@ -127,7 +127,7 @@
uint32_t i = 0;
while (i < _numMsgs) {
#ifdef JOURNAL2
- mrg::journal2::dtok* dtokPtr = 0;
+ mrg::journal2::DataToken* dtokPtr = 0;
#else
mrg::journal::data_tok* dtokPtr = 0;
#endif
@@ -172,7 +172,7 @@
default:
#ifdef JOURNAL2
std::cerr << "dequeue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << ": "
- << dtokPtr->status_str() << std::endl;
+ << dtokPtr->statusStr() << std::endl;
#else
std::cerr << "dequeue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << ": "
<< dtokPtr->status_str() << std::endl;
@@ -210,9 +210,9 @@
// This method will be called by multiple threads simultaneously
void
#ifdef JOURNAL2
- JournalInstance::wr_aio_cb(std::vector<mrg::journal2::dtok*>& dataTokenList)
+ JournalInstance::writeAioCompleteCallback(std::vector<mrg::journal2::DataToken*>& dataTokenList)
{
- mrg::journal2::dtok* dtokPtr;
+ mrg::journal2::DataToken* dtokPtr;
#else
JournalInstance::wr_aio_cb(std::vector<mrg::journal::data_tok*>& dataTokenList)
{
@@ -223,7 +223,7 @@
dtokPtr = dataTokenList.back();
dataTokenList.pop_back();
#ifdef JOURNAL2
- switch (dtokPtr->get_dtok_state().get_op_state()) {
+ switch (dtokPtr->getDataTokenState().getOpState()) {
case mrg::journal2::OP_ENQUEUE:
#else
@@ -244,7 +244,11 @@
// *** MUST BE THREAD-SAFE ****
// This method will be called by multiple threads simultaneously
void
+#ifdef JOURNAL2
+ JournalInstance::readAioCompleteCallback(std::vector<uint16_t>& /*buffPageCtrlBlkIndexList*/)
+#else
JournalInstance::rd_aio_cb(std::vector<uint16_t>& /*buffPageCtrlBlkIndexList*/)
+#endif
{}
} // namespace jtest
Modified: store/trunk/cpp/perf/JournalInstance.hpp
===================================================================
--- store/trunk/cpp/perf/JournalInstance.hpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/perf/JournalInstance.hpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -37,8 +37,8 @@
#include <queue>
#ifdef JOURNAL2
-#include "jrnl2/aio_callback.hpp"
-#include "jrnl2/dtok.hpp"
+#include "jrnl2/AioCallback.hpp"
+#include "jrnl2/DataToken.hpp"
#include "jrnl2/jrnl.hpp"
#else
#include "jrnl/aio_callback.hpp"
@@ -59,7 +59,7 @@
* journal instance is provided as a pointer to the constructor.
*/
#ifdef JOURNAL2
- class JournalInstance: public mrg::journal2::aio_callback
+ class JournalInstance: public mrg::journal2::AioCallback
#else
class JournalInstance: public mrg::journal::aio_callback
#endif
@@ -69,7 +69,7 @@
const char* _msgData; ///< Pointer to message content to be used for each message.
#ifdef JOURNAL2
mrg::journal2::jrnl* const _jrnlPtr; ///< Journal instance pointer
- std::queue<mrg::journal2::dtok*> _unprocCallbackList; ///< Queue of unprocessed callbacks to be dequeued
+ std::queue<mrg::journal2::DataToken*> _unprocCallbackList; ///< Queue of unprocessed callbacks to be dequeued
#else
mrg::journal::jcntl* const _jrnlPtr; ///< Journal instance pointer
std::queue<mrg::journal::data_tok*> _unprocCallbackList; ///< Queue of unprocessed callbacks to be dequeued
@@ -152,7 +152,7 @@
* operations
*/
#ifdef JOURNAL2
- void wr_aio_cb(std::vector<mrg::journal2::dtok*>& dataTokenList);
+ void writeAioCompleteCallback(std::vector<mrg::journal2::DataToken*>& dataTokenList);
#else
void wr_aio_cb(std::vector<mrg::journal::data_tok*>& dataTokenList);
#endif
@@ -164,7 +164,11 @@
*
* \param buffPageCtrlBlkIndexList A vector of indices to the buffer page control blocks for completed reads
*/
+#ifdef JOURNAL2
+ void readAioCompleteCallback(std::vector<uint16_t>& buffPageCtrlBlkIndexList);
+#else
void rd_aio_cb(std::vector<uint16_t>& buffPageCtrlBlkIndexList);
+#endif
};
} // namespace jtest
Modified: store/trunk/cpp/perf/JournalParameters.cpp
===================================================================
--- store/trunk/cpp/perf/JournalParameters.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/perf/JournalParameters.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -47,15 +47,15 @@
uint32_t JournalParameters::_s_defaultWriteBuffPgSize_sblks = 128;
JournalParameters::JournalParameters() :
- Streamable(),
- _jrnlDir(_s_defaultJrnlDir),
- _jrnlBaseFileName(_s_defaultJrnlBaseFileName),
- _numJrnlFiles(_s_defaultNumJrnlFiles),
- _jrnlFileSize_sblks(_s_defaultJrnlFileSize_sblks),
- _autoExpand(_s_defaultAutoExpand),
- _autoExpandMaxJrnlFiles(_s_defaultAutoExpandMaxJrnlFiles),
- _writeBuffNumPgs(_s_defaultWriteBuffNumPgs),
- _writeBuffPgSize_sblks(_s_defaultWriteBuffPgSize_sblks)
+ Streamable(),
+ _jrnlDir(_s_defaultJrnlDir),
+ _jrnlBaseFileName(_s_defaultJrnlBaseFileName),
+ _numJrnlFiles(_s_defaultNumJrnlFiles),
+ _jrnlFileSize_sblks(_s_defaultJrnlFileSize_sblks),
+ _autoExpand(_s_defaultAutoExpand),
+ _autoExpandMaxJrnlFiles(_s_defaultAutoExpandMaxJrnlFiles),
+ _writeBuffNumPgs(_s_defaultWriteBuffNumPgs),
+ _writeBuffPgSize_sblks(_s_defaultWriteBuffPgSize_sblks)
{}
JournalParameters::JournalParameters(const std::string& jrnlDir,
@@ -66,28 +66,27 @@
const uint16_t autoExpandMaxJrnlFiles,
const uint16_t writeBuffNumPgs,
const uint32_t writeBuffPgSize_sblks) :
- Streamable(),
- _jrnlDir(jrnlDir),
- _jrnlBaseFileName(jrnlBaseFileName),
- _numJrnlFiles(numJrnlFiles),
- _jrnlFileSize_sblks(jrnlFileSize_sblks),
- _autoExpand(autoExpand),
- _autoExpandMaxJrnlFiles(autoExpandMaxJrnlFiles),
- _writeBuffNumPgs(writeBuffNumPgs),
- _writeBuffPgSize_sblks(writeBuffPgSize_sblks)
+ Streamable(),
+ _jrnlDir(jrnlDir),
+ _jrnlBaseFileName(jrnlBaseFileName),
+ _numJrnlFiles(numJrnlFiles),
+ _jrnlFileSize_sblks(jrnlFileSize_sblks),
+ _autoExpand(autoExpand),
+ _autoExpandMaxJrnlFiles(autoExpandMaxJrnlFiles),
+ _writeBuffNumPgs(writeBuffNumPgs),
+ _writeBuffPgSize_sblks(writeBuffPgSize_sblks)
{}
JournalParameters::JournalParameters(const JournalParameters& jp) :
- Streamable(),
- _jrnlDir(jp._jrnlDir),
- _jrnlBaseFileName(jp._jrnlBaseFileName),
- _numJrnlFiles(jp._numJrnlFiles),
- _jrnlFileSize_sblks(jp._jrnlFileSize_sblks),
- _autoExpand(jp._autoExpand),
- _autoExpandMaxJrnlFiles(jp._autoExpandMaxJrnlFiles),
- _writeBuffNumPgs(jp._writeBuffNumPgs),
- _writeBuffPgSize_sblks(jp._writeBuffPgSize_sblks)
-
+ Streamable(),
+ _jrnlDir(jp._jrnlDir),
+ _jrnlBaseFileName(jp._jrnlBaseFileName),
+ _numJrnlFiles(jp._numJrnlFiles),
+ _jrnlFileSize_sblks(jp._jrnlFileSize_sblks),
+ _autoExpand(jp._autoExpand),
+ _autoExpandMaxJrnlFiles(jp._autoExpandMaxJrnlFiles),
+ _writeBuffNumPgs(jp._writeBuffNumPgs),
+ _writeBuffPgSize_sblks(jp._writeBuffPgSize_sblks)
{}
void
Modified: store/trunk/cpp/perf/JournalPerformanceTest.cpp
===================================================================
--- store/trunk/cpp/perf/JournalPerformanceTest.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/perf/JournalPerformanceTest.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -42,7 +42,7 @@
#include "ScopedTimer.hpp"
#ifdef JOURNAL2
-#include "jrnl2/jdir.hpp"
+#include "jrnl2/JournalDirectory.hpp"
#else
#include "jrnl/jdir.hpp"
#endif
@@ -57,11 +57,11 @@
#else
JournalPerformanceTest::JournalPerformanceTest(const TestParameters& tp, const JournalParameters& jp) :
#endif
- Streamable(),
- _testParams(tp),
- _jrnlParams(jp),
- _jrnlPerf(tp),
- msgData(new char[tp._msgSize])
+ Streamable(),
+ _testParams(tp),
+ _jrnlParams(jp),
+ _jrnlPerf(tp),
+ msgData(new char[tp._msgSize])
{}
JournalPerformanceTest::~JournalPerformanceTest()
@@ -77,10 +77,10 @@
JournalPerformanceTest::_prepareJournals()
{
#ifdef JOURNAL2
- if (mrg::journal2::jdir::exists(_jrnlParams._jrnlDir)) {
- mrg::journal2::jdir::delete_dir(_jrnlParams._jrnlDir);
+ if (mrg::journal2::JournalDirectory::s_exists(_jrnlParams._jrnlDir)) {
+ mrg::journal2::JournalDirectory::s_delete(_jrnlParams._jrnlDir);
}
- mrg::journal2::jdir::create_dir(_jrnlParams._jrnlDir);
+ mrg::journal2::JournalDirectory::s_create(_jrnlParams._jrnlDir);
mrg::journal2::jrnl* jp;
#else
if (mrg::journal::jdir::exists(_jrnlParams._jrnlDir)) {
Modified: store/trunk/cpp/perf/PerformanceResult.cpp
===================================================================
--- store/trunk/cpp/perf/PerformanceResult.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/perf/PerformanceResult.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -39,9 +39,9 @@
{
PerformanceResult::PerformanceResult(const TestParameters& tp) :
- ScopedTimable(),
- Streamable(),
- _testParams(tp)
+ ScopedTimable(),
+ Streamable(),
+ _testParams(tp)
{}
void
Modified: store/trunk/cpp/perf/TestParameters.cpp
===================================================================
--- store/trunk/cpp/perf/TestParameters.cpp 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/perf/TestParameters.cpp 2010-12-09 14:33:48 UTC (rev 4435)
@@ -45,13 +45,13 @@
uint16_t TestParameters::_s_defaultDeqTxnBlkSize = 0;
TestParameters::TestParameters():
- Streamable(),
- _numMsgs(_s_defaultNumMsgs),
- _msgSize(_s_defaultMsgSize),
- _numQueues(_s_defaultNumQueues),
- _numThreadPairsPerQueue(_s_defaultNumThreadPairsPerQueue),
- _enqTxnBlockSize(_s_defaultEnqTxnBlkSize),
- _deqTxnBlockSize(_s_defaultDeqTxnBlkSize)
+ Streamable(),
+ _numMsgs(_s_defaultNumMsgs),
+ _msgSize(_s_defaultMsgSize),
+ _numQueues(_s_defaultNumQueues),
+ _numThreadPairsPerQueue(_s_defaultNumThreadPairsPerQueue),
+ _enqTxnBlockSize(_s_defaultEnqTxnBlkSize),
+ _deqTxnBlockSize(_s_defaultDeqTxnBlkSize)
{}
TestParameters::TestParameters(const uint32_t numMsgs,
@@ -60,23 +60,23 @@
const uint16_t numThreadPairsPerQueue,
const uint16_t enqTxnBlockSize,
const uint16_t deqTxnBlockSize) :
- Streamable(),
- _numMsgs(numMsgs),
- _msgSize(msgSize),
- _numQueues(numQueues),
- _numThreadPairsPerQueue(numThreadPairsPerQueue),
- _enqTxnBlockSize(enqTxnBlockSize),
- _deqTxnBlockSize(deqTxnBlockSize)
+ Streamable(),
+ _numMsgs(numMsgs),
+ _msgSize(msgSize),
+ _numQueues(numQueues),
+ _numThreadPairsPerQueue(numThreadPairsPerQueue),
+ _enqTxnBlockSize(enqTxnBlockSize),
+ _deqTxnBlockSize(deqTxnBlockSize)
{}
TestParameters::TestParameters(const TestParameters& tp):
- Streamable(),
- _numMsgs(tp._numMsgs),
- _msgSize(tp._msgSize),
- _numQueues(tp._numQueues),
- _numThreadPairsPerQueue(tp._numThreadPairsPerQueue),
- _enqTxnBlockSize(tp._enqTxnBlockSize),
- _deqTxnBlockSize(tp._deqTxnBlockSize)
+ Streamable(),
+ _numMsgs(tp._numMsgs),
+ _msgSize(tp._msgSize),
+ _numQueues(tp._numQueues),
+ _numThreadPairsPerQueue(tp._numThreadPairsPerQueue),
+ _enqTxnBlockSize(tp._enqTxnBlockSize),
+ _deqTxnBlockSize(tp._deqTxnBlockSize)
{}
void
Modified: store/trunk/cpp/perf/m
===================================================================
--- store/trunk/cpp/perf/m 2010-12-08 18:07:29 UTC (rev 4434)
+++ store/trunk/cpp/perf/m 2010-12-09 14:33:48 UTC (rev 4435)
@@ -58,13 +58,13 @@
DEFINES=-DJOURNAL2
-JRNL_FILES="../lib/jrnl2/dtok.cpp \
- ../lib/jrnl2/jdir.cpp \
- ../lib/jrnl2/jexception.cpp \
+JRNL_FILES="../lib/jrnl2/DataToken.cpp \
+ ../lib/jrnl2/JournalDirectory.cpp \
+ ../lib/jrnl2/JournalException.cpp \
../lib/jrnl2/jrnl_state.cpp \
../lib/jrnl2/smutex.cpp \
- ../lib/jrnl2/dtok_state.cpp \
- ../lib/jrnl2/jerrno.cpp \
+ ../lib/jrnl2/DataTokenState.cpp \
+ ../lib/jrnl2/JournalErrors.cpp \
../lib/jrnl2/jrnl.cpp \
../lib/jrnl2/slock.cpp \
../lib/jrnl2/JournalParameters.cpp"
14 years
rhmessaging commits: r4434 - mgmt.
by rhmessaging-commits@lists.jboss.org
Author: tmckay
Date: 2010-12-08 13:07:29 -0500 (Wed, 08 Dec 2010)
New Revision: 4434
Added:
mgmt/MOVED_MOVED_MOVED
Log:
Add a file notice stating that the rhmessaging/mgmt elements have moved.
Added: mgmt/MOVED_MOVED_MOVED
===================================================================
--- mgmt/MOVED_MOVED_MOVED (rev 0)
+++ mgmt/MOVED_MOVED_MOVED 2010-12-08 18:07:29 UTC (rev 4434)
@@ -0,0 +1,5 @@
+As of revision 4429, the rhmessaging/mgmt/* elements of this repository have moved to
+
+http://svn.fedorahosted.org/svn/cumin/
+
+Development of these particular elements in this particular repository has ended.
14 years
rhmessaging commits: r4433 - mgmt/trunk.
by rhmessaging-commits@lists.jboss.org
Author: tmckay
Date: 2010-12-08 12:59:16 -0500 (Wed, 08 Dec 2010)
New Revision: 4433
Added:
mgmt/trunk/MOVED_MOVED_MOVED
Log:
Add a file notice stating that the rhmessaging/mgmt elements have moved.
Added: mgmt/trunk/MOVED_MOVED_MOVED
===================================================================
--- mgmt/trunk/MOVED_MOVED_MOVED (rev 0)
+++ mgmt/trunk/MOVED_MOVED_MOVED 2010-12-08 17:59:16 UTC (rev 4433)
@@ -0,0 +1,5 @@
+As of revision 4429, the rhmessaging/mgmt/* elements of this repository have moved to
+
+http://svn.fedorahosted.org/svn/cumin/
+
+Development of these particular elements in this particular repository has ended.
14 years
rhmessaging commits: r4432 - mgmt/newdata.
by rhmessaging-commits@lists.jboss.org
Author: tmckay
Date: 2010-12-08 12:57:03 -0500 (Wed, 08 Dec 2010)
New Revision: 4432
Added:
mgmt/newdata/MOVED_MOVED_MOVED
Log:
Add a file notice stating that the rhmessaging/mgmt components have moved.
Added: mgmt/newdata/MOVED_MOVED_MOVED
===================================================================
--- mgmt/newdata/MOVED_MOVED_MOVED (rev 0)
+++ mgmt/newdata/MOVED_MOVED_MOVED 2010-12-08 17:57:03 UTC (rev 4432)
@@ -0,0 +1,5 @@
+As of revision 4429, the rhmessaging/mgmt/* elements of this repository have moved to
+
+http://svn.fedorahosted.org/svn/cumin/
+
+Development of these particular elements in this particular repository has ended.
14 years
rhmessaging commits: r4431 - store/trunk/cpp/perf.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2010-12-08 11:48:40 -0500 (Wed, 08 Dec 2010)
New Revision: 4431
Modified:
store/trunk/cpp/perf/ScopedTimable.hpp
store/trunk/cpp/perf/ScopedTimer.cpp
store/trunk/cpp/perf/ScopedTimer.hpp
store/trunk/cpp/perf/m
Log:
Perf code tidy-up: Replaced ugly access fn with friend class declaration
Modified: store/trunk/cpp/perf/ScopedTimable.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimable.hpp 2010-12-08 16:26:09 UTC (rev 4430)
+++ store/trunk/cpp/perf/ScopedTimable.hpp 2010-12-08 16:48:40 UTC (rev 4431)
@@ -37,6 +37,18 @@
namespace jtest
{
+ class ScopedTimable;
+
+} // namespace jtest
+} // namespace mrg
+
+#include "ScopedTimer.hpp" // circular include
+
+namespace mrg
+{
+namespace jtest
+{
+
/**
* \brief Scoped timer class that starts timing on construction and finishes on destruction.
*
@@ -64,15 +76,7 @@
*/
virtual inline ~ScopedTimable() {}
- /**
- * \brief Gets a ref to the elapsed time _elapsed.
- *
- * Returns a ref to the elapsed time _elapsed, for use in the constructor of ScopedTimer objects.
- *
- * \returns Ref to elapsed time _elapsed
- */
- // TODO: Investigate making this class a friend of ScopedTimer instead, exposing this as a public fn is ugly.
- virtual inline double& getElapsedRef() { return _elapsed; }
+ friend class ScopedTimer;
};
} // namespace jtest
Modified: store/trunk/cpp/perf/ScopedTimer.cpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimer.cpp 2010-12-08 16:26:09 UTC (rev 4430)
+++ store/trunk/cpp/perf/ScopedTimer.cpp 2010-12-08 16:48:40 UTC (rev 4431)
@@ -41,7 +41,7 @@
::clock_gettime(CLOCK_REALTIME, &_startTime);
}
- ScopedTimer::ScopedTimer(ScopedTimable& st) : _elapsed(st.getElapsedRef())
+ ScopedTimer::ScopedTimer(ScopedTimable& st) : _elapsed(st._elapsed)
{
::clock_gettime(CLOCK_REALTIME, &_startTime);
}
Modified: store/trunk/cpp/perf/ScopedTimer.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimer.hpp 2010-12-08 16:26:09 UTC (rev 4430)
+++ store/trunk/cpp/perf/ScopedTimer.hpp 2010-12-08 16:48:40 UTC (rev 4431)
@@ -33,13 +33,25 @@
#define mrg_jtest_ScopedTimer_hpp
#include <ctime>
-#include "ScopedTimable.hpp"
+
namespace mrg
{
namespace jtest
{
+ class ScopedTimer;
+
+} // namespace jtest
+} // namespace mrg
+
+#include "ScopedTimable.hpp" // circular include
+
+namespace mrg
+{
+namespace jtest
+{
+
/**
* \brief Scoped timer class that starts timing on construction and finishes on destruction.
*
@@ -82,7 +94,6 @@
*
* \param st A ref to a ScopedTimable into which the result of the ScopedTimer can be written.
*/
- // TODO: Investigate making class ScopedTimer a friend of this class.
ScopedTimer(ScopedTimable& st);
/**
Modified: store/trunk/cpp/perf/m
===================================================================
--- store/trunk/cpp/perf/m 2010-12-08 16:26:09 UTC (rev 4430)
+++ store/trunk/cpp/perf/m 2010-12-08 16:48:40 UTC (rev 4431)
@@ -5,7 +5,7 @@
# The variable JOURNAL2, if defined, will link with the new journal2 namespace journal. Otherwise the old journal
# namespace will be used.
-#JOURNAL2=1
+JOURNAL2=1
# Optimization options
#OPT="-O0 -ggdb"
14 years
rhmessaging commits: r4430 - in store/trunk/cpp: lib/jrnl2 and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2010-12-08 11:26:09 -0500 (Wed, 08 Dec 2010)
New Revision: 4430
Added:
store/trunk/cpp/perf/JournalPerformanceTest.cpp
store/trunk/cpp/perf/JournalPerformanceTest.hpp
store/trunk/cpp/perf/PerformanceResult.cpp
store/trunk/cpp/perf/PerformanceResult.hpp
store/trunk/cpp/perf/ScopedTimable.hpp
store/trunk/cpp/perf/ScopedTimer.cpp
store/trunk/cpp/perf/ScopedTimer.hpp
store/trunk/cpp/perf/Streamable.cpp
store/trunk/cpp/perf/Streamable.hpp
Removed:
store/trunk/cpp/perf/ScopedPerformanceTimer.cpp
store/trunk/cpp/perf/ScopedPerformanceTimer.hpp
store/trunk/cpp/perf/StorePerformanceTest.cpp
store/trunk/cpp/perf/StorePerformanceTest.hpp
Modified:
store/trunk/cpp/docs/Makefile.am
store/trunk/cpp/lib/jrnl2/JournalParameters.cpp
store/trunk/cpp/lib/jrnl2/JournalParameters.hpp
store/trunk/cpp/perf/JournalInstance.cpp
store/trunk/cpp/perf/JournalInstance.hpp
store/trunk/cpp/perf/JournalParameters.cpp
store/trunk/cpp/perf/JournalParameters.hpp
store/trunk/cpp/perf/Makefile.am
store/trunk/cpp/perf/TestParameters.cpp
store/trunk/cpp/perf/TestParameters.hpp
store/trunk/cpp/perf/m
Log:
Perf code refactor and tidy-up and removed creation of postscript docs (which don't work properly on RHEL4/5)
Modified: store/trunk/cpp/docs/Makefile.am
===================================================================
--- store/trunk/cpp/docs/Makefile.am 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/docs/Makefile.am 2010-12-08 16:26:09 UTC (rev 4430)
@@ -41,9 +41,9 @@
@doxygen jrnl_tmpl.dox
# FIXME: doxygen seems to create files that do not compile under latex on 64-bit
# so the following section is disabled until this is sorted out.
- @make -C latex
+# @make -C latex
# @cd latex; dvipdf refman.dvi refman.pdf
- @cd latex; dvips refman.dvi -o refman.ps
+# @cd latex; dvips refman.dvi -o refman.ps
# @ln -fs latex/refman.pdf rhmj.pdf
# @ln -fs latex/refman.ps rhmj.ps
else
Modified: store/trunk/cpp/lib/jrnl2/JournalParameters.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalParameters.cpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/lib/jrnl2/JournalParameters.cpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -89,21 +89,41 @@
{}
+void
+JournalParameters::toStream(std::ostream& os) const
+{
+ os << "Store Parameters:" << std::endl;
+ os << " jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
+ os << " jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
+ os << " numJrnlFiles = " << _numJrnlFiles << std::endl;
+ os << " jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
+ os << " autoExpand = " << _autoExpand << std::endl;
+ os << " autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
+ os << " writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
+ os << " writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
+}
+
std::string
-JournalParameters::toString()
+JournalParameters::toString() const
{
std::ostringstream oss;
- oss << "Store Parameters:" << std::endl;
- oss << " jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
- oss << " jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
- oss << " numJrnlFiles = " << _numJrnlFiles << std::endl;
- oss << " jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
- oss << " autoExpand = " << _autoExpand << std::endl;
- oss << " autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
- oss << " writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
- oss << " writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
+ toStream(oss);
return oss.str();
}
+std::ostream&
+operator<<(std::ostream& os, const JournalParameters& jp)
+{
+ jp.toStream(os);
+ return os;
+}
+
+std::ostream&
+operator<<(std::ostream& os, const JournalParameters* jpPtr)
+{
+ jpPtr->toStream(os);
+ return os;
+}
+
} // namespace journal2
} // namespace mrg
Modified: store/trunk/cpp/lib/jrnl2/JournalParameters.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalParameters.hpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/lib/jrnl2/JournalParameters.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -32,6 +32,7 @@
#ifndef mrg_journal2_JournalParameters_hpp
#define mrg_journal2_JournalParameters_hpp
+#include <iostream>
#include <string>
#include <sys/types.h>
@@ -70,7 +71,11 @@
const u_int16_t writeBuffNumPgs,
const u_int32_t writeBuffPgSize_sblks);
JournalParameters(const JournalParameters& sp);
- std::string toString();
+ void toStream(std::ostream& os = std::cout) const;
+ std::string toString() const;
+
+ friend std::ostream& operator<<(std::ostream& os, const JournalParameters& jp);
+ friend std::ostream& operator<<(std::ostream& os, const JournalParameters* jpPtr);
};
} // namespace journal2
Modified: store/trunk/cpp/perf/JournalInstance.cpp
===================================================================
--- store/trunk/cpp/perf/JournalInstance.cpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/JournalInstance.cpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -38,216 +38,214 @@
namespace jtest
{
-JournalInstance::JournalInstance(const uint32_t numMsgs,
- const uint32_t msgSize,
- const char* msgData,
+ JournalInstance::JournalInstance(const uint32_t numMsgs,
+ const uint32_t msgSize,
+ const char* msgData,
#ifdef JOURNAL2
- mrg::journal2::jrnl* const jrnlPtr) :
+ mrg::journal2::jrnl* const jrnlPtr) :
#else
- mrg::journal::jcntl* const jrnlPtr) :
+ mrg::journal::jcntl* const jrnlPtr) :
#endif
- _numMsgs(numMsgs),
- _msgSize(msgSize),
- _msgData(msgData),
- _jrnlPtr(jrnlPtr),
- _threadSwitch(false)
-{}
+ _numMsgs(numMsgs),
+ _msgSize(msgSize),
+ _msgData(msgData),
+ _jrnlPtr(jrnlPtr),
+ _threadSwitch(false)
+ {}
-JournalInstance::~JournalInstance()
-{
- delete _jrnlPtr;
-}
+ JournalInstance::~JournalInstance()
+ {
+ delete _jrnlPtr;
+ }
-// *** MUST BE THREAD-SAFE ****
-// This method will be called by multiple threads simultaneously
-// Enqueue thread entry point
-void
-JournalInstance::_doEnqueues()
-{
- bool misfireFlag = false;
- uint32_t i = 0;
- while (i < _numMsgs) {
+ // *** MUST BE THREAD-SAFE ****
+ // This method will be called by multiple threads simultaneously
+ // Enqueue thread entry point
+ void
+ JournalInstance::_doEnqueues()
+ {
+ bool misfireFlag = false;
+ uint32_t i = 0;
+ while (i < _numMsgs) {
#ifdef JOURNAL2
- mrg::journal2::dtok* dtokPtr = new mrg::journal2::dtok();
- mrg::journal2::iores jrnlIoRes = _jrnlPtr->enqueue(_msgData, _msgSize, dtokPtr);
+ mrg::journal2::dtok* dtokPtr = new mrg::journal2::dtok();
+ mrg::journal2::iores jrnlIoRes = _jrnlPtr->enqueue(_msgData, _msgSize, dtokPtr);
#else
- mrg::journal::data_tok* dtokPtr = new mrg::journal::data_tok();
- mrg::journal::iores jrnlIoRes = _jrnlPtr->enqueue_data_record(_msgData, _msgSize, _msgSize, dtokPtr);
+ mrg::journal::data_tok* dtokPtr = new mrg::journal::data_tok();
+ mrg::journal::iores jrnlIoRes = _jrnlPtr->enqueue_data_record(_msgData, _msgSize, _msgSize, dtokPtr);
#endif
- switch (jrnlIoRes) {
+ switch (jrnlIoRes) {
#ifdef JOURNAL2
- case 0:
+ case 0:
#else
- case mrg::journal::RHM_IORES_SUCCESS:
+ case mrg::journal::RHM_IORES_SUCCESS:
#endif
- i++;
- misfireFlag = false;
- break;
+ i++;
+ misfireFlag = false;
+ break;
#ifdef JOURNAL2
- case mrg::journal2::RHM_IORES_BUSY:
+ case mrg::journal2::RHM_IORES_BUSY:
#else
- case mrg::journal::RHM_IORES_BUSY:
+ case mrg::journal::RHM_IORES_BUSY:
#endif
- if (!misfireFlag) std::cout << "-" << std::flush;
- delete dtokPtr;
- misfireFlag = true;
- break;
+ if (!misfireFlag) std::cout << "-" << std::flush;
+ delete dtokPtr;
+ misfireFlag = true;
+ break;
#ifdef JOURNAL2
- case mrg::journal2::RHM_IORES_ENQCAPTHRESH:
+ case mrg::journal2::RHM_IORES_ENQCAPTHRESH:
#else
- case mrg::journal::RHM_IORES_ENQCAPTHRESH:
+ case mrg::journal::RHM_IORES_ENQCAPTHRESH:
#endif
- //std::cout << "_doEnqueues() RHM_IORES_ENQCAPTHRESH: " << dtokPtr->status_str() << std::endl;
- if (!misfireFlag) std::cout << "*" << std::flush;
- //std::cout << ".";
- delete dtokPtr;
- misfireFlag = true;
- ::usleep(10);
- break;
- default:
- delete dtokPtr;
+ //std::cout << "_doEnqueues() RHM_IORES_ENQCAPTHRESH: " << dtokPtr->status_str() << std::endl;
+ if (!misfireFlag) std::cout << "*" << std::flush;
+ //std::cout << ".";
+ delete dtokPtr;
+ misfireFlag = true;
+ ::usleep(10);
+ break;
+ default:
+ delete dtokPtr;
#ifdef JOURNAL2
- std::cerr << "enqueue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << std::endl;
+ std::cerr << "enqueue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << std::endl;
#else
- std::cerr << "enqueue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << std::endl;
+ std::cerr << "enqueue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << std::endl;
#endif
+ }
}
+ _jrnlPtr->flush(false);
}
- _jrnlPtr->flush(false);
-}
-// *** MUST BE THREAD-SAFE ****
-// This method will be called by multiple threads simultaneously
-// Dequeue thread entry point
-void
-JournalInstance::_doDequeues()
-{
- uint32_t i = 0;
- while (i < _numMsgs) {
+ // *** MUST BE THREAD-SAFE ****
+ // This method will be called by multiple threads simultaneously
+ // Dequeue thread entry point
+ void
+ JournalInstance::_doDequeues()
+ {
+ uint32_t i = 0;
+ while (i < _numMsgs) {
#ifdef JOURNAL2
- mrg::journal2::dtok* dtokPtr = 0;
+ mrg::journal2::dtok* dtokPtr = 0;
#else
- mrg::journal::data_tok* dtokPtr = 0;
+ mrg::journal::data_tok* dtokPtr = 0;
#endif
- while (!dtokPtr) {
- bool getEventsFlag;
- {
- std::unique_lock<std::mutex> l(_unprocCallbackListMutex);
- getEventsFlag = _unprocCallbackList.size() == 0;
- if (!getEventsFlag) {
- dtokPtr = _unprocCallbackList.front();
- _unprocCallbackList.pop();
+ while (!dtokPtr) {
+ bool getEventsFlag; // thread local
+ { // --- START OF CRITICAL SECTION ---
+ std::lock_guard<std::mutex> l(_unprocCallbackListMutex);
+ getEventsFlag = _unprocCallbackList.size() == 0;
+ if (!getEventsFlag) {
+ dtokPtr = _unprocCallbackList.front();
+ _unprocCallbackList.pop();
+ }
+ } // --- END OF CRITICAL SECTION ---
+ if (getEventsFlag) {
+ _jrnlPtr->get_wr_events(0);
+ ::usleep(1);
}
}
- if (getEventsFlag) {
- _jrnlPtr->get_wr_events(0);
- ::usleep(1);
- }
- }
- bool done = false;
- while (!done) {
+ bool done = false;
+ while (!done) {
#ifdef JOURNAL2
- mrg::journal2::iores jrnlIoRes = _jrnlPtr->dequeue(dtokPtr);
+ mrg::journal2::iores jrnlIoRes = _jrnlPtr->dequeue(dtokPtr);
#else
- mrg::journal::iores jrnlIoRes = _jrnlPtr->dequeue_data_record(dtokPtr);
+ mrg::journal::iores jrnlIoRes = _jrnlPtr->dequeue_data_record(dtokPtr);
#endif
- switch (jrnlIoRes) {
+ switch (jrnlIoRes) {
#ifdef JOURNAL2
- case 0:
+ case 0:
#else
- case mrg::journal::RHM_IORES_SUCCESS:
+ case mrg::journal::RHM_IORES_SUCCESS:
#endif
- i ++;
- done = true;
- break;
+ i ++;
+ done = true;
+ break;
#ifdef JOURNAL2
- case mrg::journal2::RHM_IORES_BUSY:
+ case mrg::journal2::RHM_IORES_BUSY:
#else
- case mrg::journal::RHM_IORES_BUSY:
+ case mrg::journal::RHM_IORES_BUSY:
#endif
- //::usleep(10);
- break;
- default:
+ //::usleep(10);
+ break;
+ default:
#ifdef JOURNAL2
- std::cerr << "dequeue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << ": "
- << dtokPtr->status_str() << std::endl;
+ std::cerr << "dequeue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << ": "
+ << dtokPtr->status_str() << std::endl;
#else
- std::cerr << "dequeue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << ": "
- << dtokPtr->status_str() << std::endl;
+ std::cerr << "dequeue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << ": "
+ << dtokPtr->status_str() << std::endl;
#endif
- delete dtokPtr;
- done = true;
+ delete dtokPtr;
+ done = true;
+ }
}
+ _jrnlPtr->get_wr_events(0);
}
- _jrnlPtr->get_wr_events(0);
+ _jrnlPtr->flush(true);
}
- _jrnlPtr->flush(true);
-}
-// *** MUST BE THREAD-SAFE ****
-// This method will be called by multiple threads simultaneously
-// Main thread entry point.
-// _threadSwitch flips on each call; this makes alternate threads run _doEnqueues() and _doDequeues()
-void
-JournalInstance::operator()()
-{
- bool localThreadSwitch;
+ // *** MUST BE THREAD-SAFE ****
+ // This method will be called by multiple threads simultaneously
+ // Main thread entry point.
+ // _threadSwitch flips on each call; this makes alternate threads run _doEnqueues() and _doDequeues()
+ void
+ JournalInstance::operator()()
{
- std::lock_guard<std::mutex> l(_ts_lock);
- localThreadSwitch = _threadSwitch;
- _threadSwitch = !_threadSwitch;
+ bool localThreadSwitch; // thread local
+ { // --- START OF CRITICAL SECTION ---
+ std::lock_guard<std::mutex> l(_threadSwitchLock);
+ localThreadSwitch = _threadSwitch;
+ _threadSwitch = !_threadSwitch;
+ } // --- END OF CRITICAL SECTION ---
+ if (localThreadSwitch) {
+ _doDequeues();
+ } else {
+ _doEnqueues();
+ }
}
- if (localThreadSwitch) {
- _doDequeues();
- } else {
- _doEnqueues();
- }
-}
-// *** MUST BE THREAD-SAFE ****
-// This method will be called by multiple threads simultaneously
-void
+ // *** MUST BE THREAD-SAFE ****
+ // This method will be called by multiple threads simultaneously
+ void
#ifdef JOURNAL2
-JournalInstance::wr_aio_cb(std::vector<mrg::journal2::dtok*>& dataTokenList)
-{
- mrg::journal2::dtok* dtokPtr;
+ JournalInstance::wr_aio_cb(std::vector<mrg::journal2::dtok*>& dataTokenList)
+ {
+ mrg::journal2::dtok* dtokPtr;
#else
-JournalInstance::wr_aio_cb(std::vector<mrg::journal::data_tok*>& dataTokenList)
-{
- mrg::journal::data_tok* dtokPtr;
-#endif
- while (dataTokenList.size())
+ JournalInstance::wr_aio_cb(std::vector<mrg::journal::data_tok*>& dataTokenList)
{
- dtokPtr = dataTokenList.back();
- dataTokenList.pop_back();
-#ifdef JOURNAL2
- switch (dtokPtr->get_dtok_state().get_op_state())
+ mrg::journal::data_tok* dtokPtr;
+#endif
+ while (dataTokenList.size())
{
- case mrg::journal2::OP_ENQUEUE:
+ dtokPtr = dataTokenList.back();
+ dataTokenList.pop_back();
+#ifdef JOURNAL2
+ switch (dtokPtr->get_dtok_state().get_op_state()) {
+ case mrg::journal2::OP_ENQUEUE:
#else
- switch (dtokPtr->wstate())
- {
- case mrg::journal::data_tok::ENQ:
+ switch (dtokPtr->wstate()) {
+ case mrg::journal::data_tok::ENQ:
#endif
- {
- std::unique_lock<std::mutex> l(_unprocCallbackListMutex);
- _unprocCallbackList.push(dtokPtr);
+ { // --- START OF CRITICAL SECTION ---
+ std::lock_guard<std::mutex> l(_unprocCallbackListMutex);
+ _unprocCallbackList.push(dtokPtr);
+ } // --- END OF CRITICAL SECTION ---
+ break;
+ default:
+ delete dtokPtr;
}
- break;
- default:
- delete dtokPtr;
}
}
-}
-// *** MUST BE THREAD-SAFE ****
-// This method will be called by multiple threads simultaneously
-void
-JournalInstance::rd_aio_cb(std::vector<uint16_t>& /*buffPageCtrlBlkIndexList*/)
-{}
+ // *** MUST BE THREAD-SAFE ****
+ // This method will be called by multiple threads simultaneously
+ void
+ JournalInstance::rd_aio_cb(std::vector<uint16_t>& /*buffPageCtrlBlkIndexList*/)
+ {}
} // namespace jtest
} // namespace mrg
Modified: store/trunk/cpp/perf/JournalInstance.hpp
===================================================================
--- store/trunk/cpp/perf/JournalInstance.hpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/JournalInstance.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -76,7 +76,7 @@
#endif
std::mutex _unprocCallbackListMutex; ///< Mutex which protects the unprocessed callback queue
bool _threadSwitch; ///< A switch which alternates worker threads between enq and deq
- std::mutex _ts_lock; ///< Mutex which protects the thread switch
+ std::mutex _threadSwitchLock; ///< Mutex which protects the thread switch
/**
* \brief Worker thread enqueue task
@@ -105,8 +105,6 @@
/**
* \brief Constructor
*
- * Constructor.
- *
* \param numMsgs Number of messages per thread to be enqueued then dequeued (ie both ways through broker)
* \param msgSize Size of each message being enqueued
* \param msgData Pointer to message content (all messages have identical content)
@@ -125,9 +123,7 @@
#endif
/**
- * \brief Destructor
- *
- * Destructor.
+ * \brief virtual destructor
*/
virtual ~JournalInstance();
Modified: store/trunk/cpp/perf/JournalParameters.cpp
===================================================================
--- store/trunk/cpp/perf/JournalParameters.cpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/JournalParameters.cpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -31,85 +31,78 @@
#include "JournalParameters.hpp"
-#include <sstream>
-
namespace mrg
{
namespace jtest
{
-// static declarations
-std::string JournalParameters::_s_defaultJrnlDir = "/tmp/store";
-std::string JournalParameters::_s_defaultJrnlBaseFileName = "JournalData";
-uint16_t JournalParameters::_s_defaultNumJrnlFiles = 8;
-uint32_t JournalParameters::_s_defaultJrnlFileSize_sblks = 3072;
-bool JournalParameters::_s_defaultAutoExpand = false;
-uint16_t JournalParameters::_s_defaultAutoExpandMaxJrnlFiles = 0;
-uint16_t JournalParameters::_s_defaultWriteBuffNumPgs = 32;
-uint32_t JournalParameters::_s_defaultWriteBuffPgSize_sblks = 128;
+ // static declarations
+ std::string JournalParameters::_s_defaultJrnlDir = "/tmp/store";
+ std::string JournalParameters::_s_defaultJrnlBaseFileName = "JournalData";
+ uint16_t JournalParameters::_s_defaultNumJrnlFiles = 8;
+ uint32_t JournalParameters::_s_defaultJrnlFileSize_sblks = 3072;
+ bool JournalParameters::_s_defaultAutoExpand = false;
+ uint16_t JournalParameters::_s_defaultAutoExpandMaxJrnlFiles = 0;
+ uint16_t JournalParameters::_s_defaultWriteBuffNumPgs = 32;
+ uint32_t JournalParameters::_s_defaultWriteBuffPgSize_sblks = 128;
-JournalParameters::JournalParameters() :
- _jrnlDir(_s_defaultJrnlDir),
- _jrnlBaseFileName(_s_defaultJrnlBaseFileName),
- _numJrnlFiles(_s_defaultNumJrnlFiles),
- _jrnlFileSize_sblks(_s_defaultJrnlFileSize_sblks),
- _autoExpand(_s_defaultAutoExpand),
- _autoExpandMaxJrnlFiles(_s_defaultAutoExpandMaxJrnlFiles),
- _writeBuffNumPgs(_s_defaultWriteBuffNumPgs),
- _writeBuffPgSize_sblks(_s_defaultWriteBuffPgSize_sblks)
-{}
+ JournalParameters::JournalParameters() :
+ Streamable(),
+ _jrnlDir(_s_defaultJrnlDir),
+ _jrnlBaseFileName(_s_defaultJrnlBaseFileName),
+ _numJrnlFiles(_s_defaultNumJrnlFiles),
+ _jrnlFileSize_sblks(_s_defaultJrnlFileSize_sblks),
+ _autoExpand(_s_defaultAutoExpand),
+ _autoExpandMaxJrnlFiles(_s_defaultAutoExpandMaxJrnlFiles),
+ _writeBuffNumPgs(_s_defaultWriteBuffNumPgs),
+ _writeBuffPgSize_sblks(_s_defaultWriteBuffPgSize_sblks)
+ {}
-JournalParameters::JournalParameters(const std::string& jrnlDir,
- const std::string& jrnlBaseFileName,
- const uint16_t numJrnlFiles,
- const uint32_t jrnlFileSize_sblks,
- const bool autoExpand,
- const uint16_t autoExpandMaxJrnlFiles,
- const uint16_t writeBuffNumPgs,
- const uint32_t writeBuffPgSize_sblks) :
- _jrnlDir(jrnlDir),
- _jrnlBaseFileName(jrnlBaseFileName),
- _numJrnlFiles(numJrnlFiles),
- _jrnlFileSize_sblks(jrnlFileSize_sblks),
- _autoExpand(autoExpand),
- _autoExpandMaxJrnlFiles(autoExpandMaxJrnlFiles),
- _writeBuffNumPgs(writeBuffNumPgs),
- _writeBuffPgSize_sblks(writeBuffPgSize_sblks)
-{}
+ JournalParameters::JournalParameters(const std::string& jrnlDir,
+ const std::string& jrnlBaseFileName,
+ const uint16_t numJrnlFiles,
+ const uint32_t jrnlFileSize_sblks,
+ const bool autoExpand,
+ const uint16_t autoExpandMaxJrnlFiles,
+ const uint16_t writeBuffNumPgs,
+ const uint32_t writeBuffPgSize_sblks) :
+ Streamable(),
+ _jrnlDir(jrnlDir),
+ _jrnlBaseFileName(jrnlBaseFileName),
+ _numJrnlFiles(numJrnlFiles),
+ _jrnlFileSize_sblks(jrnlFileSize_sblks),
+ _autoExpand(autoExpand),
+ _autoExpandMaxJrnlFiles(autoExpandMaxJrnlFiles),
+ _writeBuffNumPgs(writeBuffNumPgs),
+ _writeBuffPgSize_sblks(writeBuffPgSize_sblks)
+ {}
-JournalParameters::JournalParameters(const JournalParameters& jp) :
- _jrnlDir(jp._jrnlDir),
- _jrnlBaseFileName(jp._jrnlBaseFileName),
- _numJrnlFiles(jp._numJrnlFiles),
- _jrnlFileSize_sblks(jp._jrnlFileSize_sblks),
- _autoExpand(jp._autoExpand),
- _autoExpandMaxJrnlFiles(jp._autoExpandMaxJrnlFiles),
- _writeBuffNumPgs(jp._writeBuffNumPgs),
- _writeBuffPgSize_sblks(jp._writeBuffPgSize_sblks)
+ JournalParameters::JournalParameters(const JournalParameters& jp) :
+ Streamable(),
+ _jrnlDir(jp._jrnlDir),
+ _jrnlBaseFileName(jp._jrnlBaseFileName),
+ _numJrnlFiles(jp._numJrnlFiles),
+ _jrnlFileSize_sblks(jp._jrnlFileSize_sblks),
+ _autoExpand(jp._autoExpand),
+ _autoExpandMaxJrnlFiles(jp._autoExpandMaxJrnlFiles),
+ _writeBuffNumPgs(jp._writeBuffNumPgs),
+ _writeBuffPgSize_sblks(jp._writeBuffPgSize_sblks)
-{}
+ {}
-void
-JournalParameters::toStream(std::ostream& os)
-{
- os << "Store Parameters:" << std::endl;
- os << " jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
- os << " jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
- os << " numJrnlFiles = " << _numJrnlFiles << std::endl;
- os << " jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
- os << " autoExpand = " << _autoExpand << std::endl;
- os << " autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
- os << " writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
- os << " writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
-}
+ void
+ JournalParameters::toStream(std::ostream& os) const
+ {
+ os << "Store Parameters:" << std::endl;
+ os << " jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
+ os << " jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
+ os << " numJrnlFiles = " << _numJrnlFiles << std::endl;
+ os << " jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
+ os << " autoExpand = " << _autoExpand << std::endl;
+ os << " autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
+ os << " writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
+ os << " writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
+ }
-std::string
-JournalParameters::toString()
-{
- std::ostringstream oss;
- toStream(oss);
- return oss.str();
-}
-
} // namespace jtest
} // namespace mrg
Modified: store/trunk/cpp/perf/JournalParameters.hpp
===================================================================
--- store/trunk/cpp/perf/JournalParameters.hpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/JournalParameters.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -33,8 +33,7 @@
#define mrg_jtest_JournalParameters_hpp
#include <cstdint>
-#include <iostream>
-#include <string>
+#include "Streamable.hpp"
namespace mrg
{
@@ -47,7 +46,7 @@
* This struct is used to aggregate and keep together all the common journal parameters. These affect the journal
* geometry and buffers. The test parameters are aggregated in class TestParameters.
*/
- struct JournalParameters
+ struct JournalParameters : public Streamable
{
// static default store params
static std::string _s_defaultJrnlDir; ///< Default journal directory
@@ -101,12 +100,15 @@
/**
* \brief Copy constructor
*
- * Copy constructor.
- *
* \param jp Reference to JournalParameters instance to be copied
*/
JournalParameters(const JournalParameters& jp);
+ /**
+ * \brief Virtual destructor
+ */
+ virtual ~JournalParameters() {}
+
/***
* \brief Stream the journal parameters to an output stream
*
@@ -115,17 +117,7 @@
*
* \param os Output stream to which the class data is to be streamed
*/
- void toStream(std::ostream& os = std::cout);
-
- /**
- * \brief Creates a string representation of the journal parameters
- *
- * Convenience feature which creates a multi-line string representation of all the journal parameters, one per
- * line.
- *
- * \return multi-line string representation of all the parameters, one parameter per line.
- */
- std::string toString();
+ void toStream(std::ostream& os = std::cout) const;
};
} // namespace jtest
Copied: store/trunk/cpp/perf/JournalPerformanceTest.cpp (from rev 4428, store/trunk/cpp/perf/StorePerformanceTest.cpp)
===================================================================
--- store/trunk/cpp/perf/JournalPerformanceTest.cpp (rev 0)
+++ store/trunk/cpp/perf/JournalPerformanceTest.cpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,312 @@
+/**
+ * \file JournalPerformanceTest.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "JournalPerformanceTest.hpp"
+
+#include <cstdint> // uint16_t, uint32_t
+#include <cstdlib> // atof, atoi, atol
+#include <deque>
+#include <getopt.h> // getopt_long(), required_argument, no_argument
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+#include <thread>
+
+#include "ScopedTimer.hpp"
+#ifdef JOURNAL2
+#include "jrnl2/jdir.hpp"
+#else
+#include "jrnl/jdir.hpp"
+#endif
+
+namespace mrg
+{
+namespace jtest
+{
+
+#ifdef JOURNAL2
+ JournalPerformanceTest::JournalPerformanceTest(const TestParameters& tp, const mrg::journal2::JournalParameters& jp) :
+#else
+ JournalPerformanceTest::JournalPerformanceTest(const TestParameters& tp, const JournalParameters& jp) :
+#endif
+ Streamable(),
+ _testParams(tp),
+ _jrnlParams(jp),
+ _jrnlPerf(tp),
+ msgData(new char[tp._msgSize])
+ {}
+
+ JournalPerformanceTest::~JournalPerformanceTest()
+ {
+ while (_jrnlList.size()) {
+ delete _jrnlList.back();
+ _jrnlList.pop_back();
+ }
+ delete[] msgData;
+ }
+
+ void
+ JournalPerformanceTest::_prepareJournals()
+ {
+#ifdef JOURNAL2
+ if (mrg::journal2::jdir::exists(_jrnlParams._jrnlDir)) {
+ mrg::journal2::jdir::delete_dir(_jrnlParams._jrnlDir);
+ }
+ mrg::journal2::jdir::create_dir(_jrnlParams._jrnlDir);
+ mrg::journal2::jrnl* jp;
+#else
+ if (mrg::journal::jdir::exists(_jrnlParams._jrnlDir)) {
+ mrg::journal::jdir::delete_dir(_jrnlParams._jrnlDir);
+ }
+ mrg::journal::jdir::create_dir(_jrnlParams._jrnlDir);
+ mrg::journal::jcntl* jp;
+#endif
+ JournalInstance* ptp;
+ for (uint16_t j = 0; j < _testParams._numQueues; j++) {
+ std::ostringstream jname;
+ jname << "jrnl_" << std::setw(4) << std::setfill('0') << j;
+ std::ostringstream jdir;
+ jdir << _jrnlParams._jrnlDir << "/" << jname.str();
+#ifdef JOURNAL2
+ jp = new mrg::journal2::jrnl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
+#else
+ jp = new mrg::journal::jcntl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
+#endif
+ ptp = new JournalInstance(_testParams._numMsgs, _testParams._msgSize, msgData, jp);
+#ifdef JOURNAL2
+ jp->initialize(&_jrnlParams, ptp);
+#else
+ jp->initialize(_jrnlParams._numJrnlFiles, _jrnlParams._autoExpand, _jrnlParams._autoExpandMaxJrnlFiles,
+ _jrnlParams._jrnlFileSize_sblks, _jrnlParams._writeBuffNumPgs,
+ _jrnlParams._writeBuffPgSize_sblks, ptp);
+#endif
+
+ _jrnlList.push_back(ptp);
+ }
+ }
+
+ void
+ JournalPerformanceTest::run()
+ {
+ std::deque<std::thread*> threads;
+ std::thread* tp;
+ _prepareJournals();
+ { // --- Start of timed section ---
+ ScopedTimer st(_jrnlPerf);
+
+ for (uint16_t q = 0; q < _testParams._numQueues; q++) {
+ // Launch threads in pairs
+ uint16_t numThreads = _testParams._numThreadPairsPerQueue * 2;
+ for (uint16_t t = 0; t < numThreads; t++) {
+ tp = new std::thread(std::ref(*_jrnlList[q]));
+ threads.push_back(tp);
+ }
+ }
+
+ while (threads.size()) {
+ threads.front()->join();
+ delete threads.front();
+ threads.pop_front();
+ }
+ } // --- End of timed section ---
+ }
+
+ void
+ JournalPerformanceTest::toStream(std::ostream& os) const
+ {
+ os << _testParams << std::endl;
+ os << _jrnlParams << std::endl;
+ os << _jrnlPerf << std::endl;
+ }
+
+ void
+ printArgs(std::ostream& os)
+ {
+ os << " -h --help: This help message" << std::endl;
+ os << std::endl;
+ os << "Test params:" << std::endl;
+ os << " -M --num_msgs: Number of messages to send ["
+ << 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 << " -T --num_thread_pairs_per_queue: Number of thread pairs per queue ["
+ << TestParameters::_s_defaultNumThreadPairsPerQueue << "]" << std::endl;
+ os << " -E --enq_txn_blk_size: Enqueue transaction block size (0=non-txn) ["
+ << TestParameters::_s_defaultEnqTxnBlkSize << "]" << std::endl;
+ os << " -D --deq_txn_blk_size: Dequeue transaction block size (0=non-txn) ["
+ << TestParameters::_s_defaultDeqTxnBlkSize << "]" << std::endl;
+ os << std::endl;
+ os << "Store params:" << std::endl;
+#ifdef JOURNAL2
+ os << " -d --jrnl_dir: Store directory [\""
+ << mrg::journal2::JournalParameters::_s_defaultJrnlDir << "\"]" << std::endl;
+ os << " -b --jrnl_base_filename: Base name for journal files [\""
+ << mrg::journal2::JournalParameters::_s_defaultJrnlBaseFileName << "\"]" << std::endl;
+ os << " -f --num_jfiles: Number of journal files ["
+ << mrg::journal2::JournalParameters::_s_defaultNumJrnlFiles << "]" << std::endl;
+ os << " -s --jfsize_sblks: Size of each journal file in sblks (512 byte blocks) ["
+ << mrg::journal2::JournalParameters::_s_defaultJrnlFileSize_sblks << "]" << std::endl;
+ os << " -a --auto_expand: Auto-expand the journal ["
+ << (mrg::journal2::JournalParameters::_s_defaultAutoExpand?"T":"F") << "]" << std::endl;
+ os << " -e --ae_max_jfiles: Upper limit on number of auto-expanded journal files ["
+ << mrg::journal2::JournalParameters::_s_defaultAutoExpandMaxJrnlFiles << "]" << std::endl;
+ os << " -p --wcache_num_pages: Number of write buffer pages ["
+ << mrg::journal2::JournalParameters::_s_defaultWriteBuffNumPgs << "]" << std::endl;
+ os << " -c --wcache_pgsize_sblks: Size of each write buffer page in sblks (512 byte blocks) ["
+ << mrg::journal2::JournalParameters::_s_defaultWriteBuffPgSize_sblks << "]" << std::endl;
+#else
+ os << " -d --jrnl_dir: Store directory [\""
+ << JournalParameters::_s_defaultJrnlDir << "\"]" << std::endl;
+ os << " -b --jrnl_base_filename: Base name for journal files [\""
+ << JournalParameters::_s_defaultJrnlBaseFileName << "\"]" << std::endl;
+ os << " -f --num_jfiles: Number of journal files ["
+ << JournalParameters::_s_defaultNumJrnlFiles << "]" << std::endl;
+ os << " -s --jfsize_sblks: Size of each journal file in sblks (512 byte blocks) ["
+ << JournalParameters::_s_defaultJrnlFileSize_sblks << "]" << std::endl;
+ os << " -a --auto_expand: Auto-expand the journal ["
+ << (JournalParameters::_s_defaultAutoExpand?"T":"F") << "]" << std::endl;
+ os << " -e --ae_max_jfiles: Upper limit on number of auto-expanded journal files ["
+ << JournalParameters::_s_defaultAutoExpandMaxJrnlFiles << "]" << std::endl;
+ os << " -p --wcache_num_pages: Number of write buffer pages ["
+ << JournalParameters::_s_defaultWriteBuffNumPgs << "]" << std::endl;
+ os << " -c --wcache_pgsize_sblks: Size of each write buffer page in sblks (512 byte blocks) ["
+ << JournalParameters::_s_defaultWriteBuffPgSize_sblks << "]" << std::endl;
+#endif
+}
+
+ bool
+#ifdef JOURNAL2
+ readArgs(int argc, char** argv, TestParameters& tp, mrg::journal2::JournalParameters& sp)
+#else
+ readArgs(int argc, char** argv, TestParameters& tp, JournalParameters& sp)
+#endif
+ {
+ static struct option long_options[] = {
+ {"help", no_argument, 0, 'h'},
+
+ // Test params
+ {"num_msgs", required_argument, 0, 'm'},
+ {"msg_size", required_argument, 0, 'S'},
+ {"num_queues", required_argument, 0, 'q'},
+ {"num_threads_per_queue", required_argument, 0, 't'},
+
+ // Journal params
+ {"jrnl_dir", required_argument, 0, 'd'},
+ {"jrnl_base_filename", required_argument, 0, 'b'},
+ {"num_jfiles", required_argument, 0, 'f'},
+ {"jfsize_sblks", required_argument, 0, 's'},
+ {"auto_expand", no_argument, 0, 'a'},
+ {"ae_max_jfiles", required_argument, 0, 'e'},
+ {"wcache_num_pages", required_argument, 0, 'p'},
+ {"wcache_pgsize_sblks", required_argument, 0, 'c'},
+
+ {0, 0, 0, 0}
+ };
+
+ bool err = false;
+ int c = 0;
+ while (true) {
+ int option_index = 0;
+ c = getopt_long(argc, argv, "ab:c:d:e:f:hm:p:q:s:S:t:", long_options, &option_index);
+ if (c == -1) break;
+ switch (c) {
+ // Test params
+ case 'm':
+ tp._numMsgs = uint32_t(std::atol(optarg));
+ break;
+ case 'S':
+ tp._msgSize = uint32_t(std::atol(optarg));
+ break;
+ case 'q':
+ tp._numQueues = uint16_t(std::atoi(optarg));
+ break;
+ case 't':
+ tp._numThreadPairsPerQueue = uint16_t(std::atoi(optarg));
+ break;
+
+ // Store params
+ case 'd':
+ sp._jrnlDir.assign(optarg);
+ break;
+ case 'b':
+ sp._jrnlBaseFileName.assign(optarg);
+ break;
+ case 'f':
+ sp._numJrnlFiles = uint16_t(std::atoi(optarg));
+ break;
+ case 's':
+ sp._jrnlFileSize_sblks = uint32_t(std::atol(optarg));
+ break;
+ case 'a':
+ sp._autoExpand = true;
+ break;
+ case 'e':
+ sp._autoExpandMaxJrnlFiles = uint16_t(std::atoi(optarg));
+ break;
+ case 'p':
+ sp._writeBuffNumPgs = uint16_t(std::atoi(optarg));
+ break;
+ case 'c':
+ sp._writeBuffPgSize_sblks = uint32_t(std::atol(optarg));
+ break;
+
+ // Other
+ case 'h':
+ default:
+ err = true;
+ printArgs();
+ }
+ }
+ return err;
+ }
+
+} // namespace jtest
+} // namespace mrg
+
+// -----------------------------------------------------------------
+
+int
+main(int argc, char** argv)
+{
+ mrg::jtest::TestParameters tp;
+#ifdef JOURNAL2
+ mrg::journal2::JournalParameters jp;
+#else
+ mrg::jtest::JournalParameters jp;
+#endif
+ if (mrg::jtest::readArgs(argc, argv, tp, jp)) return 1;
+ mrg::jtest::JournalPerformanceTest jpt(tp, jp);
+ jpt.run();
+ std::cout << jpt << std::endl;
+ return 0;
+}
Copied: store/trunk/cpp/perf/JournalPerformanceTest.hpp (from rev 4428, store/trunk/cpp/perf/StorePerformanceTest.hpp)
===================================================================
--- store/trunk/cpp/perf/JournalPerformanceTest.hpp (rev 0)
+++ store/trunk/cpp/perf/JournalPerformanceTest.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,147 @@
+/**
+ * \file JournalPerformanceTest.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_jtest_JournalPerformanceTest_hpp
+#define mrg_jtest_JournalPerformanceTest_hpp
+
+#include <vector>
+
+#include "JournalInstance.hpp"
+#include "PerformanceResult.hpp"
+#include "Streamable.hpp"
+#include "TestParameters.hpp"
+
+#ifdef JOURNAL2
+#include "jrnl2/JournalParameters.hpp"
+#else
+#include "JournalParameters.hpp"
+#endif
+
+
+
+namespace mrg
+{
+namespace jtest
+{
+
+ /**
+ * \brief Main test class; Create an instance and execute run()
+ *
+ * Main test class which aggregates the components of a test.
+ */
+ class JournalPerformanceTest : public Streamable
+ {
+ const TestParameters& _testParams; ///< Ref to a struct containing test params
+#ifdef JOURNAL2
+ const mrg::journal2::JournalParameters& _jrnlParams; ///< Ref to a struct containing the journal parameters
+#else
+ const JournalParameters& _jrnlParams; ///< Ref to a struct containing the journal parameters
+#endif
+ PerformanceResult _jrnlPerf; ///< Journal performance object
+ const char* msgData; ///< Pointer to msg data, which is the same for all messages
+ std::vector<JournalInstance*> _jrnlList; ///< List of journals (JournalInstance instances) being tested
+
+ /**
+ * \brief Creates journals and JournalInstance classes for all journals (queues) to be tested
+ *
+ * Creates a new journal instance and JournalInstance instance for each queue. The journals are initialized
+ * which creates a new set of journal files on the local storage media (which is determined by path in
+ * JournalParameters._jrnlDir). This activity is not timed, and is not a part of the performance test per se.
+ */
+ void _prepareJournals();
+
+ public:
+ /**
+ * \brief Constructor
+ *
+ * \param tp Test parameters for the test
+ * \param jp Journal parameters for all queues (journals) in the test
+ */
+#ifdef JOURNAL2
+ JournalPerformanceTest(const TestParameters& tp, const mrg::journal2::JournalParameters& jp);
+#else
+ JournalPerformanceTest(const TestParameters& tp, const JournalParameters& jp);
+#endif
+
+ /**
+ * \brief Virtual destructor
+ */
+ virtual ~JournalPerformanceTest();
+
+ /**
+ * \brief Runs the test and prints out the results.
+ *
+ * Runs the test as set by the test parameters and journal parameters.
+ */
+ void run();
+
+ /**
+ * \brief Stream the test setup and results to an output stream
+ *
+ * Convenience feature which streams the test setup and results to an output stream.
+ *
+ * \param os Output stream to which the test setup and results are to be streamed.
+ */
+ void toStream(std::ostream& os = std::cout) const;
+ };
+
+ /**
+ * \brief Print out the program arguments
+ *
+ * Print out the arguments to the performance program if requested by help or a parameter error.
+ *
+ * \param os Stream to which the arguments should be streamed.
+ */
+ void printArgs(std::ostream& os = std::cout);
+
+ /**
+ * \brief Process the command-line arguments
+ *
+ * Process the command-line arguments and populate the TestParameters and JournalParameters structs. Only the
+ * arguments supplied are on the command-line are changed in these structs, the others remain unchanged. It is
+ * important therefore to make sure that defaults are pre-loaded (the default behavior of the default constructors
+ * for these structs).
+ *
+ * \param argc Number of command-line arguments. Process directly from main().
+ * \param argv Pointer to array of command-line argument pointers. Process directly from main().
+ * \param tp Reference to test parameter object. Only params on the command-line are changed.
+ * \param jp Reference to journal parameter object. Only params on the command-line are changed.
+ */
+#ifdef JOURNAL2
+ bool readArgs(int argc, char** argv, TestParameters& tp, mrg::journal2::JournalParameters& jp);
+#else
+ bool readArgs(int argc, char** argv, TestParameters& tp, JournalParameters& jp);
+#endif
+
+} // namespace jtest
+} // namespace mrg
+
+#endif // mrg_jtest_JournalPerformanceTest_hpp
Modified: store/trunk/cpp/perf/Makefile.am
===================================================================
--- store/trunk/cpp/perf/Makefile.am 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/Makefile.am 2010-12-08 16:26:09 UTC (rev 4430)
@@ -30,13 +30,18 @@
perf_SOURCES = \
JournalInstance.cpp \
JournalParameters.cpp \
- ScopedPerformanceTimer.cpp \
- StorePerformanceTest.cpp \
+ JournalPerformanceTest.cpp \
+ PerformanceResult.cpp \
+ ScopedTimer.cpp \
+ Streamable.cpp \
TestParameters.cpp \
JournalInstance.hpp \
JournalParameters.hpp \
- ScopedPerformanceTimer.hpp \
- StorePerformanceTest.hpp \
+ JournalPerformanceTest.hpp \
+ PerformanceResult.hpp \
+ ScopedTimable.hpp \
+ ScopedTimer.hpp \
+ Streamable.hpp \
TestParameters.hpp
perf_CXXFLAGS = -std=c++0x -lpthread
perf_LDADD = -lrt $(top_builddir)/lib/msgstore.la
Copied: store/trunk/cpp/perf/PerformanceResult.cpp (from rev 4428, store/trunk/cpp/perf/ScopedPerformanceTimer.cpp)
===================================================================
--- store/trunk/cpp/perf/PerformanceResult.cpp (rev 0)
+++ store/trunk/cpp/perf/PerformanceResult.cpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,64 @@
+/**
+ * \file PerformanceResult.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "PerformanceResult.hpp"
+
+#include <cstdint> // uint32_t
+
+namespace mrg
+{
+namespace jtest
+{
+
+ PerformanceResult::PerformanceResult(const TestParameters& tp) :
+ ScopedTimable(),
+ Streamable(),
+ _testParams(tp)
+ {}
+
+ void
+ PerformanceResult::toStream(std::ostream& os) const
+ {
+ os << "TEST RESULTS:" << std::endl;
+ os << " Msgs per thread: " << _testParams._numMsgs << std::endl;
+ os << " Msg size: " << _testParams._msgSize << std::endl;
+ os << " No. queues: " << _testParams._numQueues << std::endl;
+ os << " No. threads/queue: " << _testParams._numThreadPairsPerQueue << std::endl;
+ os << " Time taken: " << _elapsed << " sec" << std::endl;
+ uint32_t totalMsgs = _testParams._numMsgs * _testParams._numQueues * _testParams._numThreadPairsPerQueue;
+ os << " Total no. msgs: " << totalMsgs << std::endl;
+ double msgsRate = double(totalMsgs) / _elapsed;
+ os << " Msg throughput: " << (msgsRate / 1e3) << " kMsgs/sec" << std::endl;
+ os << " " << (msgsRate * _testParams._msgSize / 1e6) << " MB/sec" << std::endl;
+ }
+
+} // namespace jtest
+} // namespace mrg
Copied: store/trunk/cpp/perf/PerformanceResult.hpp (from rev 4428, store/trunk/cpp/perf/ScopedPerformanceTimer.hpp)
===================================================================
--- store/trunk/cpp/perf/PerformanceResult.hpp (rev 0)
+++ store/trunk/cpp/perf/PerformanceResult.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,101 @@
+/**
+ * \file PerformanceResult.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_jtest_PerformanceResult_hpp
+#define mrg_jtest_PerformanceResult_hpp
+
+#include <iostream>
+
+#include "TestParameters.hpp"
+#include "ScopedTimable.hpp"
+#include "Streamable.hpp"
+
+namespace mrg
+{
+namespace jtest
+{
+
+ /**
+ * \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 TestParameters 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 PerformanceResult : public ScopedTimable, public Streamable
+ {
+ TestParameters _testParams; ///< Test parameters used for performance calculations
+
+ public:
+ /**
+ * \brief Constructor
+ *
+ * Constructor. Will start the time interval measurement.
+ *
+ * \param tp Test parameter details used to calculate the performance results.
+ */
+ PerformanceResult(const TestParameters& tp);
+
+ /**
+ * \brief Virtual destructor
+ */
+ virtual ~PerformanceResult() {}
+
+ /**
+ * \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;
+ };
+
+} // namespace jtest
+} // namespace mrg
+
+#endif // mrg_jtest_PerformanceResult_hpp
Deleted: store/trunk/cpp/perf/ScopedPerformanceTimer.cpp
===================================================================
--- store/trunk/cpp/perf/ScopedPerformanceTimer.cpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/ScopedPerformanceTimer.cpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -1,72 +0,0 @@
-/**
- * \file ScopedPerformanceTimer.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains performance test code for the journal.
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "ScopedPerformanceTimer.hpp"
-
-namespace mrg
-{
-namespace jtest
-{
- ScopedPerformanceTimer::ScopedPerformanceTimer(const TestParameters& tp,
- std::ostream& os) :
- _testParams(tp),
- _outStream(os)
- {
- ::clock_gettime(CLOCK_REALTIME, &_startTime);
- }
-
- ScopedPerformanceTimer::~ScopedPerformanceTimer()
- {
- ::timespec stopTime;
- ::clock_gettime(CLOCK_REALTIME, &stopTime);
- double timeTaken = _s_getDoubleTime(stopTime) - _s_getDoubleTime(_startTime);
- _outStream << "TEST RESULTS:" << std::endl;
- _outStream << " Msgs per thread: " << _testParams._numMsgs << std::endl;
- _outStream << " Msg size: " << _testParams._msgSize << std::endl;
- _outStream << " No. queues: " << _testParams._numQueues << std::endl;
- _outStream << " No. threads/queue: " << _testParams._numThreadPairsPerQueue << std::endl;
- _outStream << " Time taken: " << timeTaken << " sec" << std::endl;
- uint32_t msgs = _testParams._numMsgs * _testParams._numQueues * _testParams._numThreadPairsPerQueue;
- _outStream << " Total no. msgs: " << msgs << std::endl;
- double msgsRate = double(msgs) / timeTaken;
- _outStream << " Msg throughput: " << (msgsRate / 1e3) << " kMsgs/sec" << std::endl;
- _outStream << " " << (msgsRate * _testParams._msgSize / 1e6) << " MB/sec" << std::endl;
- }
-
- // static
- double ScopedPerformanceTimer::_s_getDoubleTime(const ::timespec& ts)
- {
- return ts.tv_sec + (double(ts.tv_nsec) / 1e9);
- }
-
-
-} // namespace jtest
-} // namespace mrg
Deleted: store/trunk/cpp/perf/ScopedPerformanceTimer.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedPerformanceTimer.hpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/ScopedPerformanceTimer.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -1,106 +0,0 @@
-/**
- * \file ScopedPerformanceTimer.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains performance test code for the journal.
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_jtest_ScopedPerformanceTimer_hpp
-#define mrg_jtest_ScopedPerformanceTimer_hpp
-
-#include <cstdint>
-#include <ctime>
-#include <iostream>
-
-#include "TestParameters.hpp"
-
-namespace mrg
-{
-namespace jtest
-{
-
- /**
- * \brief Scoped timer class that starts timing on construction and finishes on destruction.
- *
- * This simple scoped timer class will record the start time on construction. On destruction (going out of scope),
- * it will record the stop time, and will then print out the elapsed time and some simple performance numbers.
- * The performance calculations are made from the data in the supplied TestParameters struct.
- *
- * 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 ScopedPerformanceTimer
- {
- protected:
- TestParameters _testParams; ///< Test parameters used for performance calculations
- std::ostream& _outStream; ///< Output stream for the performance data sent at destruction
- ::timespec _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 ::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);
- public:
- /**
- * \brief Constructor
- *
- * Constructor. Will start the time interval measurement.
- *
- * \param tp Test parameter details used to calculate the performance results.
- * \param os Output stream to which the results will be sent on destruction.
- */
- ScopedPerformanceTimer(const TestParameters& tp,
- std::ostream& os = std::cout);
-
- /**
- * \brief Destructor
- *
- * Destructor. Will stop the time interval measurement and send the performance results to the out stream
- * object _outStream.
- */
- ~ScopedPerformanceTimer();
- };
-
-} // namespace jtest
-} // namespace mrg
-
-#endif // mrg_jtest_ScopedPerformanceTimer_hpp
Added: store/trunk/cpp/perf/ScopedTimable.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimable.hpp (rev 0)
+++ store/trunk/cpp/perf/ScopedTimable.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,81 @@
+/**
+ * \file ScopedTimable.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_jtest_ScopedTimable_hpp
+#define mrg_jtest_ScopedTimable_hpp
+
+namespace mrg
+{
+namespace jtest
+{
+
+ /**
+ * \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
+ {
+ protected:
+ double _elapsed; ///< Elapsed time, will be written on destruction of ScopedTimer instances
+
+ public:
+ /**
+ * \brief Constructor
+ */
+ inline ScopedTimable() : _elapsed(0.0) {}
+
+ /**
+ * \brief Destructor
+ */
+ virtual inline ~ScopedTimable() {}
+
+ /**
+ * \brief Gets a ref to the elapsed time _elapsed.
+ *
+ * Returns a ref to the elapsed time _elapsed, for use in the constructor of ScopedTimer objects.
+ *
+ * \returns Ref to elapsed time _elapsed
+ */
+ // TODO: Investigate making this class a friend of ScopedTimer instead, exposing this as a public fn is ugly.
+ virtual inline double& getElapsedRef() { return _elapsed; }
+ };
+
+} // namespace jtest
+} // namespace mrg
+
+#endif // mrg_jtest_ScopedTimer_hpp
Added: store/trunk/cpp/perf/ScopedTimer.cpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimer.cpp (rev 0)
+++ store/trunk/cpp/perf/ScopedTimer.cpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,64 @@
+/**
+ * \file ScopedTimer.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "ScopedTimer.hpp"
+
+namespace mrg
+{
+namespace jtest
+{
+
+ ScopedTimer::ScopedTimer(double& elapsed) : _elapsed(elapsed)
+ {
+ ::clock_gettime(CLOCK_REALTIME, &_startTime);
+ }
+
+ ScopedTimer::ScopedTimer(ScopedTimable& st) : _elapsed(st.getElapsedRef())
+ {
+ ::clock_gettime(CLOCK_REALTIME, &_startTime);
+ }
+
+ ScopedTimer::~ScopedTimer()
+ {
+ ::timespec stopTime;
+ ::clock_gettime(CLOCK_REALTIME, &stopTime);
+ _elapsed = _s_getDoubleTime(stopTime) - _s_getDoubleTime(_startTime);
+ }
+
+ // static
+ double ScopedTimer::_s_getDoubleTime(const ::timespec& ts)
+ {
+ return ts.tv_sec + (double(ts.tv_nsec) / 1e9);
+ }
+
+
+} // namespace jtest
+} // namespace mrg
Added: store/trunk/cpp/perf/ScopedTimer.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimer.hpp (rev 0)
+++ store/trunk/cpp/perf/ScopedTimer.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,99 @@
+/**
+ * \file ScopedTimer.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_jtest_ScopedTimer_hpp
+#define mrg_jtest_ScopedTimer_hpp
+
+#include <ctime>
+#include "ScopedTimable.hpp"
+
+namespace mrg
+{
+namespace jtest
+{
+
+ /**
+ * \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
+ {
+ double& _elapsed; ///< Ref to elapsed time, will be written on destruction of ScopedTimer instances
+ ::timespec _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 ::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);
+
+ 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.
+ */
+ // TODO: Investigate making class ScopedTimer a friend of this class.
+ ScopedTimer(ScopedTimable& st);
+
+ /**
+ * \brief Destructor
+ *
+ * Destructor. Will stop the time interval measurement and write the calculated elapsed time into _elapsed.
+ */
+ ~ScopedTimer();
+ };
+
+} // namespace jtest
+} // namespace mrg
+
+#endif // mrg_jtest_ScopedTimer_hpp
Deleted: store/trunk/cpp/perf/StorePerformanceTest.cpp
===================================================================
--- store/trunk/cpp/perf/StorePerformanceTest.cpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/StorePerformanceTest.cpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -1,316 +0,0 @@
-/**
- * \file StorePerformanceTest.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains performance test code for the journal.
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "StorePerformanceTest.hpp"
-
-#include <cstdint> // uint16_t, uint32_t
-#include <cstdlib> // atof, atoi, atol
-#include <deque>
-#include <iomanip>
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <thread>
-
-#include <getopt.h>
-#include <unistd.h>
-
-#include "ScopedPerformanceTimer.hpp"
-
-#ifdef JOURNAL2
-#include "jrnl2/jdir.hpp"
-#else
-#include "jrnl/jdir.hpp"
-#endif
-
-namespace mrg
-{
-namespace jtest
-{
-
-#ifdef JOURNAL2
-StorePerformanceTest::StorePerformanceTest(const TestParameters& tp, const mrg::journal2::JournalParameters& jp) :
-#else
-StorePerformanceTest::StorePerformanceTest(const TestParameters& tp, const JournalParameters& jp) :
-#endif
- _testParams(tp),
- _jrnlParams(jp),
- msgData(new char[tp._msgSize])
-{}
-
-StorePerformanceTest::~StorePerformanceTest()
-{
- while (_jrnlList.size())
- {
- delete _jrnlList.back();
- _jrnlList.pop_back();
- }
- delete[] msgData;
-}
-
-void
-StorePerformanceTest::_prepareJournals()
-{
-#ifdef JOURNAL2
- if (mrg::journal2::jdir::exists(_jrnlParams._jrnlDir)) {
- mrg::journal2::jdir::delete_dir(_jrnlParams._jrnlDir);
- }
- mrg::journal2::jdir::create_dir(_jrnlParams._jrnlDir);
- mrg::journal2::jrnl* jp;
-#else
- if (mrg::journal::jdir::exists(_jrnlParams._jrnlDir)) {
- mrg::journal::jdir::delete_dir(_jrnlParams._jrnlDir);
- }
- mrg::journal::jdir::create_dir(_jrnlParams._jrnlDir);
- mrg::journal::jcntl* jp;
-#endif
- JournalInstance* ptp;
- for (uint16_t j = 0; j < _testParams._numQueues; j++)
- {
- std::ostringstream jname;
- jname << "jrnl_" << std::setw(4) << std::setfill('0') << j;
- std::ostringstream jdir;
- jdir << _jrnlParams._jrnlDir << "/" << jname.str();
-#ifdef JOURNAL2
- jp = new mrg::journal2::jrnl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
-#else
- jp = new mrg::journal::jcntl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
-#endif
- ptp = new JournalInstance(_testParams._numMsgs, _testParams._msgSize, msgData, jp);
-#ifdef JOURNAL2
- jp->initialize(&_jrnlParams, ptp);
-#else
- jp->initialize(_jrnlParams._numJrnlFiles, _jrnlParams._autoExpand, _jrnlParams._autoExpandMaxJrnlFiles,
- _jrnlParams._jrnlFileSize_sblks, _jrnlParams._writeBuffNumPgs,
- _jrnlParams._writeBuffPgSize_sblks, ptp);
-#endif
-
- _jrnlList.push_back(ptp);
- }
-}
-
-void
-StorePerformanceTest::run()
-{
- std::deque<std::thread*> threads;
- std::thread* tp;
- _prepareJournals();
- {
- // --- Start of timed section ---
- ScopedPerformanceTimer pt(_testParams);
-
- for (uint16_t q=0; q<_testParams._numQueues; q++)
- {
- // Launch threads in pairs
- for (uint16_t t=0; t<_testParams._numThreadPairsPerQueue * 2; t++)
- {
- tp = new std::thread(std::ref(*_jrnlList[q]));
- threads.push_back(tp);
- }
- }
-
- while (threads.size())
- {
- threads.front()->join();
- delete threads.front();
- threads.pop_front();
- }
- std::cout << std::endl;
- // --- End of timed section ---
- }
-}
-
-void
-printArgs(std::ostream& os)
-{
- os << " -h --help: This help message" << std::endl;
- os << std::endl;
- os << "Test params:" << std::endl;
- os << " -M --num_msgs: Number of messages to send ["
- << 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 << " -T --num_thread_pairs_per_queue: Number of thread pairs per queue ["
- << TestParameters::_s_defaultNumThreadPairsPerQueue << "]" << std::endl;
- os << " -E --enq_txn_blk_size: Enqueue transaction block size (0=non-txn) ["
- << TestParameters::_s_defaultEnqTxnBlkSize << "]" << std::endl;
- os << " -D --deq_txn_blk_size: Dequeue transaction block size (0=non-txn) ["
- << TestParameters::_s_defaultDeqTxnBlkSize << "]" << std::endl;
- os << std::endl;
- os << "Store params:" << std::endl;
-#ifdef JOURNAL2
- os << " -d --jrnl_dir: Store directory [\""
- << mrg::journal2::JournalParameters::_s_defaultJrnlDir << "\"]" << std::endl;
- os << " -b --jrnl_base_filename: Base name for journal files [\""
- << mrg::journal2::JournalParameters::_s_defaultJrnlBaseFileName << "\"]" << std::endl;
- os << " -f --num_jfiles: Number of journal files ["
- << mrg::journal2::JournalParameters::_s_defaultNumJrnlFiles << "]" << std::endl;
- os << " -s --jfsize_sblks: Size of each journal file in sblks (512 byte blocks) ["
- << mrg::journal2::JournalParameters::_s_defaultJrnlFileSize_sblks << "]" << std::endl;
- os << " -a --auto_expand: Auto-expand the journal ["
- << (mrg::journal2::JournalParameters::_s_defaultAutoExpand?"T":"F") << "]" << std::endl;
- os << " -e --ae_max_jfiles: Upper limit on number of auto-expanded journal files ["
- << mrg::journal2::JournalParameters::_s_defaultAutoExpandMaxJrnlFiles << "]" << std::endl;
- os << " -p --wcache_num_pages: Number of write buffer pages ["
- << mrg::journal2::JournalParameters::_s_defaultWriteBuffNumPgs << "]" << std::endl;
- os << " -c --wcache_pgsize_sblks: Size of each write buffer page in sblks (512 byte blocks) ["
- << mrg::journal2::JournalParameters::_s_defaultWriteBuffPgSize_sblks << "]" << std::endl;
-#else
- os << " -d --jrnl_dir: Store directory [\""
- << JournalParameters::_s_defaultJrnlDir << "\"]" << std::endl;
- os << " -b --jrnl_base_filename: Base name for journal files [\""
- << JournalParameters::_s_defaultJrnlBaseFileName << "\"]" << std::endl;
- os << " -f --num_jfiles: Number of journal files ["
- << JournalParameters::_s_defaultNumJrnlFiles << "]" << std::endl;
- os << " -s --jfsize_sblks: Size of each journal file in sblks (512 byte blocks) ["
- << JournalParameters::_s_defaultJrnlFileSize_sblks << "]" << std::endl;
- os << " -a --auto_expand: Auto-expand the journal ["
- << (JournalParameters::_s_defaultAutoExpand?"T":"F") << "]" << std::endl;
- os << " -e --ae_max_jfiles: Upper limit on number of auto-expanded journal files ["
- << JournalParameters::_s_defaultAutoExpandMaxJrnlFiles << "]" << std::endl;
- os << " -p --wcache_num_pages: Number of write buffer pages ["
- << JournalParameters::_s_defaultWriteBuffNumPgs << "]" << std::endl;
- os << " -c --wcache_pgsize_sblks: Size of each write buffer page in sblks (512 byte blocks) ["
- << JournalParameters::_s_defaultWriteBuffPgSize_sblks << "]" << std::endl;
-#endif
-}
-
-bool
-#ifdef JOURNAL2
-readArgs(int argc, char** argv, TestParameters& tp, mrg::journal2::JournalParameters& sp)
-#else
-readArgs(int argc, char** argv, TestParameters& tp, JournalParameters& sp)
-#endif
-{
- static struct option long_options[] = {
- {"help", no_argument, 0, 'h'},
-
- // Test params
- {"num_msgs", required_argument, 0, 'm'},
- {"msg_size", required_argument, 0, 'S'},
- {"num_queues", required_argument, 0, 'q'},
- {"num_threads_per_queue", required_argument, 0, 't'},
-
- // Journal params
- {"jrnl_dir", required_argument, 0, 'd'},
- {"jrnl_base_filename", required_argument, 0, 'b'},
- {"num_jfiles", required_argument, 0, 'f'},
- {"jfsize_sblks", required_argument, 0, 's'},
- {"auto_expand", no_argument, 0, 'a'},
- {"ae_max_jfiles", required_argument, 0, 'e'},
- {"wcache_num_pages", required_argument, 0, 'p'},
- {"wcache_pgsize_sblks", required_argument, 0, 'c'},
-
- {0, 0, 0, 0}
- };
- bool err = false;
- int c = 0;
- while (true)
- {
- int option_index = 0;
- c = getopt_long(argc, argv, "ab:c:d:e:f:hm:p:q:s:S:t:", long_options, &option_index);
- if (c == -1) break;
- switch (c)
- {
- // Test params
- case 'm':
- tp._numMsgs = uint32_t(std::atol(optarg));
- break;
- case 'S':
- tp._msgSize = uint32_t(std::atol(optarg));
- break;
- case 'q':
- tp._numQueues = uint16_t(std::atoi(optarg));
- break;
- case 't':
- tp._numThreadPairsPerQueue = uint16_t(std::atoi(optarg));
- break;
-
- // Store params
- case 'd':
- sp._jrnlDir.assign(optarg);
- break;
- case 'b':
- sp._jrnlBaseFileName.assign(optarg);
- break;
- case 'f':
- sp._numJrnlFiles = uint16_t(std::atoi(optarg));
- break;
- case 's':
- sp._jrnlFileSize_sblks = uint32_t(std::atol(optarg));
- break;
- case 'a':
- sp._autoExpand = true;
- break;
- case 'e':
- sp._autoExpandMaxJrnlFiles = uint16_t(std::atoi(optarg));
- break;
- case 'p':
- sp._writeBuffNumPgs = uint16_t(std::atoi(optarg));
- break;
- case 'c':
- sp._writeBuffPgSize_sblks = uint32_t(std::atol(optarg));
- break;
-
- // Other
- case 'h':
- default:
- err = true;
- printArgs();
- }
- }
- return err;
-}
-
-} // namespace jtest
-} // namespace mrg
-
-// -----------------------------------------------------------------
-
-int
-main(int argc, char** argv)
-{
- mrg::jtest::TestParameters tp;
-#ifdef JOURNAL2
- mrg::journal2::JournalParameters jp;
-#else
- mrg::jtest::JournalParameters jp;
-#endif
- if (mrg::jtest::readArgs(argc, argv, tp, jp)) return 1;
- std::cout << tp.toString() << std::endl;
- std::cout << jp.toString() << std::endl;
- mrg::jtest::StorePerformanceTest p(tp, jp);
- p.run();
-
- return 0;
-}
Deleted: store/trunk/cpp/perf/StorePerformanceTest.hpp
===================================================================
--- store/trunk/cpp/perf/StorePerformanceTest.hpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/StorePerformanceTest.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -1,140 +0,0 @@
-/**
- * \file StorePerformanceTest.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains performance test code for the journal.
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * 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
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_jtest_StorePerformanceTest_hpp
-#define mrg_jtest_StorePerformanceTest_hpp
-
-#include <iostream>
-#include <vector>
-
-#include "JournalInstance.hpp"
-#include "TestParameters.hpp"
-
-#ifdef JOURNAL2
-#include "jrnl2/JournalParameters.hpp"
-#else
-#include "JournalParameters.hpp"
-#endif
-
-
-
-namespace mrg
-{
-namespace jtest
-{
-
- /**
- * \brief Main test class; Create an instance and execute run()
- *
- * Main test class which aggregates the components of a test.
- */
- class StorePerformanceTest
- {
- const TestParameters& _testParams; ///< Ref to a struct containing test params
-#ifdef JOURNAL2
- const mrg::journal2::JournalParameters& _jrnlParams; ///< Ref to a struct containing the journal parameters
-#else
- const JournalParameters& _jrnlParams; ///< Ref to a struct containing the journal parameters
-#endif
- const char* msgData; ///< Pointer to msg data, which is the same for all messages
- std::vector<JournalInstance*> _jrnlList; ///< List of journals (JournalInstance instances) being tested
-
- /**
- * \brief Creates journals and JournalInstance classes for all journals (queues) to be tested
- *
- * Creates a new journal instance and JournalInstance instance for each queue. The journals are initialized
- * which creates a new set of journal files on the local storage media (which is determined by path in
- * JournalParameters._jrnlDir). This activity is not timed, and is not a part of the performance test per se.
- */
- void _prepareJournals();
-
- public:
- /**
- * \brief Constructor
- *
- * Constructor.
- *
- * \param tp Test parameters for the test
- * \param jp Journal parameters for all queues (journals) in the test
- */
-#ifdef JOURNAL2
- StorePerformanceTest(const TestParameters& tp, const mrg::journal2::JournalParameters& jp);
-#else
- StorePerformanceTest(const TestParameters& tp, const JournalParameters& jp);
-#endif
-
- /**
- * \brief Destructor
- *
- * Destructor.
- */
- ~StorePerformanceTest();
-
- /**
- * \brief Runs the test and prints out the results.
- *
- * Runs the test as set by the test parameters and journal parameters.
- */
- void run();
- };
-
- /**
- * \brief Print out the program arguments
- *
- * Print out the arguments to the performance program if requested by help or a parameter error.
- *
- * \param os Stream to which the arguments should be streamed.
- */
- void printArgs(std::ostream& os = std::cout);
-
- /**
- * \brief Process the command-line arguments
- *
- * Process the command-line arguments and populate the TestParameters and JournalParameters structs. Only the
- * arguments supplied are on the command-line are changed in these structs, the others remain unchanged. It is
- * important therefore to make sure that defaults are pre-loaded (the default behavior of the default constructors
- * for these structs).
- *
- * \param argc Number of command-line arguments. Process directly from main().
- * \param argv Pointer to array of command-line argument pointers. Process directly from main().
- * \param tp Reference to test parameter object. Only params on the command-line are changed.
- * \param jp Reference to journal parameter object. Only params on the command-line are changed.
- */
-#ifdef JOURNAL2
- bool readArgs(int argc, char** argv, TestParameters& tp, mrg::journal2::JournalParameters& jp);
-#else
- bool readArgs(int argc, char** argv, TestParameters& tp, JournalParameters& jp);
-#endif
-
-} // namespace jtest
-} // namespace mrg
-
-#endif // mrg_jtest_StorePerformanceTest_hpp
Added: store/trunk/cpp/perf/Streamable.cpp
===================================================================
--- store/trunk/cpp/perf/Streamable.cpp (rev 0)
+++ store/trunk/cpp/perf/Streamable.cpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,64 @@
+/**
+ * \file Streamable.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "Streamable.hpp"
+
+#include <sstream>
+
+namespace mrg
+{
+namespace jtest
+{
+
+ 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 jtest
+} // namespace mrg
Added: store/trunk/cpp/perf/Streamable.hpp
===================================================================
--- store/trunk/cpp/perf/Streamable.hpp (rev 0)
+++ store/trunk/cpp/perf/Streamable.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,86 @@
+/**
+ * \file Streamable.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * 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
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_jtest_Streamable_hpp
+#define mrg_jtest_Streamable_hpp
+
+#include <iostream>
+#include <string>
+
+namespace mrg
+{
+namespace jtest
+{
+
+ /**
+ * \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.
+ */
+ struct Streamable
+ {
+ /**
+ * \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 jtest
+} // namespace mrg
+
+#endif // mrg_jtest_Streamable_hpp
Modified: store/trunk/cpp/perf/TestParameters.cpp
===================================================================
--- store/trunk/cpp/perf/TestParameters.cpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/TestParameters.cpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -31,72 +31,65 @@
#include "TestParameters.hpp"
-#include <sstream>
-
namespace mrg
{
namespace jtest
{
-// static declarations
-uint32_t TestParameters::_s_defaultNumMsgs = 100;
-uint32_t TestParameters::_s_defaultMsgSize = 10;
-uint16_t TestParameters::_s_defaultNumQueues = 1;
-uint16_t TestParameters::_s_defaultNumThreadPairsPerQueue = 1;
-uint16_t TestParameters::_s_defaultEnqTxnBlkSize = 0;
-uint16_t TestParameters::_s_defaultDeqTxnBlkSize = 0;
+ // static declarations
+ uint32_t TestParameters::_s_defaultNumMsgs = 100;
+ uint32_t TestParameters::_s_defaultMsgSize = 10;
+ uint16_t TestParameters::_s_defaultNumQueues = 1;
+ uint16_t TestParameters::_s_defaultNumThreadPairsPerQueue = 1;
+ uint16_t TestParameters::_s_defaultEnqTxnBlkSize = 0;
+ uint16_t TestParameters::_s_defaultDeqTxnBlkSize = 0;
-TestParameters::TestParameters():
- _numMsgs(_s_defaultNumMsgs),
- _msgSize(_s_defaultMsgSize),
- _numQueues(_s_defaultNumQueues),
- _numThreadPairsPerQueue(_s_defaultNumThreadPairsPerQueue),
- _enqTxnBlockSize(_s_defaultEnqTxnBlkSize),
- _deqTxnBlockSize(_s_defaultDeqTxnBlkSize)
-{}
+ TestParameters::TestParameters():
+ Streamable(),
+ _numMsgs(_s_defaultNumMsgs),
+ _msgSize(_s_defaultMsgSize),
+ _numQueues(_s_defaultNumQueues),
+ _numThreadPairsPerQueue(_s_defaultNumThreadPairsPerQueue),
+ _enqTxnBlockSize(_s_defaultEnqTxnBlkSize),
+ _deqTxnBlockSize(_s_defaultDeqTxnBlkSize)
+ {}
-TestParameters::TestParameters(const uint32_t numMsgs,
- const uint32_t msgSize,
- const uint16_t numQueues,
- const uint16_t numThreadPairsPerQueue,
- const uint16_t enqTxnBlockSize,
- const uint16_t deqTxnBlockSize) :
- _numMsgs(numMsgs),
- _msgSize(msgSize),
- _numQueues(numQueues),
- _numThreadPairsPerQueue(numThreadPairsPerQueue),
- _enqTxnBlockSize(enqTxnBlockSize),
- _deqTxnBlockSize(deqTxnBlockSize)
-{}
+ TestParameters::TestParameters(const uint32_t numMsgs,
+ const uint32_t msgSize,
+ const uint16_t numQueues,
+ const uint16_t numThreadPairsPerQueue,
+ const uint16_t enqTxnBlockSize,
+ const uint16_t deqTxnBlockSize) :
+ Streamable(),
+ _numMsgs(numMsgs),
+ _msgSize(msgSize),
+ _numQueues(numQueues),
+ _numThreadPairsPerQueue(numThreadPairsPerQueue),
+ _enqTxnBlockSize(enqTxnBlockSize),
+ _deqTxnBlockSize(deqTxnBlockSize)
+ {}
-TestParameters::TestParameters(const TestParameters& tp):
- _numMsgs(tp._numMsgs),
- _msgSize(tp._msgSize),
- _numQueues(tp._numQueues),
- _numThreadPairsPerQueue(tp._numThreadPairsPerQueue),
- _enqTxnBlockSize(tp._enqTxnBlockSize),
- _deqTxnBlockSize(tp._deqTxnBlockSize)
-{}
+ TestParameters::TestParameters(const TestParameters& tp):
+ Streamable(),
+ _numMsgs(tp._numMsgs),
+ _msgSize(tp._msgSize),
+ _numQueues(tp._numQueues),
+ _numThreadPairsPerQueue(tp._numThreadPairsPerQueue),
+ _enqTxnBlockSize(tp._enqTxnBlockSize),
+ _deqTxnBlockSize(tp._deqTxnBlockSize)
+ {}
-void
-TestParameters::toStream(std::ostream& os)
-{
- os << "Test Parameters:" << std::endl;
- os << " num_msgs = " << _numMsgs << std::endl;
- os << " msg_size = " << _msgSize << std::endl;
- os << " num_queues = " << _numQueues << std::endl;
- os << " num_thread_pairs_per_queue = " << _numThreadPairsPerQueue << std::endl;
- os << " enq_txn_blk_size = " << _enqTxnBlockSize << std::endl;
- os << " deq_txn_blk_size = " << _deqTxnBlockSize << std::endl;
-}
+ void
+ TestParameters::toStream(std::ostream& os) const
+ {
+ os << "Test Parameters:" << std::endl;
+ os << " num_msgs = " << _numMsgs << std::endl;
+ os << " msg_size = " << _msgSize << std::endl;
+ os << " num_queues = " << _numQueues << std::endl;
+ os << " num_thread_pairs_per_queue = " << _numThreadPairsPerQueue << std::endl;
+ os << " enq_txn_blk_size = " << _enqTxnBlockSize << std::endl;
+ os << " deq_txn_blk_size = " << _deqTxnBlockSize << std::endl;
+ }
-std::string
-TestParameters::toString()
-{
- std::ostringstream oss;
- toStream(oss);
- return oss.str();
-}
-
} // namespace jtest
} // namespace mrg
Modified: store/trunk/cpp/perf/TestParameters.hpp
===================================================================
--- store/trunk/cpp/perf/TestParameters.hpp 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/TestParameters.hpp 2010-12-08 16:26:09 UTC (rev 4430)
@@ -32,9 +32,8 @@
#ifndef mrg_jtest_TestParameters_hpp
#define mrg_jtest_TestParameters_hpp
-#include <cstdint>
-#include <iostream>
-#include <string>
+#include <cstdint> // uint16_t, uint32_t
+#include "Streamable.hpp"
namespace mrg
{
@@ -47,7 +46,7 @@
* This struct is used to aggregate and keep together all the test parameters. These affect the test itself, the
* journal geometry is aggregated in class JournalParameters.
*/
- struct TestParameters
+ struct TestParameters : public Streamable
{
static uint32_t _s_defaultNumMsgs; ///< Default number of messages to be sent
static uint32_t _s_defaultMsgSize; ///< Default message size in bytes
@@ -92,12 +91,15 @@
/**
* \brief Copy constructor
*
- * Copy constructor.
- *
* \param tp Reference to TestParameters instance to be copied
*/
TestParameters(const TestParameters& tp);
+ /**
+ * \brief Virtual destructor
+ */
+ virtual ~TestParameters() {}
+
/***
* \brief Stream the test parameters to an output stream
*
@@ -106,17 +108,7 @@
*
* \param os Output stream to which the class data is to be streamed
*/
- void toStream(std::ostream& os = std::cout);
-
- /**
- * \brief Creates a string representation of the test parameters
- *
- * Convenience feature which creates a multi-line string representation of all the test parameters, one
- * per line.
- *
- * \return multi-line string representation of all the parameters, one parameter per line.
- */
- std::string toString();
+ void toStream(std::ostream& os = std::cout) const;
};
} // namespace jtest
Modified: store/trunk/cpp/perf/m
===================================================================
--- store/trunk/cpp/perf/m 2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/m 2010-12-08 16:26:09 UTC (rev 4430)
@@ -5,7 +5,7 @@
# The variable JOURNAL2, if defined, will link with the new journal2 namespace journal. Otherwise the old journal
# namespace will be used.
-JOURNAL2=1
+#JOURNAL2=1
# Optimization options
#OPT="-O0 -ggdb"
@@ -16,26 +16,58 @@
-Wmissing-field-initializers -Wpacked -Wredundant-decls -Wunreachable-code -Wno-invalid-offsetof \
-Winvalid-pch -Wvolatile-register-var"
-PERF_FILES="StorePerformanceTest.cpp JournalInstance.cpp ScopedPerformanceTimer.cpp JournalParameters.cpp \
+PERF_FILES="JournalInstance.cpp \
+ JournalParameters.cpp \
+ JournalPerformanceTest.cpp \
+ PerformanceResult.cpp \
+ ScopedTimer.cpp \
+ Streamable.cpp \
TestParameters.cpp"
if [[ ${JOURNAL2}x == x ]] ; then
-JRNL_FILES="../lib/jrnl/aio.cpp ../lib/jrnl/enq_map.cpp ../lib/jrnl/jdir.cpp ../lib/jrnl/jrec.cpp ../lib/jrnl/rfc.cpp \
- ../lib/jrnl/smutex.cpp ../lib/jrnl/wmgr.cpp ../lib/jrnl/cvar.cpp ../lib/jrnl/enq_rec.cpp ../lib/jrnl/jerrno.cpp \
- ../lib/jrnl/lp_map.cpp ../lib/jrnl/rmgr.cpp ../lib/jrnl/time_ns.cpp ../lib/jrnl/wrfc.cpp ../lib/jrnl/data_tok.cpp \
- ../lib/jrnl/fcntl.cpp ../lib/jrnl/jexception.cpp ../lib/jrnl/lpmgr.cpp ../lib/jrnl/rrfc.cpp ../lib/jrnl/txn_map.cpp \
- ../lib/jrnl/deq_rec.cpp ../lib/jrnl/jcntl.cpp ../lib/jrnl/jinf.cpp ../lib/jrnl/pmgr.cpp ../lib/jrnl/slock.cpp \
- ../lib/jrnl/txn_rec.cpp"
+JRNL_FILES="../lib/jrnl/aio.cpp \
+ ../lib/jrnl/enq_map.cpp \
+ ../lib/jrnl/jdir.cpp \
+ ../lib/jrnl/jrec.cpp \
+ ../lib/jrnl/rfc.cpp \
+ ../lib/jrnl/smutex.cpp \
+ ../lib/jrnl/wmgr.cpp \
+ ../lib/jrnl/cvar.cpp \
+ ../lib/jrnl/enq_rec.cpp \
+ ../lib/jrnl/jerrno.cpp \
+ ../lib/jrnl/lp_map.cpp \
+ ../lib/jrnl/rmgr.cpp \
+ ../lib/jrnl/time_ns.cpp \
+ ../lib/jrnl/wrfc.cpp \
+ ../lib/jrnl/data_tok.cpp \
+ ../lib/jrnl/fcntl.cpp \
+ ../lib/jrnl/jexception.cpp \
+ ../lib/jrnl/lpmgr.cpp \
+ ../lib/jrnl/rrfc.cpp \
+ ../lib/jrnl/txn_map.cpp \
+ ../lib/jrnl/deq_rec.cpp \
+ ../lib/jrnl/jcntl.cpp \
+ ../lib/jrnl/jinf.cpp \
+ ../lib/jrnl/pmgr.cpp \
+ ../lib/jrnl/slock.cpp \
+ ../lib/jrnl/txn_rec.cpp"
WARN="${WARN_COMMON} ${WARN_OTHER}"
else
DEFINES=-DJOURNAL2
-JRNL_FILES="../lib/jrnl2/dtok.cpp ../lib/jrnl2/jdir.cpp ../lib/jrnl2/jexception.cpp ../lib/jrnl2/jrnl_state.cpp \
- ../lib/jrnl2/smutex.cpp ../lib/jrnl2/dtok_state.cpp ../lib/jrnl2/jerrno.cpp ../lib/jrnl2/jrnl.cpp \
- ../lib/jrnl2/slock.cpp ../lib/jrnl2/JournalParameters.cpp"
+JRNL_FILES="../lib/jrnl2/dtok.cpp \
+ ../lib/jrnl2/jdir.cpp \
+ ../lib/jrnl2/jexception.cpp \
+ ../lib/jrnl2/jrnl_state.cpp \
+ ../lib/jrnl2/smutex.cpp \
+ ../lib/jrnl2/dtok_state.cpp \
+ ../lib/jrnl2/jerrno.cpp \
+ ../lib/jrnl2/jrnl.cpp \
+ ../lib/jrnl2/slock.cpp \
+ ../lib/jrnl2/JournalParameters.cpp"
WARN="${WARN_COMMON} ${WARN_OTHER} -Wshadow -Wunsafe-loop-optimizations"
fi
14 years
rhmessaging commits: r4429 - store/trunk/cpp.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2010-12-07 13:01:04 -0500 (Tue, 07 Dec 2010)
New Revision: 4429
Modified:
store/trunk/cpp/Makefile.am
Log:
Removed the perf dir from the make process becuase of lack of c++0x support in RHEL-5
Modified: store/trunk/cpp/Makefile.am
===================================================================
--- store/trunk/cpp/Makefile.am 2010-12-07 17:01:24 UTC (rev 4428)
+++ store/trunk/cpp/Makefile.am 2010-12-07 18:01:04 UTC (rev 4429)
@@ -28,7 +28,7 @@
sysconf_DATA = etc/rhmd.conf
-SUBDIRS = lib tests tools perf docs
+SUBDIRS = lib tests tools docs
# Update libtool, if needed.
libtool: $(LIBTOOL_DEPS)
14 years
rhmessaging commits: r4428 - in store/trunk/cpp: perf and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2010-12-07 12:01:24 -0500 (Tue, 07 Dec 2010)
New Revision: 4428
Modified:
store/trunk/cpp/lib/jrnl2/JournalParameters.cpp
store/trunk/cpp/lib/jrnl2/JournalParameters.hpp
store/trunk/cpp/perf/JournalInstance.cpp
store/trunk/cpp/perf/JournalInstance.hpp
store/trunk/cpp/perf/JournalParameters.cpp
store/trunk/cpp/perf/JournalParameters.hpp
store/trunk/cpp/perf/ScopedPerformanceTimer.cpp
store/trunk/cpp/perf/ScopedPerformanceTimer.hpp
store/trunk/cpp/perf/StorePerformanceTest.cpp
store/trunk/cpp/perf/StorePerformanceTest.hpp
store/trunk/cpp/perf/TestParameters.cpp
store/trunk/cpp/perf/TestParameters.hpp
Log:
Code tidy-up for the perf tool
Modified: store/trunk/cpp/lib/jrnl2/JournalParameters.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalParameters.cpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/lib/jrnl2/JournalParameters.cpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -90,7 +90,7 @@
{}
std::string
-JournalParameters::to_string()
+JournalParameters::toString()
{
std::ostringstream oss;
oss << "Store Parameters:" << std::endl;
Modified: store/trunk/cpp/lib/jrnl2/JournalParameters.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalParameters.hpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/lib/jrnl2/JournalParameters.hpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -70,7 +70,7 @@
const u_int16_t writeBuffNumPgs,
const u_int32_t writeBuffPgSize_sblks);
JournalParameters(const JournalParameters& sp);
- std::string to_string();
+ std::string toString();
};
} // namespace journal2
Modified: store/trunk/cpp/perf/JournalInstance.cpp
===================================================================
--- store/trunk/cpp/perf/JournalInstance.cpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/perf/JournalInstance.cpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -35,27 +35,27 @@
namespace mrg
{
-namespace test
+namespace jtest
{
-JournalInstance::JournalInstance(const uint32_t num_msgs,
- const uint32_t msg_size,
- const char* msg_data,
+JournalInstance::JournalInstance(const uint32_t numMsgs,
+ const uint32_t msgSize,
+ const char* msgData,
#ifdef JOURNAL2
- mrg::journal2::jrnl* const jp) :
+ mrg::journal2::jrnl* const jrnlPtr) :
#else
- mrg::journal::jcntl* const jp) :
+ mrg::journal::jcntl* const jrnlPtr) :
#endif
- _num_msgs(num_msgs),
- _msg_size(msg_size),
- _msg_data(msg_data),
- _jp(jp),
- _thread_switch(false)
+ _numMsgs(numMsgs),
+ _msgSize(msgSize),
+ _msgData(msgData),
+ _jrnlPtr(jrnlPtr),
+ _threadSwitch(false)
{}
JournalInstance::~JournalInstance()
{
- delete _jp;
+ delete _jrnlPtr;
}
@@ -63,19 +63,19 @@
// This method will be called by multiple threads simultaneously
// Enqueue thread entry point
void
-JournalInstance::_enq()
+JournalInstance::_doEnqueues()
{
bool misfireFlag = false;
uint32_t i = 0;
- while (i < _num_msgs) {
+ while (i < _numMsgs) {
#ifdef JOURNAL2
- mrg::journal2::dtok* dtokp = new mrg::journal2::dtok();
- mrg::journal2::iores res = _jp->enqueue(_msg_data, _msg_size, dtokp);
+ mrg::journal2::dtok* dtokPtr = new mrg::journal2::dtok();
+ mrg::journal2::iores jrnlIoRes = _jrnlPtr->enqueue(_msgData, _msgSize, dtokPtr);
#else
- mrg::journal::data_tok* dtokp = new mrg::journal::data_tok();
- mrg::journal::iores res = _jp->enqueue_data_record(_msg_data, _msg_size, _msg_size, dtokp);
+ mrg::journal::data_tok* dtokPtr = new mrg::journal::data_tok();
+ mrg::journal::iores jrnlIoRes = _jrnlPtr->enqueue_data_record(_msgData, _msgSize, _msgSize, dtokPtr);
#endif
- switch (res) {
+ switch (jrnlIoRes) {
#ifdef JOURNAL2
case 0:
#else
@@ -90,7 +90,7 @@
case mrg::journal::RHM_IORES_BUSY:
#endif
if (!misfireFlag) std::cout << "-" << std::flush;
- delete dtokp;
+ delete dtokPtr;
misfireFlag = true;
break;
#ifdef JOURNAL2
@@ -98,23 +98,23 @@
#else
case mrg::journal::RHM_IORES_ENQCAPTHRESH:
#endif
- //std::cout << "_enq() RHM_IORES_ENQCAPTHRESH: " << dtokp->status_str() << std::endl;
+ //std::cout << "_doEnqueues() RHM_IORES_ENQCAPTHRESH: " << dtokPtr->status_str() << std::endl;
if (!misfireFlag) std::cout << "*" << std::flush;
//std::cout << ".";
- delete dtokp;
+ delete dtokPtr;
misfireFlag = true;
::usleep(10);
break;
default:
- delete dtokp;
+ delete dtokPtr;
#ifdef JOURNAL2
- std::cerr << "enqueue_data_record FAILED with " << mrg::journal2::iores_str(res) << std::endl;
+ std::cerr << "enqueue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << std::endl;
#else
- std::cerr << "enqueue_data_record FAILED with " << mrg::journal::iores_str(res) << std::endl;
+ std::cerr << "enqueue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << std::endl;
#endif
}
}
- _jp->flush(false);
+ _jrnlPtr->flush(false);
}
@@ -122,38 +122,38 @@
// This method will be called by multiple threads simultaneously
// Dequeue thread entry point
void
-JournalInstance::_deq()
+JournalInstance::_doDequeues()
{
uint32_t i = 0;
- while (i < _num_msgs) {
+ while (i < _numMsgs) {
#ifdef JOURNAL2
- mrg::journal2::dtok* dtokp = 0;
+ mrg::journal2::dtok* dtokPtr = 0;
#else
- mrg::journal::data_tok* dtokp = 0;
+ mrg::journal::data_tok* dtokPtr = 0;
#endif
- while (!dtokp) {
- bool get_events_flag;
+ while (!dtokPtr) {
+ bool getEventsFlag;
{
- std::unique_lock<std::mutex> l(_ucl_mutex);
- get_events_flag = _ucl.size() == 0;
- if (!get_events_flag) {
- dtokp = _ucl.front();
- _ucl.pop();
+ std::unique_lock<std::mutex> l(_unprocCallbackListMutex);
+ getEventsFlag = _unprocCallbackList.size() == 0;
+ if (!getEventsFlag) {
+ dtokPtr = _unprocCallbackList.front();
+ _unprocCallbackList.pop();
}
}
- if (get_events_flag) {
- _jp->get_wr_events(0);
+ if (getEventsFlag) {
+ _jrnlPtr->get_wr_events(0);
::usleep(1);
}
}
bool done = false;
while (!done) {
#ifdef JOURNAL2
- mrg::journal2::iores res = _jp->dequeue(dtokp);
+ mrg::journal2::iores jrnlIoRes = _jrnlPtr->dequeue(dtokPtr);
#else
- mrg::journal::iores res = _jp->dequeue_data_record(dtokp);
+ mrg::journal::iores jrnlIoRes = _jrnlPtr->dequeue_data_record(dtokPtr);
#endif
- switch (res) {
+ switch (jrnlIoRes) {
#ifdef JOURNAL2
case 0:
#else
@@ -171,36 +171,38 @@
break;
default:
#ifdef JOURNAL2
- std::cerr << "dequeue_data_record FAILED with " << mrg::journal2::iores_str(res) << ": " << dtokp->status_str() << std::endl;
+ std::cerr << "dequeue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << ": "
+ << dtokPtr->status_str() << std::endl;
#else
- std::cerr << "dequeue_data_record FAILED with " << mrg::journal::iores_str(res) << ": " << dtokp->status_str() << std::endl;
+ std::cerr << "dequeue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << ": "
+ << dtokPtr->status_str() << std::endl;
#endif
- delete dtokp;
+ delete dtokPtr;
done = true;
}
}
- _jp->get_wr_events(0);
+ _jrnlPtr->get_wr_events(0);
}
- _jp->flush(true);
+ _jrnlPtr->flush(true);
}
// *** MUST BE THREAD-SAFE ****
// This method will be called by multiple threads simultaneously
// Main thread entry point.
-// _thread_switch flips on each entry; this makes alternate threads run _enq() and _deq()
+// _threadSwitch flips on each call; this makes alternate threads run _doEnqueues() and _doDequeues()
void
JournalInstance::operator()()
{
- bool ts;
+ bool localThreadSwitch;
{
std::lock_guard<std::mutex> l(_ts_lock);
- ts = _thread_switch;
- _thread_switch = !_thread_switch;
+ localThreadSwitch = _threadSwitch;
+ _threadSwitch = !_threadSwitch;
}
- if (ts) {
- _deq();
+ if (localThreadSwitch) {
+ _doDequeues();
} else {
- _enq();
+ _doEnqueues();
}
}
@@ -208,35 +210,35 @@
// This method will be called by multiple threads simultaneously
void
#ifdef JOURNAL2
-JournalInstance::wr_aio_cb(std::vector<mrg::journal2::dtok*>& dtokl)
+JournalInstance::wr_aio_cb(std::vector<mrg::journal2::dtok*>& dataTokenList)
{
- mrg::journal2::dtok* dtokp;
+ mrg::journal2::dtok* dtokPtr;
#else
-JournalInstance::wr_aio_cb(std::vector<mrg::journal::data_tok*>& dtokl)
+JournalInstance::wr_aio_cb(std::vector<mrg::journal::data_tok*>& dataTokenList)
{
- mrg::journal::data_tok* dtokp;
+ mrg::journal::data_tok* dtokPtr;
#endif
- while (dtokl.size())
+ while (dataTokenList.size())
{
- dtokp = dtokl.back();
- dtokl.pop_back();
+ dtokPtr = dataTokenList.back();
+ dataTokenList.pop_back();
#ifdef JOURNAL2
- switch (dtokp->get_dtok_state().get_op_state())
+ switch (dtokPtr->get_dtok_state().get_op_state())
{
case mrg::journal2::OP_ENQUEUE:
#else
- switch (dtokp->wstate())
+ switch (dtokPtr->wstate())
{
case mrg::journal::data_tok::ENQ:
#endif
{
- std::unique_lock<std::mutex> l(_ucl_mutex);
- _ucl.push(dtokp);
+ std::unique_lock<std::mutex> l(_unprocCallbackListMutex);
+ _unprocCallbackList.push(dtokPtr);
}
break;
default:
- delete dtokp;
+ delete dtokPtr;
}
}
}
@@ -244,8 +246,8 @@
// *** MUST BE THREAD-SAFE ****
// This method will be called by multiple threads simultaneously
void
-JournalInstance::rd_aio_cb(std::vector<uint16_t>& /*pil*/)
+JournalInstance::rd_aio_cb(std::vector<uint16_t>& /*buffPageCtrlBlkIndexList*/)
{}
-} // namespace test
+} // namespace jtest
} // namespace mrg
Modified: store/trunk/cpp/perf/JournalInstance.hpp
===================================================================
--- store/trunk/cpp/perf/JournalInstance.hpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/perf/JournalInstance.hpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -29,12 +29,12 @@
* The GNU Lesser General Public License is available in the file COPYING.
*/
-#ifndef mrg_test_JournalInstance_hpp
-#define mrg_test_JournalInstance_hpp
+#ifndef mrg_jtest_JournalInstance_hpp
+#define mrg_jtest_JournalInstance_hpp
#include <cstdint>
+#include <mutex>
#include <queue>
-#include <mutex>
#ifdef JOURNAL2
#include "jrnl2/aio_callback.hpp"
@@ -48,48 +48,130 @@
namespace mrg
{
-namespace test
+namespace jtest
{
+ /**
+ * \brief Test journal instance. Each queue to be tested results in one instance of this class.
+ *
+ * Journal test harness which contains the journal to be tested. Each queue to be tested in the test parameters
+ * results in one instance of this class being instantiated, and consequently one set of journals on disk. The
+ * journal instance is provided as a pointer to the constructor.
+ */
#ifdef JOURNAL2
class JournalInstance: public mrg::journal2::aio_callback
#else
class JournalInstance: public mrg::journal::aio_callback
#endif
{
- const uint32_t _num_msgs;
- const uint32_t _msg_size;
- const char* _msg_data;
+ const uint32_t _numMsgs; ///< Number of messages to be processed by this journal instance
+ const uint32_t _msgSize; ///< Size of each message (in bytes)
+ const char* _msgData; ///< Pointer to message content to be used for each message.
#ifdef JOURNAL2
- mrg::journal2::jrnl* const _jp;
- std::queue<mrg::journal2::dtok*> _ucl;
+ mrg::journal2::jrnl* const _jrnlPtr; ///< Journal instance pointer
+ std::queue<mrg::journal2::dtok*> _unprocCallbackList; ///< Queue of unprocessed callbacks to be dequeued
#else
- mrg::journal::jcntl* const _jp;
- std::queue<mrg::journal::data_tok*> _ucl;
+ mrg::journal::jcntl* const _jrnlPtr; ///< Journal instance pointer
+ std::queue<mrg::journal::data_tok*> _unprocCallbackList; ///< Queue of unprocessed callbacks to be dequeued
#endif
- std::mutex _ucl_mutex;
- bool _thread_switch;
+ std::mutex _unprocCallbackListMutex; ///< Mutex which protects the unprocessed callback queue
+ bool _threadSwitch; ///< A switch which alternates worker threads between enq and deq
+ std::mutex _ts_lock; ///< Mutex which protects the thread switch
- std::mutex _ts_lock;
- void _enq();
- void _deq();
+ /**
+ * \brief Worker thread enqueue task
+ *
+ * This function is the worker thread enqueue task entry point. It enqueues _numMsgs onto the journal instance.
+ * A data tokens is created for each record, this is the start of the data token life cycle. All possible
+ * returns from the journal are handled appropriately. Since the enqueue threads also perform
+ * callbacks on completed AIO operations, the data tokens from completed enqueues are placed onto the
+ * unprocessed callback list (_unprocCallbackList) for dequeueing by the dequeue worker thread(s).
+ *
+ * This function must be thread safe.
+ */
+ void _doEnqueues();
+
+ /**
+ * \brief Worker thread dequeue task
+ *
+ * This function is the worker thread dequeue task entry point. It dequeues messages which are on the
+ * unprocessed callback list (_unprocCallbackList).
+ *
+ * This function must be thread safe.
+ */
+ void _doDequeues();
+
public:
+ /**
+ * \brief Constructor
+ *
+ * Constructor.
+ *
+ * \param numMsgs Number of messages per thread to be enqueued then dequeued (ie both ways through broker)
+ * \param msgSize Size of each message being enqueued
+ * \param msgData Pointer to message content (all messages have identical content)
+ * \param jrnlPtr Pinter to journal instance which is to be tested
+ */
#ifdef JOURNAL2
- JournalInstance(const uint32_t num_msgs, const uint32_t msg_size, const char* msg_data, mrg::journal2::jrnl* const jp);
+ JournalInstance(const uint32_t numMsgs,
+ const uint32_t msgSize,
+ const char* msgData,
+ mrg::journal2::jrnl* const jrnlPtr);
#else
- JournalInstance(const uint32_t num_msgs, const uint32_t msg_size, const char* msg_data, mrg::journal::jcntl* const jp);
+ JournalInstance(const uint32_t numMsgs,
+ const uint32_t msgSize,
+ const char* msgData,
+ mrg::journal::jcntl* const jrnlPtr);
#endif
+
+ /**
+ * \brief Destructor
+ *
+ * Destructor.
+ */
virtual ~JournalInstance();
+
+ /**
+ * \brief Worker thread entry point used by std::thread for classes. Threads must be provided in pairs.
+ *
+ * This is the entry point for worker threads. To successfully use this class, threads must be provided in
+ * pairs, with alternate threads being used for enqueueing and deqeueing tasks (_doEnqueues and _doDequeues
+ * respectively). See these functions for more detail on these tasks. The bool member _threadSwitch is
+ * responsible for alternating threads calling this function between these two tasks.
+ */
void operator()();
+
+ /**
+ * \brief Write callback function. When AIO operations return, this function is called.
+ *
+ * When AIO operations return, this function will sort the enqueue ops from the rest and place the data tokens
+ * of these records onto the unprocessed callback list (_unprocCallbackList) for dequeueing by another thread.
+ *
+ * Returning dequeue ops have their data tokens destroyed, as this is the end of the life cycle of the data
+ * tokens.
+ *
+ * Required by all subclasses of mrg::journal::aio_callback.
+ *
+ * \param dataTokenList A vector of data tokens for those messages which have completed their AIO write
+ * operations
+ */
#ifdef JOURNAL2
- void wr_aio_cb(std::vector<mrg::journal2::dtok*>& dtokl);
+ void wr_aio_cb(std::vector<mrg::journal2::dtok*>& dataTokenList);
#else
- void wr_aio_cb(std::vector<mrg::journal::data_tok*>& dtokl);
+ void wr_aio_cb(std::vector<mrg::journal::data_tok*>& dataTokenList);
#endif
- void rd_aio_cb(std::vector<uint16_t>& pil);
+
+ /**
+ * \brief Read callback function. When read AIO operations return, this function is called.
+ *
+ * Not used in this test, but required by all subclasses of mrg::journal::aio_callback.
+ *
+ * \param buffPageCtrlBlkIndexList A vector of indices to the buffer page control blocks for completed reads
+ */
+ void rd_aio_cb(std::vector<uint16_t>& buffPageCtrlBlkIndexList);
};
-} // namespace test
+} // namespace jtest
} // namespace mrg
-#endif // mrg_test_JournalInstance_hpp
+#endif // mrg_jtest_JournalInstance_hpp
Modified: store/trunk/cpp/perf/JournalParameters.cpp
===================================================================
--- store/trunk/cpp/perf/JournalParameters.cpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/perf/JournalParameters.cpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -35,7 +35,7 @@
namespace mrg
{
-namespace test
+namespace jtest
{
// static declarations
@@ -62,9 +62,9 @@
JournalParameters::JournalParameters(const std::string& jrnlDir,
const std::string& jrnlBaseFileName,
const uint16_t numJrnlFiles,
+ const uint32_t jrnlFileSize_sblks,
const bool autoExpand,
const uint16_t autoExpandMaxJrnlFiles,
- const uint32_t jrnlFileSize_sblks,
const uint16_t writeBuffNumPgs,
const uint32_t writeBuffPgSize_sblks) :
_jrnlDir(jrnlDir),
@@ -77,33 +77,39 @@
_writeBuffPgSize_sblks(writeBuffPgSize_sblks)
{}
-JournalParameters::JournalParameters(const JournalParameters& sp) :
- _jrnlDir(sp._jrnlDir),
- _jrnlBaseFileName(sp._jrnlBaseFileName),
- _numJrnlFiles(sp._numJrnlFiles),
- _jrnlFileSize_sblks(sp._jrnlFileSize_sblks),
- _autoExpand(sp._autoExpand),
- _autoExpandMaxJrnlFiles(sp._autoExpandMaxJrnlFiles),
- _writeBuffNumPgs(sp._writeBuffNumPgs),
- _writeBuffPgSize_sblks(sp._writeBuffPgSize_sblks)
+JournalParameters::JournalParameters(const JournalParameters& jp) :
+ _jrnlDir(jp._jrnlDir),
+ _jrnlBaseFileName(jp._jrnlBaseFileName),
+ _numJrnlFiles(jp._numJrnlFiles),
+ _jrnlFileSize_sblks(jp._jrnlFileSize_sblks),
+ _autoExpand(jp._autoExpand),
+ _autoExpandMaxJrnlFiles(jp._autoExpandMaxJrnlFiles),
+ _writeBuffNumPgs(jp._writeBuffNumPgs),
+ _writeBuffPgSize_sblks(jp._writeBuffPgSize_sblks)
{}
+void
+JournalParameters::toStream(std::ostream& os)
+{
+ os << "Store Parameters:" << std::endl;
+ os << " jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
+ os << " jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
+ os << " numJrnlFiles = " << _numJrnlFiles << std::endl;
+ os << " jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
+ os << " autoExpand = " << _autoExpand << std::endl;
+ os << " autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
+ os << " writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
+ os << " writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
+}
+
std::string
-JournalParameters::to_string()
+JournalParameters::toString()
{
std::ostringstream oss;
- oss << "Store Parameters:" << std::endl;
- oss << " jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
- oss << " jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
- oss << " numJrnlFiles = " << _numJrnlFiles << std::endl;
- oss << " jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
- oss << " autoExpand = " << _autoExpand << std::endl;
- oss << " autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
- oss << " writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
- oss << " writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
+ toStream(oss);
return oss.str();
}
-} // namespace test
+} // namespace jtest
} // namespace mrg
Modified: store/trunk/cpp/perf/JournalParameters.hpp
===================================================================
--- store/trunk/cpp/perf/JournalParameters.hpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/perf/JournalParameters.hpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -29,15 +29,16 @@
* The GNU Lesser General Public License is available in the file COPYING.
*/
-#ifndef mrg_test_JournalParameters_hpp
-#define mrg_test_JournalParameters_hpp
+#ifndef mrg_jtest_JournalParameters_hpp
+#define mrg_jtest_JournalParameters_hpp
#include <cstdint>
+#include <iostream>
#include <string>
namespace mrg
{
-namespace test
+namespace jtest
{
/**
@@ -78,13 +79,22 @@
* \brief Constructor
*
* Convenience constructor.
+ *
+ * \param jrnlDir Journal directory
+ * \param jrnlBaseFileName Journal base file name
+ * \param numJrnlFiles Number of journal data files
+ * \param jrnlFileSize_sblks Journal data file size in softblocks
+ * \param autoExpand Auto-expand flag (allows auto-expansion of journal data files)
+ * \param autoExpandMaxJrnlFiles Default auto-expand file number limit (0 = no limit)
+ * \param writeBuffNumPgs Number of write buffer pages
+ * \param writeBuffPgSize_sblks Size of each write buffer page in softblocks
*/
JournalParameters(const std::string& jrnlDir,
const std::string& jrnlBaseFileName,
const uint16_t numJrnlFiles,
+ const uint32_t jrnlFileSize_sblks,
const bool autoExpand,
const uint16_t autoExpandMaxJrnlFiles,
- const uint32_t jrnlFileSize_sblks,
const uint16_t writeBuffNumPgs,
const uint32_t writeBuffPgSize_sblks);
@@ -92,21 +102,33 @@
* \brief Copy constructor
*
* Copy constructor.
+ *
+ * \param jp Reference to JournalParameters instance to be copied
*/
- JournalParameters(const JournalParameters& sp);
+ JournalParameters(const JournalParameters& jp);
+ /***
+ * \brief Stream the journal parameters to an output stream
+ *
+ * Convenience feature which streams a multi-line representation of all the journal parameters, one per line to
+ * an output stream.
+ *
+ * \param os Output stream to which the class data is to be streamed
+ */
+ void toStream(std::ostream& os = std::cout);
+
/**
* \brief Creates a string representation of the journal parameters
*
- * Convenience feature which creates a multi-line string representation of all the parameters, one parameter per
+ * Convenience feature which creates a multi-line string representation of all the journal parameters, one per
* line.
*
* \return multi-line string representation of all the parameters, one parameter per line.
*/
- std::string to_string();
+ std::string toString();
};
-} // namespace test
+} // namespace jtest
} // namespace mrg
-#endif // mrg_test_JournalParameters_hpp
+#endif // mrg_jtest_JournalParameters_hpp
Modified: store/trunk/cpp/perf/ScopedPerformanceTimer.cpp
===================================================================
--- store/trunk/cpp/perf/ScopedPerformanceTimer.cpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/perf/ScopedPerformanceTimer.cpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -33,7 +33,7 @@
namespace mrg
{
-namespace test
+namespace jtest
{
ScopedPerformanceTimer::ScopedPerformanceTimer(const TestParameters& tp,
std::ostream& os) :
@@ -68,5 +68,5 @@
}
-} // namespace test
+} // namespace jtest
} // namespace mrg
Modified: store/trunk/cpp/perf/ScopedPerformanceTimer.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedPerformanceTimer.hpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/perf/ScopedPerformanceTimer.hpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -29,8 +29,8 @@
* The GNU Lesser General Public License is available in the file COPYING.
*/
-#ifndef mrg_test_ScopedPerformanceTimer_hpp
-#define mrg_test_ScopedPerformanceTimer_hpp
+#ifndef mrg_jtest_ScopedPerformanceTimer_hpp
+#define mrg_jtest_ScopedPerformanceTimer_hpp
#include <cstdint>
#include <ctime>
@@ -40,7 +40,7 @@
namespace mrg
{
-namespace test
+namespace jtest
{
/**
@@ -100,7 +100,7 @@
~ScopedPerformanceTimer();
};
-} // namespace test
+} // namespace jtest
} // namespace mrg
-#endif // mrg_test_ScopedPerformanceTimer_hpp
+#endif // mrg_jtest_ScopedPerformanceTimer_hpp
Modified: store/trunk/cpp/perf/StorePerformanceTest.cpp
===================================================================
--- store/trunk/cpp/perf/StorePerformanceTest.cpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/perf/StorePerformanceTest.cpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -53,7 +53,7 @@
namespace mrg
{
-namespace test
+namespace jtest
{
#ifdef JOURNAL2
@@ -61,59 +61,59 @@
#else
StorePerformanceTest::StorePerformanceTest(const TestParameters& tp, const JournalParameters& jp) :
#endif
- _test_params(tp),
- _store_params(jp),
- _msg_data(new char[tp._msgSize])
+ _testParams(tp),
+ _jrnlParams(jp),
+ msgData(new char[tp._msgSize])
{}
StorePerformanceTest::~StorePerformanceTest()
{
- while (_tests.size())
+ while (_jrnlList.size())
{
- delete _tests.back();
- _tests.pop_back();
+ delete _jrnlList.back();
+ _jrnlList.pop_back();
}
- delete[] _msg_data;
+ delete[] msgData;
}
void
-StorePerformanceTest::_prepare_journals()
+StorePerformanceTest::_prepareJournals()
{
#ifdef JOURNAL2
- if (mrg::journal2::jdir::exists(_store_params._jrnlDir)) {
- mrg::journal2::jdir::delete_dir(_store_params._jrnlDir);
+ if (mrg::journal2::jdir::exists(_jrnlParams._jrnlDir)) {
+ mrg::journal2::jdir::delete_dir(_jrnlParams._jrnlDir);
}
- mrg::journal2::jdir::create_dir(_store_params._jrnlDir);
+ mrg::journal2::jdir::create_dir(_jrnlParams._jrnlDir);
mrg::journal2::jrnl* jp;
#else
- if (mrg::journal::jdir::exists(_store_params._jrnlDir)) {
- mrg::journal::jdir::delete_dir(_store_params._jrnlDir);
+ if (mrg::journal::jdir::exists(_jrnlParams._jrnlDir)) {
+ mrg::journal::jdir::delete_dir(_jrnlParams._jrnlDir);
}
- mrg::journal::jdir::create_dir(_store_params._jrnlDir);
+ mrg::journal::jdir::create_dir(_jrnlParams._jrnlDir);
mrg::journal::jcntl* jp;
#endif
JournalInstance* ptp;
- for (uint16_t j = 0; j < _test_params._numQueues; j++)
+ for (uint16_t j = 0; j < _testParams._numQueues; j++)
{
std::ostringstream jname;
jname << "jrnl_" << std::setw(4) << std::setfill('0') << j;
std::ostringstream jdir;
- jdir << _store_params._jrnlDir << "/" << jname.str();
+ jdir << _jrnlParams._jrnlDir << "/" << jname.str();
#ifdef JOURNAL2
- jp = new mrg::journal2::jrnl(jname.str(), jdir.str(), _store_params._jrnlBaseFileName);
+ jp = new mrg::journal2::jrnl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
#else
- jp = new mrg::journal::jcntl(jname.str(), jdir.str(), _store_params._jrnlBaseFileName);
+ jp = new mrg::journal::jcntl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
#endif
- ptp = new JournalInstance(_test_params._numMsgs, _test_params._msgSize, _msg_data, jp);
+ ptp = new JournalInstance(_testParams._numMsgs, _testParams._msgSize, msgData, jp);
#ifdef JOURNAL2
- jp->initialize(&_store_params, ptp);
+ jp->initialize(&_jrnlParams, ptp);
#else
- jp->initialize(_store_params._numJrnlFiles, _store_params._autoExpand, _store_params._autoExpandMaxJrnlFiles,
- _store_params._jrnlFileSize_sblks, _store_params._writeBuffNumPgs,
- _store_params._writeBuffPgSize_sblks, ptp);
+ jp->initialize(_jrnlParams._numJrnlFiles, _jrnlParams._autoExpand, _jrnlParams._autoExpandMaxJrnlFiles,
+ _jrnlParams._jrnlFileSize_sblks, _jrnlParams._writeBuffNumPgs,
+ _jrnlParams._writeBuffPgSize_sblks, ptp);
#endif
- _tests.push_back(ptp);
+ _jrnlList.push_back(ptp);
}
}
@@ -122,17 +122,17 @@
{
std::deque<std::thread*> threads;
std::thread* tp;
- _prepare_journals();
+ _prepareJournals();
{
// --- Start of timed section ---
- ScopedPerformanceTimer pt(_test_params);
+ ScopedPerformanceTimer pt(_testParams);
- for (uint16_t q=0; q<_test_params._numQueues; q++)
+ for (uint16_t q=0; q<_testParams._numQueues; q++)
{
// Launch threads in pairs
- for (uint16_t t=0; t<_test_params._numThreadPairsPerQueue * 2; t++)
+ for (uint16_t t=0; t<_testParams._numThreadPairsPerQueue * 2; t++)
{
- tp = new std::thread(std::ref(*_tests[q]));
+ tp = new std::thread(std::ref(*_jrnlList[q]));
threads.push_back(tp);
}
}
@@ -149,67 +149,67 @@
}
void
-print_args()
+printArgs(std::ostream& os)
{
- std::cout << " -h --help: This help message" << std::endl;
- std::cout << std::endl;
- std::cout << "Test params:" << std::endl;
- std::cout << " -M --num_msgs: Number of messages to send ["
+ os << " -h --help: This help message" << std::endl;
+ os << std::endl;
+ os << "Test params:" << std::endl;
+ os << " -M --num_msgs: Number of messages to send ["
<< TestParameters::_s_defaultNumMsgs << "]" << std::endl;
- std::cout << " -S --msg_size: Size of each message to be sent ["
+ os << " -S --msg_size: Size of each message to be sent ["
<< TestParameters::_s_defaultMsgSize << "]" << std::endl;
- std::cout << " -Q --num_queues: Number of simultaneous queues ["
+ os << " -Q --num_queues: Number of simultaneous queues ["
<< TestParameters::_s_defaultNumQueues << "]" << std::endl;
- std::cout << " -T --num_thread_pairs_per_queue: Number of thread pairs per queue ["
+ os << " -T --num_thread_pairs_per_queue: Number of thread pairs per queue ["
<< TestParameters::_s_defaultNumThreadPairsPerQueue << "]" << std::endl;
- std::cout << " -E --enq_txn_blk_size: Enqueue transaction block size (0=non-txn) ["
+ os << " -E --enq_txn_blk_size: Enqueue transaction block size (0=non-txn) ["
<< TestParameters::_s_defaultEnqTxnBlkSize << "]" << std::endl;
- std::cout << " -D --deq_txn_blk_size: Dequeue transaction block size (0=non-txn) ["
+ os << " -D --deq_txn_blk_size: Dequeue transaction block size (0=non-txn) ["
<< TestParameters::_s_defaultDeqTxnBlkSize << "]" << std::endl;
- std::cout << std::endl;
- std::cout << "Store params:" << std::endl;
+ os << std::endl;
+ os << "Store params:" << std::endl;
#ifdef JOURNAL2
- std::cout << " -d --jrnl_dir: Store directory [\""
+ os << " -d --jrnl_dir: Store directory [\""
<< mrg::journal2::JournalParameters::_s_defaultJrnlDir << "\"]" << std::endl;
- std::cout << " -b --jrnl_base_filename: Base name for journal files [\""
+ os << " -b --jrnl_base_filename: Base name for journal files [\""
<< mrg::journal2::JournalParameters::_s_defaultJrnlBaseFileName << "\"]" << std::endl;
- std::cout << " -f --num_jfiles: Number of journal files ["
+ os << " -f --num_jfiles: Number of journal files ["
<< mrg::journal2::JournalParameters::_s_defaultNumJrnlFiles << "]" << std::endl;
- std::cout << " -s --jfsize_sblks: Size of each journal file in sblks (512 byte blocks) ["
+ os << " -s --jfsize_sblks: Size of each journal file in sblks (512 byte blocks) ["
<< mrg::journal2::JournalParameters::_s_defaultJrnlFileSize_sblks << "]" << std::endl;
- std::cout << " -a --auto_expand: Auto-expand the journal ["
+ os << " -a --auto_expand: Auto-expand the journal ["
<< (mrg::journal2::JournalParameters::_s_defaultAutoExpand?"T":"F") << "]" << std::endl;
- std::cout << " -e --ae_max_jfiles: Upper limit on number of auto-expanded journal files ["
+ os << " -e --ae_max_jfiles: Upper limit on number of auto-expanded journal files ["
<< mrg::journal2::JournalParameters::_s_defaultAutoExpandMaxJrnlFiles << "]" << std::endl;
- std::cout << " -p --wcache_num_pages: Number of write buffer pages ["
+ os << " -p --wcache_num_pages: Number of write buffer pages ["
<< mrg::journal2::JournalParameters::_s_defaultWriteBuffNumPgs << "]" << std::endl;
- std::cout << " -c --wcache_pgsize_sblks: Size of each write buffer page in sblks (512 byte blocks) ["
+ os << " -c --wcache_pgsize_sblks: Size of each write buffer page in sblks (512 byte blocks) ["
<< mrg::journal2::JournalParameters::_s_defaultWriteBuffPgSize_sblks << "]" << std::endl;
#else
- std::cout << " -d --jrnl_dir: Store directory [\""
+ os << " -d --jrnl_dir: Store directory [\""
<< JournalParameters::_s_defaultJrnlDir << "\"]" << std::endl;
- std::cout << " -b --jrnl_base_filename: Base name for journal files [\""
+ os << " -b --jrnl_base_filename: Base name for journal files [\""
<< JournalParameters::_s_defaultJrnlBaseFileName << "\"]" << std::endl;
- std::cout << " -f --num_jfiles: Number of journal files ["
+ os << " -f --num_jfiles: Number of journal files ["
<< JournalParameters::_s_defaultNumJrnlFiles << "]" << std::endl;
- std::cout << " -s --jfsize_sblks: Size of each journal file in sblks (512 byte blocks) ["
+ os << " -s --jfsize_sblks: Size of each journal file in sblks (512 byte blocks) ["
<< JournalParameters::_s_defaultJrnlFileSize_sblks << "]" << std::endl;
- std::cout << " -a --auto_expand: Auto-expand the journal ["
+ os << " -a --auto_expand: Auto-expand the journal ["
<< (JournalParameters::_s_defaultAutoExpand?"T":"F") << "]" << std::endl;
- std::cout << " -e --ae_max_jfiles: Upper limit on number of auto-expanded journal files ["
+ os << " -e --ae_max_jfiles: Upper limit on number of auto-expanded journal files ["
<< JournalParameters::_s_defaultAutoExpandMaxJrnlFiles << "]" << std::endl;
- std::cout << " -p --wcache_num_pages: Number of write buffer pages ["
+ os << " -p --wcache_num_pages: Number of write buffer pages ["
<< JournalParameters::_s_defaultWriteBuffNumPgs << "]" << std::endl;
- std::cout << " -c --wcache_pgsize_sblks: Size of each write buffer page in sblks (512 byte blocks) ["
+ os << " -c --wcache_pgsize_sblks: Size of each write buffer page in sblks (512 byte blocks) ["
<< JournalParameters::_s_defaultWriteBuffPgSize_sblks << "]" << std::endl;
#endif
}
bool
#ifdef JOURNAL2
-read_args(int argc, char** argv, mrg::test::TestParameters& tp, mrg::journal2::JournalParameters& sp)
+readArgs(int argc, char** argv, TestParameters& tp, mrg::journal2::JournalParameters& sp)
#else
-read_args(int argc, char** argv, mrg::test::TestParameters& tp, mrg::test::JournalParameters& sp)
+readArgs(int argc, char** argv, TestParameters& tp, JournalParameters& sp)
#endif
{
static struct option long_options[] = {
@@ -286,13 +286,13 @@
case 'h':
default:
err = true;
- print_args();
+ printArgs();
}
}
return err;
}
-} // namespace test
+} // namespace jtest
} // namespace mrg
// -----------------------------------------------------------------
@@ -300,16 +300,16 @@
int
main(int argc, char** argv)
{
- mrg::test::TestParameters tp;
+ mrg::jtest::TestParameters tp;
#ifdef JOURNAL2
mrg::journal2::JournalParameters jp;
#else
- mrg::test::JournalParameters jp;
+ mrg::jtest::JournalParameters jp;
#endif
- if (mrg::test::read_args(argc, argv, tp, jp)) return 1;
- std::cout << tp.to_string() << std::endl;
- std::cout << jp.to_string() << std::endl;
- mrg::test::StorePerformanceTest p(tp, jp);
+ if (mrg::jtest::readArgs(argc, argv, tp, jp)) return 1;
+ std::cout << tp.toString() << std::endl;
+ std::cout << jp.toString() << std::endl;
+ mrg::jtest::StorePerformanceTest p(tp, jp);
p.run();
return 0;
Modified: store/trunk/cpp/perf/StorePerformanceTest.hpp
===================================================================
--- store/trunk/cpp/perf/StorePerformanceTest.hpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/perf/StorePerformanceTest.hpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -29,9 +29,10 @@
* The GNU Lesser General Public License is available in the file COPYING.
*/
-#ifndef mrg_test_StorePerformanceTest_hpp
-#define mrg_test_StorePerformanceTest_hpp
+#ifndef mrg_jtest_StorePerformanceTest_hpp
+#define mrg_jtest_StorePerformanceTest_hpp
+#include <iostream>
#include <vector>
#include "JournalInstance.hpp"
@@ -47,38 +48,93 @@
namespace mrg
{
-namespace test
+namespace jtest
{
+ /**
+ * \brief Main test class; Create an instance and execute run()
+ *
+ * Main test class which aggregates the components of a test.
+ */
class StorePerformanceTest
{
- const TestParameters& _test_params;
+ const TestParameters& _testParams; ///< Ref to a struct containing test params
#ifdef JOURNAL2
- const mrg::journal2::JournalParameters& _store_params;
+ const mrg::journal2::JournalParameters& _jrnlParams; ///< Ref to a struct containing the journal parameters
#else
- const JournalParameters& _store_params;
+ const JournalParameters& _jrnlParams; ///< Ref to a struct containing the journal parameters
#endif
- const char* _msg_data;
- std::vector<JournalInstance*> _tests;
- void _prepare_journals();
+ const char* msgData; ///< Pointer to msg data, which is the same for all messages
+ std::vector<JournalInstance*> _jrnlList; ///< List of journals (JournalInstance instances) being tested
+
+ /**
+ * \brief Creates journals and JournalInstance classes for all journals (queues) to be tested
+ *
+ * Creates a new journal instance and JournalInstance instance for each queue. The journals are initialized
+ * which creates a new set of journal files on the local storage media (which is determined by path in
+ * JournalParameters._jrnlDir). This activity is not timed, and is not a part of the performance test per se.
+ */
+ void _prepareJournals();
+
public:
+ /**
+ * \brief Constructor
+ *
+ * Constructor.
+ *
+ * \param tp Test parameters for the test
+ * \param jp Journal parameters for all queues (journals) in the test
+ */
#ifdef JOURNAL2
- StorePerformanceTest(const TestParameters& tp, const mrg::journal2::JournalParameters& sp);
+ StorePerformanceTest(const TestParameters& tp, const mrg::journal2::JournalParameters& jp);
#else
- StorePerformanceTest(const TestParameters& tp, const JournalParameters& sp);
+ StorePerformanceTest(const TestParameters& tp, const JournalParameters& jp);
#endif
+
+ /**
+ * \brief Destructor
+ *
+ * Destructor.
+ */
~StorePerformanceTest();
+
+ /**
+ * \brief Runs the test and prints out the results.
+ *
+ * Runs the test as set by the test parameters and journal parameters.
+ */
void run();
};
- void print_args();
+ /**
+ * \brief Print out the program arguments
+ *
+ * Print out the arguments to the performance program if requested by help or a parameter error.
+ *
+ * \param os Stream to which the arguments should be streamed.
+ */
+ void printArgs(std::ostream& os = std::cout);
+
+ /**
+ * \brief Process the command-line arguments
+ *
+ * Process the command-line arguments and populate the TestParameters and JournalParameters structs. Only the
+ * arguments supplied are on the command-line are changed in these structs, the others remain unchanged. It is
+ * important therefore to make sure that defaults are pre-loaded (the default behavior of the default constructors
+ * for these structs).
+ *
+ * \param argc Number of command-line arguments. Process directly from main().
+ * \param argv Pointer to array of command-line argument pointers. Process directly from main().
+ * \param tp Reference to test parameter object. Only params on the command-line are changed.
+ * \param jp Reference to journal parameter object. Only params on the command-line are changed.
+ */
#ifdef JOURNAL2
- bool read_args(int argc, char** argv, mrg::test::TestParameters& tp, mrg::journal2::JournalParameters& sp);
+ bool readArgs(int argc, char** argv, TestParameters& tp, mrg::journal2::JournalParameters& jp);
#else
- bool read_args(int argc, char** argv, mrg::test::TestParameters& tp, mrg::test::JournalParameters& sp);
+ bool readArgs(int argc, char** argv, TestParameters& tp, JournalParameters& jp);
#endif
-} // namespace test
+} // namespace jtest
} // namespace mrg
-#endif // mrg_test_StorePerformanceTest_hpp
+#endif // mrg_jtest_StorePerformanceTest_hpp
Modified: store/trunk/cpp/perf/TestParameters.cpp
===================================================================
--- store/trunk/cpp/perf/TestParameters.cpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/perf/TestParameters.cpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -35,7 +35,7 @@
namespace mrg
{
-namespace test
+namespace jtest
{
// static declarations
@@ -78,19 +78,25 @@
_deqTxnBlockSize(tp._deqTxnBlockSize)
{}
+void
+TestParameters::toStream(std::ostream& os)
+{
+ os << "Test Parameters:" << std::endl;
+ os << " num_msgs = " << _numMsgs << std::endl;
+ os << " msg_size = " << _msgSize << std::endl;
+ os << " num_queues = " << _numQueues << std::endl;
+ os << " num_thread_pairs_per_queue = " << _numThreadPairsPerQueue << std::endl;
+ os << " enq_txn_blk_size = " << _enqTxnBlockSize << std::endl;
+ os << " deq_txn_blk_size = " << _deqTxnBlockSize << std::endl;
+}
+
std::string
-TestParameters::to_string()
+TestParameters::toString()
{
std::ostringstream oss;
- oss << "Test Parameters:" << std::endl;
- oss << " num_msgs = " << _numMsgs << std::endl;
- oss << " msg_size = " << _msgSize << std::endl;
- oss << " num_queues = " << _numQueues << std::endl;
- oss << " num_thread_pairs_per_queue = " << _numThreadPairsPerQueue << std::endl;
- oss << " enq_txn_blk_size = " << _enqTxnBlockSize << std::endl;
- oss << " deq_txn_blk_size = " << _deqTxnBlockSize << std::endl;
+ toStream(oss);
return oss.str();
}
-} // namespace test
+} // namespace jtest
} // namespace mrg
Modified: store/trunk/cpp/perf/TestParameters.hpp
===================================================================
--- store/trunk/cpp/perf/TestParameters.hpp 2010-12-06 20:34:52 UTC (rev 4427)
+++ store/trunk/cpp/perf/TestParameters.hpp 2010-12-07 17:01:24 UTC (rev 4428)
@@ -29,15 +29,16 @@
* The GNU Lesser General Public License is available in the file COPYING.
*/
-#ifndef mrg_test_TestParameters_hpp
-#define mrg_test_TestParameters_hpp
+#ifndef mrg_jtest_TestParameters_hpp
+#define mrg_jtest_TestParameters_hpp
#include <cstdint>
+#include <iostream>
#include <string>
namespace mrg
{
-namespace test
+namespace jtest
{
/**
@@ -49,15 +50,15 @@
struct TestParameters
{
static uint32_t _s_defaultNumMsgs; ///< Default number of messages to be sent
- static uint32_t _s_defaultMsgSize; ///< Default message size
- static uint16_t _s_defaultNumQueues; ///< Default number of queues
+ 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_defaultNumThreadPairsPerQueue; ///< Default number of thread pairs (enq and deq) per queue
static uint16_t _s_defaultEnqTxnBlkSize; ///< Default transaction block size for enqueues
static uint16_t _s_defaultDeqTxnBlkSize; ///< Default transaction block size for dequeues
uint32_t _numMsgs; ///< Number of messages to be sent
- uint32_t _msgSize; ///< Message size
- uint16_t _numQueues; ///< Number of queues
+ uint32_t _msgSize; ///< Message size in bytes
+ uint16_t _numQueues; ///< Number of queues to test simultaneously
uint16_t _numThreadPairsPerQueue; ///< Number of thread pairs (enq and deq) per queue
uint16_t _enqTxnBlockSize; ///< Transaction block size for enqueues
uint16_t _deqTxnBlockSize; ///< Transaction block size for dequeues
@@ -73,6 +74,13 @@
* \brief Constructor
*
* Convenience constructor.
+ *
+ * \param numMsgs Number of messages to be sent
+ * \param msgSize Message size in bytes
+ * \param numQueues Number of queues to test simultaneously
+ * \param numThreadPairsPerQueue Number of thread pairs (enq and deq) per queue
+ * \param enqTxnBlockSize Transaction block size for enqueues
+ * \parma deqTxnBlockSize Transaction block size for dequeues
*/
TestParameters(const uint32_t numMsgs,
const uint32_t msgSize,
@@ -85,21 +93,33 @@
* \brief Copy constructor
*
* Copy constructor.
+ *
+ * \param tp Reference to TestParameters instance to be copied
*/
TestParameters(const TestParameters& tp);
+ /***
+ * \brief Stream the test parameters to an output stream
+ *
+ * Convenience feature which streams a multi-line representation of all the test parameters, one per line to an
+ * output stream.
+ *
+ * \param os Output stream to which the class data is to be streamed
+ */
+ void toStream(std::ostream& os = std::cout);
+
/**
* \brief Creates a string representation of the test parameters
*
- * Convenience feature which creates a multiline string representation of all the parameters, one parameter per
- * line.
+ * Convenience feature which creates a multi-line string representation of all the test parameters, one
+ * per line.
*
- * \return multiline string representation of all the parameters, one parameter per line.
+ * \return multi-line string representation of all the parameters, one parameter per line.
*/
- std::string to_string();
+ std::string toString();
};
-} // namespace test
+} // namespace jtest
} // namespace mrg
-#endif // mrg_test_TestParameters_hpp
+#endif // mrg_jtest_TestParameters_hpp
14 years