rhmessaging commits: r3735 - in store/trunk/cpp: lib/jrnl and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2009-12-03 16:01:30 -0500 (Thu, 03 Dec 2009)
New Revision: 3735
Modified:
store/trunk/cpp/lib/MessageStoreImpl.cpp
store/trunk/cpp/lib/MessageStoreImpl.h
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jdir.cpp
store/trunk/cpp/lib/jrnl/jdir.hpp
store/trunk/cpp/tools/resize
Log:
Updates to the persistence id recovery logic, also a new push down function (in jdir this time) which creates a serialized backup dir instead of deleting the previous bak dir.
Modified: store/trunk/cpp/lib/MessageStoreImpl.cpp
===================================================================
--- store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-12-03 15:42:14 UTC (rev 3734)
+++ store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-12-03 21:01:30 UTC (rev 3735)
@@ -373,33 +373,6 @@
}
}
-void MessageStoreImpl::pushDown(const std::string& dirName, const std::string& targetDir, const std::string& bakDirName)
-{
- DIR* dir = ::opendir(dirName.c_str());
- if (dir)
- {
- std::ostringstream oss;
- oss << dirName << "/" << bakDirName;
- // Delete bak dir if it exists
- mrg::journal::jdir::delete_dir(oss.str());
- // Create new bak dir
- mrg::journal::jdir::create_dir(oss.str());
-
- // Copy contents of targetDir into bak dir
- struct dirent* entry;
- while ((entry = ::readdir(dir)) != 0) {
- // Search for targetDir in dirName
- if (std::strcmp(entry->d_name, targetDir.c_str()) == 0) {
- std::ostringstream oldname;
- oldname << dirName << "/" << targetDir;
- std::ostringstream newname;
- newname << oss.str() << "/" << targetDir;
- ::rename(oldname.str().c_str(), newname.str().c_str());
- }
- }
- }
-}
-
void MessageStoreImpl::truncateInit(const bool pushDownStoreFiles)
{
if (isInit) {
@@ -415,12 +388,12 @@
if (tplStorePtr->is_ready()) tplStorePtr->stop(true);
dbenv->close(0);
}
- if (pushDownStoreFiles)
- pushDown(storeDir, storeTopLevelDir, "cluster_bak");
- else {
- std::ostringstream oss;
- oss << storeDir << "/" << storeTopLevelDir;
- QPID_LOG(notice, "Store in " << oss.str() << " truncated.");
+ std::ostringstream oss;
+ oss << storeDir << "/" << storeTopLevelDir;
+ if (pushDownStoreFiles) {
+ QPID_LOG(notice, "Store directory " << oss.str() << " was pushed down into directory " << mrg::journal::jdir::push_down(storeDir, storeTopLevelDir, "cluster") << ".");
+ } else {
+ QPID_LOG(notice, "Store directory " << oss.str() << " was truncated.");
mrg::journal::jdir::delete_dir(oss.str().c_str());
}
init();
@@ -793,11 +766,12 @@
{
long rcnt = 0L; // recovered msg count
long idcnt = 0L; // in-doubt msg count
- u_int64_t thisHighestRid = 0;
+ u_int64_t thisHighestRid = 0ULL;
jQueue->recover(numJrnlFiles, autoJrnlExpand, autoJrnlExpandMaxFiles, jrnlFsizeSblks, wCacheNumPages, wCachePgSizeSblks, &prepared, thisHighestRid, key.id); // start recovery
- // RFC 1982 comparison for unsigned 64-bit
- if (thisHighestRid - highestRid < 0x8000000000000000ULL)
+ if (highestRid == 0ULL)
highestRid = thisHighestRid;
+ else if (thisHighestRid - highestRid < 0x8000000000000000ULL) // RFC 1982 comparison for unsigned 64-bit
+ highestRid = thisHighestRid;
recoverMessages(txn, registry, queue, prepared, messages, rcnt, idcnt);
QPID_LOG(info, "Recovered queue \"" << queueName << "\": " << rcnt << " messages recovered; " << idcnt << " messages in-doubt.");
jQueue->recover_complete(); // start journal.
@@ -1188,11 +1162,12 @@
void MessageStoreImpl::recoverTplStore()
{
if (journal::jdir::exists(tplStorePtr->jrnl_dir() + tplStorePtr->base_filename() + ".jinf")) {
- u_int64_t thisHighestRid;
+ u_int64_t thisHighestRid = 0ULL;
tplStorePtr->recover(tplNumJrnlFiles, false, 0, tplJrnlFsizeSblks, tplWCachePgSizeSblks, tplWCacheNumPages, 0, thisHighestRid, 0);
- // RFC 1982 comparison for unsigned 64-bit
- if (thisHighestRid - highestRid < 0x8000000000000000ULL)
+ if (highestRid == 0ULL)
highestRid = thisHighestRid;
+ else if (thisHighestRid - highestRid < 0x8000000000000000ULL) // RFC 1982 comparison for unsigned 64-bit
+ highestRid = thisHighestRid;
// Load tplRecoverMap by reading the TPL store
readTplStore();
Modified: store/trunk/cpp/lib/MessageStoreImpl.h
===================================================================
--- store/trunk/cpp/lib/MessageStoreImpl.h 2009-12-03 15:42:14 UTC (rev 3734)
+++ store/trunk/cpp/lib/MessageStoreImpl.h 2009-12-03 21:01:30 UTC (rev 3735)
@@ -169,8 +169,6 @@
void init();
- void pushDown(const std::string& dir, const std::string& targetDir, const std::string& bakDirName = "bak");
-
void recoverQueues(TxnCtxt& txn,
qpid::broker::RecoveryManager& recovery,
queue_index& index,
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2009-12-03 15:42:14 UTC (rev 3734)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2009-12-03 21:01:30 UTC (rev 3735)
@@ -932,9 +932,10 @@
throw jexception(jerrno::JERR_JCNTL_OWIMISMATCH, oss.str(), "jcntl",
"check_owi");
}
- // RFC 1982 comparison for unsigned 64-bit
- if (h._rid - rd._h_rid < 0x8000000000000000ULL)
+ if (rd._h_rid == 0)
rd._h_rid = h._rid;
+ else if (h._rid - rd._h_rid < 0x8000000000000000ULL) // RFC 1982 comparison for unsigned 64-bit
+ rd._h_rid = h._rid;
return true;
}
Modified: store/trunk/cpp/lib/jrnl/jdir.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.cpp 2009-12-03 15:42:14 UTC (rev 3734)
+++ store/trunk/cpp/lib/jrnl/jdir.cpp 2009-12-03 21:01:30 UTC (rev 3735)
@@ -168,7 +168,43 @@
close_dir(dir, dirname, "clear_dir");
}
+// === push_down ===
+std::string
+jdir::push_down(const std::string& dirname, const std::string& target_dir, const std::string& bak_dir_base)
+{
+ std::string bak_dir_name = create_bak_dir(dirname, bak_dir_base);
+
+ DIR* dir = ::opendir(dirname.c_str());
+ if (!dir)
+ {
+ std::ostringstream oss;
+ oss << "dir=\"" << dirname << "\"" << FORMAT_SYSERR(errno);
+ throw jexception(jerrno::JERR_JDIR_OPENDIR, oss.str(), "jdir", "push_down");
+ }
+ // Copy contents of targetDirName into bak dir
+ struct dirent* entry;
+ while ((entry = ::readdir(dir)) != 0)
+ {
+ // Search for targetDirName in storeDirName
+ if (std::strcmp(entry->d_name, target_dir.c_str()) == 0)
+ {
+ std::ostringstream oldname;
+ oldname << dirname << "/" << target_dir;
+ std::ostringstream newname;
+ newname << bak_dir_name << "/" << target_dir;
+ if (::rename(oldname.str().c_str(), newname.str().c_str()))
+ {
+ std::ostringstream oss;
+ oss << "file=\"" << oldname.str() << "\" dest=\"" << newname.str() << "\"" << FORMAT_SYSERR(errno);
+ throw jexception(jerrno::JERR_JDIR_FMOVE, oss.str(), "jdir", "push_down");
+ }
+ break;
+ }
+ }
+ return bak_dir_name;
+}
+
// === verify_dir ===
void
Modified: store/trunk/cpp/lib/jrnl/jdir.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.hpp 2009-12-03 15:42:14 UTC (rev 3734)
+++ store/trunk/cpp/lib/jrnl/jdir.hpp 2009-12-03 21:01:30 UTC (rev 3735)
@@ -153,7 +153,21 @@
const bool create_flag = true);
+
/**
+ * \brief Move (push down) the directory target_dir located in directory dirname into a backup directory
+ * named _bak_dir_base.XXXX (note prepended underscore), where XXXX is an increasing hex serial number
+ * starting at 0000.
+ *
+ * \param dirname Full path to directory containing directory to be pushed down.
+ * \param target_dir Name of directory in dirname to be pushed down.
+ * \param bak_dir_base Base name for backup directory to be created in dirname, into which target_dir will be moved.
+ * \return Name of backup dir into which target_dir was pushed.
+ */
+ static std::string push_down(const std::string& dirname, const std::string& target_dir, const std::string& bak_dir_base);
+
+
+ /**
* \brief Verify that dirname is a valid %journal directory.
*
* The validation reads the .%jinf file, and using this information verifies that all the expected %journal
Modified: store/trunk/cpp/tools/resize
===================================================================
--- store/trunk/cpp/tools/resize 2009-12-03 15:42:14 UTC (rev 3734)
+++ store/trunk/cpp/tools/resize 2009-12-03 21:01:30 UTC (rev 3735)
@@ -193,7 +193,7 @@
elif self._fNum == self._jrnlInfo.getNumJrnlFiles() - 1: return False
else: self._fNum += 1
self._fileRecWrCnt = 0
- self._fName = os.path.join(self._jrnlInfo.getJrnlDir(), "%s.%04d.jdat" % (self._jrnlInfo.getJrnlBaseName(), self._fNum))
+ self._fName = os.path.join(self._jrnlInfo.getJrnlDir(), "%s.%04x.jdat" % (self._jrnlInfo.getJrnlBaseName(), self._fNum))
if self._opts.vflag: print "* Opening file %s" % self._fName,
self._file = open(self._fName, "w")
if rid == None or fro == None:
16 years, 5 months
rhmessaging commits: r3734 - store/trunk/cpp/lib/jrnl.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2009-12-03 10:42:14 -0500 (Thu, 03 Dec 2009)
New Revision: 3734
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
Log:
Tidied up some common code in jdir class, fixed up some of its documentation.
Modified: store/trunk/cpp/lib/jrnl/jdir.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.cpp 2009-12-03 10:00:25 UTC (rev 3733)
+++ store/trunk/cpp/lib/jrnl/jdir.cpp 2009-12-03 15:42:14 UTC (rev 3734)
@@ -35,7 +35,6 @@
#include <cstdlib>
#include <cstring>
-#include <dirent.h>
#include <cerrno>
#include <iomanip>
#include "jrnl/jcfg.hpp"
@@ -164,20 +163,9 @@
}
// FIXME: Find out why this fails with false alarms/errors from time to time...
// While commented out, there is no error capture from reading dir entries.
-// if (errno)
-// {
-// std::ostringstream oss;
-// oss << "dir=\"" << dirname << "\"" << FORMAT_SYSERR(errno);
-// ::closedir(dir); // Try to close, it makes no sense to trap errors here...
-// throw jexception(jerrno::JERR_JDIR_READDIR, oss.str(), "jdir", "clear_dir");
-// }
+// check_err(errno, dir, dirname, "clear_dir");
#endif
- if (::closedir(dir))
- {
- std::ostringstream oss;
- oss << "dir=\"" << dirname << "\"" << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR_JDIR_CLOSEDIR, oss.str(), "jdir", "clear_dir");
- }
+ close_dir(dir, dirname, "clear_dir");
}
@@ -287,23 +275,13 @@
}
}
}
+
// FIXME: Find out why this fails with false alarms/errors from time to time...
// While commented out, there is no error capture from reading dir entries.
-// if (errno)
-// {
-// std::ostringstream oss;
-// oss << "dir=\"" << dirname << "\"" << FORMAT_SYSERR(errno);
-// ::closedir(dir); // Try to close, it makes no sense to trap errors here...
-// throw jexception(jerrno::JERR_JDIR_READDIR, oss.str(), "jdir", "delete_dir");
-// }
+// check_err(errno, dir, dirname, "delete_dir");
}
// Now dir is empty, close and delete it
- if (::closedir(dir))
- {
- std::ostringstream oss;
- oss << "dir=\"" << dirname << "\"" << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR_JDIR_CLOSEDIR, oss.str(), "jdir", "delete_dir");
- }
+ close_dir(dir, dirname, "delete_dir");
if (!children_only)
if (::rmdir(dirname.c_str()))
@@ -347,19 +325,9 @@
}
// FIXME: Find out why this fails with false alarms/errors from time to time...
// While commented out, there is no error capture from reading dir entries.
-// if (errno)
-// {
-// std::ostringstream oss;
-// oss << "dir=\"" << dirname << "\"" << FORMAT_SYSERR(errno);
-// ::closedir(dir); // Try to close, it makes no sense to trap errors here...
-// throw jexception(jerrno::JERR_JDIR_READDIR, oss.str(), "jdir", "clear_dir");
-// }
- if (::closedir(dir))
- {
- std::ostringstream oss;
- oss << "dir=\"" << dirname << "\"" << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR_JDIR_CLOSEDIR, oss.str(), "jdir", "create_bak_dir");
- }
+// check_err(errno, dir, dirname, "create_bak_dir");
+ close_dir(dir, dirname, "create_bak_dir");
+
std::ostringstream dn;
dn << dirname << "/_" << base_filename << ".bak." << std::hex << std::setw(4) <<
std::setfill('0') << ++dir_num;
@@ -413,6 +381,29 @@
return exists(name.c_str());
}
+void
+jdir::check_err(const int err_num, DIR* dir, const std::string& dir_name, const std::string& fn_name)
+{
+ if (err_num)
+ {
+ std::ostringstream oss;
+ oss << "dir=\"" << dir_name << "\"" << FORMAT_SYSERR(err_num);
+ ::closedir(dir); // Try to close, it makes no sense to trap errors here...
+ throw jexception(jerrno::JERR_JDIR_READDIR, oss.str(), "jdir", fn_name);
+ }
+}
+
+void
+jdir::close_dir(DIR* dir, const std::string& dir_name, const std::string& fn_name)
+{
+ if (::closedir(dir))
+ {
+ std::ostringstream oss;
+ oss << "dir=\"" << dir_name << "\"" << FORMAT_SYSERR(errno);
+ throw jexception(jerrno::JERR_JDIR_CLOSEDIR, oss.str(), "jdir", fn_name);
+ }
+}
+
std::ostream&
operator<<(std::ostream& os, const jdir& jdir)
{
Modified: store/trunk/cpp/lib/jrnl/jdir.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.hpp 2009-12-03 10:00:25 UTC (rev 3733)
+++ store/trunk/cpp/lib/jrnl/jdir.hpp 2009-12-03 15:42:14 UTC (rev 3734)
@@ -3,8 +3,8 @@
*
* Qpid asynchronous store plugin library
*
- * File containing code for class mrg::journal::jdir (journal data
- * directory), used for controlling and manipulating journal data
+ * File containing code for class mrg::journal::jdir (%journal data
+ * directory), used for controlling and manipulating %journal data
* directories and files. See class documentation for details.
*
* \author Kim van der Riet
@@ -43,6 +43,7 @@
}
#include "jrnl/jinf.hpp"
+#include <dirent.h>
namespace mrg
{
@@ -51,7 +52,7 @@
/**
* \class jdir
- * \brief Class to manage the journal directory
+ * \brief Class to manage the %journal directory
*/
class jdir
{
@@ -65,7 +66,7 @@
* \brief Sole constructor
*
* \param dirname Name of directory to be managed.
- * \param base_filename Filename root used in the creation of journal files
+ * \param base_filename Filename root used in the creation of %journal files
* and sub-directories.
*/
jdir(const std::string& dirname, const std::string& base_filename);
@@ -74,10 +75,10 @@
/**
- * \brief Create journal directory as set in the dirname parameter of the constructor.
+ * \brief Create %journal directory as set in the dirname parameter of the constructor.
* Recursive creation is supported.
*
- * \exception ??
+ * \exception jerrno::JERR_JDIR_MKDIR The creation of dirname failed.
*/
void create_dir();
@@ -86,7 +87,7 @@
*
* \param dirname C-string containing name of directory.
*
- * \exception ??
+ * \exception jerrno::JERR_JDIR_MKDIR The creation of dirname failed.
*/
static void create_dir(const char* dirname);
@@ -95,153 +96,180 @@
*
* \param dirname String containing name of directory.
*
- * \exception ??
+ * \exception jerrno::JERR_JDIR_MKDIR The creation of dirname failed.
*/
static void create_dir(const std::string& dirname);
/**
- * \brief Clear the journal directory of files matching the base filename
+ * \brief Clear the %journal directory of files matching the base filename
* 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 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
+ * \exception jerrno::JERR_JDIR_OPENDIR The %journal directory could not be opened.
+ * \exception jerrno::JERR_JDIR_FMOVE Moving the files from the %journal directory to the created backup
* directory failed.
- * \exception The directory handle could not be closed.
+ * \exception jerrno::JERR_JDIR_CLOSEDIR The directory handle could not be closed.
*/
void clear_dir(const bool create_flag = true);
/**
- * \brief Clear the directory dirname of journal files matching 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
+ * \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
+ * \exception jerrno::JERR_JDIR_OPENDIR The %journal directory could not be opened.
+ * \exception jerrno::JERR_JDIR_FMOVE Moving the files from the %journal directory to the created backup
* directory failed.
- * \exception The directory handle could not be closed.
+ * \exception jerrno::JERR_JDIR_CLOSEDIR The directory handle could not be closed.
*/
static void clear_dir(const char* dirname, const char* base_filename,
const bool create_flag = true);
/**
- * \brief Clear the directory dirname of journal files matching base_filename
+ * \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
+ * \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
+ * \exception jerrno::JERR_JDIR_OPENDIR The %journal directory could not be opened.
+ * \exception jerrno::JERR_JDIR_FMOVE Moving the files from the %journal directory to the created backup
* directory failed.
- * \exception The directory handle could not be closed.
+ * \exception jerrno::JERR_JDIR_CLOSEDIR 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);
/**
- * \brief ??
+ * \brief Verify that dirname is a valid %journal directory.
*
- * \exception ??
+ * The validation reads the .%jinf file, and using this information verifies that all the expected %journal
+ * (.jdat) files are present.
+ *
+ * \exception jerrno::JERR_JDIR_NOTDIR dirname is not a directory
+ * \exception jerrno::JERR_JDIR_STAT Could not stat dirname
+ * \exception jerrno::JERR__FILEIO Error reading %jinf file
+ * \exception jerrno::JERR_JINF_CVALIDFAIL Error validating %jinf file
+ * \exception jerrno::JERR_JDIR_NOSUCHFILE Expected jdat file is missing
*/
void verify_dir();
/**
- * \brief ??
+ * \brief Verify that dirname is a valid %journal directory.
*
- * \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.
+ * The validation reads the .%jinf file, and using this information verifies that all the expected %journal
+ * (.jdat) files are present.
*
- * \exception ??
+ * \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 sub-directory.
+ *
+ * \exception jerrno::JERR_JDIR_NOTDIR dirname is not a directory
+ * \exception jerrno::JERR_JDIR_STAT Could not stat dirname
+ * \exception jerrno::JERR__FILEIO Error reading %jinf file
+ * \exception jerrno::JERR_JINF_CVALIDFAIL Error validating %jinf file
+ * \exception jerrno::JERR_JDIR_NOSUCHFILE Expected jdat file is missing
*/
static void verify_dir(const char* dirname, const char* base_filename);
/**
- * \brief ??
+ * \brief Verify that dirname is a valid %journal 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.
+ * The validation reads the .%jinf file, and using this information verifies that all the expected %journal
+ * (.jdat) files are present.
*
- * \exception ??
+ * \param dirname String containing name of %journal directory.
+ * \param base_filename String containing base filename of %journal files to be matched for moving into sub-directory.
+ *
+ * \exception jerrno::JERR_JDIR_NOTDIR dirname is not a directory
+ * \exception jerrno::JERR_JDIR_STAT Could not stat dirname
+ * \exception jerrno::JERR__FILEIO Error reading %jinf file
+ * \exception jerrno::JERR_JINF_CVALIDFAIL Error validating %jinf file
+ * \exception jerrno::JERR_JDIR_NOSUCHFILE Expected jdat file is missing
*/
static void verify_dir(const std::string& dirname, const std::string& base_filename);
/**
- * \brief Delete the journal directory and all files and sub--directories that it may
+ * \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 children_only To only delete children.
+ * \param children_only If true, delete only children of dirname, but leave dirname itself.
*
- * \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.
+ * \exception jerrno::JERR_JDIR_OPENDIR The %journal directory could not be opened.
+ * \exception jerrno::JERR_JDIR_STAT Could not stat dirname.
+ * \exception jerrno::JERR_JDIR_UNLINK A file could not be deleted.
+ * \exception jerrno::JERR_JDIR_BADFTYPE A dir entry is neiter a file nor a dir.
+ * \exception jerrno::JERR_JDIR_CLOSEDIR The directory handle could not be closed.
+ * \exception jerrno::JERR_JDIR_RMDIR A directory could not be deleted.
*/
void delete_dir(bool children_only = false );
/**
- * \brief Delete the journal directory and all files and sub--directories that it may
+ * \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 C-string containing name of directory to be deleted.
- * \param children_only To only delete children.
+ * \param children_only If true, delete only children of dirname, but leave dirname itself.
*
- * \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.
+ * \exception jerrno::JERR_JDIR_OPENDIR The %journal directory could not be opened.
+ * \exception jerrno::JERR_JDIR_STAT Could not stat dirname.
+ * \exception jerrno::JERR_JDIR_UNLINK A file could not be deleted.
+ * \exception jerrno::JERR_JDIR_BADFTYPE A dir entry is neiter a file nor a dir.
+ * \exception jerrno::JERR_JDIR_CLOSEDIR The directory handle could not be closed.
+ * \exception jerrno::JERR_JDIR_RMDIR A directory could not be deleted.
*/
static void delete_dir(const char* dirname, bool children_only = false);
/**
- * \brief Delete the journal directory and all files and sub--directories that it may
+ * \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.
- * \param children_only To only delete children.
+ * \param children_only If true, delete only children of dirname, but leave dirname itself.
*
- * \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.
+ * \exception jerrno::JERR_JDIR_OPENDIR The %journal directory could not be opened.
+ * \exception jerrno::JERR_JDIR_STAT Could not stat dirname.
+ * \exception jerrno::JERR_JDIR_UNLINK A file could not be deleted.
+ * \exception jerrno::JERR_JDIR_BADFTYPE A dir entry is neiter a file nor a dir.
+ * \exception jerrno::JERR_JDIR_CLOSEDIR The directory handle could not be closed.
+ * \exception jerrno::JERR_JDIR_RMDIR A directory could not be deleted.
*/
static void delete_dir(const std::string& dirname, bool children_only = false);
/**
- * \brief Create bakup directory that is next in sequence and move all journal files
+ * \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
+ * 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
+ * \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 ??
+ * \exception jerrno::JERR_JDIR_OPENDIR The %journal directory could not be opened.
+ * \exception jerrno::JERR_JDIR_CLOSEDIR The directory handle could not be closed.
+ * \exception jerrno::JERR_JDIR_MKDIR The backup directory could not be deleted.
*/
static std::string create_bak_dir(const std::string& dirname,
const std::string& base_filename);
@@ -252,7 +280,7 @@
inline const std::string& dirname() const { return _dirname; }
/**
- * \brief Return the journal base filename name as a string.
+ * \brief Return the %journal base filename name as a string.
*/
inline const std::string& base_filename() const { return _base_filename; }
@@ -262,7 +290,7 @@
* \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.
+ * \exception jerrno::JERR_JDIR_STAT Could not stat name.
*/
static bool is_dir(const char* name);
@@ -272,7 +300,7 @@
* \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.
+ * \exception jerrno::JERR_JDIR_STAT Could not stat name.
*/
static bool is_dir(const std::string& name);
@@ -287,7 +315,7 @@
* \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.
+ * \exception jerrno::JERR_JDIR_STAT Could not stat name.
*/
static bool exists(const char* name);
@@ -301,12 +329,10 @@
* \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.
+ * \exception jerrno::JERR_JDIR_STAT Could not stat name.
*/
static bool exists(const std::string& name);
- public:
-
/**
* \brief Stream operator
*/
@@ -316,6 +342,21 @@
* \brief Stream operator
*/
friend std::ostream& operator<<(std::ostream& os, const jdir* jdirPtr);
+
+ private:
+ /**
+ * \brief Check for error, if non-zero close DIR handle and throw JERR_JDIR_READDIR
+ *
+ * \exception jerrno::JERR_JDIR_READDIR Error while reading contents of dir.
+ */
+ static void check_err(const int err_num, DIR* dir, const std::string& dir_name, const std::string& fn_name);
+
+ /**
+ * \brief Close a DIR handle, throw JERR_JDIR_CLOSEDIR if error occurs during close
+ *
+ * \exception jerrno::JERR_JDIR_CLOSEDIR The directory handle could not be closed.
+ */
+ static void close_dir(DIR* dir, const std::string& dir_name, const std::string& fn_name);
};
} // namespace journal
Modified: store/trunk/cpp/lib/jrnl/jerrno.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.cpp 2009-12-03 10:00:25 UTC (rev 3733)
+++ store/trunk/cpp/lib/jrnl/jerrno.cpp 2009-12-03 15:42:14 UTC (rev 3734)
@@ -68,7 +68,7 @@
const u_int32_t jerrno::JERR_JDIR_NOTDIR = 0x0300;
const u_int32_t jerrno::JERR_JDIR_MKDIR = 0x0301;
const u_int32_t jerrno::JERR_JDIR_OPENDIR = 0x0302;
-//const u_int32_t jerrno::JERR_JDIR_READDIR = 0x0303;
+const u_int32_t jerrno::JERR_JDIR_READDIR = 0x0303;
const u_int32_t jerrno::JERR_JDIR_CLOSEDIR = 0x0304;
const u_int32_t jerrno::JERR_JDIR_RMDIR = 0x0305;
const u_int32_t jerrno::JERR_JDIR_NOSUCHFILE = 0x0306;
@@ -158,7 +158,7 @@
_err_map[JERR_JDIR_NOTDIR] = "JERR_JDIR_NOTDIR: Directory name exists but is not a directory.";
_err_map[JERR_JDIR_MKDIR] = "JERR_JDIR_MKDIR: Directory creation failed.";
_err_map[JERR_JDIR_OPENDIR] = "JERR_JDIR_OPENDIR: Directory open failed.";
- //_err_map[JERR_JDIR_READDIR] = "JERR_JDIR_READDIR: Directory read failed.";
+ _err_map[JERR_JDIR_READDIR] = "JERR_JDIR_READDIR: Directory read failed.";
_err_map[JERR_JDIR_CLOSEDIR] = "JERR_JDIR_CLOSEDIR: Directory close failed.";
_err_map[JERR_JDIR_RMDIR] = "JERR_JDIR_RMDIR: Directory delete failed.";
_err_map[JERR_JDIR_NOSUCHFILE] = "JERR_JDIR_NOSUCHFILE: File does not exist.";
Modified: store/trunk/cpp/lib/jrnl/jerrno.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.hpp 2009-12-03 10:00:25 UTC (rev 3733)
+++ store/trunk/cpp/lib/jrnl/jerrno.hpp 2009-12-03 15:42:14 UTC (rev 3734)
@@ -86,7 +86,7 @@
static const u_int32_t JERR_JDIR_NOTDIR; ///< Exists but is not a directory
static const u_int32_t JERR_JDIR_MKDIR; ///< Directory creation 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_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_NOSUCHFILE; ///< File does not exist
16 years, 5 months
rhmessaging commits: r3733 - store/branches/java.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2009-12-03 05:00:25 -0500 (Thu, 03 Dec 2009)
New Revision: 3733
Added:
store/branches/java/0.5.x-dev/
Log:
Branch to stay in sync with Apache
Copied: store/branches/java/0.5.x-dev (from rev 3732, store/trunk/java/bdbstore)
16 years, 5 months
rhmessaging commits: r3732 - store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2009-12-03 04:56:53 -0500 (Thu, 03 Dec 2009)
New Revision: 3732
Modified:
store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
Log:
QPID-2001 : Converted Log Messages from XXX-<Number> to a more meaningfull XXX-<Name>. This makes the code more readable and does not affect the log message output. Removed the en_US properties as a) it is not required b) the two english files were not being kept in sync.
Modified: store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
===================================================================
--- store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java 2009-12-02 18:23:36 UTC (rev 3731)
+++ store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java 2009-12-03 09:56:53 UTC (rev 3732)
@@ -202,7 +202,7 @@
}
}
- CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_1002(environmentPath.getAbsolutePath()));
+ CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_STORE_LOCATION(environmentPath.getAbsolutePath()));
_version = config.getInt(DATABASE_FORMAT_VERSION_PROPERTY, DATABASE_FORMAT_VERSION);
@@ -1231,7 +1231,7 @@
stateTransition(State.CONFIGURED, State.RECOVERING);
_log.info("Recovering persistent state...");
- CurrentActor.get().message(_logSubject,MessageStoreMessages.MST_1004(null, false));
+ CurrentActor.get().message(_logSubject,MessageStoreMessages.MST_RECOVERY_START(null, false));
StoreContext context = new StoreContext();
try
@@ -1241,7 +1241,7 @@
for (AMQQueue q : queues.values())
{
- CurrentActor.get().message(_logSubject,MessageStoreMessages.MST_1004(String.valueOf(q.getName()), true));
+ CurrentActor.get().message(_logSubject,MessageStoreMessages.MST_RECOVERY_START(String.valueOf(q.getName()), true));
//Record that we have a queue for recovery
_queueRecoveries.put(q.getName(), 0);
@@ -1253,7 +1253,7 @@
deliverMessages(context, queues);
_log.info("Persistent state recovered successfully");
- CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_1006(null, false));
+ CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_RECOVERY_COMPLETE(null, false));
commitTran(context);
@@ -1721,9 +1721,9 @@
for(Map.Entry<AMQShortString,Integer> entry : _queueRecoveries.entrySet())
{
- CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_1005(entry.getValue(), String.valueOf(entry.getKey())));
+ CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_RECOVERED(entry.getValue(), String.valueOf(entry.getKey())));
- CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_1006(String.valueOf(entry.getKey()), true));
+ CurrentActor.get().message(_logSubject, MessageStoreMessages.MST_RECOVERY_COMPLETE(String.valueOf(entry.getKey()), true));
}
//Free the memory
16 years, 5 months
rhmessaging commits: r3731 - in store/trunk/cpp/lib: jrnl and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2009-12-02 13:23:36 -0500 (Wed, 02 Dec 2009)
New Revision: 3731
Modified:
store/trunk/cpp/lib/IdSequence.cpp
store/trunk/cpp/lib/MessageStoreImpl.cpp
store/trunk/cpp/lib/jrnl/jcntl.cpp
Log:
Fix for rid overflow (which happens after 2^64 persistence ids are used - this will take a little time) which allowed the persistence id to return to 0. Fixed recovery logic to use correct RFC 1982 arithmatic, modified for use with unsigned ints.
Modified: store/trunk/cpp/lib/IdSequence.cpp
===================================================================
--- store/trunk/cpp/lib/IdSequence.cpp 2009-11-30 20:07:31 UTC (rev 3730)
+++ store/trunk/cpp/lib/IdSequence.cpp 2009-12-02 18:23:36 UTC (rev 3731)
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2007, 2008 Red Hat, Inc.
+ Copyright (c) 2007, 2008, 2009 Red Hat, Inc.
This file is part of the Qpid async store library msgstore.so.
@@ -31,6 +31,7 @@
u_int64_t IdSequence::next()
{
Mutex::ScopedLock guard(lock);
+ if (!id) id++; // avoid 0 when folding around
return id++;
}
Modified: store/trunk/cpp/lib/MessageStoreImpl.cpp
===================================================================
--- store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-11-30 20:07:31 UTC (rev 3730)
+++ store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-12-02 18:23:36 UTC (rev 3731)
@@ -795,7 +795,8 @@
long idcnt = 0L; // in-doubt msg count
u_int64_t thisHighestRid = 0;
jQueue->recover(numJrnlFiles, autoJrnlExpand, autoJrnlExpandMaxFiles, jrnlFsizeSblks, wCacheNumPages, wCachePgSizeSblks, &prepared, thisHighestRid, key.id); // start recovery
- if (thisHighestRid > highestRid)
+ // RFC 1982 comparison for unsigned 64-bit
+ if (thisHighestRid - highestRid < 0x8000000000000000ULL)
highestRid = thisHighestRid;
recoverMessages(txn, registry, queue, prepared, messages, rcnt, idcnt);
QPID_LOG(info, "Recovered queue \"" << queueName << "\": " << rcnt << " messages recovered; " << idcnt << " messages in-doubt.");
@@ -812,6 +813,7 @@
// NOTE: highestRid is set by both recoverQueues() and recoverTplStore() as
// the messageIdSequence is used for both queue journals and the tpl journal.
messageIdSequence.reset(highestRid + 1);
+ QPID_LOG(info, "Most recent persistence id found: 0x" << std::hex << highestRid << std::dec);
queueIdSequence.reset(maxQueueId + 1);
}
@@ -1188,7 +1190,8 @@
if (journal::jdir::exists(tplStorePtr->jrnl_dir() + tplStorePtr->base_filename() + ".jinf")) {
u_int64_t thisHighestRid;
tplStorePtr->recover(tplNumJrnlFiles, false, 0, tplJrnlFsizeSblks, tplWCachePgSizeSblks, tplWCacheNumPages, 0, thisHighestRid, 0);
- if (thisHighestRid > highestRid)
+ // RFC 1982 comparison for unsigned 64-bit
+ if (thisHighestRid - highestRid < 0x8000000000000000ULL)
highestRid = thisHighestRid;
// Load tplRecoverMap by reading the TPL store
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2009-11-30 20:07:31 UTC (rev 3730)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2009-12-02 18:23:36 UTC (rev 3731)
@@ -932,7 +932,8 @@
throw jexception(jerrno::JERR_JCNTL_OWIMISMATCH, oss.str(), "jcntl",
"check_owi");
}
- if (rd._h_rid < h._rid)
+ // RFC 1982 comparison for unsigned 64-bit
+ if (h._rid - rd._h_rid < 0x8000000000000000ULL)
rd._h_rid = h._rid;
return true;
}
16 years, 5 months