rhmessaging commits: r3103 - in store/trunk/cpp: lib/jrnl and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2009-02-03 15:44:17 -0500 (Tue, 03 Feb 2009)
New Revision: 3103
Modified:
store/trunk/cpp/lib/MessageStoreImpl.cpp
store/trunk/cpp/lib/MessageStoreImpl.h
store/trunk/cpp/lib/jrnl/jinf.cpp
store/trunk/cpp/lib/jrnl/jinf.hpp
store/trunk/cpp/tests/jrnl/_st_read.cpp
Log:
Partial fix for BZ 483822 - "Persistent clusters encounter null queue names". Prevented the creation and recovery of null queues.
Modified: store/trunk/cpp/lib/MessageStoreImpl.cpp
===================================================================
--- store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-02-03 19:57:26 UTC (rev 3102)
+++ store/trunk/cpp/lib/MessageStoreImpl.cpp 2009-02-03 20:44:17 UTC (rev 3103)
@@ -424,6 +424,12 @@
value = args.get("qpid.file_size");
if (value.get() != 0 && !value->empty() && value->convertsTo<int>())
localFileSizeSblks = (u_int32_t) value->get<int>() * JRNL_RMGR_PAGE_SIZE;
+
+ if (queue.getName().size() == 0)
+ {
+ QPID_LOG(error, "Cannot create store for empty (null) queue name - ignoring and attempting to continue.");
+ return;
+ }
{
// TODO: Is this mutex necessary?
@@ -698,9 +704,14 @@
//set the persistenceId and update max as required
queue->setPersistenceId(key.id);
- const char* queueName = queue->getName().c_str();
+ const std::string queueName = queue->getName().c_str();
JournalImpl* jQueue = 0;
+ if (queueName.size() == 0)
{
+ QPID_LOG(error, "Cannot recover empty (null) queue name - ignoring and attempting to continue.");
+ break;
+ }
+ {
qpid::sys::Mutex::ScopedLock sl(jrnlCreateLock);
jQueue = new JournalImpl(queueName, getJrnlDir(queueName), std::string("JournalData"), defJournalGetEventsTimeout, defJournalFlushTimeout);
}
@@ -1770,11 +1781,11 @@
return h;
}
-std::string MessageStoreImpl::getJrnlDir(const char* queueName) //for exmaple /var/rhm/ + queueDir/
+std::string MessageStoreImpl::getJrnlDir(const std::string& queueName) //for exmaple /var/rhm/ + queueDir/
{
std::stringstream dir;
dir << getJrnlBaseDir() << std::hex << std::setfill('0') << std::setw(4);
- dir << (bHash(queueName) % 29); // Use a prime number for better distribution across dirs
+ dir << (bHash(queueName.c_str()) % 29); // Use a prime number for better distribution across dirs
dir << "/" << queueName << "/";
return dir.str();
}
Modified: store/trunk/cpp/lib/MessageStoreImpl.h
===================================================================
--- store/trunk/cpp/lib/MessageStoreImpl.h 2009-02-03 19:57:26 UTC (rev 3102)
+++ store/trunk/cpp/lib/MessageStoreImpl.h 2009-02-03 20:44:17 UTC (rev 3103)
@@ -243,7 +243,7 @@
void createJrnlQueue(const qpid::broker::PersistableQueue& queue);
u_int32_t bHash(const std::string str);
std::string getJrnlDir(const qpid::broker::PersistableQueue& queue); //for exmaple /var/rhm/ + queueDir/
- std::string getJrnlDir(const char* queueName);
+ std::string getJrnlDir(const std::string& queueName);
std::string getJrnlBaseDir();
std::string getBdbBaseDir();
std::string getTplBaseDir();
Modified: store/trunk/cpp/lib/jrnl/jinf.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jinf.cpp 2009-02-03 19:57:26 UTC (rev 3102)
+++ store/trunk/cpp/lib/jrnl/jinf.cpp 2009-02-03 20:44:17 UTC (rev 3103)
@@ -50,6 +50,7 @@
jinf::jinf(const std::string& jinf_filename, bool validate_flag):
_jver(0),
+ _filename(jinf_filename),
_num_jfiles(0),
_ae(false),
_ae_max_jfiles(0),
@@ -66,7 +67,7 @@
_initial_owi(false),
_frot(false)
{
- read(jinf_filename);
+ read(_filename);
if (validate_flag)
validate();
}
@@ -93,7 +94,9 @@
_valid_flag(false),
_analyzed_flag(false),
_initial_owi(false)
-{}
+{
+ set_filename();
+}
jinf::~jinf()
{}
@@ -105,18 +108,21 @@
std::ostringstream oss;
if (_jver != RHM_JDAT_VERSION)
{
+ oss << "File \"" << _filename << "\": ";
oss << "RHM_JDAT_VERSION mismatch: " << _jver;
oss << "; required=" << RHM_JDAT_VERSION << std::endl;
err = true;
}
if (_num_jfiles < JRNL_MIN_NUM_FILES)
{
+ oss << "File \"" << _filename << "\": ";
oss << "Number of journal files too small: found=" << _num_jfiles;
oss << "; minimum=" << JRNL_MIN_NUM_FILES << std::endl;
err = true;
}
if (_num_jfiles > JRNL_MAX_NUM_FILES)
{
+ oss << "File \"" << _filename << "\": ";
oss << "Number of journal files too large: found=" << _num_jfiles;
oss << "; maximum=" << JRNL_MAX_NUM_FILES << std::endl;
err = true;
@@ -125,12 +131,14 @@
{
if (_ae_max_jfiles > _num_jfiles)
{
+ oss << "File \"" << _filename << "\": ";
oss << "Number of journal files exceeds auto-expansion limit: found=" << _num_jfiles;
oss << "; maximum=" << _ae_max_jfiles;
err = true;
}
if (_ae_max_jfiles > JRNL_MAX_NUM_FILES)
{
+ oss << "File \"" << _filename << "\": ";
oss << "Auto-expansion file limit too large: found=" << _ae_max_jfiles;
oss << "; maximum=" << JRNL_MAX_NUM_FILES;
err = true;
@@ -138,18 +146,21 @@
}
if (_jfsize_sblks < JRNL_MIN_FILE_SIZE)
{
+ oss << "File \"" << _filename << "\": ";
oss << "Journal file size too small: found=" << _jfsize_sblks;
oss << "; minimum=" << JRNL_MIN_FILE_SIZE << " (sblks)" << std::endl;
err = true;
}
if (_sblk_size_dblks != JRNL_SBLK_SIZE)
{
+ oss << "File \"" << _filename << "\": ";
oss << "JRNL_SBLK_SIZE mismatch: " << _sblk_size_dblks;
oss << "; required=" << JRNL_SBLK_SIZE << std::endl;
err = true;
}
if (_dblk_size != JRNL_DBLK_SIZE)
{
+ oss << "File \"" << _filename << "\": ";
oss << "JRNL_DBLK_SIZE mismatch: " << _dblk_size;
oss << "; required=" << JRNL_DBLK_SIZE << std::endl;
err = true;
@@ -362,6 +373,14 @@
}
void
+jinf::set_filename()
+{
+ std::ostringstream oss;
+ oss << _jdir << "/" << _base_filename << "." << JRNL_INFO_EXTENSION;
+ _filename = oss.str().c_str();
+}
+
+void
jinf::read(const std::string& jinf_filename)
{
// TODO: This is *not* an XML reader, rather for simplicity, it is a brute-force line reader which relies on string
@@ -446,12 +465,20 @@
int target2_char = '\"';
char* t1 = std::strstr(line, target1_str);
if (t1 == 0)
- throw jexception(jerrno::JERR_JINF_NOVALUESTR, line, "jinf", "find_value");
+ {
+ std::ostringstream oss;
+ oss << "File \"" << _filename << "\": line=" << line;
+ throw jexception(jerrno::JERR_JINF_NOVALUESTR, oss.str(), "jinf", "find_value");
+ }
t1 += std::strlen(target1_str);
char* t2 = std::strchr(t1, target2_char);
if (t2 == 0)
- throw jexception(jerrno::JERR_JINF_BADVALUESTR, line, "jinf", "find_value");
+ {
+ std::ostringstream oss;
+ oss << "File \"" << _filename << "\": line=" << line;
+ throw jexception(jerrno::JERR_JINF_BADVALUESTR, oss.str(), "jinf", "find_value");
+ }
*t2 = '\0';
return t1;
}
Modified: store/trunk/cpp/lib/jrnl/jinf.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jinf.hpp 2009-02-03 19:57:26 UTC (rev 3102)
+++ store/trunk/cpp/lib/jrnl/jinf.hpp 2009-02-03 20:44:17 UTC (rev 3103)
@@ -56,6 +56,7 @@
std::string _jid;
std::string _jdir;
std::string _base_filename;
+ std::string _filename;
timespec _ts;
u_int16_t _num_jfiles;
bool _ae;
@@ -116,6 +117,7 @@
std::string xml_str() const;
private:
+ void set_filename();
void read(const std::string& jinf_filename);
bool bool_value(char* line) const;
u_int16_t u_int16_value(char* line) const;
Modified: store/trunk/cpp/tests/jrnl/_st_read.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_st_read.cpp 2009-02-03 19:57:26 UTC (rev 3102)
+++ store/trunk/cpp/tests/jrnl/_st_read.cpp 2009-02-03 20:44:17 UTC (rev 3103)
@@ -89,7 +89,7 @@
catch(const exception& e) { BOOST_FAIL(e.what()); }
cout << "ok" << endl;
}
-/*
+
QPID_AUTO_TEST_CASE(multi_page_enqueue_read_dequeue_block)
{
string test_name = get_test_name(test_filename, "multi_page_enqueue_read_dequeue_block");
@@ -156,7 +156,7 @@
catch(const exception& e) { BOOST_FAIL(e.what()); }
cout << "ok" << endl;
}
-*/
+
QPID_AUTO_TEST_CASE(enqueue_recovered_read_dequeue)
{
string test_name = get_test_name(test_filename, "enqueue_recovered_read_dequeue");