Author: kpvdr
Date: 2007-09-14 14:21:12 -0400 (Fri, 14 Sep 2007)
New Revision: 923
Modified:
store/trunk/cpp/lib/jrnl/data_tok.cpp
store/trunk/cpp/lib/jrnl/data_tok.hpp
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jerrno.cpp
store/trunk/cpp/lib/jrnl/jerrno.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/wrfc.cpp
Log:
Added simple timeout to blocking jcntl::aio_cmpl_wait(); some obsolete commented-out code
removed.
Modified: store/trunk/cpp/lib/jrnl/data_tok.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/data_tok.cpp 2007-09-14 17:33:14 UTC (rev 922)
+++ store/trunk/cpp/lib/jrnl/data_tok.cpp 2007-09-14 18:21:12 UTC (rev 923)
@@ -87,7 +87,8 @@
case DEQ:
return "DEQ";
}
- return "<unknown>";
+ // Not using default: forces compiler to ensure all cases are covered.
+ return "<wstate unknown>";
}
const char*
@@ -110,7 +111,8 @@
case READ:
return "READ";
}
- return "<unknown>";
+ // Not using default: forces compiler to ensure all cases are covered.
+ return "<rstate unknown>";
}
void
@@ -126,15 +128,6 @@
_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()
{
Modified: store/trunk/cpp/lib/jrnl/data_tok.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/data_tok.hpp 2007-09-14 17:33:14 UTC (rev 922)
+++ store/trunk/cpp/lib/jrnl/data_tok.hpp 2007-09-14 18:21:12 UTC (rev 923)
@@ -126,14 +126,12 @@
inline void incr_dblocks_written(u_int32_t dblks_written)
{ _dblks_written += dblks_written; }
inline void set_dblocks_written(u_int32_t dblks_written) { _dblks_written =
dblks_written; }
-// inline void reset_dblks_proc() { _dblks_written = 0; }
inline const u_int32_t dblocks_read() const { return _dblks_read; }
inline void incr_dblocks_read(u_int32_t dblks_read) { _dblks_read += dblks_read;
}
inline void set_dblocks_read(u_int32_t dblks_read) { _dblks_read = dblks_read; }
-// inline void reset_dblks_read() { _dblks_read = 0; }
- const u_int64_t rid() const throw (jexception);
+ inline const u_int64_t rid() const { return _rid; }
inline void set_rid(const u_int64_t rid) { _rid = rid; }
inline const u_int64_t dequeue_rid() const throw (jexception) {return
_dequeue_rid; }
inline void set_dequeue_rid(const u_int64_t rid) { _dequeue_rid = rid; }
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-14 17:33:14 UTC (rev 922)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-14 18:21:12 UTC (rev 923)
@@ -201,13 +201,20 @@
of.close();
}
-#define AIO_CMPL_SLEEP 10000 // 10 ms
+#define AIO_CMPL_SLEEP 10000 // 10 ms
+#define MAX_AIO_CMPL_SLEEPS 1000 // Total: 10 sec
+
void
jcntl::aio_cmpl_wait() throw (jexception)
{
- while (_wmgr.get_aio_evt_rem())
+ u_int32_t cnt = 0;
+ u_int32_t rem = _wmgr.get_aio_evt_rem();
+ while (rem)
{
get_wr_events();
+ rem = _wmgr.get_aio_evt_rem();
+ if (cnt++ > MAX_AIO_CMPL_SLEEPS)
+ throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl",
"aio_cmpl_wait");
usleep(AIO_CMPL_SLEEP);
}
}
Modified: store/trunk/cpp/lib/jrnl/jerrno.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.cpp 2007-09-14 17:33:14 UTC (rev 922)
+++ store/trunk/cpp/lib/jrnl/jerrno.cpp 2007-09-14 18:21:12 UTC (rev 923)
@@ -53,6 +53,7 @@
// class jcntl
const u_int32_t jerrno::JERR_JCNTL_STOPPED = 0x0200;
+const u_int32_t jerrno::JERR_JCNTL_AIOCMPLWAIT = 0x0201;
// class jdir
const u_int32_t jerrno::JERR_JDIR_MKDIR = 0x0300;
@@ -116,6 +117,8 @@
// class jcntl
_err_map[JERR_JCNTL_STOPPED] = std::string("JERR_JCNTL_STOPPED: Operation on
stopped journal.");
+ _err_map[JERR_JCNTL_AIOCMPLWAIT] = std::string("JERR_JCNTL_AIOCMPLWAIT: "
+ "Timeout waiting for AIOs to complete.");
// class jdir
_err_map[JERR_JDIR_MKDIR] = std::string("JERR_JDIR_MKDIR: Directory creation
failed.");
Modified: store/trunk/cpp/lib/jrnl/jerrno.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.hpp 2007-09-14 17:33:14 UTC (rev 922)
+++ store/trunk/cpp/lib/jrnl/jerrno.hpp 2007-09-14 18:21:12 UTC (rev 923)
@@ -70,6 +70,7 @@
// class jcntl
static const u_int32_t JERR_JCNTL_STOPPED; ///< Operation on stopped
journal
+ static const u_int32_t JERR_JCNTL_AIOCMPLWAIT; ///< Timeout waiting for AIOs
to complete
// class jdir
static const u_int32_t JERR_JDIR_MKDIR; ///< Directory creation
failed
Modified: store/trunk/cpp/lib/jrnl/nlfh.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/nlfh.cpp 2007-09-14 17:33:14 UTC (rev 922)
+++ store/trunk/cpp/lib/jrnl/nlfh.cpp 2007-09-14 18:21:12 UTC (rev 923)
@@ -316,40 +316,6 @@
return _wr_cmpl_cnt_dblks;
}
-// const bool
-// nlfh::is_rd_compl() const throw (jexception)
-// {
-// return rd_remaining_dblks() == 0 &&
-// (JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1)) - _wr_cmpl_cnt_dblks == 0;
-// }
-//
-// 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)
-// {
-// assert(_wr_subm_cnt_dblks <= JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1));
-// 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
{
Modified: store/trunk/cpp/lib/jrnl/nlfh.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/nlfh.hpp 2007-09-14 17:33:14 UTC (rev 922)
+++ store/trunk/cpp/lib/jrnl/nlfh.hpp 2007-09-14 18:21:12 UTC (rev 923)
@@ -129,12 +129,6 @@
{ return _wr_subm_cnt_dblks - _wr_cmpl_cnt_dblks; }
inline const bool wr_file_rotate() const { return is_wr_full(); }
-// const u_int32_t rd_remaining_dblks() const throw (jexception);
-// const bool is_rd_compl() const throw (jexception);
-// const u_int32_t wr_remaining_dblks() const throw (jexception);
-// inline const bool is_wr_compl() const throw (jexception)
-// { return wr_remaining_dblks() == 0; }
-
const bool will_fit(const size_t rec_size) const;
protected:
Modified: store/trunk/cpp/lib/jrnl/pmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-09-14 17:33:14 UTC (rev 922)
+++ store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-09-14 18:21:12 UTC (rev 923)
@@ -258,9 +258,8 @@
return "AIO_PENDING";
case AIO_COMPLETE:
return "AIO_COMPLETE";
- default:
- return "<unknown state>";
}
+ return "<page_state unknown>";
}
} // namespace journal
Modified: store/trunk/cpp/lib/jrnl/wrfc.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wrfc.cpp 2007-09-14 17:33:14 UTC (rev 922)
+++ store/trunk/cpp/lib/jrnl/wrfc.cpp 2007-09-14 18:21:12 UTC (rev 923)
@@ -74,7 +74,6 @@
if (_fh_index == _nfiles)
_fh_index = 0;
_curr_fh = _fh_arr[_fh_index];
-//std::cout << "wrfc::rotate() RESET fid=" << _fh_index <<
std::flush;
return reset(); //Checks if file is still in use (ie not fully dequeued yet)
}