rhmessaging commits: r914 - in store/trunk/cpp: tests/jrnl and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-09-08 12:06:25 -0400 (Sat, 08 Sep 2007)
New Revision: 914
Modified:
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/tests/jrnl/Makefile.rtest
Log:
Added recursive abilities to rhm::journal::jdir directory create and delte methods; made most methods static.
Modified: store/trunk/cpp/lib/jrnl/jdir.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.cpp 2007-09-08 00:22:36 UTC (rev 913)
+++ store/trunk/cpp/lib/jrnl/jdir.cpp 2007-09-08 16:06:25 UTC (rev 914)
@@ -39,7 +39,7 @@
#include <sstream>
#include <sys/stat.h>
#include <jrnl/jerrno.hpp>
-
+#include <iostream>// debug only
namespace rhm
{
namespace journal
@@ -51,69 +51,99 @@
{
}
+// === create_dir ===
+
void
jdir::create_dir() throw (jexception)
{
- if (::mkdir(_dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
+ create_dir(_dirname);
+}
+
+
+void
+jdir::create_dir(const char* dirname) throw (jexception)
+{
+ create_dir(std::string(dirname));
+}
+
+
+void
+jdir::create_dir(const std::string& dirname) throw (jexception)
+{
+ size_t fdp = dirname.find_last_of('/');
+ if (fdp != std::string::npos)
{
- std::stringstream ss;
- ss << "dir=\"" << _dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_MKDIR, ss.str(), "jdir", "create_dir");
+ std::string parent_dir = dirname.substr(0, fdp);
+ if (!exists(parent_dir))
+ create_dir(parent_dir);
}
+ if (!exists(dirname))
+ {
+ 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::delete_dir() throw (jexception)
+
+// === clear_dir ===
+
+void
+jdir::clear_dir(const bool create_flag) throw (jexception)
{
+ clear_dir(_dirname, _base_filename, create_flag);
+}
- clear_dir(false); // cct hack -- TODO kpvdr to do the real deal...
+void
+jdir::clear_dir(const char* dirname, const char* base_filename, const bool create_flag)
+ throw (jexception)
+{
+ clear_dir(std::string(dirname), std::string(base_filename), create_flag);
}
void
-jdir::clear_dir(const bool create_flag) throw (jexception)
+jdir::clear_dir(const std::string& dirname, const std::string& base_filename,
+ const bool create_flag) throw (jexception)
{
- DIR* dir = opendir(_dirname.c_str());
+ DIR* dir = ::opendir(dirname.c_str());
if (!dir)
{
- if (errno == 2 && !create_flag) // ENOENT (No such file or 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(dirname);
+ return;
}
- 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");
- }
+ std::stringstream ss;
+ ss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str(), "jdir", "clear_dir");
}
#ifndef RHM_JOWRITE
struct dirent* entry;
bool found = false;
std::string bak_dir;
- while ((entry = readdir(dir)) != NULL)
+ 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 (strlen(entry->d_name) > base_filename.size())
{
- if (strncmp(entry->d_name, _base_filename.c_str(), _base_filename.size()) == 0)
+ if (strncmp(entry->d_name, base_filename.c_str(), base_filename.size()) == 0)
{
if (!found)
{
- create_bak_dir(bak_dir);
+ bak_dir = create_bak_dir(dirname, base_filename);
found = true;
}
std::stringstream oldname;
- oldname << _dirname << "/" << entry->d_name;
+ oldname << dirname << "/" << entry->d_name;
std::stringstream newname;
newname << bak_dir << "/" << entry->d_name;
- if (rename(oldname.str().c_str(), newname.str().c_str()))
+ if (::rename(oldname.str().c_str(), newname.str().c_str()))
{
std::stringstream ss;
ss << "file=\"" << oldname.str() << "\" dest=\"" <<
@@ -124,77 +154,208 @@
}
}
}
+ if (errno)
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << dirname << "\" errno=" << errno;
+ ::closedir(dir); // Try to close, it makes no sense to trap errors here...
+ throw jexception(jerrno::JERR_JDIR_READDIR, ss.str(), "jdir", "clear_dir");
+ }
#endif
- if (closedir(dir))
+ if (::closedir(dir))
{
std::stringstream ss;
- ss << "dir=\"" << _dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_DIRCLOSE, ss.str(), "jdir", "clear_dir");
+ ss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str(), "jdir", "clear_dir");
}
}
-std::string&
-jdir::create_bak_dir(std::string& str) throw (jexception)
+
+// === delete_dir ===
+
+void
+jdir::delete_dir() throw (jexception)
{
- DIR* dir = opendir(_dirname.c_str());
+ delete_dir(_dirname);
+}
+
+void
+jdir::delete_dir(const char* dirname) throw (jexception)
+{
+ delete_dir(std::string(dirname));
+}
+
+void
+jdir::delete_dir(const std::string& dirname) throw (jexception)
+{
+ struct dirent* entry;
+ struct stat s;
+ DIR* dir = ::opendir(dirname.c_str());
+ if (!dir)
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str(), "jdir", "delete_dir");
+ }
+ else
+ {
+ while ((entry = ::readdir(dir)) != NULL)
+ {
+ // Ignore . and ..
+ if (::strcmp(entry->d_name, ".") != 0 && ::strcmp(entry->d_name, "..") != 0)
+ {
+ std::string full_name(dirname + "/" + entry->d_name);
+ if (::stat(full_name.c_str(), &s))
+ {
+ std::stringstream ss;
+ ss << "stat: file=\"" << full_name << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_STAT, ss.str(), "jdir", "delete_dir");
+ }
+ // FIXME: This fn does not handle symbolic links correctly and throws up
+ // For some reason, S_ISLNK() fails to identify links correctly.
+ if (S_ISREG(s.st_mode) || S_ISLNK(s.st_mode)) // This is a file or slink
+ {
+ if(::unlink(full_name.c_str()))
+ {
+ std::stringstream ss;
+ ss << "unlink: file=\"" << entry->d_name << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_UNLINK, ss.str(), "jdir", "delete_dir");
+ }
+ }
+ else if (S_ISDIR(s.st_mode)) // This is a dir
+ {
+ delete_dir(full_name);
+ }
+ else // all other types, throw up!
+ {
+ std::stringstream ss;
+ ss << "file=\"" << entry->d_name << "\" is not a dir, file or slink.";
+ ss << " (mode=0x" << std::hex << s.st_mode << std::dec << ")";
+ throw jexception(jerrno::JERR_JDIR_BADFTYPE, ss.str(), "jdir", "delete_dir");
+ }
+ }
+ }
+ if (errno)
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << dirname << "\" errno=" << errno;
+ ::closedir(dir); // Try to close, it makes no sense to trap errors here...
+ throw jexception(jerrno::JERR_JDIR_READDIR, ss.str(), "jdir", "delete_dir");
+ }
+ }
+ // Now dir is empty, close and delete it
+ if (::closedir(dir))
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str(), "jdir", "delete_dir");
+ }
+ if (::rmdir(dirname.c_str()))
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_RMDIR, ss.str(), "jdir", "delete_dir");
+ }
+}
+
+
+std::string
+jdir::create_bak_dir(const std::string& dirname, const std::string& base_filename)
+ 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");
+ ss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str(), "jdir", "create_bak_dir");
}
struct dirent* entry;
- while ((entry = readdir(dir)) != NULL)
+ 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
+ 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)
+ 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);
+ 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))
+ if (errno)
{
std::stringstream ss;
- ss << "dir=\"" << _dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_DIRCLOSE, ss.str(), "jdir", "create_bak_dir");
+ ss << "dir=\"" << dirname << "\" errno=" << errno;
+ ::closedir(dir); // Try to close, it makes no sense to trap errors here...
+ throw jexception(jerrno::JERR_JDIR_READDIR, ss.str(), "jdir", "clear_dir");
}
+ if (::closedir(dir))
+ {
+ std::stringstream ss;
+ ss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str(), "jdir", "create_bak_dir");
+ }
std::stringstream dn;
- dn << _dirname << "/_" << _base_filename << ".bak." << std::hex << std::setw(4) <<
+ 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))
+ 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;
+ return std::string(dn.str());
}
const bool
+jdir::is_dir(const char* name) throw (jexception)
+{
+ struct stat s;
+ if (::stat(name, &s))
+ {
+ std::stringstream ss;
+ ss << "file=\"" << name << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_STAT, ss.str(), "jdir", "is_dir");
+ }
+ return S_ISDIR(s.st_mode);
+}
+
+const bool
jdir::is_dir(const std::string& name) throw (jexception)
{
+ return is_dir(name.c_str());
+}
+
+const bool
+jdir::exists(const char* name) throw (jexception)
+{
struct stat s;
- if (::stat(name.c_str(), &s))
+ if (::stat(name, &s))
{
+ if (errno == ENOENT) // No such dir or file
+ return false;
+ // Throw for any other condition
std::stringstream ss;
ss << "file=\"" << name << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_FSTAT, ss.str(), "jdir", "is_dir");
+ throw jexception(jerrno::JERR_JDIR_STAT, ss.str(), "jdir", "is_dir");
}
- return s.st_mode == S_IFDIR;
+ return true;
}
+const bool
+jdir::exists(const std::string& name) throw (jexception)
+{
+ return exists(name.c_str());
+}
+
std::ostream&
operator<<(std::ostream& os, const jdir& jdir)
{
Modified: store/trunk/cpp/lib/jrnl/jdir.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.hpp 2007-09-08 00:22:36 UTC (rev 913)
+++ store/trunk/cpp/lib/jrnl/jdir.hpp 2007-09-08 16:06:25 UTC (rev 914)
@@ -69,17 +69,42 @@
*/
jdir(const std::string& dirname, const std::string& base_filename);
+
/**
- * \brief Create jouirnal directory.
+ * \brief Create journal directory as set in the dirname parameter of the constructor.
+ * Recursive creation is supported.
+ *
+ * \expeption ??
*/
void create_dir() throw (jexception);
/**
+ * \brief Static function to create a directory. Recursive creation is supported.
+ *
+ * \param dirname C-string containing name of directory.
+ *
+ * \expeption ??
+ */
+ static void create_dir(const char* dirname) throw (jexception);
+
+ /**
+ * \brief Static function to create a directory. Recursive creation is supported.
+ *
+ * \param dirname String containing name of directory.
+ *
+ * \expeption ??
+ */
+ static void create_dir(const std::string& dirname) throw (jexception);
+
+
+ /**
* \brief Clear the journal directory of files matching the base filename
- * by moving them into a subdirectory.
+ * by moving them into a subdirectory. This fn uses the dirname and base_filename
+ * that were set on construction.
*
- * \param create_flag If set, create directory if it is non-existent,
- * throw exception otherwise.
+ * \param create_flag If set, create dirname if it is non-existent, otherwise throw
+ * exception.
+ *
* \exception The journal directory could not be opened.
* \exception The move of files from the journal directory to the created backup
* directory failed.
@@ -88,37 +113,114 @@
void clear_dir(const bool create_flag = true) throw (jexception);
/**
- * \brief Delete the journal directory of files matching the base filename
+ * \brief Clear the directory dirname of journal files matching base_filename
* by moving them into a subdirectory.
*
+ * \param dirname C-string containing name of journal directory.
+ * \param base_filename C-string containing base filename of journal files to be matched
+ * for moving into subdirectory.
+ * \param create_flag If set, create dirname if it is non-existent, otherwise throw
+ * exception
+ *
* \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.
*/
+ static void clear_dir(const char* dirname, const char* base_filename,
+ const bool create_flag = true) throw (jexception);
+
+ /**
+ * \brief Clear the directory dirname of journal files matching base_filename
+ * by moving them into a subdirectory.
+ *
+ * \param dirname String containing name of journal directory.
+ * \param base_filename String containing base filename of journal files to be matched
+ * for moving into subdirectory.
+ * \param create_flag If set, create dirname if it is non-existent, otherwise throw
+ * exception
+ *
+ * \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.
+ */
+ static void clear_dir(const std::string& dirname, const std::string& base_filename,
+ const bool create_flag = true) throw (jexception);
+
+ /**
+ * \brief Delete the journal directory and all files and sub--directories that it may
+ * contain. This is equivilent of rm -rf.
+ *
+ * FIXME: links are not handled correctly.
+ *
+ * \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 delete_dir() throw (jexception);
/**
- * \brief Create bakup directory that is next in sequence.
+ * \brief Delete the journal directory and all files and sub--directories that it may
+ * contain. This is equivilent of rm -rf.
*
- * Search for directory using pattern "_basename.bak.XXXX" where XXXX is a hexadecimal
- * sequence, and create next directory based on highest number found.
+ * FIXME: links are not handled correctly.
*
- * \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'.
+ * \param dirname C-string containing name of directory to be deleted.
+ *
* \exception The journal directory could not be opened.
- * \exception The creation of the new backup directory failed.
+ * \exception The move of files from the journal directory to the created backup
+ * directory failed.
* \exception The directory handle could not be closed.
*/
- std::string& create_bak_dir(std::string& str) throw (jexception);
+ static void delete_dir(const char* dirname) throw (jexception);
/**
+ * \brief Delete the journal directory and all files and sub--directories that it may
+ * contain. This is equivilent of rm -rf.
+ *
+ * FIXME: links are not handled correctly.
+ *
+ * \param dirname String containing name of directory to be deleted.
+ *
+ * \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.
+ */
+ static void delete_dir(const std::string& dirname) throw (jexception);
+
+ /**
+ * \brief Create bakup directory that is next in sequence and move all journal files
+ * matching base_filename into it.
+ *
+ * In directory dirname, search for existing backup directory using pattern
+ * "_basename.bak.XXXX" where XXXX is a hexadecimal sequence, and create next directory
+ * based on highest number found. Move all journal files which match the base_fileaname
+ * parameter into this new backup directory.
+ *
+ * \param dirname String containing name of journal directory.
+ * \param base_filename String containing base filename of journal files to be matched
+ * for moving into subdirectory.
+ *
+ * \exception ??
+ *
+ */
+ static std::string create_bak_dir(const std::string& dirname,
+ const std::string& base_filename) throw (jexception);
+
+ /**
* \brief Return the directory name as a string.
*/
inline const std::string& dirname() const { return _dirname; }
/**
+ * \brief Return the journal base filename name as a string.
+ */
+ inline const std::string& base_filename() const { return _base_filename; }
+
+ /**
* \brief Test whether the named file is a directory.
*
* \param name Name of file to be tested.
@@ -126,9 +228,55 @@
* otherwise.
* \exception The stat() operation failed on the named file.
*/
+ const static bool is_dir(const char* name) throw (jexception);
+
+ /**
+ * \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);
+
+ /**
+ * \brief Test whether the named entity exists on the filesystem.
+ *
+ * If stat() fails with error ENOENT, then this will return <b><i>false</i></b>. If
+ * stat() succeeds, then <b><i>true</i></b> is returned, irrespective of the file type.
+ * If stat() fails with any other error, an exception is thrown.
+ *
+ * \param name Name of entity to be tested.
+ * \return <b><i>true</i></b> if the named entity exists; <b><i>false</i></b>
+ * otherwise.
+ * \exception The stat() operation failed on the named entity.
+ */
+ const static bool exists(const char* name) throw (jexception);
+
+ /**
+ * \brief Test whether the named entity exists on the filesystem.
+ *
+ * If stat() fails with error ENOENT, then this will return <b><i>false</i></b>. If
+ * stat() succeeds, then <b><i>true</i></b> is returned, irrespective of the file type.
+ * If stat() fails with any other error, an exception is thrown.
+ *
+ * \param name Name of entity to be tested.
+ * \return <b><i>true</i></b> if the named entity exists; <b><i>false</i></b>
+ * otherwise.
+ * \exception The stat() operation failed on the named entity.
+ */
+ const static bool exists(const std::string& name) throw (jexception);
+
+ /**
+ * \brief Stream operator
+ */
friend std::ostream& operator<<(std::ostream& os, const jdir& jdir);
+
+ /**
+ * \brief Stream operator
+ */
friend std::ostream& operator<<(std::ostream& os, const jdir* jdirPtr);
};
Modified: store/trunk/cpp/lib/jrnl/jerrno.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.cpp 2007-09-08 00:22:36 UTC (rev 913)
+++ store/trunk/cpp/lib/jrnl/jerrno.cpp 2007-09-08 16:06:25 UTC (rev 914)
@@ -56,11 +56,14 @@
// 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;
+const u_int32_t jerrno::JERR_JDIR_OPENDIR = 0x0301;
+const u_int32_t jerrno::JERR_JDIR_READDIR = 0x0302;
+const u_int32_t jerrno::JERR_JDIR_CLOSEDIR = 0x0303;
+const u_int32_t jerrno::JERR_JDIR_RMDIR = 0x0304;
+const u_int32_t jerrno::JERR_JDIR_FMOVE = 0x0305;
+const u_int32_t jerrno::JERR_JDIR_STAT = 0x0306;
+const u_int32_t jerrno::JERR_JDIR_UNLINK = 0x0307;
+const u_int32_t jerrno::JERR_JDIR_BADFTYPE = 0x0308;
// class nlfh
const u_int32_t jerrno::JERR_NLFH_OPENRD = 0x0400;
@@ -113,12 +116,15 @@
// 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_OPENDIR] = std::string("JERR_JDIR_OPENDIR: Directory open failed.");
+ _err_map[JERR_JDIR_READDIR] = std::string("JERR_JDIR_READDIR: Directory read failed.");
+ _err_map[JERR_JDIR_CLOSEDIR] = std::string("JERR_JDIR_CLOSEDIR: Directory close failed.");
+ _err_map[JERR_JDIR_RMDIR] = std::string("JERR_JDIR_RMDIR: Directory delete 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.");
+ _err_map[JERR_JDIR_STAT] = std::string("JERR_JDIR_STAT: File stat failed.");
+ _err_map[JERR_JDIR_UNLINK] = std::string("JERR_JDIR_UNLINK: File delete failed.");
+ _err_map[JERR_JDIR_BADFTYPE] = std::string("JERR_JDIR_BADFTYPE: "
+ "Bad or unknown file type (stat mode).");
// class nlfh
_err_map[JERR_NLFH_OPENRD] = std::string("JERR_JNLFH_OPENRD: Unable to open file for read.");
Modified: store/trunk/cpp/lib/jrnl/jerrno.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.hpp 2007-09-08 00:22:36 UTC (rev 913)
+++ store/trunk/cpp/lib/jrnl/jerrno.hpp 2007-09-08 16:06:25 UTC (rev 914)
@@ -73,11 +73,14 @@
// 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_OPENDIR; ///< Directory open failed
+ static const u_int32_t JERR_JDIR_READDIR; ///< Directory read failed
+ static const u_int32_t JERR_JDIR_CLOSEDIR; ///< Directory close failed
+ static const u_int32_t JERR_JDIR_RMDIR; ///< Directory delete failed
static const u_int32_t JERR_JDIR_FMOVE; ///< File move failed
- static const u_int32_t JERR_JDIR_FSTAT; ///< File stat failed
+ static const u_int32_t JERR_JDIR_STAT; ///< File stat failed
+ static const u_int32_t JERR_JDIR_UNLINK; ///< File delete failed
+ static const u_int32_t JERR_JDIR_BADFTYPE; ///< Bad or unknown file type (stat mode)
// class nlfh
static const u_int32_t JERR_NLFH_OPENRD; ///< Unable to open file for read
Modified: store/trunk/cpp/tests/jrnl/Makefile.rtest
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-09-08 00:22:36 UTC (rev 913)
+++ store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-09-08 16:06:25 UTC (rev 914)
@@ -71,7 +71,7 @@
JTEST_FILES = jtest
CXX = g++
-CXXINCLUDES = -I. -I../../lib
+CXXINCLUDES = -I. -I../../lib -I../../../../qpid/cpp/src -I../../../../qpid/cpp/src/gen
CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -Wno-shadow -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wvolatile-register-var -Winvalid-pch -Wno-system-headers -pedantic -ggdb -O0 -pthread $(CXXINCLUDES)
LDFLAGS = -lpthread -laio -lrt
16 years, 9 months
rhmessaging commits: r913 - in store/trunk/cpp: lib/jrnl and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: cctrieloff
Date: 2007-09-07 20:22:36 -0400 (Fri, 07 Sep 2007)
New Revision: 913
Modified:
store/trunk/cpp/lib/BdbMessageStore.cpp
store/trunk/cpp/lib/BdbMessageStore.h
store/trunk/cpp/lib/Makefile.am
store/trunk/cpp/lib/StoreException.h
store/trunk/cpp/lib/jrnl/aio_cb.hpp
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/jcntl.hpp
store/trunk/cpp/lib/jrnl/jdir.cpp
store/trunk/cpp/lib/jrnl/jdir.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/wmgr.cpp
store/trunk/cpp/lib/jrnl/wmgr.hpp
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:
- added create / delete for async journal
- added enqueue logic
- integration updates with async journal
- still builds and test using bdb as defualt - set by runtime flag
- async callback handlers implented.
Modified: store/trunk/cpp/lib/BdbMessageStore.cpp
===================================================================
--- store/trunk/cpp/lib/BdbMessageStore.cpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/BdbMessageStore.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -30,6 +30,7 @@
#include "BindingDbt.h"
#include "IdPairDbt.h"
#include "StringDbt.h"
+#include <jrnl/jcntl.hpp>
using namespace rhm::bdbstore;
using namespace qpid::broker;
@@ -111,24 +112,51 @@
txn->commit(0);
}
-void BdbMessageStore::create(const PersistableQueue& queue)
+void BdbMessageStore::create(PersistableQueue& queue)
{
if (queue.getPersistenceId()) {
THROW_STORE_EXCEPTION("Queue already created: " + queue.getName());
}
+
+
+ if (usingJrnl())
+ {
+ journal::jcntl* jQueue = new journal::jcntl(queue.getName(), getJrnlDir(queue), string("JournalData"));
+ queue.setExternalQueueStore(dynamic_cast<ExternalQueueStore*>(jQueue));
+
+ try
+ {
+ // init will create the deque's for the init...
+ jQueue->initialize();
+
+ } catch (journal::jexception& e) {
+ std::string s;
+ THROW_STORE_EXCEPTION(e.to_string(s) + queue.getName());
+ }
+ }
+
try {
if (!create(queueDb, queueIdSequence, queue)) {
- THROW_STORE_EXCEPTION("Queue already exists: " + queue.getName());
+ THROW_STORE_EXCEPTION("Queue already exists: " + queue.getName());
}
} catch (DbException& e) {
- THROW_STORE_EXCEPTION_2("Error creating queue named " + queue.getName(), e);
+ THROW_STORE_EXCEPTION_2("Error creating queue named " + queue.getName(), e);
}
}
-void BdbMessageStore::destroy(const PersistableQueue& queue)
+void BdbMessageStore::destroy(PersistableQueue& queue)
{
destroy(queueDb, queue);
+ qpid::broker::ExternalQueueStore* eqs = queue.getExternalQueueStore();
+ journal::jcntl* jQueue = static_cast<journal::jcntl*>(eqs);
+ if (jQueue)
+ {
+ jQueue->delete_jrnl();
+ delete(jQueue);
+ queue.setExternalQueueStore(NULL);
+ }
+
}
void BdbMessageStore::create(const PersistableExchange& exchange)
@@ -472,7 +500,7 @@
try {
Dbt key (&messageId, sizeof(messageId));
messageId = messageIdSequence.next();
- store(txn.get(), key, msg);
+ store(NULL, txn.get(), key, msg);
msg.setPersistenceId(messageId);
txn.commit();
} catch (std::exception& e) {
@@ -592,14 +620,18 @@
try {
if (messageId == 0) {
messageId = messageIdSequence.next();
- store(txn->get(), key, msg);
+ store(&queue, txn->get(), key, msg);
msg.setPersistenceId(messageId);
- msg.enqueueComplete(); // set enqueued for ack
+ if (!usingJrnl())
+ msg.enqueueComplete(); // set enqueued for ack
}
- /// cct mapping db
- put(mappingDb, txn->get(), key, value);
- if (txn->isTPC()) {
+ if (!usingJrnl())
+ put(mappingDb, txn->get(), key, value);
+
+ // cct if using Journal do we need to wait for IO to complete before calling thus???
+ // set enqueue comple on callback msg.enqueueComplete();
+ if (txn->isTPC()) {
record2pcOp(enqueueXidDb, dynamic_cast<TPCTxnCtxt&>(*txn), messageId, queueId);
}
@@ -610,21 +642,57 @@
}
}
-void BdbMessageStore::store(DbTxn* txn, Dbt& messageId, PersistableMessage& message)
+void BdbMessageStore::store(const PersistableQueue* queue, DbTxn* txn, Dbt& messageId, PersistableMessage& message)
{
u_int32_t headerSize = message.encodedHeaderSize();
- u_int32_t totalSize = message.encodedSize();
- char* buff = static_cast<char*>(::alloca(totalSize + sizeof(u_int32_t)/*header length*/));
- Buffer buffer(buff, headerSize + sizeof(u_int32_t));
+ u_int64_t size = message.encodedSize() + sizeof(u_int32_t);
+ char* buff = static_cast<char*>(::alloca(size)); // long + headers + content
+ Buffer buffer(buff,size);
buffer.putLong(headerSize);
message.encode(buffer);
//buffer.flip();
+
+ try {
- Dbt data(buff, totalSize + sizeof(u_int32_t));
- try {
-
- /// cct message db
- messageDb.put(txn, &messageId, &data, DB_NOOVERWRITE);
+ if (queue && usingJrnl()){
+
+ // cct TODO -- delete this in the callback...
+ journal::data_tok* dtokp = new journal::data_tok();
+ dtokp->setSourceMessage (&message);
+ dtokp->set_rid(message.getPersistenceId()); // set the messageID into the Journal header (record-id)
+
+ unsigned aio_sleep_cnt = 0;
+ bool written = false;
+ while (!written)
+ {
+ journal::jcntl* jc = static_cast<journal::jcntl*>(queue->getExternalQueueStore());
+ rhm::journal::iores eres = jc->enqueue_data(buff, size, dtokp);
+ switch (eres)
+ {
+ case rhm::journal::RHM_IORES_SUCCESS:
+ if (dtokp->wstate() >= rhm::journal::data_tok::ENQ_SUBM)
+ written = true;
+ break;
+ case rhm::journal::RHM_IORES_AIO_WAIT:
+ if (aio_sleep_cnt >= MAX_AIO_SLEEPS)
+ THROW_STORE_EXCEPTION("Error storing message -- AIO timeout for: " + queue->getName());
+ usleep(AIO_SLEEP_TIME);
+ jc->get_wr_events();
+ aio_sleep_cnt++;
+ break;
+ case rhm::journal::RHM_IORES_FULL:
+ THROW_STORE_FULL_EXCEPTION("Error storing message -- Journal full :" + queue->getName());
+ break;
+ default:
+ assert( "Unexpected msg state");
+ }
+ }
+ } else {
+ /// cct message db
+ Dbt data(buff,size);
+ messageDb.put(txn, &messageId, &data, DB_NOOVERWRITE);
+ }
+
} catch (DbException& e) {
THROW_STORE_EXCEPTION_2("Error storing message", e);
}
@@ -860,3 +928,18 @@
THROW_STORE_EXCEPTION("Deletion failed: " + string(DbEnv::strerror(status)));
}
}
+
+string BdbMessageStore::getJrnlDir(const qpid::broker::PersistableQueue& queue) //for exmaple /var/rhm/ + queueDir/
+{
+ std::stringstream dir;
+ dir << "/var/rhm/" ;
+ dir << std::setw(4);
+ dir << std::setfill('0');
+ dir << (atol(queue.getName().c_str())%20);
+ dir << "/" << queue.getName() << "/";
+ return dir.str();
+}
+
+
+
+
Modified: store/trunk/cpp/lib/BdbMessageStore.h
===================================================================
--- store/trunk/cpp/lib/BdbMessageStore.h 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/BdbMessageStore.h 2007-09-08 00:22:36 UTC (rev 913)
@@ -43,7 +43,11 @@
namespace rhm {
namespace bdbstore {
using std::string;
-
+
+ #define MAX_AIO_SLEEPS 300
+ #define AIO_SLEEP_TIME 1000
+
+
/**
* An implementation of the MessageStore interface based on Berkeley DB
*/
@@ -81,7 +85,7 @@
void readXids(Db& db, std::set<string>& xids);
void readLockedMappings(Db& db, txn_lock_map& mappings);
TxnCtxt* check(qpid::broker::TransactionContext* ctxt);
- void store(DbTxn* txn, Dbt& messageId, qpid::broker::PersistableMessage& message);
+ void store(const qpid::broker::PersistableQueue* queue, DbTxn* txn, Dbt& messageId, qpid::broker::PersistableMessage& message);
void enqueue(DbTxn* txn, Dbt& messageId, Dbt& queueId);
bool dequeue(DbTxn* txn, Dbt& messageId, Dbt& queueId);
bool deleteIfUnused(Cursor& cursor, DbTxn* txn, Dbt& messageId);
@@ -95,6 +99,12 @@
void put(Db& db, DbTxn* txn, Dbt& key, Dbt& value);
bool deleteKeyValuePair(Db& db, DbTxn* txn, Dbt& key, Dbt& value);
void open(Db& db, DbTxn* txn, const char* file, bool dupKey);
+
+
+ // journal functions
+ void createJrnlQueue(const qpid::broker::PersistableQueue& queue);
+ string getJrnlDir(const qpid::broker::PersistableQueue& queue); //for exmaple /var/rhm/ + queueDir/
+ inline bool usingJrnl() {return false;} // make configurable
public:
BdbMessageStore(const char* envpath = 0);
@@ -102,8 +112,8 @@
void truncate();
- void create(const qpid::broker::PersistableQueue& queue);
- void destroy(const qpid::broker::PersistableQueue& queue);
+ void create(qpid::broker::PersistableQueue& queue);
+ void destroy(qpid::broker::PersistableQueue& queue);
void create(const qpid::broker::PersistableExchange& queue);
void destroy(const qpid::broker::PersistableExchange& queue);
Modified: store/trunk/cpp/lib/Makefile.am
===================================================================
--- store/trunk/cpp/lib/Makefile.am 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/Makefile.am 2007-09-08 00:22:36 UTC (rev 913)
@@ -72,6 +72,8 @@
jrnl/wmgr.hpp \
jrnl/wrfc.hpp
+
+
BUILT_SOURCES = db-inc.h
db-inc.h: Makefile.in
echo '#include <$(DB_CXX_HEADER_PREFIX)db_cxx.h>' > $@-t
Modified: store/trunk/cpp/lib/StoreException.h
===================================================================
--- store/trunk/cpp/lib/StoreException.h 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/StoreException.h 2007-09-08 00:22:36 UTC (rev 913)
@@ -37,11 +37,19 @@
const char* what() const throw() { return text.c_str(); }
};
+class StoreFullException : public StoreException
+{
+public:
+ StoreFullException(const std::string& _text) : StoreException(_text) {}
+ StoreFullException(const std::string& _text, DbException& cause) : StoreException(_text, cause) {}
+ ~StoreFullException() throw() {}
+};
+
#define THROW_STORE_EXCEPTION(MESSAGE) throw StoreException(boost::str(boost::format("%s (%s:%d)") % (MESSAGE) % __FILE__ % __LINE__))
#define THROW_STORE_EXCEPTION_2(MESSAGE, EXCEPTION) throw StoreException(boost::str(boost::format("%s (%s:%d)") % (MESSAGE) % __FILE__ % __LINE__), EXCEPTION)
+#define THROW_STORE_FULL_EXCEPTION(MESSAGE) throw StoreFullException(boost::str(boost::format("%s (%s:%d)") % (MESSAGE) % __FILE__ % __LINE__))
-
}}
#endif
Modified: store/trunk/cpp/lib/jrnl/aio_cb.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/aio_cb.hpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/aio_cb.hpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -37,10 +37,13 @@
{
namespace journal
{
+
+ class jcntl;
+
/**
* \brief Callback function pointer to be called when AIO events arrive.
*/
- typedef void (*aio_cb)(u_int32_t num_dtoks);
+ typedef void (*aio_cb)(jcntl* journal, u_int32_t num_dtoks);
}
}
Modified: store/trunk/cpp/lib/jrnl/data_tok.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/data_tok.cpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/data_tok.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -50,7 +50,8 @@
_rstate(UNREAD),
_dsize(0),
_dblks_proc(0),
- _rid(0)
+ _rid(0),
+ _sourceMsg(NULL)
{}
data_tok::~data_tok()
Modified: store/trunk/cpp/lib/jrnl/data_tok.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/data_tok.hpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/data_tok.hpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -41,11 +41,20 @@
}
}
+namespace qpid
+{
+namespace broker
+{
+class PersistableMessage;
+}
+}
+
#include <sys/types.h>
#include <jrnl/jexception.hpp>
namespace rhm
{
+
namespace journal
{
@@ -84,11 +93,15 @@
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
+ qpid::broker::PersistableMessage* _sourceMsg; ///< Pointer back to source Message in Broker
public:
data_tok();
~data_tok();
+ inline qpid::broker::PersistableMessage* getSourceMessage(){return _sourceMsg;}
+ inline void setSourceMessage(qpid::broker::PersistableMessage* msg) {_sourceMsg = msg;}
+
inline const u_int64_t id() const { return _icnt; }
inline const write_state wstate() const {return _wstate; }
const char* wstate_str() const;
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -39,6 +39,7 @@
#include <jrnl/jerrno.hpp>
#include <jrnl/jinf.hpp>
#include <sstream>
+#include <qpid/broker/PersistableMessage.h>
namespace rhm
{
@@ -58,8 +59,8 @@
_emap(),
_rrfc(),
_wrfc(),
- _rmgr(_emap, _rrfc),
- _wmgr(_emap, _wrfc)
+ _rmgr(this, _emap, _rrfc),
+ _wmgr(this, _emap, _wrfc)
{}
jcntl::~jcntl()
@@ -116,6 +117,18 @@
_init_flag = true;
}
+void
+jcntl::delete_jrnl() throw (jexception)
+{
+ stop();
+
+ // wait for AIO or issue cancel...
+
+ _jdir.delete_dir();
+
+}
+
+
const iores
jcntl::enqueue_data(const void* const dbuf, const size_t dlen, data_tok* const dtok)
throw (jexception)
@@ -190,5 +203,50 @@
of.close();
}
+void
+jcntl::aio_wr_callback(jcntl* journal, u_int32_t num_dtoks)
+{
+
+//kpvdr TODO -- can we get rid of the copy???
+ std::deque<rhm::journal::data_tok*> this_dtok_list(journal->_aio_wr_cmpl_dtok_list.begin(),
+ journal->_aio_wr_cmpl_dtok_list.end());
+ journal->_aio_wr_cmpl_dtok_list.clear();
+ for (u_int32_t i=0; i<num_dtoks; i++)
+ {
+ data_tok*& dtokp = this_dtok_list.front();
+ data_tok::write_state st = dtokp->wstate();
+ if (st == data_tok::ENQ)
+ {
+ dtokp->getSourceMessage()->enqueueComplete();
+ /// cct --- if TPC work out what to do !!!
+ }
+ else if (dtokp->wstate() == data_tok::DEQ)
+ {
+ dtokp->getSourceMessage()->dequeueComplete();
+ }
+ this_dtok_list.pop_front();
+ }
+}
+
+void
+jcntl::aio_rd_callback(jcntl* journal, u_int32_t num_dtoks)
+{
+//kpvdr TODO -- can we get rid of the copy???
+ std::deque<rhm::journal::data_tok*> this_dtok_list(journal->_aio_rd_cmpl_dtok_list.begin(),
+ journal->_aio_rd_cmpl_dtok_list.end());
+ journal->_aio_rd_cmpl_dtok_list.clear();
+ for (u_int32_t i=0; i<num_dtoks; i++)
+ {
+ data_tok*& dtokp = this_dtok_list.front();
+ if (dtokp->wstate() == data_tok::ENQ && dtokp->rstate() == data_tok::READ)
+ {
+ // cct call the recovery manager. / lazyload..
+ }
+ this_dtok_list.pop_front();
+ }
+}
+
+
+
} // namespace journal
} // namespace rhm
Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -41,11 +41,13 @@
}
}
+#include <deque>
#include <jrnl/jdir.hpp>
#include <jrnl/lfh.hpp>
#include <jrnl/rmgr.hpp>
#include <jrnl/wmgr.hpp>
#include <jrnl/wrfc.hpp>
+#include <qpid/broker/PersistableQueue.h>
namespace rhm
{
@@ -63,7 +65,7 @@
* 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
+ class jcntl : public qpid::broker::ExternalQueueStore
{
private:
/**
@@ -126,6 +128,9 @@
rmgr _rmgr; ///< Read page manager which manages AIO
wmgr _wmgr; ///< Write page manager which manages AIO
+ 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
+
public:
/**
* \brief Journal constructor.
@@ -152,6 +157,9 @@
* <b>NOTE: Any existing journal will be ignored by this operation.</b> To use recover
* the data from an existing journal, use recover().
*
+ * <b>NOTE: if NULL is passed to the deque's they are created internally and deleted intenally
+ * <b>NOTE: if NULL is passed to the callbacks internal ones will be used.
+ *
* \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)
@@ -159,9 +167,24 @@
* \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);
+ std::deque<data_tok*>* wr_dtokl, const aio_cb wr_cb) throw (jexception);
+ void initialize() {
+ initialize(&_aio_rd_cmpl_dtok_list, &aio_rd_callback, &_aio_wr_cmpl_dtok_list, &aio_wr_callback );
+ }
+
/**
+ * \brief Delete the journal directory of files matching the base filename
+ * by moving them into a subdirectory
+ *
+ * Stops AIO, stop journal, deletes files.....
+ *
+ * \exception The directory handle could not be closed.
+ */
+ void delete_jrnl() throw (jexception);
+
+
+ /**
* \brief Enqueues (writes) data to the journal.
*
* \param dbuf Pointer to data to be written to journal.
@@ -265,6 +288,8 @@
inline const std::string& base_filename() const { return _base_filename; }
+
+
private:
/**
* \brief Check status of journal before allowing certain operations.
@@ -276,6 +301,17 @@
*/
void write_infofile() const throw (jexception);
+ /**
+ * Intenal callback write
+ */
+ static void aio_wr_callback(jcntl* journal, u_int32_t num_dtoks);
+
+ /**
+ * Intenal callback write
+ */
+ static void aio_rd_callback(jcntl* journal, u_int32_t num_dtoks);
+
+
};
} // namespace journal
Modified: store/trunk/cpp/lib/jrnl/jdir.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.cpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/jdir.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -62,6 +62,14 @@
}
}
+void
+jdir::delete_dir() throw (jexception)
+{
+
+ clear_dir(false); // cct hack -- TODO kpvdr to do the real deal...
+}
+
+
void
jdir::clear_dir(const bool create_flag) throw (jexception)
{
Modified: store/trunk/cpp/lib/jrnl/jdir.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.hpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/jdir.hpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -88,6 +88,17 @@
void clear_dir(const bool create_flag = true) throw (jexception);
/**
+ * \brief Delete the journal directory of files matching the base filename
+ * by moving them into a subdirectory.
+ *
+ * \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 delete_dir() throw (jexception);
+
+ /**
* \brief Create bakup directory that is next in sequence.
*
* Search for directory using pattern "_basename.bak.XXXX" where XXXX is a hexadecimal
Modified: store/trunk/cpp/lib/jrnl/pmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -73,9 +73,10 @@
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):
+pmgr::pmgr(jcntl* jc, enq_map& emap, const u_int32_t pagesize, const u_int16_t pages):
_pagesize(pagesize),
_pages(pages),
+ _jc(jc),
_emap(emap),
_dtokl(NULL),
_page_base_ptr(NULL),
@@ -91,10 +92,11 @@
_cb(NULL)
{}
-pmgr::pmgr(enq_map& emap, const u_int32_t pagesize, const u_int16_t pages,
+pmgr::pmgr(jcntl* jc, 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),
+ _jc(jc),
_emap(emap),
_dtokl(dtokl),
_page_base_ptr(NULL),
Modified: store/trunk/cpp/lib/jrnl/pmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.hpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/pmgr.hpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -38,6 +38,7 @@
namespace journal
{
class pmgr;
+ class jcntl;
}
}
@@ -109,6 +110,7 @@
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
+ jcntl* _jc; ///< Pointer to journal controller
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
@@ -127,8 +129,8 @@
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,
+ pmgr(jcntl* jc, enq_map& emap, const u_int32_t pagesize, const u_int16_t pages);
+ pmgr(jcntl* jc, enq_map& emap, const u_int32_t pagesize, const u_int16_t pages,
std::deque<data_tok*>* const dtokl) throw (jexception);
virtual ~pmgr();
Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -42,14 +42,14 @@
namespace journal
{
-rmgr::rmgr(enq_map& emap, rrfc& rrfc):
- pmgr(emap, JRNL_RMGR_PAGE_SIZE, JRNL_RMGR_PAGES),
+rmgr::rmgr(jcntl* jc, enq_map& emap, rrfc& rrfc):
+ pmgr(jc, 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),
+rmgr::rmgr(jcntl* jc, enq_map& emap, rrfc& rrfc, std::deque<data_tok*>* const dtokl) throw (jexception):
+ pmgr(jc, emap, JRNL_RMGR_PAGE_SIZE, JRNL_RMGR_PAGES, dtokl),
_rrfc(rrfc),
_hdr()
{}
@@ -168,7 +168,7 @@
// Perform AIO return callback
if (_cb)
- (_cb)(s);
+ (_cb)(_jc, s);
}
return tot_data_toks;
Modified: store/trunk/cpp/lib/jrnl/rmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.hpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/rmgr.hpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -62,8 +62,8 @@
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(jcntl* jc, enq_map& emap, rrfc& rrfc);
+ rmgr(jcntl* jc, 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);
Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -42,8 +42,8 @@
namespace journal
{
-wmgr::wmgr(enq_map& emap, wrfc& wrfc):
- pmgr(emap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES),
+wmgr::wmgr(jcntl* jc, enq_map& emap, wrfc& wrfc):
+ pmgr(jc, emap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES),
_wrfc(wrfc),
_max_dtokpp(0),
_max_io_wait_us(0),
@@ -52,9 +52,9 @@
_enq_busy(false)
{}
-wmgr::wmgr(enq_map& emap, wrfc& wrfc, std::deque<data_tok*>* const dtokl,
+wmgr::wmgr(jcntl* jc, 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),
+ pmgr(jc, emap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES, dtokl),
_wrfc(wrfc),
_max_dtokpp(max_dtokpp),
_max_io_wait_us(max_iowait_us),
@@ -105,7 +105,12 @@
else
_enq_busy = true;
- u_int64_t rid = cont ? _wrfc.rid() - 1 : _wrfc.get_incr_rid();
+ u_int64_t rid;
+ if (dtok->getSourceMessage())
+ rid = dtok->rid();
+ else
+ rid = cont ? _wrfc.rid() - 1 : _wrfc.get_incr_rid();
+
_data_rec.reset(rid, mbuf, dlen);
if (!cont)
dtok->set_rid(rid);
@@ -388,7 +393,7 @@
// Perform AIO return callback
if (_cb && tot_data_toks)
- (_cb)(tot_data_toks);
+ (_cb)(_jc, tot_data_toks);
return tot_data_toks;
}
Modified: store/trunk/cpp/lib/jrnl/wmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.hpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/lib/jrnl/wmgr.hpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -79,8 +79,8 @@
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,
+ wmgr(jcntl* jc, enq_map& emap, wrfc& wrfc);
+ wmgr(jcntl* jc, 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();
Modified: store/trunk/cpp/tests/jrnl/JournalTest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -63,7 +63,7 @@
CPPUNIT_TEST(Test_023);
CPPUNIT_TEST(Test_024);
CPPUNIT_TEST(Test_025);
- CPPUNIT_TEST(Test_026);
+ CPPUNIT_TEST(Test_026);
CPPUNIT_TEST_SUITE_END();
jtest t;
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2007-09-08 00:22:36 UTC (rev 913)
@@ -21,7 +21,7 @@
abs_builddir=@abs_builddir@
-AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) -pthread -DRHM_CLEAN -DRHM_WRONLY -DRHM_TESTVALS
+AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) $(QPID_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-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -219,9 +219,9 @@
// static method
void
-jtest::mp_aio_cb(u_int32_t num_dtoks)
+jtest::mp_aio_cb(rhm::journal::jcntl* jc, u_int32_t num_dtoks)
{
- jtest::_mp.aio_callback(num_dtoks);
+ jtest::_mp.aio_callback(jc, num_dtoks);
}
// static method
Modified: store/trunk/cpp/tests/jrnl/jtest.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.hpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/tests/jrnl/jtest.hpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -97,7 +97,7 @@
string& report_time(string& str) const;
// AIO callback functions
- static void mp_aio_cb(u_int32_t num_dtoks);
+ static void mp_aio_cb(rhm::journal::jcntl* jc, u_int32_t num_dtoks);
};
#endif
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -182,7 +182,7 @@
}
void
-msg_consumer::aio_callback(u_int32_t num_dtoks)
+msg_consumer::aio_callback(rhm::journal::jcntl* /*jc*/, u_int32_t num_dtoks)
{
std::cout << "msg_consumer::aio_cb(" << num_dtoks << ")" << std::endl;
}
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -76,7 +76,7 @@
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);
+ void aio_callback(rhm::journal::jcntl* jc, 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; }
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -216,7 +216,7 @@
}
void
-msg_producer::aio_callback(u_int32_t num_dtoks)
+msg_producer::aio_callback(rhm::journal::jcntl* /*jc*/, 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(),
Modified: store/trunk/cpp/tests/jrnl/msg_producer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-09-07 10:27:55 UTC (rev 912)
+++ store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-09-08 00:22:36 UTC (rev 913)
@@ -86,7 +86,7 @@
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);
+ void aio_callback(rhm::journal::jcntl* jc, 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; }
16 years, 9 months
rhmessaging commits: r912 - in store/trunk/cpp: tests and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: gordonsim
Date: 2007-09-07 06:27:55 -0400 (Fri, 07 Sep 2007)
New Revision: 912
Modified:
store/trunk/cpp/lib/BdbMessageStore.cpp
store/trunk/cpp/tests/persistence.py
Log:
Fixes to get tests working again:
- on store buffer needs to be sized for the full message, not just the header
- change for XA_OK value
Modified: store/trunk/cpp/lib/BdbMessageStore.cpp
===================================================================
--- store/trunk/cpp/lib/BdbMessageStore.cpp 2007-09-06 13:10:59 UTC (rev 911)
+++ store/trunk/cpp/lib/BdbMessageStore.cpp 2007-09-07 10:27:55 UTC (rev 912)
@@ -613,13 +613,14 @@
void BdbMessageStore::store(DbTxn* txn, Dbt& messageId, PersistableMessage& message)
{
u_int32_t headerSize = message.encodedHeaderSize();
- char* buff = static_cast<char*>(::alloca(headerSize + sizeof(u_int32_t)/*header length*/));
+ u_int32_t totalSize = message.encodedSize();
+ char* buff = static_cast<char*>(::alloca(totalSize + sizeof(u_int32_t)/*header length*/));
Buffer buffer(buff, headerSize + sizeof(u_int32_t));
buffer.putLong(headerSize);
message.encode(buffer);
//buffer.flip();
- Dbt data(buff, headerSize + sizeof(u_int32_t));
+ Dbt data(buff, totalSize + sizeof(u_int32_t));
try {
/// cct message db
Modified: store/trunk/cpp/tests/persistence.py
===================================================================
--- store/trunk/cpp/tests/persistence.py 2007-09-06 13:10:59 UTC (rev 911)
+++ store/trunk/cpp/tests/persistence.py 2007-09-07 10:27:55 UTC (rev 912)
@@ -30,6 +30,10 @@
class PersistenceTest(qpid.testlib.TestBase):
+ XA_RBROLLBACK = 1
+ XA_RBTIMEOUT = 2
+ XA_OK = 0
+
def phase1(self):
channel = self.channel
@@ -190,10 +194,10 @@
for q in queues:
self.assertEqual(0, channel.queue_query(queue=q).message_count, "Bad count for %s" % (q))
- self.assertEqual(8, channel.dtx_coordination_commit(xid=txa, one_phase=True).status)
- self.assertEqual(8, channel.dtx_coordination_rollback(xid=txb).status)
- self.assertEqual(8, channel.dtx_coordination_prepare(xid=txc).status)
- self.assertEqual(8, channel.dtx_coordination_prepare(xid=txd).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_commit(xid=txa, one_phase=True).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_rollback(xid=txb).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_prepare(xid=txc).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_prepare(xid=txd).status)
#further checks
not_empty = ["queue-a2", "queue-b1"]
@@ -243,8 +247,8 @@
self.assertEqual(0, channel.queue_query(queue=q).message_count, "Bad count for %s" % (q))
#complete the prepared transactions
- self.assertEqual(8, channel.dtx_coordination_commit(xid=txc).status)
- self.assertEqual(8, channel.dtx_coordination_rollback(xid=txd).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_commit(xid=txc).status)
+ self.assertEqual(self.XA_OK, channel.dtx_coordination_rollback(xid=txd).status)
not_empty.append("queue-c2")
not_empty.append("queue-d1")
@@ -259,13 +263,13 @@
return pack('LBB', 0, len(txid), len(branchqual)) + txid + branchqual
def txswap(self, src, dest, tx):
- self.assertEqual(8, self.channel.dtx_demarcation_start(xid=tx).status)
+ self.assertEqual(self.XA_OK, 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(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)
+ self.assertEqual(self.XA_OK, self.channel.dtx_demarcation_end(xid=tx).status)
def assertEmptyQueue(self, name):
self.assertEqual(0, self.channel.queue_query(queue=name).message_count)
16 years, 9 months
rhmessaging commits: r911 - in store/trunk/cpp: tests/jrnl and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-09-06 09:10:59 -0400 (Thu, 06 Sep 2007)
New Revision: 911
Modified:
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/pmgr.cpp
store/trunk/cpp/lib/jrnl/wmgr.cpp
store/trunk/cpp/lib/jrnl/wrfc.cpp
store/trunk/cpp/lib/jrnl/wrfc.hpp
store/trunk/cpp/tests/jrnl/JournalTest.cpp
store/trunk/cpp/tests/jrnl/jtest.cpp
store/trunk/cpp/tests/jrnl/msg_producer.cpp
Log:
Solved possible static test interactions between runs of the tests
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -101,6 +101,7 @@
_datafh[i] = ::new lfh(ss.str(), i);
}
+ // TODO: Check the following comment/note (may be obsolete):
// 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).
Modified: store/trunk/cpp/lib/jrnl/pmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -123,6 +123,13 @@
{
std::stringstream ss;
+ // As static use of this class keeps old values around, clean up first...
+ _pg_index = 0;
+ _pg_cntr = 0;
+ _pg_offset_dblks = 0;
+ _aio_evt_rem = 0;
+ clean();
+
// 1. Allocate page memory (as a single block)
size_t pagesize = _pages * _pagesize * _sblksize;
if (::posix_memalign(&_page_base_ptr, _sblksize, pagesize))
Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -406,6 +406,8 @@
}
_page_cb_arr[0]._state = IN_USE;
_ddtokl.clear();
+ _cached_offset_dblks = 0;
+ _enq_busy = false;
}
const iores
Modified: store/trunk/cpp/lib/jrnl/wrfc.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wrfc.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/lib/jrnl/wrfc.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -52,6 +52,19 @@
wrfc::~wrfc() {}
+void
+wrfc::initialize(u_int32_t nfiles, nlfh** fh_arr, u_int32_t fh_index) throw (jexception)
+{
+ rrfc::initialize(nfiles, fh_arr, fh_index);
+#ifdef DRHM_TESTVALS
+ // TODO: Find method of specifying 64-bit literals under gcc with -pedantic option
+ _rid = u_int64_t(0xffeeddcc) << 32;
+#else
+ _rid = 0;
+#endif
+ _reset_ok = false;
+}
+
bool
wrfc::rotate() throw (jexception)
{
Modified: store/trunk/cpp/lib/jrnl/wrfc.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wrfc.hpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/lib/jrnl/wrfc.hpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -63,6 +63,16 @@
~wrfc();
/**
+ * \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().
*/
Modified: store/trunk/cpp/tests/jrnl/JournalTest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -72,7 +72,7 @@
const unsigned max_msg_szie, const bool auto_deq, const unsigned iterations,
const char* test_descr)
{
- std::cout << " " << test_descr << " " << std::flush;
+ 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++)
{
@@ -85,10 +85,8 @@
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;
+ std::string s;
+ CPPUNIT_FAIL(e.to_string(s));
}
t.finalize();
}
@@ -187,7 +185,8 @@
void Test_018()
{
- runJournalTest(8, 3933, 3933, true, 5, "8*(1/8 page - 1 dblk for deq record + 1 byte), auto-deq");
+ runJournalTest(8, 3933, 3933, true, 5,
+ "8*(1/8 page - 1 dblk for deq record + 1 byte), auto-deq");
}
void Test_019()
@@ -197,37 +196,39 @@
void Test_020()
{
- runJournalTest(33, 32732, 32732, false, 5, "33*(1 page exact fit)");
+ runJournalTest(33, 32732, 32732, false, 10, "33*(1 page exact fit)");
}
void Test_021()
{
- runJournalTest(22, 49116, 49116, false, 5, "22*(1.5 pages)");
+ runJournalTest(22, 49116, 49116, false, 10, "22*(1.5 pages)");
}
void Test_022()
{
- runJournalTest(22, 48988, 48988, true, 5, "22*(1.5 pages - 1 dblk for deq record), auto-deq");
+ runJournalTest(22, 48988, 48988, true, 10,
+ "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)");
+ runJournalTest(48, 32732, 32732, false, 10, "48*(1 page exact fit)");
}
void Test_024()
{
- runJournalTest(49, 32732, 32732, false, 5, "49*(1 page exact fit)");
+ runJournalTest(49, 32732, 32732, false, 10, "49*(1 page exact fit)");
}
void Test_025()
{
- runJournalTest(20, 81884, 81884, false, 5, "20*(2.5 pages)");
+ runJournalTest(20, 81884, 81884, false, 10, "20*(2.5 pages)");
}
void Test_026()
{
- runJournalTest(20, 81756, 81756, true, 5, "20*(2.5 pages - 1 dblk for deq record), auto-deq");
+ runJournalTest(20, 81756, 81756, true, 10,
+ "20*(2.5 pages - 1 dblk for deq record), auto-deq");
}
};
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -186,6 +186,16 @@
{
_mp.finalize();
_mc.finalize();
+ if (p_args)
+ {
+ delete p_args;
+ p_args = NULL;
+ }
+ if (c_args)
+ {
+ delete c_args;
+ c_args = NULL;
+ }
}
string&
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -137,7 +137,7 @@
}
rhm::journal::data_tok* dtokp = _dtok_master_list[msgCntr];
const void* const msg = (char*)_msg_buff + (msgCntr%10);
-//std::cout << "e" << dtokp->id() << "-" << dtokp->wstate_str() << " " << std::flush;
+//std::cout << "e" << dtokp->id() << /*"-" << dtokp->wstate_str() <<*/ " " << std::flush;
bool written = false;
while (!written)
{
@@ -305,7 +305,8 @@
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");
+ throw rhm::journal::jexception(EXCEPTION_BASE+4, ss.str(), "msg_producer",
+ "jrnl_flush");
}
//std::cout << "+" << std::flush;
jc.get_wr_events();
@@ -331,7 +332,8 @@
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");
+ throw rhm::journal::jexception(EXCEPTION_BASE+5, ss.str(), "msg_producer",
+ "jrnl_flush");
}
//std::cout << "*" << std::flush;
jc.get_wr_events();
16 years, 9 months
rhmessaging commits: r910 - store/trunk/cpp/docs.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-09-06 07:37:08 -0400 (Thu, 06 Sep 2007)
New Revision: 910
Modified:
store/trunk/cpp/docs/Makefile.am
Log:
Added missing doxygen template
Modified: store/trunk/cpp/docs/Makefile.am
===================================================================
--- store/trunk/cpp/docs/Makefile.am 2007-09-06 10:40:13 UTC (rev 909)
+++ store/trunk/cpp/docs/Makefile.am 2007-09-06 11:37:08 UTC (rev 910)
@@ -5,7 +5,7 @@
DOXYGEN = @DOXYGEN@
-EXTRA_DIST = html man #rhmj.pdf rhmj.ps
+EXTRA_DIST = jrnl_tmpl.dox html man #rhmj.pdf rhmj.ps
all: doxygen
16 years, 9 months
rhmessaging commits: r909 - store/trunk/cpp/lib.
by rhmessaging-commits@lists.jboss.org
Author: astitcher
Date: 2007-09-06 06:40:13 -0400 (Thu, 06 Sep 2007)
New Revision: 909
Modified:
store/trunk/cpp/lib/BdbMessageStore.cpp
store/trunk/cpp/lib/BindingDbt.cpp
store/trunk/cpp/lib/BindingDbt.h
store/trunk/cpp/lib/BufferValue.cpp
store/trunk/cpp/lib/BufferValue.h
Log:
* Fixed bdbstore for changes in framing::Buffer class in qpid
* There are still test assertion failures though
Modified: store/trunk/cpp/lib/BdbMessageStore.cpp
===================================================================
--- store/trunk/cpp/lib/BdbMessageStore.cpp 2007-09-05 19:22:25 UTC (rev 908)
+++ store/trunk/cpp/lib/BdbMessageStore.cpp 2007-09-06 10:40:13 UTC (rev 909)
@@ -333,14 +333,14 @@
IdDbt key;
size_t preamble_length = sizeof(u_int32_t)/*header size*/;
- BufferValue value(preamble_length, 0);
-
u_int64_t maxMessageId(1);
+ BufferValue value(preamble_length, 0);
+ value.buffer.record();
while (messages.next(key, value)) {
//read header only to begin with
u_int32_t headerSize = value.buffer.getLong();
- value.buffer.clear();
+ value.buffer.restore();
BufferValue header(headerSize, preamble_length);
messages.current(key, header);
@@ -612,13 +612,14 @@
void BdbMessageStore::store(DbTxn* txn, Dbt& messageId, PersistableMessage& message)
{
- Buffer buffer(message.encodedSize() + sizeof(u_int32_t)/*header length*/);
u_int32_t headerSize = message.encodedHeaderSize();
+ char* buff = static_cast<char*>(::alloca(headerSize + sizeof(u_int32_t)/*header length*/));
+ Buffer buffer(buff, headerSize + sizeof(u_int32_t));
buffer.putLong(headerSize);
message.encode(buffer);
- buffer.flip();
+ //buffer.flip();
- Dbt data(buffer.start(), buffer.available());
+ Dbt data(buff, headerSize + sizeof(u_int32_t));
try {
/// cct message db
Modified: store/trunk/cpp/lib/BindingDbt.cpp
===================================================================
--- store/trunk/cpp/lib/BindingDbt.cpp 2007-09-05 19:22:25 UTC (rev 908)
+++ store/trunk/cpp/lib/BindingDbt.cpp 2007-09-06 10:40:13 UTC (rev 909)
@@ -31,18 +31,22 @@
BindingDbt::BindingDbt(const PersistableExchange& e, const PersistableQueue& q, const string& k, const FieldTable& a)
- : buffer(encodedSize(e, q, k, a))
+ : data(new char[encodedSize(e, q, k, a)]),
+ buffer(data, encodedSize(e, q, k, a))
{
buffer.putLongLong(q.getPersistenceId());
buffer.putShortString(q.getName());
buffer.putShortString(k);
buffer.putFieldTable(a);
- buffer.flip();
- set_data(buffer.start());
- set_size(buffer.available());
+ set_data(data);
+ set_size(encodedSize(e, q, k, a));
}
+BindingDbt::~BindingDbt()
+{
+ delete [] data;
+}
uint32_t BindingDbt::encodedSize(const PersistableExchange& /*not used*/, const PersistableQueue& q, const string& k, const FieldTable& a)
{
Modified: store/trunk/cpp/lib/BindingDbt.h
===================================================================
--- store/trunk/cpp/lib/BindingDbt.h 2007-09-05 19:22:25 UTC (rev 908)
+++ store/trunk/cpp/lib/BindingDbt.h 2007-09-06 10:40:13 UTC (rev 909)
@@ -35,6 +35,7 @@
class BindingDbt : public Dbt
{
+ char* data;
qpid::framing::Buffer buffer;
static uint32_t encodedSize(const qpid::broker::PersistableExchange& e,
@@ -48,6 +49,8 @@
const std::string& k,
const qpid::framing::FieldTable& a);
+ ~BindingDbt();
+
};
}}
Modified: store/trunk/cpp/lib/BufferValue.cpp
===================================================================
--- store/trunk/cpp/lib/BufferValue.cpp 2007-09-05 19:22:25 UTC (rev 908)
+++ store/trunk/cpp/lib/BufferValue.cpp 2007-09-06 10:40:13 UTC (rev 909)
@@ -26,22 +26,29 @@
using namespace rhm::bdbstore;
using qpid::broker::Persistable;
-BufferValue::BufferValue(u_int32_t size, u_int64_t offset) : buffer(size)
+BufferValue::BufferValue(u_int32_t size, u_int64_t offset)
+ : data(new char[size]),
+ buffer(data, size)
{
- set_data(buffer.start());
- set_size(buffer.available());
+ set_data(data);
+ set_size(size);
set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
set_doff(offset);
- set_dlen(buffer.available());
- set_ulen(buffer.available());
+ set_dlen(size);
+ set_ulen(size);
}
-BufferValue::BufferValue(const Persistable& p) : buffer(p.encodedSize())
+BufferValue::BufferValue(const Persistable& p)
+ : data(new char[p.encodedSize()]),
+ buffer(data, p.encodedSize())
{
p.encode(buffer);
- buffer.flip();
- set_data(buffer.start());
- set_size(buffer.available());
+ set_data(data);
+ set_size(p.encodedSize());
}
+BufferValue::~BufferValue()
+{
+ delete [] data;
+}
Modified: store/trunk/cpp/lib/BufferValue.h
===================================================================
--- store/trunk/cpp/lib/BufferValue.h 2007-09-05 19:22:25 UTC (rev 908)
+++ store/trunk/cpp/lib/BufferValue.h 2007-09-06 10:40:13 UTC (rev 909)
@@ -33,11 +33,14 @@
class BufferValue : public Dbt
{
+ char* data;
+
public:
qpid::framing::Buffer buffer;
BufferValue(u_int32_t size, u_int64_t offset);
BufferValue(const qpid::broker::Persistable& p);
+ ~BufferValue();
};
}}
16 years, 9 months
rhmessaging commits: r908 - store/trunk/cpp.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-09-05 15:22:25 -0400 (Wed, 05 Sep 2007)
New Revision: 908
Modified:
store/trunk/cpp/Makefile.am
Log:
Corrected error in top-level Makefile.am
Modified: store/trunk/cpp/Makefile.am
===================================================================
--- store/trunk/cpp/Makefile.am 2007-09-05 19:05:28 UTC (rev 907)
+++ store/trunk/cpp/Makefile.am 2007-09-05 19:22:25 UTC (rev 908)
@@ -3,7 +3,7 @@
EXTRA_DIST = README
-SUBDIRS = lib tests
+SUBDIRS = lib tests docs
# Update libtool, if needed.
libtool: $(LIBTOOL_DEPS)
16 years, 9 months
rhmessaging commits: r907 - in store/trunk/cpp: docs and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-09-05 15:05:28 -0400 (Wed, 05 Sep 2007)
New Revision: 907
Modified:
store/trunk/cpp/Makefile.am
store/trunk/cpp/docs/Makefile.am
store/trunk/cpp/tests/jrnl/rwtests.csv
store/trunk/cpp/tests/jrnl/tests.ods
Log:
Disabled Latex compilation until doxygen latex generation problems are sorted out.
Modified: store/trunk/cpp/Makefile.am
===================================================================
--- store/trunk/cpp/Makefile.am 2007-09-05 16:14:52 UTC (rev 906)
+++ store/trunk/cpp/Makefile.am 2007-09-05 19:05:28 UTC (rev 907)
@@ -3,7 +3,7 @@
EXTRA_DIST = README
-SUBDIRS = lib tests docs
+SUBDIRS = lib tests
# Update libtool, if needed.
libtool: $(LIBTOOL_DEPS)
Modified: store/trunk/cpp/docs/Makefile.am
===================================================================
--- store/trunk/cpp/docs/Makefile.am 2007-09-05 16:14:52 UTC (rev 906)
+++ store/trunk/cpp/docs/Makefile.am 2007-09-05 19:05:28 UTC (rev 907)
@@ -5,24 +5,26 @@
DOXYGEN = @DOXYGEN@
-EXTRA_DIST = html man rhmj.pdf rhmj.ps
+EXTRA_DIST = html man #rhmj.pdf rhmj.ps
all: doxygen
man: doxygen
-rhmj: doxygen
+#rhmj: doxygen
-rhmj: doxygen
+#rhmj: doxygen
doxygen:
if DOXYGEN
@doxygen jrnl_tmpl.dox
- @make -C latex
- @cd latex; dvipdf refman.dvi refman.pdf
- @cd latex; dvips refman.dvi -o refman.ps
- @ln -fs latex/refman.pdf rhmj.pdf
- @ln -fs latex/refman.ps rhmj.ps
+# FIXME: doxygen seems to create files that do not compile under latex on 64-bit
+# so the following section is disabled until this is sorted out.
+# @make -C latex
+# @cd latex; dvipdf refman.dvi refman.pdf
+# @cd latex; dvips refman.dvi -o refman.ps
+# @ln -fs latex/refman.pdf rhmj.pdf
+# @ln -fs latex/refman.ps rhmj.ps
else
@echo "Doxygen not found during configuration; documentation skipped."
endif
Modified: store/trunk/cpp/tests/jrnl/rwtests.csv
===================================================================
--- store/trunk/cpp/tests/jrnl/rwtests.csv 2007-09-05 16:14:52 UTC (rev 906)
+++ store/trunk/cpp/tests/jrnl/rwtests.csv 2007-09-05 19:05:28 UTC (rev 907)
@@ -20,39 +20,48 @@
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)"
+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)"
,,,,,,
-"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)"
+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",,,,,,
-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"
+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",,,,,,
-40,16,786396,786396,FALSE,,"16 * (12 pages = ? file); Total = 8 files exactly"
+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)"
Modified: store/trunk/cpp/tests/jrnl/tests.ods
===================================================================
(Binary files differ)
16 years, 9 months
rhmessaging commits: r906 - store/trunk/cpp/docs.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-09-05 12:14:52 -0400 (Wed, 05 Sep 2007)
New Revision: 906
Modified:
store/trunk/cpp/docs/Makefile.am
Log:
Fixing man dependency
Modified: store/trunk/cpp/docs/Makefile.am
===================================================================
--- store/trunk/cpp/docs/Makefile.am 2007-09-05 15:55:05 UTC (rev 905)
+++ store/trunk/cpp/docs/Makefile.am 2007-09-05 16:14:52 UTC (rev 906)
@@ -9,6 +9,12 @@
all: doxygen
+man: doxygen
+
+rhmj: doxygen
+
+rhmj: doxygen
+
doxygen:
if DOXYGEN
@doxygen jrnl_tmpl.dox
16 years, 9 months
rhmessaging commits: r905 - in store/trunk/cpp: docs and 3 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-09-05 11:55:05 -0400 (Wed, 05 Sep 2007)
New Revision: 905
Added:
store/trunk/cpp/docs/Makefile.am
Modified:
store/trunk/cpp/Makefile.am
store/trunk/cpp/configure.ac
store/trunk/cpp/docs/
store/trunk/cpp/docs/jrnl_tmpl.dox
store/trunk/cpp/lib/
store/trunk/cpp/lib/jrnl/jcntl.hpp
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/rtest
Log:
Documentation now included in make; fixed minor issues
Modified: store/trunk/cpp/Makefile.am
===================================================================
--- store/trunk/cpp/Makefile.am 2007-09-04 20:37:27 UTC (rev 904)
+++ store/trunk/cpp/Makefile.am 2007-09-05 15:55:05 UTC (rev 905)
@@ -3,7 +3,7 @@
EXTRA_DIST = README
-SUBDIRS = lib tests
+SUBDIRS = lib tests docs
# Update libtool, if needed.
libtool: $(LIBTOOL_DEPS)
Modified: store/trunk/cpp/configure.ac
===================================================================
--- store/trunk/cpp/configure.ac 2007-09-04 20:37:27 UTC (rev 904)
+++ store/trunk/cpp/configure.ac 2007-09-05 15:55:05 UTC (rev 905)
@@ -164,12 +164,17 @@
# We use valgrind for the tests. See if it's available.
AC_CHECK_PROG([VALGRIND], [valgrind], [yes])
+# Also doxygen for documentation...
+AC_CHECK_PROG([do_doxygen], [doxygen], [yes])
+AM_CONDITIONAL([DOXYGEN], [test x$do_doxygen = xyes])
+
AC_CONFIG_FILES([
rhm.spec
Makefile
tests/Makefile
tests/jrnl/Makefile
lib/Makefile
+ docs/Makefile
])
AC_OUTPUT
Property changes on: store/trunk/cpp/docs
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
Added: store/trunk/cpp/docs/Makefile.am
===================================================================
--- store/trunk/cpp/docs/Makefile.am (rev 0)
+++ store/trunk/cpp/docs/Makefile.am 2007-09-05 15:55:05 UTC (rev 905)
@@ -0,0 +1,29 @@
+#
+# Run doxygen to generate HTML doc.
+# Generate dependency files so its rebuilt only when needed.
+#
+
+DOXYGEN = @DOXYGEN@
+
+EXTRA_DIST = html man rhmj.pdf rhmj.ps
+
+all: doxygen
+
+doxygen:
+if DOXYGEN
+ @doxygen jrnl_tmpl.dox
+ @make -C latex
+ @cd latex; dvipdf refman.dvi refman.pdf
+ @cd latex; dvips refman.dvi -o refman.ps
+ @ln -fs latex/refman.pdf rhmj.pdf
+ @ln -fs latex/refman.ps rhmj.ps
+else
+ @echo "Doxygen not found during configuration; documentation skipped."
+endif
+
+clean-local:
+ @rm -f rhmj.pdf
+ @rm -f rhmj.ps
+ @rm -rf latex
+ @rm -rf html
+ @rm -rf man
Modified: store/trunk/cpp/docs/jrnl_tmpl.dox
===================================================================
--- store/trunk/cpp/docs/jrnl_tmpl.dox 2007-09-04 20:37:27 UTC (rev 904)
+++ store/trunk/cpp/docs/jrnl_tmpl.dox 2007-09-05 15:55:05 UTC (rev 905)
@@ -30,7 +30,7 @@
# 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
+OUTPUT_DIRECTORY =
# 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
@@ -459,7 +459,7 @@
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = jrnl
+INPUT = ../lib/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
Property changes on: store/trunk/cpp/lib
___________________________________________________________________
Name: svn:ignore
- .deps
.libs
Makefile
Makefile.in
db-inc.h
+ .deps
.libs
Makefile
Makefile.in
db-inc.h
BdbMessageStore.loT
Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-09-04 20:37:27 UTC (rev 904)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-09-05 15:55:05 UTC (rev 905)
@@ -272,7 +272,7 @@
void check_status(const char* fn_name) const throw (jexception);
/**
- * \brief Write info file <basefilename>.jinf to disk
+ * \brief Write info file <basefilename>.jinf to disk
*/
void write_infofile() const throw (jexception);
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2007-09-04 20:37:27 UTC (rev 904)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2007-09-05 15:55:05 UTC (rev 905)
@@ -1,3 +1,24 @@
+# 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.
+
abs_builddir=@abs_builddir@
AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) -pthread -DRHM_CLEAN -DRHM_WRONLY -DRHM_TESTVALS
@@ -24,4 +45,4 @@
libdlclose_noop_la_SOURCES = ../dlclose_noop.c
libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir)
-EXTRA_DIST = $(TESTS) ftest.py
+EXTRA_DIST = $(TESTS) rtest ftest.py tests.ods rtests.csv rwtests.csv wtests.csv
Modified: store/trunk/cpp/tests/jrnl/Makefile.rtest
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-09-04 20:37:27 UTC (rev 904)
+++ store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-09-05 15:55:05 UTC (rev 905)
@@ -1,9 +1,47 @@
+# 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.
+
+
+# RHM Defines
+# The following defines are usable during the build of rhmj:
+# RHM_CLEAN: Writes 0xff 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)
+
SHELL = /bin/bash
-.SUFFIXES:
-.SUFFIXES: .cpp .o
-
RHM_JRNL_SRC_DIR = ../../lib/jrnl
+RHM_JRNL_DOC_DIR = ../../docs
VPATH = $(RHM_JRNL_SRC_DIR)
@@ -37,22 +75,33 @@
CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -Wno-shadow -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wvolatile-register-var -Winvalid-pch -Wno-system-headers -pedantic -ggdb -O0 -pthread $(CXXINCLUDES)
LDFLAGS = -lpthread -laio -lrt
+.SUFFIXES:
+.SUFFIXES: .cpp .o
+
.PHONY: jrtest jwtest jrwtest
default: jtest
help:
@echo "The following make options are available: (* is default)"
- @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 " jrwtest: Make the journal test suite for simultaneous write/read tests"
- @echo " check: Run complete regression test suite; compiles with special flags"
- @echo " clean: Clean build"
- @echo " clean-data: Clean journal data files"
- @echo " clean-all: Clean build and journal data files"
+ @echo " --- Building options ---"
+ @echo " all: Run check, build jtest and docs"
+ @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 " jrwtest: Make the journal test suite for simultaneous write/read tests"
+ @echo " --- Testing options ---"
+ @echo " check: Run complete regression test suite; compiles with special flags"
+ @echo " --- Documentation options ---"
+ @echo " help: This help message"
+ @echo " --- Cleaning options ---"
+ @echo " clean: Clean build"
+ @echo " clean-data: Clean journal data files"
+ @echo " clean-docs: Clean documtentation"
+ @echo " clean-all: Clean build, journal data files and documentation"
-# Build all journal and test object files, produces jtest executable
+all: check jtest
+
jtest: $(JRNL_OBJ_FILES) $(JTEST_OBJ_FILES)
jrtest: RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY -DRHM_TESTVALS
Modified: store/trunk/cpp/tests/jrnl/chk_jdata
===================================================================
--- store/trunk/cpp/tests/jrnl/chk_jdata 2007-09-04 20:37:27 UTC (rev 904)
+++ store/trunk/cpp/tests/jrnl/chk_jdata 2007-09-05 15:55:05 UTC (rev 905)
@@ -4,7 +4,7 @@
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
+for f in jdata/test.*.jdat; do
echo $f
hexdump -C -n 1024 $f
hexdump -C -s ${END_OFFSET} $f
Modified: store/trunk/cpp/tests/jrnl/rtest
===================================================================
--- store/trunk/cpp/tests/jrnl/rtest 2007-09-04 20:37:27 UTC (rev 904)
+++ store/trunk/cpp/tests/jrnl/rtest 2007-09-05 15:55:05 UTC (rev 905)
@@ -56,7 +56,7 @@
RM_DIR="${RM} -rf"
TEST_PROG="./jtest"
CHK_PROG="./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"
+VALGRIND="valgrind -q --track-fds=yes --leak-check=full --leak-resolution=high --show-reachable=yes"
MAKE="make -f Makefile.rtest"
16 years, 9 months