Author: kpvdr
Date: 2007-09-25 09:00:25 -0400 (Tue, 25 Sep 2007)
New Revision: 944
Modified:
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jcntl.hpp
store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp
Log:
Further updates to new DTX API in jcntl
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-24 20:16:06 UTC (rev 943)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-25 13:00:25 UTC (rev 944)
@@ -202,39 +202,52 @@
const iores
jcntl::enqueue_data_record(const void* const /*data_buff*/, const size_t
/*tot_data_len*/,
- const size_t /*this_data_len*/, const void* const /*xid_buff*/, const size_t
/*xid_len*/,
- data_tok* /*dtok*/) throw (jexception)
+ const size_t /*this_data_len*/, data_tok* /*dtokp*/, const std::string /*xid*/,
+ const bool /*transient*/) throw (jexception)
{
return RHM_IORES_NOTIMPL;
}
const iores
-get_next_data_record(data_tok* /*dtok*/) throw (jexception)
+jcntl::get_next_data_record(const void** const /*data*/, const size_t& /*dsize*/,
+ const size_t& /*dsize_avail*/) throw (jexception)
{
return RHM_IORES_NOTIMPL;
}
const iores
-discard_next_data_record(data_tok* /*dtok*/) throw (jexception)
+jcntl::discard_next_data_record(data_tok* /*dtokp*/) throw (jexception)
{
return RHM_IORES_NOTIMPL;
}
const iores
-jcntl::read_next_data_record(void* const dbuf, const size_t dbsize, data_tok* const
dtok)
+jcntl::read_next_data_record(void* const dbuf, const size_t dbsize, data_tok* const
dtokp)
throw (jexception)
{
check_rstatus("read_data");
- return _rmgr.read(dbuf, dbsize, dtok);
+ return _rmgr.read(dbuf, dbsize, dtokp);
}
const iores
-jcntl::dequeue_data_record(data_tok* const dtok) throw (jexception)
+jcntl::dequeue_data_record(data_tok* const dtokp, const std::string /*xid*/) throw
(jexception)
{
check_wstatus("dequeue_data");
- return _wmgr.dequeue(dtok);
+ return _wmgr.dequeue(dtokp);
}
+const iores
+jcntl::abort_dtx(const std::string /*xid*/) throw (jexception)
+{
+ return RHM_IORES_NOTIMPL;
+}
+
+const iores
+jcntl::commit_dtx(const std::string /*xid*/) throw (jexception)
+{
+ return RHM_IORES_NOTIMPL;
+}
+
const u_int32_t
jcntl::get_wr_events() throw (jexception)
{
@@ -516,6 +529,8 @@
}
+// Static instance of empty string used as default XID parameter and which signifies no
XID.
+const std::string jcntl::no_xid;
} // namespace journal
Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-09-24 20:16:06 UTC (rev 943)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-09-25 13:00:25 UTC (rev 944)
@@ -137,6 +137,7 @@
rmgr _rmgr; ///< Read page manager which manages AIO
wmgr _wmgr; ///< Write page manager which manages AIO
rcvdat _rcvdat; ///< Recovery data used for recovery
+ static const std::string no_xid;
std::deque<rhm::journal::data_tok*> _aio_rd_cmpl_dtok_list; ///<
Internally mamanged deque
std::deque<rhm::journal::data_tok*> _aio_wr_cmpl_dtok_list; ///<
Internally mamanged deque
@@ -179,7 +180,7 @@
* AIO operations.
* \param wr_cb Function pointer to callback function for write operations. May be
NULL.
*
- * \exception ??
+ * \exception TODO
*/
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);
@@ -189,7 +190,7 @@
*
* TODO: Move to JournalImpl later
*
- * \exception ??
+ * \exception TODO
*/
void initialize() throw (jexception)
{
@@ -218,7 +219,7 @@
* AIO operations.
* \param wr_cb Function pointer to callback function for write operations. May be
NULL.
*
- * \exception ??
+ * \exception TODO
*/
void recover(std::deque<data_tok*>* rd_dtokl, const aio_cb rd_cb,
std::deque<data_tok*>* wr_dtokl, const aio_cb wr_cb) throw (jexception);
@@ -228,7 +229,7 @@
*
* TODO: Move to JournalImpl later
*
- * \exception ??
+ * \exception TODO
*/
void recover() throw (jexception)
{
@@ -245,7 +246,7 @@
* may be re-read during normal operation. The read-only flag is then reset,
allowing
* enqueue and dequeue operations to resume.
*
- * \exception ??
+ * \exception TODO
*/
void recover_complete() throw (jexception);
@@ -254,64 +255,87 @@
*
* Clear the journal directory of all journal files matching the base filename.
*
- * \exception ??
+ * \exception TODO
*/
void delete_jrnl_files() 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.
- *
- * \exception ??
- */
+ // TODO *** DEPRECATED *** Replaced by enqueue_data_record() call below.
const iores enqueue_data_record(const void* const dbuf, const size_t dlen,
data_tok* const dtok) throw (jexception);
/**
- * \brief Enqueue data or part of data
+ * \brief Enqueue data.
*
- * \param data_buff
- * \param tot_data_len
- * \param this_data_len
- * \param xid_buff
- * \param xid_len
- * \param dtok
+ * Enqueue data or part thereof. If a large data block is being written, then it
may be
+ * enqueued in parts by setting this_data_len to the size of the data being
written in this
+ * call. The total data size must be known in advance, however, as this is written
into the
+ * record header on the first record write. The state of the write (i.e. how much
has been
+ * written so far) is maintained in the data token dtokp. Partial writes will
return in state
+ * ENQ_PART.
*
- * \exception ??
+ * Note that a return value of anything other than RHM_IORES_SUCCESS implies that
this write
+ * operation did not complete successfully or was partially completed. The action
taken under
+ * these conditions depends on the value of the return. For example,
RHM_IORES_AIO_WAIT
+ * implies that all pages in the write page cache are waiting for AIO operations
to return,
+ * and that the call should be remade after waiting a bit.
+ *
+ * Example: If a write of 99 kB is divided into three equal parts, then the
following states
+ * and returns would characterize a successful operation:
+ * dtok. dtok. dtok.
+ * operation return wstate() dsize() written() comment
+ * NONE 0 0 Value of dtok before op
+ * edr(99000, 33000) SUCCESS ENQ_PART 99000 33000 Enqueue part 1
+ * edr(99000, 33000) AIO_WAIT ENQ_PART 99000 50000 Enqueue part 2, not
completed
+ * edr(99000, 33000) SUCCESS ENQ_PART 99000 66000 Enqueue part 2 again
+ * edr(99000, 33000) SUCCESS ENQ 99000 99000 Enqueue part 3
+ *
+ * \param data_buff Pointer to data to be enqueued for this enqueue operation.
+ * \param tot_data_len Total data length.
+ * \param this_data_len Amount to be written in this enqueue operation.
+ * \param dtokp Pointer to data token which contains the details of the enqueue
operation.
+ * \param xid String containing xid. An empty string (i.e. length=0) will be
considered
+ * non-transactional.
+ * \param transient Flag indicating transient persistence (ie, ignored on
recover).
+ *
+ * \exception TODO
*/
- const iores enqueue_data_record(
- const void* const data_buff, ///< pointer to data to be enqueued in
this enq op
- const size_t tot_data_len, ///< total data length
- const size_t this_data_len, ///< amount to be written in this enq
op
- const void* const xid_buff, ///< pointer to xid
- const size_t xid_len, ///< xid length
- data_tok* dtok) ///< pointer to data token instance
- throw (jexception);
+ const iores enqueue_data_record(const void* const data_buff, const size_t
tot_data_len,
+ const size_t this_data_len, data_tok* dtokp, const std::string xid =
no_xid,
+ const bool transient = false) throw (jexception);
/**
* \brief Retrieve details of next record to be read without consuming the
record.
*
* Retrieve details of next record to be read without consuming the record. A
pointer to
- * the data is also returned.
+ * the data is returned, along with the data size and available data size. If a
large record
+ * should span more than one page of the read page cache, then if the following
page is still
+ * waiting for AIO return, then only a portion of the total data will be available
for
+ * consumption. If dsize_avail < dsize, then a subsequent call will update
dsize_avail if
+ * more pages have returned from AIO.
*
- * \param dtok
+ * Note that using this function does not consume the record, it merely makes the
content
+ * of the read page cache available through a pointer. To mark this record as
consumed,
+ * discard_next_data_record() must be called.
*
- * \exception ??
+ * \param data Pointer to data pointer which will point to the first byte of the
next record
+ * data.
+ * \param dsize Reference that returns the total data size of the record data .
+ * \param dsize_avail Reference that returns the amount of the data that is
available for
+ * consumption.
+ *
+ * \exception TODO
*/
- const iores get_next_data_record(data_tok* dtok) throw (jexception);
+ const iores get_next_data_record(const void** const data, const size_t&
dsize,
+ const size_t& dsize_avail) throw (jexception);
/**
* \brief Discard (skip) next record to be read without reading or retrieving it.
*
- * \param dtok
+ * \param dtokp Pointer to data token which contains the details of the enqueue
operation.
*
- * \exception ??
+ * \exception TODO
*/
- const iores discard_next_data_record(data_tok* dtok) throw (jexception);
+ const iores discard_next_data_record(data_tok* dtokp) throw (jexception);
/**
* \brief Reads data from the journal.
@@ -319,13 +343,13 @@
* \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
+ * \param dtokp Pointer to data_tok instance for this data, used to track state of
data
* through journal.
*
- * \exception ??
+ * \exception TODO
*/
const iores read_next_data_record(void* const dbuf, const size_t dbsize,
- data_tok* const dtok) throw (jexception);
+ data_tok* const dtokp) throw (jexception);
/**
* \brief Dequeues (marks as no longer needed) data record in journal.
@@ -336,12 +360,15 @@
* record to be dequeued and the write state of ENQ must be manually set in a new
or reset
* instance of data_tok.
*
- * \param dtok Pointer to data_tok instance for this data, used to track state of
data
+ * \param dtokp Pointer to data_tok instance for this data, used to track state of
data
* through journal.
+ * \param xid String containing xid. An empty string (i.e. length=0) will be
considered
+ * non-transactional.
*
- * \exception ??
+ * \exception TODO
*/
- const iores dequeue_data_record(data_tok* const dtok) throw (jexception);
+ const iores dequeue_data_record(data_tok* const dtokp, const std::string xid =
no_xid)
+ throw (jexception);
/**
* \brief Abort the transaction for all records enqueued or dequeued with the
matching xid.
@@ -350,12 +377,11 @@
* are effectively deleted from the journal, and can not be read. All dequeued
records remain
* as though they had never been dequeued.
*
- * \param xid_buff
- * \param xid_len
+ * \param xid String containing xid.
*
- * \exception ??
+ * \exception TODO
*/
- const iores abort_xid(const void* const xid_buff, const size_t xid_len) throw
(jexception);
+ const iores abort_dtx(const std::string xid) throw (jexception);
/**
* \brief Commit the transaction for all records enqueued or dequeued with the
matching xid.
@@ -364,22 +390,20 @@
* records are effectively released for reading and dequeueing. All dequeued
records are
* removed and can no longer be accessed.
*
- * \param xid_buff
- * \param xid_len
+ * \param xid String containing xid.
*
- * \exception ??
+ * \exception TODO
*/
- const iores commit_xid(const void* const xid_buff, const size_t xid_len) throw
(jexception);
+ const iores commit_dtx(const std::string xid) throw (jexception);
/**
* \brief Check whether all the enqueue records for the given xid have reached
disk.
*
- * \param xid_buff
- * \param xid_len
+ * \param xid String containing xid.
*
- * \exception ??
+ * \exception TODO
*/
- const bool is_synced(const void* const xid_buff, const size_t xid_len) throw
(jexception);
+ const bool is_dtx_synced(const std::string xid) throw (jexception);
/**
* \brief Forces a check for returned AIO write events.
Modified: store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp 2007-09-24 20:16:06 UTC (rev 943)
+++ store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp 2007-09-25 13:00:25 UTC (rev 944)
@@ -42,22 +42,14 @@
class JournalSystemTests : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(JournalSystemTests);
- CPPUNIT_TEST(InstantiationTest_Stack);
- CPPUNIT_TEST(InstantiationTest_Heap);
- CPPUNIT_TEST(InitializationTest_Stack);
- CPPUNIT_TEST(InitializationTest_Heap);
- CPPUNIT_TEST(EmptyRecoverTest_Stack);
- CPPUNIT_TEST(EmptyRecoverTest_Heap);
- CPPUNIT_TEST(EnqueueTest_Stack);
- CPPUNIT_TEST(EnqueueTest_Heap);
- CPPUNIT_TEST(RecoverReadTest_Stack);
- CPPUNIT_TEST(RecoverReadTest_Heap);
- CPPUNIT_TEST(RecoveredReadTest_Stack);
- CPPUNIT_TEST(RecoveredReadTest_Heap);
- CPPUNIT_TEST(RecoveredDequeueTest_Stack);
- CPPUNIT_TEST(RecoveredDequeueTest_Heap);
- CPPUNIT_TEST(ComplexRecoveryTest1_Stack);
- CPPUNIT_TEST(ComplexRecoveryTest1_Heap);
+ CPPUNIT_TEST(InstantiationTest);
+ CPPUNIT_TEST(InitializationTest);
+ CPPUNIT_TEST(EmptyRecoverTest);
+ CPPUNIT_TEST(EnqueueTest);
+ CPPUNIT_TEST(RecoverReadTest);
+ CPPUNIT_TEST(RecoveredReadTest);
+ CPPUNIT_TEST(RecoveredDequeueTest);
+ CPPUNIT_TEST(ComplexRecoveryTest1);
CPPUNIT_TEST(EncodeTest_000);
CPPUNIT_TEST(EncodeTest_001);
CPPUNIT_TEST(EncodeTest_002);
@@ -95,9 +87,10 @@
public:
- void InstantiationTest_Stack()
+ void InstantiationTest()
{
- const char* test_name = "InstantiationTest_Stack";
+ //Stack
+ char* test_name = "InstantiationTest_Stack";
try
{
rhm::journal::jcntl jc(test_name, "jdata", test_name);
@@ -108,11 +101,8 @@
ss << e;
CPPUNIT_FAIL(ss.str());
}
- }
-
- void InstantiationTest_Heap()
- {
- const char* test_name = "InstantiationTest_Heap";
+ // Heap
+ test_name = "InstantiationTest_Heap";
rhm::journal::jcntl* jcp = NULL;
try
{
@@ -128,9 +118,10 @@
}
}
- void InitializationTest_Stack()
+ void InitializationTest()
{
- const char* test_name = "InitializationTest_Stack";
+ //Stack
+ char* test_name = "InitializationTest_Stack";
try
{
rhm::journal::jcntl jc(test_name, "jdata", test_name);
@@ -142,11 +133,8 @@
ss << e;
CPPUNIT_FAIL(ss.str());
}
- }
-
- void InitializationTest_Heap()
- {
- const char* test_name = "InitializationTest_Heap";
+ // Heap
+ test_name = "InitializationTest_Heap";
rhm::journal::jcntl* jcp = NULL;
try
{
@@ -165,9 +153,10 @@
}
}
- void EmptyRecoverTest_Stack()
+ void EmptyRecoverTest()
{
- const char* test_name = "EmptyRecoverTest_Stack";
+ //Stack
+ char* test_name = "EmptyRecoverTest_Stack";
try
{
{
@@ -190,11 +179,8 @@
ss << e;
CPPUNIT_FAIL(ss.str());
}
- }
-
- void EmptyRecoverTest_Heap()
- {
- const char* test_name = "EmptyRecoverTest_Heap";
+ // Heap
+ test_name = "EmptyRecoverTest_Heap";
rhm::journal::jcntl* jcp = NULL;
try
{
@@ -230,9 +216,10 @@
}
}
- void EnqueueTest_Stack()
+ void EnqueueTest()
{
- const char* test_name = "EnqueueTest_Stack";
+ //Stack
+ char* test_name = "EnqueueTest_Stack";
try
{
rhm::journal::jcntl jc(test_name, "jdata", test_name);
@@ -246,11 +233,8 @@
ss << e;
CPPUNIT_FAIL(ss.str());
}
- }
-
- void EnqueueTest_Heap()
- {
- const char* test_name = "EnqueueTest_Heap";
+ // Heap
+ test_name = "EnqueueTest_Heap";
rhm::journal::jcntl* jcp = NULL;
try
{
@@ -271,9 +255,10 @@
}
}
- void RecoverReadTest_Stack()
+ void RecoverReadTest()
{
- const char* test_name = "RecoverReadTest_Stack";
+ //Stack
+ char* test_name = "RecoverReadTest_Stack";
try
{
{
@@ -296,11 +281,8 @@
ss << e;
CPPUNIT_FAIL(ss.str());
}
- }
-
- void RecoverReadTest_Heap()
- {
- const char* test_name = "RecoverReadTest_Heap";
+ // Heap
+ test_name = "RecoverReadTest_Heap";
rhm::journal::jcntl* jcp = NULL;
try
{
@@ -333,9 +315,10 @@
}
}
- void RecoveredReadTest_Stack()
+ void RecoveredReadTest()
{
- const char* test_name = "RecoveredReadTest_Stack";
+ //Stack
+ char* test_name = "RecoveredReadTest_Stack";
try
{
{
@@ -362,11 +345,8 @@
ss << e;
CPPUNIT_FAIL(ss.str());
}
- }
-
- void RecoveredReadTest_Heap()
- {
- const char* test_name = "RecoveredReadTest_Heap";
+ // Heap
+ test_name = "RecoveredReadTest_Heap";
rhm::journal::jcntl* jcp = NULL;
try
{
@@ -403,9 +383,10 @@
}
}
- void RecoveredDequeueTest_Stack()
+ void RecoveredDequeueTest()
{
- const char* test_name = "RecoveredDequeueTest_Stack";
+ //Stack
+ char* test_name = "RecoveredDequeueTest_Stack";
try
{
{
@@ -434,11 +415,8 @@
ss << e;
CPPUNIT_FAIL(ss.str());
}
- }
-
- void RecoveredDequeueTest_Heap()
- {
- const char* test_name = "RecoveredDequeueTest_Heap";
+ // Heap
+ test_name = "RecoveredDequeueTest_Heap";
rhm::journal::jcntl* jcp = NULL;
try
{
@@ -477,9 +455,10 @@
}
}
- void ComplexRecoveryTest1_Stack()
+ void ComplexRecoveryTest1()
{
- const char* test_name = "ComplexRecoveryTest1_Stack";
+ //Stack
+ char* test_name = "ComplexRecoveryTest1_Stack";
try
{
{
@@ -526,11 +505,8 @@
ss << e;
CPPUNIT_FAIL(ss.str());
}
- }
-
- void ComplexRecoveryTest1_Heap()
- {
- const char* test_name = "RecoveredDequeueTest_Heap";
+ // Heap
+ test_name = "RecoveredDequeueTest_Heap";
rhm::journal::jcntl* jcp = NULL;
try
{