[rhmessaging-commits] rhmessaging commits: r2002 - in store/trunk/cpp: tests/jrnl and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue May 6 15:39:27 EDT 2008


Author: kpvdr
Date: 2008-05-06 15:39:27 -0400 (Tue, 06 May 2008)
New Revision: 2002

Modified:
   store/trunk/cpp/lib/jrnl/jcntl.cpp
   store/trunk/cpp/lib/jrnl/jinf.cpp
   store/trunk/cpp/lib/jrnl/jinf.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/tests/jrnl/_ut_jdir.cpp
   store/trunk/cpp/tests/jrnl/_ut_jinf.cpp
Log:
Removed references to JRNL_WMGR_PAGE_SIZE in preparation for turning it into a configurable parameter. Some tidy-up. Also fixed BZ426278: "Journal recovery fails if journal files are moved to new location"

Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp	2008-05-06 18:14:25 UTC (rev 2001)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp	2008-05-06 19:39:27 UTC (rev 2002)
@@ -498,7 +498,7 @@
         oss << "errno=" << errno;
         throw jexception(jerrno::JERR__RTCLOCK, oss.str(), "jcntl", "write_infofile");
     }
-    jinf ji(_jid, _jdir.dirname(), _base_filename, _num_jfiles, _jfsize_sblks, ts);
+    jinf ji(_jid, _jdir.dirname(), _base_filename, _num_jfiles, _jfsize_sblks, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES, ts);
     ji.write();
 }
 
@@ -590,6 +590,14 @@
         this->log(LOG_WARN, oss.str());
         _jfsize_sblks = ji.jfsize_sblks();
     }
+    if (_jdir.dirname().compare(ji.jdir()))
+    {
+        std::ostringstream oss;
+        oss << "Journal file location change: original = \"" << ji.jdir() <<
+                "\"; current = \"" << _jdir.dirname() << "\"";
+        this->log(LOG_WARN, oss.str());
+        ji.set_jdir(_jdir.dirname());
+    }
 
     try
     {

Modified: store/trunk/cpp/lib/jrnl/jinf.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jinf.cpp	2008-05-06 18:14:25 UTC (rev 2001)
+++ store/trunk/cpp/lib/jrnl/jinf.cpp	2008-05-06 19:39:27 UTC (rev 2002)
@@ -51,10 +51,10 @@
         _jfsize_sblks(0),
         _sblk_size_dblks(0),
         _dblk_size(0),
-        _wmgr_page_size_dblks(0),
-        _wmgr_num_pages(0),
-        _rmgr_page_size_dblks(0),
-        _rmgr_num_pages(0),
+        _wcache_pgsize_sblks(0),
+        _wcache_num_pages(0),
+        _rcache_pgsize_sblks(0),
+        _rcache_num_pages(0),
         _tm_ptr(0),
         _valid_flag(false),
         _analyzed_flag(false),
@@ -69,7 +69,8 @@
 }
 
 jinf::jinf(const std::string& jid, const std::string& jdir, const std::string& base_filename,
-        const u_int16_t num_jfiles, const u_int32_t jfsize_sblks, const timespec& ts):
+        const u_int16_t num_jfiles, const u_int32_t jfsize_sblks,
+        const u_int32_t wcache_pgsize_sblks, const u_int32_t wcache_num_pages, const timespec& ts):
         _jver(RHM_JDAT_VERSION),
         _jid(jid),
         _jdir(jdir),
@@ -79,10 +80,10 @@
         _jfsize_sblks(jfsize_sblks),
         _sblk_size_dblks(JRNL_SBLK_SIZE),
         _dblk_size(JRNL_DBLK_SIZE),
-        _wmgr_page_size_dblks(JRNL_WMGR_PAGE_SIZE),
-        _wmgr_num_pages(JRNL_WMGR_PAGES),
-        _rmgr_page_size_dblks(JRNL_RMGR_PAGE_SIZE),
-        _rmgr_num_pages(JRNL_RMGR_PAGES),
+        _wcache_pgsize_sblks(wcache_pgsize_sblks),
+        _wcache_num_pages(wcache_num_pages),
+        _rcache_pgsize_sblks(JRNL_RMGR_PAGE_SIZE),
+        _rcache_num_pages(JRNL_RMGR_PAGES),
         _tm_ptr(std::localtime(&ts.tv_sec)),
         _valid_flag(false),
         _analyzed_flag(false),
@@ -129,30 +130,6 @@
         oss << "; required=" << JRNL_DBLK_SIZE << std::endl;
         err = true;
     }
-    if (_wmgr_page_size_dblks != JRNL_WMGR_PAGE_SIZE)
-    {
-        oss << "JRNL_WMGR_PAGE_SIZE mismatch: " << _wmgr_page_size_dblks;
-        oss << "; required=" << JRNL_WMGR_PAGE_SIZE << std::endl;
-        err = true;
-    }
-    if (_wmgr_num_pages != JRNL_WMGR_PAGES)
-    {
-        oss << "JRNL_WMGR_PAGES mismatch: " << _wmgr_num_pages;
-        oss << "; required=" << JRNL_WMGR_PAGES << std::endl;
-        err = true;
-    }
-    if (_rmgr_page_size_dblks != JRNL_RMGR_PAGE_SIZE)
-    {
-        oss << "JRNL_RMGR_PAGE_SIZE mismatch: " << _rmgr_page_size_dblks;
-        oss << "; required=" << JRNL_RMGR_PAGE_SIZE << std::endl;
-        err = true;
-    }
-    if (_rmgr_num_pages != JRNL_RMGR_PAGES)
-    {
-        oss << "JRNL_RMGR_PAGES mismatch: " << _rmgr_num_pages;
-        oss << "; required=" << JRNL_RMGR_PAGES << std::endl;
-        err = true;
-    }
     if (err)
         throw jexception(jerrno::JERR_JINF_CVALIDFAIL, oss.str(), "jinf", "validate");
     _valid_flag = true;
@@ -268,12 +245,11 @@
     oss << "  Journal file size: " << _jfsize_sblks << " sblks" << std::endl;
     oss << "  Softblock size (JRNL_SBLK_SIZE): " << _sblk_size_dblks << " dblks" << std::endl;
     oss << "  Datablock size (JRNL_DBLK_SIZE): " << _dblk_size << " bytes" << std::endl;
-    oss << "  Write page size (JRNL_WMGR_PAGE_SIZE): " << _wmgr_page_size_dblks << " dblks" <<
+    oss << "  Write page size: " << _wcache_pgsize_sblks << " sblks" << std::endl;
+    oss << "  Number of write pages: " << _wcache_num_pages << std::endl;
+    oss << "  Read page size (JRNL_RMGR_PAGE_SIZE): " << _rcache_pgsize_sblks << " sblks" <<
             std::endl;
-    oss << "  Number of write pages (JRNL_WMGR_PAGES): " << _wmgr_num_pages << std::endl;
-    oss << "  Read page size (JRNL_RMGR_PAGE_SIZE): " << _rmgr_page_size_dblks << " dblks" <<
-            std::endl;
-    oss << "  Number of read pages (JRNL_RMGR_PAGES): " << _rmgr_num_pages << std::endl;
+    oss << "  Number of read pages (JRNL_RMGR_PAGES): " << _rcache_num_pages << std::endl;
     return oss.str();
 }
 
@@ -306,11 +282,13 @@
     oss << "    <jrnl_file_size_sblks value=\"" << _jfsize_sblks << "\" />" << std::endl;
     oss << "    <JRNL_SBLK_SIZE value=\"" << _sblk_size_dblks << "\" />" << std::endl;
     oss << "    <JRNL_DBLK_SIZE value=\"" << _dblk_size << "\" />" << std::endl;
-    oss << "    <JRNL_WMGR_PAGE_SIZE value=\"" << _wmgr_page_size_dblks << "\" />" << std::endl;
-    oss << "    <JRNL_WMGR_PAGES value=\"" << _wmgr_num_pages << "\" />" << std::endl;
-    oss << "    <JRNL_RMGR_PAGE_SIZE value=\"" << _rmgr_page_size_dblks << "\" />" << std::endl;
-    oss << "    <JRNL_RMGR_PAGES value=\"" << _rmgr_num_pages << "\" />" << std::endl;
     oss << "  </journal_file_geometry>" << std::endl;
+    oss << "  <cache_geometry>" << std::endl;
+    oss << "    <wcache_pgsize_sblks value=\"" << _wcache_pgsize_sblks << "\" />" << std::endl;
+    oss << "    <wcache_num_pages value=\"" << _wcache_num_pages << "\" />" << std::endl;
+    oss << "    <JRNL_RMGR_PAGE_SIZE value=\"" << _rcache_pgsize_sblks << "\" />" << std::endl;
+    oss << "    <JRNL_RMGR_PAGES value=\"" << _rcache_num_pages << "\" />" << std::endl;
+    oss << "  </cache_geometry>" << std::endl;
     oss << "</jrnl>" << std::endl;
     return oss.str();
 }   
@@ -318,7 +296,7 @@
 void
 jinf::read(const std::string& jinf_filename)
 {
-    // FIXME: This is *not* an XML reader, rather for simplicity, it is a brute-force
+    // TODO: This is *not* an XML reader, rather for simplicity, it is a brute-force
     // line reader which relies on string recognition.
 
     char buff[1024];
@@ -344,14 +322,14 @@
             _sblk_size_dblks = u_int16_value(buff);
         else if(std::strstr(buff, "JRNL_DBLK_SIZE"))
             _dblk_size = u_int32_value(buff);
-        else if(std::strstr(buff, "JRNL_WMGR_PAGE_SIZE"))
-            _wmgr_page_size_dblks = u_int32_value(buff);
-        else if(std::strstr(buff, "JRNL_WMGR_PAGES"))
-            _wmgr_num_pages = u_int32_value(buff);
+        else if(std::strstr(buff, "wcache_pgsize_sblks"))
+            _wcache_pgsize_sblks = u_int32_value(buff);
+        else if(std::strstr(buff, "wcache_num_pages"))
+            _wcache_num_pages = u_int32_value(buff);
         else if(std::strstr(buff, "JRNL_RMGR_PAGE_SIZE"))
-            _rmgr_page_size_dblks = u_int32_value(buff);
+            _rcache_pgsize_sblks = u_int32_value(buff);
         else if(std::strstr(buff, "JRNL_RMGR_PAGES"))
-            _rmgr_num_pages = u_int32_value(buff);
+            _rcache_num_pages = u_int32_value(buff);
         else if(std::strstr(buff, "nanoseconds"))
             _ts.tv_nsec = u_int32_value(buff);
         else if(std::strstr(buff, "seconds"))

Modified: store/trunk/cpp/lib/jrnl/jinf.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jinf.hpp	2008-05-06 18:14:25 UTC (rev 2001)
+++ store/trunk/cpp/lib/jrnl/jinf.hpp	2008-05-06 19:39:27 UTC (rev 2002)
@@ -56,10 +56,10 @@
         u_int32_t _jfsize_sblks;
         u_int16_t _sblk_size_dblks;
         u_int32_t _dblk_size;
-        u_int32_t _wmgr_page_size_dblks;
-        u_int32_t _wmgr_num_pages;
-        u_int32_t _rmgr_page_size_dblks;
-        u_int32_t _rmgr_num_pages;
+        u_int32_t _wcache_pgsize_sblks;
+        u_int32_t _wcache_num_pages;
+        u_int32_t _rcache_pgsize_sblks;
+        u_int32_t _rcache_num_pages;
         std::tm* _tm_ptr;
         bool _valid_flag;
         bool _analyzed_flag;
@@ -73,7 +73,9 @@
         jinf(const std::string& jinf_filename, bool validate_flag);
         // constructor for writing jinf file
         jinf(const std::string& jid, const std::string& jdir, const std::string& base_filename,
-            const u_int16_t num_jfiles, const u_int32_t jfsize_sblks, const timespec& ts);
+                const u_int16_t num_jfiles, const u_int32_t jfsize_sblks,
+                const u_int32_t wcache_pgsize_sblks, const u_int32_t wcache_num_pages,
+                const timespec& ts);
         virtual ~jinf();
 
         void validate();
@@ -83,16 +85,17 @@
         inline u_int8_t jver() const { return _jver; }
         inline const std::string& jid() const { return _jid; }
         inline const std::string& jdir() const { return _jdir; }
+        inline void set_jdir(const std::string& jdir) { _jdir = jdir; }
         inline const std::string& base_filename() const { return _base_filename; }
         inline const timespec& ts() const { return _ts; }
         inline u_int16_t num_jfiles() const { return _num_jfiles; }
         inline u_int32_t jfsize_sblks() const { return _jfsize_sblks; }
         inline u_int16_t sblk_size_dblks() const { return _sblk_size_dblks; }
         inline u_int32_t dblk_size() const { return _dblk_size; }
-        inline u_int32_t wmgr_page_size_dblks() const { return _wmgr_page_size_dblks; }
-        inline u_int32_t wmgr_num_pages() const { return _wmgr_num_pages; }
-        inline u_int32_t rmgr_page_size_dblks() const { return _rmgr_page_size_dblks; }
-        inline u_int32_t rmgr_num_pages() const { return _rmgr_num_pages; }
+        inline u_int32_t wcache_pgsize_sblks() const { return _wcache_pgsize_sblks; }
+        inline u_int32_t wcache_num_pages() const { return _wcache_num_pages; }
+        inline u_int32_t rcache_pgsize_sblks() const { return _rcache_pgsize_sblks; }
+        inline u_int32_t rcache_num_pages() const { return _rcache_num_pages; }
         u_int16_t get_start_file();
         u_int16_t get_end_file();
         bool get_initial_owi();

Modified: store/trunk/cpp/lib/jrnl/lfh.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/lfh.cpp	2008-05-06 18:14:25 UTC (rev 2001)
+++ store/trunk/cpp/lib/jrnl/lfh.cpp	2008-05-06 19:39:27 UTC (rev 2002)
@@ -38,8 +38,8 @@
 namespace journal
 {
 
-lfh::lfh(const u_int32_t jfsize_sblks):
-        nlfh(jfsize_sblks)
+lfh::lfh(const u_int32_t jfsize_sblks, const u_int16_t fid):
+        nlfh(jfsize_sblks, fid)
 {}
 
 lfh::lfh(const std::string& fbasename, const u_int16_t fid, const u_int32_t jfsize_sblks,

Modified: store/trunk/cpp/lib/jrnl/lfh.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/lfh.hpp	2008-05-06 18:14:25 UTC (rev 2001)
+++ store/trunk/cpp/lib/jrnl/lfh.hpp	2008-05-06 19:39:27 UTC (rev 2002)
@@ -55,7 +55,7 @@
     class lfh : public nlfh
     {
     public:
-        lfh(const u_int32_t jfsize_sblks);
+        lfh(const u_int32_t jfsize_sblks, const u_int16_t fid);
         lfh(const std::string& fbasename, const u_int16_t fid, const u_int32_t jfsize_sblks,
                 rcvdat const * const ro);
         virtual ~lfh();

Modified: store/trunk/cpp/lib/jrnl/nlfh.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/nlfh.cpp	2008-05-06 18:14:25 UTC (rev 2001)
+++ store/trunk/cpp/lib/jrnl/nlfh.cpp	2008-05-06 19:39:27 UTC (rev 2002)
@@ -45,9 +45,9 @@
 namespace journal
 {
 
-nlfh::nlfh(const u_int32_t jfsize_sblks):
+nlfh::nlfh(const u_int32_t jfsize_sblks, const u_int16_t fid):
         _fname(),
-        _fid(0),
+        _fid(fid),
         _ffull_dblks(JRNL_SBLK_SIZE * (jfsize_sblks + 1)),
         _rd_fh(-1),
         _wr_fh(-1),
@@ -97,11 +97,7 @@
         const u_int32_t jfsize_sblks, const rcvdat* const ro)
 {
     _fid = fid;
-    std::ostringstream oss;
-    oss << fbasename << ".";
-    oss << std::setw(4) << std::setfill('0') << std::hex << fid;
-    oss << "." << JRNL_DATA_EXTENSION;
-    _fname = oss.str();
+    _fname = filename(fbasename, fid);
 
 #ifdef RHM_JOWRITE
     // In test mode, only create file if it does not exist
@@ -130,60 +126,7 @@
             }
         }
         else // Normal initialization: create empty journal files
-        {
-            const std::size_t sblksize = JRNL_DBLK_SIZE * JRNL_SBLK_SIZE;
-            const std::size_t writesize = sblksize * JRNL_WMGR_PAGE_SIZE;
-
-            // NOTE: The journal file size is always one sblock bigger than the specified journal
-            // file size, 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 sblock in size.
-            u_int32_t nsblks = jfsize_sblks + 1;
-
-            void* nullbuf = 0;
-            if (::posix_memalign(&nullbuf, sblksize, writesize))
-            {
-                std::ostringstream oss;
-                oss << ": posix_memalign() failed: size=" << writesize << " blk_size=" << sblksize;
-                oss << " errno=" << errno;
-                throw jexception(jerrno::JERR__MALLOC, oss.str(), "nlfh", "initialize");
-            }
-            std::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)
-            {
-                std::ostringstream oss;
-                oss << ": open() failed:" << "\" errno=" << errno;
-                std::free(nullbuf);
-                throw jexception(jerrno::JERR_NLFH_OPENWR, oss.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::ostringstream oss;
-                    oss << ": wr_size=" << (this_write_sblks * sblksize) << " errno=" << errno;
-                    ::close(fh);
-                    std::free(nullbuf);
-                    throw jexception(jerrno::JERR_NLFH_WRITE, oss.str(), "nlfh",
-                            "initialize");
-                }
-                nsblks -= this_write_sblks;
-            }
-
-            // Clean up
-            std::free(nullbuf);
-            if (::close(fh))
-            {
-                std::ostringstream oss;
-                oss << ": errno=" << errno;
-                throw jexception(jerrno::JERR_NLFH_CLOSE, oss.str(), "nlfh", "initialize");
-            }
-        }
+            create_jfile(jfsize_sblks);
 #ifdef RHM_JOWRITE
     }
 #endif
@@ -354,7 +297,7 @@
     {
         std::ostringstream oss;
         oss << "file=\"" << _fname << "\" errno=" << errno;
-        throw jexception(jerrno::JERR_NLFH_OPENRD, oss.str(), "nlfh", "open");
+        throw jexception(jerrno::JERR_NLFH_OPENRD, oss.str(), "nlfh", "open_fh");
     }
     _wr_fh = ::open(_fname.c_str(), O_WRONLY | O_DIRECT,
             S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // 0644 -rw-r--r--
@@ -362,7 +305,7 @@
     {
         std::ostringstream oss;
         oss << "file=\"" << _fname << "\" errno=" << errno;
-        throw jexception(jerrno::JERR_NLFH_OPENWR, oss.str(), "nlfh", "open");
+        throw jexception(jerrno::JERR_NLFH_OPENWR, oss.str(), "nlfh", "open_fh");
     }
 }
 
@@ -381,5 +324,100 @@
     }
 }
 
+std::string
+nlfh::filename(const std::string& fbasename, const u_int16_t fid)
+{
+    std::ostringstream oss;
+    oss << fbasename << ".";
+    oss << std::setw(4) << std::setfill('0') << std::hex << fid;
+    oss << "." << JRNL_DATA_EXTENSION;
+    return oss.str();
+}
+
+void
+nlfh::clean_file(const u_int32_t jfsize_sblks)
+{
+    // NOTE: The journal file size is always one sblock bigger than the specified journal
+    // file size, 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 sblock in size.
+    u_int32_t nsblks = jfsize_sblks + 1;
+
+    // TODO - look at more efficient alternatives to allocating a null block:
+    // 1. mmap() against /dev/zero, but can alignment for O_DIRECT be assured?
+    // 2. ftruncate(), but does this result in a sparse file? If so, then this is no good.
+    
+    // Create temp null block for writing
+    const std::size_t sblksize = JRNL_DBLK_SIZE * JRNL_SBLK_SIZE;
+    void* nullbuf = 0;
+    // Allocate no more than 2MB (4096 sblks) as a null buffer
+    const u_int32_t nullbuffsize_sblks = nsblks > 4096 ? 4096 : nsblks;
+    const std::size_t nullbuffsize = nullbuffsize_sblks * sblksize;
+    if (::posix_memalign(&nullbuf, sblksize, nullbuffsize))
+    {
+        std::ostringstream oss;
+        oss << ": posix_memalign() failed: size=" << nullbuffsize << " blk_size=" << sblksize;
+        oss << " errno=" << errno;
+        throw jexception(jerrno::JERR__MALLOC, oss.str(), "nlfh", "clean_file");
+    }
+    std::memset(nullbuf, 0, nullbuffsize);
+
+    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)
+    {
+        std::free(nullbuf);
+        std::ostringstream oss;
+        oss << ": open() failed:" << "\" errno=" << errno;
+        throw jexception(jerrno::JERR_NLFH_OPENWR, oss.str(), "nlfh", "clean_file");
+    }
+
+    while (nsblks > 0)
+    {
+        u_int32_t this_write_sblks = nsblks >= nullbuffsize_sblks ? nullbuffsize_sblks : nsblks;
+        if (::write(fh, nullbuf, this_write_sblks * sblksize) == -1)
+        {
+            ::close(fh);
+            std::free(nullbuf);
+            std::ostringstream oss;
+            oss << ": wr_size=" << (this_write_sblks * sblksize) << " errno=" << errno;
+            throw jexception(jerrno::JERR_NLFH_WRITE, oss.str(), "nlfh", "clean_file");
+        }
+        nsblks -= this_write_sblks;
+    }
+
+    // Clean up
+    std::free(nullbuf);
+    if (::close(fh))
+    {
+        std::ostringstream oss;
+        oss << ": errno=" << errno;
+        throw jexception(jerrno::JERR_NLFH_CLOSE, oss.str(), "nlfh", "clean_file");
+    }
+}
+
+void
+nlfh::create_jfile(const u_int32_t jfsize_sblks)
+{
+    clean_file(jfsize_sblks);
+}
+
+void
+nlfh::get_jfile()
+{
+    // Step 1: stat _pool_dir, locate first available file, check file size matches
+    // Step 2: move file to current directory
+}
+
+void return_jfile()
+{
+    // Step 1: Clean file (if req'd)
+    // Step 2: Move file to _pool_dir
+}
+
+
+// Static declarations
+
+std::string nlfh::_pool_dir;
+
 } // namespace journal
 } // namespace rhm

Modified: store/trunk/cpp/lib/jrnl/nlfh.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/nlfh.hpp	2008-05-06 18:14:25 UTC (rev 2001)
+++ store/trunk/cpp/lib/jrnl/nlfh.hpp	2008-05-06 19:39:27 UTC (rev 2002)
@@ -57,6 +57,7 @@
     class nlfh
     {
     protected:
+        static std::string _pool_dir;   ///< Directory containing unused file pool
         std::string _fname;             ///< File name
         u_int16_t _fid;                 ///< File ID (ordinal number in ring buffer)
         const u_int32_t _ffull_dblks;   ///< File size in dblks (incl. file header)
@@ -70,12 +71,15 @@
         u_int16_t _aio_cnt;             ///< Outstanding AIO operations on this file
 
     public:
-        nlfh(const u_int32_t jfsize_sblks);
+        nlfh(const u_int32_t jfsize_sblks, const u_int16_t fid);
         // Constructors with implicit initialize() and open()
         nlfh(const std::string& fbasename, const u_int16_t fid, const u_int32_t jfsize_sblks,
                 const rcvdat* const ro);
         virtual ~nlfh();
 
+        inline static std::string& pool_dir() { return _pool_dir; }
+        inline static void set_pool_dir(const std::string pool_dir) { _pool_dir = pool_dir; }
+        
         virtual void initialize(const std::string& fbasename, const u_int16_t fid,
                 const u_int32_t jfsize_sblks, const rcvdat* const ro);
         virtual bool reset(const rcvdat* const ro = 0);
@@ -141,6 +145,13 @@
     protected:
         virtual void open_fh();
         virtual void close_fh();
+        static std::string filename(const std::string& fbasename, const u_int16_t fid);
+        void clean_file(const u_int32_t jfsize_sblks);
+        void create_jfile(const u_int32_t jfsize_sblks);
+        
+        // These functions for future use of file pool
+        void get_jfile();
+        void return_jfile();
     };
 
 } // namespace journal

Modified: store/trunk/cpp/tests/jrnl/_ut_jdir.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_jdir.cpp	2008-05-06 18:14:25 UTC (rev 2001)
+++ store/trunk/cpp/tests/jrnl/_ut_jdir.cpp	2008-05-06 19:39:27 UTC (rev 2002)
@@ -86,7 +86,8 @@
 {
     timespec ts;
     ::clock_gettime(CLOCK_REALTIME, &ts);
-    jinf ji("test journal id", dirname, base_filename, NUM_JFILES, JFSIZE_SBLKS, ts);
+    jinf ji("test journal id", dirname, base_filename, NUM_JFILES, JFSIZE_SBLKS,
+            JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES, ts);
     ji.write();
 }
 

Modified: store/trunk/cpp/tests/jrnl/_ut_jinf.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_jinf.cpp	2008-05-06 18:14:25 UTC (rev 2001)
+++ store/trunk/cpp/tests/jrnl/_ut_jinf.cpp	2008-05-06 19:39:27 UTC (rev 2002)
@@ -145,7 +145,8 @@
 {
     cout << test_filename << ".write_constructor: " << flush;
     ::clock_gettime(CLOCK_REALTIME, &ts);
-    jinf ji(jid, jdir, base_filename, NUM_JFILES, JFSIZE_SBLKS, ts);
+    jinf ji(jid, jdir, base_filename, NUM_JFILES, JFSIZE_SBLKS, JRNL_WMGR_PAGE_SIZE,
+            JRNL_WMGR_PAGES, ts);
     BOOST_CHECK_EQUAL(ji.jver(), RHM_JDAT_VERSION);
     BOOST_CHECK(ji.jid().compare(jid) == 0);
     BOOST_CHECK(ji.jdir().compare(jdir) == 0);
@@ -157,10 +158,6 @@
     BOOST_CHECK_EQUAL(ji.jfsize_sblks(), (u_int32_t)JFSIZE_SBLKS);
     BOOST_CHECK_EQUAL(ji.sblk_size_dblks(), (u_int16_t)JRNL_SBLK_SIZE);
     BOOST_CHECK_EQUAL(ji.dblk_size(), (u_int32_t)JRNL_DBLK_SIZE);
-    BOOST_CHECK_EQUAL(ji.wmgr_page_size_dblks(), (u_int32_t)JRNL_WMGR_PAGE_SIZE);
-    BOOST_CHECK_EQUAL(ji.wmgr_num_pages(), (u_int32_t)JRNL_WMGR_PAGES);
-    BOOST_CHECK_EQUAL(ji.rmgr_page_size_dblks(), (u_int32_t)JRNL_RMGR_PAGE_SIZE);
-    BOOST_CHECK_EQUAL(ji.rmgr_num_pages(), (u_int32_t)JRNL_RMGR_PAGES);
     ji.write();
     cout << "ok" << endl;
 }
@@ -182,10 +179,6 @@
     BOOST_CHECK_EQUAL(ji.jfsize_sblks(), (u_int32_t)JFSIZE_SBLKS);
     BOOST_CHECK_EQUAL(ji.sblk_size_dblks(), (u_int16_t)JRNL_SBLK_SIZE);
     BOOST_CHECK_EQUAL(ji.dblk_size(), (u_int32_t)JRNL_DBLK_SIZE);
-    BOOST_CHECK_EQUAL(ji.wmgr_page_size_dblks(), (u_int32_t)JRNL_WMGR_PAGE_SIZE);
-    BOOST_CHECK_EQUAL(ji.wmgr_num_pages(), (u_int32_t)JRNL_WMGR_PAGES);
-    BOOST_CHECK_EQUAL(ji.rmgr_page_size_dblks(), (u_int32_t)JRNL_RMGR_PAGE_SIZE);
-    BOOST_CHECK_EQUAL(ji.rmgr_num_pages(), (u_int32_t)JRNL_RMGR_PAGES);
     cout << "ok" << endl;
 }
 




More information about the rhmessaging-commits mailing list