rhmessaging commits: r903 - store/trunk/cpp/tests.
by rhmessaging-commits@lists.jboss.org
Author: gordonsim
Date: 2007-08-31 13:03:31 -0400 (Fri, 31 Aug 2007)
New Revision: 903
Modified:
store/trunk/cpp/tests/OrderingTest.cpp
store/trunk/cpp/tests/SimpleTest.cpp
store/trunk/cpp/tests/TransactionalTest.cpp
store/trunk/cpp/tests/TwoPhaseCommitTest.cpp
Log:
Changed to reflect new signature for Queue::dequeue in qpid trunk.
Modified: store/trunk/cpp/tests/OrderingTest.cpp
===================================================================
--- store/trunk/cpp/tests/OrderingTest.cpp 2007-08-30 21:42:58 UTC (rev 902)
+++ store/trunk/cpp/tests/OrderingTest.cpp 2007-08-31 17:03:31 UTC (rev 903)
@@ -106,7 +106,7 @@
bool pop()
{
- Message::shared_ptr msg = queue->dequeue();
+ Message::shared_ptr msg = queue->dequeue().payload;
if (msg) {
queue->dequeue(0, msg);
string expected = ids.front();
Modified: store/trunk/cpp/tests/SimpleTest.cpp
===================================================================
--- store/trunk/cpp/tests/SimpleTest.cpp 2007-08-30 21:42:58 UTC (rev 902)
+++ store/trunk/cpp/tests/SimpleTest.cpp 2007-08-31 17:03:31 UTC (rev 903)
@@ -216,7 +216,7 @@
Queue::shared_ptr queue = registry.find(name);
CPPUNIT_ASSERT(queue);
CPPUNIT_ASSERT_EQUAL((u_int32_t) 1, queue->getMessageCount());
- Message::shared_ptr msg = queue->dequeue();
+ Message::shared_ptr msg = queue->dequeue().payload;
CPPUNIT_ASSERT_EQUAL(exchange, msg->getExchangeName());
CPPUNIT_ASSERT_EQUAL(routingKey, msg->getRoutingKey());
@@ -332,7 +332,7 @@
Queue::shared_ptr queue = registry.find(name);
CPPUNIT_ASSERT(queue);
CPPUNIT_ASSERT_EQUAL((u_int32_t) 1, queue->getMessageCount());
- Message::shared_ptr msg = queue->dequeue();
+ Message::shared_ptr msg = queue->dequeue().payload;
//check headers
CPPUNIT_ASSERT_EQUAL(exchange, msg->getExchangeName());
Modified: store/trunk/cpp/tests/TransactionalTest.cpp
===================================================================
--- store/trunk/cpp/tests/TransactionalTest.cpp 2007-08-30 21:42:58 UTC (rev 902)
+++ store/trunk/cpp/tests/TransactionalTest.cpp 2007-08-31 17:03:31 UTC (rev 903)
@@ -71,7 +71,7 @@
{
setup();
- Message::shared_ptr msg = queueA->dequeue();
+ Message::shared_ptr msg = queueA->dequeue().payload;
CPPUNIT_ASSERT(msg);
//move the message from one queue to the other as a transaction
@@ -141,7 +141,7 @@
CPPUNIT_ASSERT_EQUAL((u_int32_t) 0, x->getMessageCount());
CPPUNIT_ASSERT_EQUAL((u_int32_t) 1, y->getMessageCount());
- Message::shared_ptr msg = y->dequeue();
+ Message::shared_ptr msg = y->dequeue().payload;
CPPUNIT_ASSERT(msg);
CPPUNIT_ASSERT_EQUAL(messageId, msg->getProperties<MessageProperties>()->getMessageId());
}
Modified: store/trunk/cpp/tests/TwoPhaseCommitTest.cpp
===================================================================
--- store/trunk/cpp/tests/TwoPhaseCommitTest.cpp 2007-08-30 21:42:58 UTC (rev 902)
+++ store/trunk/cpp/tests/TwoPhaseCommitTest.cpp 2007-08-31 17:03:31 UTC (rev 903)
@@ -261,7 +261,7 @@
void swap(TPCTransactionContext* txn)
{
- Message::shared_ptr msg = queueA->dequeue();//just dequeues in memory
+ Message::shared_ptr msg = queueA->dequeue().payload;//just dequeues in memory
//move the message from one queue to the other as part of a
//distributed transaction
queueB->enqueue(txn, msg);//note: need to enqueue it first to avoid message being deleted
@@ -270,7 +270,7 @@
void dequeue(TPCTransactionContext* txn)
{
- Message::shared_ptr msg = queueA->dequeue();//just dequeues in memory
+ Message::shared_ptr msg = queueA->dequeue().payload;//just dequeues in memory
queueA->dequeue(txn, msg);
}
@@ -340,7 +340,7 @@
CPPUNIT_ASSERT_EQUAL((u_int32_t) 0, x->getMessageCount());
CPPUNIT_ASSERT_EQUAL((u_int32_t) 1, y->getMessageCount());
- Message::shared_ptr msg = y->dequeue();
+ Message::shared_ptr msg = y->dequeue().payload;
CPPUNIT_ASSERT(msg);
CPPUNIT_ASSERT_EQUAL(msgid, msg->getProperties<MessageProperties>()->getMessageId());
}
@@ -350,7 +350,7 @@
CPPUNIT_ASSERT(queueA);
CPPUNIT_ASSERT_EQUAL(size, queueA->getMessageCount());
if (size > 0) {
- Message::shared_ptr msg = queueA->dequeue();
+ Message::shared_ptr msg = queueA->dequeue().payload;
CPPUNIT_ASSERT(msg);
CPPUNIT_ASSERT_EQUAL(msgid, msg->getProperties<MessageProperties>()->getMessageId());
}
17 years, 4 months
rhmessaging commits: r902 - in store/trunk/cpp: lib/jrnl and 2 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-08-30 17:42:58 -0400 (Thu, 30 Aug 2007)
New Revision: 902
Modified:
store/trunk/cpp/lib/Makefile.am
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/tests/Makefile.am
store/trunk/cpp/tests/jrnl/JournalTest.cpp
store/trunk/cpp/tests/jrnl/Makefile.am
store/trunk/cpp/tests/jrnl/jtest.cpp
store/trunk/cpp/tests/jrnl/jtest.hpp
store/trunk/cpp/tests/jrnl/msg_consumer.cpp
store/trunk/cpp/tests/jrnl/msg_consumer.hpp
store/trunk/cpp/tests/jrnl/msg_producer.cpp
store/trunk/cpp/tests/jrnl/msg_producer.hpp
Log:
More tests added
Modified: store/trunk/cpp/lib/Makefile.am
===================================================================
--- store/trunk/cpp/lib/Makefile.am 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/lib/Makefile.am 2007-08-30 21:42:58 UTC (rev 902)
@@ -1,4 +1,5 @@
-AM_CXXFLAGS = $(WARNING_CFLAGS) $(APR_CXXFLAGS) $(QPID_CXXFLAGS)
+AM_CXXFLAGS = $(WARNING_CFLAGS) $(APR_CXXFLAGS) $(QPID_CXXFLAGS) \
+ -DRHM_CLEAN -DRHM_WRONLY -DRHM_TESTVALS
lib_LTLIBRARIES = libbdbstore.la
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -80,6 +80,15 @@
// Prepare journal dir, journal files and file handles
_jdir.clear_dir();
+ // TODO - place this in a finalize() fn? - see ~jcntl()...
+ if (_datafh)
+ {
+ for (u_int32_t i=0; i<JRNL_NUM_FILES; i++)
+ if (_datafh[i])
+ ::delete _datafh[i];
+ ::delete[] _datafh;
+ }
+
_datafh = ::new lfh*[JRNL_NUM_FILES];
// NOTE: We NULL the pointer array prior to setting the pointers because exceptions
// can be thrown during pointer initialization, and the clean() fn that will be
Modified: store/trunk/cpp/tests/Makefile.am
===================================================================
--- store/trunk/cpp/tests/Makefile.am 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/Makefile.am 2007-08-30 21:42:58 UTC (rev 902)
@@ -2,7 +2,7 @@
abs_srcdir=@abs_srcdir@
AM_CXXFLAGS = $(WARNING_CFLAGS) $(APR_CXXFLAGS) $(QPID_CXXFLAGS) \
- $(CPPUNIT_CXXFLAGS)
+ $(CPPUNIT_CXXFLAGS)
INCLUDES=-I../lib
Modified: store/trunk/cpp/tests/jrnl/JournalTest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -37,19 +37,198 @@
class JournalTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(JournalTest);
+ CPPUNIT_TEST(Test_000);
CPPUNIT_TEST(Test_001);
+ CPPUNIT_TEST(Test_002);
+ CPPUNIT_TEST(Test_003);
+ CPPUNIT_TEST(Test_004);
+ CPPUNIT_TEST(Test_005);
+ CPPUNIT_TEST(Test_006);
+ CPPUNIT_TEST(Test_007);
+ CPPUNIT_TEST(Test_008);
+ CPPUNIT_TEST(Test_009);
+ CPPUNIT_TEST(Test_010);
+ CPPUNIT_TEST(Test_011);
+ CPPUNIT_TEST(Test_012);
+ CPPUNIT_TEST(Test_013);
+ CPPUNIT_TEST(Test_014);
+ CPPUNIT_TEST(Test_015);
+ CPPUNIT_TEST(Test_016);
+ CPPUNIT_TEST(Test_017);
+ CPPUNIT_TEST(Test_018);
+ CPPUNIT_TEST(Test_019);
+ CPPUNIT_TEST(Test_020);
+ CPPUNIT_TEST(Test_021);
+ CPPUNIT_TEST(Test_022);
+ CPPUNIT_TEST(Test_023);
+ CPPUNIT_TEST(Test_024);
+ CPPUNIT_TEST(Test_025);
+ CPPUNIT_TEST(Test_026);
CPPUNIT_TEST_SUITE_END();
+ jtest t;
+
+ void runJournalTest(const unsigned num_msgs, const unsigned min_msg_size,
+ const unsigned max_msg_szie, const bool auto_deq, const unsigned iterations,
+ const char* test_descr)
+ {
+ std::cout << " " << test_descr << " " << std::flush;
+ jtest::targs ta(num_msgs, min_msg_size, max_msg_szie, auto_deq, test_descr);
+ for (unsigned i=0; i<iterations; i++)
+ {
+ std::cout << "." << std::flush;
+ try
+ {
+ t.initialize(ta);
+ t.run();
+ }
+ catch (rhm::journal::jexception e)
+ {
+ t.finalize();
+ std::cout << e << std::endl;
+ std::cout << std::hex << std::setfill('0');
+ std::cerr << "*** jtest failed with code 0x" << std::setw(4) << e.err_code() << " ***" << std::endl << std::flush;
+ throw e;
+ }
+ t.finalize();
+ }
+ }
+
public:
+ void Test_000()
+ {
+ runJournalTest(0, 0, 0, false, 2, "Empty journal");
+ }
+
void Test_001()
{
- jtest::targs ta(1, 10, 10, false, "Test 1");
- jtest t;
- t.initialize(ta);
- t.run();
- t.report();
- t.finalize();
+ runJournalTest(1, 10, 10, false, 5, "1*(10 bytes)");
}
+
+ void Test_002()
+ {
+ runJournalTest(1, 10, 10, true, 5, "1*(10 bytes), auto-deq");
+ }
+
+ void Test_003()
+ {
+ runJournalTest(10, 10, 10, false, 5, "10*(10 bytes)");
+ }
+
+ void Test_004()
+ {
+ runJournalTest(10, 10, 10, true, 5, "10*(10 bytes), auto-deq");
+ }
+
+ void Test_005()
+ {
+ runJournalTest(10, 92, 92, false, 5, "10*(1 dblk exact fit)");
+ }
+
+ void Test_006()
+ {
+ runJournalTest(10, 92, 92, true, 5, "10*(1 dblk exact fit), auto-deq");
+ }
+
+ void Test_007()
+ {
+ runJournalTest(10, 93, 93, false, 5, "10*(1 dblk + 1 byte)");
+ }
+
+ void Test_008()
+ {
+ runJournalTest(10, 93, 93, true, 5, "10*(1 dblk + 1 byte), auto-deq");
+ }
+
+ void Test_009()
+ {
+ runJournalTest(10, 476, 476, false, 5, "10*(1 sblk exact fit)");
+ }
+
+ void Test_010()
+ {
+ runJournalTest(10, 476, 476, true, 5, "10*(1 sblk exact fit), auto-deq");
+ }
+
+ void Test_011()
+ {
+ runJournalTest(10, 477, 477, false, 5, "10*(1 sblk + 1 byte)");
+ }
+
+ void Test_012()
+ {
+ runJournalTest(10, 477, 477, true, 5, "10*(1 sblk + 1 byte), auto-deq");
+ }
+
+ void Test_013()
+ {
+ runJournalTest(8, 4060, 4060, false, 5, "8*(1/8 page)");
+ }
+
+ void Test_014()
+ {
+ runJournalTest(9, 4060, 4060, false, 5, "9*(1/8 page)");
+ }
+
+ void Test_015()
+ {
+ runJournalTest(8, 4061, 4061, false, 5, "8*(1/8 page + 1 byte)");
+ }
+
+ void Test_016()
+ {
+ runJournalTest(8, 3932, 3932, true, 5, "8*(1/8 page - 1 dblk for deq record), auto-deq");
+ }
+
+ void Test_017()
+ {
+ runJournalTest(9, 3932, 3932, true, 5, "9*(1/8 page - 1 dblk for deq record), auto-deq");
+ }
+
+ void Test_018()
+ {
+ runJournalTest(8, 3933, 3933, true, 5, "8*(1/8 page - 1 dblk for deq record + 1 byte), auto-deq");
+ }
+
+ void Test_019()
+ {
+ runJournalTest(32, 32732, 32732, false, 5, "32*(1 page exact fit)");
+ }
+
+ void Test_020()
+ {
+ runJournalTest(33, 32732, 32732, false, 5, "33*(1 page exact fit)");
+ }
+
+ void Test_021()
+ {
+ runJournalTest(22, 49116, 49116, false, 5, "22*(1.5 pages)");
+ }
+
+ void Test_022()
+ {
+ runJournalTest(22, 48988, 48988, true, 5, "22*(1.5 pages - 1 dblk for deq record), auto-deq");
+ }
+
+ void Test_023()
+ {
+ runJournalTest(48, 32732, 32732, false, 5, "48*(1 page exact fit)");
+ }
+
+ void Test_024()
+ {
+ runJournalTest(49, 32732, 32732, false, 5, "49*(1 page exact fit)");
+ }
+
+ void Test_025()
+ {
+ runJournalTest(20, 81884, 81884, false, 5, "20*(2.5 pages)");
+ }
+
+ void Test_026()
+ {
+ runJournalTest(20, 81756, 81756, true, 5, "20*(2.5 pages - 1 dblk for deq record), auto-deq");
+ }
};
// Make this test suite a plugin.
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2007-08-30 21:42:58 UTC (rev 902)
@@ -1,6 +1,6 @@
abs_builddir=@abs_builddir@
-AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) -pthread
+AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) -pthread -DRHM_CLEAN -DRHM_WRONLY -DRHM_TESTVALS
INCLUDES=-I../../lib
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -85,7 +85,7 @@
_comment(comment)
{}
-jtest::jtest() throw (rhm::journal::jexception):
+jtest::jtest():
_start_time(new timeval),
_end_time(new timeval),
_tz_ptr(NULL)
@@ -118,7 +118,7 @@
void
jtest::initialize(const targs& ta) throw (rhm::journal::jexception)
{
- gettimeofday(_start_time, _tz_ptr);
+// gettimeofday(_start_time, _tz_ptr);
p_args = new msg_producer::_p_args(_jc, ta._num_msgs, ta._min_msg_size, ta._max_msg_size,
ta._auto_deq);
@@ -127,9 +127,9 @@
_mc.initialize(c_args);
_jc.initialize(&_mc.aio_dtokl(), NULL, &_mp.aio_dtokl(), &mp_aio_cb);
- gettimeofday(_end_time, _tz_ptr);
- string str;
- cout << "initialize(): " << report_time(str) << endl;
+// gettimeofday(_end_time, _tz_ptr);
+// string str;
+// cout << "initialize(): " << report_time(str) << endl;
}
void
@@ -145,7 +145,7 @@
#ifndef RHM_RDONLY
produce(p_args);
#ifndef RHM_WRONLY
- std::cout << "-----" << std::endl;
+// std::cout << "-----" << std::endl;
usleep(500000); // 0.5 sec
#endif
#endif
@@ -170,7 +170,7 @@
gettimeofday(_end_time, _tz_ptr);
string str;
- cout << "run(): " << report_time(str) << endl;
+// cout << "run(): " << report_time(str) << endl;
}
void
@@ -179,7 +179,10 @@
void
jtest::finalize() throw (rhm::journal::jexception)
-{}
+{
+ _mp.finalize();
+ _mc.finalize();
+}
string&
jtest::report_time(string& str) const
Modified: store/trunk/cpp/tests/jrnl/jtest.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.hpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/jtest.hpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -62,7 +62,6 @@
};
private:
-// static msg_producer::_p_args p_arg_arr[NUM_TESTS];
static msg_producer::_p_args* p_args;
static msg_consumer::_c_args* c_args;
static rhm::journal::jcntl _jc;
@@ -74,7 +73,7 @@
pthread_t _c_thread;
public:
- jtest() throw (rhm::journal::jexception);
+ jtest();
~jtest();
static void proc_args(int argc, char** argv, char** test_file_name, int* test_num)
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -47,8 +47,8 @@
{}
msg_consumer::msg_consumer():
- _tot_blks(0),
- _tot_msize(0)
+ _tot_dblks(0),
+ _tot_dsize(0)
{
instCnt++;
}
@@ -83,6 +83,20 @@
initialize(args->_num_msgs);
}
+void
+msg_consumer::finalize()
+{
+ _tot_dblks = 0;
+ _tot_dsize = 0;
+ _aio_cmpl_dtok_list.clear();
+ for (u_int32_t i=0; i<_dtok_master_list.size(); i++)
+ {
+ delete _dtok_master_list[i];
+ _dtok_master_list[i] = NULL;
+ }
+ _dtok_master_list.clear();
+}
+
u_int32_t
msg_consumer::consume(rhm::journal::jcntl& _jcntl, const u_int32_t num_msgs,
const size_t min_msg_size, const size_t max_msg_size) throw (rhm::journal::jexception)
@@ -110,8 +124,8 @@
data_size = dtokp->dsize();
_msg_buff[data_size] = 0; // Make msg into a c-string
read = true;
- _tot_blks += dtokp->dblocks_proc();
- _tot_msize += data_size;
+ _tot_dblks += dtokp->dblocks_proc();
+ _tot_dsize += data_size;
// Comment out these for performance checks/measurements
check_msg(msgCntr, data_size, min_msg_size, max_msg_size, true, _msg_buff);
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -62,8 +62,8 @@
u_int32_t _num_msgs;
std::deque<rhm::journal::data_tok*> _dtok_master_list; // One dtok per msg to be received
std::deque<rhm::journal::data_tok*> _aio_cmpl_dtok_list; // Dtoks from completed AIOs go here
- u_int64_t _tot_blks;
- u_int64_t _tot_msize;
+ u_int64_t _tot_dblks;
+ u_int64_t _tot_dsize;
public:
msg_consumer();
@@ -71,14 +71,15 @@
void initialize(const u_int32_t numMsgs);
void initialize(_c_args* args);
+ void finalize();
u_int32_t consume(rhm::journal::jcntl& _jcntl, const u_int32_t numMsgs,
const size_t min_msg_size, const size_t max_msg_size) throw (rhm::journal::jexception);
u_int32_t consume(_c_args* args) throw (rhm::journal::jexception);
void aio_callback(u_int32_t num_dtoks);
- const inline u_int64_t get_tot_blks() const { return _tot_blks; }
- const inline u_int64_t get_tot_msize() const { return _tot_msize; }
+ const inline u_int64_t get_tot_dblks() const { return _tot_dblks; }
+ const inline u_int64_t get_tot_dsize() const { return _tot_dsize; }
inline std::deque<rhm::journal::data_tok*>& aio_dtokl() { return _aio_cmpl_dtok_list; }
static void interrupt();
private:
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -87,6 +87,25 @@
initialize(args->_num_msgs, args->_auto_dequeue);
}
+void
+msg_producer::finalize()
+{
+ _num_msgs_enq_subm = 0;
+ _num_msgs_enq = 0;
+ _num_msgs_deq_subm = 0;
+ _num_msgs_deq = 0;
+ _tot_dblks = 0;
+ _tot_dsize = 0;
+ _aio_cmpl_dtok_list.clear();
+ _dd_dtok_list.clear();
+ for (u_int32_t i=0; i<_dtok_master_list.size(); i++)
+ {
+ delete _dtok_master_list[i];
+ _dtok_master_list[i] = NULL;
+ }
+ _dtok_master_list.clear();
+}
+
u_int32_t
msg_producer::produce(rhm::journal::jcntl& jc, const size_t minMsgSize,
const size_t maxMsgSize) throw (rhm::journal::jexception)
@@ -111,7 +130,7 @@
}
rhm::journal::data_tok* dtokp = _dtok_master_list[msgCntr];
const void* const msg = (char*)_msg_buff + (msgCntr%10);
-//std::cout << "e" << dtokp->id() << " " << std::flush;
+//std::cout << "e" << dtokp->id() << "-" << dtokp->wstate_str() << " " << std::flush;
bool written = false;
while (!written)
{
@@ -175,10 +194,10 @@
}
_interrupt_flag = false;
//std::cout << std::endl;
- std::cout << std::dec;
- std::cout << "Messages sent = " << _num_msgs << std::endl;
- std::cout << "Total enqueue events = " << _num_msgs_enq << std::endl;
- std::cout << "Total dequeue events = " << _num_msgs_deq << std::endl;
+// std::cout << std::dec;
+// std::cout << "Messages sent = " << _num_msgs << std::endl;
+// std::cout << "Total enqueue events = " << _num_msgs_enq << std::endl;
+// std::cout << "Total dequeue events = " << _num_msgs_deq << std::endl;
//std::cout << std::endl;
return _num_msgs;
}
Modified: store/trunk/cpp/tests/jrnl/msg_producer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-08-30 18:27:45 UTC (rev 901)
+++ store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-08-30 21:42:58 UTC (rev 902)
@@ -81,6 +81,7 @@
void initialize(const u_int32_t numMsgs, bool auto_dequeue);
void initialize(_p_args* args);
+ void finalize();
u_int32_t produce(rhm::journal::jcntl& jc, const size_t minMsgSize, const size_t maxMsgSize)
throw (rhm::journal::jexception);
17 years, 4 months
rhmessaging commits: r901 - store/trunk/cpp/tests.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-08-30 14:27:45 -0400 (Thu, 30 Aug 2007)
New Revision: 901
Modified:
store/trunk/cpp/tests/setup
Log:
Oops, incorrect valgrind suppression got in again! Fixed.
Modified: store/trunk/cpp/tests/setup
===================================================================
--- store/trunk/cpp/tests/setup 2007-08-30 18:26:06 UTC (rev 900)
+++ store/trunk/cpp/tests/setup 2007-08-30 18:27:45 UTC (rev 901)
@@ -19,7 +19,6 @@
vg_options="
--suppressions=$abs_srcdir/.vg-supp
- --suppressions=/usr/lib/valgrind/glibc-2.5.supp
--num-callers=25
--demangle=yes
--track-fds=yes
17 years, 4 months
rhmessaging commits: r900 - in store/trunk/cpp/tests: jrnl and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-08-30 14:26:06 -0400 (Thu, 30 Aug 2007)
New Revision: 900
Modified:
store/trunk/cpp/tests/jrnl/
store/trunk/cpp/tests/jrnl/JournalTest.cpp
store/trunk/cpp/tests/jrnl/Makefile.am
store/trunk/cpp/tests/jrnl/Makefile.rtest
store/trunk/cpp/tests/jrnl/jtest.cpp
store/trunk/cpp/tests/jrnl/jtest.hpp
store/trunk/cpp/tests/setup
Log:
Added jtest methods to directly input test parameters (in addition to csv file), implemented in JournalTest thus removing need for absolute path. Also solved rpm packaging issue.
Property changes on: store/trunk/cpp/tests/jrnl
___________________________________________________________________
Name: svn:ignore
+ .deps
.libs
Makefile
Makefile.in
jtest
Modified: store/trunk/cpp/tests/jrnl/JournalTest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-08-30 18:26:06 UTC (rev 900)
@@ -34,19 +34,18 @@
#include "msg_consumer.hpp"
#include "jtest.hpp"
-#define JTEST_CSV_FILE "/home/kpvdr/store/cpp/tests/jrnl/rwtests.csv"
-
class JournalTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(JournalTest);
- CPPUNIT_TEST(SingleMsgReadWrite);
+ CPPUNIT_TEST(Test_001);
CPPUNIT_TEST_SUITE_END();
public:
- void SingleMsgReadWrite()
+ void Test_001()
{
- jtest t(1);
- t.initialize(JTEST_CSV_FILE);
+ jtest::targs ta(1, 10, 10, false, "Test 1");
+ jtest t;
+ t.initialize(ta);
t.run();
t.report();
t.finalize();
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2007-08-30 18:26:06 UTC (rev 900)
@@ -4,8 +4,6 @@
INCLUDES=-I../../lib
-EXTRA_DIST = ftest.py rwtests.csv
-
TESTS = run-journal-tests
check_LTLIBRARIES = \
@@ -25,3 +23,5 @@
libdlclose_noop_la_SOURCES = ../dlclose_noop.c
libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir)
+
+EXTRA_DIST = $(TESTS) ftest.py
Modified: store/trunk/cpp/tests/jrnl/Makefile.rtest
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-08-30 18:26:06 UTC (rev 900)
@@ -19,48 +19,46 @@
#RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY
#RHM_DEFINES = -DRHM_CLEAN -DRHM_WRONLY
#RHM_DEFINES = -DRHM_CLEAN
-RHM_DEFINES = -DRHM_TESTVALS
+#RHM_DEFINES = -DRHM_TESTVALS
-RHM_JRNL_SRC_DIR = jrnl
-RHM_MGMT_SRC_DIR = mgmt
+RHM_JRNL_SRC_DIR = ../../lib/jrnl
+RHM_JRNL_OBJ_DIR = .lib
RHM_TEST_SRC_DIR = test
-RHM_DOC_DIR = docs
-RHM_JOURNAL_DIR = jdata
-RHM_TESTRES_DIR = ${RHM_TEST_SRC_DIR}/res
-RHM_TESTREF_DIR = ${RHM_TEST_SRC_DIR}/ref
-RHM_TESTREF_TAR = ${RHM_TEST_SRC_DIR}/ref.tar.gz
-
+RHM_TEST_OBJ_DIR = .lib
+#RHM_DOC_DIR = ../../docs
+#RHM_JOURNAL_DIR = jdata
+#
CXXINCLUDES = \
- -I.
+ -I. -I../../lib
JRNL_OBJFILES = \
- $(RHM_JRNL_SRC_DIR)/jexception.o \
- $(RHM_JRNL_SRC_DIR)/jerrno.o \
- $(RHM_JRNL_SRC_DIR)/jinf.o \
- $(RHM_JRNL_SRC_DIR)/enq_map.o \
- $(RHM_JRNL_SRC_DIR)/jdir.o \
- $(RHM_JRNL_SRC_DIR)/data_tok.o \
- $(RHM_JRNL_SRC_DIR)/file_hdr.o \
- $(RHM_JRNL_SRC_DIR)/jrec.o \
- $(RHM_JRNL_SRC_DIR)/data_rec.o \
- $(RHM_JRNL_SRC_DIR)/nlfh.o \
- $(RHM_JRNL_SRC_DIR)/lfh.o \
- $(RHM_JRNL_SRC_DIR)/rrfc.o \
- $(RHM_JRNL_SRC_DIR)/wrfc.o \
- $(RHM_JRNL_SRC_DIR)/pmgr.o \
- $(RHM_JRNL_SRC_DIR)/rmgr.o \
- $(RHM_JRNL_SRC_DIR)/wmgr.o \
- $(RHM_JRNL_SRC_DIR)/jcntl.o \
+ $(RHM_JRNL_OBJ_DIR)/jexception.o \
+ $(RHM_JRNL_OBJ_DIR)/jerrno.o \
+ $(RHM_JRNL_OBJ_DIR)/jinf.o \
+ $(RHM_JRNL_OBJ_DIR)/enq_map.o \
+ $(RHM_JRNL_OBJ_DIR)/jdir.o \
+ $(RHM_JRNL_OBJ_DIR)/data_tok.o \
+ $(RHM_JRNL_OBJ_DIR)/file_hdr.o \
+ $(RHM_JRNL_OBJ_DIR)/jrec.o \
+ $(RHM_JRNL_OBJ_DIR)/data_rec.o \
+ $(RHM_JRNL_OBJ_DIR)/nlfh.o \
+ $(RHM_JRNL_OBJ_DIR)/lfh.o \
+ $(RHM_JRNL_OBJ_DIR)/rrfc.o \
+ $(RHM_JRNL_OBJ_DIR)/wrfc.o \
+ $(RHM_JRNL_OBJ_DIR)/pmgr.o \
+ $(RHM_JRNL_OBJ_DIR)/rmgr.o \
+ $(RHM_JRNL_OBJ_DIR)/wmgr.o \
+ $(RHM_JRNL_OBJ_DIR)/jcntl.o \
JTEST_OBJ_FILES = \
- $(RHM_TEST_SRC_DIR)/jtest.o \
- $(RHM_TEST_SRC_DIR)/msg_producer.o \
- $(RHM_TEST_SRC_DIR)/msg_consumer.o \
+ $(RHM_TEST_OBJ_DIR)/jtest.o \
+ $(RHM_TEST_OBJ_DIR)/msg_producer.o \
+ $(RHM_TEST_OBJ_DIR)/msg_consumer.o \
JTEST_FILES = \
- $(RHM_TEST_SRC_DIR)/jtest \
+ jtest \
-CC = g++
+#CC = gcc
CXX = g++
CXXDEBUGFLAGS = -g -O0
#CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -pedantic -O3 -pthread $(CXXINCLUDES)
@@ -72,108 +70,112 @@
RMDIRS = rm -rf
# These targets are not actual files, only conventient names
-.PHONY: default clean all help clean-all clean-jtest jmgmt clean-jmgmt jrnl clean-jrnl docs clean-docs test
+.PHONY: jrtest jwtest jrwtest
# Default build operation
default: jtest
-# Default clean operation
-clean: clean-jtest clean-jmgmt clean-jrnl clean-core-files
+## Default clean operation
+#clean: clean-jtest clean-jmgmt clean-jrnl clean-core-files
-all: jrnl jmgmt jtest aiotest docs test
+#all: jrnl jmgmt jtest aiotest docs test
-clean-all: clean-jtest clean-jmgmt clean-jrnl clean-docs clean-jdata clean-core-files
+#clean-all: clean-jtest clean-jmgmt clean-jrnl clean-docs clean-jdata clean-core-files
-# Print make options
-help:
- @echo "The following make options are available: (* is default)"
- @echo " Make operations: "
- @echo " all: Make everything"
- @echo " help: This message"
- @echo " *jtest: Make the journal test suite"
- @echo " jrtest: Make the journal test suite for read tests"
- @echo " jwtest: Make the journal test suite for write tests"
- @echo " jmgmt: Make the jouranl management utils"
- @echo " jrnl: Build the journal library"
- @echo " docs: Make the doxygen docs"
- @echo " test: Run regression test suite"
- @echo " Clean operations: "
- @echo " clean: Clean most things (not docs or journal data)"
- @echo " clean-all: Blow it *all* away!"
- @echo " clean-jtest: Clean journal tests and test support files"
- @echo " clean-jmgmt: Clean management utils"
- @echo " clean-jrnl: Clean journal object files"
- @echo " clean-docs: Blow the docs dir away"
- @echo " clean-jdata: Clear all jouranl data files"
+## Print make options
+#help:
+# @echo "The following make options are available: (* is default)"
+# @echo " Make operations: "
+# @echo " all: Make everything"
+# @echo " help: This message"
+# @echo " *jtest: Make the journal test suite"
+# @echo " jrtest: Make the journal test suite for read tests"
+# @echo " jwtest: Make the journal test suite for write tests"
+# @echo " jmgmt: Make the jouranl management utils"
+# @echo " jrnl: Build the journal library"
+# @echo " docs: Make the doxygen docs"
+# @echo " test: Run regression test suite"
+# @echo " Clean operations: "
+# @echo " clean: Clean most things (not docs or journal data)"
+# @echo " clean-all: Blow it *all* away!"
+# @echo " clean-jtest: Clean journal tests and test support files"
+# @echo " clean-jmgmt: Clean management utils"
+# @echo " clean-jrnl: Clean journal object files"
+# @echo " clean-docs: Blow the docs dir away"
+# @echo " clean-jdata: Clear all jouranl data files"
+#
+## Run regression test script
+#test: jtest #ref
+# @./rtest
+#
+#ref: $(RHM_TESTREF_DIR)
+#
+#$(RHM_TESTREF_DIR): $(RHM_TESTREF_TAR)
+# @tar -C $(RHM_TEST_SRC_DIR) -xzf $(RHM_TESTREF_TAR)
+#
+## Build all journal and test object files, produces jtest executable
+#jtest: $(JTEST_FILES)
-# Run regression test script
-test: jtest #ref
- @./rtest
+#jrtest: RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY -DRHM_TESTVALS
+#jrtest: $(JTEST_FILES)
-ref: $(RHM_TESTREF_DIR)
-
-$(RHM_TESTREF_DIR): $(RHM_TESTREF_TAR)
- @tar -C $(RHM_TEST_SRC_DIR) -xzf $(RHM_TESTREF_TAR)
-
-# Build all journal and test object files, produces jtest executable
-jtest: $(JTEST_FILES)
-
-jrtest: RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY -DRHM_TESTVALS
-jrtest: $(JTEST_FILES)
-
jwtest: RHM_DEFINES = -DRHM_CLEAN -DRHM_WRONLY -DRHM_TESTVALS
jwtest: $(JTEST_FILES)
-jrwtest: RHM_DEFINES = -DRHM_CLEAN -DRHM_TESTVALS
-jrwtest: $(JTEST_FILES)
+#jrwtest: RHM_DEFINES = -DRHM_CLEAN -DRHM_TESTVALS
+#jrwtest: $(JTEST_FILES)
$(JTEST_FILES): $(JRNL_OBJFILES) $(JTEST_OBJ_FILES)
-# Clean all journal test executables and build artifacts
-clean-jtest:
- @-$(RM) $(RHM_TEST_SRC_DIR)/*~
- @-$(RM) $(JTEST_OBJ_FILES)
- @-$(RM) $(JTEST_FILES)
- @-$(RMDIRS) $(RHM_TESTRES_DIR)
-# @-$(RMDIRS) $(RHM_TESTREF_DIR)
+#$(JRNL_OBJFILES): $(RHM_JRNL_SRC_DIR)/$(*F)
-# Build management utilities
-jmgmt: $(MGMT_FILES)
+#$(JTEST_OBJ_FILES): $(RHM_TEST_SRC_DIR)/$(*F)
-$(MGMT_FILES): $(JRNL_OBJFILES) $(MGMT_OBJ_FILES)
-
-# Clean up all management utility build and edit artifacts
-clean-jmgmt:
- @-$(RM) $(RHM_MGMT_SRC_DIR)/*~
- @-$(RM) $(MGMT_OBJ_FILES)
- @-$(RM) $(MGMT_FILES)
-
-# Builds just the journal object files. No executable is produced
-jrnl: $(JRNL_OBJFILES)
-
-# Clean up all journal build and edit artifacts
-clean-jrnl:
- @-$(RM) $(RHM_JRNL_SRC_DIR)/*~
- @-$(RM) $(JRNL_OBJFILES)
-
-# Build all Doxygen docs, produce a pdf and ps file from the latex output
-docs:
- @mkdir -p $(RHM_DOC_DIR)
- @doxygen test_tmpl.dox
- @make -C $(RHM_DOC_DIR)/latex
- @cd $(RHM_DOC_DIR)/latex; dvipdf refman.dvi refman.pdf
- @cd $(RHM_DOC_DIR)/latex; dvips refman.dvi -o refman.ps
-
-# Clean up all Doxygen docs located in $(RHM_DOC_DIR)
-clean-docs:
- @-$(RMDIRS) $(RHM_DOC_DIR)
-
-# Clean up journal artifacts located in $(RHM_JOURNAL_DIR)
-clean-jdata:
- @-$(RMDIRS) $(RHM_JOURNAL_DIR)
- @-$(RMDIRS) $(RHM_RTEST_DIR)
-
-# Find and remove any core files lying around
-clean-core-files:
- @-$(RM) core*
- @-$(RM) vgcore*
+## Clean all journal test executables and build artifacts
+#clean-jtest:
+# @-$(RM) $(RHM_TEST_SRC_DIR)/*~
+# @-$(RM) $(JTEST_OBJ_FILES)
+# @-$(RM) $(JTEST_FILES)
+# @-$(RMDIRS) $(RHM_TESTRES_DIR)
+## @-$(RMDIRS) $(RHM_TESTREF_DIR)
+#
+## Build management utilities
+#jmgmt: $(MGMT_FILES)
+#
+#$(MGMT_FILES): $(JRNL_OBJFILES) $(MGMT_OBJ_FILES)
+#
+## Clean up all management utility build and edit artifacts
+#clean-jmgmt:
+# @-$(RM) $(RHM_MGMT_SRC_DIR)/*~
+# @-$(RM) $(MGMT_OBJ_FILES)
+# @-$(RM) $(MGMT_FILES)
+#
+## Builds just the journal object files. No executable is produced
+#jrnl: $(JRNL_OBJFILES)
+#
+## Clean up all journal build and edit artifacts
+#clean-jrnl:
+# @-$(RM) $(RHM_JRNL_SRC_DIR)/*~
+# @-$(RM) $(JRNL_OBJFILES)
+#
+## Build all Doxygen docs, produce a pdf and ps file from the latex output
+#docs:
+# @mkdir -p $(RHM_DOC_DIR)
+# @doxygen test_tmpl.dox
+# @make -C $(RHM_DOC_DIR)/latex
+# @cd $(RHM_DOC_DIR)/latex; dvipdf refman.dvi refman.pdf
+# @cd $(RHM_DOC_DIR)/latex; dvips refman.dvi -o refman.ps
+#
+## Clean up all Doxygen docs located in $(RHM_DOC_DIR)
+#clean-docs:
+# @-$(RMDIRS) $(RHM_DOC_DIR)
+#
+## Clean up journal artifacts located in $(RHM_JOURNAL_DIR)
+#clean-jdata:
+# @-$(RMDIRS) $(RHM_JOURNAL_DIR)
+# @-$(RMDIRS) $(RHM_RTEST_DIR)
+#
+## Find and remove any core files lying around
+#clean-core-files:
+# @-$(RM) core*
+# @-$(RM) vgcore*
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-08-30 18:26:06 UTC (rev 900)
@@ -51,8 +51,8 @@
assert(tnum >= 0);
std::cout << "Test data file: \"" << test_csv_file << "\"" << std::endl;
cout << "jtest: starting test " << tnum << endl;
- jtest t(tnum);
- t.initialize(test_csv_file);
+ jtest t;
+ t.initialize(tnum, test_csv_file);
t.run();
t.report();
t.finalize();
@@ -68,11 +68,27 @@
return 0;
}
-jtest::jtest(int tnum) throw (rhm::journal::jexception):
+jtest::targs::targs():
+ _num_msgs(0),
+ _min_msg_size(0),
+ _max_msg_size(0),
+ _auto_deq(false),
+ _comment(NULL)
+{}
+
+jtest::targs::targs(const u_int32_t num_msgs, const size_t min_msg_size, const size_t max_msg_size, const bool auto_deq,
+ const char* comment):
+ _num_msgs(num_msgs),
+ _min_msg_size(min_msg_size),
+ _max_msg_size(max_msg_size),
+ _auto_deq(auto_deq),
+ _comment(comment)
+{}
+
+jtest::jtest() throw (rhm::journal::jexception):
_start_time(new timeval),
_end_time(new timeval),
- _tz_ptr(NULL),
- _tnum(tnum)
+ _tz_ptr(NULL)
{}
jtest::~jtest()
@@ -92,12 +108,18 @@
}
void
-jtest::initialize(const char* test_csv_file) throw (rhm::journal::jexception)
+jtest::initialize(const int test_num, const char* test_csv_file) throw (rhm::journal::jexception)
{
+ targs ta;
+ jtest::get_test(&ta, std::string(test_csv_file), test_num);
+ initialize(ta);
+}
+
+void
+jtest::initialize(const targs& ta) throw (rhm::journal::jexception)
+{
gettimeofday(_start_time, _tz_ptr);
- targs ta;
- jtest::get_test(&ta, std::string(test_csv_file), _tnum);
p_args = new msg_producer::_p_args(_jc, ta._num_msgs, ta._min_msg_size, ta._max_msg_size,
ta._auto_deq);
c_args = new msg_consumer::_c_args(_jc, ta._num_msgs, ta._min_msg_size, ta._max_msg_size);
@@ -293,9 +315,9 @@
tap->_max_msg_size = atol(toks[3]);
tap->_auto_deq = strcmp(toks[4], "FALSE") != 0;
if (toks.size() > 5)
- tap->_comment = std::string(toks[5]);
+ tap->_comment = toks[5];
else
- tap->_comment = std::string();
+ tap->_comment = NULL;
std::cout << "Test " << tnum << ": Messages=" << tap->_num_msgs << " Size=" <<
tap->_min_msg_size;
if (tap->_min_msg_size == tap->_max_msg_size)
@@ -303,7 +325,7 @@
else
std::cout << " - " << tap->_max_msg_size << " (random)";
std::cout << (tap->_auto_deq ? " auto-dequeue" : " no dequeue");
- if (tap->_comment.size())
+ if (tap->_comment)
std::cout << " [" << tap->_comment << "]";
std::cout << std::endl;
}
Modified: store/trunk/cpp/tests/jrnl/jtest.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.hpp 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/jrnl/jtest.hpp 2007-08-30 18:26:06 UTC (rev 900)
@@ -55,7 +55,10 @@
size_t _min_msg_size;
size_t _max_msg_size;
bool _auto_deq;
- std::string _comment;
+ const char* _comment;
+ targs();
+ targs(const u_int32_t num_msgs, const size_t min_msg_size, const size_t max_msg_size, const bool auto_deq = false,
+ const char* comment = NULL);
};
private:
@@ -69,19 +72,18 @@
struct timezone* _tz_ptr;
pthread_t _p_thread;
pthread_t _c_thread;
- int _tnum;
public:
- jtest(int test_num) throw (rhm::journal::jexception);
+ jtest() throw (rhm::journal::jexception);
~jtest();
static void proc_args(int argc, char** argv, char** test_file_name, int* test_num)
throw (rhm::journal::jexception);
- void initialize(const char* test_csv_file) throw (rhm::journal::jexception);
+ void initialize(const int test_num, const char* test_csv_file) throw (rhm::journal::jexception);
+ void initialize(const targs& ta) throw (rhm::journal::jexception);
void run() throw (rhm::journal::jexception);
void report() throw (rhm::journal::jexception);
void finalize() throw (rhm::journal::jexception);
- inline const int test_num() const { return _tnum; }
static void get_test(targs* tap, const std::string& filename, const unsigned test_num)
throw (rhm::journal::jexception);
static void print_compile_defs(bool verbose);
Modified: store/trunk/cpp/tests/setup
===================================================================
--- store/trunk/cpp/tests/setup 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/setup 2007-08-30 18:26:06 UTC (rev 900)
@@ -19,6 +19,7 @@
vg_options="
--suppressions=$abs_srcdir/.vg-supp
+ --suppressions=/usr/lib/valgrind/glibc-2.5.supp
--num-callers=25
--demangle=yes
--track-fds=yes
17 years, 4 months
rhmessaging commits: r899 - in store/trunk/cpp: tests and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-08-30 10:30:17 -0400 (Thu, 30 Aug 2007)
New Revision: 899
Removed:
store/trunk/cpp/jrnl/
Modified:
store/trunk/cpp/tests/setup
Log:
Removed extra valgrind supression that should not have made it into the repository
Modified: store/trunk/cpp/tests/setup
===================================================================
--- store/trunk/cpp/tests/setup 2007-08-30 13:40:45 UTC (rev 898)
+++ store/trunk/cpp/tests/setup 2007-08-30 14:30:17 UTC (rev 899)
@@ -19,7 +19,6 @@
vg_options="
--suppressions=$abs_srcdir/.vg-supp
- --suppressions=/usr/lib/valgrind/glibc-2.5.supp
--num-callers=25
--demangle=yes
--track-fds=yes
17 years, 4 months
rhmessaging commits: r898 - in store/trunk/cpp: docs and 5 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-08-30 09:40:45 -0400 (Thu, 30 Aug 2007)
New Revision: 898
Added:
store/trunk/cpp/docs/
store/trunk/cpp/docs/jrnl_tmpl.dox
store/trunk/cpp/lib/jrnl/
store/trunk/cpp/lib/jrnl/README
store/trunk/cpp/lib/jrnl/aio_cb.hpp
store/trunk/cpp/lib/jrnl/data_rec.cpp
store/trunk/cpp/lib/jrnl/data_rec.hpp
store/trunk/cpp/lib/jrnl/data_tok.cpp
store/trunk/cpp/lib/jrnl/data_tok.hpp
store/trunk/cpp/lib/jrnl/enq_map.cpp
store/trunk/cpp/lib/jrnl/enq_map.hpp
store/trunk/cpp/lib/jrnl/file_hdr.cpp
store/trunk/cpp/lib/jrnl/file_hdr.hpp
store/trunk/cpp/lib/jrnl/jcfg.hpp
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jcntl.hpp
store/trunk/cpp/lib/jrnl/jdir.cpp
store/trunk/cpp/lib/jrnl/jdir.hpp
store/trunk/cpp/lib/jrnl/jerrno.cpp
store/trunk/cpp/lib/jrnl/jerrno.hpp
store/trunk/cpp/lib/jrnl/jexception.cpp
store/trunk/cpp/lib/jrnl/jexception.hpp
store/trunk/cpp/lib/jrnl/jinf.cpp
store/trunk/cpp/lib/jrnl/jinf.hpp
store/trunk/cpp/lib/jrnl/jrec.cpp
store/trunk/cpp/lib/jrnl/jrec.hpp
store/trunk/cpp/lib/jrnl/lfh.cpp
store/trunk/cpp/lib/jrnl/lfh.hpp
store/trunk/cpp/lib/jrnl/nlfh.cpp
store/trunk/cpp/lib/jrnl/nlfh.hpp
store/trunk/cpp/lib/jrnl/pmgr.cpp
store/trunk/cpp/lib/jrnl/pmgr.hpp
store/trunk/cpp/lib/jrnl/rmgr.cpp
store/trunk/cpp/lib/jrnl/rmgr.hpp
store/trunk/cpp/lib/jrnl/rrfc.cpp
store/trunk/cpp/lib/jrnl/rrfc.hpp
store/trunk/cpp/lib/jrnl/wmgr.cpp
store/trunk/cpp/lib/jrnl/wmgr.hpp
store/trunk/cpp/lib/jrnl/wrfc.cpp
store/trunk/cpp/lib/jrnl/wrfc.hpp
store/trunk/cpp/tests/jrnl/
store/trunk/cpp/tests/jrnl/JournalTest.cpp
store/trunk/cpp/tests/jrnl/Makefile.am
store/trunk/cpp/tests/jrnl/Makefile.rtest
store/trunk/cpp/tests/jrnl/chk_jdata
store/trunk/cpp/tests/jrnl/cp_rtest_jrnl
store/trunk/cpp/tests/jrnl/ftest.py
store/trunk/cpp/tests/jrnl/jtest.cpp
store/trunk/cpp/tests/jrnl/jtest.hpp
store/trunk/cpp/tests/jrnl/msg_consumer.cpp
store/trunk/cpp/tests/jrnl/msg_consumer.hpp
store/trunk/cpp/tests/jrnl/msg_producer.cpp
store/trunk/cpp/tests/jrnl/msg_producer.hpp
store/trunk/cpp/tests/jrnl/prof
store/trunk/cpp/tests/jrnl/rtest
store/trunk/cpp/tests/jrnl/rtests.csv
store/trunk/cpp/tests/jrnl/run-journal-tests
store/trunk/cpp/tests/jrnl/rwtests.csv
store/trunk/cpp/tests/jrnl/tests.ods
store/trunk/cpp/tests/jrnl/wtests.csv
Removed:
store/trunk/cpp/jrnl/COPYING
store/trunk/cpp/jrnl/Makefile
store/trunk/cpp/jrnl/README
store/trunk/cpp/jrnl/jrnl/
store/trunk/cpp/jrnl/jtest
store/trunk/cpp/jrnl/prof
store/trunk/cpp/jrnl/rtest
store/trunk/cpp/jrnl/test/
store/trunk/cpp/jrnl/test_tmpl.dox
Modified:
store/trunk/cpp/configure.ac
store/trunk/cpp/lib/Makefile.am
store/trunk/cpp/tests/Makefile.am
store/trunk/cpp/tests/setup
Log:
Reorganization of journal code to fit under existing structure; initial simple journal test included.
Modified: store/trunk/cpp/configure.ac
===================================================================
--- store/trunk/cpp/configure.ac 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/configure.ac 2007-08-30 13:40:45 UTC (rev 898)
@@ -8,7 +8,7 @@
dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-AC_INIT([rhm], [0.2], [qpid-dev(a)incubator.apache.org])
+AC_INIT([rhm], [0.2], [rhm-users(a)redhat.com])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([dist-bzip2])
@@ -34,7 +34,7 @@
# Warnings: Enable as many as possible, keep the code clean. Please
# do not disable warnings or remove -Werror without discussing on
-# qpid-dev list.
+# rhm-users list.
#
# The following warnings are deliberately omitted, they warn on valid code.
# -Wunreachable-code -Wpadded -Winline
@@ -87,6 +87,13 @@
AC_SUBST([QPID_DIR])
AC_SUBST([QPID_LIBS])
AC_SUBST([QPID_CXXFLAGS])
+
+# Check for libaio and libaio-devel
+libaio_fail=0
+AC_CHECK_LIB([aio], [io_setup], ,[libaio_fail=1])
+AC_CHECK_HEADER([libaio.h], ,[libaio_fail=1])
+test $libaio_fail == 1 && \
+ AC_MSG_ERROR([libaio-devel package missing. Please ensure both libaio and libaio-devel are installed. (hint: yum install libaio-devel should do it...)])
# For libraries (libcommon) that use dlopen, dlerror, etc.,
# test whether we need to link with -ldl.
@@ -161,6 +168,7 @@
rhm.spec
Makefile
tests/Makefile
+ tests/jrnl/Makefile
lib/Makefile
])
Copied: store/trunk/cpp/docs/jrnl_tmpl.dox (from rev 891, store/trunk/cpp/jrnl/test_tmpl.dox)
===================================================================
--- store/trunk/cpp/docs/jrnl_tmpl.dox (rev 0)
+++ store/trunk/cpp/docs/jrnl_tmpl.dox 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,1252 @@
+# Doxyfile 1.5.1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = "Red Hat Messaging Journal (RHMJ)"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = docs
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian,
+# Italian, Japanese, Japanese-en (Japanese with English messages), Korean,
+# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian,
+# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE = English
+
+# This tag can be used to specify the encoding used in the generated output.
+# The encoding is not always determined by the language that is chosen,
+# but also whether or not the output is meant for Windows or non-Windows users.
+# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
+# forces the Windows encoding (this is the default for the Windows binary),
+# whereas setting the tag to NO uses a Unix-style encoding (the default for
+# all platforms other than Windows).
+
+USE_WINDOWS_ENCODING = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like the Qt-style comments (thus requiring an
+# explicit @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member
+# documentation.
+
+DETAILS_AT_TOP = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 4
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for Java.
+# For instance, namespaces will be presented as packages, qualified scopes
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to
+# include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = YES
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from the
+# version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = YES
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = jrnl
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
+
+FILE_PATTERNS = *.cpp *.hpp
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output. If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default)
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default)
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code. Otherwise they will link to the documentstion.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = YES
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader. This is useful
+# if you want to understand what is going on. On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
+# generate a call dependency graph for every global function or class method.
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will
+# generate a caller dependency graph for every global function or class method.
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than
+# this value, doxygen will try to truncate the graph, so that it fits within
+# the specified constraint. Beware that most browsers cannot cope with very
+# large images.
+
+MAX_DOT_GRAPH_WIDTH = 1024
+
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than
+# this value, doxygen will try to truncate the graph, so that it fits within
+# the specified constraint. Beware that most browsers cannot cope with very
+# large images.
+
+MAX_DOT_GRAPH_HEIGHT = 1024
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that a graph may be further truncated if the graph's
+# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH
+# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default),
+# the graph is not depth-constrained.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, which results in a white background.
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE = NO
Deleted: store/trunk/cpp/jrnl/COPYING
===================================================================
--- store/trunk/cpp/jrnl/COPYING 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/jrnl/COPYING 2007-08-30 13:40:45 UTC (rev 898)
@@ -1,458 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
Deleted: store/trunk/cpp/jrnl/Makefile
===================================================================
--- store/trunk/cpp/jrnl/Makefile 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/jrnl/Makefile 2007-08-30 13:40:45 UTC (rev 898)
@@ -1,179 +0,0 @@
-# RHM_DEFINES
-# The following defines are usable during the build of rhmj:
-# RHM_CLEAN: Writes 0x00 to all unused disk space bytes. This makes debugging easier,
-# but the memcpy required incurs a performance penalty. Do not use for
-# production or performance checks.
-# RHM_TESTVALS: Uses special values (e.g. RIDs starting at 0xffeeddcc00000000 rather than 0)
-# for testing purposes, or to expose special test conditions.
-# RHM_JOWRITE: Defeats the relocation of previous journal files into a subdir, makes
-# the execution quicker provided the files are of the same size as previous
-# run. If the files are not present, they will be created.
-# RHM_WRONLY: Defeats the test which check that a journal file has been read before it
-# overwritten. NOTE: ONLY USE FOR PERFORMANCE TESTS!
-# RHM_RDONLY: Defeats the test which check that a journal file has been written before it
-# read. Use together with RHM_JOWRITE if test reads from previously written
-# journal. Ensure journal contains valid entries in all files. NOTE: ONLY USE
-# FOR PERFORMANCE TESTS!
-# Prefix each define with -D. (eg RHM_DEFINES = -DRHM_JOWRITE -DRHM_WRONLY)
-#RHM_DEFINES = -DRHM_WRONLY
-#RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY
-#RHM_DEFINES = -DRHM_CLEAN -DRHM_WRONLY
-#RHM_DEFINES = -DRHM_CLEAN
-RHM_DEFINES = -DRHM_TESTVALS
-
-RHM_JRNL_SRC_DIR = jrnl
-RHM_MGMT_SRC_DIR = mgmt
-RHM_TEST_SRC_DIR = test
-RHM_DOC_DIR = docs
-RHM_JOURNAL_DIR = jdata
-RHM_TESTRES_DIR = ${RHM_TEST_SRC_DIR}/res
-RHM_TESTREF_DIR = ${RHM_TEST_SRC_DIR}/ref
-RHM_TESTREF_TAR = ${RHM_TEST_SRC_DIR}/ref.tar.gz
-
-CXXINCLUDES = \
- -I.
-
-JRNL_OBJFILES = \
- $(RHM_JRNL_SRC_DIR)/jexception.o \
- $(RHM_JRNL_SRC_DIR)/jerrno.o \
- $(RHM_JRNL_SRC_DIR)/jinf.o \
- $(RHM_JRNL_SRC_DIR)/enq_map.o \
- $(RHM_JRNL_SRC_DIR)/jdir.o \
- $(RHM_JRNL_SRC_DIR)/data_tok.o \
- $(RHM_JRNL_SRC_DIR)/file_hdr.o \
- $(RHM_JRNL_SRC_DIR)/jrec.o \
- $(RHM_JRNL_SRC_DIR)/data_rec.o \
- $(RHM_JRNL_SRC_DIR)/nlfh.o \
- $(RHM_JRNL_SRC_DIR)/lfh.o \
- $(RHM_JRNL_SRC_DIR)/rrfc.o \
- $(RHM_JRNL_SRC_DIR)/wrfc.o \
- $(RHM_JRNL_SRC_DIR)/pmgr.o \
- $(RHM_JRNL_SRC_DIR)/rmgr.o \
- $(RHM_JRNL_SRC_DIR)/wmgr.o \
- $(RHM_JRNL_SRC_DIR)/jcntl.o \
-
-JTEST_OBJ_FILES = \
- $(RHM_TEST_SRC_DIR)/jtest.o \
- $(RHM_TEST_SRC_DIR)/msg_producer.o \
- $(RHM_TEST_SRC_DIR)/msg_consumer.o \
-
-JTEST_FILES = \
- $(RHM_TEST_SRC_DIR)/jtest \
-
-CC = g++
-CXX = g++
-CXXDEBUGFLAGS = -g -O0
-#CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -pedantic -O3 -pthread $(CXXINCLUDES)
-CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -pedantic -ggdb -O0 -pthread $(CXXINCLUDES)
-LDFLAGS = -lpthread -laio -lrt
-LDLIBS =
-
-RM = rm -f
-RMDIRS = rm -rf
-
-# These targets are not actual files, only conventient names
-.PHONY: default clean all help clean-all clean-jtest jmgmt clean-jmgmt jrnl clean-jrnl docs clean-docs test
-
-# Default build operation
-default: jtest
-
-# Default clean operation
-clean: clean-jtest clean-jmgmt clean-jrnl clean-core-files
-
-all: jrnl jmgmt jtest aiotest docs test
-
-clean-all: clean-jtest clean-jmgmt clean-jrnl clean-docs clean-jdata clean-core-files
-
-# Print make options
-help:
- @echo "The following make options are available: (* is default)"
- @echo " Make operations: "
- @echo " all: Make everything"
- @echo " help: This message"
- @echo " *jtest: Make the journal test suite"
- @echo " jrtest: Make the journal test suite for read tests"
- @echo " jwtest: Make the journal test suite for write tests"
- @echo " jmgmt: Make the jouranl management utils"
- @echo " jrnl: Build the journal library"
- @echo " docs: Make the doxygen docs"
- @echo " test: Run regression test suite"
- @echo " Clean operations: "
- @echo " clean: Clean most things (not docs or journal data)"
- @echo " clean-all: Blow it *all* away!"
- @echo " clean-jtest: Clean journal tests and test support files"
- @echo " clean-jmgmt: Clean management utils"
- @echo " clean-jrnl: Clean journal object files"
- @echo " clean-docs: Blow the docs dir away"
- @echo " clean-jdata: Clear all jouranl data files"
-
-# Run regression test script
-test: jtest #ref
- @./rtest
-
-ref: $(RHM_TESTREF_DIR)
-
-$(RHM_TESTREF_DIR): $(RHM_TESTREF_TAR)
- @tar -C $(RHM_TEST_SRC_DIR) -xzf $(RHM_TESTREF_TAR)
-
-# Build all journal and test object files, produces jtest executable
-jtest: $(JTEST_FILES)
-
-jrtest: RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY -DRHM_TESTVALS
-jrtest: $(JTEST_FILES)
-
-jwtest: RHM_DEFINES = -DRHM_CLEAN -DRHM_WRONLY -DRHM_TESTVALS
-jwtest: $(JTEST_FILES)
-
-jrwtest: RHM_DEFINES = -DRHM_CLEAN -DRHM_TESTVALS
-jrwtest: $(JTEST_FILES)
-
-$(JTEST_FILES): $(JRNL_OBJFILES) $(JTEST_OBJ_FILES)
-
-# Clean all journal test executables and build artifacts
-clean-jtest:
- @-$(RM) $(RHM_TEST_SRC_DIR)/*~
- @-$(RM) $(JTEST_OBJ_FILES)
- @-$(RM) $(JTEST_FILES)
- @-$(RMDIRS) $(RHM_TESTRES_DIR)
-# @-$(RMDIRS) $(RHM_TESTREF_DIR)
-
-# Build management utilities
-jmgmt: $(MGMT_FILES)
-
-$(MGMT_FILES): $(JRNL_OBJFILES) $(MGMT_OBJ_FILES)
-
-# Clean up all management utility build and edit artifacts
-clean-jmgmt:
- @-$(RM) $(RHM_MGMT_SRC_DIR)/*~
- @-$(RM) $(MGMT_OBJ_FILES)
- @-$(RM) $(MGMT_FILES)
-
-# Builds just the journal object files. No executable is produced
-jrnl: $(JRNL_OBJFILES)
-
-# Clean up all journal build and edit artifacts
-clean-jrnl:
- @-$(RM) $(RHM_JRNL_SRC_DIR)/*~
- @-$(RM) $(JRNL_OBJFILES)
-
-# Build all Doxygen docs, produce a pdf and ps file from the latex output
-docs:
- @mkdir -p $(RHM_DOC_DIR)
- @doxygen test_tmpl.dox
- @make -C $(RHM_DOC_DIR)/latex
- @cd $(RHM_DOC_DIR)/latex; dvipdf refman.dvi refman.pdf
- @cd $(RHM_DOC_DIR)/latex; dvips refman.dvi -o refman.ps
-
-# Clean up all Doxygen docs located in $(RHM_DOC_DIR)
-clean-docs:
- @-$(RMDIRS) $(RHM_DOC_DIR)
-
-# Clean up journal artifacts located in $(RHM_JOURNAL_DIR)
-clean-jdata:
- @-$(RMDIRS) $(RHM_JOURNAL_DIR)
- @-$(RMDIRS) $(RHM_RTEST_DIR)
-
-# Find and remove any core files lying around
-clean-core-files:
- @-$(RM) core*
- @-$(RM) vgcore*
Deleted: store/trunk/cpp/jrnl/README
===================================================================
--- store/trunk/cpp/jrnl/README 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/jrnl/README 2007-08-30 13:40:45 UTC (rev 898)
@@ -1,34 +0,0 @@
-MESSAGE JOURNAL
-===============
-This directory contains the source for the messaging journal. It is not yet integrated with the
-rest of the store source.
-
-External dependencies:
-----------------------
-libaio-dev
-
-Building:
----------
-"make clean-all" then "make" To see all make options, run "make help".
-
-NOTE: This makefile is a manually created file, not a part of automake/autoconf (yet). It does not
-have complete dependency checking, so if a header file is changed, a clean make should be performed
-manually.
-
-Testing:
---------
-The tests are defined in jtest.cpp, and are numbered from 0 to 40 (more or less). To run an
-individual test, run "./jtest -t <testnum>" where testnum is the requried test number.
-
-To analyze the journal files (which are written to a new jdata dir)
-
-To run regression tests which go through all the tests repeatedly and analyse the results, run
-"rtest". This can take some time, especially for the valgrind check (the '*'
-symbol) on tests 33 and above.
-
-Directories:
-------------
-jrnl: Contains the journal source code.
-test: Contains the journal test framework and test utils.
-jdata: This dir is created when the tests are run, it contains the jorunal data files.
-docs: This dir contains the doxygen docs, created when running "make docs".
Deleted: store/trunk/cpp/jrnl/jtest
===================================================================
--- store/trunk/cpp/jrnl/jtest 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/jrnl/jtest 2007-08-30 13:40:45 UTC (rev 898)
@@ -1 +0,0 @@
-link test/jtest
\ No newline at end of file
Deleted: store/trunk/cpp/jrnl/prof
===================================================================
--- store/trunk/cpp/jrnl/prof 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/jrnl/prof 2007-08-30 13:40:45 UTC (rev 898)
@@ -1 +0,0 @@
-link test/prof
\ No newline at end of file
Deleted: store/trunk/cpp/jrnl/rtest
===================================================================
--- store/trunk/cpp/jrnl/rtest 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/jrnl/rtest 2007-08-30 13:40:45 UTC (rev 898)
@@ -1 +0,0 @@
-link test/rtest
\ No newline at end of file
Deleted: store/trunk/cpp/jrnl/test_tmpl.dox
===================================================================
--- store/trunk/cpp/jrnl/test_tmpl.dox 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/jrnl/test_tmpl.dox 2007-08-30 13:40:45 UTC (rev 898)
@@ -1,1252 +0,0 @@
-# Doxyfile 1.5.1
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-# TAG = value [value, ...]
-# For lists items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
-
-PROJECT_NAME = "Red Hat Messaging Journal (RHMJ)"
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-# if some version control system is used.
-
-PROJECT_NUMBER =
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
-# base path where the generated documentation will be put.
-# If a relative path is entered, it will be relative to the location
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY = docs
-
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
-# 4096 sub-directories (in 2 levels) under the output directory of each output
-# format and will distribute the generated files over these directories.
-# Enabling this option can be useful when feeding doxygen a huge amount of
-# source files, where putting all generated files in the same directory would
-# otherwise cause performance problems for the file system.
-
-CREATE_SUBDIRS = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# The default language is English, other supported languages are:
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
-# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian,
-# Italian, Japanese, Japanese-en (Japanese with English messages), Korean,
-# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian,
-# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
-
-OUTPUT_LANGUAGE = English
-
-# This tag can be used to specify the encoding used in the generated output.
-# The encoding is not always determined by the language that is chosen,
-# but also whether or not the output is meant for Windows or non-Windows users.
-# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
-# forces the Windows encoding (this is the default for the Windows binary),
-# whereas setting the tag to NO uses a Unix-style encoding (the default for
-# all platforms other than Windows).
-
-USE_WINDOWS_ENCODING = NO
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
-# include brief member descriptions after the members that are listed in
-# the file and class documentation (similar to JavaDoc).
-# Set to NO to disable this.
-
-BRIEF_MEMBER_DESC = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
-# the brief description of a member or function before the detailed description.
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-
-REPEAT_BRIEF = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator
-# that is used to form the text in various listings. Each string
-# in this list, if found as the leading text of the brief description, will be
-# stripped from the text and the result after processing the whole list, is
-# used as the annotated text. Otherwise, the brief description is used as-is.
-# If left blank, the following values are used ("$name" is automatically
-# replaced with the name of the entity): "The $name class" "The $name widget"
-# "The $name file" "is" "provides" "specifies" "contains"
-# "represents" "a" "an" "the"
-
-ABBREVIATE_BRIEF =
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# Doxygen will generate a detailed section even if there is only a brief
-# description.
-
-ALWAYS_DETAILED_SEC = NO
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
-# inherited members of a class in the documentation of that class as if those
-# members were ordinary class members. Constructors, destructors and assignment
-# operators of the base classes will not be shown.
-
-INLINE_INHERITED_MEMB = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
-# path before files name in the file list and in the header files. If set
-# to NO the shortest path that makes the file name unique will be used.
-
-FULL_PATH_NAMES = YES
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
-# can be used to strip a user-defined part of the path. Stripping is
-# only done if one of the specified strings matches the left-hand part of
-# the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the
-# path to strip.
-
-STRIP_FROM_PATH =
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
-# the path mentioned in the documentation of a class, which tells
-# the reader which header file to include in order to use a class.
-# If left blank only the name of the header file containing the class
-# definition is used. Otherwise one should specify the include paths that
-# are normally passed to the compiler using the -I flag.
-
-STRIP_FROM_INC_PATH =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
-SHORT_NAMES = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
-# will interpret the first line (until the first dot) of a JavaDoc-style
-# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like the Qt-style comments (thus requiring an
-# explicit @brief command for a brief description.
-
-JAVADOC_AUTOBRIEF = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
-# treat a multi-line C++ special comment block (i.e. a block of //! or ///
-# comments) as a brief description. This used to be the default behaviour.
-# The new default is to treat a multi-line C++ comment block as a detailed
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the DETAILS_AT_TOP tag is set to YES then Doxygen
-# will output the detailed description near the top, like JavaDoc.
-# If set to NO, the detailed description appears after the member
-# documentation.
-
-DETAILS_AT_TOP = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
-# member inherits the documentation from any documented member that it
-# re-implements.
-
-INHERIT_DOCS = YES
-
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
-# a new page for each member. If set to NO, the documentation of a member will
-# be part of the file/class/namespace that contains it.
-
-SEPARATE_MEMBER_PAGES = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab.
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
-TAB_SIZE = 4
-
-# This tag can be used to specify a number of aliases that acts
-# as commands in the documentation. An alias has the form "name=value".
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to
-# put the command \sideeffect (or @sideeffect) in the documentation, which
-# will result in a user-defined paragraph with heading "Side Effects:".
-# You can put \n's in the value part of an alias to insert newlines.
-
-ALIASES =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
-# sources only. Doxygen will then generate output that is more tailored for C.
-# For instance, some of the names that are used will be different. The list
-# of all members will be omitted, etc.
-
-OPTIMIZE_OUTPUT_FOR_C = NO
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
-# sources only. Doxygen will then generate output that is more tailored for Java.
-# For instance, namespaces will be presented as packages, qualified scopes
-# will look different, etc.
-
-OPTIMIZE_OUTPUT_JAVA = NO
-
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to
-# include (a tag file for) the STL sources as input, then you should
-# set this tag to YES in order to let doxygen match functions declarations and
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
-# func(std::string) {}). This also make the inheritance and collaboration
-# diagrams that involve STL classes more complete and accurate.
-
-BUILTIN_STL_SUPPORT = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC = NO
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
-# the same type (for instance a group of public functions) to be put as a
-# subgroup of that type (e.g. under the Public Functions section). Set it to
-# NO to prevent subgrouping. Alternatively, this can be done per class using
-# the \nosubgrouping command.
-
-SUBGROUPING = YES
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
-# documentation are documented, even if no documentation was available.
-# Private class members and static file members will be hidden unless
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
-EXTRACT_ALL = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
-# will be included in the documentation.
-
-EXTRACT_PRIVATE = YES
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file
-# will be included in the documentation.
-
-EXTRACT_STATIC = YES
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
-# defined locally in source files will be included in the documentation.
-# If set to NO only classes defined in header files are included.
-
-EXTRACT_LOCAL_CLASSES = YES
-
-# This flag is only useful for Objective-C code. When set to YES local
-# methods, which are defined in the implementation section but not in
-# the interface are included in the documentation.
-# If set to NO (the default) only methods in the interface are included.
-
-EXTRACT_LOCAL_METHODS = YES
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
-# undocumented members of documented classes, files or namespaces.
-# If set to NO (the default) these members will be included in the
-# various overviews, but no documentation section is generated.
-# This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_MEMBERS = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy.
-# If set to NO (the default) these classes will be included in the various
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_CLASSES = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
-# friend (class|struct|union) declarations.
-# If set to NO (the default) these declarations will be included in the
-# documentation.
-
-HIDE_FRIEND_COMPOUNDS = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
-# documentation blocks found inside the body of a function.
-# If set to NO (the default) these blocks will be appended to the
-# function's detailed documentation block.
-
-HIDE_IN_BODY_DOCS = NO
-
-# The INTERNAL_DOCS tag determines if documentation
-# that is typed after a \internal command is included. If the tag is set
-# to NO (the default) then the documentation will be excluded.
-# Set it to YES to include the internal documentation.
-
-INTERNAL_DOCS = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
-# file names in lower-case letters. If set to YES upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
-
-CASE_SENSE_NAMES = YES
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
-# will show members with their full class and namespace scopes in the
-# documentation. If set to YES the scope will be hidden.
-
-HIDE_SCOPE_NAMES = NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
-# will put a list of the files that are included by a file in the documentation
-# of that file.
-
-SHOW_INCLUDE_FILES = YES
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
-# is inserted in the documentation for inline members.
-
-INLINE_INFO = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
-# will sort the (detailed) documentation of file and class members
-# alphabetically by member name. If set to NO the members will appear in
-# declaration order.
-
-SORT_MEMBER_DOCS = YES
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
-# brief documentation of file, namespace and class members alphabetically
-# by member name. If set to NO (the default) the members will appear in
-# declaration order.
-
-SORT_BRIEF_DOCS = NO
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
-# sorted by fully-qualified names, including namespaces. If set to
-# NO (the default), the class list will be sorted only by class name,
-# not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the
-# alphabetical list.
-
-SORT_BY_SCOPE_NAME = NO
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or
-# disable (NO) the todo list. This list is created by putting \todo
-# commands in the documentation.
-
-GENERATE_TODOLIST = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or
-# disable (NO) the test list. This list is created by putting \test
-# commands in the documentation.
-
-GENERATE_TESTLIST = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or
-# disable (NO) the bug list. This list is created by putting \bug
-# commands in the documentation.
-
-GENERATE_BUGLIST = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
-# disable (NO) the deprecated list. This list is created by putting
-# \deprecated commands in the documentation.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
-# the documentation. If the initializer consists of more lines than specified
-# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
-# documentation can be controlled using \showinitializer or \hideinitializer
-# command in the documentation regardless of this setting.
-
-MAX_INITIALIZER_LINES = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
-# at the bottom of the documentation of classes and structs. If set to YES the
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES = YES
-
-# If the sources in your project are distributed over multiple directories
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
-# in the documentation. The default is NO.
-
-SHOW_DIRECTORIES = NO
-
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that
-# doxygen should invoke to get the current version for each file (typically from the
-# version control system). Doxygen will invoke the program by executing (via
-# popen()) the command <command> <input-file>, where <command> is the value of
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
-# provided by doxygen. Whatever the program writes to standard output
-# is used as the file version. See the manual for examples.
-
-FILE_VERSION_FILTER =
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
-QUIET = YES
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated by doxygen. Possible values are YES and NO. If left blank
-# NO is used.
-
-WARNINGS = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
-# automatically be disabled.
-
-WARN_IF_UNDOCUMENTED = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some
-# parameters in a documented function, or documenting parameters that
-# don't exist or using markup commands wrongly.
-
-WARN_IF_DOC_ERROR = YES
-
-# This WARN_NO_PARAMDOC option can be abled to get warnings for
-# functions that are documented, but have no documentation for their parameters
-# or return value. If set to NO (the default) doxygen will only warn about
-# wrong or incomplete parameter documentation, but not about the absence of
-# documentation.
-
-WARN_NO_PARAMDOC = YES
-
-# The WARN_FORMAT tag determines the format of the warning messages that
-# doxygen can produce. The string should contain the $file, $line, and $text
-# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text. Optionally the format may contain
-# $version, which will be replaced by the version of the file (if it could
-# be obtained via FILE_VERSION_FILTER)
-
-WARN_FORMAT = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning
-# and error messages should be written. If left blank the output is written
-# to stderr.
-
-WARN_LOGFILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain
-# documented source files. You may enter file names like "myfile.cpp" or
-# directories like "/usr/src/myproject". Separate the files or directories
-# with spaces.
-
-INPUT = jrnl
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py
-
-FILE_PATTERNS = *.cpp *.hpp
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories
-# should be searched for input files as well. Possible values are YES and NO.
-# If left blank NO is used.
-
-RECURSIVE = NO
-
-# The EXCLUDE tag can be used to specify files and/or directories that should
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE =
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
-# directories that are symbolic links (a Unix filesystem feature) are excluded
-# from the input.
-
-EXCLUDE_SYMLINKS = NO
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories. Note that the wildcards are matched
-# against the file with absolute path, so to exclude all test directories
-# for example use the pattern */test/*
-
-EXCLUDE_PATTERNS =
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or
-# directories that contain example code fragments that are included (see
-# the \include command).
-
-EXAMPLE_PATH =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank all files are included.
-
-EXAMPLE_PATTERNS =
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude
-# commands irrespective of the value of the RECURSIVE tag.
-# Possible values are YES and NO. If left blank NO is used.
-
-EXAMPLE_RECURSIVE = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or
-# directories that contain image that are included in the documentation (see
-# the \image command).
-
-IMAGE_PATH =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command <filter> <input-file>, where <filter>
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
-# input file. Doxygen will then use the output that the filter program writes
-# to standard output. If FILTER_PATTERNS is specified, this tag will be
-# ignored.
-
-INPUT_FILTER =
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis. Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match. The filters are a list of the form:
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
-# is applied to all files.
-
-FILTER_PATTERNS =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will be used to filter the input files when producing source
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
-FILTER_SOURCE_FILES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will
-# be generated. Documented entities will be cross-referenced with these sources.
-# Note: To get rid of all source code in the generated output, make sure also
-# VERBATIM_HEADERS is set to NO.
-
-SOURCE_BROWSER = YES
-
-# Setting the INLINE_SOURCES tag to YES will include the body
-# of functions and classes directly in the documentation.
-
-INLINE_SOURCES = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
-# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C and C++ comments will always remain visible.
-
-STRIP_CODE_COMMENTS = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES (the default)
-# then for each documented function all documented
-# functions referencing it will be listed.
-
-REFERENCED_BY_RELATION = YES
-
-# If the REFERENCES_RELATION tag is set to YES (the default)
-# then for each documented function all documented entities
-# called/used by that function will be listed.
-
-REFERENCES_RELATION = YES
-
-# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
-# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
-# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
-# link to the source code. Otherwise they will link to the documentstion.
-
-REFERENCES_LINK_SOURCE = YES
-
-# If the USE_HTAGS tag is set to YES then the references to source code
-# will point to the HTML generated by the htags(1) tool instead of doxygen
-# built-in source browser. The htags tool is part of GNU's global source
-# tagging system (see http://www.gnu.org/software/global/global.html). You
-# will need version 4.8.6 or higher.
-
-USE_HTAGS = NO
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
-# will generate a verbatim copy of the header file for each class for
-# which an include is specified. Set to NO to disable this.
-
-VERBATIM_HEADERS = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
-# of all compounds will be generated. Enable this if the project
-# contains a lot of classes, structs, unions or interfaces.
-
-ALPHABETICAL_INDEX = NO
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
-# in which this list will be split (can be a number in the range [1..20])
-
-COLS_IN_ALPHA_INDEX = 5
-
-# In case all classes in a project start with a common prefix, all
-# classes will be put under the same header in the alphabetical index.
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
-# should be ignored while generating the index headers.
-
-IGNORE_PREFIX =
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
-# generate HTML output.
-
-GENERATE_HTML = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `html' will be used as the default path.
-
-HTML_OUTPUT = html
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
-# doxygen will generate files with .html extension.
-
-HTML_FILE_EXTENSION = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
-
-HTML_HEADER =
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard footer.
-
-HTML_FOOTER =
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
-# style sheet that is used by each HTML page. It can be used to
-# fine-tune the look of the HTML output. If the tag is left blank doxygen
-# will generate a default style sheet. Note that doxygen will try to copy
-# the style sheet file to the HTML output directory, so don't put your own
-# stylesheet in the HTML output directory as well, or it will be erased!
-
-HTML_STYLESHEET =
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
-# files or namespaces will be aligned in HTML using tables. If set to
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS = YES
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files
-# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
-# of the generated HTML documentation.
-
-GENERATE_HTMLHELP = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
-# be used to specify the file name of the resulting .chm file. You
-# can add a path in front of the file if the result should not be
-# written to the html output directory.
-
-CHM_FILE =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
-# be used to specify the location (absolute path including file name) of
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
-# the HTML help compiler on the generated index.hhp.
-
-HHC_LOCATION =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
-# controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
-
-GENERATE_CHI = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
-# controls whether a binary table of contents is generated (YES) or a
-# normal table of contents (NO) in the .chm file.
-
-BINARY_TOC = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members
-# to the contents of the HTML help documentation and to the tree view.
-
-TOC_EXPAND = NO
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
-
-DISABLE_INDEX = NO
-
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE = 4
-
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that
-# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
-# probably better off using the HTML help feature.
-
-GENERATE_TREEVIEW = NO
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
-# used to set the initial width (in pixels) of the frame in which the tree
-# is shown.
-
-TREEVIEW_WIDTH = 250
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
-# generate Latex output.
-
-GENERATE_LATEX = YES
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `latex' will be used as the default path.
-
-LATEX_OUTPUT = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked. If left blank `latex' will be used as the default command name.
-
-LATEX_CMD_NAME = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
-# generate index for LaTeX. If left blank `makeindex' will be used as the
-# default command name.
-
-MAKEINDEX_CMD_NAME = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
-# LaTeX documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_LATEX = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
-# executive. If left blank a4wide will be used.
-
-PAPER_TYPE = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
-# packages that should be included in the LaTeX output.
-
-EXTRA_PACKAGES =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
-# the generated latex document. The header should contain everything until
-# the first chapter. If it is left blank doxygen will generate a
-# standard header. Notice: only use this tag if you know what you are doing!
-
-LATEX_HEADER =
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will
-# contain links (just like the HTML output) instead of page references
-# This makes the output suitable for online browsing using a pdf viewer.
-
-PDF_HYPERLINKS = NO
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
-# plain latex in the generated Makefile. Set this option to YES to get a
-# higher quality PDF documentation.
-
-USE_PDFLATEX = NO
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
-# command to the generated LaTeX files. This will instruct LaTeX to keep
-# running if errors occur, instead of asking the user for help.
-# This option is also used when generating formulas in HTML.
-
-LATEX_BATCHMODE = NO
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not
-# include the index chapters (such as File Index, Compound Index, etc.)
-# in the output.
-
-LATEX_HIDE_INDICES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimized for Word 97 and may not look very pretty with
-# other RTF readers or editors.
-
-GENERATE_RTF = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `rtf' will be used as the default path.
-
-RTF_OUTPUT = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
-# RTF documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_RTF = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
-# will contain hyperlink fields. The RTF file will
-# contain links (just like the HTML output) instead of page references.
-# This makes the output suitable for online browsing using WORD or other
-# programs which support those fields.
-# Note: wordpad (write) and others do not support links.
-
-RTF_HYPERLINKS = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assignments. You only have to provide
-# replacements, missing definitions are set to their default value.
-
-RTF_STYLESHEET_FILE =
-
-# Set optional variables used in the generation of an rtf document.
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE =
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
-# generate man pages
-
-GENERATE_MAN = YES
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `man' will be used as the default path.
-
-MAN_OUTPUT = man
-
-# The MAN_EXTENSION tag determines the extension that is added to
-# the generated man pages (default is the subroutine's section .3)
-
-MAN_EXTENSION = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
-# then it will generate one additional man file for each entity
-# documented in the real man page(s). These additional files
-# only source the real man page, but without them the man command
-# would be unable to find the correct page. The default is NO.
-
-MAN_LINKS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will
-# generate an XML file that captures the structure of
-# the code including all documentation.
-
-GENERATE_XML = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `xml' will be used as the default path.
-
-XML_OUTPUT = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_SCHEMA =
-
-# The XML_DTD tag can be used to specify an XML DTD,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_DTD =
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
-# dump the program listings (including syntax highlighting
-# and cross-referencing information) to the XML output. Note that
-# enabling this will significantly increase the size of the XML output.
-
-XML_PROGRAMLISTING = YES
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
-# generate an AutoGen Definitions (see autogen.sf.net) file
-# that captures the structure of the code including all
-# documentation. Note that this feature is still experimental
-# and incomplete at the moment.
-
-GENERATE_AUTOGEN_DEF = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will
-# generate a Perl module file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
-
-GENERATE_PERLMOD = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able
-# to generate PDF and DVI output from the Perl module output.
-
-PERLMOD_LATEX = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader. This is useful
-# if you want to understand what is going on. On the other hand, if this
-# tag is set to NO the size of the Perl module output will be much smaller
-# and Perl will parse it just the same.
-
-PERLMOD_PRETTY = YES
-
-# The names of the make variables in the generated doxyrules.make file
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
-# This is useful so different doxyrules.make files included by the same
-# Makefile don't overwrite each other's variables.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
-# evaluate all C-preprocessor directives found in the sources and include
-# files.
-
-ENABLE_PREPROCESSING = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
-# names in the source code. If set to NO (the default) only conditional
-# compilation will be performed. Macro expansion can be done in a controlled
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
-MACRO_EXPANSION = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
-# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_DEFINED tags.
-
-EXPAND_ONLY_PREDEF = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-SEARCH_INCLUDES = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by
-# the preprocessor.
-
-INCLUDE_PATH =
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will
-# be used.
-
-INCLUDE_FILE_PATTERNS =
-
-# The PREDEFINED tag can be used to specify one or more macro names that
-# are defined before the preprocessor is started (similar to the -D option of
-# gcc). The argument of the tag is a list of macros of the form: name
-# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed. To prevent a macro definition from being
-# undefined via #undef or recursively expanded use the := operator
-# instead of the = operator.
-
-PREDEFINED =
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
-# this tag can be used to specify a list of macro names that should be expanded.
-# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
-EXPAND_AS_DEFINED =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse
-# the parser if not removed.
-
-SKIP_FUNCTION_MACROS = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
-
-TAGFILES =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE =
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed
-# in the class index. If set to NO only the inherited external classes
-# will be listed.
-
-ALLEXTERNALS = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will
-# be listed.
-
-EXTERNAL_GROUPS = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of `which perl').
-
-PERL_PATH = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
-# or super classes. Setting the tag to NO turns the diagrams off. Note that
-# this option is superseded by the HAVE_DOT option below. This is only a
-# fallback. It is recommended to install and use dot, since it yields more
-# powerful graphs.
-
-CLASS_DIAGRAMS = YES
-
-# If set to YES, the inheritance and collaboration graphs will hide
-# inheritance and usage relations if the target is undocumented
-# or is not a class.
-
-HIDE_UNDOC_RELATIONS = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz, a graph visualization
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section
-# have no effect if this option is set to NO (the default)
-
-HAVE_DOT = NO
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect implementation dependencies (inheritance, containment, and
-# class references variables) of the class with other documented classes.
-
-COLLABORATION_GRAPH = YES
-
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for groups, showing the direct groups dependencies
-
-GROUP_GRAPHS = YES
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
-# collaboration diagrams in a style similar to the OMG's Unified Modeling
-# Language.
-
-UML_LOOK = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS = NO
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
-# tags are set to YES then doxygen will generate a graph for each documented
-# file showing the direct and indirect include dependencies of the file with
-# other documented files.
-
-INCLUDE_GRAPH = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
-# documented header file showing the documented files that directly or
-# indirectly include this file.
-
-INCLUDED_BY_GRAPH = YES
-
-# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
-# generate a call dependency graph for every global function or class method.
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable call graphs for selected
-# functions only using the \callgraph command.
-
-CALL_GRAPH = NO
-
-# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will
-# generate a caller dependency graph for every global function or class method.
-# Note that enabling this option will significantly increase the time of a run.
-# So in most cases it will be better to enable caller graphs for selected
-# functions only using the \callergraph command.
-
-CALLER_GRAPH = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY = YES
-
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
-# then doxygen will show the dependencies a directory has on other directories
-# in a graphical way. The dependency relations are determined by the #include
-# relations between the files in the directories.
-
-DIRECTORY_GRAPH = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT = png
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found in the path.
-
-DOT_PATH =
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the
-# \dotfile command).
-
-DOTFILE_DIRS =
-
-# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than
-# this value, doxygen will try to truncate the graph, so that it fits within
-# the specified constraint. Beware that most browsers cannot cope with very
-# large images.
-
-MAX_DOT_GRAPH_WIDTH = 1024
-
-# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
-# (in pixels) of the graphs generated by dot. If a graph becomes larger than
-# this value, doxygen will try to truncate the graph, so that it fits within
-# the specified constraint. Beware that most browsers cannot cope with very
-# large images.
-
-MAX_DOT_GRAPH_HEIGHT = 1024
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
-# graphs generated by dot. A depth value of 3 means that only nodes reachable
-# from the root by following a path via at most 3 edges will be shown. Nodes
-# that lay further from the root node will be omitted. Note that setting this
-# option to 1 or 2 may greatly reduce the computation time needed for large
-# code bases. Also note that a graph may be further truncated if the graph's
-# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH
-# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default),
-# the graph is not depth-constrained.
-
-MAX_DOT_GRAPH_DEPTH = 0
-
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
-# background. This is disabled by default, which results in a white background.
-# Warning: Depending on the platform used, enabling this option may lead to
-# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
-# read).
-
-DOT_TRANSPARENT = NO
-
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
-# files in one run (i.e. multiple -o and -T options on the command line). This
-# makes dot run faster, but since only newer versions of dot (>1.8.10)
-# support this, this feature is disabled by default.
-
-DOT_MULTI_TARGETS = NO
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
-# generate a legend page explaining the meaning of the various boxes and
-# arrows in the dot generated graphs.
-
-GENERATE_LEGEND = YES
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
-# remove the intermediate dot files that are used to generate
-# the various graphs.
-
-DOT_CLEANUP = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE = NO
Modified: store/trunk/cpp/lib/Makefile.am
===================================================================
--- store/trunk/cpp/lib/Makefile.am 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/lib/Makefile.am 2007-08-30 13:40:45 UTC (rev 898)
@@ -1,5 +1,5 @@
- AM_CXXFLAGS = $(WARNING_CFLAGS) $(APR_CXXFLAGS) $(QPID_CXXFLAGS)
-
+AM_CXXFLAGS = $(WARNING_CFLAGS) $(APR_CXXFLAGS) $(QPID_CXXFLAGS)
+
lib_LTLIBRARIES = libbdbstore.la
libbdbstore_la_LIBADD = \
@@ -32,7 +32,44 @@
PreparedTransaction.h \
StoreException.h \
StringDbt.h \
- TxnCtxt.h
+ TxnCtxt.h \
+ jrnl/data_rec.cpp \
+ jrnl/data_rec.hpp \
+ jrnl/data_tok.cpp \
+ jrnl/enq_map.cpp \
+ jrnl/file_hdr.cpp \
+ jrnl/jcntl.cpp \
+ jrnl/jdir.cpp \
+ jrnl/jerrno.cpp \
+ jrnl/jexception.cpp \
+ jrnl/jinf.cpp \
+ jrnl/jrec.cpp \
+ jrnl/lfh.cpp \
+ jrnl/nlfh.cpp \
+ jrnl/pmgr.cpp \
+ jrnl/rmgr.cpp \
+ jrnl/rrfc.cpp \
+ jrnl/wmgr.cpp \
+ jrnl/wrfc.cpp \
+ jrnl/aio_cb.hpp \
+ jrnl/data_rec.hpp \
+ jrnl/data_tok.hpp \
+ jrnl/enq_map.hpp \
+ jrnl/file_hdr.hpp \
+ jrnl/jcfg.hpp \
+ jrnl/jcntl.hpp \
+ jrnl/jdir.hpp \
+ jrnl/jerrno.hpp \
+ jrnl/jexception.hpp \
+ jrnl/jinf.hpp \
+ jrnl/jrec.hpp \
+ jrnl/lfh.hpp \
+ jrnl/nlfh.hpp \
+ jrnl/pmgr.hpp \
+ jrnl/rmgr.hpp \
+ jrnl/rrfc.hpp \
+ jrnl/wmgr.hpp \
+ jrnl/wrfc.hpp
BUILT_SOURCES = db-inc.h
db-inc.h: Makefile.in
Copied: store/trunk/cpp/lib/jrnl/README (from rev 891, store/trunk/cpp/jrnl/README)
===================================================================
--- store/trunk/cpp/lib/jrnl/README (rev 0)
+++ store/trunk/cpp/lib/jrnl/README 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,37 @@
+MESSAGE JOURNAL
+===============
+This directory contains the source for the persistent message journal.
+
+External dependencies:
+----------------------
+libaio-dev (run "yum install libaio-dev" as root to install)
+doxygen (required to generate documentation)
+
+Building:
+---------
+For manual building, use the makefile Makefile.rtest in the tests/jrnl directory.
+Change to this directory to run the makefiles and regression tests:
+"make -f Makefile.rtest clean-all" then "make -f Makefile.rtest" To see all make options, run
+"make -f Makefile.rtest help". ** TODO: Check this as it may change **
+
+NOTE: This makefile is a manually created file, not a part of automake/autoconf (yet). It does not
+have complete dependency checking, so if a header file is changed, a clean make should be performed
+manually.
+
+Testing:
+--------
+The tests are defined in jtest.cpp, and are numbered from 0 to 40 (more or less). To run an
+individual test, run "./jtest <csvfile> <testnum>" where testnum is the requried test number
+whose parameters are defined in the named csv file.
+
+To analyze the journal files (which are written to a new jdata dir)
+
+To run regression tests which go through all the tests repeatedly and analyse the results, run
+"rtest". This can take some time, especially for the valgrind check (the '*'
+symbol).
+
+Directories:
+------------
+Source: cpp/lib/jrnl
+Tests and test utils: cpp/tests/jrnl
+Documentation: ??? TBD
Copied: store/trunk/cpp/lib/jrnl/aio_cb.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/aio_cb.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/aio_cb.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/aio_cb.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,47 @@
+/**
+* \file aio_cb.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the definition for the AIO callback function
+* pointer.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_aio_cb_hpp
+#define rhm_journal_aio_cb_hpp
+
+namespace rhm
+{
+namespace journal
+{
+ /**
+ * \brief Callback function pointer to be called when AIO events arrive.
+ */
+ typedef void (*aio_cb)(u_int32_t num_dtoks);
+}
+}
+
+#endif
Copied: store/trunk/cpp/lib/jrnl/data_rec.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/data_rec.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/data_rec.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/data_rec.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,463 @@
+/**
+* \file data_rec.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the code for the rhm::journal::data_rec (journal data
+* record) class. See comments in file data_rec.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/data_rec.hpp>
+
+#include <assert.h>
+#include <iomanip>
+#include <sstream>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+// Default constructor; must be used in conjunction with reset() to prepare
+// instance for use with write or read operations
+data_rec::data_rec():
+ jrec(), // superclass
+ _enq_hdr(RHM_JDAT_ENQ_MAGIC, 0, 0, RHM_JDAT_VERSION),
+ _data(NULL),
+ _buff(NULL),
+ _enq_tail(_enq_hdr),
+ _max_data_size(0),
+ _data_size(0),
+ _rec_size(0)
+{}
+
+// Constructor used for write operations, where dbuf contains data to be written.
+data_rec::data_rec(const u_int64_t rid, const void* const dbuf, const size_t dlen):
+ jrec(), // superclass
+ _enq_hdr(RHM_JDAT_ENQ_MAGIC, rid, dlen, RHM_JDAT_VERSION),
+ _data(dbuf),
+ _buff(NULL),
+ _enq_tail(_enq_hdr),
+ _max_data_size(0),
+ _data_size(dlen),
+ _rec_size(size_dblks(dlen + enq_hdr::size() + enq_tail::size()) * JRNL_DBLK_SIZE)
+{}
+
+// Constructor used for read operations, where buf contains preallocated space
+// to receive data.
+data_rec::data_rec(void* const buf, const size_t bufsize):
+ jrec(), // superclass
+ _enq_hdr(RHM_JDAT_ENQ_MAGIC, 0, bufsize, RHM_JDAT_VERSION),
+ _data(NULL),
+ _buff(buf),
+ _enq_tail(_enq_hdr),
+ _max_data_size(bufsize),
+ _data_size(0),
+ _rec_size(0)
+{}
+
+data_rec::~data_rec()
+{
+#ifdef RHM_NOAIO
+ if (_wbuff)
+ {
+ ::free(_wbuff);
+ _wbuff = NULL;
+ }
+#endif
+}
+
+// Prepare instance for use in writing data to journal, where dbuf contains data to be written.
+void
+data_rec::reset(const u_int64_t rid, const void* const dbuf, const size_t dlen)
+{
+ _enq_hdr._hdr._rid = rid;
+ _enq_hdr._dsize = dlen;
+ _data = dbuf;
+ _buff = NULL;
+ _enq_tail._rid = rid;
+ _max_data_size = 0;
+ _data_size = dlen;
+ _rec_size = size_dblks(dlen + enq_hdr::size() + enq_tail::size()) * JRNL_DBLK_SIZE;
+}
+
+// Prepare instance for use in reading data from journal, where buf contains preallocated space
+// to receive data.
+void
+data_rec::reset(void* const buf, const size_t bufsize)
+{
+ _enq_hdr._hdr._rid = 0;
+ _enq_hdr._dsize = bufsize;
+ _data = NULL;
+ _buff = buf;
+ _enq_tail._rid = 0;
+ _max_data_size = bufsize;
+ _data_size = 0;
+ _rec_size = 0;
+}
+
+u_int32_t
+data_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks) throw (jexception)
+{
+ assert(wptr != NULL);
+ assert(max_size_dblks > 0);
+
+ size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
+ size_t rem = max_size_dblks * JRNL_DBLK_SIZE;
+ size_t wr_cnt = 0;
+ if (rec_offs_dblks) // Continuation of split data record (over 2 or more pages)
+ {
+ if (size_dblks(rec_size()) - rec_offs_dblks > max_size_dblks) // Further split required
+ {
+ size_t wsize = sizeof(_enq_hdr) > rec_offs ? sizeof(_enq_hdr) - rec_offs : 0;
+ size_t wsize2 = wsize;
+ if (wsize)
+ {
+ if (wsize > rem)
+ wsize = rem;
+ ::memcpy(wptr, (char*)&_enq_hdr + rec_offs, wsize);
+ wr_cnt = wsize;
+ rem -= wsize;
+ }
+ rec_offs -= sizeof(_enq_hdr) - wsize2;
+ if (rem)
+ {
+ wsize = _data_size > rec_offs ? _data_size - rec_offs : 0;
+ wsize2 = wsize;
+ if (wsize)
+ {
+ if (wsize > rem)
+ wsize = rem;
+ ::memcpy((char*)wptr + wr_cnt, (char*)_data + rec_offs, wsize);
+ wr_cnt += wsize;
+ rem -= wsize;
+ }
+ rec_offs -= _data_size - wsize2;
+ }
+ if (rem)
+ {
+ wsize = sizeof(_enq_tail) > rec_offs ? sizeof(_enq_tail) - rec_offs : 0;
+ wsize2 = wsize;
+ if (wsize)
+ {
+ if (wsize > rem)
+ wsize = rem;
+ ::memcpy((char*)wptr + wr_cnt, (char*)&_enq_tail + rec_offs, wsize);
+ wr_cnt += wsize;
+ rem -= wsize;
+ }
+ rec_offs -= sizeof(_enq_tail) - wsize2;
+ }
+ assert(rem == 0);
+ assert(rec_offs == 0);
+ }
+ else // No further split required
+ {
+ size_t wsize = sizeof(_enq_hdr) > rec_offs ? sizeof(_enq_hdr) - rec_offs : 0;
+ if (wsize)
+ {
+ ::memcpy(wptr, (char*)&_enq_hdr + rec_offs, wsize);
+ wr_cnt = wsize;
+ }
+ rec_offs -= sizeof(_enq_hdr) - wsize;
+ wsize = _data_size > rec_offs ? _data_size - rec_offs : 0;
+ if (wsize)
+ {
+ ::memcpy((char*)wptr + wr_cnt, (char*)_data + rec_offs, wsize);
+ wr_cnt += wsize;
+ }
+ rec_offs -= _data_size - wsize;
+ wsize = sizeof(_enq_tail) > rec_offs ? sizeof(_enq_tail) - rec_offs : 0;
+ if (wsize)
+ {
+ ::memcpy((char*)wptr + wr_cnt, (char*)&_enq_tail + rec_offs, wsize);
+ wr_cnt += wsize;
+#ifdef RHM_CLEAN
+ ::memset((char*)wptr + wr_cnt, RHM_CLEAN_CHAR,
+ _rec_size - (rec_offs_dblks * JRNL_DBLK_SIZE) - wr_cnt);
+#endif
+ }
+ rec_offs -= sizeof(_enq_tail) - wsize;
+ assert(rec_offs == 0);
+ }
+ }
+ else // Start at beginning of data record
+ {
+ if (size_dblks(rec_size()) > max_size_dblks) // Split required
+ {
+ size_t wsize = rem >= sizeof(_enq_hdr) ? sizeof(_enq_hdr) : rem;
+ ::memcpy(wptr, (void*)&_enq_hdr, wsize);
+ wr_cnt = wsize;
+ rem -= wsize;
+ if (rem)
+ {
+ wsize = rem >= _data_size ? _data_size : rem;
+ ::memcpy((char*)wptr + wr_cnt, _data, wsize);
+ wr_cnt += wsize;
+ rem -= wsize;
+ }
+ if (rem)
+ {
+ wsize = rem >= sizeof(_enq_tail) ? sizeof(_enq_tail) : rem;
+ ::memcpy((char*)wptr + wr_cnt, (void*)&_enq_tail, wsize);
+ wr_cnt += wsize;
+ rem -= wsize;
+ }
+ assert(rem == 0);
+ }
+ else // No split required
+ {
+ ::memcpy(wptr, (void*)&_enq_hdr, sizeof(_enq_hdr));
+ wr_cnt = sizeof(_enq_hdr);
+ ::memcpy((char*)wptr + wr_cnt, _data, _data_size);
+ wr_cnt += _data_size;
+ ::memcpy((char*)wptr + wr_cnt, (void*)&_enq_tail, sizeof(_enq_tail));
+ wr_cnt += sizeof(_enq_tail);
+#ifdef RHM_CLEAN
+ ::memset((char*)wptr + wr_cnt, RHM_CLEAN_CHAR, _rec_size - wr_cnt);
+#endif
+ }
+ }
+ return size_dblks(wr_cnt);
+}
+
+u_int32_t
+data_rec::decode(hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+ throw (jexception)
+{
+ assert(rptr != NULL);
+ assert(max_size_dblks > 0);
+
+ size_t rd_cnt = 0;
+ if (rec_offs_dblks) // Continuation of record on new page
+ {
+ const u_int32_t hdr_data_dblks = size_dblks(enq_hdr::size() + _data_size);
+ const u_int32_t hdr_data_tail_dblks = size_dblks(enq_hdr::size() + _data_size +
+ enq_tail::size());
+ const size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
+
+ if (hdr_data_tail_dblks - rec_offs_dblks <= max_size_dblks)
+ {
+ // Remainder of record fits within this page
+ if (rec_offs - enq_hdr::size() < _data_size)
+ {
+ // Data still outstanding, copy remainder of data and tail
+ const size_t data_offs = rec_offs - enq_hdr::size();
+ const size_t data_rem = _data_size - data_offs;
+ ::memcpy((char*)_buff + data_offs, rptr, data_rem);
+ rd_cnt += data_rem;
+ ::memcpy((void*)&_enq_tail, ((char*)rptr + data_rem), sizeof(_enq_tail));
+ chk_tail(_enq_tail, _enq_hdr);
+ rd_cnt += sizeof(_enq_tail);
+ }
+ else
+ {
+ // Tail or part of tail only outstanding, complete tail
+ const size_t tail_offs = rec_offs - enq_hdr::size() - _data_size;
+ const size_t tail_rem = enq_tail::size() - tail_offs;
+ ::memcpy((char*)&_enq_tail + tail_offs, rptr, tail_rem);
+ chk_tail(_enq_tail, _enq_hdr);
+ rd_cnt = tail_rem;
+ }
+ }
+ else if (hdr_data_dblks - rec_offs_dblks <= max_size_dblks)
+ {
+ // Remainder of record data fits within this page, tail split
+ const size_t data_offs = rec_offs - enq_hdr::size();
+ const size_t data_rem = _data_size - data_offs;
+ ::memcpy((char*)_buff + data_offs, rptr, data_rem);
+ rd_cnt += data_rem;
+ const size_t tail_rem = (max_size_dblks * JRNL_DBLK_SIZE) - rd_cnt;
+ if (tail_rem)
+ {
+ ::memcpy((void*)&_enq_tail, ((char*)rptr + data_rem), tail_rem);
+ rd_cnt += tail_rem;
+ }
+ }
+ else
+ {
+ // Remainder of record data split
+ const size_t data_cp_size = (max_size_dblks * JRNL_DBLK_SIZE);
+ ::memcpy((char*)_buff + rec_offs - enq_hdr::size(), rptr, data_cp_size);
+ rd_cnt += data_cp_size;
+ }
+ }
+ else // Start of record
+ {
+ // Get and check header
+ _enq_hdr._hdr.copy(h);
+ _enq_hdr._dsize = *(size_t*)((char*)rptr + sizeof(hdr));
+ rd_cnt = _enq_hdr.size();
+ chk_hdr(_enq_hdr);
+ _data_size = _enq_hdr._dsize;
+ const u_int32_t hdr_data_dblks = size_dblks(enq_hdr::size() + _data_size);
+ const u_int32_t hdr_data_tail_dblks = size_dblks(enq_hdr::size() + _data_size +
+ enq_tail::size());
+
+ if (_data_size)
+ {
+ // Check if record (header + data + tail) fits within this page, we can check the
+ // tail before the expense of copying data to memory
+ if (hdr_data_tail_dblks <= max_size_dblks)
+ {
+ // Entire header, data and tail fits within this page
+ ::memcpy((void*)&_enq_tail, (char*)rptr + rd_cnt + _data_size, sizeof(_enq_tail));
+ chk_tail(_enq_tail, _enq_hdr);
+ ::memcpy(_buff, (char*)rptr + rd_cnt, _data_size);
+ rd_cnt += _data_size + sizeof(_enq_tail);
+ }
+ else if (hdr_data_dblks <= max_size_dblks)
+ {
+ // Entire header and data fit within this page, tail split
+ ::memcpy(_buff, (char*)rptr + rd_cnt, _data_size);
+ rd_cnt += _data_size;
+ const size_t tail_rem = (max_size_dblks * JRNL_DBLK_SIZE) - rd_cnt;
+ if (tail_rem)
+ {
+ ::memcpy((void*)&_enq_tail, (char*)rptr + rd_cnt, tail_rem);
+ rd_cnt += tail_rem;
+ }
+ }
+ else
+ {
+ // Header fits within this page, record data split
+ const size_t data_cp_size = (max_size_dblks * JRNL_DBLK_SIZE) - rd_cnt;
+ ::memcpy(_buff, (char*)rptr + rd_cnt, data_cp_size);
+ rd_cnt += data_cp_size;
+ }
+ }
+ }
+ return size_dblks(rd_cnt);
+}
+
+std::string&
+data_rec::str(std::string& str) const
+{
+ std::stringstream ss;
+ ss << "data_rec: m=" << _enq_hdr._hdr._magic;
+ ss << " v=" << (int)_enq_hdr._hdr._version;
+ ss << " rid=" << _enq_hdr._hdr._rid;
+ ss << " len=" << _enq_hdr._dsize;
+ str.append(ss.str());
+ return str;
+}
+
+const size_t
+data_rec::data_size() const
+{
+ return _data_size;
+}
+
+const size_t
+data_rec::rec_size() const
+{
+ return _data_size + enq_hdr::size() + enq_tail::size();
+}
+
+void
+data_rec::set_rid(const u_int64_t rid)
+{
+ _enq_hdr._hdr._rid = rid;
+ _enq_tail._rid = rid;
+}
+
+void
+data_rec::chk_hdr(enq_hdr& hdr, u_int64_t rid, bool enq) const throw (jexception)
+{
+ chk_hdr(hdr, enq);
+ if (hdr._hdr._rid != rid)
+ {
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ ss << "rid mismatch: expected=0x" << std::setw(16) << rid;
+ ss << " read=0x" << std::setw(16) << hdr._hdr._rid;
+ throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "data_rec", "chk_hdr");
+ }
+}
+
+void
+data_rec::chk_hdr(enq_hdr& hdr, bool enq) const throw (jexception)
+{
+ if (enq)
+ {
+ if (hdr._hdr._magic != RHM_JDAT_ENQ_MAGIC)
+ {
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ ss << "enq magic: rid=0x" << std::setw(16) << hdr._hdr._rid;
+ ss << ": expected=0x" << std::setw(8) << RHM_JDAT_ENQ_MAGIC;
+ ss << " read=0x" << std::setw(2) << (int)hdr._hdr._magic;
+ throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "data_rec", "chk_hdr");
+ }
+ }
+ else
+ {
+ if (hdr._hdr._magic != RHM_JDAT_DEQ_MAGIC)
+ {
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ ss << "deq magic: rid=0x" << std::setw(16) << hdr._hdr._rid;
+ ss << ": expected=0x" << std::setw(8) << RHM_JDAT_DEQ_MAGIC;
+ ss << " read=0x" << std::setw(2) << (int)hdr._hdr._magic;
+ throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "data_rec", "chk_hdr");
+ }
+ }
+ if (hdr._hdr._version != RHM_JDAT_VERSION)
+ {
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ ss << "version: rid=0x" << std::setw(16) << hdr._hdr._rid;
+ ss << ": expected=0x" << std::setw(2) << (int)RHM_JDAT_VERSION;
+ ss << " read=0x" << std::setw(2) << (int)hdr._hdr._version;
+ throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "data_rec", "chk_hdr");
+ }
+#if defined (JRNL_LITTLE_ENDIAN)
+ u_int8_t endian_flag = RHM_LENDIAN_FLAG;
+#else
+ u_int8_t endian_flag = RHM_BENDIAN_FLAG;
+#endif
+ if (hdr._hdr._eflag != endian_flag)
+ {
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ ss << "endian_flag: rid=" << std::setw(16) << hdr._hdr._rid;
+ ss << ": expected=0x" << std::setw(2) << (int)endian_flag;
+ ss << " read=0x" << std::setw(2) << (int)hdr._hdr._eflag;
+ throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "data_rec", "chk_hdr");
+ }
+ if (hdr._dsize > _max_data_size)
+ {
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ ss << "data_size: rid=" << std::setw(16) << hdr._hdr._rid;
+ ss << std::dec << ": buff_size=" << _max_data_size << " data_size=" << hdr._dsize;
+ throw jexception(jerrno::JERR_DREC_BUFFSIZE, ss.str(), "data_rec", "chk_hdr");
+ }
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/data_rec.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/data_rec.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/data_rec.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/data_rec.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,113 @@
+/**
+* \file data_rec.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the code for the rhm::journal::data_rec (journal data
+* record) class. See class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_data_rec_hpp
+#define rhm_journal_data_rec_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class data_rec;
+}
+}
+
+#include <jrnl/jrec.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \class data_rec
+ * \brief Class to handle a single journal data record. These are the records
+ * contained in the jouranl data files.
+ */
+ class data_rec : public jrec
+ {
+ private:
+ enq_hdr _enq_hdr;
+ const void* _data; ///< Pointer to data to be written
+ void* _buff; ///< Pointer to buffer to receive read data
+ enq_tail _enq_tail;
+ size_t _max_data_size; ///< Max buffer size for decoding into during read
+ size_t _data_size; ///< Size of data (bytes)
+ size_t _rec_size; ///< Size of data blocks required for record (bytes)
+
+ public:
+ /**
+ * \brief Default constructor; must be used in conjunction with reset() to prepare
+ * instance for use with write or read operations.
+ */
+ data_rec();
+
+ /**
+ * \brief Constructor used for write operations, where mbuf contains data to be written.
+ */
+ data_rec(const u_int64_t rid, const void* const dbuf, const size_t dlen);
+
+ /**
+ * \brief Constructor used for read operations, where buf contains preallocated space
+ * to receive data.
+ */
+ data_rec(void* const buf, const size_t bufsize);
+ ~data_rec();
+
+ // Prepare instance for use in writing data to journal
+ void reset(const u_int64_t rid, const void* const dbuf, const size_t dlen);
+ // Prepare instance for use in reading data from journal
+ void reset(void* const buf, const size_t bufsize);
+
+ u_int32_t encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+ throw (jexception);
+ u_int32_t decode(hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+ throw (jexception);
+ std::string& str(std::string& str) const;
+ inline const size_t max_data_size() const { return _max_data_size; }
+ inline const size_t max_rec_size() const
+ { return _max_data_size + enq_hdr::size() + enq_tail::size(); }
+ const size_t data_size() const;
+ const size_t rec_size() const;
+ inline const u_int32_t rec_size_dblks() const { return size_dblks(rec_size()); }
+ inline const u_int64_t rid() const { return _enq_hdr._hdr._rid; }
+ void set_rid(const u_int64_t rid);
+
+ private:
+ void chk_hdr(enq_hdr& hdr, u_int64_t rid, bool enq = true) const throw (jexception);
+ void chk_hdr(enq_hdr& hdr, bool enq = true) const throw (jexception);
+ }; // class data_rec
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_data_rec_hpp
Copied: store/trunk/cpp/lib/jrnl/data_tok.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/data_tok.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/data_tok.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/data_tok.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,144 @@
+/**
+* \file data_tok.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::data_tok (data block token).
+* See comments in file data_tok.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/data_tok.hpp>
+
+#include <sstream>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+// Static members
+
+u_int64_t data_tok::_cnt = 0;
+
+data_tok::data_tok():
+ _icnt(_cnt++),
+ _wstate(NONE),
+ _rstate(UNREAD),
+ _dsize(0),
+ _dblks_proc(0),
+ _rid(0)
+{}
+
+data_tok::~data_tok()
+{}
+
+const char*
+data_tok::wstate_str() const
+{
+ return wstate_str(_wstate);
+}
+
+const char*
+data_tok::wstate_str(write_state wstate)
+{
+ switch (wstate)
+ {
+ case NONE:
+ return "NONE";
+ case ENQ_CACHED:
+ return "ENQ_CACHED";
+ case ENQ_PART:
+ return "ENQ_PART";
+ case ENQ_SUBM:
+ return "ENQ_SUBM";
+ case ENQ:
+ return "ENQ";
+ case DEQ_CACHED:
+ return "DEQ_CACHED";
+ case DEQ_SUBM:
+ return "DEQ_SUBM";
+ case DEQ:
+ return "DEQ";
+ }
+ return "<unknown>";
+}
+
+const char*
+data_tok::rstate_str() const
+{
+ return rstate_str(_rstate);
+}
+
+const char*
+data_tok::rstate_str(read_state rstate)
+{
+ switch (rstate)
+ {
+ case NONE:
+ return "NONE";
+ case READ_PART:
+ return "READ_PART";
+ case READ:
+ return "READ";
+ }
+ return "<unknown>";
+}
+
+void
+data_tok::set_rstate(const read_state rstate)
+{
+ if (_wstate != ENQ && rstate != UNREAD)
+ {
+ std::stringstream ss;
+ ss << "Attempted to change read state to " << rstate_str(rstate);
+ ss << " while write state is not enqueued (wstate ENQ); wstate=" << wstate_str() << ".";
+ throw new jexception(jerrno::JERR_DTOK_ILLEGALSTATE, ss.str(), "data_tok","set_rstate");
+ }
+ _rstate = rstate;
+}
+
+const u_int64_t
+data_tok::rid() const throw (jexception)
+{
+ if (_wstate == NONE)
+ throw new jexception(jerrno::JERR_DTOK_RIDNOTSET,
+ "Instance in write state NONE; rid not known.", "data_tok","rid");
+ return _rid;
+}
+
+void
+data_tok::reset()
+{
+ _wstate = NONE;
+ _rstate = UNREAD;
+ _dsize = 0;
+ _dblks_proc = 0;
+ _rid = 0;
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/data_tok.hpp (from rev 891, store/trunk/cpp/jrnl/jrnl/data_tok.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/data_tok.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/data_tok.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,120 @@
+/**
+* \file data_tok.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::data_tok (data block token).
+* See class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_data_tok_hpp
+#define rhm_journal_data_tok_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class data_tok;
+}
+}
+
+#include <sys/types.h>
+#include <jrnl/jexception.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \class data_tok
+ * \brief Data block token (data_tok) used to track wstate of a data block through asynchronous
+ * I/O process
+ */
+ class data_tok
+ {
+ public:
+ enum write_state
+ {
+ NONE, ///< Data block not sent to journal
+ ENQ_CACHED, ///< Data block enqueue written to page cache
+ ENQ_PART, ///< Data block part-submitted to AIO, waiting for page buffer to free up
+ ENQ_SUBM, ///< Data block enqueue submitted to AIO
+ ENQ, ///< Data block enqueue AIO write complete (enqueue complete)
+ DEQ_CACHED, ///< Data block dequeue written to page cache
+ DEQ_SUBM, ///< Data block dequeue submitted to AIO
+ DEQ ///< Data block dequeue AIO write complete (dequeue complete)
+ };
+
+ enum read_state
+ {
+ UNREAD, ///< Data block not read
+ READ_PART, ///< Data block is part-read; waiting for page buffer to fill
+ READ ///< Data block is fully read
+ };
+
+ private:
+ static u_int64_t _cnt;
+ u_int64_t _icnt;
+ write_state _wstate; ///< Enqueued / dequeued state of data
+ read_state _rstate; ///< Read state of data
+ size_t _dsize; ///< Data size in bytes
+ u_int32_t _dblks_proc; ///< Data blocks read/written
+ u_int64_t _rid; ///< RID of data set by enqueue operation
+
+ public:
+ data_tok();
+ ~data_tok();
+
+ inline const u_int64_t id() const { return _icnt; }
+ inline const write_state wstate() const {return _wstate; }
+ const char* wstate_str() const;
+ static const char* wstate_str(write_state wstate);
+ inline const read_state rstate() const {return _rstate; }
+ const char* rstate_str() const;
+ static const char* rstate_str(read_state rstate);
+ inline const bool is_writable() const { return _wstate == NONE || _wstate == ENQ_PART; }
+ inline const bool is_enqueued() const { return _wstate == ENQ; }
+ inline const bool is_readable() const { return _wstate == ENQ; }
+ inline const bool is_read() const { return _rstate == READ; }
+ inline const bool is_dequeueable() const { return _wstate == ENQ; }
+ inline void set_wstate(const write_state wstate) { _wstate = wstate; }
+ void set_rstate(const read_state rstate);
+ inline const size_t dsize() const { return _dsize; }
+ inline void set_dsize(size_t dsize) { _dsize = dsize; }
+ inline const u_int32_t dblocks_proc() const { return _dblks_proc; }
+ inline void incr_dblocks_proc(u_int32_t dblks_proc) { _dblks_proc += dblks_proc; }
+ inline void set_dblocks_proc(u_int32_t dblks_proc) { _dblks_proc = dblks_proc; }
+ inline void reset_dblks_proc() { _dblks_proc = 0; }
+ const u_int64_t rid() const throw (jexception);
+ inline void set_rid(const u_int64_t rid) { _rid = rid; }
+ void reset();
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_data_tok_hpp
Copied: store/trunk/cpp/lib/jrnl/enq_map.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/enq_map.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_map.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/enq_map.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,83 @@
+/**
+* \file enq_map.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::enq_map (enqueue map). See
+* comments in file enq_map.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright (C) 2007 Red Hat Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/enq_map.hpp>
+
+#include <iomanip>
+#include <sstream>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+enq_map::enq_map():
+ _map()
+{
+ _map.clear();
+}
+
+enq_map::~enq_map()
+{}
+
+void
+enq_map::insert_fid(u_int64_t rid, u_int16_t fid) throw (jexception)
+{
+ _ret = _map.insert(std::pair<u_int64_t, u_int16_t>(rid, fid));
+ if (_ret.second == false)
+ {
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ ss << "rid=0x" << std::setw(16) << rid << " fid=0x" << std::setw(4) << fid;
+ throw jexception(jerrno::JERR_EMAP_DUPLICATE, ss.str(), "enq_map", "insert");
+ }
+}
+
+u_int16_t
+enq_map::get_remove_fid(u_int64_t rid) throw (jexception)
+{
+ _it = _map.find(rid);
+ if (_it == _map.end())
+ {
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ ss << "rid=0x" << std::setw(16) << rid;
+ throw jexception(jerrno::JERR_EMAP_NOTFOUND, ss.str(), "enq_map", "get_remove_fid");
+ }
+ u_int16_t fid = _it->second;
+ _map.erase(_it);
+ return fid;
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/enq_map.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/enq_map.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_map.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/enq_map.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,77 @@
+/**
+* \file enq_map.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::enq_map (enqueue map).
+* See class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright (C) 2007 Red Hat Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_enq_map_hpp
+#define rhm_journal_enq_map_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class enq_map;
+}
+}
+
+#include <map>
+#include <jrnl/jexception.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \class enq_map
+ * \brief Class for storing the file id (fid) for each enqueued data block using
+ * the record id (rid) as a key.
+ */
+ class enq_map
+ {
+ private:
+ std::map<u_int64_t, u_int16_t> _map;
+ std::map<u_int64_t, u_int16_t>::iterator _it;
+ std::pair<std::map<u_int64_t, u_int16_t>::iterator, bool> _ret;
+
+ public:
+ enq_map();
+ ~enq_map();
+
+ void insert_fid(u_int64_t rid, u_int16_t fid) throw (jexception);
+ u_int16_t get_remove_fid(u_int64_t rid) throw (jexception);
+ inline const bool empty() const { return _map.empty(); }
+ inline const u_int16_t size() const { return (u_int16_t)_map.size(); }
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_enq_map_hpp
Copied: store/trunk/cpp/lib/jrnl/file_hdr.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/file_hdr.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/file_hdr.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/file_hdr.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,227 @@
+/**
+* \file file_hdr.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::file_hdr (journal log file
+* handle), used for controlling journal log files. See comments in file
+* file_hdr.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/file_hdr.hpp>
+
+#include <cerrno>
+#include <sstream>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+hdr::hdr():
+ _magic(0),
+ _version(0),
+ _eflag(0),
+ _uflag(0),
+ _rid(0)
+{}
+
+hdr::hdr(const u_int32_t magic, const u_int64_t rid, const u_int8_t version,
+ const u_int8_t uflag):
+ _magic(magic),
+ _version(version),
+#if defined(JRNL_BIG_ENDIAN)
+ _eflag(RHM_BENDIAN_FLAG),
+#else
+ _eflag(RHM_LENDIAN_FLAG),
+#endif
+ _uflag(uflag),
+ _rid(rid)
+{}
+
+void
+hdr::copy(const hdr& h)
+{
+ _magic = h._magic;
+ _version = h._version;
+ _eflag = h._eflag;
+ _uflag = h._uflag;
+ _rid = h._rid;
+}
+
+void
+hdr::reset()
+{
+ _magic = 0;
+ _version = 0;
+ _eflag = 0;
+ _uflag = 0;
+ _rid = 0;
+}
+
+file_hdr::file_hdr():
+ _hdr(),
+ _fid(0),
+ _res(0),
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ _filler0(0),
+#endif
+ _fro(0),
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+ _filler0(0),
+#endif
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ _filler1(0),
+#endif
+ _ts_sec(0),
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+ _filler1(0),
+#endif
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ _filler2(0),
+#endif
+ _ts_nsec(0)
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+ , _filler2(0)
+#endif
+{}
+
+file_hdr::file_hdr(const u_int32_t magic, const u_int64_t rid, const u_int32_t fid,
+ const size_t fro, const bool settime, const u_int8_t version, const u_int8_t uflag)
+ throw (jexception):
+ _hdr(magic, rid, version, uflag),
+ _fid(fid),
+ _res(0),
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ _filler0(0),
+#endif
+ _fro(fro),
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+ _filler0(0),
+#endif
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ _filler1(0),
+#endif
+ _ts_sec(0),
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+ _filler1(0),
+#endif
+#if defined(JRNL_BIG_ENDIAN)
+ _filler2(0),
+#endif
+ _ts_nsec(0)
+#if defined(JRNL_LITTLE_ENDIAN)
+ , _filler2(0)
+#endif
+{
+ if (settime)
+ set_time();
+}
+
+void
+file_hdr::set_time() throw (jexception)
+{
+// TODO: Standardize on a method for getting time that does not requrie a context switch.
+ timespec ts;
+ if (::clock_gettime(CLOCK_REALTIME, &ts))
+ {
+ std::stringstream ss;
+ ss << "errno=" << errno;
+ throw jexception(jerrno::JERR__RTCLOCK, ss.str(), "file_hdr", "set_time");
+ }
+ _ts_sec = ts.tv_sec;
+ _ts_nsec = ts.tv_nsec;
+// This version uses a call with microsecond resolution instead of nanosecond resolution...
+// timeval tv;
+// if (::gettimeofday(&tv, 0))
+// ;
+// else
+// {
+// _ts_sec = tv.tv_sec;
+// _ts_nsec = tv.tv_usec * 1000;
+// }
+}
+
+void
+file_hdr::set_time(timespec ts)
+{
+ _ts_sec = ts.tv_sec;
+ _ts_nsec = ts.tv_nsec;
+}
+
+enq_hdr::enq_hdr():
+ _hdr(),
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ _filler0(0),
+#endif
+ _dsize(0)
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+ , _filler0(0)
+#endif
+{}
+
+enq_hdr::enq_hdr(const u_int32_t magic, const u_int64_t rid, const size_t dsize,
+ const u_int8_t version, const u_int8_t uflag):
+ _hdr(magic, rid, version, uflag),
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ _filler0(0),
+#endif
+ _dsize(dsize)
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+ , _filler0(0)
+#endif
+{}
+
+
+enq_tail::enq_tail():
+ _xmagic(0xffffff), // 1's complement of 0
+ _rid(0)
+{}
+
+enq_tail::enq_tail(const enq_hdr& rhdr):
+ _xmagic(~rhdr._hdr._magic),
+ _rid(rhdr._hdr._rid)
+{}
+
+enq_tail::enq_tail(const u_int32_t xmagic, const u_int64_t rid):
+ _xmagic(xmagic),
+ _rid(rid)
+{}
+
+deq_hdr::deq_hdr():
+ _hdr(),
+ _deq_rid(0)
+{}
+
+deq_hdr::deq_hdr(const u_int32_t magic, const u_int64_t rid, const u_int64_t deq_rid,
+ const u_int8_t version, const u_int8_t uflag):
+ _hdr(magic, rid, version, uflag),
+ _deq_rid(deq_rid)
+{}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/file_hdr.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/file_hdr.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/file_hdr.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/file_hdr.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,371 @@
+/**
+* \file file_hdr.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::file_hdr (journal log file
+* handle), used for controlling journal log files. See class documentation
+* for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_file_hdr_hpp
+#define rhm_journal_file_hdr_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class file_hdr;
+}
+}
+
+#include <jrnl/jcfg.hpp>
+#include <jrnl/jexception.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+#pragma pack(1)
+
+ /**
+ * \struct hdr
+ * \brief Struct for data common to the head of all journal files and records.
+ * This includes identification for the file type, the encoding version, endian
+ * indicator and a record ID.
+ *
+ * File header info in binary format (16 bytes):
+ * <pre>
+ * 0 7
+ * +---+---+---+---+---+---+---+---+
+ * | magic | v | e | flags |
+ * +---+---+---+---+---+---+---+---+
+ * | rec-id |
+ * +---+---+---+---+---+---+---+---+
+ * v = file version (If the format or encoding of this file changes, then this
+ * number should be incremented)
+ * e = endian flag, false (0x00) for little endian, true (0x01) for big endian
+ * </pre>
+ *
+ * Note that journal files should be transferable between 32- and 64-bit
+ * hardware of the same endianness, but not between hardware of opposite
+ * entianness without some sort of binary conversion utility. Thus buffering
+ * will be needed for types that change size between 32- and 64-bit compiles.
+ */
+ struct hdr
+ {
+ u_int32_t _magic; ///< File type identifier (magic number)
+ u_int8_t _version; ///< File encoding version
+ u_int8_t _eflag; ///< Flag for determining endianness
+ u_int16_t _uflag; ///< User-defined flags
+ u_int64_t _rid; ///< Record ID (rotating 64-bit counter)
+
+ // Convenience constructors and methods
+ /**
+ * \brief Default constructor, which sets all values to 0.
+ */
+ hdr();
+
+ /**
+ * \brief Convenience constructor which initializes values during construction.
+ */
+ hdr(const u_int32_t magic, const u_int64_t rid, const u_int8_t version = 0,
+ const u_int8_t uflag = 0);
+
+ /**
+ * \brief Convenience copy method.
+ */
+ void copy(const hdr& h);
+
+ /**
+ * \brief Resets all fields to 0
+ */
+ void reset();
+
+ /**
+ * \brief Returns the size of the header in bytes.
+ */
+ inline static const size_t size() { return sizeof(hdr); }
+ }; // struct hdr
+
+
+ /**
+ * \struct file_hdr
+ * \brief Struct for data common to the head of all journal files. In addition to
+ * the common data, this includes the record ID and offset of the first record in
+ * the file.
+ *
+ * This header precedes all data in journal files and occupies the first complete
+ * block in the file. The record ID and offset are updated on each overwrite of the
+ * file.
+ *
+ * File header info in binary format (48 bytes):
+ * <pre>
+ * 0 7
+ * +---+---+---+---+---+---+---+---+ -+
+ * | magic | v | e | flags | |
+ * +---+---+---+---+---+---+---+---+ | struct hdr
+ * | first rec-id in file | |
+ * +---+---+---+---+---+---+---+---+ -+
+ * | fid | reserved (0) |
+ * +---+---+---+---+---+---+---+---+
+ * | fro |
+ * +---+---+---+---+---+---+---+---+
+ * | timestamp (sec) |
+ * +---+---+---+---+---+---+---+---+
+ * | timestamp (ns) |
+ * +---+---+---+---+---+---+---+---+
+ * v = file version (If the format or encoding of this file changes, then this
+ * number should be incremented)
+ * e = endian flag, false (0x00) for little endian, true (0x01) for big endian
+ * fid = File ID (number used in naming file)
+ * fro = First record offset, offset from start of file to first record header
+ * </pre>
+ *
+ * Note that journal files should be transferable between 32- and 64-bit
+ * hardware of the same endianness, but not between hardware of opposite
+ * entianness without some sort of binary conversion utility. Thus buffering
+ * will be needed for types that change size between 32- and 64-bit compiles.
+ */
+ struct file_hdr
+ {
+ hdr _hdr; ///< Common header
+ u_int32_t _fid; ///< File ID
+ u_int32_t _res; ///< Reserved (for alignment/flags)
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ u_int32_t _filler0; ///< Big-endian filler for 32-bit size_t
+#endif
+ size_t _fro; ///< First record offset
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+ u_int32_t _filler0; ///< Little-endian filler for 32-bit size_t
+#endif
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ u_int32_t _filler1; ///< Big-endian filler for 32-bit time_t
+#endif
+ time_t _ts_sec; ///< Timestamp of journal initilailization
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+ u_int32_t _filler1; ///< Little-endian filler for 32-bit time_t
+#endif
+#if defined(JRNL_BIG_ENDIAN)
+ u_int32_t _filler2; ///< Big endian filler for u_int32_t
+#endif
+ u_int32_t _ts_nsec; ///< Timestamp of journal initilailization
+#if defined(JRNL_LITTLE_ENDIAN)
+ u_int32_t _filler2; ///< Little-endian filler for u_int32_t
+#endif
+
+ /**
+ * \brief Default constructor, which sets all values to 0.
+ */
+ file_hdr();
+
+ /**
+ * \brief Convenience constructor which initializes values during construction.
+ */
+ file_hdr(const u_int32_t magic, const u_int64_t rid, const u_int32_t fid,
+ const size_t fro, const bool settime = false, const u_int8_t version = 0,
+ const u_int8_t uflag = 0) throw (jexception);
+
+ /**
+ * \brief Gets the current time from the system clock and sets the timestamp in the struct.
+ */
+ void set_time() throw (jexception);
+
+ /**
+ * \brief Sets the timestamp in the struct to the provided value (in seconds and
+ * nanoseconds).
+ */
+ void set_time(timespec ts);
+
+ /**
+ * \brief Returns the size of the header in bytes.
+ */
+ inline static const size_t size() { return sizeof(file_hdr); }
+ }; // struct file_hdr
+
+
+ /**
+ * \struct enq_hdr
+ * \brief Struct for data common to the head of all records. In addition to
+ * the common data, this includes the data blob size.
+ *
+ * This header precedes all records in journal files.
+ *
+ * Record header info in binary format (24 bytes):
+ * <pre>
+ * 0 7
+ * +---+---+---+---+---+---+---+---+ -+
+ * | magic | v | e | flags | |
+ * +---+---+---+---+---+---+---+---+ | struct hdr
+ * | rec-id | |
+ * +---+---+---+---+---+---+---+---+ -+
+ * | dsize |
+ * +---+---+---+---+---+---+---+---+
+ * v = file version (If the format or encoding of this file changes, then this
+ * number should be incremented)
+ * e = endian flag, false (0x00) for little endian, true (0x01) for big endian
+ * </pre>
+ *
+ * Note that journal files should be transferable between 32- and 64-bit
+ * hardware of the same endianness, but not between hardware of opposite
+ * entianness without some sort of binary conversion utility. Thus buffering
+ * will be needed for types that change size between 32- and 64-bit compiles.
+ */
+ struct enq_hdr
+ {
+ hdr _hdr; ///< Common header
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ u_int32_t _filler0; ///< Big-endian filler for 32-bit size_t
+#endif
+ size_t _dsize; ///< Record data size
+#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
+ u_int32_t _filler0; ///< Little-endian filler for 32-bit size_t
+#endif
+
+ /**
+ * \brief Default constructor, which sets all values to 0.
+ */
+ enq_hdr();
+
+ /**
+ * \brief Convenience constructor which initializes values during construction.
+ */
+ enq_hdr(const u_int32_t magic, const u_int64_t rid, const size_t dsize,
+ const u_int8_t version = 0, const u_int8_t uflag = 0);
+
+ /**
+ * \brief Returns the size of the header in bytes.
+ */
+ inline static const size_t size() { return sizeof(enq_hdr); }
+ };
+
+
+ /**
+ * \struct enq_tail
+ * \brief Struct for data common to the tail of all records. The magic number
+ * used here is the binary inverse (1's complement) of the magic used in the
+ * record header; this minimizes possible confusion with other headers that may
+ * be present during recovery.
+ *
+ * This header precedes all records in journal files.
+ *
+ * Record header info in binary format (12 bytes):
+ * <pre>
+ * 0 7
+ * +---+---+---+---+---+---+---+---+
+ * | ~(magic) | rec-id |
+ * +---+---+---+---+---+---+---+---+
+ * |rec-id (con't) |
+ * +---+---+---+---+
+ * </pre>
+ */
+ struct enq_tail
+ {
+ u_int32_t _xmagic; ///< Binary inverse (1's complement) of hdr magic number
+ u_int64_t _rid; ///< ID (rotating 64-bit counter)
+
+
+ /**
+ * \brief Default constructor, which sets all values to 0.
+ */
+ enq_tail();
+
+
+ /**
+ * \brief Convenience constructor which initializes values during construction from
+ * existing enq_hdr instance.
+ */
+ enq_tail(const enq_hdr& rhdr);
+
+ /**
+ * \brief Convenience constructor which initializes values during construction.
+ */
+ enq_tail(const u_int32_t xmagic, const u_int64_t rid);
+
+ /**
+ * \brief Returns the size of the header in bytes.
+ */
+ inline static const size_t size() { return sizeof(enq_tail); }
+ };
+
+
+ /**
+ * \struct deq_hdr
+ * \brief Struct for dequeue record. This record carries no data or tail,
+ * and consists of this struct only. The record-id (part of hdr struct) is
+ * the record id for this struct which is counted as a record.
+ *
+ * This header precedes all records in journal files.
+ *
+ * Record header info in binary format (24 bytes):
+ * <pre>
+ * 0 7
+ * +---+---+---+---+---+---+---+---+ -+
+ * | magic | v | e | flags | |
+ * +---+---+---+---+---+---+---+---+ | struct hdr
+ * | rec-id | |
+ * +---+---+---+---+---+---+---+---+ -+
+ * | deq-rec-id |
+ * +---+---+---+---+---+---+---+---+
+ * v = file version (If the format or encoding of this file changes, then this
+ * number should be incremented)
+ * e = endian flag, false (0x00) for little endian, true (0x01) for big endian
+ * </pre>
+ *
+ * Note that journal files should be transferable between 32- and 64-bit
+ * hardware of the same endianness, but not between hardware of opposite
+ * entianness without some sort of binary conversion utility. Thus buffering
+ * will be needed for types that change size between 32- and 64-bit compiles.
+ */
+ struct deq_hdr
+ {
+ hdr _hdr; ///< Common header
+ u_int64_t _deq_rid; ///< Record ID of dequeued record
+
+ /**
+ * \brief Default constructor, which sets all values to 0.
+ */
+ deq_hdr();
+
+ /**
+ * \brief Convenience constructor which initializes values during construction.
+ */
+ deq_hdr(const u_int32_t magic, const u_int64_t rid, const u_int64_t deq_rid,
+ const u_int8_t version = 0, const u_int8_t uflag = 0);
+
+ /**
+ * \brief Returns the size of the header in bytes.
+ */
+ inline static const size_t size() { return sizeof(deq_hdr); }
+ };
+
+#pragma pack()
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_file_hdr_hpp
Copied: store/trunk/cpp/lib/jrnl/jcfg.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jcfg.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jcfg.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jcfg.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,88 @@
+/**
+* \file jcfg.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains \#defines that control the implementation details of
+* the journal.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_jcfg_hpp
+#define rhm_journal_jcfg_hpp
+
+#include <iomanip> // for debug only
+#include <iostream> // for debug only
+
+#if defined(__i386__) /* little endian, 32 bits */
+#define JRNL_LITTLE_ENDIAN
+#define JRNL_32_BIT
+#elif defined(__PPC__) || defined(__s390__) /* big endian, 32 bits */
+#define JRNL_BIG_ENDIAN
+#define JRNL_32_BIT
+#elif defined(__ia64__) || defined(__x86_64__) || defined(__alpha__) /* little endian, 64 bits */
+#define JRNL_LITTLE_ENDIAN
+#define JRNL_64_BIT
+#elif defined(__powerpc64__) || defined(__s390x__) /* big endian, 64 bits */
+#define JRNL_BIG_ENDIAN
+#define JRNL_64_BIT
+#else
+#error endian?
+#endif
+
+
+/**
+* <b>Rule:</b> Data block size (JRNL_DBLK_SIZE) MUST be a power of 2 such that
+* <pre>
+* JRNL_DBLK_SIZE * JRNL_SBLK_SIZE == n * 512 (n = 1,2,3...)
+* </pre>
+* (The disk softblock size is 512 for Linux kernels >= 2.6)
+*/
+#define JRNL_DBLK_SIZE 128 ///< Data block size in bytes (CANNOT BE LESS THAN 32!)
+#define JRNL_SBLK_SIZE 4 ///< Disk softblock size in multiples of JRNL_DBLK_SIZE
+#define JRNL_FILE_SIZE 3072 ///< Journal file size in softblocks excl. file_hdr
+#define JRNL_NUM_FILES 8 ///< Number of journal files
+
+#define JRNL_RMGR_PAGE_SIZE 128 ///< Journal page size in softblocks
+#define JRNL_RMGR_PAGES 16 ///< Number of pages to use in wmgr
+
+#define JRNL_WMGR_PAGE_SIZE 64 ///< Journal write page size in softblocks
+#define JRNL_WMGR_PAGES 32 ///< Number of pages to use in wmgr
+#define JRNL_WMGR_MAXDTOKPP 1024 ///< Max. dtoks (data blocks) per page in wmgr
+#define JRNL_WMGR_MAXWAITUS 100 ///< Max. wait time (us) before submitting AIO
+
+#define JRNL_INFO_EXTENSION "jinf" ///< Extension for journal info files
+#define JRNL_DATA_EXTENSION "jdat" ///< Extension for journal data files
+#define RHM_JDAT_FILE_MAGIC 0x664d4852 ///< ("RHMf" in little endian) Magic for file hdrs
+#define RHM_JDAT_ENQ_MAGIC 0x654d4852 ///< ("RHMe" in little endian) Magic for enq rec hdrs
+#define RHM_JDAT_DEQ_MAGIC 0x644d4852 ///< ("RHMd" in little endian) Magic for deq rec hdrs
+#define RHM_JDAT_EMPTY_MAGIC 0x784d4852 ///< ("RHMx" in little endian) Magic for empty dblk
+#define RHM_JDAT_VERSION 0x01 ///< Version (of file layout)
+#define RHM_CLEAN_CHAR 0xff ///< Char used to clear empty space on disk
+
+#define RHM_LENDIAN_FLAG 0 ///< Value of little endian flag on disk
+#define RHM_BENDIAN_FLAG 1 ///< Value of big endian flag on disk
+
+#endif // ifndef rhm_journal_jcfg_hpp
Copied: store/trunk/cpp/lib/jrnl/jcntl.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jcntl.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,184 @@
+/**
+* \file jcntl.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* Messaging journal top-level control and interface class
+* rhm::journal::jcntl. See comments in file jcntl.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/jcntl.hpp>
+
+#include <cerrno>
+#include <fstream>
+#include <iomanip>
+#include <jrnl/jerrno.hpp>
+#include <jrnl/jinf.hpp>
+#include <sstream>
+
+namespace rhm
+{
+namespace journal
+{
+
+// Functions
+
+jcntl::jcntl(const std::string& jid, const std::string& jdir, const std::string& base_filename):
+ _jid(jid),
+ _jdir(jdir, base_filename),
+ _base_filename(base_filename),
+ _init_flag(false),
+ _stop_flag(false),
+ _autostop(true),
+ _datafh(NULL),
+ _emap(),
+ _rrfc(),
+ _wrfc(),
+ _rmgr(_emap, _rrfc),
+ _wmgr(_emap, _wrfc)
+{}
+
+jcntl::~jcntl()
+{
+ if (_datafh)
+ {
+ for (u_int32_t i=0; i<JRNL_NUM_FILES; i++)
+ if (_datafh[i])
+ ::delete _datafh[i];
+ ::delete[] _datafh;
+ }
+}
+
+void
+jcntl::initialize(std::deque<data_tok*>* rd_dtokl, const aio_cb rd_cb,
+ std::deque<data_tok*>* wr_dtokl, const aio_cb wr_cb) throw (jexception)
+{
+ // Prepare journal dir, journal files and file handles
+ _jdir.clear_dir();
+
+ _datafh = ::new lfh*[JRNL_NUM_FILES];
+ // NOTE: We NULL the pointer array prior to setting the pointers because exceptions
+ // can be thrown during pointer initialization, and the clean() fn that will be
+ // called after an exception will attempt to free any non-null pointer.
+ ::memset(_datafh, 0, sizeof(lfh*) * JRNL_NUM_FILES);
+ for (u_int16_t i=0; i<JRNL_NUM_FILES; i++)
+ {
+ std::stringstream ss;
+ ss << _jdir << "/" << _base_filename;
+ _datafh[i] = ::new lfh(ss.str(), i);
+ }
+
+ // NOTE: The write RFC must initialize first. This sets all the file handle object
+ // (lfh) counters and pointers for both read and write, since write activity
+ // constrains read activity (i.e. one can't read what has not yet been written).
+ _wrfc.initialize(JRNL_NUM_FILES, (nlfh**)_datafh);
+ _rrfc.initialize(JRNL_NUM_FILES, (nlfh**)_datafh);
+ _rmgr.initialize(rd_dtokl, rd_cb);
+ _wmgr.initialize(wr_dtokl, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
+
+ // Write info file (<basename>.jinf) to disk
+ write_infofile();
+
+ _init_flag = true;
+}
+
+const iores
+jcntl::enqueue_data(const void* const dbuf, const size_t dlen, data_tok* const dtok)
+ throw (jexception)
+{
+ check_status("enqueue_data");
+ return _wmgr.enqueue(dbuf, dlen, dtok);
+}
+
+const iores
+jcntl::read_data(void* const dbuf, const size_t dbsize, data_tok* const dtok) throw (jexception)
+{
+ check_status("read_data");
+ return _rmgr.read(dbuf, dbsize, dtok);
+}
+
+const iores
+jcntl::dequeue_data(data_tok* const dtok) throw (jexception)
+{
+ check_status("dequeue_data");
+ return _wmgr.dequeue(dtok);
+}
+
+const u_int32_t
+jcntl::get_wr_events() throw (jexception)
+{
+ return _wmgr.get_events(pmgr::UNUSED);
+}
+
+const u_int32_t
+jcntl::get_rd_events() throw (jexception)
+{
+ return _rmgr.get_events();
+}
+
+void
+jcntl::stop() throw (jexception)
+{
+ check_status("stop");
+ _stop_flag = true;
+ flush();
+}
+
+// Private functions
+
+void
+jcntl::check_status(const char* fn_name) const throw (jexception)
+{
+ if (!_init_flag)
+ throw jexception(jerrno::JERR__NINIT, "jcntl", fn_name);
+ if (_stop_flag)
+ throw jexception(jerrno::JERR_JCNTL_STOPPED, "jcntl", fn_name);
+}
+
+void
+jcntl::write_infofile() const throw (jexception)
+{
+ timespec ts;
+ if (::clock_gettime(CLOCK_REALTIME, &ts))
+ {
+ std::stringstream ss;
+ ss << "errno=" << errno;
+ throw jexception(jerrno::JERR__RTCLOCK, ss.str(), "jcntl", "write_infofile");
+ }
+ jinf ji(_jid, _jdir.dirname(), _base_filename, ts);
+ std::stringstream fn;
+ fn << _jdir << "/" << _base_filename << "." << JRNL_INFO_EXTENSION;
+ std::ofstream of(fn.str().c_str(), std::ofstream::out | std::ofstream::trunc);
+ if (!of.good())
+ throw jexception(jerrno::JERR__FILEIO, fn.str(), "jcntl", "write_infofile");
+ std::string s;
+ of << ji.str(s);
+ of.close();
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/jcntl.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jcntl.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,284 @@
+/**
+* \file jcntl.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* Messaging journal top-level control and interface class
+* rhm::journal::jcntl. See class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_jcntl_hpp
+#define rhm_journal_jcntl_hpp
+
+namespace rhm
+{
+namespace journal
+{
+ class jcntl;
+}
+}
+
+#include <jrnl/jdir.hpp>
+#include <jrnl/lfh.hpp>
+#include <jrnl/rmgr.hpp>
+#include <jrnl/wmgr.hpp>
+#include <jrnl/wrfc.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \class jcntl
+ * \brief Access and control interface for the journal. This is the top-level class for the
+ * journal.
+ *
+ * This is the top-level journal class; one instance of this class controls one instance of the
+ * journal and all its files and associated control structures. Besides this class, the only
+ * other class that needs to be used at a higher level is the data_tok class, one instance of
+ * which is used per data block written to the journal, and is used to track its status through
+ * the AIO enqueue, read and dequeue process.
+ */
+ class jcntl
+ {
+ private:
+ /**
+ * \var _jid
+ * \brief Journal ID
+ *
+ * This string uniquly identifies this journal instance. It will most likely be associated
+ * with the identity of the message queue with which it is associated.
+ */
+ // TODO: This is not included in any files at present, add to file_hdr?
+ std::string _jid;
+
+ /**
+ * \var _jdir
+ * \brief Journal directory
+ *
+ * This string stores the path to the journal directory. It may be absolute or relative, and
+ * should not end in a file separator character. (e.g. "/fastdisk/jdata" is correct,
+ * "/fastdisk/jdata/" is not.)
+ */
+ jdir _jdir;
+
+ /**
+ * \var _base_filename
+ * \brief Base filename
+ *
+ * This string contains the base filename used for the journal files. The filenames will
+ * start with this base, and have various sections added to it to derive the final file names
+ * that will be written to disk. No file separator characters should be included here, but
+ * all other legal filename characters are valid.
+ */
+ std::string _base_filename;
+
+ /**
+ * \var _init_flag
+ * \brief Initialized flag
+ *
+ * This flag starts out set to false, is set to true once this object has been initilaized,
+ * either by calling initialize() or recover().
+ */
+ bool _init_flag;
+
+ /**
+ * \var _stop_flag
+ * \brief Stopped flag
+ *
+ * This flag starts out false, and is set to true when stop() is called. At this point, the
+ * journal will no longer accept messages until either initialize() or recover() is called.
+ * There is no way other than through initialization to reset this flag.
+ */
+ bool _stop_flag;
+
+ bool _autostop; ///< Autostop flag - stops journal when overrun occurs
+
+ // Journal control structures
+ lfh** _datafh; ///< Array of pointers to data file handles
+ enq_map _emap; ///< Enqueue map for low water mark management
+ rrfc _rrfc; ///< Read journal rotating file controller
+ wrfc _wrfc; ///< Write journal rotating file controller
+ rmgr _rmgr; ///< Read page manager which manages AIO
+ wmgr _wmgr; ///< Write page manager which manages AIO
+
+ public:
+ /**
+ * \brief Journal constructor.
+ *
+ * Constructor which sets the physical file location and base name.
+ *
+ * \param jid A unique identifier for this journal instance.
+ * \param jdir The directory which will contain the journal files.
+ * \param base_filename The string which will be used to start all journal filenames.
+ */
+ jcntl(const std::string& jid, const std::string& jdir, const std::string& base_filename);
+
+ /**
+ * \brief Destructor.
+ */
+ ~jcntl();
+
+ /**
+ * \brief Initialize the journal for storing data.
+ *
+ * Initialize the journal by creating new journal data files and initializing internal
+ * control structures. When complete, the journal will be empty, and ready to store data.
+ *
+ * <b>NOTE: Any existing journal will be ignored by this operation.</b> To use recover
+ * the data from an existing journal, use recover().
+ *
+ * \param rd_dtokl deque for storing data tokens retruning from read AIO operations.
+ * \param rd_cb Function pointer to callback function for read operations. May be NULL.
+ * \param wr_dtokl deque for storing data tokens retruning from enqueue and dequeue (write)
+ * AIO operations.
+ * \param wr_cb Function pointer to callback function for write operations. May be NULL.
+ */
+ void initialize(std::deque<data_tok*>* rd_dtokl, const aio_cb rd_cb,
+ std::deque<data_tok*>* wr_dtokl, const aio_cb wr_cb) throw (jexception);
+
+ /**
+ * \brief Enqueues (writes) data to the journal.
+ *
+ * \param dbuf Pointer to data to be written to journal.
+ * \param dlen Size of data (in bytes) in dbuf to be written.
+ * \param dtok Pointer to data_tok instance for this data, used to track state of data
+ * through journal.
+ */
+ const iores enqueue_data(const void* const dbuf, const size_t dlen, data_tok* const dtok)
+ throw (jexception);
+
+ /**
+ * \brief Reads data from the journal.
+ *
+ * \param dbuf Pointer to buffer into which data is to be read.
+ * \param dbsize Buffer capacity in bytes - i.e. Maximum size of data to be written into
+ * dbuf.
+ * \param dtok Pointer to data_tok instance for this data, used to track state of data
+ * through journal.
+ */
+ const iores read_data(void* const dbuf, const size_t dbsize, data_tok* const dtok)
+ throw (jexception);
+
+ /**
+ * \brief Dequeues (marks as no longer needed) data from journal.
+ *
+ * Dequeues (marks as no longer needed) data from journal. Note that it is imperative to use
+ * the same data token instance used to enqueue this data; it contains the record ID needed
+ * to correctly mark this data as dequeued in the journal.
+ *
+ * \param dtok Pointer to data_tok instance for this data, used to track state of data
+ * through journal.
+ */
+ const iores dequeue_data(data_tok* const dtok) throw (jexception);
+
+ /**
+ * \brief Forces a check for returned AIO write events.
+ *
+ * Forces a check for returned AIO write events. This is normally performed by enqueue() and
+ * dequeue() operations, but if these operations cease, then this call needs to be made to
+ * force the processing of any outstanding AIO operations.
+ */
+ const u_int32_t get_wr_events() throw (jexception);
+
+ /**
+ * \brief Forces a check for returned AIO read events.
+ *
+ * Forces a check for returned AIO read events. This is normally performed by read_data()
+ * operations, but if these operations cease, then this call needs to be made to force the
+ * processing of any outstanding AIO operations.
+ */
+ const u_int32_t get_rd_events() throw (jexception);
+
+ /**
+ * \brief Stop the journal from accepting any further requests to read or write data.
+ *
+ * This operation is used to stop the jouranl. This is the normal mechanism for bringing the
+ * journal to an orderly stop. Any outstanding AIO operations or partially written pages in
+ * the write page cache will by flushed and will complete.
+ *
+ * <b>Note:</b> The jouranl cannot be restarted without either initailizing it or restoring
+ * it.
+ */
+ void stop() throw (jexception);
+
+ /**
+ * \brief Force a flush of the write page cache, creating a single AIO write operation.
+ */
+ inline void flush() throw (jexception) { _wmgr.flush(); }
+
+ /**
+ * \brief Check if the journal is ready to read and write data.
+ *
+ * Checks if the jouranl is ready to read and write data. This function will return
+ * <b><i>true</i></b> if the journal has been either initialized or restored, and the stop()
+ * function has not been called since the initialization.
+ *
+ * Note that the jouranl may also be stopped if an internal error occurs (such as running out
+ * of data jouranl file space).
+ *
+ * \return <b><i>true</i></b> if the jouranl is ready to read and write data;
+ * <b><i>false</i></b> otherwise.
+ */
+ inline const bool is_ready() const { return _init_flag and not _stop_flag; }
+
+ /**
+ * \brief Get the journal directory.
+ *
+ * This returns the journal directory as set during initialization. This is the directory
+ * into which the journal files will be written.
+ */
+ inline const std::string& dirname() const { return _jdir.dirname(); }
+
+ /**
+ * \brief Get the journal base filename.
+ *
+ * Get the journal base filename as set during initialization. This is the prefix used in all
+ * journal files of this instance. Note that if more than one instance of the journal shares
+ * the same directory, their base filenames <b>MUST</b> be different or else the instances
+ * will overwrite one another.
+ */
+ inline const std::string& base_filename() const { return _base_filename; }
+
+
+ private:
+ /**
+ * \brief Check status of journal before allowing certain operations.
+ */
+ void check_status(const char* fn_name) const throw (jexception);
+
+ /**
+ * \brief Write info file <basefilename>.jinf to disk
+ */
+ void write_infofile() const throw (jexception);
+
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_jcntl_hpp
Copied: store/trunk/cpp/lib/jrnl/jdir.cpp (from rev 891, store/trunk/cpp/jrnl/jrnl/jdir.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jdir.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,205 @@
+/**
+* \file jdir.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::jdir (journal data
+* directory), used for controlling and manipulating journal data
+* direcories and files. See comments in file jdir.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/jdir.hpp>
+
+#include <dirent.h>
+#include <cerrno>
+#include <iomanip>
+#include <sstream>
+#include <sys/stat.h>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+jdir::jdir(const std::string& dirname, const std::string& _base_filename):
+ _dirname(dirname),
+ _base_filename(_base_filename)
+{
+}
+
+void
+jdir::create_dir() throw (jexception)
+{
+ if (::mkdir(_dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << _dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_MKDIR, ss.str(), "jdir", "create_dir");
+ }
+}
+
+void
+jdir::clear_dir(const bool create_flag) throw (jexception)
+{
+ DIR* dir = opendir(_dirname.c_str());
+ if (!dir)
+ {
+ if (errno == 2 && !create_flag) // ENOENT (No such file or dir)
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << _dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_DIROPEN, ss.str(), "jdir", "clear_dir");
+ }
+ create_dir();
+ dir = opendir(_dirname.c_str());
+ if (!dir)
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << _dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_CDIROPEN, ss.str(), "jdir", "clear_dir");
+ }
+ }
+#ifndef RHM_JOWRITE
+ struct dirent* entry;
+ bool found = false;
+ std::string bak_dir;
+ while ((entry = readdir(dir)) != NULL)
+ {
+ // Ignore . and ..
+ if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0)
+ {
+ if (strlen(entry->d_name) > _base_filename.size())
+ {
+ if (strncmp(entry->d_name, _base_filename.c_str(), _base_filename.size()) == 0)
+ {
+ if (!found)
+ {
+ create_bak_dir(bak_dir);
+ found = true;
+ }
+ std::stringstream oldname;
+ oldname << _dirname << "/" << entry->d_name;
+ std::stringstream newname;
+ newname << bak_dir << "/" << entry->d_name;
+ if (rename(oldname.str().c_str(), newname.str().c_str()))
+ {
+ std::stringstream ss;
+ ss << "file=\"" << oldname.str() << "\" dest=\"" <<
+ newname.str() << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_FMOVE, ss.str(), "jdir", "clear_dir");
+ }
+ }
+ }
+ }
+ }
+#endif
+ if (closedir(dir))
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << _dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_DIRCLOSE, ss.str(), "jdir", "clear_dir");
+ }
+}
+
+std::string&
+jdir::create_bak_dir(std::string& str) throw (jexception)
+{
+ DIR* dir = opendir(_dirname.c_str());
+ long dir_num = 0L;
+ if (!dir)
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << _dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_DIROPEN, ss.str(), "jdir", "create_bak_dir");
+ }
+ struct dirent* entry;
+ while ((entry = readdir(dir)) != NULL)
+ {
+ // Ignore . and ..
+ if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0)
+ {
+ if (strlen(entry->d_name) == _base_filename.size() + 10) // Format: _basename.bak.XXXX
+ {
+ std::stringstream ss;
+ ss << "_" << _base_filename << ".bak.";
+ if (strncmp(entry->d_name, ss.str().c_str(), _base_filename.size() + 6) == 0)
+ {
+ long this_dir_num = strtol(entry->d_name + _base_filename.size() + 6, NULL, 16);
+ if (this_dir_num > dir_num)
+ dir_num = this_dir_num;
+ }
+ }
+ }
+ }
+ if (closedir(dir))
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << _dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_DIRCLOSE, ss.str(), "jdir", "create_bak_dir");
+ }
+ std::stringstream dn;
+ dn << _dirname << "/_" << _base_filename << ".bak." << std::hex << std::setw(4) <<
+ std::setfill('0') << ++dir_num;
+ if (mkdir(dn.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH))
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << dn.str() << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_MKDIR, ss.str(), "jdir", "create_bak_dir");
+ }
+ str.assign(dn.str());
+ return str;
+}
+
+const bool
+jdir::is_dir(const std::string& name) throw (jexception)
+{
+ struct stat s;
+ if (::stat(name.c_str(), &s))
+ {
+ std::stringstream ss;
+ ss << "file=\"" << name << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_FSTAT, ss.str(), "jdir", "is_dir");
+ }
+ return s.st_mode == S_IFDIR;
+}
+
+std::ostream&
+operator<<(std::ostream& os, const jdir& jdir)
+{
+ os << jdir._dirname;
+ return os;
+}
+
+std::ostream&
+operator<<(std::ostream& os, const jdir* jdirPtr)
+{
+ os << jdirPtr->_dirname;
+ return os;
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/jdir.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jdir.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jdir.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,127 @@
+/**
+* \file jdir.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::jdir (journal data
+* directory), used for controlling and manipulating journal data
+* directories and files. See class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_jdir_hpp
+#define rhm_journal_jdir_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class jdir;
+}
+}
+
+#include <jrnl/jexception.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \class jdir
+ * \brief Class to manage the journal directory
+ */
+ class jdir
+ {
+ private:
+ std::string _dirname;
+ std::string _base_filename;
+
+ public:
+ /**
+ * \brief Sole constructor
+ *
+ * \param dirname Name of directory to be managed.
+ * \param base_filename Filename root used in the creation of journal files
+ * and sub-directories.
+ */
+ jdir(const std::string& dirname, const std::string& base_filename);
+
+ /**
+ * \brief Create jouirnal directory.
+ */
+ void create_dir() throw (jexception);
+
+ /**
+ * \brief Clear the journal directory of files matching the base filename
+ * by moving them into a subdirectory.
+ *
+ * \param create_flag If set, create directory if it is non-existent,
+ * throw exception otherwise.
+ * \exception The journal directory could not be opened.
+ * \exception The move of files from the journal directory to the created backup
+ * directory failed.
+ * \exception The directory handle could not be closed.
+ */
+ void clear_dir(const bool create_flag = true) throw (jexception);
+
+ /**
+ * \brief Create bakup directory that is next in sequence.
+ *
+ * Search for directory using pattern "_basename.bak.XXXX" where XXXX is a hexadecimal
+ * sequence, and create next directory based on highest number found.
+ *
+ * \param str The new directory name will be placed in this string instance, which
+ * is also returned by this function.
+ * \return New directory name, the same instance as was passed in as paramter 'str'.
+ * \exception The journal directory could not be opened.
+ * \exception The creation of the new backup directory failed.
+ * \exception The directory handle could not be closed.
+ */
+ std::string& create_bak_dir(std::string& str) throw (jexception);
+
+ /**
+ * \brief Return the directory name as a string.
+ */
+ inline const std::string& dirname() const { return _dirname; }
+
+ /**
+ * \brief Test whether the named file is a directory.
+ *
+ * \param name Name of file to be tested.
+ * \return <b><i>true</i></b> if the named file is a directory; <b><i>false</i></b>
+ * otherwise.
+ * \exception The stat() operation failed on the named file.
+ */
+ const static bool is_dir(const std::string& name) throw (jexception);
+
+ friend std::ostream& operator<<(std::ostream& os, const jdir& jdir);
+ friend std::ostream& operator<<(std::ostream& os, const jdir* jdirPtr);
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_jdir_hpp
Copied: store/trunk/cpp/lib/jrnl/jerrno.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jerrno.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jerrno.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,183 @@
+/**
+* \file jerrno.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::jerrno (journal error
+* codes). See comments in file jerrno.hpp for details.
+*
+* See file jerrno.hpp for class details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+std::map<u_int32_t, std::string> jerrno::_err_map;
+std::map<u_int32_t, std::string>::iterator jerrno::_err_map_itr;
+bool jerrno::_initialized = jerrno::__init();
+
+// generic errors
+const u_int32_t jerrno::JERR__MALLOC = 0x0100;
+const u_int32_t jerrno::JERR__UNDERFLOW = 0x0101;
+const u_int32_t jerrno::JERR__NINIT = 0x0102;
+const u_int32_t jerrno::JERR__AIO = 0x0103;
+const u_int32_t jerrno::JERR__FILEIO = 0x0104;
+const u_int32_t jerrno::JERR__RTCLOCK = 0x0105;
+
+// class jcntl
+const u_int32_t jerrno::JERR_JCNTL_STOPPED = 0x0200;
+
+// class jdir
+const u_int32_t jerrno::JERR_JDIR_MKDIR = 0x0300;
+const u_int32_t jerrno::JERR_JDIR_DIROPEN = 0x0301;
+const u_int32_t jerrno::JERR_JDIR_CDIROPEN = 0x0302;
+const u_int32_t jerrno::JERR_JDIR_DIRCLOSE = 0x0303;
+const u_int32_t jerrno::JERR_JDIR_FMOVE = 0x0304;
+const u_int32_t jerrno::JERR_JDIR_FSTAT = 0x0305;
+
+// class nlfh
+const u_int32_t jerrno::JERR_NLFH_OPENRD = 0x0400;
+const u_int32_t jerrno::JERR_NLFH_OPENWR = 0x0401;
+const u_int32_t jerrno::JERR_NLFH_WRITE = 0x0402;
+const u_int32_t jerrno::JERR_NLFH_CLOSE = 0x0403;
+const u_int32_t jerrno::JERR_NLFH_FILEOFFSOVFL = 0x0404;
+const u_int32_t jerrno::JERR_NFLH_CMPLOFFSOVFL = 0x0405;
+const u_int32_t jerrno::JERR_NFLH_RDOFFSOVFL = 0x0406;
+
+// class file_hdr
+
+// class jrec
+const u_int32_t jerrno::JERR_JREC_INVRTAIL = 0x0600;
+
+// class data_rec
+const u_int32_t jerrno::JERR_DREC_INVRHDR = 0x0701;
+const u_int32_t jerrno::JERR_DREC_BUFFSIZE = 0x0702;
+
+// class wmgr
+const u_int32_t jerrno::JERR_WMGR_BADPGSTATE = 0x0801;
+const u_int32_t jerrno::JERR_WMGR_BADDTOKSTATE = 0x0802;
+const u_int32_t jerrno::JERR_WMGR_ENQDISCONT = 0x0803;
+
+// class rmgr
+const u_int32_t jerrno::JERR_RMGR_UNKNOWNMAGIC = 0x0900;
+
+// class data_tok
+const u_int32_t jerrno::JERR_DTOK_ILLEGALSTATE = 0x0a00;
+const u_int32_t jerrno::JERR_DTOK_RIDNOTSET = 0x0a01;
+
+// class enq_map
+const u_int32_t jerrno::JERR_EMAP_DUPLICATE = 0x0b00;
+const u_int32_t jerrno::JERR_EMAP_NOTFOUND = 0x0b01;
+
+
+bool
+jerrno::__init()
+{
+ // generic errors
+ _err_map[JERR__MALLOC] = std::string("JERR__MALLOC: Buffer memory allocation failed.");
+ _err_map[JERR__UNDERFLOW] = std::string("JERR__UNDERFLOW: Underflow error");
+ _err_map[JERR__NINIT] = std::string("JERR__NINIT: Operation on uninitialized class.");
+ _err_map[JERR__AIO] = std::string("JERR__AIO: AIO error.");
+ _err_map[JERR__FILEIO] = std::string("JERR__FILEIO: File read or write failure.");
+ _err_map[JERR__RTCLOCK] = std::string("JERR__RTCLOCK: Reading real-time clock failed.");
+
+ // class jcntl
+ _err_map[JERR_JCNTL_STOPPED] = std::string("JERR_JCNTL_STOPPED: Operation on stopped journal.");
+
+ // class jdir
+ _err_map[JERR_JDIR_MKDIR] = std::string("JERR_JDIR_MKDIR: Directory creation failed.");
+ _err_map[JERR_JDIR_DIROPEN] = std::string("JERR_JDIR_DIROPEN: Directory open failed.");
+ _err_map[JERR_JDIR_CDIROPEN] = std::string("JERR_JDIR_CDIROPEN: "
+ "Open of newly created directory failed.");
+ _err_map[JERR_JDIR_DIRCLOSE] = std::string("JERR_JDIR_DIRCLOSE: Directory close failed.");
+ _err_map[JERR_JDIR_FMOVE] = std::string("JERR_JDIR_FMOVE: File move failed.");
+ _err_map[JERR_JDIR_FSTAT] = std::string("JERR_JDIR_FSTAT: File stat failed.");
+
+ // class nlfh
+ _err_map[JERR_NLFH_OPENRD] = std::string("JERR_JNLFH_OPENRD: Unable to open file for read.");
+ _err_map[JERR_NLFH_OPENWR] = std::string("JERR_JNLFH_OPENWR: Unable to open file for write.");
+ _err_map[JERR_NLFH_WRITE] = std::string("JERR_JNLFH_WRITE: Unable to write to file.");
+ _err_map[JERR_NLFH_CLOSE] = std::string("JERR_JNLFH_CLOSE: File close failed.");
+ _err_map[JERR_NLFH_FILEOFFSOVFL] = std::string("JERR_NLFH_FILEOFFSOVFL: "
+ "Attempted increase file offset past file size.");
+ _err_map[JERR_NFLH_CMPLOFFSOVFL] = std::string("JERR_NFLH_CMPLOFFSOVFL: "
+ "Attempted increase completed file offset past submitted offset.");
+ _err_map[JERR_NFLH_RDOFFSOVFL] = std::string("JERR_NFLH_RDOFFSOVFL: "
+ "Attempted increase read offset past write offset.");
+
+
+ // class file_hdr
+
+ // class jrec
+ _err_map[JERR_JREC_INVRTAIL] = std::string("JERR_JREC_INVRTAIL: Invalid data record tail.");
+
+ // class data_rec
+ _err_map[JERR_DREC_INVRHDR] = std::string("JERR_DREC_INVRHDR: Invalid data record header.");
+ _err_map[JERR_DREC_BUFFSIZE] = std::string("JERR_DREC_BUFFSIZE: "
+ "Journal data record too big to fit into buffer.");
+
+ // class wmgr
+ _err_map[JERR_WMGR_BADPGSTATE] = std::string("JERR_WMGR_BADPGSTATE: "
+ "Page buffer in illegal state for operation.");
+ _err_map[JERR_WMGR_BADDTOKSTATE] = std::string("JERR_WMGR_BADDTOKSTATE: "
+ "Data token in illegal state for operation.");
+ _err_map[JERR_WMGR_ENQDISCONT] = std::string("JERR_WMGR_ENQDISCONT: "
+ "Enqueued new dtok when previous enqueue returned partly completed (state ENQ_PART).");
+
+ // class rmgr
+ _err_map[JERR_RMGR_UNKNOWNMAGIC] = std::string("JERR_RMGR_UNKNOWNMAGIC: "
+ "Found record with unknown magic.");
+
+ // class data_tok
+ _err_map[JERR_DTOK_ILLEGALSTATE] = std::string("JERR_MTOK_ILLEGALSTATE: "
+ "Attempted to change to illegal state.");
+ _err_map[JERR_DTOK_RIDNOTSET] = std::string("JERR_DTOK_RIDNOTSET: Record ID not set.");
+
+ // class enq_map
+ _err_map[JERR_EMAP_DUPLICATE] = std::string("JERR_EMAP_DUPLICATE: "
+ "Attempted to insert using duplicat key.");
+ _err_map[JERR_EMAP_NOTFOUND] = std::string("JERR_EMAP_NOTFOUND: Key not found in map.");
+
+ //_err_map[] = std::string("");
+
+ return true;
+}
+
+const std::string&
+jerrno::err_msg(const u_int32_t err_no) throw (int)
+{
+ _err_map_itr = _err_map.find(err_no);
+ if (_err_map_itr == _err_map.end())
+ throw -1; // not found
+ return _err_map_itr->second;
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/jerrno.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jerrno.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jerrno.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,132 @@
+/**
+* \file jerrno.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::jerrno (journal error
+* codes). See class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_jerrno_hpp
+#define rhm_journal_jerrno_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class jerrno;
+}
+}
+
+#include <map>
+#include <string>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \class jerrno
+ * \brief Class containing static error definitions and static map for error messages.
+ */
+ class jerrno
+ {
+ static std::map<u_int32_t, std::string> _err_map; ///< Map of error messages
+ static std::map<u_int32_t, std::string>::iterator _err_map_itr; ///< Iterator
+ static bool _initialized; ///< Dummy flag, used to initialise map.
+
+ public:
+ // generic errors
+ static const u_int32_t JERR__MALLOC; ///< Buffer memory allocation failed
+ static const u_int32_t JERR__UNDERFLOW; ///< Underflow error
+ static const u_int32_t JERR__NINIT; ///< Operation on uninitialized class
+ static const u_int32_t JERR__AIO; ///< AIO failure
+ static const u_int32_t JERR__FILEIO; ///< File read or write failure
+ static const u_int32_t JERR__RTCLOCK; ///< Reading real-time clock failed
+
+ // class jcntl
+ static const u_int32_t JERR_JCNTL_STOPPED; ///< Operation on stopped journal
+
+ // class jdir
+ static const u_int32_t JERR_JDIR_MKDIR; ///< Directory creation failed
+ static const u_int32_t JERR_JDIR_DIROPEN; ///< Directory open failed
+ static const u_int32_t JERR_JDIR_CDIROPEN; ///< Open of newly created directory failed
+ static const u_int32_t JERR_JDIR_DIRCLOSE; ///< Directory close failed
+ static const u_int32_t JERR_JDIR_FMOVE; ///< File move failed
+ static const u_int32_t JERR_JDIR_FSTAT; ///< File stat failed
+
+ // class nlfh
+ static const u_int32_t JERR_NLFH_OPENRD; ///< Unable to open file for read
+ static const u_int32_t JERR_NLFH_OPENWR; ///< Unable to open file for write
+ static const u_int32_t JERR_NLFH_WRITE; ///< Unable to write to file
+ static const u_int32_t JERR_NLFH_CLOSE; ///< File close failed
+ static const u_int32_t JERR_NLFH_FILEOFFSOVFL; ///< Increased offset past file size
+ static const u_int32_t JERR_NFLH_CMPLOFFSOVFL; ///< Increased cmpl offs past subm offs
+ static const u_int32_t JERR_NFLH_RDOFFSOVFL; ///< Increased read offs past write offs
+
+ // class file_hdr
+
+ // class jrec
+ static const u_int32_t JERR_JREC_INVRTAIL; ///< Invalid data record tail
+
+ // class data_rec
+ static const u_int32_t JERR_DREC_INVRHDR; ///< Invalid data record header
+ static const u_int32_t JERR_DREC_BUFFSIZE; ///< Journal data record too big for buffer
+
+ // class wmgr
+ static const u_int32_t JERR_WMGR_BADPGSTATE; ///< Page buffer in illegal state.
+ static const u_int32_t JERR_WMGR_BADDTOKSTATE; ///< Data token in illegal state.
+ static const u_int32_t JERR_WMGR_ENQDISCONT; ///< Enq. new dtok when previous part compl.
+
+ // class rmgr
+ static const u_int32_t JERR_RMGR_UNKNOWNMAGIC; ///< Found record with unknown magic
+
+ // class data_tok
+ static const u_int32_t JERR_DTOK_ILLEGALSTATE; ///< Attempted to change to illegal state
+ static const u_int32_t JERR_DTOK_RIDNOTSET; ///< Record ID not set
+
+ // class enq_map
+ static const u_int32_t JERR_EMAP_DUPLICATE; ///< Attempted to insert using duplicate key
+ static const u_int32_t JERR_EMAP_NOTFOUND; ///< Key not found in map
+
+
+ /**
+ * \brief Method to access error message from known error number.
+ */
+ static const std::string& err_msg(const u_int32_t err_no) throw (int);
+
+ private:
+ /**
+ * \brief Static function to initialize map.
+ */
+ static bool __init();
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_jerrno_hpp
Copied: store/trunk/cpp/lib/jrnl/jexception.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jexception.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jexception.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,125 @@
+/**
+* \file jexception.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* Generic journal exception class rhm::journal::jexception. See comments
+* in file jexception.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/jexception.hpp>
+
+#include <iomanip>
+#include <sstream>
+#include <jrnl/jerrno.hpp>
+
+
+namespace rhm
+{
+namespace journal
+{
+
+jexception::jexception(const u_int32_t err_code):
+ _err_code(err_code),
+ _additional_info(),
+ _throwing_class(),
+ _throwing_fn()
+
+{}
+
+jexception::jexception(const std::string& additional_info):
+ _err_code(0),
+ _additional_info(additional_info),
+ _throwing_class(),
+ _throwing_fn()
+{}
+
+jexception::jexception(const u_int32_t err_code, const std::string& additional_info):
+ _err_code(err_code),
+ _additional_info(additional_info),
+ _throwing_class(),
+ _throwing_fn()
+{}
+
+jexception::jexception(const u_int32_t err_code, const std::string& throwing_class,
+ const std::string& throwing_fn):
+ _err_code(err_code),
+ _additional_info(),
+ _throwing_class(throwing_class),
+ _throwing_fn(throwing_fn)
+{}
+
+jexception::jexception(const u_int32_t err_code, const std::string& additional_info,
+ const std::string& throwing_class, const std::string& throwing_fn):
+ _err_code(err_code),
+ _additional_info(additional_info),
+ _throwing_class(throwing_class),
+ _throwing_fn(throwing_fn)
+{}
+
+jexception::~jexception() throw ()
+{}
+
+const std::string&
+jexception::to_string(std::string& str) const
+{
+ std::stringstream ss;
+ if (!_throwing_class.empty() && !_throwing_fn.empty())
+ ss << _throwing_class << "::" << _throwing_fn << "() threw ";
+ std::string err_msg;
+ try { err_msg = jerrno::err_msg(_err_code); }
+ catch (int) { err_msg.assign("<Unknown error code>"); }
+ ss << "jexception: 0x" << std::hex << std::setw(4) << std::setfill('0') << _err_code;
+ ss << " " << err_msg;
+ if (!_additional_info.empty())
+ ss << " (" << _additional_info << ")";
+ return str.assign(ss.str());
+}
+
+const char*
+jexception::what() const throw ()
+{
+ return _additional_info.c_str();
+}
+
+std::ostream&
+operator<<(std::ostream& os, const jexception& je)
+{
+ std::string str;
+ os << je.to_string(str);
+ return os;
+}
+
+std::ostream&
+operator<<(std::ostream& os, const jexception* jePtr)
+{
+ std::string str;
+ os << jePtr->to_string(str);
+ return os;
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/jexception.hpp (from rev 891, store/trunk/cpp/jrnl/jrnl/jexception.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jexception.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,90 @@
+/**
+* \file jexception.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* Generic journal exception class rhm::journal::jexception (derived
+* from class std::exception). Intended to serve as a common exception
+* class for all more speicalized exceptions in the message journal. See
+* class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_jrnl_exception_hpp
+#define rhm_journal_jrnl_exception_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class jexception;
+}
+}
+
+#include <exception>
+#include <string>
+#include <sys/types.h>
+
+namespace rhm
+{
+namespace journal
+{
+ /**
+ * \class jexception
+ * \brief Generic journal exception class
+ */
+ class jexception : public std::exception
+ {
+ private:
+ u_int32_t _err_code;
+ std::string _additional_info;
+ std::string _throwing_class;
+ std::string _throwing_fn;
+
+ public:
+ jexception(const u_int32_t err_code);
+ jexception(const std::string& additional_info);
+ jexception(const u_int32_t err_code, const std::string& additional_info);
+ jexception(const u_int32_t err_code, const std::string& throwing_class,
+ const std::string& throwing_fn);
+ jexception(const u_int32_t err_code, const std::string& additional_info,
+ const std::string& throwing_class, const std::string& throwing_fn);
+ virtual ~jexception() throw ();
+ const std::string& to_string(std::string& str) const;
+ virtual const char* what() const throw (); // override std::exception::what()
+
+ inline const u_int32_t err_code() const { return _err_code; }
+ inline const std::string& additional_info() const { return _additional_info; }
+ inline const std::string& throwing_class() const { return _throwing_class; }
+ inline const std::string& throwing_fn() const { 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 journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_jrnl_exception_hpp
Copied: store/trunk/cpp/lib/jrnl/jinf.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jinf.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jinf.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jinf.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,99 @@
+/**
+* \file jinf.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the code for the rhm::journal::jinf class.
+*
+* See jinf.hpp comments for details of this class.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/jinf.hpp>
+
+#include <jrnl/jcntl.hpp>
+//#include <errno.h>
+//#include <iomanip>
+#include <sstream>
+//#include <jrnl/jcntl.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+jinf::jinf(const std::string& jid, const std::string& jdir, const std::string& base_filename,
+ const timespec& ts):
+ _jid(jid),
+ _jdir(jdir),
+ _base_filename(base_filename),
+ _ts(ts),
+ _tm_ptr(::localtime(&ts.tv_sec))
+{}
+
+jinf::~jinf()
+{}
+
+const std::string&
+jinf::str(std::string& s) const
+{
+ std::stringstream ss;
+ // TODO: I'm sure a more elegant way can be found to do this, but direct and simple
+ // seems like a good start!
+ ss << std::setfill('0');
+ ss << "<?xml version=\"1.0\"?>" << std::endl;
+ ss << "<jrnl>" << std::endl;
+ ss << " <journal_version value=\"" << RHM_JDAT_VERSION << "\"/>" << std::endl;
+ ss << " <journal_id>" << std::endl;
+ ss << " <id_string value=\"" << _jid << "\" />" << std::endl;
+ ss << " <directory value=\"" << _jdir << "\" />" << std::endl;
+ ss << " <base_filename value=\"" << _base_filename << "\" />" << std::endl;
+ ss << " </journal_id>" << std::endl;
+ ss << " <creation_time>" << std::endl;
+ ss << " <seconds value=\"" << _ts.tv_sec << "\" />" << std::endl;
+ ss << " <nanoseconds value=\"" << _ts.tv_nsec << "\" />" << std::endl;
+ ss << " <string vlaue=\"" << (_tm_ptr->tm_year + 1900) << "/";
+ ss << std::setw(2) << (_tm_ptr->tm_mon + 1) << "/" << std::setw(2) << _tm_ptr->tm_mday << " ";
+ ss << std::setw(2) << _tm_ptr->tm_hour << ":" << std::setw(2) << _tm_ptr->tm_min << ":";
+ ss << std::setw(2) << _tm_ptr->tm_sec << "." << std::setw(9) << _ts.tv_nsec;
+ ss << "\" />" << std::endl;
+ ss << " </creation_time>" << std::endl;
+ ss << " <journal_file_geometry>" << std::endl;
+ ss << " <JRNL_NUM_FILES value=\"" << JRNL_NUM_FILES << "\" />" << std::endl;
+ ss << " <JRNL_FILE_SIZE value=\"" << JRNL_FILE_SIZE << "\" />" << std::endl;
+ ss << " <JRNL_SBLK_SIZE value=\"" << JRNL_SBLK_SIZE << "\" />" << std::endl;
+ ss << " <JRNL_DBLK_SIZE value=\"" << JRNL_DBLK_SIZE << "\" />" << std::endl;
+ ss << " <JRNL_WMGR_PAGE_SIZE value=\"" << JRNL_WMGR_PAGE_SIZE << "\" />" << std::endl;
+ ss << " <JRNL_WMGR_PAGES value=\"" << JRNL_WMGR_PAGES << "\" />" << std::endl;
+ ss << " <JRNL_RMGR_PAGE_SIZE value=\"" << JRNL_RMGR_PAGE_SIZE << "\" />" << std::endl;
+ ss << " <JRNL_RMGR_PAGES value=\"" << JRNL_RMGR_PAGES << "\" />" << std::endl;
+ ss << " </journal_file_geometry>" << std::endl;
+ ss << "</jrnl>" << std::endl;
+ s.assign(ss.str());
+ return s;
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/jinf.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jinf.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jinf.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jinf.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,67 @@
+/**
+* \file jinf.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the code for the rhm::journal::jinf class.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_jinf_hpp
+#define rhm_journal_jinf_hpp
+
+//#include <sstream>
+//#include <jrnl/file_hdr.hpp>
+#include <jrnl/jexception.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+ /**
+ * \class jinf
+ * \brief Class to handle the journal information file <basename>.jinf.
+ */
+ class jinf
+ {
+ private:
+ const std::string& _jid;
+ const std::string& _jdir;
+ const std::string& _base_filename;
+ const timespec& _ts;
+ tm* _tm_ptr;
+
+ public:
+ jinf(const std::string& jid, const std::string& jdir, const std::string& base_filename,
+ const timespec& ts);
+ ~jinf();
+
+ const std::string& str(std::string& ss) const;
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_jinf_hpp
Copied: store/trunk/cpp/lib/jrnl/jrec.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jrec.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jrec.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jrec.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,88 @@
+/**
+* \file jrec.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing source code for class rhm::journal::jrec (abstract journal
+* jrecord). See comments in file jrec.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 jreceived 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/jrec.hpp>
+
+#include <errno.h>
+#include <iomanip>
+#include <sstream>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+jrec::jrec() {}
+jrec::~jrec() {}
+
+const u_int32_t
+jrec::size_dblks(const size_t size)
+{
+ return size_blks(size, JRNL_DBLK_SIZE);
+}
+
+const u_int32_t
+jrec::size_sblks(const size_t size)
+{
+ return size_blks(size, JRNL_DBLK_SIZE * JRNL_SBLK_SIZE);
+}
+
+const u_int32_t
+jrec::size_blks(const size_t size, const size_t blksize)
+{
+ return (size + blksize - 1)/blksize;
+}
+
+void
+jrec::chk_tail(enq_tail& tail, enq_hdr& hdr) const throw (jexception)
+{
+ std::stringstream ss;
+ if (tail._xmagic != ~hdr._hdr._magic)
+ {
+ ss << std::hex << std::setfill('0');
+ ss << "magic: rid=0x" << std::setw(16) << hdr._hdr._rid;
+ ss << ": expected=0x" << std::setw(8) << ~hdr._hdr._magic;
+ ss << " read=0x" << std::setw(8) << tail._xmagic;
+ throw jexception(jerrno::JERR_JREC_INVRTAIL, ss.str(), "jrec", "chk_tail");
+ }
+ if (tail._rid != hdr._hdr._rid)
+ {
+ ss << std::hex << std::setfill('0');
+ ss << "rid: rid=0x" << std::setw(16) << hdr._hdr._rid;
+ ss << ": read=0x" << std::setw(16) << tail._rid;
+ throw jexception(jerrno::JERR_JREC_INVRTAIL, ss.str(), "jrec", "chk_tail");
+ }
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/jrec.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/jrec.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/jrec.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/jrec.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,168 @@
+/**
+* \file jrec.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing source code for class rhm::journal::jrec (abstract journal
+* jrecord). See class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 jreceived 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 rhm_journal_jrec_hpp
+#define rhm_journal_jrec_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class jrec;
+}
+}
+
+#include <string>
+#include <sys/types.h>
+#include <jrnl/file_hdr.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \class jrec
+ * \brief Abstract class for all file jrecords, both data and log. This class establishes
+ * the common data format and structure for these jrecords.
+ */
+ class jrec
+ {
+ public:
+ jrec();
+ virtual ~jrec();
+
+ /**
+ * \brief Encode this instance of jrec into the write buffer at the disk-block-aligned
+ * pointer wptr starting at position rec_offs_dblks in the encoded record to a
+ * maximum size of max_size_dblks.
+ *
+ * This call encodes the content of the data contianed in this instance of jrec into a
+ * disk-softblock-aligned (defined by JRNL_SBLK_SIZE) buffer pointed to by parameter
+ * wptr. No more than paramter max_size_dblks data-blocks may be written to the buffer.
+ * The parameter rec_offs_dblks is the offset in data-blocks within the fully encoded
+ * data block this instance represents at which to start encoding.
+ *
+ * Encoding entails writing the record header (struct enq_hdr), the data and the record tail
+ * (struct enq_tail). The record must be data-block-aligned (defined by JRNL_DBLK_SIZE),
+ * thus any remaining space in the final data-block is ignored; the returned value is the
+ * number of data-blocks consumed from the page by the encode action. Provided the initial
+ * alignment requirements are met, records may be of arbitrary size and may span multiple
+ * data-blocks, disk-blocks and/or pages.
+ *
+ * Since the record size in data-blocks is known, the general usage pattern is to call
+ * encode() as many times as is needed to fully encode the data. Each call to encode()
+ * will encode as much of the record as it can to what remains of the current page cache,
+ * and will return the number of data-blocks actually encoded.
+ *
+ * <b>Example:</b> Assume that record r1 was previously written to page 0, and that this
+ * is an instance representing record r2. Being larger than the page size ps, r2 would span
+ * multiple pages as follows:
+ * <pre>
+ * |<---ps--->|
+ * +----------+----------+----------+----...
+ * | |r2a| r2b | r2c | |
+ * |<-r1-><----------r2----------> |
+ * +----------+----------+----------+----...
+ * page: p0 p1 p2
+ * </pre>
+ * Encoding record r2 will require multiple calls to encode; one for each page which
+ * is involved. Record r2 is divided logically into sections r2a, r2b and r2c at the
+ * points where the page boundaries intersect with the record. Assuming a page size
+ * of ps, the page boundary pointers are represented by their names p0, p1... and the
+ * sizes of the record segments are represented by their names r1, r2a, r2b..., the calls
+ * should be as follows:
+ * <pre>
+ * encode(p0+r1, 0, ps-r1); (returns r2a data-blocks)
+ * encode(p1, r2a, ps); (returns r2b data-blocks which equals ps)
+ * encode(p2, r2a+r2b, ps); (returns r2c data-blocks)
+ * </pre>
+ *
+ * \param wptr Data-block-aligned pointer to position in page buffer where encoding is to
+ * take place.
+ * \param rec_offs_dblks Offset in data-blocks within record from which to start encoding.
+ * \param max_size_dblks Maximum number of data-blocks to write to pointer wptr.
+ * \returns Number of data-blocks encoded.
+ */
+ virtual u_int32_t encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+ throw (jexception) = 0;
+
+ /**
+ * \brief Decode into this instance of jrec from the read buffer at the disk-block-aligned
+ * pointer rptr starting at position jrec_offs_dblks in the encoded record to a
+ * maximum size of max_size_blks.
+ *
+ * This call decodes a record in the page buffer pointed to by the data-block-aligned
+ * (defined by JRNL_DBLK_SIZE) parameter rptr into this instance of jrec. No more than
+ * paramter max_size_dblks data-blocks may be read from the buffer. The parameter
+ * jrec_offs_dblks is the offset in data-blocks within the encoded record at which to start
+ * decoding.
+ *
+ * Decoding entails reading the record header, the data and the tail. The record is
+ * data-block-aligned (defined by JRNL_DBLK_SIZE); the returned value is the number of
+ * data-blocks read from the buffer by the decode action. As the record data size is only
+ * known once the header is read, the number of calls required to complete reading the
+ * record will depend on the vlaues within this instance which are set when the
+ * header is decoded.
+ *
+ * A non-zero value for jrec_offs_dblks implies that this is not the first call to
+ * decode and the record data will be appended at this offset.
+ *
+ * \param h Reference to instance of struct hdr, already read from page buffer and used
+ * to determine record type
+ * \param rptr Data-block-aligned pointer to position in page buffer where decoding is to
+ * begin.
+ * \param rec_offs_dblks Offset within record from which to start appending the decoded
+ * record.
+ * \param max_size_dblks Maximum number of data-blocks to read from pointer rptr.
+ * \returns Number of data-blocks read (consumed).
+ */
+ virtual u_int32_t decode(hdr& h, void* rptr, u_int32_t rec_offs_dblks,
+ u_int32_t max_size_dblks) throw (jexception) = 0;
+
+ virtual std::string& str(std::string& str) const = 0;
+ virtual const size_t data_size() const = 0;
+ virtual const size_t rec_size() const = 0;
+ static const u_int32_t size_dblks(const size_t size);
+ static const u_int32_t size_sblks(const size_t size);
+ static const u_int32_t size_blks(const size_t size, const size_t blksize);
+
+ protected:
+ virtual void chk_hdr(enq_hdr& hdr, u_int64_t rid, bool enq = true)
+ const throw (jexception) = 0;
+ virtual void chk_tail(enq_tail& tail, enq_hdr& hdr) const throw (jexception);
+ }; // class jrec
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_jrec_hpp
Copied: store/trunk/cpp/lib/jrnl/lfh.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/lfh.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/lfh.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/lfh.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,54 @@
+/**
+* \file lfh.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::lfh (logging file
+* handle), used for controlling journal data files. See comments in file
+* lfh.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/lfh.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+lfh::lfh():
+ nlfh()
+{}
+
+lfh::lfh(const std::string& fbasename, const u_int16_t fid) throw (jexception*):
+ nlfh(fbasename, fid)
+{}
+
+lfh::~lfh()
+{}
+
+} // namespace journal
+} // namespace rhm
+
Copied: store/trunk/cpp/lib/jrnl/lfh.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/lfh.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/lfh.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/lfh.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,67 @@
+/**
+* \file lfh.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::lfh (logging file
+* handle), used for controlling journal data files. See class
+* documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_lfh_hpp
+#define rhm_journal_lfh_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class lfh;
+}
+}
+
+#include <jrnl/nlfh.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+ /**
+ * \class lfh
+ * \brief Logging journal file handler. This means that each data action is logged.
+ */
+ class lfh : public nlfh
+ {
+ public:
+ lfh();
+ lfh(const std::string& fbasename, const u_int16_t fid) throw (jexception*);
+ virtual ~lfh();
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_lfh_hpp
+
Copied: store/trunk/cpp/lib/jrnl/nlfh.cpp (from rev 891, store/trunk/cpp/jrnl/jrnl/nlfh.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/nlfh.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/nlfh.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,388 @@
+/**
+* \file nlfh.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::nlfh (non-logging file
+* handle), used for controlling journal log files. See comments in file
+* nlfh.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/nlfh.hpp>
+
+#include <cerrno>
+#include <fcntl.h>
+#include <iomanip>
+#include <sstream>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+nlfh::nlfh():
+ _fname(),
+ _fid(0),
+ _rd_fh(-1),
+ _wr_fh(-1),
+ _rec_enqcnt(0),
+ _rd_subm_cnt_dblks(0),
+ _rd_cmpl_cnt_dblks(0),
+#ifdef RHM_RDONLY
+ _wr_subm_cnt_dblks(JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1)),
+ _wr_cmpl_cnt_dblks(JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1))
+#else
+ _wr_subm_cnt_dblks(0),
+ _wr_cmpl_cnt_dblks(0)
+#endif
+{}
+
+nlfh::nlfh(const std::string& fbasename, const u_int16_t fid) throw (jexception):
+ _fname(),
+ _fid(fid),
+ _rd_fh(-1),
+ _wr_fh(-1),
+ _rec_enqcnt(0),
+ _rd_subm_cnt_dblks(0),
+ _rd_cmpl_cnt_dblks(0),
+#ifdef RHM_RDONLY
+ _wr_subm_cnt_dblks(JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1)),
+ _wr_cmpl_cnt_dblks(JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1))
+#else
+ _wr_subm_cnt_dblks(0),
+ _wr_cmpl_cnt_dblks(0)
+#endif
+{
+ initialize(fbasename, fid);
+ open();
+}
+
+nlfh::~nlfh()
+{
+ close();
+}
+
+void
+nlfh::initialize(const std::string& fbasename, const u_int16_t fid) throw (jexception)
+{
+ std::stringstream ss;
+
+ _fid = fid;
+ ss << fbasename << ".";
+ ss << std::setw(4) << std::setfill('0') << std::hex << fid;
+ ss << "." << JRNL_DATA_EXTENSION;
+ _fname = ss.str();
+
+#ifdef RHM_JOWRITE
+ // In test mode, only create file if it does not exist
+ struct stat s;
+ if (::stat(_fname.c_str(), &s))
+ {
+#endif
+ const size_t sblksize = JRNL_DBLK_SIZE * JRNL_SBLK_SIZE;
+ const size_t writesize = sblksize * JRNL_WMGR_PAGE_SIZE;
+
+ // NOTE: The journal file size is always one sblock bigger than the specified journal file
+ // size (JRNL_FILE_SIZE in jcfg.hpp), which is the data content size. The extra block is
+ // for the journal file header which precedes all data on each file and is exactly one
+ // softblock in size.
+ u_int32_t nsblks = JRNL_FILE_SIZE + 1;
+ void* nullbuf = NULL;
+ if (::posix_memalign(&nullbuf, sblksize, writesize))
+ {
+ ss << ": posix_memalign() failed: size=" << writesize << " blk_size=" << sblksize;
+ ss << " errno=" << errno;
+ throw jexception(jerrno::JERR__MALLOC, ss.str(), "nlfh", "initialize");
+ }
+ ::memset(nullbuf, 0, writesize);
+
+ int fh = ::open(_fname.c_str(), O_WRONLY | O_CREAT | O_DIRECT,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // 0644 -rw-r--r--
+ if (fh < 0)
+ {
+ ss << ": open() failed:" << "\" errno=" << errno;
+ ::free(nullbuf);
+ throw jexception(jerrno::JERR_NLFH_OPENWR, ss.str(), "nlfh", "initialize");
+ }
+
+ while (nsblks > 0)
+ {
+ u_int32_t this_write_sblks = nsblks >= JRNL_WMGR_PAGE_SIZE ?
+ JRNL_WMGR_PAGE_SIZE : nsblks;
+ if (::write(fh, (void*)nullbuf, this_write_sblks * sblksize) == -1)
+ {
+ std::stringstream ss;
+ ss << ": wr_size=" << (this_write_sblks * sblksize) << " errno=" << errno;
+ ::close(fh);
+ ::free(nullbuf);
+ throw jexception(jerrno::JERR_NLFH_WRITE, ss.str(), "nlfh", "initialize");
+ }
+ nsblks -= this_write_sblks;
+ }
+
+ // Clean up
+ ::free(nullbuf);
+ if (::close(fh))
+ {
+ ss << ": errno=" << errno;
+ throw jexception(jerrno::JERR_NLFH_CLOSE, ss.str(), "jcntl", "initialize");
+ }
+#ifdef RHM_JOWRITE
+ }
+#endif
+}
+
+bool
+nlfh::reset()
+{
+#ifndef RHM_WRONLY
+ // Journal overflow test - checks if the file to be reset still contains enqueued records
+ if (_rec_enqcnt)
+ return false;
+#endif
+#ifndef RHM_RDONLY
+ _wr_subm_cnt_dblks = 0;
+ _wr_cmpl_cnt_dblks = 0;
+#endif
+ _rd_subm_cnt_dblks = 0;
+ _rd_cmpl_cnt_dblks = 0;
+ return true;
+}
+
+const u_int32_t
+nlfh::add_enqcnt(u_int32_t a)
+{
+ _rec_enqcnt += a;
+ return _rec_enqcnt;
+}
+
+const u_int32_t
+nlfh::decr_enqcnt() throw (jexception)
+{
+ if (_rec_enqcnt == 0)
+ throw jexception (jerrno::JERR__UNDERFLOW, "nlfh", "decr_enqcnt");
+ return --_rec_enqcnt;
+}
+
+const u_int32_t
+nlfh::subtr_enqcnt(u_int32_t s) throw (jexception)
+{
+ if (_rec_enqcnt < s)
+ {
+ std::stringstream ss;
+ ss << "_rec_enqcnt=" << _rec_enqcnt << " decr=" << s;
+ throw jexception (jerrno::JERR__UNDERFLOW, ss.str(), "nlfh", "decr_enqcnt");
+ }
+ _rec_enqcnt -= s;
+ return _rec_enqcnt;
+}
+
+const u_int32_t
+nlfh::incr_rd_subm_cnt_dblks() throw (jexception)
+{
+ if (_rd_subm_cnt_dblks >= _wr_subm_cnt_dblks)
+ {
+ std::stringstream ss;
+ ss << "_rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks;
+ ss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
+ throw jexception(jerrno::JERR_NFLH_RDOFFSOVFL, ss.str(), "nlfh", "incr_rd_subm_cnt_dblks");
+ }
+ return ++_rd_subm_cnt_dblks;
+}
+
+const u_int32_t
+nlfh::add_rd_subm_cnt_dblks(u_int32_t a) throw (jexception)
+{
+ if (_rd_subm_cnt_dblks + a > _wr_subm_cnt_dblks)
+ {
+ std::stringstream ss;
+ ss << "_rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks << " incr=" << a;
+ ss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
+ throw jexception(jerrno::JERR_NFLH_RDOFFSOVFL, ss.str(), "nlfh", "add_rd_subm_cnt_dblks");
+ }
+ _rd_subm_cnt_dblks += a;
+ return _rd_subm_cnt_dblks;
+}
+
+const u_int32_t
+nlfh::incr_rd_cmpl_cnt_dblks() throw (jexception)
+{
+ if (_rd_cmpl_cnt_dblks >= _rd_subm_cnt_dblks)
+ {
+ std::stringstream ss;
+ ss << "_rd_cmpl_cnt_dblks=" << _rd_cmpl_cnt_dblks;
+ ss << " _rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks;
+ throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str(), "nlfh",
+ "incr_rd_cmpl_cnt_dblks");
+ }
+ return ++_rd_cmpl_cnt_dblks;
+}
+
+const u_int32_t
+nlfh::add_rd_cmpl_cnt_dblks(u_int32_t a) throw (jexception)
+{
+ if (_rd_cmpl_cnt_dblks + a > _rd_subm_cnt_dblks)
+ {
+ std::stringstream ss;
+ ss << "_rd_cmpl_cnt_dblks=" << _rd_cmpl_cnt_dblks << " incr=" << a;
+ ss << " _rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks;
+ throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str(), "nlfh",
+ "add_rd_cmpl_cnt_dblks");
+ }
+ _rd_cmpl_cnt_dblks += a;
+ return _rd_cmpl_cnt_dblks;
+}
+
+const u_int32_t
+nlfh::incr_wr_subm_cnt_dblks() throw (jexception)
+{
+ if (_wr_subm_cnt_dblks + 1 > JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1)) // Allow for file header
+ {
+ std::stringstream ss;
+ ss << "_wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
+ ss << " fsize=" << JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1) << " dblks";
+ throw jexception(jerrno::JERR_NLFH_FILEOFFSOVFL, ss.str(), "nlfh",
+ "incr_wr_subm_cnt_dblks");
+ }
+ return ++_wr_subm_cnt_dblks;
+}
+
+const u_int32_t
+nlfh::add_wr_subm_cnt_dblks(u_int32_t a) throw (jexception)
+{
+ if (_wr_subm_cnt_dblks + a > JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1)) // Allow for file header
+ {
+ std::stringstream ss;
+ ss << "_wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks << " incr=" << a;
+ ss << " fsize=" << JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1) << " dblks";
+ throw jexception(jerrno::JERR_NLFH_FILEOFFSOVFL, ss.str(), "nlfh",
+ "add_wr_subm_cnt_dblks");
+ }
+ _wr_subm_cnt_dblks += a;
+ return _wr_subm_cnt_dblks;
+}
+
+const u_int32_t
+nlfh::incr_wr_cmpl_cnt_dblks() throw (jexception)
+{
+ if (_wr_cmpl_cnt_dblks >= _wr_subm_cnt_dblks)
+ {
+ std::stringstream ss;
+ ss << "_wr_cmpl_cnt_dblks=" << _wr_cmpl_cnt_dblks;
+ ss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
+ throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str(), "nlfh",
+ "incr_wr_cmpl_cnt_dblks");
+ }
+ return ++_wr_cmpl_cnt_dblks;
+}
+
+const u_int32_t
+nlfh::add_wr_cmpl_cnt_dblks(u_int32_t a) throw (jexception)
+{
+ if (_wr_cmpl_cnt_dblks + a > _wr_subm_cnt_dblks)
+ {
+ std::stringstream ss;
+ ss << "_wr_cmpl_cnt_dblks=" << _wr_cmpl_cnt_dblks << " incr=" << a;
+ ss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
+ throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str(), "nlfh",
+ "add_wr_cmpl_cnt_dblks");
+ }
+ _wr_cmpl_cnt_dblks += a;
+ return _wr_cmpl_cnt_dblks;
+}
+
+const u_int32_t
+nlfh::rd_remaining_dblks() const throw (jexception)
+{
+ if (_rd_subm_cnt_dblks > _wr_subm_cnt_dblks)
+ {
+ std::stringstream ss;
+ ss << "_rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks;
+ ss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
+ throw jexception(jerrno::JERR_NFLH_RDOFFSOVFL, ss.str(), "nlfh", "rd_remaining_dblks");
+ }
+ return _wr_cmpl_cnt_dblks - _rd_subm_cnt_dblks;
+}
+
+const u_int32_t
+nlfh::wr_remaining_dblks() const throw (jexception)
+{
+ if (_wr_subm_cnt_dblks > JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1)) // Allow for file header
+ {
+ std::stringstream ss;
+ ss << "_wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
+ ss << " fsize=" << JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1) << " dblks";
+ throw jexception(jerrno::JERR_NLFH_FILEOFFSOVFL, ss.str(), "nlfh", "wr_remaining_dblks");
+ }
+ return (JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1)) - _wr_subm_cnt_dblks;
+}
+
+const bool
+nlfh::will_fit(const size_t rec_size) const
+{
+ return rec_size <= wr_remaining_dblks() * JRNL_DBLK_SIZE;
+}
+
+// Private functions
+
+void
+nlfh::open() throw (jexception)
+{
+ _rd_fh = ::open(_fname.c_str(), O_RDONLY | O_DIRECT);
+ if (_rd_fh < 0)
+ {
+ std::stringstream ss;
+ ss << "file=\"" << _fname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_NLFH_OPENRD, ss.str(), "nlfh", "open");
+ }
+ _wr_fh = ::open(_fname.c_str(), O_WRONLY | O_DIRECT,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // 0644 -rw-r--r--
+ if (_wr_fh < 0)
+ {
+ std::stringstream ss;
+ ss << "file=\"" << _fname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_NLFH_OPENWR, ss.str(), "nlfh", "open");
+ }
+}
+
+void
+nlfh::close()
+{
+ if (_rd_fh >= 0)
+ {
+ ::close(_rd_fh);
+ _rd_fh = -1;
+ }
+ if (_wr_fh >= 0)
+ {
+ ::close(_wr_fh);
+ _wr_fh = -1;
+ }
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/nlfh.hpp (from rev 891, store/trunk/cpp/jrnl/jrnl/nlfh.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/nlfh.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/nlfh.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,129 @@
+/**
+* \file nlfh.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::nlfh (non-logging file
+* handle), used for controlling journal log files. See class documentation for
+* details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_nlfh_hpp
+#define rhm_journal_nlfh_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class nlfh;
+}
+}
+
+#include <string>
+#include <jrnl/file_hdr.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \class nlfh
+ * \brief Non-logging file handler. This means that each data action is not logged.
+ */
+ class nlfh
+ {
+ protected:
+ std::string _fname; ///< File name
+ u_int16_t _fid; ///< File ID (ordinal number in ring buffer)
+ int _rd_fh; ///< Read file handle
+ int _wr_fh; ///< Write file handle
+ u_int32_t _rec_enqcnt; ///< Count of enqueued records
+ u_int32_t _rd_subm_cnt_dblks; ///< Read file count (data blocks) for submitted AIO
+ u_int32_t _rd_cmpl_cnt_dblks; ///< Read file count (data blocks) for completed AIO
+ u_int32_t _wr_subm_cnt_dblks; ///< Write file count (data blocks) for submitted AIO
+ u_int32_t _wr_cmpl_cnt_dblks; ///< Write file count (data blocks) for completed AIO
+
+ public:
+ nlfh();
+ // Constructors with implicit initialize() and open()
+ nlfh(const std::string& fbasename, const u_int16_t fid) throw (jexception);
+ virtual ~nlfh();
+
+ virtual void initialize(const std::string& fbasename, const u_int16_t fid)
+ throw (jexception);
+ virtual bool reset(); ///< Reset file handle pointers prior to reuse
+
+ inline const std::string& fname() const { return _fname; }
+ inline const u_int16_t fid() const { return _fid; }
+ inline const int rd_fh() const { return _rd_fh; }
+ inline const int wr_fh() const { return _wr_fh; }
+ inline const u_int32_t enqcnt() const { return _rec_enqcnt; }
+ inline const u_int32_t incr_enqcnt() { return ++_rec_enqcnt; }
+ const u_int32_t add_enqcnt(u_int32_t a);
+ const u_int32_t decr_enqcnt() throw (jexception);
+ const u_int32_t subtr_enqcnt(u_int32_t s) throw (jexception);
+
+ inline const u_int32_t rd_subm_cnt_dblks() const { return _rd_subm_cnt_dblks; }
+ inline const size_t rd_subm_offs() const { return _rd_subm_cnt_dblks * JRNL_DBLK_SIZE; }
+ const u_int32_t incr_rd_subm_cnt_dblks() throw (jexception);
+ const u_int32_t add_rd_subm_cnt_dblks(u_int32_t a) throw (jexception);
+
+ inline const u_int32_t rd_cmpl_cnt_dblks() const { return _rd_cmpl_cnt_dblks; }
+ inline const size_t rd_cmpl_offs() const { return _rd_cmpl_cnt_dblks * JRNL_DBLK_SIZE; }
+ const u_int32_t incr_rd_cmpl_cnt_dblks() throw (jexception);
+ const u_int32_t add_rd_cmpl_cnt_dblks(u_int32_t a) throw (jexception);
+
+ inline const u_int32_t wr_subm_cnt_dblks() const { return _wr_subm_cnt_dblks; }
+ inline const size_t wr_subm_offs() const { return _wr_subm_cnt_dblks * JRNL_DBLK_SIZE; }
+ const u_int32_t incr_wr_subm_cnt_dblks() throw (jexception);
+ const u_int32_t add_wr_subm_cnt_dblks(u_int32_t a) throw (jexception);
+
+ inline const u_int32_t wr_cmpl_cnt_dblks() const { return _wr_cmpl_cnt_dblks; }
+ inline const size_t wr_cmpl_offs() const { return _wr_cmpl_cnt_dblks * JRNL_DBLK_SIZE; }
+ const u_int32_t incr_wr_cmpl_cnt_dblks() throw (jexception);
+ const u_int32_t add_wr_cmpl_cnt_dblks(u_int32_t a) throw (jexception);
+
+ // Derived helper functions
+
+ const u_int32_t rd_remaining_dblks() const throw (jexception);
+ inline const bool is_rd_compl() const throw (jexception)
+ { return rd_remaining_dblks() == 0; }
+ const u_int32_t wr_remaining_dblks() const throw (jexception);
+ inline const bool is_wr_compl() const throw (jexception)
+ { return wr_remaining_dblks() == 0; }
+ inline const bool empty() const { return _wr_subm_cnt_dblks == 0; }
+ const bool will_fit(const size_t rec_size) const;
+
+ protected:
+ virtual void open() throw (jexception);
+ virtual void close();
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_nlfh_hpp
Copied: store/trunk/cpp/lib/jrnl/pmgr.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/pmgr.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,239 @@
+/**
+* \file pmgr.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::pmgr (page manager). See
+* comments in file pmgr.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/pmgr.hpp>
+
+#include <cerrno>
+#include <sstream>
+#include <jrnl/jcfg.hpp>
+#include <jrnl/jerrno.hpp>
+
+
+namespace rhm
+{
+namespace journal
+{
+
+pmgr::page_cb::page_cb(u_int16_t index):
+ _index(index),
+ _state(UNUSED),
+ _wdblks(0),
+ _rdblks(0),
+ _pdtokl(NULL),
+ _wfh(NULL),
+ _rfh(NULL),
+ _pbuff(NULL)
+{}
+
+const char*
+pmgr::page_cb::state_str() const
+{
+ switch(_state)
+ {
+ case UNUSED:
+ return "UNUSED";
+ case IN_USE:
+ return "IN_USE";
+ case AIO_PENDING:
+ return "AIO_PENDING";
+ case AIO_COMPLETE:
+ return "AIO_COMPLETE";
+ }
+ return "<unknown>";
+}
+
+const u_int32_t pmgr::_sblksize = JRNL_SBLK_SIZE * JRNL_DBLK_SIZE;
+
+pmgr::pmgr(enq_map& emap, const u_int32_t pagesize, const u_int16_t pages):
+ _pagesize(pagesize),
+ _pages(pages),
+ _emap(emap),
+ _dtokl(NULL),
+ _page_base_ptr(NULL),
+ _page_ptr_arr(NULL),
+ _page_cb_arr(NULL),
+ _iocb_arr(NULL),
+ _ioevt_arr(NULL),
+ _ioctx(0),
+ _pg_index(0),
+ _pg_cntr(0),
+ _pg_offset_dblks(0),
+ _aio_evt_rem(0),
+ _cb(NULL)
+{}
+
+pmgr::pmgr(enq_map& emap, const u_int32_t pagesize, const u_int16_t pages,
+ std::deque<data_tok*>* const dtokl) throw (jexception):
+ _pagesize(pagesize),
+ _pages(pages),
+ _emap(emap),
+ _dtokl(dtokl),
+ _page_base_ptr(NULL),
+ _page_ptr_arr(NULL),
+ _page_cb_arr(NULL),
+ _iocb_arr(NULL),
+ _ioevt_arr(NULL),
+ _ioctx(0),
+ _pg_index(0),
+ _pg_cntr(0),
+ _pg_offset_dblks(0),
+ _aio_evt_rem(0),
+ _data_rec(),
+ _cb(NULL)
+{
+ initialize();
+}
+
+pmgr::~pmgr()
+{
+ clean();
+}
+
+void
+pmgr::initialize() throw (jexception)
+{
+ std::stringstream ss;
+
+ // 1. Allocate page memory (as a single block)
+ size_t pagesize = _pages * _pagesize * _sblksize;
+ if (::posix_memalign(&_page_base_ptr, _sblksize, pagesize))
+ {
+ clean();
+ ss << "posix_memalign(): blksize=" << _sblksize << " size=" << pagesize;
+ ss << " errno=" << errno;
+ throw jexception(jerrno::JERR__MALLOC, ss.str(), "pmgr", "initialize");
+ }
+ // 2. Allocate array of page pointers
+ _page_ptr_arr = (void**)::malloc(_pages * sizeof(void*));
+ if (_page_ptr_arr == NULL)
+ {
+ clean();
+ ss << "_page_ptr_arr malloc(): errno=" << errno;
+ throw jexception(jerrno::JERR__MALLOC, ss.str(), "pmgr", "initialize");
+ }
+
+ // 3. Allocate and initilaize page control block (page_cb) array
+ _page_cb_arr = (page_cb*)::malloc(_pages * sizeof(page_cb));
+ if (_page_cb_arr == NULL)
+ {
+ clean();
+ ss << "_page_cb_arr malloc(): errno=" << errno;
+ throw jexception(jerrno::JERR__MALLOC, ss.str(), "pmgr", "initialize");
+ }
+ ::memset(_page_cb_arr, 0, _pages * sizeof(page_cb));
+
+ // 5. Allocate IO control block (iocb) array
+ _iocb_arr = (iocb*)::malloc(_pages * sizeof(iocb));
+ if (_iocb_arr == NULL)
+ {
+ clean();
+ ss << "_iocb_arr malloc(): errno=" << errno;
+ throw jexception(jerrno::JERR__MALLOC, ss.str(), "pmgr", "initialize");
+ }
+
+ // 6. Set page pointers in _page_ptr_arr, _page_cb_arr and iocbs to pages within page block
+ for (u_int16_t i=0; i<_pages; i++)
+ {
+ _page_ptr_arr[i] = (void*)((char*)_page_base_ptr + _pagesize * _sblksize * i);
+ _page_cb_arr[i]._index = i;
+ _page_cb_arr[i]._state = UNUSED;
+ _page_cb_arr[i]._pbuff = _page_ptr_arr[i];
+ _page_cb_arr[i]._pdtokl = ::new std::deque<data_tok*>;
+ _page_cb_arr[i]._pdtokl->clear();
+ _iocb_arr[i].data = (void*)&_page_cb_arr[i];
+ }
+
+ // 7. Allocate io_event array, max one event per cache page in rmgr and wmgr
+ const u_int16_t max_aio_evts = JRNL_RMGR_PAGES + JRNL_WMGR_PAGES;
+ _ioevt_arr = (io_event*)::malloc(max_aio_evts * sizeof(io_event));
+ if (_ioevt_arr == NULL)
+ {
+ clean();
+ ss << "_ioevt_arr malloc(): errno=" << errno;
+ throw jexception(jerrno::JERR__MALLOC, ss.str(), "pmgr", "initialize");
+ }
+
+ // 8. Initialize AIO context
+ if (int ret = ::io_queue_init(max_aio_evts, &_ioctx))
+ {
+ ss << "io_queue_init() failed: " << strerror(-ret) << " (" << ret << ")";
+ throw jexception(jerrno::JERR__AIO, ss.str(), "pmgr", "initialize");
+ }
+}
+
+bool
+pmgr::rotate_page(page_state state)
+{
+ _page_cb_arr[_pg_index]._state = state;
+ _pg_offset_dblks = 0;
+ if (++_pg_index >= _pages)
+ _pg_index = 0;
+ _pg_cntr++;
+ return false;
+}
+
+void
+pmgr::clean()
+{
+ if (_ioctx)
+ ::io_queue_release(_ioctx);
+ if (_page_base_ptr)
+ {
+ ::free(_page_base_ptr);
+ _page_base_ptr = NULL;
+ }
+ if (_page_ptr_arr)
+ {
+ for (int i=0; i<_pages; i++)
+ ::delete _page_cb_arr[i]._pdtokl;
+ ::free(_page_ptr_arr);
+ _page_ptr_arr = NULL;
+ }
+ if (_page_cb_arr)
+ {
+ ::free(_page_cb_arr);
+ _page_cb_arr = NULL;
+ }
+ if (_iocb_arr)
+ {
+ ::free(_iocb_arr);
+ _iocb_arr = NULL;
+ }
+ if (_ioevt_arr)
+ {
+ ::free(_ioevt_arr);
+ _ioevt_arr = NULL;
+ }
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/pmgr.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/pmgr.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/pmgr.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,147 @@
+/**
+* \file pmgr.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::pmgr (page manager). See
+* class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_pmgr_hpp
+#define rhm_journal_pmgr_hpp
+
+namespace rhm
+{
+namespace journal
+{
+ class pmgr;
+}
+}
+
+#include <deque>
+#include <libaio.h>
+#include <jrnl/aio_cb.hpp>
+#include <jrnl/data_rec.hpp>
+#include <jrnl/data_tok.hpp>
+#include <jrnl/enq_map.hpp>
+#include <jrnl/nlfh.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+ // TODO: Change this to flags, as multiple of these conditions may exist simultaneously
+ /**
+ * \brief Enumeration of possilbe return states from journal read and write operations.
+ */
+ enum _iores
+ {
+ RHM_IORES_SUCCESS, ///< Success: IO operation completed noramlly.
+ RHM_IORES_AIO_WAIT, ///< IO operation suspended as all pages in cache are waiting for AIO.
+ RHM_IORES_EMPTY, ///< During read operations, nothing further is available to read.
+ RHM_IORES_FULL, ///< During write operations, the journal files are full.
+ RHM_IORES_BUSY ///< Another blocking operation is in progress.
+ };
+ typedef _iores iores;
+
+ /**
+ * \brief Abstract class for managing either read or write page cache of arbitrary size and
+ * number of pages.
+ */
+ class pmgr
+ {
+ public:
+ /**
+ * \brief Enumeration of possible stats of a page within a page cache.
+ */
+ enum page_state
+ {
+ UNUSED, ///< A page is uninitialized, contains no data.
+ IN_USE, ///< Page is in use.
+ AIO_PENDING, ///< An AIO request outstanding.
+ AIO_COMPLETE ///< An AIO request is complete.
+ };
+
+ protected:
+ /**
+ * \brief Page control block, carries control and state information for each page in the
+ * cache.
+ */
+ struct page_cb
+ {
+ u_int16_t _index; ///< Index of this page
+ page_state _state; ///< Status of page
+ u_int64_t _frid; ///< First rid in page (used for fhdr init)
+ u_int32_t _wdblks; ///< Total number of dblks in page so far
+ u_int32_t _rdblks; ///< Total number of dblks in page so far
+ std::deque<data_tok*>* _pdtokl; ///< Page message tokens list
+ nlfh* _wfh; ///< File handle for incrementing write compl counts
+ nlfh* _rfh; ///< File handle for incrementing read compl counts
+ void* _pbuff; ///< Page buffer
+
+ page_cb(u_int16_t index); ///< Convenience constructor
+ const char* state_str() const; ///< Return state as string for this pcb
+ };
+
+ static const u_int32_t _sblksize; ///< Disk softblock size
+ const u_int32_t _pagesize; ///< Size of page cache pages
+ const u_int16_t _pages; ///< Number of page cache pages
+ enq_map& _emap; ///< Ref to enqueue map
+ std::deque<data_tok*>* _dtokl; ///< Pointer to external data token list
+ void* _page_base_ptr; ///< Base pointer to page memory
+ void** _page_ptr_arr; ///< Array of pointers to pages in page memory
+ page_cb* _page_cb_arr; ///< Array of page_cb structs
+ iocb* _iocb_arr; ///< Array of iocb structs
+ io_event* _ioevt_arr; ///< Array of io_events
+ io_context_t _ioctx; ///< AIO context for read/write operations
+ u_int16_t _pg_index; ///< Index of current page being used
+ u_int32_t _pg_cntr; ///< Page counter; determines if file rotation req'd
+ u_int32_t _pg_offset_dblks; ///< Page offset (used so far) in data blocks
+ u_int32_t _aio_evt_rem; ///< Remaining AIO events
+ data_rec _data_rec; ///< Data record into/from which data is encoded/decoded
+ // TODO: move _cb down to wmgr, it is the only class that uses it There is no need for
+ // read callbacks based on AIO. - (check this asertion)
+ aio_cb _cb; ///< Callback function pointer for AIO events
+
+ public:
+ pmgr(enq_map& emap, const u_int32_t pagesize, const u_int16_t pages);
+ pmgr(enq_map& emap, const u_int32_t pagesize, const u_int16_t pages,
+ std::deque<data_tok*>* const dtokl) throw (jexception);
+ virtual ~pmgr();
+
+ virtual const u_int32_t get_events(page_state state) throw (jexception) = 0;
+ inline const u_int32_t get_aio_evt_rem() const { return _aio_evt_rem; }
+
+ protected:
+ virtual void initialize() throw (jexception);
+ virtual bool rotate_page(page_state state = UNUSED);
+ virtual void clean();
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_pmgr_hpp
Copied: store/trunk/cpp/lib/jrnl/rmgr.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/rmgr.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,347 @@
+/**
+* \file rmgr.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::rmgr (read manager). See
+* comments in file rmgr.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/rmgr.hpp>
+
+#include <assert.h>
+#include <cerrno>
+#include <sstream>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+rmgr::rmgr(enq_map& emap, rrfc& rrfc):
+ pmgr(emap, JRNL_RMGR_PAGE_SIZE, JRNL_RMGR_PAGES),
+ _rrfc(rrfc),
+ _hdr()
+{}
+
+rmgr::rmgr(enq_map& emap, rrfc& rrfc, std::deque<data_tok*>* const dtokl) throw (jexception):
+ pmgr(emap, JRNL_RMGR_PAGE_SIZE, JRNL_RMGR_PAGES, dtokl),
+ _rrfc(rrfc),
+ _hdr()
+{}
+
+rmgr::~rmgr()
+{}
+
+void
+rmgr::initialize(std::deque<data_tok*>* const dtokl, const aio_cb rd_cb) throw (jexception)
+{
+ _dtokl = dtokl;
+ _cb = rd_cb;
+ initialize();
+}
+
+const iores
+rmgr::read(void* const mbuf, const size_t mbsize, data_tok* dtok) throw (jexception)
+{
+ if (_aio_evt_rem)
+ get_events();
+ if(dblks_rem() == 0 && _rrfc.empty())
+ return RHM_IORES_EMPTY;
+
+ if (dtok->rstate() == data_tok::READ_PART)
+ {
+ assert(dtok->rid() == _hdr._rid);
+ void* rptr = (void*)((char*)_page_ptr_arr[_pg_index] + (_pg_offset_dblks * JRNL_DBLK_SIZE));
+ return read_enq(_hdr, rptr, dtok);
+ }
+ else
+ {
+ _hdr.reset();
+ // Read header, determine next record type
+ while (true)
+ {
+ if (_page_cb_arr[_pg_index]._state != AIO_COMPLETE)
+ {
+ aio_cycle();
+ return RHM_IORES_AIO_WAIT;
+ }
+ void* rptr = (void*)((char*)_page_ptr_arr[_pg_index] +
+ (_pg_offset_dblks * JRNL_DBLK_SIZE));
+ ::memcpy(&_hdr, rptr, sizeof(hdr));
+ dtok->set_rid(_hdr._rid);
+ switch (_hdr._magic)
+ {
+ case RHM_JDAT_ENQ_MAGIC:
+ _data_rec.reset(mbuf, mbsize);
+ return read_enq(_hdr, rptr, dtok);
+ case RHM_JDAT_DEQ_MAGIC:
+ consume_deq();
+ break;
+ case RHM_JDAT_EMPTY_MAGIC:
+ consume_filler();
+ break;
+ default:
+ std::stringstream ss;
+ ss << std::setw(8) << std::setfill('0');
+ ss << std::hex << "Magic=0x" << _hdr._magic << std::dec;
+ throw jexception(jerrno::JERR_RMGR_UNKNOWNMAGIC, ss.str(), "rmgr", "read");
+ }
+ }
+ }
+}
+
+const u_int32_t
+rmgr::get_events(page_state state) throw (jexception)
+{
+ int ret = 0;
+ if ((ret = ::io_getevents(_ioctx, 0, JRNL_RMGR_PAGES + JRNL_WMGR_PAGES, _ioevt_arr, NULL)) < 0)
+ {
+ if (ret == -EINTR) // No events
+ return 0;
+ std::stringstream ss;
+ ss << "io_getevents() failed: " << strerror(-ret) << " (" << ret << ")";
+ throw jexception(jerrno::JERR__AIO, ss.str(), "rmgr", "get_events");
+ }
+
+ u_int32_t tot_data_toks = 0;
+ for (int i=0; i<ret; i++) // Index of returned AIOs
+ {
+ if (_aio_evt_rem == 0)
+ {
+ std::stringstream ss;
+ ss << "_aio_evt_rem; evt " << (i + 1) << " of " << ret;
+ throw jexception(jerrno::JERR__UNDERFLOW, ss.str(), "rmgr", "get_events");
+ }
+ _aio_evt_rem--;
+ iocb* iocbp = _ioevt_arr[i].obj; // This I/O control block (iocb)
+ page_cb* pcbp = (page_cb*)(iocbp->data); // This page control block (pcb)
+ long aioret = (long)_ioevt_arr[i].res;
+ if (aioret < 0)
+ {
+ std::stringstream ss;
+ ss << "AIO read operation failed: " << strerror(-aioret) << " (" << aioret << ")";
+ ss << " [pg=" << pcbp->_index << " size=" << iocbp->u.c.nbytes;
+ ss << " offset=" << iocbp->u.c.offset << " fh=" << iocbp->aio_fildes << "]";
+ throw jexception(jerrno::JERR__AIO, ss.str(), "rmgr", "get_events");
+ }
+
+ // Transfer all data tokens
+ u_int32_t s = pcbp->_pdtokl->size();
+ for (u_int32_t k=0; k<s; k++)
+ _dtokl->push_back(pcbp->_pdtokl->at(k));
+ tot_data_toks += s;
+
+ // Increment the completed read offset
+ // NOTE: We cannot use _rrfc here, as it may have rotated since submitting count.
+ // Use stored pointer to nlfh in the pcb instead.
+ pcbp->_rdblks = iocbp->u.c.nbytes / JRNL_DBLK_SIZE;
+ pcbp->_rfh->add_rd_cmpl_cnt_dblks(pcbp->_rdblks);
+
+ // Clean up this pcb's data_tok list
+ pcbp->_pdtokl->clear();
+ pcbp->_state = state;
+
+ // Perform AIO return callback
+ if (_cb)
+ (_cb)(s);
+ }
+
+ return tot_data_toks;
+}
+
+void
+rmgr::initialize() throw (jexception)
+{
+ pmgr::initialize();
+}
+
+const iores
+rmgr::read_enq(hdr& h, void* rptr, data_tok* dtok)
+ throw (jexception)
+{
+ if (_page_cb_arr[_pg_index]._state != AIO_COMPLETE)
+ {
+ aio_cycle(); // check if any AIOs have returned
+ return RHM_IORES_AIO_WAIT;
+ }
+
+ // Read data from this page, first block will have header and data size.
+ u_int32_t dblks_rd = _data_rec.decode(h, rptr, dtok->dblocks_proc(), dblks_rem());
+ dtok->incr_dblocks_proc(dblks_rd);
+
+ _pg_offset_dblks += dblks_rd;
+
+ // If data still incomplete, move to next page and decode again
+ while (dtok->dblocks_proc() < _data_rec.rec_size_dblks())
+ {
+ rotate_page();
+ if (_page_cb_arr[_pg_index]._state != AIO_COMPLETE)
+ {
+ dtok->set_rstate(data_tok::READ_PART);
+ dtok->set_dsize(_data_rec.data_size());
+ return RHM_IORES_AIO_WAIT;
+ }
+
+ rptr = (void*)((char*)_page_ptr_arr[_pg_index]);
+ dblks_rd = _data_rec.decode(h, rptr, dtok->dblocks_proc(), dblks_rem());
+ dtok->incr_dblocks_proc(dblks_rd);
+ _pg_offset_dblks += dblks_rd;
+ }
+
+ // If we have finished with this page, rotate it
+ if (dblks_rem() == 0)
+ rotate_page();
+
+ // Set the record size in dtok
+ dtok->set_rstate(data_tok::READ);
+ dtok->set_dsize(_data_rec.data_size());
+ return RHM_IORES_SUCCESS;
+}
+
+void
+rmgr::consume_deq() throw (jexception)
+{
+ // TODO: Check: Assumption - dequeue record fills one dblk, but dblk size is tunable.
+ _pg_offset_dblks++;
+ if (dblks_rem() == 0)
+ rotate_page();
+}
+
+void
+rmgr::consume_filler() throw (jexception)
+{
+ // Filler (Magic "RHMx") is one dblk by definition
+ _pg_offset_dblks++;
+ if (dblks_rem() == 0)
+ rotate_page();
+}
+
+void
+rmgr::aio_cycle() throw (jexception)
+{
+ int16_t first_uninit = -1;
+ u_int16_t num_uninit = 0;
+ bool outstanding = false;
+ // Index must start with current buffer and cycle around so that first
+ // uninitialized buffer is initialized first
+ for (u_int16_t i=_pg_index; i<_pg_index+_pages; i++)
+ {
+ int16_t ci = i % _pages;
+ switch (_page_cb_arr[ci]._state)
+ {
+ case UNUSED:
+ if (first_uninit < 0)
+ first_uninit = ci;
+ num_uninit++;
+ break;
+ case IN_USE:
+ break;
+ case AIO_PENDING:
+ outstanding = true;
+ break;
+ default:;
+ }
+ }
+ if (num_uninit)
+ init_aio_reads(first_uninit, num_uninit);
+ if (outstanding)
+ get_events();
+}
+
+void
+rmgr::init_aio_reads(const int16_t first_uninit, const u_int16_t num_uninit) throw (jexception)
+{
+ for (int16_t i=0; i<num_uninit; i++)
+ {
+ if (_rrfc.empty()) // Nothing to do; this file not yet written to
+ break;
+
+ // If this is the first read from a file, increase the read pointers to beyond fhdr
+ // or consume fhdr here for analysis (not req'd at present)
+ if (_rrfc.subm_offs() == 0)
+ {
+ _rrfc.add_subm_cnt_dblks(JRNL_SBLK_SIZE);
+ _rrfc.add_cmpl_cnt_dblks(JRNL_SBLK_SIZE);
+ }
+
+ // TODO: Future perf improvement: Do a single AIO read for all available file
+ // space into all contiguous empty pages in one AIO operation.
+
+ u_int32_t file_rem_dblks = _rrfc.remaining_dblks();
+ u_int32_t pg_size_dblks = JRNL_RMGR_PAGE_SIZE * JRNL_SBLK_SIZE;
+ u_int32_t rd_size = file_rem_dblks > pg_size_dblks ? pg_size_dblks : file_rem_dblks;
+ if (rd_size)
+ {
+ int16_t pi = (i + first_uninit) % _pages;
+ // TODO: For perf, combine contiguous pages into single read
+ // 1 or 2 AIOs needed depending on whether read block folds
+ iocb* this_iocb_ptr = &_iocb_arr[pi];
+ rhm_prep_pread(this_iocb_ptr, _rrfc.fh(), _page_ptr_arr[pi],
+ rd_size * JRNL_DBLK_SIZE, _rrfc.subm_offs());
+ if (::io_submit(_ioctx, 1, &this_iocb_ptr) < 0)
+ throw jexception(jerrno::JERR__AIO, "rmgr", "init_aio_reads");
+ _rrfc.add_subm_cnt_dblks(rd_size);
+ _aio_evt_rem++;
+ _page_cb_arr[pi]._state = AIO_PENDING;
+ _page_cb_arr[pi]._rfh = _rrfc.file_handle();
+ }
+ if (_rrfc.is_compl())
+ _rrfc.rotate();
+ }
+}
+
+void
+rmgr::consume_fhdr() throw (jexception)
+{
+ // If in the future it should become necessary to read each file header, this is where it would
+ // happen.
+
+ // Set read pointers to first dblk after file header
+ _rrfc.add_subm_cnt_dblks(JRNL_SBLK_SIZE);
+ _rrfc.add_cmpl_cnt_dblks(JRNL_SBLK_SIZE);
+}
+
+void
+rmgr::rotate_page()
+{
+ pmgr::rotate_page();
+ aio_cycle();
+ _pg_offset_dblks = 0;
+ // This counter is for bookkeeping only, page rotates are handled directly in init_aio_reads()
+ if (_pg_cntr >= (JRNL_FILE_SIZE / JRNL_RMGR_PAGE_SIZE))
+ _pg_cntr = 0;
+}
+
+const u_int32_t
+rmgr::dblks_rem() const
+{
+ return _page_cb_arr[_pg_index]._rdblks - _pg_offset_dblks;
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/rmgr.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/rmgr.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/rmgr.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,106 @@
+/**
+* \file rmgr.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::rmgr (read manager). See
+* class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_rmgr_hpp
+#define rhm_journal_rmgr_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class rmgr;
+}
+}
+
+#include <jrnl/pmgr.hpp>
+#include <jrnl/rrfc.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \brief Class for managing a read page cache of arbitrary size and number of pages.
+ *
+ * The read page cache works on the principle of filling as many pages as possilbe in advance of
+ * reading the data. This ensures that delays caused by AIO operations are minimized.
+ */
+ class rmgr : public pmgr
+ {
+ private:
+ rrfc& _rrfc; ///< Ref to write rotating file controller
+ hdr _hdr; ///< Header used to determind record type
+
+ public:
+ rmgr(enq_map& emap, rrfc& rrfc);
+ rmgr(enq_map& emap, rrfc& rrfc, std::deque<data_tok*>* const dtokl) throw (jexception);
+ ~rmgr();
+
+ void initialize(std::deque<data_tok*>* const dtokl, const aio_cb rd_cb) throw (jexception);
+ const iores read(void* const mbuf, const size_t mbsize, data_tok* dtok)
+ throw (jexception);
+ const u_int32_t get_events(page_state state = AIO_COMPLETE) throw (jexception);
+
+ private:
+ void initialize() throw (jexception);
+ const iores read_enq(hdr& h, void* rptr, data_tok* dtok) throw (jexception);
+ void consume_deq() throw (jexception);
+ void consume_filler() throw (jexception);
+ void aio_cycle() throw (jexception);
+ void init_aio_reads(const int16_t first_uninit, const u_int16_t num_uninit)
+ throw (jexception);
+ void consume_fhdr() throw (jexception);
+ void rotate_page();
+ const u_int32_t dblks_rem() const;
+
+
+ // Special version of libaio's io_prep_pread() which preserves the value of the data
+ // pointer. This allows iocbs to be initialized with a pointer that can be re-used. Note
+ // that C++ does not support type long long, this has been replaced with int64_t.
+ static inline void rhm_prep_pread(struct iocb *iocb, int fd, void *buf, size_t count,
+ int64_t offset)
+ {
+ ::memset((void*)((char*)iocb + sizeof(void*)), 0, sizeof(*iocb) - sizeof(void*));
+ iocb->aio_fildes = fd;
+ iocb->aio_lio_opcode = IO_CMD_PREAD;
+ iocb->aio_reqprio = 0;
+ iocb->u.c.buf = buf;
+ iocb->u.c.nbytes = count;
+ iocb->u.c.offset = offset;
+ }
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_rmgr_hpp
Copied: store/trunk/cpp/lib/jrnl/rrfc.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/rrfc.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/rrfc.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/rrfc.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,86 @@
+/**
+* \file rrfc.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::rrfc (rotating
+* file controller). See comments in file rrfc.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/rrfc.hpp>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+rrfc::rrfc():
+ _nfiles(0),
+ _fh_arr(NULL),
+ _fh_index(0),
+ _curr_fh(NULL)
+{}
+
+rrfc::~rrfc() {}
+
+void
+rrfc::initialize(u_int32_t nfiles, nlfh** fh_arr, u_int32_t fh_index) throw (jexception)
+{
+ _nfiles = nfiles;
+ _fh_arr = fh_arr;
+ _fh_index = fh_index;
+ _curr_fh = _fh_arr[_fh_index];
+}
+
+bool
+rrfc::rotate() throw (jexception)
+{
+ if (!_nfiles)
+ throw jexception(jerrno::JERR__NINIT, "rrfc", "rotate");
+ u_int16_t next_fh_index = _fh_index + 1;
+ if (next_fh_index == _nfiles)
+ next_fh_index = 0;
+ nlfh* next_fh = _fh_arr[next_fh_index];
+#ifdef RHM_RDONLY
+ // Since write constrains read, it is wrfc::rotate() that normally resets both the
+ // read and write states. However, in the RHM_RDONLY test mode (no writes), it must
+ // be done here.
+ bool ret = next_fh->reset();
+#endif
+
+ _fh_index = next_fh_index;
+ _curr_fh = next_fh;
+#ifdef RHM_RDONLY
+ return ret;
+#else
+ return true;
+#endif
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/rrfc.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/rrfc.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/rrfc.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/rrfc.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,130 @@
+/**
+* \file rrfc.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::rrfc (rotating
+* file controller). See class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_rrfc_hpp
+#define rhm_journal_rrfc_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class rrfc;
+}
+}
+
+#include <jrnl/nlfh.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \class rrfc
+ * \brief Class to handle manangement of a journal rotating file handle.
+ */
+ class rrfc
+ {
+ protected:
+ u_int32_t _nfiles; ///< Number of data files
+ nlfh** _fh_arr; ///< Array of pointers to data file handles
+ u_int16_t _fh_index; ///< Index of current file handle
+ nlfh* _curr_fh; ///< Pointer to current file handle
+
+ public:
+ rrfc();
+ virtual ~rrfc();
+
+ /**
+ * \brief Initialize the controller.
+ * \param nfiles Number of files in the rotating file group.
+ * \param fh_arr Pointer to an array of file handles (nlogging_fh or subclasses),
+ * each of which correspond to one of the physical files.
+ * \param fh_index Initial index of journal file. Default = 0.
+ */
+ void initialize(u_int32_t nfiles, nlfh** fh_arr, u_int32_t fh_index = 0)
+ throw (jexception);
+
+ /**
+ * \brief Rotate active file handle to next file in rotating file group.
+ * \exception jerrno::JERR__NINIT if called before calling initialize().
+ */
+ bool rotate() throw (jexception);
+
+ /**
+ * \brief Returns the index of the currently active file within the rotating
+ * file group.
+ */
+ inline const u_int16_t index() const { return _fh_index; }
+
+ /**
+ * \brief Returns the currently active journal file handle within the rotating
+ * file group.
+ */
+ inline nlfh* file_handle() const { return _curr_fh; }
+
+ // Convenience access methods to current file handle
+
+ inline const u_int32_t fid() const { return _curr_fh->fid(); }
+ inline const int fh() const { return _curr_fh->rd_fh(); }
+ inline const u_int32_t enqcnt() const { return _curr_fh->enqcnt(); }
+ inline const u_int32_t incr_enqcnt() { return _curr_fh->incr_enqcnt(); }
+ inline const u_int32_t add_enqcnt(u_int32_t a) { return _curr_fh->add_enqcnt(a); }
+ inline const u_int32_t decr_enqcnt(u_int16_t fid) { return _fh_arr[fid]->decr_enqcnt(); }
+ inline const u_int32_t subtr_enqcnt(u_int16_t fid, u_int32_t s)
+ { return _fh_arr[fid]->subtr_enqcnt(s); }
+
+ inline const u_int32_t subm_cnt_dblks() const { return _curr_fh->rd_subm_cnt_dblks(); }
+ inline const size_t subm_offs() const { return _curr_fh->rd_subm_offs(); }
+ inline const u_int32_t incr_subm_cnt_dblks() throw (jexception)
+ { return _curr_fh->incr_rd_subm_cnt_dblks(); }
+ inline const u_int32_t add_subm_cnt_dblks(u_int32_t a) throw (jexception)
+ { return _curr_fh->add_rd_subm_cnt_dblks(a); }
+
+ inline const u_int32_t cmpl_cnt_dblks() const { return _curr_fh->rd_cmpl_cnt_dblks(); }
+ inline const size_t cmpl_offs() const { return _curr_fh->rd_cmpl_offs(); }
+ inline const u_int32_t incr_cmpl_cnt_dblks() throw (jexception)
+ { return _curr_fh->incr_rd_cmpl_cnt_dblks(); }
+ inline const u_int32_t add_cmpl_cnt_dblks(u_int32_t a) throw (jexception)
+ { return _curr_fh->add_rd_cmpl_cnt_dblks(a); }
+
+ inline const u_int32_t remaining_dblks() const throw (jexception)
+ { return _curr_fh->rd_remaining_dblks(); }
+ inline const bool is_compl() const throw (jexception) { return _curr_fh->is_rd_compl(); };
+ inline const bool empty() const { return _curr_fh->empty(); }
+ inline const bool will_fit(const size_t size) const { return _curr_fh->will_fit(size); }
+ }; // class rrfc
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_rrfc_hpp
Copied: store/trunk/cpp/lib/jrnl/wmgr.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/wmgr.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,484 @@
+/**
+* \file wmgr.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::wmgr (read manager). See
+* comments in file wmgr.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/wmgr.hpp>
+
+#include <assert.h>
+#include <cerrno>
+#include <sstream>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+wmgr::wmgr(enq_map& emap, wrfc& wrfc):
+ pmgr(emap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES),
+ _wrfc(wrfc),
+ _max_dtokpp(0),
+ _max_io_wait_us(0),
+ _fhdr_buff(NULL),
+ _cached_offset_dblks(0),
+ _enq_busy(false)
+{}
+
+wmgr::wmgr(enq_map& emap, wrfc& wrfc, std::deque<data_tok*>* const dtokl,
+ const u_int32_t max_dtokpp, const u_int32_t max_iowait_us) throw (jexception):
+ pmgr(emap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES, dtokl),
+ _wrfc(wrfc),
+ _max_dtokpp(max_dtokpp),
+ _max_io_wait_us(max_iowait_us),
+ _fhdr_buff(NULL),
+ _cached_offset_dblks(0),
+ _enq_busy(false)
+{}
+
+wmgr::~wmgr()
+{
+ if (_fhdr_buff)
+ {
+ ::free(_fhdr_buff);
+ _fhdr_buff = NULL;
+ }
+}
+
+void
+wmgr::initialize(std::deque<data_tok*>* dtokl, const aio_cb wr_cb, const u_int32_t max_dtokpp,
+ const u_int32_t max_iowait_us) throw (jexception)
+{
+ _dtokl = dtokl;
+ _max_dtokpp = max_dtokpp;
+ _max_io_wait_us = max_iowait_us;
+ _cb = wr_cb;
+ initialize();
+}
+
+const iores
+wmgr::enqueue(const void* const mbuf, const size_t dlen, data_tok* dtok) throw (jexception)
+{
+ iores res = pre_write_check(true, dtok);
+ if (res != RHM_IORES_SUCCESS)
+ return res;
+
+ bool cont = false;
+ if (_enq_busy) // If enqueue() exited last time with RHM_IORES_FULL or RHM_IORES_AIO_WAIT
+ {
+ if (dtok->wstate() == data_tok::ENQ_PART)
+ cont = true;
+ else
+ {
+ std::stringstream ss;
+ ss << "This data_tok: id=" << dtok->id() << " state=" << dtok->wstate_str();
+ throw jexception(jerrno::JERR_WMGR_ENQDISCONT, ss.str(), "wmgr", "enqueue");
+ }
+ }
+ else
+ _enq_busy = true;
+
+ u_int64_t rid = cont ? _wrfc.rid() - 1 : _wrfc.get_incr_rid();
+ _data_rec.reset(rid, mbuf, dlen);
+ if (!cont)
+ dtok->set_rid(rid);
+ bool done = false;
+ while (!done)
+ {
+ assert(_pg_offset_dblks < JRNL_WMGR_PAGE_SIZE * JRNL_SBLK_SIZE);
+ void* wptr = (void*)((char*)_page_ptr_arr[_pg_index] + _pg_offset_dblks * JRNL_DBLK_SIZE);
+ u_int32_t data_offs_dblks = dtok->dblocks_proc();
+ u_int32_t ret = _data_rec.encode(wptr, data_offs_dblks,
+ (JRNL_WMGR_PAGE_SIZE * JRNL_SBLK_SIZE) - _pg_offset_dblks);
+#if !(defined(RHM_WRONLY) || defined(RHM_RDONLY))
+ if (data_offs_dblks == 0)
+ {
+ _wrfc.incr_enqcnt();
+ _emap.insert_fid(rid, _wrfc.index());
+ }
+#endif
+ _pg_offset_dblks += ret;
+ _cached_offset_dblks += ret;
+ dtok->incr_dblocks_proc(ret);
+
+ // Is the encoding of this record complete?
+ if (dtok->dblocks_proc() >= _data_rec.rec_size_dblks())
+ {
+ // TODO: Incorrect - must set state to ENQ_CACHED; ENQ_SUBM is set when AIO returns.
+ dtok->set_wstate(data_tok::ENQ_SUBM);
+ dtok->set_dsize(dlen);
+ // Only add this data token to page token list when submit is complete, this way
+ // long multi-page messages have their token on the page containing the END of the
+ // message. AIO callbacks will then only process this token when entire message is
+ // enqueued.
+ _page_cb_arr[_pg_index]._pdtokl->push_back(dtok);
+ done = true;
+ }
+
+ // Has the file header been written (i.e. write pointers still at 0)?
+ if (_wrfc.empty())
+ {
+ u_int32_t rec_dblks_rem = _data_rec.rec_size_dblks() - data_offs_dblks;
+ bool file_fit = rec_dblks_rem <= JRNL_FILE_SIZE * JRNL_SBLK_SIZE;
+ bool file_full = rec_dblks_rem == JRNL_FILE_SIZE * JRNL_SBLK_SIZE;
+ size_t fro = 0;
+ if (cont)
+ {
+ if (file_fit && !file_full)
+ fro = (rec_dblks_rem + JRNL_SBLK_SIZE) * JRNL_DBLK_SIZE;
+ }
+ else
+ fro = JRNL_SBLK_SIZE * JRNL_DBLK_SIZE;
+ write_fhdr(rid, _wrfc.index(), fro);
+ }
+
+ // Is the page full? If so, flush.
+ if (_pg_offset_dblks >= JRNL_WMGR_PAGE_SIZE * JRNL_SBLK_SIZE)
+ {
+ res = write_flush();
+ assert(res == RHM_IORES_SUCCESS);
+
+ if (_page_cb_arr[_pg_index]._state == AIO_PENDING && !done)
+ {
+ res = RHM_IORES_AIO_WAIT;
+ dtok->set_wstate(data_tok::ENQ_PART);
+ done = true;
+ }
+
+ if (_pg_cntr >= (JRNL_FILE_SIZE / JRNL_WMGR_PAGE_SIZE))
+ {
+ iores rfres = rotate_file();
+ if (rfres != RHM_IORES_SUCCESS)
+ res = rfres;
+ if (!done)
+ {
+ if (rfres == RHM_IORES_SUCCESS)
+ cont = true;
+ else
+ {
+ // Set last data_tok in page only to state ENQ_PART
+ dtok->set_wstate(data_tok::ENQ_PART);
+ done = true;
+ }
+ }
+ }
+ }
+ }
+ if (dtok->wstate() >= data_tok::ENQ_SUBM)
+ _enq_busy = false;
+ return res;
+}
+
+const iores
+wmgr::dequeue(data_tok* dtok) throw (jexception)
+{
+ if (_enq_busy)
+ return RHM_IORES_BUSY;
+
+ iores res = pre_write_check(false, dtok);
+ if (res != RHM_IORES_SUCCESS)
+ return res;
+
+ u_int64_t rid = _wrfc.get_incr_rid();
+ //***
+ // NOTE: ASSUMPTION: sizeof(deq_hdr) <= JRNL_DBLK_SIZE
+ // This encoding is a simplification: it assumes deq_hdr (currently 20 bytes) fits inside
+ // one dblk. The dblk is a tunable parameter, but is unlikely to go lower than deq_hdr
+ // (currently dblk = 128 bytes). JRNL_DBLK_SIZE must be a power of 2.
+ // IF JRNL_DBLK_SIZE IS SET TO < 32 (i.e. 16 OR LESS) BYTES, THIS ENCODING WILL FAIL!
+ //***
+ deq_hdr dhdr(RHM_JDAT_DEQ_MAGIC, rid, dtok->rid(), RHM_JDAT_VERSION);
+ void* wptr = (void*)((char*)_page_ptr_arr[_pg_index] + _pg_offset_dblks * JRNL_DBLK_SIZE);
+ ::memcpy(wptr, &dhdr, sizeof(dhdr));
+#ifdef RHM_CLEAN
+ ::memset((char*)wptr + sizeof(dhdr), RHM_CLEAN_CHAR, JRNL_DBLK_SIZE - sizeof(dhdr));
+#endif
+#if !(defined RHM_WRONLY || defined RHM_RDONLY)
+ u_int16_t fid = _emap.get_remove_fid(dtok->rid());
+ _wrfc.decr_enqcnt(fid);
+#endif
+ _pg_offset_dblks++;
+ _cached_offset_dblks++;
+ // TODO: Incorrect - must set state to DEQ_CACHED; DEQ_SUBM is set when AIO returns.
+ dtok->set_wstate(data_tok::DEQ_SUBM);
+ _page_cb_arr[_pg_index]._pdtokl->push_back(dtok);
+ if (_wrfc.empty()) // Has the file_hdr been written?
+ write_fhdr(rid, _wrfc.index(), JRNL_SBLK_SIZE * JRNL_DBLK_SIZE);
+ if (_pg_offset_dblks >= JRNL_WMGR_PAGE_SIZE * JRNL_SBLK_SIZE)
+ res = flush();
+
+ return res;
+}
+
+const iores
+wmgr::flush()
+{
+ iores res = write_flush();
+ if (_pg_cntr >= (JRNL_FILE_SIZE / JRNL_WMGR_PAGE_SIZE))
+ {
+ iores rfres = rotate_file();
+ if (rfres != RHM_IORES_SUCCESS)
+ res = rfres;
+ }
+ return res;
+}
+
+const iores
+wmgr::write_flush()
+{
+ iores res = RHM_IORES_SUCCESS;
+ // Don't bother flushing an empty page or one that is still in state AIO_PENDING
+ if (_cached_offset_dblks)
+ {
+ if (_page_cb_arr[_pg_index]._state == AIO_PENDING)
+ res = RHM_IORES_AIO_WAIT;
+ else
+ {
+ if (_page_cb_arr[_pg_index]._state != IN_USE)
+ {
+ std::stringstream ss;
+ ss << "pg_index=" << _pg_index << " state=" << _page_cb_arr[_pg_index].state_str();
+ throw jexception(jerrno::JERR_WMGR_BADPGSTATE, ss.str(), "wmgr", "write_flush");
+ }
+
+ // Send current page using AIO
+
+ // In manual flushes, dblks may not coincide with sblks, add filler records ("RHMx")
+ // if necessary.
+ dblk_roundup();
+
+ size_t pg_offs = (_pg_offset_dblks - _cached_offset_dblks) * JRNL_DBLK_SIZE;
+ rhm_prep_pwrite(&_iocb_arr[_pg_index], _wrfc.fh(),
+ (char*)_page_ptr_arr[_pg_index] + pg_offs, _cached_offset_dblks * JRNL_DBLK_SIZE,
+ _wrfc.subm_offs());
+ iocb* this_iocb_ptr = &_iocb_arr[_pg_index];
+ page_cb* pcbp = (page_cb*)(this_iocb_ptr->data); // This page control block (pcb)
+ pcbp->_wdblks = _cached_offset_dblks;
+ pcbp->_wfh = _wrfc.file_handle();
+ if (::io_submit(_ioctx, 1, &this_iocb_ptr) < 0)
+ throw jexception(jerrno::JERR__AIO, "wmgr", "write_flush");
+ _wrfc.add_subm_cnt_dblks(_cached_offset_dblks);
+ _aio_evt_rem++;
+ _cached_offset_dblks = 0;
+
+ // Rotate cache page?
+ if (_pg_offset_dblks >= JRNL_WMGR_PAGE_SIZE * JRNL_SBLK_SIZE)
+ {
+ rotate_page(AIO_PENDING); // increments _pg_index, resets _pg_offset_dblks if req'd
+ if (_page_cb_arr[_pg_index]._state == UNUSED)
+ _page_cb_arr[_pg_index]._state = IN_USE;
+ }
+ }
+ }
+ get_events(UNUSED);
+ if (_page_cb_arr[_pg_index]._state == UNUSED)
+ _page_cb_arr[_pg_index]._state = IN_USE;
+ return res;
+}
+
+const iores
+wmgr::rotate_file()
+{
+ if (!_wrfc.rotate())
+ return RHM_IORES_FULL;
+ _pg_cntr = 0;
+ return RHM_IORES_SUCCESS;
+}
+
+const u_int32_t
+wmgr::get_events(page_state state) throw (jexception)
+{
+ int ret = 0;
+ if ((ret = ::io_getevents(_ioctx, 0, JRNL_RMGR_PAGES + JRNL_WMGR_PAGES, _ioevt_arr, NULL)) < 0)
+ {
+ if (ret == -EINTR) // No events
+ return 0;
+ std::stringstream ss;
+ ss << "io_getevents() failed: " << strerror(-ret) << " (" << ret << ")";
+ throw jexception(jerrno::JERR__AIO, ss.str(), "wmgr", "get_events");
+ }
+
+ u_int32_t tot_data_toks = 0;
+ for (int i=0; i<ret; i++) // Index of returned AIOs
+ {
+ if (_aio_evt_rem == 0)
+ {
+ std::stringstream ss;
+ ss << "_aio_evt_rem; evt " << (i + 1) << " of " << ret;
+ throw jexception(jerrno::JERR__UNDERFLOW, ss.str(), "wmgr", "get_events");
+ }
+ _aio_evt_rem--;
+ iocb* iocbp = _ioevt_arr[i].obj; // This I/O control block (iocb)
+ page_cb* pcbp = (page_cb*)(iocbp->data); // This page control block (pcb)
+ long aioret = (long)_ioevt_arr[i].res;
+ if (aioret < 0)
+ {
+ std::stringstream ss;
+ ss << "AIO write operation failed: " << strerror(-aioret) << " (" << aioret << ")";
+ ss << " [pg=" << pcbp->_index << " size=" << iocbp->u.c.nbytes;
+ ss << " offset=" << iocbp->u.c.offset << " fh=" << iocbp->aio_fildes << "]";
+ throw jexception(jerrno::JERR__AIO, ss.str(), "wmgr", "get_events");
+ }
+ if (pcbp) // File header writes have no pcb
+ {
+ u_int32_t s = pcbp->_pdtokl->size();
+ for (u_int32_t k=0; k<s; k++)
+ {
+ data_tok* dtp = pcbp->_pdtokl->at(k);
+ switch (dtp->wstate())
+ {
+ case data_tok::ENQ_SUBM:
+ assert(dtp->wstate() == data_tok::ENQ_SUBM);
+ dtp->set_wstate(data_tok::ENQ);
+ break;
+ case data_tok::DEQ_SUBM:
+ assert(dtp->wstate() == data_tok::DEQ_SUBM);
+ dtp->set_wstate(data_tok::DEQ);
+ break;
+ default:
+ std::stringstream ss;
+ ss << "dtok_state=" << dtp->wstate_str();
+ throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str(), "wmgr",
+ "get_events");
+ }
+ _dtokl->push_back(dtp);
+ }
+ tot_data_toks += s;
+
+
+ // Increment the completed write offset
+ // NOTE: We cannot use _wrfc here, as it may have rotated since submitting count.
+ // Use stored pointer to nlfh in the pcb instead.
+ pcbp->_wfh->add_wr_cmpl_cnt_dblks(pcbp->_wdblks);
+
+ // Clean up this pcb's data_tok list
+ pcbp->_pdtokl->clear();
+ pcbp->_state = state;
+ }
+ else
+ _wrfc.add_cmpl_cnt_dblks(JRNL_SBLK_SIZE);
+ }
+
+ // Perform AIO return callback
+ if (_cb && tot_data_toks)
+ (_cb)(tot_data_toks);
+
+ return tot_data_toks;
+}
+
+void
+wmgr::initialize() throw (jexception)
+{
+ pmgr::initialize();
+ if (::posix_memalign(&_fhdr_buff, _sblksize, _sblksize))
+ {
+ std::stringstream ss;
+ ss << "posix_memalign(): blksize=" << _sblksize << " size=" << _sblksize;
+ ss << " errno=" << errno;
+ throw jexception(jerrno::JERR__MALLOC, ss.str(), "wmgr", "initialize");
+ }
+ _page_cb_arr[0]._state = IN_USE;
+ _ddtokl.clear();
+}
+
+const iores
+wmgr::pre_write_check(bool enqueue, data_tok* dtok) throw (jexception)
+{
+ // Check status of current file
+ if (!_wrfc.is_reset())
+ {
+ if (!_wrfc.reset())
+ return RHM_IORES_FULL;
+ }
+
+ // Check status of current page
+ if (_page_cb_arr[_pg_index]._state != IN_USE)
+ {
+ if (_page_cb_arr[_pg_index]._state == UNUSED)
+ _page_cb_arr[_pg_index]._state = IN_USE;
+ else if (_page_cb_arr[_pg_index]._state == AIO_PENDING)
+ return RHM_IORES_AIO_WAIT;
+ else
+ {
+ std::stringstream ss;
+ ss << "op=" << (enqueue ? "enqueue" : "dequeue") << " index=" << _pg_index;
+ ss << " state=" << _page_cb_arr[_pg_index].state_str();
+ throw jexception(jerrno::JERR_WMGR_BADPGSTATE, ss.str(), "wmgr", "pre_write_check");
+ }
+ }
+
+ // Check state of data_tok
+ bool res = enqueue ? dtok->is_writable() : dtok->is_dequeueable();
+ if (!res)
+ {
+ std::stringstream ss;
+ ss << "op=" << (enqueue ? "enqueue" : "dequeue") << " dtok_id=" << dtok->id();
+ ss << " dtok_state=" << dtok->wstate_str();
+ throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str(), "wmgr", "pre_write_check");
+ }
+
+ return RHM_IORES_SUCCESS;
+}
+
+void
+wmgr::dblk_roundup()
+{
+ const u_int32_t xmagic = RHM_JDAT_EMPTY_MAGIC;
+ u_int32_t wdblks = jrec::size_blks(_cached_offset_dblks, JRNL_SBLK_SIZE) * JRNL_SBLK_SIZE;
+ while (_cached_offset_dblks < wdblks)
+ {
+ void* wptr = (void*)((char*)_page_ptr_arr[_pg_index] + _pg_offset_dblks * JRNL_DBLK_SIZE);
+ ::memcpy(wptr, (void*)&xmagic, 4);
+#ifdef RHM_CLEAN
+ ::memset((char*)wptr + 4, RHM_CLEAN_CHAR, JRNL_DBLK_SIZE - 4);
+#endif
+ _pg_offset_dblks++;
+ _cached_offset_dblks++;
+ }
+}
+
+void
+wmgr::write_fhdr(u_int64_t rid, u_int32_t fid, size_t fro) throw (jexception)
+{
+ file_hdr fhdr(RHM_JDAT_FILE_MAGIC, rid, fid, fro, true, RHM_JDAT_VERSION);
+ ::memcpy(_fhdr_buff, &fhdr, sizeof(fhdr));
+#ifdef RHM_CLEAN
+ ::memset((char*)_fhdr_buff + sizeof(fhdr), RHM_CLEAN_CHAR, _sblksize - sizeof(fhdr));
+#endif
+ iocb* iocbp = &_fhdr_iocb;
+ ::io_prep_pwrite(iocbp, _wrfc.fh(), _fhdr_buff, _sblksize, 0);
+ if (::io_submit(_ioctx, 1, &iocbp) < 0)
+ throw jexception(jerrno::JERR__AIO, "wmgr", "write_fhdr");
+ _aio_evt_rem++;
+ _wrfc.add_subm_cnt_dblks(JRNL_SBLK_SIZE);
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/wmgr.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/wmgr.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/wmgr.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,122 @@
+/**
+* \file wmgr.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::wmgr (read manager). See
+* class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_wmgr_hpp
+#define rhm_journal_wmgr_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class wmgr;
+}
+}
+
+#include <jrnl/pmgr.hpp>
+#include <jrnl/wrfc.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \brief Class for managing a write page cache of arbitrary size and number of pages.
+ *
+ * The write page cache works on the principle of caching the write data within a page until
+ * that page is either full or flushed; this initiates a sinlge AIO write operation to store
+ * the data on disk.
+ *
+ * The maximum disk troughput is acheived by keeping the write operations of uniform size.
+ * Waiting for a page cache to fill achieves this; and in high data volume/throughput situations
+ * achieves the optimal disk throughput. Calling flush() forces a write of the current page cache
+ * no matter how full it is, and disrupts the uniformity of the write operations. This should
+ * normally only be done if throughput drops and there is a danger of a page of unwritten data
+ * waiting around for excessive time.
+ *
+ * The usual tradeoff between data storage latency and thoughput performance applies.
+ */
+ class wmgr : public pmgr
+ {
+ private:
+ wrfc& _wrfc; ///< Ref to write rotating file controller
+ u_int32_t _max_dtokpp; ///< Max data writes per page
+ u_int32_t _max_io_wait_us; ///< Max wait in microseconds till submit
+ void* _fhdr_buff; ///< Buffer for file header writes
+ iocb _fhdr_iocb; ///< IO control block for file header writes
+ u_int32_t _cached_offset_dblks; ///< Amount of unwritten data in page (dblocks)
+ std::deque<data_tok*> _ddtokl; ///< Deferred dequeue data_tok list
+ // TODO: Convert _enq_busy into a proper threadsafe lock
+ bool _enq_busy; ///< Flag true if enqueue is in progress
+
+ public:
+ wmgr(enq_map& emap, wrfc& wrfc);
+ wmgr(enq_map& emap, wrfc& wrfc, std::deque<data_tok*>* const dtokl,
+ const u_int32_t max_dtokpp, const u_int32_t max_iowait_us) throw (jexception);
+ ~wmgr();
+
+ void initialize(std::deque<data_tok*>* const dtokl, aio_cb wr_cb,
+ const u_int32_t max_dtokpp, const u_int32_t max_iowait_us) throw (jexception);
+ const iores enqueue(const void* const mbuf, const size_t mlen, data_tok* dtok)
+ throw (jexception);
+ const iores dequeue(data_tok* dtok) throw (jexception);
+ const iores flush();
+ const u_int32_t get_events(page_state state) throw (jexception);
+
+ private:
+ void initialize() throw (jexception);
+ const iores pre_write_check(bool enqueue, data_tok* dtok) throw (jexception);
+ const iores write_flush();
+ const iores rotate_file();
+ void dblk_roundup();
+ void write_fhdr(u_int64_t rid, u_int32_t fid, size_t fro) throw (jexception);
+
+ // Special version of libaio's io_prep_pwrite() which preserves the value of the data
+ // pointer. This allows iocbs to be initialized with a pointer that can be re-used. Note
+ // that C++ does not support type long long, this has been replaced with int64_t.
+ static inline void rhm_prep_pwrite(struct iocb *iocb, int fd, void *buf,
+ size_t count, int64_t offset)
+ {
+ ::memset((void*)((char*)iocb + sizeof(void*)), 0, sizeof(*iocb) - sizeof(void*));
+ iocb->aio_fildes = fd;
+ iocb->aio_lio_opcode = IO_CMD_PWRITE;
+ iocb->aio_reqprio = 0;
+ iocb->u.c.buf = buf;
+ iocb->u.c.nbytes = count;
+ iocb->u.c.offset = offset;
+ }
+ };
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_wmgr_hpp
Copied: store/trunk/cpp/lib/jrnl/wrfc.cpp (from rev 894, store/trunk/cpp/jrnl/jrnl/wrfc.cpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/wrfc.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/wrfc.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,75 @@
+/**
+* \file wrfc.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::rrfc (rotating
+* file controller). See comments in file rrfc.hpp for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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/wrfc.hpp>
+#include <jrnl/jerrno.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+wrfc::wrfc():
+ rrfc(),
+#ifdef DRHM_TESTVALS
+ // TODO: Find method of specifying 64-bit literals under gcc with -pedantic option
+ _rid(u_int64_t(0xffeeddcc) << 32), // For testing high rids
+#else
+ _rid(0),
+#endif
+ _reset_ok(false)
+{}
+
+wrfc::~wrfc() {}
+
+bool
+wrfc::rotate() throw (jexception)
+{
+ if (!_nfiles)
+ throw jexception(jerrno::JERR__NINIT, "wrfc", "rotate");
+ _fh_index++;
+ if (_fh_index == _nfiles)
+ _fh_index = 0;
+ _curr_fh = _fh_arr[_fh_index];
+ return reset(); //Checks if file is still in use (ie not fully dequeued yet)
+}
+
+const bool
+wrfc::reset()
+{
+ _reset_ok = _curr_fh->reset(); // returns false if full (ie file still contains enqueued recs)
+ return _reset_ok;
+}
+
+} // namespace journal
+} // namespace rhm
Copied: store/trunk/cpp/lib/jrnl/wrfc.hpp (from rev 894, store/trunk/cpp/jrnl/jrnl/wrfc.hpp)
===================================================================
--- store/trunk/cpp/lib/jrnl/wrfc.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/wrfc.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,102 @@
+/**
+* \file wrfc.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::wrfc (write rotating
+* file controller). See class documentation for details.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 rhm_journal_rfc_hpp
+#define rhm_journal_rfc_hpp
+
+namespace rhm
+{
+namespace journal
+{
+class wrfc;
+}
+}
+
+#include <jrnl/rrfc.hpp>
+
+namespace rhm
+{
+namespace journal
+{
+
+ /**
+ * \class wrfc
+ * \brief Class to handle manangement of a journal rotating file handle.
+ */
+ class wrfc : public rrfc
+ {
+ private:
+ u_int64_t _rid; ///< Master counter for record ID (rid)
+ bool _reset_ok; ///< Flag set when reset succeeds
+
+ public:
+ wrfc();
+ ~wrfc();
+
+ /**
+ * \brief Rotate active file handle to next file in rotating file group.
+ * \exception jerrno::JERR__NINIT if called before calling initialize().
+ */
+ bool rotate() throw (jexception);
+
+ inline const u_int64_t rid() const { return _rid; }
+ inline const u_int64_t get_incr_rid() { return _rid++; }
+ const bool reset();
+ inline const bool is_reset() const { return _reset_ok; }
+
+ // Convenience access methods to current file handle
+
+ inline const int fh() const { return _curr_fh->wr_fh(); }
+
+ inline const u_int32_t subm_cnt_dblks() const { return _curr_fh->wr_subm_cnt_dblks(); }
+ inline const size_t subm_offs() const { return _curr_fh->wr_subm_offs(); }
+ inline const u_int32_t incr_subm_cnt_dblks() throw (jexception)
+ { return _curr_fh->incr_wr_subm_cnt_dblks(); }
+ inline const u_int32_t add_subm_cnt_dblks(u_int32_t a) throw (jexception)
+ { return _curr_fh->add_wr_subm_cnt_dblks(a); }
+
+ inline const u_int32_t cmpl_cnt_dblks() const { return _curr_fh->wr_cmpl_cnt_dblks(); }
+ inline const size_t cmpl_offs() const { return _curr_fh->wr_cmpl_offs(); }
+ inline const u_int32_t incr_cmpl_cnt_dblks() throw (jexception)
+ { return _curr_fh->incr_wr_cmpl_cnt_dblks(); }
+ inline const u_int32_t add_cmpl_cnt_dblks(u_int32_t a) throw (jexception)
+ { return _curr_fh->add_wr_cmpl_cnt_dblks(a); }
+
+ inline const u_int32_t remaining_dblks() const throw (jexception)
+ { return _curr_fh->wr_remaining_dblks(); }
+ inline const bool is_compl() const throw (jexception) { return _curr_fh->is_wr_compl(); };
+ }; // class wrfc
+
+} // namespace journal
+} // namespace rhm
+
+#endif // ifndef rhm_journal_rfc_hpp
Modified: store/trunk/cpp/tests/Makefile.am
===================================================================
--- store/trunk/cpp/tests/Makefile.am 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/tests/Makefile.am 2007-08-30 13:40:45 UTC (rev 898)
@@ -8,10 +8,12 @@
EXTRA_DIST = persistence.py
+SUBDIRS = jrnl
+
unit_tests = \
OrderingTest \
SimpleTest \
- TwoPhaseCommitTest \
+ TwoPhaseCommitTest \
TransactionalTest
TESTS = \
Added: store/trunk/cpp/tests/jrnl/JournalTest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalTest.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,58 @@
+/**
+* \file JournalTest.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 "../test_plugin.h"
+#include "msg_producer.hpp"
+#include "msg_consumer.hpp"
+#include "jtest.hpp"
+
+#define JTEST_CSV_FILE "/home/kpvdr/store/cpp/tests/jrnl/rwtests.csv"
+
+class JournalTest : public CppUnit::TestCase
+{
+ CPPUNIT_TEST_SUITE(JournalTest);
+ CPPUNIT_TEST(SingleMsgReadWrite);
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ void SingleMsgReadWrite()
+ {
+ jtest t(1);
+ t.initialize(JTEST_CSV_FILE);
+ t.run();
+ t.report();
+ t.finalize();
+ }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(JournalTest);
Added: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am (rev 0)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,27 @@
+abs_builddir=@abs_builddir@
+
+AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) -pthread
+
+INCLUDES=-I../../lib
+
+EXTRA_DIST = ftest.py rwtests.csv
+
+TESTS = run-journal-tests
+
+check_LTLIBRARIES = \
+ JournalTest.la \
+ libdlclose_noop.la
+
+JournalTest_la_SOURCES = \
+ JournalTest.cpp \
+ jtest.cpp \
+ msg_producer.cpp \
+ msg_consumer.cpp \
+ jtest.hpp \
+ msg_producer.hpp \
+ msg_consumer.hpp
+JournalTest_la_LDFLAGS = -lpthread -module -rpath $(abs_builddir)
+JournalTest_la_LIBADD = ../../lib/libbdbstore.la $(CPPUNIT_LIBS)
+
+libdlclose_noop_la_SOURCES = ../dlclose_noop.c
+libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir)
Copied: store/trunk/cpp/tests/jrnl/Makefile.rtest (from rev 894, store/trunk/cpp/jrnl/Makefile)
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.rtest (rev 0)
+++ store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,179 @@
+# RHM_DEFINES
+# The following defines are usable during the build of rhmj:
+# RHM_CLEAN: Writes 0x00 to all unused disk space bytes. This makes debugging easier,
+# but the memcpy required incurs a performance penalty. Do not use for
+# production or performance checks.
+# RHM_TESTVALS: Uses special values (e.g. RIDs starting at 0xffeeddcc00000000 rather than 0)
+# for testing purposes, or to expose special test conditions.
+# RHM_JOWRITE: Defeats the relocation of previous journal files into a subdir, makes
+# the execution quicker provided the files are of the same size as previous
+# run. If the files are not present, they will be created.
+# RHM_WRONLY: Defeats the test which check that a journal file has been read before it
+# overwritten. NOTE: ONLY USE FOR PERFORMANCE TESTS!
+# RHM_RDONLY: Defeats the test which check that a journal file has been written before it
+# read. Use together with RHM_JOWRITE if test reads from previously written
+# journal. Ensure journal contains valid entries in all files. NOTE: ONLY USE
+# FOR PERFORMANCE TESTS!
+# Prefix each define with -D. (eg RHM_DEFINES = -DRHM_JOWRITE -DRHM_WRONLY)
+#RHM_DEFINES = -DRHM_WRONLY
+#RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY
+#RHM_DEFINES = -DRHM_CLEAN -DRHM_WRONLY
+#RHM_DEFINES = -DRHM_CLEAN
+RHM_DEFINES = -DRHM_TESTVALS
+
+RHM_JRNL_SRC_DIR = jrnl
+RHM_MGMT_SRC_DIR = mgmt
+RHM_TEST_SRC_DIR = test
+RHM_DOC_DIR = docs
+RHM_JOURNAL_DIR = jdata
+RHM_TESTRES_DIR = ${RHM_TEST_SRC_DIR}/res
+RHM_TESTREF_DIR = ${RHM_TEST_SRC_DIR}/ref
+RHM_TESTREF_TAR = ${RHM_TEST_SRC_DIR}/ref.tar.gz
+
+CXXINCLUDES = \
+ -I.
+
+JRNL_OBJFILES = \
+ $(RHM_JRNL_SRC_DIR)/jexception.o \
+ $(RHM_JRNL_SRC_DIR)/jerrno.o \
+ $(RHM_JRNL_SRC_DIR)/jinf.o \
+ $(RHM_JRNL_SRC_DIR)/enq_map.o \
+ $(RHM_JRNL_SRC_DIR)/jdir.o \
+ $(RHM_JRNL_SRC_DIR)/data_tok.o \
+ $(RHM_JRNL_SRC_DIR)/file_hdr.o \
+ $(RHM_JRNL_SRC_DIR)/jrec.o \
+ $(RHM_JRNL_SRC_DIR)/data_rec.o \
+ $(RHM_JRNL_SRC_DIR)/nlfh.o \
+ $(RHM_JRNL_SRC_DIR)/lfh.o \
+ $(RHM_JRNL_SRC_DIR)/rrfc.o \
+ $(RHM_JRNL_SRC_DIR)/wrfc.o \
+ $(RHM_JRNL_SRC_DIR)/pmgr.o \
+ $(RHM_JRNL_SRC_DIR)/rmgr.o \
+ $(RHM_JRNL_SRC_DIR)/wmgr.o \
+ $(RHM_JRNL_SRC_DIR)/jcntl.o \
+
+JTEST_OBJ_FILES = \
+ $(RHM_TEST_SRC_DIR)/jtest.o \
+ $(RHM_TEST_SRC_DIR)/msg_producer.o \
+ $(RHM_TEST_SRC_DIR)/msg_consumer.o \
+
+JTEST_FILES = \
+ $(RHM_TEST_SRC_DIR)/jtest \
+
+CC = g++
+CXX = g++
+CXXDEBUGFLAGS = -g -O0
+#CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -pedantic -O3 -pthread $(CXXINCLUDES)
+CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -pedantic -ggdb -O0 -pthread $(CXXINCLUDES)
+LDFLAGS = -lpthread -laio -lrt
+LDLIBS =
+
+RM = rm -f
+RMDIRS = rm -rf
+
+# These targets are not actual files, only conventient names
+.PHONY: default clean all help clean-all clean-jtest jmgmt clean-jmgmt jrnl clean-jrnl docs clean-docs test
+
+# Default build operation
+default: jtest
+
+# Default clean operation
+clean: clean-jtest clean-jmgmt clean-jrnl clean-core-files
+
+all: jrnl jmgmt jtest aiotest docs test
+
+clean-all: clean-jtest clean-jmgmt clean-jrnl clean-docs clean-jdata clean-core-files
+
+# Print make options
+help:
+ @echo "The following make options are available: (* is default)"
+ @echo " Make operations: "
+ @echo " all: Make everything"
+ @echo " help: This message"
+ @echo " *jtest: Make the journal test suite"
+ @echo " jrtest: Make the journal test suite for read tests"
+ @echo " jwtest: Make the journal test suite for write tests"
+ @echo " jmgmt: Make the jouranl management utils"
+ @echo " jrnl: Build the journal library"
+ @echo " docs: Make the doxygen docs"
+ @echo " test: Run regression test suite"
+ @echo " Clean operations: "
+ @echo " clean: Clean most things (not docs or journal data)"
+ @echo " clean-all: Blow it *all* away!"
+ @echo " clean-jtest: Clean journal tests and test support files"
+ @echo " clean-jmgmt: Clean management utils"
+ @echo " clean-jrnl: Clean journal object files"
+ @echo " clean-docs: Blow the docs dir away"
+ @echo " clean-jdata: Clear all jouranl data files"
+
+# Run regression test script
+test: jtest #ref
+ @./rtest
+
+ref: $(RHM_TESTREF_DIR)
+
+$(RHM_TESTREF_DIR): $(RHM_TESTREF_TAR)
+ @tar -C $(RHM_TEST_SRC_DIR) -xzf $(RHM_TESTREF_TAR)
+
+# Build all journal and test object files, produces jtest executable
+jtest: $(JTEST_FILES)
+
+jrtest: RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY -DRHM_TESTVALS
+jrtest: $(JTEST_FILES)
+
+jwtest: RHM_DEFINES = -DRHM_CLEAN -DRHM_WRONLY -DRHM_TESTVALS
+jwtest: $(JTEST_FILES)
+
+jrwtest: RHM_DEFINES = -DRHM_CLEAN -DRHM_TESTVALS
+jrwtest: $(JTEST_FILES)
+
+$(JTEST_FILES): $(JRNL_OBJFILES) $(JTEST_OBJ_FILES)
+
+# Clean all journal test executables and build artifacts
+clean-jtest:
+ @-$(RM) $(RHM_TEST_SRC_DIR)/*~
+ @-$(RM) $(JTEST_OBJ_FILES)
+ @-$(RM) $(JTEST_FILES)
+ @-$(RMDIRS) $(RHM_TESTRES_DIR)
+# @-$(RMDIRS) $(RHM_TESTREF_DIR)
+
+# Build management utilities
+jmgmt: $(MGMT_FILES)
+
+$(MGMT_FILES): $(JRNL_OBJFILES) $(MGMT_OBJ_FILES)
+
+# Clean up all management utility build and edit artifacts
+clean-jmgmt:
+ @-$(RM) $(RHM_MGMT_SRC_DIR)/*~
+ @-$(RM) $(MGMT_OBJ_FILES)
+ @-$(RM) $(MGMT_FILES)
+
+# Builds just the journal object files. No executable is produced
+jrnl: $(JRNL_OBJFILES)
+
+# Clean up all journal build and edit artifacts
+clean-jrnl:
+ @-$(RM) $(RHM_JRNL_SRC_DIR)/*~
+ @-$(RM) $(JRNL_OBJFILES)
+
+# Build all Doxygen docs, produce a pdf and ps file from the latex output
+docs:
+ @mkdir -p $(RHM_DOC_DIR)
+ @doxygen test_tmpl.dox
+ @make -C $(RHM_DOC_DIR)/latex
+ @cd $(RHM_DOC_DIR)/latex; dvipdf refman.dvi refman.pdf
+ @cd $(RHM_DOC_DIR)/latex; dvips refman.dvi -o refman.ps
+
+# Clean up all Doxygen docs located in $(RHM_DOC_DIR)
+clean-docs:
+ @-$(RMDIRS) $(RHM_DOC_DIR)
+
+# Clean up journal artifacts located in $(RHM_JOURNAL_DIR)
+clean-jdata:
+ @-$(RMDIRS) $(RHM_JOURNAL_DIR)
+ @-$(RMDIRS) $(RHM_RTEST_DIR)
+
+# Find and remove any core files lying around
+clean-core-files:
+ @-$(RM) core*
+ @-$(RM) vgcore*
Copied: store/trunk/cpp/tests/jrnl/chk_jdata (from rev 891, store/trunk/cpp/jrnl/test/chk_jdata)
===================================================================
--- store/trunk/cpp/tests/jrnl/chk_jdata (rev 0)
+++ store/trunk/cpp/tests/jrnl/chk_jdata 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+JRNL_BLK_SIZE=512 # Block size in bytes
+JRNL_PAGE_SIZE=256 # Journal page size in blocks
+JRNL_FILE_SIZE=12 # Journal file size in pages
+let END_OFFSET=${JRNL_BLK_SIZE}*${JRNL_PAGE_SIZE}*${JRNL_FILE_SIZE}
+for f in jdata/test.*; do
+ echo $f
+ hexdump -C -n 1024 $f
+ hexdump -C -s ${END_OFFSET} $f
+ echo "============"
+done
Copied: store/trunk/cpp/tests/jrnl/cp_rtest_jrnl (from rev 891, store/trunk/cpp/jrnl/test/cp_rtest_jrnl)
===================================================================
--- store/trunk/cpp/tests/jrnl/cp_rtest_jrnl (rev 0)
+++ store/trunk/cpp/tests/jrnl/cp_rtest_jrnl 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,39 @@
+#!/bin/bash
+JDATA_DIR=jdata
+TAR_DIR=test/rd_test_jrnls
+
+function get_filename
+{
+ local prefix=$1
+ local file_num=$2
+ local suffix=$3
+
+ if (( file_num < 10 )); then
+ local num="000${file_num}"
+ elif (( file_num < 100 )); then
+ local num="00${file_num}"
+ elif (( file_num < 1000 )); then
+ local num="0${file_num}"
+ else
+ local num="${file_num}"
+ fi
+ FILENAME=${prefix}${num}${suffix}
+ return 0
+}
+
+if (( $# != 1 )); then
+ echo "Incorrect args, expected 1 arg (usage: \"prep <testnum>\")"
+ exit
+fi
+
+get_filename "t" $1 ".tar.gz"
+if [[ -d ${JDATA_DIR} ]]; then
+ rm -rf ${JDATA_DIR}/*
+else
+ mkdir -p ${JDATA_DIR}
+fi
+if [[ -f "${TAR_DIR}/${FILENAME}" ]]; then
+ tar -C ${JDATA_DIR} -xzf "${TAR_DIR}/${FILENAME}"
+else
+ echo "Error: file \"${TAR_DIR}/${FILENAME}\" not found."
+fi
Copied: store/trunk/cpp/tests/jrnl/ftest.py (from rev 891, store/trunk/cpp/jrnl/test/ftest.py)
===================================================================
--- store/trunk/cpp/tests/jrnl/ftest.py (rev 0)
+++ store/trunk/cpp/tests/jrnl/ftest.py 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,428 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2007 Red Hat Inc.
+#
+# This file is part of Red Hat Messaging.
+#
+# Red Hat Messaging 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.
+
+import sys
+from struct import unpack, calcsize
+from time import gmtime, strftime
+
+dblk_size = 128
+sblk_size = 4 * dblk_size
+file_size = (3072 + 1) * sblk_size
+num_files = 8
+
+def load(f, klass):
+ args = load_args(f, klass)
+ subclass = klass.descriminate(args)
+ result = subclass(*args)
+ if subclass != klass:
+ result.init(f, *load_args(f, subclass))
+ result.skip(f)
+ return result;
+
+def load_args(f, klass):
+ size = calcsize(klass.format)
+ foffs = f.tell(),
+ bin = f.read(size)
+ if len(bin) != size:
+ raise Exception("end of file")
+ return foffs + unpack(klass.format, bin)
+
+def size_blks(size, blk_size):
+ return (size + blk_size - 1)/blk_size
+
+def rem_in_blk(f, blk_size):
+ foffs = f.tell()
+ return (size_blks(f.tell(), blk_size) * blk_size) - foffs;
+
+def compl(n):
+ return ~n & 0xffffffff
+
+def file_full(f):
+ return f.tell() >= file_size
+
+
+class Sizeable:
+
+ def size(self):
+ classes = [self.__class__]
+
+ size = 0
+ while classes:
+ cls = classes.pop()
+ if hasattr(cls, "format"):
+ size += calcsize(cls.format)
+ classes.extend(cls.__bases__)
+
+ return size
+
+class Hdr(Sizeable):
+
+ format = '=4sBBHQ'
+
+ @staticmethod
+ def descriminate(args):
+ return CLASSES.get(args[1][-1], Hdr)
+
+ def __init__(self, foffs, magic, ver, end, flags, rid):
+ self.foffs = foffs
+ self.magic = magic
+ self.ver = ver
+ self.end = end
+ self.flags = flags
+ self.rid = rid
+ if self.magic[-1] not in ['0x00', 'd', 'e', 'f', 'x']:
+ error = 3;
+
+ def __str__(self):
+ if self.empty():
+ return '0x%08x: <empty>' % (self.foffs)
+ if self.magic[-1] == 'x':
+ return '0x%08x: \"%s\"' % (self.foffs, self.magic)
+ if self.magic[-1] in ['d', 'e', 'f', 'x']:
+ return '0x%08x: \"%s\" v=%d e=%d f=0x%04x rid=%d' % (self.foffs, self.magic, self.ver, self.end, self.flags, self.rid)
+ return '0x%08x: <error, unknown magic \"%s\" (possible overwrite boundary?)>' % (self.foffs, self.magic)
+
+ def empty(self):
+ return self.magic == '\x00'*4
+
+ def skip(self, f):
+ f.read(rem_in_blk(f, dblk_size))
+
+ def check(self):
+ if self.empty() or self.magic[-1] not in ['d', 'e', 'f', 'x']:
+ return True
+ return False
+
+
+
+class FileHdr(Hdr):
+
+ format = '=I4x3Q'
+
+ def init(self, f, foffs, fid, fro, time_sec, time_ns):
+ self.fid = fid
+ self.fro = fro
+ self.time_sec = time_sec
+ self.time_ns = time_ns
+
+ def __str__(self):
+ return '%s fid=%d fro=0x%08x t=%s' % (Hdr.__str__(self), self.fid, self.fro, self.timestamp_str())
+
+ def skip(self, f):
+ f.read(rem_in_blk(f, sblk_size))
+
+ def timestamp(self):
+ return (self.time_sec, self.time_ns)
+
+ def timestamp_str(self):
+ ts = gmtime(self.time_sec)
+ fstr = '%%a %%b %%d %%H:%%M:%%S.%d %%Y' % (self.time_ns)
+ return strftime(fstr, ts)
+
+
+class DeqHdr(Hdr):
+
+ format = '=Q'
+
+ def init(self, f, foffs, deq_rid):
+ self.deq_rid = deq_rid
+
+ def __str__(self):
+ return '%s d=%d' % (Hdr.__str__(self), self.deq_rid)
+
+
+class EnqTail(Sizeable):
+
+ format = '=IQ'
+
+ def __init__(self, foffs, magic_inv, rid):
+ self.foffs = foffs
+ self.magic_inv = magic_inv
+ self.rid = rid
+
+ def __str__(self):
+ return '0x%04x rid=%d' % (self.magic_inv, self.rid)
+
+ def skip(self, f):
+ f.read(rem_in_blk(f, dblk_size))
+
+
+class EnqRec(Hdr):
+
+ format = '=Q'
+
+ def init(self, f, foffs, dsize):
+ self.dsize = dsize
+ self.data = None
+ self.enq_tail = None
+ self.data_complete = False
+ self.tail_complete = False
+ self.tail_bin = None
+ self.tail_offs = 0
+ self.load(f)
+
+ def load(self, f):
+ if not self.data_complete:
+ self.load_data(f)
+ if self.data_complete and not self.tail_complete:
+ self.load_tail(f)
+ return self.complete()
+
+ def load_data(self, f):
+ if self.data == None:
+ loaded = 0
+ else:
+ loaded = len(self.data)
+ foverflow = f.tell() + self.dsize - loaded > file_size
+ if foverflow:
+ rsize = file_size - f.tell()
+ else:
+ rsize = self.dsize - loaded
+ bin = f.read(rsize)
+ if self.data == None:
+ self.data = unpack('%ds' % (rsize), bin)[0]
+ else:
+ self.data = self.data + unpack('%ds' % (rsize), bin)[0]
+ self.data_complete = not foverflow
+ return self.data_complete
+
+ def load_tail(self, f):
+ if self.tail_bin == None:
+ self.tail_offs = f.tell()
+ self.tail_bin = f.read(calcsize(EnqTail.format))
+ if len(self.tail_bin) != calcsize(EnqTail.format):
+ return
+ else:
+ self.tail_bin += f.read(calcsize(EnqTail.format) - len(self.tail_bin))
+ self.enq_tail = EnqTail(self.tail_offs, *unpack(EnqTail.format, self.tail_bin))
+ magic_int = 0
+ inv_magic_int_1 = 0
+ for i in range(0,4):
+ magic_int = (magic_int << 8) + ord(self.magic[3-i]) # Little endian only
+ if self.enq_tail.magic_inv != compl(magic_int) or self.enq_tail.rid != self.rid:
+ print " > %s" % self
+ raise Exception('Invalid enqueue record tail (magic=0x%08x; rid=%d) at 0x%08x' % (self.enq_tail.magic_inv, self.enq_tail.rid, self.enq_tail.foffs))
+ self.enq_tail.skip(f)
+ self.tail_complete = True
+
+ def complete(self):
+ return self.data_complete and self.tail_complete
+
+ def __str__(self):
+ if len(self.data) > 50:
+ dstr = self.data[:20] + ' ... ' + self.data[-20:]
+ else:
+ dstr = self.data
+ if self.enq_tail == None:
+ return '%s s=%d data=\"%s\" [no tail]' % (Hdr.__str__(self), self.dsize, dstr)
+ return '%s s=%d data=\"%s\" %s' % (Hdr.__str__(self), self.dsize, dstr, self.enq_tail)
+
+
+class Main:
+
+ def __init__(self, tfile, tnum):
+ tparams = self.get_test(tfile, tnum)
+ if tparams == None:
+ raise Exception('Test %d not found in file %s' % (tnum, tfile))
+ self.num_msgs = tparams['num_msgs']
+ if tparams['min_size'] == tparams['max_size']:
+ self.msg_len = tparams['max_size']
+ else:
+ self.msg_len = 0
+ self.auto_deq = tparams['auto_deq']
+ self.file_start = 0
+ self.file_num = 0
+ self.fro = 0x200
+ self.enqueued = {}
+ self.msg_cnt = 0
+ self.fhdr = None
+ self.f = None
+ self.first_rec = False
+ self.last_file = False
+ self.last_rid = -1
+
+
+ def run(self):
+ for msg_num in range(self.num_msgs):
+ start_info = self.analyze_files()
+ stop = self.advance_file(*start_info)
+ while not stop:
+ warn = ''
+ if file_full(self.f):
+ stop = self.advance_file()
+ if stop:
+ break
+ hdr = load(self.f, Hdr)
+ if hdr.empty():
+ stop = True;
+ break
+ if hdr.check():
+ stop = True;
+ if self.first_rec:
+ if self.fhdr.fro != hdr.foffs:
+ raise Exception('File header first record offset mismatch: fro=0x%08x; rec_offs=0x%08x' % (self.fhdr.fro, hdr.foffs))
+ else:
+ print ' * fro ok: 0x%08x' % self.fhdr.fro
+ self.first_rec = False
+ if isinstance(hdr, EnqRec):
+ while not hdr.complete():
+ stop = self.advance_file()
+ if stop:
+ break
+ hdr.load(self.f)
+ if self.msg_len > 0 and len(hdr.data) != self.msg_len:
+ raise Exception('Message length (%d) incorrect: expected %d' % (len(hdr.data), self.msg_len))
+ stop = not self.check_rid(hdr)
+ if stop:
+ warn = ' (WARNING: rid out of order, last rid = %d - could be overwrite boundary.)' % hdr.rid
+ else:
+ self.msg_cnt += 1
+ if self.auto_deq:
+ self.enqueued[hdr.rid] = hdr
+ elif isinstance(hdr, DeqHdr):
+ if self.auto_deq:
+ if hdr.deq_rid in self.enqueued:
+ del self.enqueued[hdr.deq_rid]
+ else:
+ warn = ' (WARNING: dequeue rid %d not found in enqueued records)' % hdr.deq_rid
+ stop = not self.check_rid(hdr)
+ if stop:
+ warn = ' (WARNING: rid out of order, last rid = %d - could be overwrite boundary.)' % hdr.rid
+ else:
+ warn = 'WARNING: Dequeue record rid=%d found in non-dequeue test - ignoring.' % hdr.rid
+ print ' > %s%s' % (hdr, warn)
+ if not stop:
+ stop = (self.last_file and hdr.check()) or hdr.empty() or self.fhdr.empty() or msg_num >= self.num_msgs
+ if stop:
+ break
+
+ def report(self):
+ if self.msg_cnt != self.num_msgs:
+ print 'WARNING: Found %d messages; %d expected.' % (self.msg_cnt, self.num_msgs)
+ if len(self.enqueued) > 0:
+ print 'Remaining enqueued records: ', len(self.enqueued)
+ for h in self.enqueued:
+ print self.enqueued[h]
+ print 'WARNING: Enqueue-Dequeue mismatch, %d enqueued records remain.' % len(self.enqueued)
+ print 'Test passed; %d records processed.' % self.msg_cnt
+
+ def advance_file(self, *start_info):
+ seek_flag = False
+ if len(start_info) == 3:
+ self.file_start = self.file_num = start_info[0]
+ self.fro = start_info[2]
+ seek_flag = True
+ if self.f != None and file_full(self.f):
+ self.file_num = self.incr_fnum()
+ if self.file_num == self.file_start:
+ return True
+ if self.file_start == 0:
+ self.last_file = self.file_num == num_files - 1
+ else:
+ self.last_file = self.file_num == self.file_start - 1
+ if self.file_num < 0 or self.file_num >= num_files:
+ raise Exception('Bad file number %d' % self.file_num)
+ file_name = 'jdata/test.%04d.jdat' % self.file_num
+ self.f = open(file_name)
+ self.fhdr = load(self.f, Hdr)
+ if seek_flag and self.f.tell() != self.fro:
+ self.f.seek(self.fro)
+ self.first_rec = True
+ print file_name, ": ", self.fhdr
+ return False
+
+ def incr_fnum(self):
+ self.file_num += 1
+ if self.file_num >= num_files:
+ self.file_num = 0;
+ return self.file_num
+
+ def check_rid(self, hdr):
+ if self.last_rid != -1 and hdr.rid != self.last_rid + 1:
+ return False
+ self.last_rid = hdr.rid
+ return True
+
+ def get_test(self, filename, tnum):
+ f=open(filename, 'r')
+ for l in f:
+ sl = l.strip().split(',')
+ if len(sl[1]) > 0: #Comments are in col 0, remaining cols are empty
+ try:
+ if (int(sl[0]) == tnum):
+ return { 'num_msgs':int(sl[1]),
+ 'min_size':int(sl[2]),
+ 'max_size':int(sl[3]),
+ 'auto_deq':sl[4] != 'FALSE' }
+ except Exception:
+ pass
+ return None
+
+ def analyze_files(self):
+ fname = ''
+ fnum = -1
+ rid = -1
+ fro = -1
+ tss = ''
+ print 'Analyzing journal files:'
+ for i in range(0, num_files):
+ file_name = 'jdata/test.%04d.jdat' % i
+ f = open(file_name)
+ fhdr = load(f, Hdr)
+ if fhdr.empty():
+ break
+ if (rid == -1 or fhdr.rid < rid) and fhdr.fro > 0:
+ fname = file_name
+ fnum = i
+ rid = fhdr.rid
+ fro = fhdr.fro
+ tss = fhdr.timestamp_str()
+ print ' %s: rid=%d, fro=0x%08x ts=%s' % (file_name, fhdr.rid, fhdr.fro, fhdr.timestamp_str())
+ if fnum < 0 or rid < 0 or fro < 0:
+ raise Exception('All journal files empty')
+ print 'Lowest rid found in file %s: rid=%d, fro=0x%08x ts=%s' % (fname, rid, fro, tss)
+ return (fnum, rid, fro)
+
+
+CLASSES = {
+ "e": EnqRec,
+ "d": DeqHdr,
+ "f": FileHdr
+}
+
+if len(sys.argv) != 3:
+ print 'Incorrect number of command-line arguments (expected 2, found %d).' % (len(sys.argv) - 1)
+ print 'Usage: ftest test-file test-number'
+ raise Exception('Bad command-line arguments')
+if not sys.argv[2].isdigit():
+ print 'Illegal argument (\"%s\"): test-number must be a number' % a
+ print 'Usage: ftest test-file test-number'
+ raise Exception('Illegal argument value')
+
+tnum = int(sys.argv[2])
+print 'Test number: %d' % tnum
+print 'Test file: %s' %sys.argv[1]
+
+m = Main(sys.argv[1], tnum)
+m.run()
+m.report()
Copied: store/trunk/cpp/tests/jrnl/jtest.cpp (from rev 891, store/trunk/cpp/jrnl/test/jtest.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,374 @@
+/**
+* \file jtest.cpp
+*
+* Test framework for RHM journalling.
+*
+* \author Kim van der Riet
+*
+* Copyright (C) 2007 Red Hat Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 "jtest.hpp"
+
+#include <assert.h>
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <sys/time.h>
+
+#define EXCEPTION_BASE 0x30
+
+int main(int argc, char** argv)
+{
+ jtest::print_compile_defs(false);
+ char* test_csv_file = NULL;
+ int tnum = -1;
+ try
+ {
+ jtest::proc_args(argc, argv, &test_csv_file, &tnum);
+ assert(test_csv_file != NULL);
+ assert(tnum >= 0);
+ std::cout << "Test data file: \"" << test_csv_file << "\"" << std::endl;
+ cout << "jtest: starting test " << tnum << endl;
+ jtest t(tnum);
+ t.initialize(test_csv_file);
+ t.run();
+ t.report();
+ t.finalize();
+ cout << "*** jtest done." << endl << endl;
+ }
+ catch (const rhm::journal::jexception& e)
+ {
+ cerr << e << endl;
+ cerr << std::hex << std::setfill('0');
+ cerr << "*** jtest failed with code 0x" << std::setw(4) << e.err_code() << " ***" << endl;
+ return(1);
+ }
+ return 0;
+}
+
+jtest::jtest(int tnum) throw (rhm::journal::jexception):
+ _start_time(new timeval),
+ _end_time(new timeval),
+ _tz_ptr(NULL),
+ _tnum(tnum)
+{}
+
+jtest::~jtest()
+{
+ delete _start_time;
+ delete _end_time;
+ if (p_args)
+ {
+ delete p_args;
+ p_args = NULL;
+ }
+ if (c_args)
+ {
+ delete c_args;
+ c_args = NULL;
+ }
+}
+
+void
+jtest::initialize(const char* test_csv_file) throw (rhm::journal::jexception)
+{
+ gettimeofday(_start_time, _tz_ptr);
+
+ targs ta;
+ jtest::get_test(&ta, std::string(test_csv_file), _tnum);
+ p_args = new msg_producer::_p_args(_jc, ta._num_msgs, ta._min_msg_size, ta._max_msg_size,
+ ta._auto_deq);
+ c_args = new msg_consumer::_c_args(_jc, ta._num_msgs, ta._min_msg_size, ta._max_msg_size);
+ _mp.initialize(p_args);
+ _mc.initialize(c_args);
+ _jc.initialize(&_mc.aio_dtokl(), NULL, &_mp.aio_dtokl(), &mp_aio_cb);
+
+ gettimeofday(_end_time, _tz_ptr);
+ string str;
+ cout << "initialize(): " << report_time(str) << endl;
+}
+
+void
+jtest::run() throw (rhm::journal::jexception)
+{
+ gettimeofday(_start_time, _tz_ptr);
+
+ // === Do something spectacular here... ===
+
+ // Use ONE OF the following two execution blocks below:
+
+ // Serial execution - uncomment these lines...
+#ifndef RHM_RDONLY
+ produce(p_args);
+#ifndef RHM_WRONLY
+ std::cout << "-----" << std::endl;
+ usleep(500000); // 0.5 sec
+#endif
+#endif
+
+#ifndef RHM_WRONLY
+ consume(c_args);
+#endif
+
+ // Concurrent execution - uncomment these lines...
+// pthread_create(&_p_thread, NULL, produce, (void*)&p_arg_arr[_tnum]);
+// pthread_create(&_c_thread, NULL, consume, (void*)&c_args);
+// pthread_join(_p_thread, NULL);
+// pthread_join(_c_thread, NULL);
+
+ if (p_args->_err)
+ if (p_args->_err != 1) // This is the zero msg length err, ignore
+ throw (rhm::journal::jexception(p_args->_err));
+ if (c_args->_err)
+ throw (rhm::journal::jexception(c_args->_err));
+
+ // === End: Do something spectacular here... ===
+
+ gettimeofday(_end_time, _tz_ptr);
+ string str;
+ cout << "run(): " << report_time(str) << endl;
+}
+
+void
+jtest::report() throw (rhm::journal::jexception)
+{}
+
+void
+jtest::finalize() throw (rhm::journal::jexception)
+{}
+
+string&
+jtest::report_time(string& str) const
+{
+ double diff = _end_time->tv_sec - _start_time->tv_sec +
+ (_end_time->tv_usec - _start_time->tv_usec)/1e6;
+ stringstream ss;
+ ss.precision(6);
+ ss << fixed << diff << " sec";
+ str.assign(ss.str());
+ return str;
+}
+
+// static varialbe declarations
+msg_producer::_p_args* jtest::p_args = NULL;
+msg_consumer::_c_args* jtest::c_args = NULL;
+msg_producer jtest::_mp;
+msg_consumer jtest::_mc;
+rhm::journal::jcntl jtest::_jc(JOURNAL_ID, JOURNAL_DIR, JOURNAL_BASE_FILENAME);
+
+// static method
+void
+jtest::mp_aio_cb(u_int32_t num_dtoks)
+{
+ jtest::_mp.aio_callback(num_dtoks);
+}
+
+// static method
+void
+jtest::proc_args(int argc, char** argv, char** test_file_name, int* test_num)
+ throw (rhm::journal::jexception)
+{
+ char num_chars[] = "0123456789";
+ stringstream ss;
+ if (argc != 3)
+ {
+ ss << "Illegal number of args: expected 2, found " << (argc - 1) <<
+ " (Hint: use \"jtest [test_def_file] [testnum]\")";
+ throw rhm::journal::jexception(EXCEPTION_BASE+0, ss.str());
+ }
+ *test_file_name = argv[1];
+ if (argv[2][0] == '-')
+ {
+ if (strcspn(argv[2], num_chars) != 1)
+ {
+ ss << "Test number argument \"" << argv[2] << "\" not a valid number.";
+ throw rhm::journal::jexception(EXCEPTION_BASE+1, ss.str());
+ }
+ }
+ else
+ {
+ if (strcspn(argv[2], num_chars) != 0)
+ {
+ ss << "Test number argument \"" << argv[2] << "\" not a valid number.";
+ throw rhm::journal::jexception(EXCEPTION_BASE+2, ss.str());
+ }
+ }
+ *test_num = atoi(argv[2]);
+ if (*test_num < 0)
+ {
+ ss << "Illegal test number \""<< test_num << "\"";
+ throw rhm::journal::jexception(EXCEPTION_BASE+3, ss.str());
+ }
+}
+
+// static method
+void*
+jtest::produce(void* ptr)
+{
+ msg_producer::_p_args* p_args_ptr = (msg_producer::_p_args*)ptr;
+ try { _mp.produce(p_args_ptr); }
+ catch (const rhm::journal::jexception& e)
+ {
+ msg_consumer::interrupt(); // Wheels fell off; stop consumer thread
+ cout << "Producer failed with exception 0x" << hex << setw(4) << setfill('0')
+ << e.err_code() << "; consumer thread aborted." << endl;
+ cout << e << endl;
+ p_args_ptr->_err = e.err_code();
+ }
+ return NULL;
+}
+
+// static method
+void*
+jtest::consume(void* ptr)
+{
+ msg_consumer::_c_args* c_args_ptr = (msg_consumer::_c_args*)ptr;
+ try { _mc.consume(c_args_ptr); }
+ catch (const rhm::journal::jexception& e)
+ {
+ msg_producer::interrupt(); // Train smash; stop producer thread
+ cout << "Consumer failed with exception 0x" << hex << setw(4) << setfill('0')
+ << e.err_code() << "; producer thread aborted." << endl;
+ cout << e << endl;
+ c_args_ptr->_err = e.err_code();
+ }
+ return NULL;
+}
+
+// static method
+void
+jtest::get_test(targs* tap, const std::string& filename, const unsigned tnum) throw (rhm::journal::jexception)
+{
+ if (tap == NULL)
+ throw rhm::journal::jexception(EXCEPTION_BASE+4, "targs NULL", "jtest", "get_test");
+ char line[MAX_LINE_LEN];
+ std::ifstream ifs(filename.c_str());
+ if (!ifs.good())
+ {
+ std::cerr << "ERROR: Unable to open file \"" << filename << "\"!" << std:: endl;
+ throw rhm::journal::jexception(EXCEPTION_BASE+5, "CSV file not found", "jtest", "get_test");
+ }
+ std::vector<char*> toks;
+ bool found = false;
+ while (ifs.good() && !found)
+ {
+ ifs.getline(line, MAX_LINE_LEN);
+ toks.clear();
+ char* pch = strtok(line, ",");
+ while (pch != NULL)
+ {
+ toks.push_back(pch);
+ pch = strtok(NULL, ",");
+ }
+ if (toks.size() >= 5)
+ {
+ unsigned this_tnum = atoi(toks[0]);
+ if (this_tnum == tnum)
+ {
+ found = true;
+ tap->_num_msgs = atol(toks[1]);
+ tap->_min_msg_size = atol(toks[2]);
+ tap->_max_msg_size = atol(toks[3]);
+ tap->_auto_deq = strcmp(toks[4], "FALSE") != 0;
+ if (toks.size() > 5)
+ tap->_comment = std::string(toks[5]);
+ else
+ tap->_comment = std::string();
+ std::cout << "Test " << tnum << ": Messages=" << tap->_num_msgs << " Size=" <<
+ tap->_min_msg_size;
+ if (tap->_min_msg_size == tap->_max_msg_size)
+ std::cout << " (fixed)";
+ else
+ std::cout << " - " << tap->_max_msg_size << " (random)";
+ std::cout << (tap->_auto_deq ? " auto-dequeue" : " no dequeue");
+ if (tap->_comment.size())
+ std::cout << " [" << tap->_comment << "]";
+ std::cout << std::endl;
+ }
+ }
+ }
+ ifs.close();
+ if (!found)
+ {
+ std::cout << "ERROR: Failed to find test " << tnum << " in test file \"" << filename <<
+ "\"." << std::endl;
+ throw rhm::journal::jexception(EXCEPTION_BASE+6, "Test data not found in CSV test data file.");
+ }
+}
+
+// static method
+void
+jtest::print_compile_defs(bool verbose)
+{
+#ifdef RHM_CLEAN
+ cout << "*** WARNING: Compiled with RHM_CLEAN defined." << endl;
+#endif
+#ifdef RHM_JOWRITE
+ cout << "*** WARNING: Compiled with RHM_JOWRITE defined." << endl;
+#endif
+#ifdef RHM_WRONLY
+ cout << "*** WARNING: Compiled with RHM_WRONLY defined." << endl;
+#endif
+#ifdef RHM_RDONLY
+ cout << "*** WARNING: Compiled with RHM_RDONLY defined." << endl;
+#endif
+#if defined(RHM_CLEAN) || defined(RHM_JOWRITE) || defined(RHM_WRONLY) || defined(RHM_RDONLY )
+ cout << endl;
+#endif
+
+ if (verbose)
+ {
+#ifdef JRNL_BIG_ENDIAN
+ cout << "JRNL_BIG_ENDIAN defined." << endl;
+#endif
+#ifdef JRNL_LITTLE_ENDIAN
+ cout << "JRNL_LITTLE_ENDIAN defined." << endl;
+#endif
+#ifdef JRNL_32_BIT
+ cout << "JRNL_32_BIT defined." << endl;
+#endif
+#ifdef JRNL_64_BIT
+ cout << "JRNL_64_BIT defined." << endl;
+#endif
+ cout << "JRNL_DBLK_SIZE = " << JRNL_DBLK_SIZE << " bytes" << endl;
+ cout << "JRNL_SBLK_SIZE = " << JRNL_SBLK_SIZE << " dblks (" <<
+ (JRNL_DBLK_SIZE * JRNL_SBLK_SIZE) << " bytes)" << endl;
+ cout << "JRNL_FILE_SIZE = " << JRNL_FILE_SIZE << " dblks (" <<
+ (JRNL_DBLK_SIZE * JRNL_SBLK_SIZE * JRNL_FILE_SIZE / 1024.0 / 1024.0) << " MiB)" << endl;
+ cout << "JRNL_NUM_FILES = " << JRNL_NUM_FILES << " (Total capacity: " <<
+ (JRNL_DBLK_SIZE * JRNL_SBLK_SIZE * JRNL_FILE_SIZE * JRNL_NUM_FILES / 1024.0 / 1024.0) <<
+ " MiB)" << endl;
+ cout << "JRNL_RMGR_PAGE_SIZE = " << JRNL_RMGR_PAGE_SIZE << " sblocks (" <<
+ (JRNL_DBLK_SIZE * JRNL_SBLK_SIZE * JRNL_RMGR_PAGE_SIZE / 1024.0) << " KiB)" << endl;
+ cout << "JRNL_RMGR_PAGES = " << JRNL_RMGR_PAGES << " pages (" <<
+ (JRNL_DBLK_SIZE * JRNL_SBLK_SIZE * JRNL_RMGR_PAGE_SIZE * JRNL_RMGR_PAGES / 1024.0) <<
+ " KiB)" << endl;
+ cout << "JRNL_WMGR_PAGE_SIZE = " << JRNL_WMGR_PAGE_SIZE << " sblocks (" <<
+ (JRNL_DBLK_SIZE * JRNL_SBLK_SIZE * JRNL_WMGR_PAGE_SIZE / 1024.0) << " KiB)" << endl;
+ cout << "JRNL_WMGR_PAGES = " << JRNL_WMGR_PAGES << " pages (" <<
+ (JRNL_DBLK_SIZE * JRNL_SBLK_SIZE * JRNL_WMGR_PAGE_SIZE * JRNL_WMGR_PAGES / 1024.0) <<
+ " KiB)" << endl;
+ }
+}
Copied: store/trunk/cpp/tests/jrnl/jtest.hpp (from rev 891, store/trunk/cpp/jrnl/test/jtest.hpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.hpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/jtest.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,102 @@
+/**
+* \file jtest.hpp
+*
+* Test framework for RHM journalling.
+*
+* \author Kim van der Riet
+*
+* Copyright (C) 2007 Red Hat Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 _jtest_hpp_
+#define _jtest_hpp_
+
+#include <jrnl/jcfg.hpp>
+#include <jrnl/jcntl.hpp>
+#include <jrnl/jexception.hpp>
+#include "msg_producer.hpp"
+#include "msg_consumer.hpp"
+
+#define JOURNAL_ID "Test Journal"
+#define JOURNAL_DIR "jdata"
+#define JOURNAL_BASE_FILENAME "test"
+//#define JRNL_TEST_CSV_FILE "test/wtests.csv"
+
+//#define NUM_TESTS 76
+#define MAX_LINE_LEN 1024
+
+using namespace std;
+
+class jtest
+{
+public:
+ struct targs
+ {
+ u_int32_t _num_msgs;
+ size_t _min_msg_size;
+ size_t _max_msg_size;
+ bool _auto_deq;
+ std::string _comment;
+ };
+
+private:
+// static msg_producer::_p_args p_arg_arr[NUM_TESTS];
+ static msg_producer::_p_args* p_args;
+ static msg_consumer::_c_args* c_args;
+ static rhm::journal::jcntl _jc;
+
+ struct timeval* _start_time;
+ struct timeval* _end_time;
+ struct timezone* _tz_ptr;
+ pthread_t _p_thread;
+ pthread_t _c_thread;
+ int _tnum;
+
+public:
+ jtest(int test_num) throw (rhm::journal::jexception);
+ ~jtest();
+
+ static void proc_args(int argc, char** argv, char** test_file_name, int* test_num)
+ throw (rhm::journal::jexception);
+ void initialize(const char* test_csv_file) throw (rhm::journal::jexception);
+ void run() throw (rhm::journal::jexception);
+ void report() throw (rhm::journal::jexception);
+ void finalize() throw (rhm::journal::jexception);
+ inline const int test_num() const { return _tnum; }
+ static void get_test(targs* tap, const std::string& filename, const unsigned test_num)
+ throw (rhm::journal::jexception);
+ static void print_compile_defs(bool verbose);
+
+ // Methods called by threads
+ static void* produce(void* ptr);
+ static void* consume(void* ptr);
+ static msg_producer _mp;
+ static msg_consumer _mc;
+
+private:
+ string& report_time(string& str) const;
+
+ // AIO callback functions
+ static void mp_aio_cb(u_int32_t num_dtoks);
+};
+
+#endif
Copied: store/trunk/cpp/tests/jrnl/msg_consumer.cpp (from rev 891, store/trunk/cpp/jrnl/test/msg_consumer.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,250 @@
+/**
+* \file msg_consumer.cpp
+*
+* Message producer; part of test framework for RHM journalling
+*
+* \author Kim van der Riet
+*
+* Copyright (C) 2007 Red Hat Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 "msg_consumer.hpp"
+
+#include <sstream>
+#include <cstring>
+#include <iostream>
+#include <unistd.h>
+#include <jrnl/jerrno.hpp>
+
+#define EXCEPTION_BASE 0x40
+
+msg_consumer::_c_args::_c_args(rhm::journal::jcntl& jc, u_int32_t num_msgs, size_t min_msg_size,
+ size_t max_msg_size):
+ _jc(jc),
+ _num_msgs(num_msgs),
+ _min_msg_size(min_msg_size),
+ _max_msg_size(max_msg_size),
+ _err(0)
+{}
+
+msg_consumer::msg_consumer():
+ _tot_blks(0),
+ _tot_msize(0)
+{
+ instCnt++;
+}
+
+msg_consumer::~msg_consumer()
+{
+ for (u_int32_t i=0; i<_num_msgs; i++)
+ {
+ delete _dtok_master_list[i];
+ _dtok_master_list[i] = NULL;
+ }
+ instCnt--;
+}
+
+void
+msg_consumer::initialize(const u_int32_t numMsgs)
+{
+ _num_msgs = numMsgs;
+ for (u_int32_t i=0; i<_num_msgs; i++)
+ {
+ rhm::journal::data_tok* dtp = new rhm::journal::data_tok;
+ dtp->set_wstate(rhm::journal::data_tok::ENQ); // Assume all msgs enqueued OK
+ _dtok_master_list.push_back(dtp);
+
+ }
+}
+
+void
+msg_consumer::initialize(_c_args* args)
+{
+ if (args)
+ initialize(args->_num_msgs);
+}
+
+u_int32_t
+msg_consumer::consume(rhm::journal::jcntl& _jcntl, const u_int32_t num_msgs,
+ const size_t min_msg_size, const size_t max_msg_size) throw (rhm::journal::jexception)
+{
+//std::cout << "msg_consumer::consume() num_msgs=" << num_msgs << std::endl;
+ size_t data_size;
+ u_int32_t msgCntr = 0;
+ for (msgCntr = 0; msgCntr < num_msgs && !_interrupt_flag; msgCntr++)
+ {
+ rhm::journal::data_tok* dtokp = _dtok_master_list[msgCntr];
+ unsigned aio_sleep_cnt = 0;
+ unsigned jempty_sleep_cnt = 0;
+ bool read = false;
+ while (!read)
+ {
+ rhm::journal::iores res = _jcntl.read_data((void* const)_msg_buff, buffSize, dtokp);
+ rhm::journal::data_tok::read_state rs = dtokp->rstate();
+ rhm::journal::data_tok::write_state ws = dtokp->wstate();
+ switch (res)
+ {
+ case rhm::journal::RHM_IORES_SUCCESS:
+ if (rs != rhm::journal::data_tok::READ || ws != rhm::journal::data_tok::ENQ)
+ std::cout << "###### Unexpected state: res=" << iores_str[res] << " ws=" <<
+ dtokp->wstate_str() << "; rs=" << dtokp->rstate_str();
+ data_size = dtokp->dsize();
+ _msg_buff[data_size] = 0; // Make msg into a c-string
+ read = true;
+ _tot_blks += dtokp->dblocks_proc();
+ _tot_msize += data_size;
+
+ // Comment out these for performance checks/measurements
+ check_msg(msgCntr, data_size, min_msg_size, max_msg_size, true, _msg_buff);
+ //print_dbug(msgCntr, data_size, _msg_buff, true);
+ break;
+ case rhm::journal::RHM_IORES_AIO_WAIT:
+//std::cout << "a" << std::flush;
+ if (rs == rhm::journal::data_tok::READ ||
+ ws != rhm::journal::data_tok::ENQ)
+ std::cout << "###### Unexpected state: res=" << iores_str[res] << " ws=" <<
+ dtokp->wstate_str() << "; rs=" << dtokp->rstate_str();
+ if (aio_sleep_cnt >= MAX_AIO_SLEEPS)
+ throw rhm::journal::jexception(EXCEPTION_BASE+0,
+ "Page cache full (AIO events outstanding for all pages); "
+ "exceeced wait time for pages to free.", "msg_consumer",
+ "consume");
+ usleep(AIO_SLEEP_TIME);
+ aio_sleep_cnt++;
+ break;
+ case rhm::journal::RHM_IORES_EMPTY:
+//std::cout << "e" << std::flush;
+ if (rs == rhm::journal::data_tok::READ ||
+ ws != rhm::journal::data_tok::ENQ)
+ std::cout << "Unexpected state: res=" << iores_str[res] << " ws=" <<
+ dtokp->wstate_str() << "; rs=" << dtokp->rstate_str();
+ if (jempty_sleep_cnt >= MAX_EMPTY_SLEEPS)
+ throw rhm::journal::jexception(EXCEPTION_BASE+1,
+ "Journal empty (no further data written to journal); "
+ "exceeded wait time for journal to fill.", "msg_consumer",
+ "consume");
+ usleep(EMPTY_SLEEP_TIME);
+ jempty_sleep_cnt++;
+ break;
+ default:
+ std::cout << "###### Unexpected msg state: id=" << dtokp->id() << " ms=" <<
+ dtokp->wstate_str() << " res=" << iores_str[res] << std::flush;
+ }
+ }
+ }
+ _interrupt_flag = false;
+ return msgCntr;
+}
+
+u_int32_t
+msg_consumer::consume(_c_args* args) throw (rhm::journal::jexception)
+{
+ return consume(args->_jc, args->_num_msgs, args->_min_msg_size, args->_max_msg_size);
+}
+
+void
+msg_consumer::aio_callback(u_int32_t num_dtoks)
+{
+ std::cout << "msg_consumer::aio_cb(" << num_dtoks << ")" << std::endl;
+}
+
+void
+msg_consumer::interrupt()
+{
+ _interrupt_flag = true;
+}
+
+void
+msg_consumer::check_msg(const u_int32_t msgCntr, const size_t msg_size, const size_t min_msg_size,
+ const size_t max_msg_size, bool chk_data, char* buff) const throw (rhm::journal::jexception)
+{
+ if (max_msg_size > 0 && (msg_size < min_msg_size || msg_size > max_msg_size))
+ {
+ std::stringstream ss;
+ ss << "Message " << msgCntr << " of size " << msg_size;
+ if (min_msg_size == max_msg_size)
+ ss << " is valid, but exptected size is " << min_msg_size;
+ else
+ {
+ ss << " is valid, but exptected size must lie between " << min_msg_size;
+ ss << " and " << max_msg_size;
+ }
+ throw rhm::journal::jexception(EXCEPTION_BASE+2, ss.str(), "msg_consumer", "check_msg");
+ }
+ if (chk_data)
+ {
+ for (unsigned i=0; i<msg_size; i++)
+ {
+ char expected = '0' + (((msgCntr%10) + i + 1) % 10);
+ if (buff[i] != expected)
+ {
+ std::stringstream ss;
+ ss << "Message " << msgCntr << " failed content check at char " << i;
+ ss << ": found \'" << buff[i] << "\'; expected \'" << expected << "\'";
+ throw rhm::journal::jexception(EXCEPTION_BASE+3, ss.str(), "msg_consumer",
+ "check_msg");
+ }
+ }
+ }
+}
+
+void
+msg_consumer::print_dbug(const u_int32_t msgCntr, const size_t msg_size, char* buff,
+ const bool show_msg) const
+{
+// std::cout << 'c' << std::flush;
+ std::cout << "msg_consumer::consume(): read msg " << msgCntr << " size=" << msg_size;
+ if (show_msg)
+ {
+ std::cout << " msg=\"";
+ if (msg_size <= 50)
+ std::cout << buff;
+ else
+ {
+ size_t i=0;
+ for (; i<20; i++)
+ std::cout << buff[i];
+ std::cout << " ... ";
+ i=msg_size-20;
+ for (; i<msg_size; i++)
+ std::cout << buff[i];
+ }
+ std::cout << "\"";
+ }
+ std::cout << std::endl;
+ std::cout.flush();
+}
+
+// *** Static member declarations ***
+
+const char* msg_consumer::iores_str[] = {
+ "RHM_IORES_SUCCESS",
+ "RHM_IORES_AIO_WAIT",
+ "RHM_IORES_EMPTY",
+ "RHM_IORES_FULL",
+ "RHM_IORES_BUSY"
+ };
+
+u_int16_t msg_consumer::instCnt = 0;
+const size_t msg_consumer::buffSize = JRNL_DBLK_SIZE * JRNL_SBLK_SIZE * JRNL_FILE_SIZE * JRNL_NUM_FILES;
+char msg_consumer::_msg_buff[msg_consumer::buffSize];
+bool msg_consumer::_interrupt_flag = false;
Copied: store/trunk/cpp/tests/jrnl/msg_consumer.hpp (from rev 891, store/trunk/cpp/jrnl/test/msg_consumer.hpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.hpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,93 @@
+/**
+* \file msg_consumer.hpp
+*
+* Message producer; part of test framework for RHM journalling
+*
+* \author Kim van der Riet
+*
+* Copyright (C) 2007 Red Hat Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 msg_consumer_hpp
+#define msg_consumer_hpp
+
+#include <jrnl/jcntl.hpp>
+#include <jrnl/jexception.hpp>
+
+#define MAX_AIO_SLEEPS 500
+#define AIO_SLEEP_TIME 1000
+
+#define MAX_EMPTY_SLEEPS 1000
+#define EMPTY_SLEEP_TIME 10000
+
+class msg_consumer
+{
+public:
+ struct _c_args
+ {
+ rhm::journal::jcntl& _jc;
+ u_int32_t _num_msgs;
+ size_t _min_msg_size;
+ size_t _max_msg_size;
+ u_int32_t _err;
+ _c_args(rhm::journal::jcntl& jc, u_int32_t num_msgs, size_t min_msg_size,
+ size_t max_msg_size);
+ };
+
+ static const char* iores_str[];
+
+private:
+ static u_int16_t instCnt;
+ static const size_t buffSize;
+ static char _msg_buff[];
+ static bool _interrupt_flag;
+ u_int32_t _num_msgs;
+ std::deque<rhm::journal::data_tok*> _dtok_master_list; // One dtok per msg to be received
+ std::deque<rhm::journal::data_tok*> _aio_cmpl_dtok_list; // Dtoks from completed AIOs go here
+ u_int64_t _tot_blks;
+ u_int64_t _tot_msize;
+
+public:
+ msg_consumer();
+ ~msg_consumer();
+
+ void initialize(const u_int32_t numMsgs);
+ void initialize(_c_args* args);
+
+ u_int32_t consume(rhm::journal::jcntl& _jcntl, const u_int32_t numMsgs,
+ const size_t min_msg_size, const size_t max_msg_size) throw (rhm::journal::jexception);
+ u_int32_t consume(_c_args* args) throw (rhm::journal::jexception);
+ void aio_callback(u_int32_t num_dtoks);
+
+ const inline u_int64_t get_tot_blks() const { return _tot_blks; }
+ const inline u_int64_t get_tot_msize() const { return _tot_msize; }
+ inline std::deque<rhm::journal::data_tok*>& aio_dtokl() { return _aio_cmpl_dtok_list; }
+ static void interrupt();
+private:
+ void check_msg(const u_int32_t msgCntr, const size_t msg_size, const size_t min_msg_size,
+ const size_t max_msg_size, bool chk_data, char* buff) const
+ throw (rhm::journal::jexception);
+ void print_dbug(const u_int32_t msgCntr, const size_t msg_size, char* buff,
+ const bool show_msg = false) const;
+
+}; // class msg_consumer
+
+#endif // ifndef msg_consumer_hpp
Copied: store/trunk/cpp/tests/jrnl/msg_producer.cpp (from rev 891, store/trunk/cpp/jrnl/test/msg_producer.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,363 @@
+/**
+* \file msg_producer.cpp
+*
+* Message producer; part of test framework for RHM journalling
+*
+* \author Kim van der Riet
+*
+* Copyright (C) 2007 Red Hat Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 "msg_producer.hpp"
+
+#include <assert.h>
+#include <iostream>
+#include <sstream>
+
+#define EXCEPTION_BASE 0x50
+
+msg_producer::_p_args::_p_args(rhm::journal::jcntl& jc, u_int32_t num_msgs,
+ size_t min_msg_size, size_t max_msg_size, bool auto_dequeue):
+ _jc(jc),
+ _num_msgs(num_msgs),
+ _min_msg_size(min_msg_size),
+ _max_msg_size(max_msg_size),
+ _auto_dequeue(auto_dequeue),
+ _err(0)
+{}
+
+msg_producer::msg_producer():
+ _jcptr(NULL),
+ _num_msgs(0),
+ _num_msgs_enq_subm(0),
+ _num_msgs_enq(0),
+ _num_msgs_deq_subm(0),
+ _num_msgs_deq(0),
+ _tot_dblks(0),
+ _tot_dsize(0)
+{
+ instance_cnt++;
+ init_msg_buff();
+ _aio_cmpl_dtok_list.clear();
+ _dd_dtok_list.clear();
+}
+
+msg_producer::~msg_producer()
+{
+ for (u_int32_t i=0; i<_num_msgs; i++)
+ {
+ delete _dtok_master_list[i];
+ _dtok_master_list[i] = NULL;
+ }
+ instance_cnt--;
+}
+
+void
+msg_producer::initialize(const u_int32_t numMsgs, bool auto_dequeue)
+{
+ _num_msgs = numMsgs;
+ _auto_dequeue = auto_dequeue;
+ for (u_int32_t i=0; i<_num_msgs; i++)
+ _dtok_master_list.push_back(new rhm::journal::data_tok);
+}
+
+void
+msg_producer::initialize(_p_args* args)
+{
+ if (args)
+ initialize(args->_num_msgs, args->_auto_dequeue);
+}
+
+u_int32_t
+msg_producer::produce(rhm::journal::jcntl& jc, const size_t minMsgSize,
+ const size_t maxMsgSize) throw (rhm::journal::jexception)
+{
+ _jcptr = &jc;
+ if (!_num_msgs)
+ return 0;
+ if (maxMsgSize > _msg_buff_size)
+ throw rhm::journal::jexception(EXCEPTION_BASE+0, "Message size exceeds internal buffer limit",
+ "msg_producer", "produce");
+ {
+//std::cout << "[" << _num_msgs << "]" << std::flush;
+ for(u_int32_t msgCntr = 0; msgCntr < _num_msgs && !_interrupt_flag; msgCntr++)
+ {
+ unsigned aio_sleep_cnt = 0;
+ unsigned jfull_sleep_cnt = 0;
+ size_t size = maxMsgSize;
+ if (minMsgSize < maxMsgSize)
+ {
+ size_t sizeRange = maxMsgSize - minMsgSize + 1;
+ size = minMsgSize + (int)(1.0*rand()*sizeRange/(RAND_MAX + 1.0));
+ }
+ rhm::journal::data_tok* dtokp = _dtok_master_list[msgCntr];
+ const void* const msg = (char*)_msg_buff + (msgCntr%10);
+//std::cout << "e" << dtokp->id() << " " << std::flush;
+ bool written = false;
+ while (!written)
+ {
+ rhm::journal::iores eres = jc.enqueue_data(msg, size, dtokp);
+ rhm::journal::data_tok::write_state ws = dtokp->wstate();
+ const char* wsstr = dtokp->wstate_str();
+ switch (eres)
+ {
+ case rhm::journal::RHM_IORES_SUCCESS:
+ if (ws >= rhm::journal::data_tok::ENQ_SUBM)
+ {
+ written = true;
+ _tot_dblks += dtokp->dblocks_proc();
+ _tot_dsize += dtokp->dsize();
+ }
+ else
+ std::cout << "Unexpected msg state: id=" << dtokp->id() << " ws=" <<
+ wsstr << " eres=" << iores_str[eres] << std::flush;
+ break;
+ case rhm::journal::RHM_IORES_AIO_WAIT:
+ if (ws >= rhm::journal::data_tok::ENQ_SUBM)
+ std::cout << "Unexpected msg state: id=" << dtokp->id() << " ws=" <<
+ wsstr << " eres=" << iores_str[eres] << std::flush;
+ if (aio_sleep_cnt >= MAX_AIO_SLEEPS)
+ throw rhm::journal::jexception(EXCEPTION_BASE+1,
+ "Page cache full (AIO events outstanding for all pages); "
+ "exceeced wait time for pages to free.", "msg_producer",
+ "produce");
+//std::cout << "$" << dtokp->id() << " " << std::flush;
+ usleep(AIO_SLEEP_TIME);
+ jc.get_wr_events();
+ aio_sleep_cnt++;
+ break;
+ case rhm::journal::RHM_IORES_FULL:
+ if (ws >= rhm::journal::data_tok::ENQ_SUBM)
+ std::cout << "Unexpected msg state: id=" << dtokp->id() << " ws=" <<
+ wsstr << " eres=" << iores_str[eres] << std::flush;
+ if (jfull_sleep_cnt >= MAX_FULL_SLEEPS)
+ throw rhm::journal::jexception(EXCEPTION_BASE+2,
+ "Journal full (next file to write still has undequeued data); "
+ "exceeded wait time for journal to free.", "msg_producer",
+ "produce");
+//std::cout << "#" << dtokp->id() << " " << std::flush;
+ usleep(FULL_SLEEP_TIME);
+ jfull_sleep_cnt++;
+ break;
+ default:
+ std::cout << "Unexpected msg state: id=" << dtokp->id() << " ws=" <<
+ wsstr << " eres=" << iores_str[eres] << std::flush;
+ }
+
+ //print_dbug(msgCntr, size, (char*)msg, true);
+ }
+ _num_msgs_enq_subm++;
+
+ // Submit deferred dequeues (if any)
+ if (_auto_dequeue)
+ send_deferred_dequeues(jc);
+ }
+ jrnl_flush(jc, _num_msgs);
+ }
+ _interrupt_flag = false;
+//std::cout << std::endl;
+ std::cout << std::dec;
+ std::cout << "Messages sent = " << _num_msgs << std::endl;
+ std::cout << "Total enqueue events = " << _num_msgs_enq << std::endl;
+ std::cout << "Total dequeue events = " << _num_msgs_deq << std::endl;
+//std::cout << std::endl;
+ return _num_msgs;
+}
+
+u_int32_t
+msg_producer::produce(_p_args* args) throw (rhm::journal::jexception)
+{
+ return produce(args->_jc, args->_min_msg_size, args->_max_msg_size);
+}
+
+void
+msg_producer::aio_callback(u_int32_t num_dtoks)
+{
+ assert(num_dtoks == _aio_cmpl_dtok_list.size());
+ std::deque<rhm::journal::data_tok*> this_dtok_list(_aio_cmpl_dtok_list.begin(),
+ _aio_cmpl_dtok_list.end());
+ _aio_cmpl_dtok_list.clear();
+ for (u_int32_t i=0; i<num_dtoks; i++)
+ {
+ rhm::journal::data_tok*& dtokp = this_dtok_list.front();
+ rhm::journal::data_tok::write_state st = dtokp->wstate();
+ if (st == rhm::journal::data_tok::ENQ)
+ {
+ _num_msgs_enq++;
+//std::cout << "^" << dtokp->id() << " " << std::flush;
+ _dd_dtok_list.push_back(dtokp);
+ }
+ else if (dtokp->wstate() == rhm::journal::data_tok::DEQ)
+ _num_msgs_deq++;
+ this_dtok_list.pop_front();
+ }
+}
+
+void
+msg_producer::interrupt()
+{
+ _interrupt_flag = true;
+}
+
+void
+msg_producer::init_msg_buff()
+{
+ for (unsigned int i=0; i<_msg_buff_size; i++)
+ _msg_buff[i] = '0' + (i + 1)%10;
+}
+
+void
+msg_producer::send_deferred_dequeues(rhm::journal::jcntl& jc)
+{
+ while (!_dd_dtok_list.empty())
+ {
+ rhm::journal::data_tok* ddtokp = _dd_dtok_list.front();
+//std::cout << "d" << ddtokp->id() << " " << std::flush;
+ unsigned aio_sleep_cnt = 0;
+ bool written = false;
+ while (!written)
+ {
+ rhm::journal::iores dres = _jcptr->dequeue_data(ddtokp);
+ const char* wsstr = ddtokp->wstate_str();
+ switch (dres)
+ {
+ case rhm::journal::RHM_IORES_SUCCESS:
+ written = true;
+ _num_msgs_deq_subm++;
+ break;
+ case rhm::journal::RHM_IORES_AIO_WAIT:
+ if (aio_sleep_cnt >= MAX_AIO_SLEEPS)
+ throw rhm::journal::jexception(EXCEPTION_BASE+3,
+ "Page cache full (AIO events outstanding for all pages); "
+ "exceeced wait time for pages to free.", "msg_producer",
+ "send_deferred_dequeues");
+//std::cout << "$" << dres << " " << std::flush;
+ jc.get_wr_events();
+ usleep(AIO_SLEEP_TIME);
+ aio_sleep_cnt++;
+ break;
+ default:
+ std::cout << "Unexpected msg state: id=" << ddtokp->id() << " ws=" <<
+ wsstr << " dres=" << iores_str[dres] << std::flush;
+ }
+ }
+ _dd_dtok_list.pop_front();
+ }
+}
+
+void
+msg_producer::jrnl_flush(rhm::journal::jcntl& jc, u_int32_t num_msgs_sent)
+{
+ // Clear any unsent enqueues in buffer, then wait for all enqueues to return
+ unsigned flush_cnt = 0;
+ if (_num_msgs_enq < num_msgs_sent)
+ {
+ jc.flush();
+ while (_num_msgs_enq < num_msgs_sent && !_interrupt_flag)
+ {
+ if (flush_cnt >= MAX_FLUSH_SLEEPS)
+ {
+ std::stringstream ss;
+ ss << "Journal flush phase 1 failed, _num_msgs_enq=" << _num_msgs_enq;
+ ss << " num_msgs_sent=" << num_msgs_sent;
+ throw rhm::journal::jexception(EXCEPTION_BASE+4, ss.str(), "msg_producer", "jrnl_flush");
+ }
+//std::cout << "+" << std::flush;
+ jc.get_wr_events();
+ usleep(FLUSH_SLEEPTIME);
+ flush_cnt++;
+ }
+ }
+
+ // Submit deferred dequeues (if any)
+ if (_auto_dequeue)
+ {
+ send_deferred_dequeues(jc);
+
+ // Clear any unsent dequeues in buffer, then wait for all dequeues to return
+ flush_cnt = 0;
+ if (_num_msgs_deq < num_msgs_sent)
+ {
+ jc.flush();
+ while (_num_msgs_deq < num_msgs_sent && !_interrupt_flag)
+ {
+ if (flush_cnt >= MAX_FLUSH_SLEEPS)
+ {
+ std::stringstream ss;
+ ss << "Journal flush phase 2 failed, _num_msgs_deq=" << _num_msgs_deq;
+ ss << " num_msgs_sent=" << num_msgs_sent;
+ throw rhm::journal::jexception(EXCEPTION_BASE+5, ss.str(), "msg_producer", "jrnl_flush");
+ }
+//std::cout << "*" << std::flush;
+ jc.get_wr_events();
+ usleep(1000);
+ flush_cnt++;
+ }
+ }
+ }
+}
+
+void
+msg_producer::print_dbug(u_int32_t msg_cnt, size_t msg_size, char* _msg_buff, bool show_msg) const
+{
+ std::cout << "msg_producer::produce(): wrote msg " << msg_cnt << " size=" << msg_size;
+ if (show_msg)
+ {
+ std::cout << " msg=\"";
+ if (msg_size <= 50)
+ {
+ // Since _msg_buff points to a *very* large buffer of data, we must still
+ // count out how much we are printing here.
+ for (size_t i=0; i<msg_size; i++)
+ std::cout << _msg_buff[i];
+ }
+ else
+ {
+ size_t i=0;
+ for (; i<20; i++)
+ std::cout << _msg_buff[i];
+ std::cout << " ... ";
+ i=msg_size-20;
+ for (; i<msg_size; i++)
+ std::cout << _msg_buff[i];
+ }
+ std::cout << "\"";
+ }
+ std::cout << std::endl;
+ std::cout.flush();
+}
+
+// *** Static member declarations ***
+
+const char* msg_producer::iores_str[] = {
+ "RHM_IORES_SUCCESS",
+ "RHM_IORES_AIO_WAIT",
+ "RHM_IORES_EMPTY",
+ "RHM_IORES_FULL",
+ "RHM_IORES_BUSY"
+ };
+
+u_int16_t msg_producer::instance_cnt = 0;
+const size_t msg_producer::_msg_buff_size = JRNL_DBLK_SIZE * JRNL_SBLK_SIZE * JRNL_FILE_SIZE * JRNL_NUM_FILES;
+char msg_producer::_msg_buff[msg_producer::_msg_buff_size];
+bool msg_producer::_interrupt_flag = false;
+
Copied: store/trunk/cpp/tests/jrnl/msg_producer.hpp (from rev 891, store/trunk/cpp/jrnl/test/msg_producer.hpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.hpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,103 @@
+/**
+* \file msg_producer.hpp
+*
+* Message producer; part of test framework for RHM journalling
+*
+* \author Kim van der Riet
+*
+* Copyright (C) 2007 Red Hat Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 msg_producer_hpp
+#define msg_producer_hpp
+
+#include <jrnl/jcntl.hpp>
+
+#define MAX_AIO_SLEEPS 500
+#define AIO_SLEEP_TIME 1000
+
+#define MAX_FULL_SLEEPS 1000
+#define FULL_SLEEP_TIME 10000
+
+#define MAX_FLUSH_SLEEPS 1000
+#define FLUSH_SLEEPTIME 1000
+
+class msg_producer
+{
+public:
+ struct _p_args
+ {
+ rhm::journal::jcntl& _jc;
+ u_int32_t _num_msgs;
+ size_t _min_msg_size;
+ size_t _max_msg_size;
+ bool _auto_dequeue;
+ u_int32_t _err;
+ _p_args(rhm::journal::jcntl& jc, u_int32_t num_msgs, size_t min_msg_size,
+ size_t max_msg_size, bool auto_dequeue);
+ };
+
+ static const char* iores_str[];
+
+private:
+ static u_int16_t instance_cnt;
+ static const size_t _msg_buff_size;
+ static char _msg_buff[];
+ static bool _interrupt_flag;
+ rhm::journal::jcntl* _jcptr;
+ u_int32_t _num_msgs;
+ bool _auto_dequeue;
+ u_int32_t _num_msgs_enq_subm;
+ u_int32_t _num_msgs_enq;
+ u_int32_t _num_msgs_deq_subm;
+ u_int32_t _num_msgs_deq;
+ std::deque<rhm::journal::data_tok*> _dtok_master_list; // One dtok per msg to be sent
+ std::deque<rhm::journal::data_tok*> _aio_cmpl_dtok_list; // Dtoks from completed AIOs go here
+ std::deque<rhm::journal::data_tok*> _dd_dtok_list; // Deferred dequeues
+ u_int64_t _tot_dblks;
+ u_int64_t _tot_dsize;
+
+public:
+ msg_producer();
+ ~msg_producer();
+
+ void initialize(const u_int32_t numMsgs, bool auto_dequeue);
+ void initialize(_p_args* args);
+
+ u_int32_t produce(rhm::journal::jcntl& jc, const size_t minMsgSize, const size_t maxMsgSize)
+ throw (rhm::journal::jexception);
+ u_int32_t produce(_p_args* args) throw (rhm::journal::jexception);
+ void aio_callback(u_int32_t num_dtoks);
+
+ const inline u_int64_t get_tot_dblks() const { return _tot_dblks; }
+ const inline u_int64_t get_tot_dsize() const { return _tot_dsize; }
+ inline std::deque<rhm::journal::data_tok*>& aio_dtokl() { return _aio_cmpl_dtok_list; }
+ static void interrupt();
+
+private:
+ void init_msg_buff();
+ void send_deferred_dequeues(rhm::journal::jcntl& jc);
+ void jrnl_flush(rhm::journal::jcntl& jc, u_int32_t num_msgs_sent);
+ void print_dbug(u_int32_t msg_cnt, size_t msg_size, char* _msg_buff, bool show_msg = false) const;
+
+}; // class msg_producer
+
+#endif // ifndef msg_producer_hpp
Copied: store/trunk/cpp/tests/jrnl/prof (from rev 891, store/trunk/cpp/jrnl/test/prof)
===================================================================
--- store/trunk/cpp/tests/jrnl/prof (rev 0)
+++ store/trunk/cpp/tests/jrnl/prof 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+mkdir -p profile
+opcontrol --setup --no-vmlinux --separate=library
+opcontrol --start
+# -- Do stuff here --
+./jtest
+# -- End of stuff --
+opcontrol --stop
+opcontrol --dump
+opcontrol --shutdown
+opreport -l ./jtest
+opannotate --source --output-dir=profile ./jtest
Copied: store/trunk/cpp/tests/jrnl/rtest (from rev 891, store/trunk/cpp/jrnl/test/rtest)
===================================================================
--- store/trunk/cpp/tests/jrnl/rtest (rev 0)
+++ store/trunk/cpp/tests/jrnl/rtest 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,545 @@
+#!/bin/bash
+
+# Copyright (C) 2007 Red Hat Inc.
+#
+# This file is part of Red Hat Messaging.
+#
+# Red Hat Messaging 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.
+
+JDATA_DIR=jdata
+TEST_DIR=test
+TAR_DIR=${TEST_DIR}/rd_test_jrnls
+NULL_FILE=/dev/null
+TEMP_T_FILE=/tmp/t.txt
+TEMP_C_FILE=/tmp/c.txt
+TEMP_V_FILE=/tmp/v.txt
+
+NUM_JFILES=8
+VG_NORM_FILESIZE=11
+
+# Write test
+W_DO_TEST=T
+W_TEST_FILE=${TEST_DIR}/wtests.csv
+W_TEST_START=0
+W_TEST_STOP=81
+W_NITER=5
+
+# Read test
+R_DO_TEST=T
+R_TEST_FILE=${TEST_DIR}/rtests.csv
+R_TEST_START=0
+R_TEST_STOP=45
+R_NITER=5
+
+# Read-Write test
+RW_DO_TEST=T
+RW_TEST_FILE=${TEST_DIR}/rwtests.csv
+RW_TEST_START=0
+RW_TEST_STOP=1
+RW_NITER=1
+
+RM=rm
+RM_DIR="${RM} -rf"
+TEST_PROG="./jtest"
+CHK_PROG="./test/ftest.py"
+VALGRIND="valgrind -q --track-fds=yes --leak-check=full --leak-resolution=high --show-reachable=yes --suppressions=/usr/lib/valgrind/glibc-2.5.supp"
+MAKE="make"
+
+
+function usage
+{
+ echo "Usage:"
+ echo " rtest [w [start [stop [numit]]]] [r [start [stop [numit]]]] [rw start [stop [numit]]]]"
+}
+
+function print_test_args
+{
+ echo "Test summary:"
+ echo -n " jwtest: "
+ if [[ ${W_DO_TEST} == T ]]; then
+ if (( ${W_TEST_START} == ${W_TEST_STOP} )); then
+ echo "${W_TEST_START} x ${W_NITER}"
+ else
+ echo "${W_TEST_START} - ${W_TEST_STOP} x ${W_NITER}"
+ fi
+ else
+ echo "disabled"
+ fi
+ echo -n " jrtest: "
+ if [[ ${R_DO_TEST} == T ]]; then
+ if (( ${R_TEST_START} == ${R_TEST_STOP} )); then
+ echo "${R_TEST_START} x ${R_NITER}"
+ else
+ echo "${R_TEST_START} - ${R_TEST_STOP} x ${R_NITER}"
+ fi
+ else
+ echo "disabled"
+ fi
+ echo -n " jrwtest: "
+ if [[ ${RW_DO_TEST} == T ]]; then
+ if (( ${RW_TEST_START} == ${RW_TEST_STOP} )); then
+ echo "${RW_TEST_START} x ${RW_NITER}"
+ else
+ echo "${RW_TEST_START} - ${RW_TEST_STOP} x ${RW_NITER}"
+ fi
+ else
+ echo "disabled"
+ fi
+}
+
+function assign_test_args
+{
+ if (( $# < 1 )); then
+ echo "assign_test_args args!"
+ return -1
+ fi
+ tt=$1
+ tstart=$2
+ tstop=$3
+ iter=$4
+ case ${tt} in
+ r)
+ if [[ -n ${tstart} ]]; then
+ R_TEST_START=${tstart}
+ if [[ -n ${tstop} ]]; then
+ R_TEST_STOP=${tstop}
+ if [[ -n ${iter} ]]; then
+ R_NITER=${iter}
+ fi
+ else
+ R_TEST_STOP=${tstart}
+ fi
+ fi
+ ;;
+ w)
+ if [[ -n ${tstart} ]]; then
+ W_TEST_START=${tstart}
+ if [[ -n ${tstop} ]]; then
+ W_TEST_STOP=${tstop}
+ if [[ -n ${iter} ]]; then
+ W_NITER=${iter}
+ fi
+ else
+ W_TEST_STOP=${tstart}
+ fi
+ fi
+ ;;
+ rw)
+ if [[ -n ${tstart} ]]; then
+ RW_TEST_START=${tstart}
+ if [[ -n ${tstop} ]]; then
+ RW_TEST_STOP=${tstop}
+ if [[ -n ${iter} ]]; then
+ RW_NITER=${iter}
+ fi
+ else
+ RW_TEST_STOP=${tstart}
+ fi
+ fi
+ ;;
+ esac
+}
+
+function handle_args
+{
+ # Modify test start/stop from params
+ # Format: [w [start [stop [numit]]]] [r [start [stop [numit]]]] [rw start [stop [numit]]]]
+ if (( $# >= 1 )); then
+ W_DO_TEST=F
+ R_DO_TEST=F
+ RW_DO_TEST=F
+
+ for p in $*; do
+ case $p in
+ w)
+ if [[ ${W_DO_TEST} == T ]]; then
+ echo "Error: Parameter w already set: \"$@\""
+ usage
+ exit
+ fi
+ W_DO_TEST=T
+ if [[ -n ${tt} ]]; then
+ assign_test_args ${tt} ${tstart} ${tstop} ${iter}
+ unset tt tstart tstop iter
+ fi
+ local tt=w
+ ;;
+ r)
+ if [[ ${R_DO_TEST} == T ]]; then
+ echo "Error: Parameter r already set: \"$@\""
+ usage
+ exit
+ fi
+ R_DO_TEST=T
+ if [[ -n ${tt} ]]; then
+ assign_test_args ${tt} ${tstart} ${tstop} ${iter}
+ unset tt tstart tstop iter
+ fi
+ local tt=r
+ ;;
+ rw)
+ if [[ ${RW_DO_TEST} == T ]]; then
+ echo "Error: Parameter rw already set: \"$@\""
+ usage
+ exit
+ fi
+ RW_DO_TEST=T
+ if [[ -n ${tt} ]]; then
+ assign_test_args ${tt} ${tstart} ${tstop} ${iter}
+ unset tt tstart tstop iter
+ fi
+ local tt=rw
+ ;;
+ *)
+ if [[ ${tt} == w ]]; then
+ if [[ -z ${tstart} ]]; then
+ local tstart=$p
+ elif [[ -z ${tstop} ]]; then
+ local tstop=$p
+ elif [[ -z ${iter} ]]; then
+ local iter=$p
+ else
+ echo "Error: Too many params for ${tt}: \"$@\""
+ usage
+ exit
+ fi
+ elif [[ ${tt} == r ]]; then
+ if [[ -z ${tstart} ]]; then
+ local tstart=$p
+ elif [[ -z ${tstop} ]]; then
+ local tstop=$p
+ elif [[ -z ${iter} ]]; then
+ local iter=$p
+ else
+ echo "Error: Too many params for ${tt}: \"$@\""
+ usage
+ exit
+ fi
+ elif [[ ${tt} == rw ]]; then
+ if [[ -z ${tstart} ]]; then
+ local tstart=$p
+ elif [[ -z ${tstop} ]]; then
+ local tstop=$p
+ elif [[ -z ${iter} ]]; then
+ local iter=$p
+ else
+ echo "Error: Too many params for ${tt}: \"$@\""
+ usage
+ exit
+ fi
+ else
+ echo "Error: bad parameters - no test type set: \"$@\""
+ usage
+ exit
+ fi
+ ;;
+ esac
+ done
+ if [[ -n ${tt} ]]; then
+ assign_test_args ${tt} ${tstart} ${tstop} ${iter}
+ fi
+ fi
+ print_test_args
+}
+
+function get_filename
+{
+ if (( $# != 3 )); then
+ echo "get_filename args!"
+ return -1
+ fi
+ local prefix=$1
+ local file_num=$2
+ local suffix=$3
+
+ if (( file_num < 10 )); then
+ local num="000${file_num}"
+ elif (( file_num < 100 )); then
+ local num="00${file_num}"
+ elif (( file_num < 1000 )); then
+ local num="0${file_num}"
+ else
+ local num="${file_num}"
+ fi
+ FILENAME=${prefix}${num}${suffix}
+ return 0
+}
+
+function build
+{
+ if (( $# != 1 )); then
+ echo "build args!"
+ return -1
+ fi
+ local build_target=$1
+
+ # Remove all previous data and build
+ echo -n "Clearing previous build and test files..."
+ ${MAKE} clean-all
+ echo " ok"
+
+ # Make for write pipeline tests
+ echo "Making ${build_target} ..."
+ ${MAKE} ${build_target}
+ local ret=$?
+ if [[ ${ret} -ne 0 || ! -x ${TEST_PROG} ]]; then
+ echo "Sorry, make ${build_target} failed; tests aborted."
+ return 1
+ fi
+ return 0
+}
+
+function run_test
+{
+ if (( $# != 4 )); then
+ echo "run_test args!"
+ return -1
+ fi
+ local test_name=$1
+ local test_num=$2
+ local it_num=$3
+ local test_file=$4
+
+ if (( (it_num - 1) % 10 == 0 )); then
+ echo -n " "
+ fi
+
+ # Run test
+ echo -n "."
+ ${TEST_PROG} ${test_file} ${test_num} > ${TEMP_T_FILE}
+ local ret=$?
+ if (( ${ret} != 0 )); then
+ echo "${TEST_PROG} ${test_file} ${test_num} returned ${ret}; exiting."
+ echo
+ cat ${TEMP_T_FILE}
+ return 2
+ fi
+
+ # Analyze journal written by test
+ if [[ ${test_name} != jrtest ]]; then
+ echo -n ":"
+ ${CHK_PROG} ${test_file} ${test_num} > ${TEMP_C_FILE}
+ local ret=$?
+ if (( $ret != 0 )); then
+ echo "${CHK_PROG} ${NUM_RECS[${test_num}]} ${REC_SIZE[${test_num}]} returned ${ret}; exiting."
+ echo
+ cat ${TEMP_C_FILE}
+ return 3
+ fi
+ fi
+ return 0
+}
+
+function valgrind_memchk
+{
+ if (( $# != 2 )); then
+ echo "valgrind_memchk args!"
+ return -1
+ fi
+ local test_file=$1
+ local test_num=$2
+
+ # Perform valgrind test (memory leak check)
+ echo -n " *"
+ ${VALGRIND} ${TEST_PROG} ${test_file} ${test_num} > ${NULL_FILE} 2> ${TEMP_V_FILE}
+ local ret=$?
+ if (( ${ret} != 0 )); then
+ echo "${VALGRIND} ${TEST_PROG} ${test_file} ${test_num} returned ${ret}; exiting."
+ echo
+ cat ${TEMP_V_FILE}
+ return 4
+ fi
+ lc=`wc -l < ${TEMP_V_FILE}`
+ if (( ${lc} != ${VG_NORM_FILESIZE} )); then
+ echo "${VALGRIND} ${TEST_PROG} -t ${test_num} exposed errors; exiting."
+ echo
+ cat ${TEMP_V_FILE}
+ return 5
+ fi
+ return 0
+}
+
+function create_rd_jrnls
+{
+ if (( $# != 3 )); then
+ echo "create_rd_jrnls args!"
+ return -1
+ fi
+ local test_file=$1
+ local test_start=$2
+ local test_stop=$3
+
+ # To generate journals for reading, we must first compile in write mode
+ build jwtest
+
+ if [[ -d ${TAR_DIR} ]]; then
+ rm -rf ${TAR_DIR}/*
+ else
+ mkdir -p ${TAR_DIR}
+ fi
+
+ # Create journal file name list
+ get_filename "test." 0 ".jdat"
+ local jfiles=${FILENAME}
+ for (( f=1; f<${NUM_JFILES}; f++ )); do
+ get_filename "test." $f ".jdat"
+ local jfiles=${jfiles}" "${FILENAME}
+ done
+
+ echo -n "Creating test journal archives: "
+ for (( f=${test_start}; f<=${test_stop}; f++ )); do
+ ${MAKE} clean-jdata
+ run_test jrtest $f 0 ${test_file}
+ local ret=$?
+ if (( ${ret} != 0 )); then
+ return ${ret}
+ fi
+ get_filename "t" $f ".tar.gz"
+ tar -C ${JDATA_DIR} -czf "${TAR_DIR}/${FILENAME}" ${jfiles}
+ local ret=$?
+ if (( ${ret} != 0 )); then
+ return ${ret}
+ fi
+ done
+ echo " ok"
+ return 0
+}
+
+function prepare_rd_jrnl
+{
+ if (( $# != 1 )); then
+ echo "prepare_rd_jrnl args!"
+ return -1
+ fi
+ local test_num=$1
+
+ get_filename "t" ${test_num} ".tar.gz"
+
+ if [[ -d ${JDATA_DIR} ]]; then
+ rm -rf ${JDATA_DIR}/*
+ else
+ mkdir -p ${JDATA_DIR}
+ fi
+ tar -C ${JDATA_DIR} -xzf "${TAR_DIR}/${FILENAME}"
+ # returns with tar return code
+}
+
+function run_tests
+{
+ if (( $# != 5 )); then
+ echo "run_tests args!"
+ return -1
+ fi
+ local test_name=$1
+ local test_file=$2
+ local test_start=$3
+ local test_stop=$4
+ local test_iterations=$5
+
+ for (( t=${test_start}; t<=${test_stop}; t++ )); do
+ echo -n "Test $t: "
+
+ # Get journal ready for read tests
+ if [[ ${test_name} == jrtest ]]; then
+ prepare_rd_jrnl $t
+ fi
+
+ for (( i=1; i<=${test_iterations}; i++ )); do
+ run_test ${test_name} $t $i ${test_file}
+ local ret=$?
+ if (( ${ret} != 0 )); then
+ return ${ret}
+ fi
+ done
+
+ valgrind_memchk ${test_file} $t
+ local ret=$?
+ if (( ${ret} != 0 )); then
+ return ${ret}
+ fi
+
+ # Remove journals accumulated during test
+ echo -n " ~"
+ ${RM_DIR} ${JDATA_DIR}/*
+ echo " ok"
+ done
+ return 0
+}
+
+function do_test
+{
+ if (( $# != 5 )); then
+ echo "do_test args!"
+ exit -1
+ fi
+ local test_name=$1
+ local test_file=$2
+ local test_start=$3
+ local test_stop=$4
+ local test_iterations=$5
+
+ echo
+ echo "===== TEST: ${test_name} ====="
+
+ # For read-only tests, first generate and archive journals to read using a write-only build
+ if [[ $test_name == jrtest ]]; then
+ create_rd_jrnls ${test_file} ${test_start} ${test_stop}
+ ret=$?
+ if (( ${ret} != 0 )); then
+ exit ${ret}
+ fi
+ fi
+
+ build ${test_name}
+ ret=$?
+ if (( ${ret} != 0 )); then
+ exit ${ret}
+ fi
+ echo
+
+ run_tests ${test_name} ${test_file} ${test_start} ${test_stop} ${test_iterations}
+ ret=$?
+ if (( ${ret} != 0 )); then
+ exit ${ret}
+ fi
+}
+
+function cleanup
+{
+ # Clean up temp files
+ ${RM} -f ${TEMP_T_FILE}
+ ${RM} -f ${TEMP_C_FILE}
+ ${RM} -f ${TEMP_V_FILE}
+ return 0
+}
+
+
+#Main program starts here
+
+handle_args "$@"
+if [[ ${W_DO_TEST} == T ]]; then
+ do_test jwtest ${W_TEST_FILE} ${W_TEST_START} ${W_TEST_STOP} ${W_NITER}
+fi
+if [[ ${R_DO_TEST} == T ]]; then
+ do_test jrtest ${R_TEST_FILE} ${R_TEST_START} ${R_TEST_STOP} ${R_NITER}
+fi
+if [[ ${RW_DO_TEST} == T ]]; then
+ do_test jrwtest ${RW_TEST_FILE} ${RW_TEST_START} ${RW_TEST_STOP} ${RW_NITER}
+fi
+cleanup
+
Copied: store/trunk/cpp/tests/jrnl/rtests.csv (from rev 894, store/trunk/cpp/jrnl/test/rtests.csv)
===================================================================
--- store/trunk/cpp/tests/jrnl/rtests.csv (rev 0)
+++ store/trunk/cpp/tests/jrnl/rtests.csv 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,72 @@
+"Initialize only",,,,,,
+0,0,0,0,FALSE,,"No messages"
+,,,,,,
+"Within first block, page, file",,,,,,
+1,1,10,10,FALSE,,"10-byte message"
+2,10,10,10,FALSE,,"10-byte message"
+3,1,10,10,TRUE,,"10-byte message"
+4,10,10,10,TRUE,,"10-byte message"
+,,,,,,
+"Transition from one d-block to two per message",,,,,,
+5,10,92,92,FALSE,,"1 dblk exact fit"
+6,10,93,93,FALSE,,"1 dblk + 1 byte"
+7,10,92,92,TRUE,,"1 dblk exact fit"
+8,10,93,93,TRUE,,"1 dblk + 1 byte"
+,,,,,,
+"Transition from one s-block to two per message",,,,,,
+9,10,476,476,FALSE,,"1 sblk exact fit"
+10,10,477,477,FALSE,,"1 sblk + 1 byte"
+11,10,476,476,TRUE,,"1 sblk exact fit"
+12,10,477,477,TRUE,,"1 sblk + 1 byte"
+,,,,,,
+"Transition from first page to second",,,,,,
+13,8,8156,8156,FALSE,,"8 * 1/8 page; Total = 1 page exact fit"
+14,9,8156,8156,FALSE,,"9 * 1/8 page"
+15,8,8157,8157,FALSE,,"8 * (1/8 page + 1 byte)"
+16,8,8028,8028,TRUE,,"8 * (1/8 page – 1 dblk for deq record); Total = 1 page exact fit with deqs"
+17,9,8028,8028,TRUE,,"9 * (1/8 page – 1 dblk for deq record)"
+18,8,8029,8029,TRUE,,"8 * (1/8 page – 1 dblk for deq record + 1 byte)"
+,,,,,,
+"Page cache rollover (from last page back to page 0) - no dequeues as exact sizes are needed and dequeues are non-deterministic",,,,,,
+19,16,65500,65500,FALSE,,"16 * (1 page exact fit); Total = entire cache exactly"
+20,17,65500,65500,FALSE,,"17 * (1 page exact fit); Total = entire cache + reuse of 1 page"
+21,11,98268,98268,FALSE,,"11 * 1.5 pages"
+22,11,98140,98140,TRUE,,"11 * (1.5 pages including 1 sblk for deq record)"
+,,,,,,
+"File transition (from file 0000 to 0001) - no dequeues as exact sizes are needed and dequeues are non-deterministic",,,,,,
+23,24,65500,65500,FALSE,,"24 * (1 page exact fit); Total = entire file exactly"
+24,25,65500,65500,FALSE,,"25 * (1 page exact fit); Total = entire file + 1 page"
+25,10,163804,163804,FALSE,,"10 * (2.5 pages); Total = entire file + 2 pages"
+26,10,163676,163676,TRUE,,"10 * (2.5 pages including 1 sblk for deq record); Total = entire file + 2 pages"
+,,,,,,
+"File rollover (from file 0007 to 0000) - RHM_WRONLY req'd for auto-dequeue == FALSE",,,,,,
+27,16,786396,786396,FALSE,,"16 * (12 pages = ½ file); Total = 8 files exactly"
+,,,,,,
+"Multi-page messages (large messages) - tests various paths in encoder; no dequeues required to test this functionality.",,,,,,
+28,16,65500,65500,FALSE,,"16 * (1 page exact fit)"
+29,16,65501,65501,FALSE,,"16 * (1 page + 1 byte): tail split"
+30,16,65511,65511,FALSE,,"16 * (1 page + 11 bytes): tail split"
+31,16,65512,65512,FALSE,,"16 * (1 page + 12 bytes): tail separated exactly"
+32,16,65513,65513,FALSE,,"16 * (1 page + 13 bytes): data split"
+33,16,131036,131036,FALSE,,"16 * (2 pages exact fit)"
+34,16,131037,131037,FALSE,,"16 * (2 pages + 1 byte): tail split"
+35,16,131047,131047,FALSE,,"16 * (2 pages + 11 bytes): tail split"
+36,16,131048,131048,FALSE,,"16 * (2 pages + 12 bytes): tail separated exactly"
+37,16,131049,131049,FALSE,,"16 * (2 pages + 13 bytes) data split"
+38,16,262108,262108,FALSE,,"16 * (4 pages exact fit)"
+39,16,262109,262109,FALSE,,"16 * (4 pages + 1 byte: tail split)"
+40,16,262119,262119,FALSE,,"16 * (4 pages + 1 byte: tail split)"
+41,16,262120,262120,FALSE,,"16 * (4 pages + 12 bytes: tail separated)"
+42,16,262121,262121,FALSE,,"16 * (4 pages + 13 bytes: data split)"
+43,16,229340,229340,FALSE,,"16 * (3.5 pages)"
+44,16,229341,229341,FALSE,,"16 * (3.5 pages + 1 byte)"
+,,,,,,
+"These set up journals for circular tests (repeatedly reading same journal) Make sure value testing is off!",,,,,,
+45,98304,0,92,FALSE,,"1 dblk no dequeues"
+46,49152,0,92,TRUE,,"1 dblk with dequeues"
+47,49152,0,220,FALSE,,"2 dblk no dequeues"
+48,24576,0,220,TRUE,,"2 dblk with dequeues"
+49,32768,220,220,TRUE,,"2 dblk fixed with dequeues"
+,,,,,,
+"Circular tests",,,,,,
+50,10000000,0,0,FALSE,,"Read 10,000,000 messages from one of the circular test journals above"
Added: store/trunk/cpp/tests/jrnl/run-journal-tests
===================================================================
--- store/trunk/cpp/tests/jrnl/run-journal-tests (rev 0)
+++ store/trunk/cpp/tests/jrnl/run-journal-tests 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. ../setup
+
+fail=0
+
+LD_PRELOAD=$pwd/.libs/libdlclose_noop.so DllPlugInTester -c -b $pwd/.libs/*Test.so || fail=1
+
+exit $fail
Property changes on: store/trunk/cpp/tests/jrnl/run-journal-tests
___________________________________________________________________
Name: svn:executable
+ *
Copied: store/trunk/cpp/tests/jrnl/rwtests.csv (from rev 891, store/trunk/cpp/jrnl/test/rwtests.csv)
===================================================================
--- store/trunk/cpp/tests/jrnl/rwtests.csv (rev 0)
+++ store/trunk/cpp/tests/jrnl/rwtests.csv 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,58 @@
+"Initialize only",,,,,,
+0,0,0,0,FALSE,,"No messages"
+,,,,,,
+"Within first block, page, file",,,,,,
+1,1,10,10,FALSE,,"10-byte message"
+2,10,10,10,FALSE,,"10-byte message"
+3,1,10,10,TRUE,,"10-byte message"
+4,10,10,10,TRUE,,"10-byte message"
+,,,,,,
+"Transition from one d-block to two per message",,,,,,
+5,10,92,92,FALSE,,"1 dblk exact fit"
+6,10,93,93,FALSE,,"1 dblk + 1 byte"
+7,10,92,92,TRUE,,"1 dblk exact fit"
+8,10,93,93,TRUE,,"1 dblk + 1 byte"
+,,,,,,
+"Transition from one s-block to two per message",,,,,,
+9,10,476,476,FALSE,,"1 sblk exact fit"
+10,10,477,477,FALSE,,"1 sblk + 1 byte"
+11,10,476,476,TRUE,,"1 sblk exact fit"
+12,10,477,477,TRUE,,"1 sblk + 1 byte"
+,,,,,,
+"Transition from first page to second",,,,,,
+13,8,8156,8156,FALSE,,"8 * 1/8 page; Total = 1 page exact fit"
+14,9,8156,8156,FALSE,,"9 * 1/8 page"
+15,8,8157,8157,FALSE,,"8 * (1/8 page + 1 byte)"
+16,8,8028,8028,TRUE,,"8 * (1/8 page - 1 dblk for deq record); Total = 1 page exact fit with deqs"
+17,9,8028,8028,TRUE,,"9 * (1/8 page - 1 dblk for deq record)"
+18,8,8029,8029,TRUE,,"8 * (1/8 page - 1 dblk for deq record + 1 byte)"
+,,,,,,
+"Multi-page messages (large messages) - tests various paths in encoder; no dequeues required to test this functionality.",,,,,,
+19,2,65500,65500,FALSE,,"2 * (1 page exact fit)"
+20,2,65501,65501,FALSE,,"2 * (1 page + 1 byte): tail split"
+21,2,65512,65512,FALSE,,"2 * (1 page + 12 bytes): tail separated exactly"
+22,2,65513,65513,FALSE,,"2 * (1 page + 13 bytes): data split"
+23,2,131036,131036,FALSE,,"2 * (2 pages exact fit)"
+24,2,131037,131037,FALSE,,"2 * (2 pages + 1 byte): tail split"
+25,2,131048,131048,FALSE,,"2 * (2 pages + 12 bytes): tail separated exactly"
+26,2,131049,131049,FALSE,,"2 * (2 pages + 13 bytes) data split"
+27,1,262108,262108,FALSE,,"4 pages exact fit"
+28,1,262109,262109,FALSE,,"4 pages + 1 byte: tail split"
+29,1,262120,262120,FALSE,,"4 pages + 12 bytes: tail separated"
+30,1,262121,262121,FALSE,,"4 pages + 13 bytes: data split"
+31,2,229340,229340,FALSE,,"2 * 3.5 pages; Total = 7 pages"
+,,,,,,
+"Page cache rollover (from page 32 back to page 0) - no dequeues as exact sizes are needed and dequeues are non-deterministic",,,,,,
+32,32,65500,65500,FALSE,,"32 * (1 page exact fit); Total = entire cache exactly"
+33,33,65500,65500,FALSE,,"33 * (1 page exact fit); Total = entire cache + reuse of 1 page"
+34,22,98268,98268,FALSE,,"22 * 1.5 pages"
+35,22,98140,98140,TRUE,,"22 * (1.5 pages including 1 sblk for deq record)"
+,,,,,,
+"File transition (from file 0000 to 0001) - no dequeues as exact sizes are needed and dequeues are non-deterministic",,,,,,
+36,48,65500,65500,FALSE,,"48 * (1 page exact fit); Total = entire file exactly"
+37,49,65500,65500,FALSE,,"49 * (1 page exact fit); Total = entire file + 1 page"
+38,20,163804,163804,FALSE,,"20 * (2.5 pages); Total = entire file + 2 pages"
+39,20,163676,163676,TRUE,,"20 * (2.5 pages including 1 sblk for deq record); Total = entire file + 2 pages"
+,,,,,,
+"File rollover (from file 0007 to 0000) - RHM_WRONLY req'd for auto-dequeue == FALSE",,,,,,
+40,16,786396,786396,FALSE,,"16 * (12 pages = ? file); Total = 8 files exactly"
Copied: store/trunk/cpp/tests/jrnl/tests.ods (from rev 894, store/trunk/cpp/jrnl/test/tests.ods)
===================================================================
(Binary files differ)
Copied: store/trunk/cpp/tests/jrnl/wtests.csv (from rev 891, store/trunk/cpp/jrnl/test/wtests.csv)
===================================================================
--- store/trunk/cpp/tests/jrnl/wtests.csv (rev 0)
+++ store/trunk/cpp/tests/jrnl/wtests.csv 2007-08-30 13:40:45 UTC (rev 898)
@@ -0,0 +1,107 @@
+"Initialize only",,,,,,
+0,0,0,0,FALSE,,"No messages"
+,,,,,,
+"Within first block, page, file",,,,,,
+1,1,10,10,FALSE,,"10-byte message"
+2,10,10,10,FALSE,,"10-byte message"
+3,1,10,10,TRUE,,"10-byte message"
+4,10,10,10,TRUE,,"10-byte message"
+,,,,,,
+"Transition from one d-block to two per message",,,,,,
+5,10,92,92,FALSE,,"1 dblk exact fit"
+6,10,93,93,FALSE,,"1 dblk + 1 byte"
+7,10,92,92,TRUE,,"1 dblk exact fit"
+8,10,93,93,TRUE,,"1 dblk + 1 byte"
+,,,,,,
+"Transition from one s-block to two per message",,,,,,
+9,10,476,476,FALSE,,"1 sblk exact fit"
+10,10,477,477,FALSE,,"1 sblk + 1 byte"
+11,10,476,476,TRUE,,"1 sblk exact fit"
+12,10,477,477,TRUE,,"1 sblk + 1 byte"
+,,,,,,
+"Transition from first page to second",,,,,,
+13,8,4060,4060,FALSE,,"8 * 1/8 page; Total = 1 page exact fit"
+14,9,4060,4060,FALSE,,"9 * 1/8 page"
+15,8,4061,4061,FALSE,,"8 * (1/8 page + 1 byte)"
+16,8,3932,3932,TRUE,,"8 * (1/8 page - 1 dblk for deq record); Total = 1 page exact fit with deqs"
+17,9,3932,3932,TRUE,,"9 * (1/8 page - 1 dblk for deq record)"
+18,8,3933,3933,TRUE,,"8 * (1/8 page - 1 dblk for deq record + 1 byte)"
+,,,,,,
+"Page cache rollover (from page 32 back to page 0) - no dequeues as exact sizes are needed and dequeues are non-deterministic",,,,,,
+19,32,32732,32732,FALSE,,"32 * (1 page exact fit); Total = entire cache exactly"
+20,33,32732,32732,FALSE,,"33 * (1 page exact fit); Total = entire cache + reuse of 1 page"
+21,22,49116,49116,FALSE,,"22 * 1.5 pages"
+22,22,48988,48988,TRUE,,"22 * (1.5 pages including 1 sblk for deq record)"
+,,,,,,
+"File transition (from file 0000 to 0001) - no dequeues as exact sizes are needed and dequeues are non-deterministic",,,,,,
+23,48,32732,32732,FALSE,,"48 * (1 page exact fit); Total = entire file exactly"
+24,49,32732,32732,FALSE,,"49 * (1 page exact fit); Total = entire file + 1 page"
+25,20,81884,81884,FALSE,,"20 * (2.5 pages); Total = entire file + 2 pages"
+26,20,81756,81756,TRUE,,"20 * (2.5 pages including 1 sblk for deq record); Total = entire file + 2 pages"
+,,,,,,
+"File rollover (from file 0007 to 0000) - RHM_WRONLY req'd for auto-dequeue == FALSE",,,,,,
+27,16,786396,786396,FALSE,,"16 * (24 pages = ½ file); Total = 8 files exactly"
+28,17,786396,786396,FALSE,,"17 * (24 pages = ½ file); Total = 8 files + file 0 overwritten by ½ file"
+29,16,786397,786397,FALSE,,"16 * (24 pages + 1 byte); Total = 8 files + file 0 overwritten by 16 sblks"
+30,32,786396,786396,FALSE,,"32 * (24 pages = ½ file); Total = 16 files exactly, all files overwritten once"
+31,33,786396,786396,FALSE,,"33 * (24 pages = ½ file); Total = 16 ½ files, all files overwritten once + file 0 overwritten again by ½ file"
+32,32,786397,786397,FALSE,,"32 * (24 pages + 1 byte); All files overwritten once + file 0 overwritten again by 32 sblks"
+,,,,,,
+"Multi-page messages (large messages) - tests various paths in encoder; no dequeues required to test this functionality.",,,,,,
+33,16,32732,32732,FALSE,,"16 * (1 page exact fit)"
+34,16,32733,32733,FALSE,,"16 * (1 page + 1 byte): tail split"
+35,16,32743,32743,FALSE,,"16 * (1 page + 11 bytes): tail split"
+36,16,32744,32744,FALSE,,"16 * (1 page + 12 bytes): tail separated exactly"
+37,16,32745,32745,FALSE,,"16 * (1 page + 13 bytes): data split"
+38,16,65500,65500,FALSE,,"16 * (2 pages exact fit)"
+39,16,65501,65501,FALSE,,"16 * (2 pages + 1 byte): tail split"
+40,16,65511,65511,FALSE,,"16 * (2 pages + 11 bytes): tail split"
+41,16,65512,65512,FALSE,,"16 * (2 pages + 12 bytes): tail separated exactly"
+42,16,65513,65513,FALSE,,"16 * (2 pages + 13 bytes) data split"
+43,16,131036,131036,FALSE,,"16 * (4 pages exact fit)"
+44,16,131037,131037,FALSE,,"16 * (4 pages + 1 byte: tail split)"
+45,16,131047,131047,FALSE,,"16 * (4 pages + 1 byte: tail split)"
+46,16,131048,131048,FALSE,,"16 * (4 pages + 12 bytes: tail separated)"
+47,16,131049,131049,FALSE,,"16 * (4 pages + 13 bytes: data split)"
+48,16,114652,114652,FALSE,,"16 * (3.5 pages)"
+49,16,114653,114653,FALSE,,"16 * (3.5 pages + 1 byte)"
+,,,,,,
+"Large (multi-megabyte) messages - RHM_WRONLY req'd for auto-dequeue == FALSE",,,,,,
+50,32,1572828,1572828,FALSE,,"32 * (48 pages = 1 file exactly)"
+51,32,1572829,1572829,FALSE,,"32 * (48 pages + 1 byte)"
+52,32,1605596,1605596,FALSE,,"32 * (49 pages = 1 file + 1 page)"
+53,16,3145692,3145692,FALSE,,"16 * (96 pages = 2 files exactly)"
+54,16,3145693,3145693,FALSE,,"16 * (96 pages + 1 byte)"
+55,16,3178460,3178460,FALSE,,"16 * (97 pages = 2 files + 1 page"
+56,8,6291420,6291420,FALSE,,"8 * (192 pages = 4 files exactly)"
+57,8,6291421,6291421,FALSE,,"8 * (192 pages + 1 byte)"
+58,8,6324188,6324188,FALSE,,"8 * (193 pages = 4 files + 1 page)"
+59,32,1572700,1572700,TRUE,,"32 * (48 pages including 1 sblk for deq record = 1 file exactly)"
+60,32,1572701,1572701,TRUE,,"32 * (48 pages including 1 sblk for deq record + 1 byte)"
+61,32,1605468,1605468,TRUE,,"32 * (49 pages including 1 sblk for deq record = 1 file + 1 page)"
+62,16,3145564,3145564,TRUE,,"16 * (96 pages including 1 sblk for deq record = 2 files exactly)"
+63,16,3145565,3145565,TRUE,,"16 * (96 pages including 1 sblk for deq record + 1 byte)"
+64,16,3178332,3178332,TRUE,,"16 * (97 pages including 1 sblk for deq record = 2 files + 1 page"
+65,8,6291292,6291292,TRUE,,"8 * (192 pages including 1 sblk for deq record = 4 files exactly)"
+66,8,6291293,6291293,TRUE,,"8 * (192 pages including 1 sblk for deq record + 1 byte)"
+67,8,6324060,6324060,TRUE,,"8 * (193 pages including 1 sblk for deq record = 4 files + 1 page)"
+,,,,,,
+"High volume tests of random message lengths - RHM_WRONLY req'd for auto-dequeue == FALSE",,,,,,
+68,5000000,0,92,FALSE,,"1 dblk max"
+69,3000000,0,348,FALSE,,"3 dblks max"
+70,1600000,0,1244,FALSE,,"10 dblks max"
+71,600000,0,3804,FALSE,,"30 dblks max"
+72,200000,0,12764,FALSE,,"100 dblks max"
+73,60000,0,38364,FALSE,,"300 dblks max"
+74,20000,0,127964,FALSE,,"1000 dblks max"
+75,2500000,0,92,TRUE,,"1 dblk max"
+76,1500000,0,348,TRUE,,"3 dblks max"
+77,800000,0,1244,TRUE,,"10 dblks max"
+78,300000,0,3804,TRUE,,"30 dblks max"
+79,100000,0,12768,TRUE,,"100 dblks max"
+80,30000,0,38364,TRUE,,"300 dblks max"
+81,10000,0,127964,TRUE,,"1000 dblks max"
+,,,,,,
+"STANDARD PERFORMANCE BENCHMARK: 10,000,000 writes, data=220b (2 dblks)",,,,,,
+82,10000000,220,220,FALSE,,"2 dblks"
+83,10000000,220,220,TRUE,,"2 dblks"
Modified: store/trunk/cpp/tests/setup
===================================================================
--- store/trunk/cpp/tests/setup 2007-08-28 19:40:03 UTC (rev 897)
+++ store/trunk/cpp/tests/setup 2007-08-30 13:40:45 UTC (rev 898)
@@ -19,6 +19,7 @@
vg_options="
--suppressions=$abs_srcdir/.vg-supp
+ --suppressions=/usr/lib/valgrind/glibc-2.5.supp
--num-callers=25
--demangle=yes
--track-fds=yes
17 years, 4 months
rhmessaging commits: r897 - in store/trunk/cpp: tests and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: gordonsim
Date: 2007-08-28 15:40:03 -0400 (Tue, 28 Aug 2007)
New Revision: 897
Added:
store/trunk/cpp/tests/MessageUtils.h
Modified:
store/trunk/cpp/lib/BdbMessageStore.cpp
store/trunk/cpp/tests/Makefile.am
store/trunk/cpp/tests/OrderingTest.cpp
store/trunk/cpp/tests/SimpleTest.cpp
store/trunk/cpp/tests/TransactionalTest.cpp
store/trunk/cpp/tests/TwoPhaseCommitTest.cpp
store/trunk/cpp/tests/persistence.py
Log:
Updates for change to message class on qpid trunk.
Modified: store/trunk/cpp/lib/BdbMessageStore.cpp
===================================================================
--- store/trunk/cpp/lib/BdbMessageStore.cpp 2007-08-28 19:14:13 UTC (rev 896)
+++ store/trunk/cpp/lib/BdbMessageStore.cpp 2007-08-28 19:40:03 UTC (rev 897)
@@ -23,8 +23,7 @@
#include "BdbMessageStore.h"
#include <qpid/broker/RecoveryManager.h>
-#include <qpid/broker/BrokerMessage.h>
-#include <qpid/broker/BrokerMessageMessage.h>
+#include <qpid/broker/Message.h>
#include <qpid/framing/Buffer.h>
#include <algorithm>
#include <sstream>
Modified: store/trunk/cpp/tests/Makefile.am
===================================================================
--- store/trunk/cpp/tests/Makefile.am 2007-08-28 19:14:13 UTC (rev 896)
+++ store/trunk/cpp/tests/Makefile.am 2007-08-28 19:40:03 UTC (rev 897)
@@ -24,7 +24,7 @@
abs_srcdir=$(abs_srcdir) \
LIBBDBSTORE=$(abs_builddir)/../lib/.libs/libbdbstore.so
-EXTRA_DIST += $(TESTS) test_plugin.h setup .vg-supp
+EXTRA_DIST += $(TESTS) test_plugin.h MessageUtils.h setup .vg-supp
include gen.mk
Added: store/trunk/cpp/tests/MessageUtils.h
===================================================================
--- store/trunk/cpp/tests/MessageUtils.h (rev 0)
+++ store/trunk/cpp/tests/MessageUtils.h 2007-08-28 19:40:03 UTC (rev 897)
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2007 Red Hat Software
+
+ This file is part of Red Hat Messaging.
+
+ Red Hat Messaging 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 file 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 <qpid/broker/Message.h>
+#include <qpid/broker/MessageDelivery.h>
+#include <qpid/framing/AMQFrame.h>
+
+using namespace qpid::broker;
+using namespace qpid::framing;
+
+struct MessageUtils
+{
+ static Message::shared_ptr createMessage(const string& exchange, const string& routingKey,
+ const string& messageId="", uint64_t contentSize = 0)
+ {
+ Message::shared_ptr msg(new Message());
+
+ AMQFrame method(0, MessageTransferBody(ProtocolVersion(), 0, exchange, 0, 0));
+ AMQFrame header(0, AMQHeaderBody());
+
+ msg->getFrames().append(method);
+ msg->getFrames().append(header);
+ MessageProperties* props = msg->getFrames().getHeaders()->get<MessageProperties>(true);
+ props->setContentLength(contentSize);
+ props->setMessageId(messageId);
+ msg->getFrames().getHeaders()->get<DeliveryProperties>(true)->setRoutingKey(routingKey);
+ return msg;
+ }
+
+ static void addContent(Message::shared_ptr msg, const string& data)
+ {
+ AMQFrame content(0, AMQContentBody(data));
+ msg->getFrames().append(content);
+ }
+};
Property changes on: store/trunk/cpp/tests/MessageUtils.h
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: store/trunk/cpp/tests/OrderingTest.cpp
===================================================================
--- store/trunk/cpp/tests/OrderingTest.cpp 2007-08-28 19:14:13 UTC (rev 896)
+++ store/trunk/cpp/tests/OrderingTest.cpp 2007-08-28 19:40:03 UTC (rev 897)
@@ -22,9 +22,10 @@
*/
#include "BdbMessageStore.h"
+#include "MessageUtils.h"
#include <qpid/framing/AMQMethodBody.h>
#include <qpid/framing/AMQHeaderBody.h>
-#include <qpid/broker/BrokerMessage.h>
+#include <qpid/broker/Message.h>
#include <qpid/broker/BrokerQueue.h>
#include <qpid/broker/RecoveryManagerImpl.h>
#include "test_plugin.h"
@@ -97,12 +98,8 @@
string messageId(id.str());
ids.push(messageId);
- Message::shared_ptr msg = Message::shared_ptr(new BasicMessage(0, "exchange", "routing_key", false, false));
- AMQHeaderBody header(BASIC);
- header.setContentSize(0);
- msg->setHeader(&header);
- msg->getHeaderProperties()->setMessageId(messageId);
- msg->getHeaderProperties()->setDeliveryMode(PERSISTENT);
+ Message::shared_ptr msg = MessageUtils::createMessage("exchange", "routing_key", messageId, 0);
+ msg->getProperties<DeliveryProperties>()->setDeliveryMode(PERSISTENT);
queue->deliver(msg);
}
@@ -114,7 +111,7 @@
queue->dequeue(0, msg);
string expected = ids.front();
ids.pop();
- CPPUNIT_ASSERT_EQUAL(expected, msg->getHeaderProperties()->getMessageId());
+ CPPUNIT_ASSERT_EQUAL(expected, msg->getProperties<MessageProperties>()->getMessageId());
return true;
} else {
return false;
Modified: store/trunk/cpp/tests/SimpleTest.cpp
===================================================================
--- store/trunk/cpp/tests/SimpleTest.cpp 2007-08-28 19:14:13 UTC (rev 896)
+++ store/trunk/cpp/tests/SimpleTest.cpp 2007-08-28 19:40:03 UTC (rev 897)
@@ -23,14 +23,14 @@
#include "BdbMessageStore.h"
#include "test_plugin.h"
+#include "MessageUtils.h"
#include <qpid/Exception.h>
#include <qpid/framing/AMQP_HighestVersion.h>
#include <qpid/framing/AMQFrame.h>
#include <qpid/framing/AMQHeaderBody.h>
#include <qpid/framing/AMQMethodBody.h>
#include <qpid/framing/ChannelAdapter.h>
-#include <qpid/broker/BrokerMessage.h>
-#include <qpid/broker/BrokerMessageMessage.h>
+#include <qpid/broker/Message.h>
#include <qpid/broker/BrokerQueue.h>
#include <qpid/broker/DirectExchange.h>
#include <qpid/broker/RecoveryManagerImpl.h>
@@ -79,7 +79,6 @@
CPPUNIT_TEST(testStaging);
CPPUNIT_TEST(testDestroyStagedMessage);
CPPUNIT_TEST(testDestroyEnqueuedMessage);
- CPPUNIT_TEST(testEnqueueMessageMessage);
CPPUNIT_TEST(testExchangeCreateAndDestroy);
CPPUNIT_TEST(testExchangeBindAndUnbind);
CPPUNIT_TEST(testExchangeImplicitUnbind);
@@ -199,18 +198,14 @@
FieldTable settings;
queue.create(settings);
- Message::shared_ptr msg = Message::shared_ptr(newBasicMessage(0, exchange, routingKey, false, false));
- AMQHeaderBody header(BASIC);
- header.setContentSize(14);
- AMQContentBody part1(data1);
- AMQContentBody part2(data2);
- msg->setHeader(&header);
- msg->addContent(&part1);
- msg->addContent(&part2);
+ Message::shared_ptr msg = MessageUtils::createMessage(exchange, routingKey, messageId, 14);
+ MessageUtils::addContent(msg, data1);
+ MessageUtils::addContent(msg, data2);
- msg->getHeaderProperties()->setMessageId(messageId);
- msg->getHeaderProperties()->setDeliveryMode(PERSISTENT);
- msg->getHeaderProperties()->getHeaders().setString("abc", "xyz");
+ msg->getProperties<DeliveryProperties>()->setDeliveryMode(PERSISTENT);
+ FieldTable table;
+ table.setString("abc", "xyz");
+ msg->getProperties<MessageProperties>()->setApplicationHeaders(table);
queue.enqueue(0, msg);
}//db will be closed
@@ -223,16 +218,16 @@
CPPUNIT_ASSERT_EQUAL((u_int32_t) 1, queue->getMessageCount());
Message::shared_ptr msg = queue->dequeue();
- CPPUNIT_ASSERT_EQUAL(exchange, msg->getExchange());
+ CPPUNIT_ASSERT_EQUAL(exchange, msg->getExchangeName());
CPPUNIT_ASSERT_EQUAL(routingKey, msg->getRoutingKey());
- CPPUNIT_ASSERT_EQUAL(messageId, msg->getHeaderProperties()->getMessageId());
- CPPUNIT_ASSERT_EQUAL(PERSISTENT, msg->getHeaderProperties()->getDeliveryMode());
- CPPUNIT_ASSERT_EQUAL(string("xyz"), msg->getHeaderProperties()->getHeaders().getString("abc"));
+ CPPUNIT_ASSERT_EQUAL(messageId, msg->getProperties<MessageProperties>()->getMessageId());
+ CPPUNIT_ASSERT_EQUAL((uint8_t) PERSISTENT, msg->getProperties<DeliveryProperties>()->getDeliveryMode());
+ CPPUNIT_ASSERT_EQUAL(string("xyz"), msg->getProperties<MessageProperties>()->getApplicationHeaders().getString("abc"));
CPPUNIT_ASSERT_EQUAL((u_int64_t) 14, msg->contentSize());
DummyHandler handler;
DummyAdapter adapter(0, &handler, qpid::framing::highestProtocolVersion);
- msg->deliver(adapter, 0, BasicMessage::createConsumeToken("ignore"), 100);
+ MessageDelivery::deliver(msg, adapter, 0, MessageDelivery::getBasicConsumeToken("ignore"), 100);
CPPUNIT_ASSERT_EQUAL((size_t) 3, handler.frames.size());
AMQContentBody* contentBody(dynamic_cast<AMQContentBody*>(handler.frames[2].getBody()));
CPPUNIT_ASSERT(contentBody);
@@ -256,16 +251,10 @@
FieldTable settings;
queue.create(settings);
- Message::shared_ptr msg = Message::shared_ptr(newBasicMessage(0, exchange, routingKey, false, false));
- AMQHeaderBody header(BASIC);
- header.setContentSize(7);
- AMQContentBody content(data);
- msg->setHeader(&header);
- msg->addContent(&content);
+ Message::shared_ptr msg = MessageUtils::createMessage(exchange, routingKey, messageId, 7);
+ MessageUtils::addContent(msg, data);
+ msg->getProperties<DeliveryProperties>()->setDeliveryMode(PERSISTENT);
- msg->getHeaderProperties()->setMessageId(messageId);
- msg->getHeaderProperties()->setDeliveryMode(PERSISTENT);
-
queue.enqueue(0, msg);
queue.dequeue(0, msg);
}//db will be closed
@@ -292,23 +281,22 @@
store.truncate();//make sure it is empty to begin with
//create & stage a message
- Message::shared_ptr msg = Message::shared_ptr(newBasicMessage(0, exchange, routingKey, false, false));
- AMQHeaderBody header(BASIC);
- header.setContentSize(data1.size() + data2.size());
- msg->setHeader(&header);
- msg->getHeaderProperties()->setMessageId(messageId);
- msg->getHeaderProperties()->setDeliveryMode(PERSISTENT);
- msg->getHeaderProperties()->getHeaders().setString("abc", "xyz");
+ Message::shared_ptr msg = MessageUtils::createMessage(exchange, routingKey, messageId, (data1.size() + data2.size()));
+ msg->getProperties<DeliveryProperties>()->setDeliveryMode(PERSISTENT);
+ FieldTable table;
+ table.setString("abc", "xyz");
+ msg->getProperties<MessageProperties>()->setApplicationHeaders(table);
store.stage(*msg);
//append to it
msg->releaseContent(&store);//ensure that data is not held in memory but is appended to disk when added
+ store.appendContent(*msg, data1);
+ store.appendContent(*msg, data2);
- AMQContentBody part1(data1);
- msg->addContent(&part1);
-
- AMQContentBody part2(data2);
- msg->addContent(&part2);
+ //AMQContentBody part1(data1);
+ //msg->addContent(&part1);FIXME
+ //AMQContentBody part2(data2);
+ //msg->addContent(&part2);FIXME
//enqueue it
Queue queue(name, 0, &store, 0);
@@ -319,10 +307,11 @@
//load it (without recovery)
DummyHandler handler;
DummyAdapter adapter(0, &handler, qpid::framing::highestProtocolVersion);
- msg->deliver(adapter, 0, BasicMessage::createConsumeToken("ignore"), 20);//52 chars of data, i.e. 2 chunks of 20 and one of 12
- CPPUNIT_ASSERT_EQUAL((size_t) 5, handler.frames.size());
+ MessageDelivery::deliver(msg, adapter, 0,
+ MessageDelivery::getBasicConsumeToken("ignore"), 20);//52 chars of data, i.e. 2 chunks of 20 and one of 12
+ CPPUNIT_ASSERT(handler.frames.size() > 2);
string loaded;
- for (int i = 2; i < 5; i++) {
+ for (uint i = 2; i < handler.frames.size(); i++) {
AMQContentBody* contentBody(dynamic_cast<AMQContentBody*>(handler.frames[i].getBody()));
CPPUNIT_ASSERT(contentBody);
loaded += contentBody->getData();
@@ -346,22 +335,23 @@
Message::shared_ptr msg = queue->dequeue();
//check headers
- CPPUNIT_ASSERT_EQUAL(exchange, msg->getExchange());
+ CPPUNIT_ASSERT_EQUAL(exchange, msg->getExchangeName());
CPPUNIT_ASSERT_EQUAL(routingKey, msg->getRoutingKey());
- CPPUNIT_ASSERT_EQUAL(messageId, msg->getHeaderProperties()->getMessageId());
- CPPUNIT_ASSERT_EQUAL(PERSISTENT, msg->getHeaderProperties()->getDeliveryMode());
- CPPUNIT_ASSERT_EQUAL(string("xyz"), msg->getHeaderProperties()->getHeaders().getString("abc"));
- CPPUNIT_ASSERT_EQUAL((u_int64_t) (data1.size() + data2.size()), msg->expectedContentSize());
+ CPPUNIT_ASSERT_EQUAL(messageId, msg->getProperties<MessageProperties>()->getMessageId());
+ CPPUNIT_ASSERT_EQUAL((uint8_t) PERSISTENT, msg->getProperties<DeliveryProperties>()->getDeliveryMode());
+ CPPUNIT_ASSERT_EQUAL(string("xyz"), msg->getProperties<MessageProperties>()->getApplicationHeaders().getString("abc"));
+ CPPUNIT_ASSERT_EQUAL((u_int64_t) (data1.size() + data2.size()), msg->getFrames().getHeaders()->getContentLength());
- CPPUNIT_ASSERT_EQUAL((u_int32_t) 0, msg->encodedContentSize());//ensure it is being lazily loaded
+ CPPUNIT_ASSERT_EQUAL((u_int64_t) 0, msg->contentSize());//ensure it is being lazily loaded
//load lazily
DummyHandler handler;
DummyAdapter adapter(0, &handler, qpid::framing::highestProtocolVersion);
- msg->deliver(adapter, 0, BasicMessage::createConsumeToken("ignore"), 20);//52 chars of data, i.e. 2 chunks of 20 and one of 12
- CPPUNIT_ASSERT_EQUAL((size_t) 5, handler.frames.size());
+ MessageDelivery::deliver(msg, adapter, 0, MessageDelivery::getBasicConsumeToken("ignore"), 20);//52 chars of data, i.e. 2 chunks of 20 and one of 12
+
+ CPPUNIT_ASSERT(handler.frames.size() > 2);
string loaded;
- for (int i = 2; i < 5; i++) {
+ for (uint i = 2; i < handler.frames.size(); i++) {
AMQContentBody* contentBody(dynamic_cast<AMQContentBody*>(handler.frames[i].getBody()));
CPPUNIT_ASSERT(contentBody);
loaded += contentBody->getData();
@@ -379,9 +369,8 @@
store.truncate();//make sure it is empty to begin with
const string data("abcdefg");
- std::auto_ptr<Message> msg(createMessage("my_exchange", "my_routing_key", "my_message", data.length()));
- AMQContentBody content(data);
- msg->addContent(&content);
+ Message::shared_ptr msg(MessageUtils::createMessage("my_exchange", "my_routing_key", "my_message", data.length()));
+ MessageUtils::addContent(msg, data);
store.stage(*msg);
store.destroy(*msg);
@@ -400,9 +389,8 @@
store.truncate();//make sure it is empty to begin with
const string data("abcdefg");
- std::auto_ptr<Message> msg(createMessage("my_exchange", "my_routing_key", "my_message", data.length()));
- AMQContentBody content(data);
- msg->addContent(&content);
+ Message::shared_ptr msg(MessageUtils::createMessage("my_exchange", "my_routing_key", "my_message", data.length()));
+ MessageUtils::addContent(msg, data);
Queue queue("my_queue", 0, &store, 0);
store.create(queue);
@@ -419,73 +407,6 @@
}
- void testEnqueueMessageMessage()
- {
- string name("MyDurableQueue");
- string exchange("MyExchange");
- string routingKey("MyRoutingKey");
- string messageId = "MyMessage";
- FieldTable headers;
- headers.setString("abc", "xyz");
- qpid::framing::Content data(INLINE, "abcdefghijklmn");
- {
- BdbMessageStore store;
- store.truncate();//make sure it is empty to begin with
- Queue queue(name, 0, &store, 0);
- FieldTable settings;
- queue.create(settings);
-
- MessageTransferBody body(highestProtocolVersion,
- 0, //ticket,
- exchange, //destination,
- false, //redelivered,
- false, //reject-unroutable
- false, //immediate,
- 0, //ttl,
- 0, //priority,
- 0, //timestamp,
- PERSISTENT, //deliveryMode,
- 0, //expiration,
- exchange, //exchange,
- routingKey, //routingKey,
- messageId, //messageId,
- "", //correlationId,
- "", //replyTo,
- "", //contentType,
- "", //contentEncoding,
- 0, //contentLength,
- "", //type
- "", //userId,
- "", //appId,
- "", //transactionId,
- "", //securityToken,
- headers, //applicationHeaders,
- data //body
- );
- Message::shared_ptr msg = Message::shared_ptr(new MessageMessage(0, &body));
-
-
- queue.enqueue(0, msg);
- }//db will be closed
- {
- BdbMessageStore store;
- QueueRegistry registry(&store);
- recover(store, registry);
- Queue::shared_ptr queue = registry.find(name);
- CPPUNIT_ASSERT(queue);
- CPPUNIT_ASSERT_EQUAL((u_int32_t) 1, queue->getMessageCount());
- Message::shared_ptr base_msg = queue->dequeue();
- MessageMessage::shared_ptr msg = dynamic_pointer_cast<MessageMessage, Message>(base_msg);
- CPPUNIT_ASSERT(msg);
- CPPUNIT_ASSERT_EQUAL(exchange, msg->getTransfer()->getExchange());
- CPPUNIT_ASSERT_EQUAL(routingKey, msg->getTransfer()->getRoutingKey());
- CPPUNIT_ASSERT_EQUAL(messageId, msg->getTransfer()->getMessageId());
- CPPUNIT_ASSERT_EQUAL((u_int8_t) PERSISTENT, msg->getTransfer()->getDeliveryMode());
- CPPUNIT_ASSERT_EQUAL(string("xyz"), msg->getApplicationHeaders().getString("abc"));
- CPPUNIT_ASSERT_EQUAL(data.getValue(), msg->getTransfer()->getBody().getValue());
- }
- }
-
void testExchangeCreateAndDestroy()
{
uint64_t id(0);
@@ -628,21 +549,6 @@
}
}
- Message* createMessage(const string& exchange, const string& routingKey, const string& messageId, u_int64_t contentSize)
- {
- std::auto_ptr<Message> msg(newBasicMessage(0, exchange, routingKey, false, false));
- AMQHeaderBody header(BASIC);
- header.setContentSize(contentSize);
- msg->setHeader(&header);
- msg->getHeaderProperties()->setMessageId(messageId);
- return msg.release();
- }
-
- Message* newBasicMessage(const ConnectionToken* const publisher, const string& exchange, const string& routingKey, bool mandatory, bool immediate)
- {
- return new BasicMessage(publisher, exchange, routingKey, mandatory, immediate);
- }
-
};
// Make this test suite a plugin.
Modified: store/trunk/cpp/tests/TransactionalTest.cpp
===================================================================
--- store/trunk/cpp/tests/TransactionalTest.cpp 2007-08-28 19:14:13 UTC (rev 896)
+++ store/trunk/cpp/tests/TransactionalTest.cpp 2007-08-28 19:40:03 UTC (rev 897)
@@ -22,10 +22,11 @@
*/
#include "BdbMessageStore.h"
+#include "MessageUtils.h"
#include "test_plugin.h"
#include <qpid/framing/AMQHeaderBody.h>
#include <qpid/framing/AMQMethodBody.h>
-#include <qpid/broker/BrokerMessage.h>
+#include <qpid/broker/Message.h>
#include <qpid/broker/BrokerQueue.h>
#include <qpid/broker/RecoveryManagerImpl.h>
#include <iostream>
@@ -100,12 +101,8 @@
queueB->create(settings);
//create message and enqueue it onto first queue:
- Message::shared_ptr msg = Message::shared_ptr(new BasicMessage(0, "exchange", "routing_key", false, false));
- AMQHeaderBody header(BASIC);
- header.setContentSize(0);
- msg->setHeader(&header);
- msg->getHeaderProperties()->setMessageId(messageId);
- msg->getHeaderProperties()->setDeliveryMode(PERSISTENT);
+ Message::shared_ptr msg = MessageUtils::createMessage("exchange", "routing_key", messageId, 0);
+ msg->getProperties<DeliveryProperties>()->setDeliveryMode(PERSISTENT);
queueA->deliver(msg);
}
@@ -146,7 +143,7 @@
CPPUNIT_ASSERT_EQUAL((u_int32_t) 1, y->getMessageCount());
Message::shared_ptr msg = y->dequeue();
CPPUNIT_ASSERT(msg);
- CPPUNIT_ASSERT_EQUAL(messageId, msg->getHeaderProperties()->getMessageId());
+ CPPUNIT_ASSERT_EQUAL(messageId, msg->getProperties<MessageProperties>()->getMessageId());
}
};
Modified: store/trunk/cpp/tests/TwoPhaseCommitTest.cpp
===================================================================
--- store/trunk/cpp/tests/TwoPhaseCommitTest.cpp 2007-08-28 19:14:13 UTC (rev 896)
+++ store/trunk/cpp/tests/TwoPhaseCommitTest.cpp 2007-08-28 19:40:03 UTC (rev 897)
@@ -23,9 +23,10 @@
#include "test_plugin.h"
#include "BdbMessageStore.h"
+#include "MessageUtils.h"
#include <qpid/framing/AMQHeaderBody.h>
#include <qpid/framing/AMQMethodBody.h>
-#include <qpid/broker/BrokerMessage.h>
+#include <qpid/broker/Message.h>
#include <qpid/broker/BrokerQueue.h>
#include <qpid/broker/RecoveryManagerImpl.h>
#include <iostream>
@@ -300,12 +301,8 @@
Message::shared_ptr createMessage(const string& id, const string& exchange="exchange", const string& key="routing_key")
{
- Message::shared_ptr msg = Message::shared_ptr(new BasicMessage(0, exchange, key, false, false));
- AMQHeaderBody header(BASIC);
- header.setContentSize(0);
- msg->setHeader(&header);
- msg->getHeaderProperties()->setMessageId(id);
- msg->getHeaderProperties()->setDeliveryMode(PERSISTENT);
+ Message::shared_ptr msg = MessageUtils::createMessage(exchange, key, id, 0);
+ msg->getProperties<DeliveryProperties>()->setDeliveryMode(PERSISTENT);
return msg;
}
@@ -345,7 +342,7 @@
CPPUNIT_ASSERT_EQUAL((u_int32_t) 1, y->getMessageCount());
Message::shared_ptr msg = y->dequeue();
CPPUNIT_ASSERT(msg);
- CPPUNIT_ASSERT_EQUAL(msgid, msg->getHeaderProperties()->getMessageId());
+ CPPUNIT_ASSERT_EQUAL(msgid, msg->getProperties<MessageProperties>()->getMessageId());
}
void checkA(u_int32_t size, const string& msgid = "<none>")
@@ -355,7 +352,7 @@
if (size > 0) {
Message::shared_ptr msg = queueA->dequeue();
CPPUNIT_ASSERT(msg);
- CPPUNIT_ASSERT_EQUAL(msgid, msg->getHeaderProperties()->getMessageId());
+ CPPUNIT_ASSERT_EQUAL(msgid, msg->getProperties<MessageProperties>()->getMessageId());
}
}
};
Modified: store/trunk/cpp/tests/persistence.py
===================================================================
--- store/trunk/cpp/tests/persistence.py 2007-08-28 19:14:13 UTC (rev 896)
+++ store/trunk/cpp/tests/persistence.py 2007-08-28 19:40:03 UTC (rev 897)
@@ -24,6 +24,7 @@
from getopt import getopt, GetoptError
import qpid.client, qpid.spec, qpid.content, qpid.testlib
from qpid.client import Closed
+from qpid.content import Content
from struct import *
from time import sleep
@@ -37,8 +38,10 @@
channel.queue_bind(queue="queue-a", exchange="amq.direct", routing_key="a")
channel.queue_bind(queue="queue-b", exchange="amq.direct", routing_key="b")
- channel.message_transfer(destination="amq.direct", routing_key="a", message_id="Msg0001", delivery_mode=2, body="A_Message1")
- channel.message_transfer(destination="amq.direct", routing_key="b", message_id="Msg0002", delivery_mode=2, body="B_Message1")
+ channel.message_transfer(destination="amq.direct",
+ content=Content(properties={'routing_key':"a", 'message_id':"Msg0001", 'delivery_mode':2}, body="A_Message1"))
+ channel.message_transfer(destination="amq.direct",
+ content=Content(properties={'routing_key':"b", 'message_id':"Msg0002", 'delivery_mode':2}, body="B_Message1"))
def phase2(self):
@@ -65,7 +68,8 @@
channel.queue_bind(queue="queue-b", exchange="amq.topic", routing_key="abc")
channel.queue_bind(queue="queue-c", exchange="amq.topic", routing_key="abc")
- channel.message_transfer(destination="amq.topic", routing_key="abc", message_id="Msg0003", delivery_mode=2, body="AB_Message2")
+ channel.message_transfer(destination="amq.topic",
+ content=Content(properties={'routing_key':"abc", 'message_id':"Msg0003", 'delivery_mode':2}, body="AB_Message2"))
def phase3(self):
@@ -92,9 +96,15 @@
self.assertEmptyQueue("queue-c")
#note: default bindings must be restored for this to work
- channel.message_transfer(routing_key="queue-a", message_id="Msg0004", delivery_mode=2, body="A_Message3")
- channel.message_transfer(routing_key="queue-a", message_id="Msg0005", delivery_mode=2, body="A_Message4")
- channel.message_transfer(routing_key="queue-a", message_id="Msg0006", delivery_mode=2, body="A_Message5")
+ channel.message_transfer(content=Content(
+ properties={'routing_key':"queue-a", 'message_id':"Msg0004", 'delivery_mode':2},
+ body="A_Message3"))
+ channel.message_transfer(content=Content(
+ properties={'routing_key':"queue-a", 'message_id':"Msg0005", 'delivery_mode':2},
+ body="A_Message4"))
+ channel.message_transfer(content=Content(
+ properties={'routing_key':"queue-a", 'message_id':"Msg0006", 'delivery_mode':2},
+ body="A_Message5"))
channel.tx_commit()
@@ -111,7 +121,9 @@
msg = included.get(timeout=1)
self.assertExpectedContent(msg, "Msg0006", "A_Message5").complete()
- channel.message_transfer(destination="amq.direct", routing_key="queue-b", message_id="Msg0007", delivery_mode=2, body="B_Message3")
+ channel.message_transfer(destination="amq.direct", content=Content(
+ properties={'routing_key':"queue-b", 'message_id':"Msg0007", 'delivery_mode':2},
+ body="B_Message3"))
channel.tx_rollback()
@@ -150,10 +162,18 @@
for q in queues:
channel.queue_declare(queue=q, durable=True)
- channel.message_transfer(routing_key="queue-a1", message_id="MsgA", delivery_mode=2, body="MessageA")
- channel.message_transfer(routing_key="queue-b1", message_id="MsgB", delivery_mode=2, body="MessageB")
- channel.message_transfer(routing_key="queue-c1", message_id="MsgC", delivery_mode=2, body="MessageC")
- channel.message_transfer(routing_key="queue-d1", message_id="MsgD", delivery_mode=2, body="MessageD")
+ channel.message_transfer(content=Content(
+ properties={'routing_key':"queue-a1", 'message_id':"MsgA", 'delivery_mode':2},
+ body="MessageA"))
+ channel.message_transfer(content=Content(
+ properties={'routing_key':"queue-b1", 'message_id':"MsgB", 'delivery_mode':2},
+ body="MessageB"))
+ channel.message_transfer(content=Content(
+ properties={'routing_key':"queue-c1", 'message_id':"MsgC", 'delivery_mode':2},
+ body="MessageC"))
+ channel.message_transfer(content=Content(
+ properties={'routing_key':"queue-d1", 'message_id':"MsgD", 'delivery_mode':2},
+ body="MessageD"))
channel.dtx_demarcation_select()
txa = self.xid('a')
@@ -242,7 +262,8 @@
self.assertEqual(8, self.channel.dtx_demarcation_start(xid=tx).status)
self.channel.message_get(destination="temp-swap", queue=src)
msg = self.client.queue("temp-swap").get(timeout=1)
- self.channel.message_transfer(routing_key=dest, message_id=msg.message_id, delivery_mode=2, body=msg.body)
+ self.channel.message_transfer(content=Content(properties={'routing_key':dest, 'message_id':msg.content['message_id'], 'delivery_mode':2},
+ body=msg.content.body))
msg.complete();
self.assertEqual(8, self.channel.dtx_demarcation_end(xid=tx).status)
@@ -264,8 +285,8 @@
self.assertEqual(method, reply.method.name)
def assertExpectedContent(self, content, id, body):
- self.assertEqual(id, content.message_id)
- self.assertEqual(body, content.body)
+ self.assertEqual(id, content.content['message_id'])
+ self.assertEqual(body, content.content.body)
return content
def assertExpectedGetResult(self, id, body):
17 years, 4 months