[rhmessaging-commits] rhmessaging commits: r4040 - store/trunk/cpp/lib/jrnl.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Fri Jun 18 13:04:34 EDT 2010
Author: kpvdr
Date: 2010-06-18 13:04:33 -0400 (Fri, 18 Jun 2010)
New Revision: 4040
Modified:
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/txn_map.cpp
store/trunk/cpp/lib/jrnl/txn_map.hpp
store/trunk/cpp/lib/jrnl/wmgr.cpp
Log:
Further tidy-up of txn_map error handling
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2010-06-18 14:56:46 UTC (rev 4039)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2010-06-18 17:04:33 UTC (rev 4040)
@@ -700,11 +700,10 @@
assert(xidp != 0);
std::string xid((char*)xidp, er.xid_size());
_tmap.insert_txn_data(xid, txn_data(h._rid, 0, start_fid, true));
- if (_tmap.set_aio_compl(xid, h._rid)) // xid or rid not found
+ if (_tmap.set_aio_compl(xid, h._rid) < txn_map::TMAP_OK) // fail - xid or rid not found
{
std::ostringstream oss;
- oss << std::hex << "_tmap.set_aio_compl: txn_enq xid=\"" << xid;
- oss << "\" rid=0x" << h._rid;
+ oss << std::hex << "_tmap.set_aio_compl: txn_enq xid=\"" << xid << "\" rid=0x" << h._rid;
throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "jcntl", "rcvr_get_next_record");
}
std::free(xidp);
@@ -737,11 +736,10 @@
std::string xid((char*)xidp, dr.xid_size());
_tmap.insert_txn_data(xid, txn_data(dr.rid(), dr.deq_rid(), start_fid, false,
dr.is_txn_coml_commit()));
- if (_tmap.set_aio_compl(xid, dr.rid())) // xid or rid not found
+ if (_tmap.set_aio_compl(xid, dr.rid()) < txn_map::TMAP_OK) // fail - xid or rid not found
{
std::ostringstream oss;
- oss << std::hex << "_tmap.set_aio_compl: txn_deq xid=\"" << xid;
- oss << "\" rid=0x" << dr.rid();
+ oss << std::hex << "_tmap.set_aio_compl: txn_deq xid=\"" << xid << "\" rid=0x" << dr.rid();
throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "jcntl", "rcvr_get_next_record");
}
std::free(xidp);
Modified: store/trunk/cpp/lib/jrnl/txn_map.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/txn_map.cpp 2010-06-18 14:56:46 UTC (rev 4039)
+++ store/trunk/cpp/lib/jrnl/txn_map.cpp 2010-06-18 17:04:33 UTC (rev 4040)
@@ -43,6 +43,13 @@
namespace journal
{
+// return/error codes
+int16_t txn_map::TMAP_RID_NOT_FOUND = -2;
+int16_t txn_map::TMAP_XID_NOT_FOUND = -1;
+int16_t txn_map::TMAP_OK = 0;
+int16_t txn_map::TMAP_NOT_SYNCED = 0;
+int16_t txn_map::TMAP_SYNCED = 1;
+
txn_data_struct::txn_data_struct(const u_int64_t rid, const u_int64_t drid, const u_int16_t pfid,
const bool enq_flag, const bool commit_flag):
_rid(rid),
@@ -158,13 +165,13 @@
return c;
}
-int8_t
+int16_t
txn_map::is_txn_synced(const std::string& xid)
{
slock s(_mutex);
xmap_itr itr = _map.find(xid);
if (itr == _map.end()) // not found in map
- return -1;
+ return TMAP_XID_NOT_FOUND;
bool is_synced = true;
for (tdl_itr litr = itr->second.begin(); litr < itr->second.end(); litr++)
{
@@ -174,26 +181,26 @@
break;
}
}
- return is_synced ? 1 : 0;
+ return is_synced ? TMAP_SYNCED : TMAP_NOT_SYNCED;
}
-int8_t
+int16_t
txn_map::set_aio_compl(const std::string& xid, const u_int64_t rid)
{
slock s(_mutex);
xmap_itr itr = _map.find(xid);
if (itr == _map.end()) // xid not found in map
- return -1;
+ return TMAP_XID_NOT_FOUND;
for (tdl_itr litr = itr->second.begin(); litr < itr->second.end(); litr++)
{
if (litr->_rid == rid)
{
litr->_aio_compl = true;
- return 0; // rid found
+ return TMAP_OK; // rid found
}
}
// xid present, but rid not found
- return -2;
+ return TMAP_RID_NOT_FOUND;
}
bool
Modified: store/trunk/cpp/lib/jrnl/txn_map.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/txn_map.hpp 2010-06-18 14:56:46 UTC (rev 4039)
+++ store/trunk/cpp/lib/jrnl/txn_map.hpp 2010-06-18 17:04:33 UTC (rev 4040)
@@ -111,6 +111,14 @@
*/
class txn_map
{
+ public:
+ // return/error codes
+ static int16_t TMAP_RID_NOT_FOUND;
+ static int16_t TMAP_XID_NOT_FOUND;
+ static int16_t TMAP_OK;
+ static int16_t TMAP_NOT_SYNCED;
+ static int16_t TMAP_SYNCED;
+
private:
typedef std::pair<std::string, txn_data_list> xmap_param;
typedef std::map<std::string, txn_data_list> xmap;
@@ -133,8 +141,8 @@
bool in_map(const std::string& xid);
u_int32_t enq_cnt();
u_int32_t deq_cnt();
- int8_t is_txn_synced(const std::string& xid); // -1=xid not found; 0=not synced; 1=synced
- int8_t set_aio_compl(const std::string& xid, const u_int64_t rid); // -2=rid not found; -1=xid not found; 0=done
+ int16_t is_txn_synced(const std::string& xid); // -1=xid not found; 0=not synced; 1=synced
+ int16_t set_aio_compl(const std::string& xid, const u_int64_t rid); // -2=rid not found; -1=xid not found; 0=done
bool data_exists(const std::string& xid, const u_int64_t rid);
bool is_enq(const u_int64_t rid);
inline void clear() { _map.clear(); }
Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp 2010-06-18 14:56:46 UTC (rev 4039)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2010-06-18 17:04:33 UTC (rev 4040)
@@ -810,7 +810,8 @@
bool
wmgr::is_txn_synced(const std::string& xid)
{
- if (_tmap.is_txn_synced(xid) == 0) // not synced
+ // Ignore xid not found error here
+ if (_tmap.is_txn_synced(xid) == txn_map::TMAP_NOT_SYNCED)
return false;
// Check for outstanding commit/aborts
std::set<std::string>::iterator it = _txn_pending_set.find(xid);
More information about the rhmessaging-commits
mailing list