rhmessaging commits: r1317 - store/trunk/cpp/tests/jrnl.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-15 08:00:56 -0500 (Thu, 15 Nov 2007)
New Revision: 1317
Modified:
store/trunk/cpp/tests/jrnl/msg_producer.cpp
Log:
Removed debug prints accidentally left in at last checkin
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-11-15 04:21:08 UTC (rev 1316)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-11-15 13:00:56 UTC (rev 1317)
@@ -408,7 +408,7 @@
void
msg_producer::jrnl_flush(rhm::journal::jcntl& jc, u_int32_t num_msgs_sent)
{
-std::cout << "msg_producer::jrnl_flush(" << num_msgs_sent << ")" << std::endl << std::flush;
+//std::cout << "msg_producer::jrnl_flush(" << num_msgs_sent << ")" << std::endl << std::flush;
// Clear any unsent enqueues in buffer, then wait for all enqueues to return
unsigned flush_cnt = 0;
assert(num_msgs_sent == _num_msgs_enq_subm);
@@ -425,7 +425,7 @@
throw rhm::journal::jexception(EXCEPTION_BASE+10, ss.str().c_str(), "msg_producer",
"jrnl_flush");
}
-std::cout << "+" << std::flush;
+//std::cout << "+" << std::flush;
jc.get_wr_events();
usleep(FLUSH_SLEEPTIME);
flush_cnt++;
@@ -435,7 +435,7 @@
// Submit deferred dequeues (if any)
if (_auto_dequeue)
{
-std::cout << "auto_dequeue: " << _dd_dtok_list.size() << " dequeues waiting. " << std::flush;
+//std::cout << "auto_dequeue: " << _dd_dtok_list.size() << " dequeues waiting. " << std::flush;
u_int32_t cnt = 0;
send_deferred_dequeues(jc);
while (!_dd_dtok_list.empty() && !_interrupt_flag)
@@ -447,11 +447,11 @@
usleep(1000);
send_deferred_dequeues(jc);
}
-std::cout << "auto_dequeue: done. " << std::flush;
+//std::cout << "auto_dequeue: done. " << std::flush;
// Clear any unsent dequeues in buffer, then wait for all dequeues to return
flush_cnt = 0;
-std::cout << "_num_msgs_deq_subm=" << _num_msgs_deq_subm << std::endl << std::flush;
+//std::cout << "_num_msgs_deq_subm=" << _num_msgs_deq_subm << std::endl << std::flush;
assert(num_msgs_sent == _num_msgs_deq_subm);
if (_num_msgs_deq < _num_msgs_deq_subm || _num_txn < _num_txn_subm)
{
@@ -467,7 +467,7 @@
throw rhm::journal::jexception(EXCEPTION_BASE+12, ss.str().c_str(),
"msg_producer", "jrnl_flush");
}
-std::cout << "*" << std::flush;
+//std::cout << "*" << std::flush;
jc.get_wr_events();
usleep(1000);
flush_cnt++;
17 years, 1 month
rhmessaging commits: r1316 - store/trunk/cpp/tests/jrnl.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-14 23:21:08 -0500 (Wed, 14 Nov 2007)
New Revision: 1316
Modified:
store/trunk/cpp/tests/jrnl/unit_test_jdir.cpp
store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp
Log:
Added to unit tests
Modified: store/trunk/cpp/tests/jrnl/unit_test_jdir.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jdir.cpp 2007-11-14 22:20:42 UTC (rev 1315)
+++ store/trunk/cpp/tests/jrnl/unit_test_jdir.cpp 2007-11-15 04:21:08 UTC (rev 1316)
@@ -32,16 +32,22 @@
#include <boost/test/results_reporter.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/unit_test_log.hpp>
+#include <fstream>
#include <iostream>
#include <jrnl/jdir.hpp>
#include <jrnl/jerrno.hpp>
#include <jrnl/jexception.hpp>
+#include <sys/stat.h>
#define ERRORSTR(e) ::strerror(ret) << " (" << ret << ")"
using namespace boost::unit_test;
using namespace rhm::journal;
+// Helper function declarations
+void make_file(const char* filename, mode_t fmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+void make_jrnl_files(const char* dirname);
+
// Test functions of the form
// void fn() {...}
@@ -56,17 +62,11 @@
void test_create_delete_dir()
{
+ // Use instance
std::string dir_A("/tmp/A");
std::string dir_Ats("/tmp/A/"); // trailing '/'
- std::string dir_Bts("/tmp/B/"); // trailing '/'
- std::string dir_C("/tmp/C");
- std::string dir_Dts("/tmp/D/"); // trailing '/'
- std::string dir_X("/tmp/X");
- std::string dir_Xts("/tmp/X/"); // trailing '/'
- std::string bfn("test_base");
-
- // Use instance
- jdir dir1(dir_A, bfn);
+ BOOST_CHECK(!jdir::exists(dir_A));
+ jdir dir1(dir_A, "test_base");
dir1.create_dir();
// check all combos of jdir::exists and jdir::is_dir()
BOOST_CHECK(jdir::exists(dir_A));
@@ -77,102 +77,232 @@
BOOST_CHECK(jdir::is_dir(dir_Ats));
BOOST_CHECK(jdir::is_dir(dir_Ats.c_str()));
BOOST_CHECK(jdir::is_dir(dir_Ats.c_str()));
+ dir1.delete_dir();
+ BOOST_CHECK(!jdir::exists(dir_A));
+
+ // Use static fn
+ BOOST_CHECK(!jdir::exists("/tmp/B"));
+ jdir::create_dir("/tmp/B");
+ BOOST_CHECK(jdir::is_dir("/tmp/B"));
+ jdir::delete_dir("/tmp/B");
+ BOOST_CHECK(!jdir::exists("/tmp/B"));
+
+ // Non-empty dirs
+ BOOST_CHECK(!jdir::exists("/tmp/C"));
+ jdir::create_dir("/tmp/C");
+ BOOST_CHECK(jdir::is_dir("/tmp/C"));
+ make_file("/tmp/C/test_file_1.txt"); // mode 644 (default)
+ make_file("/tmp/C/test_file_2.txt", S_IRWXU | S_IRWXG | S_IRWXO); // mode 777
+ make_file("/tmp/C/test_file_3.txt", S_IRUSR | S_IRGRP | S_IROTH); // mode 444 (read-only)
+ make_file("/tmp/C/test_file_4.txt", 0); // mode 000 (no permissions)
+ BOOST_CHECK(jdir::is_dir("/tmp/C"));
+ jdir::delete_dir("/tmp/C");
+ BOOST_CHECK(!jdir::exists("/tmp/C"));
// Check non-existent dirs fail
- BOOST_CHECK(!jdir::exists(dir_X));
- BOOST_CHECK(!jdir::exists(dir_Xts));
+ BOOST_CHECK(!jdir::exists("/tmp/D"));
try
{
- jdir::is_dir(dir_X);
+ jdir::is_dir("/tmp/D");
BOOST_ERROR("jdir::is_dir() failed to throw jexeption for non-existent directory.");
}
catch(const jexception e)
{
BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_JDIR_STAT);
}
+}
+
+void test_create_delete_dir_recursive()
+{
+ // Use instances
+ BOOST_CHECK(!jdir::exists("/tmp/E"));
+ jdir dir1("/tmp/E/F/G/H", "test_base");
+ dir1.create_dir();
+ BOOST_CHECK(jdir::is_dir("/tmp/E/F/G/H"));
+ dir1.delete_dir();
+ BOOST_CHECK(!jdir::exists("/tmp/E/F/G/H")); // only H deleted, E/F/G remain
+ BOOST_CHECK(jdir::exists("/tmp/E"));
+ jdir::delete_dir("/tmp/E"); // delete remaining dirs
+ BOOST_CHECK(!jdir::exists("/tmp/E"));
+
+ BOOST_CHECK(!jdir::exists("/tmp/F"));
+ jdir dir2("/tmp/F/G/H/I/", "test_base"); // trailing '/'
+ dir2.create_dir();
+ BOOST_CHECK(jdir::is_dir("/tmp/F/G/H/I/"));
+ dir2.delete_dir();
+ BOOST_CHECK(!jdir::exists("/tmp/F/G/H/I/"));
+ BOOST_CHECK(jdir::exists("/tmp/F"));
+ jdir::delete_dir("/tmp/F");
+ BOOST_CHECK(!jdir::exists("/tmp/F"));
+
+ // Use static fn
+ BOOST_CHECK(!jdir::exists("/tmp/G"));
+ jdir::create_dir("/tmp/G/H/I/J");
+ BOOST_CHECK(jdir::is_dir("/tmp/G/H/I/J"));
+ jdir::delete_dir("/tmp/G/H/I/J");
+ BOOST_CHECK(!jdir::exists("/tmp/G/H/I/J"));
+ BOOST_CHECK(jdir::exists("/tmp/G"));
+ jdir::delete_dir("/tmp/G");
+ BOOST_CHECK(!jdir::exists("/tmp/G"));
+
+ BOOST_CHECK(!jdir::exists("/tmp/H"));
+ jdir::create_dir("/tmp/H/I/J/K/");
+ BOOST_CHECK(jdir::is_dir("/tmp/H/I/J/K/"));
+ jdir::delete_dir("/tmp/H/I/J/K/");
+ BOOST_CHECK(!jdir::exists("/tmp/H/I/J/K/"));
+ BOOST_CHECK(jdir::exists("/tmp/H"));
+ jdir::delete_dir("/tmp/H");
+ BOOST_CHECK(!jdir::exists("/tmp/H"));
+
+ // Non-empty dirs
+ BOOST_CHECK(!jdir::exists("/tmp/I"));
+ jdir::create_dir("/tmp/I/J/K1/L1");
+ jdir::create_dir("/tmp/I/J/K1/L2");
+ jdir::create_dir("/tmp/I/J/K1/L3");
+ jdir::create_dir("/tmp/I/J/K1/L4");
+ make_file("/tmp/I/J/K1/L4/test_file_1.txt"); // mode 644 (default)
+ make_file("/tmp/I/J/K1/L4/test_file_2.txt", S_IRWXU | S_IRWXG | S_IRWXO); // mode 777
+ make_file("/tmp/I/J/K1/L4/test_file_3.txt", S_IRUSR | S_IRGRP | S_IROTH); // mode 444
+ make_file("/tmp/I/J/K1/L4/test_file_4.txt", 0); // mode 000 (no permissions)
+ jdir::create_dir("/tmp/I/J/K2");
+ jdir::create_dir("/tmp/I/J/K3/L5");
+ jdir::create_dir("/tmp/I/J/K3/L6");
+ BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L1"));
+ BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L2"));
+ BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L3"));
+ BOOST_CHECK(jdir::is_dir("/tmp/I/J/K1/L4"));
+ BOOST_CHECK(jdir::is_dir("/tmp/I/J/K2"));
+ BOOST_CHECK(jdir::is_dir("/tmp/I/J/K3/L5"));
+ BOOST_CHECK(jdir::is_dir("/tmp/I/J/K3/L6"));
+ jdir::delete_dir("/tmp/I");
+ BOOST_CHECK(!jdir::exists("/tmp/I"));
+}
+
+void test_clear_dir()
+{
+ // Use instances
+ BOOST_CHECK(!jdir::exists("/tmp/test_dir_1"));
+ jdir test_dir_1("/tmp/test_dir_1", "test_base");
+ test_dir_1.create_dir();
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_1"));
+ // add some journal files
+ make_jrnl_files("/tmp/test_dir_1");
+ // clear dir
+ test_dir_1.clear_dir();
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_1"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_1/_test_base.bak.0001"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_1/_test_base.bak.0001/test_base.jinf"));
+ // add some more journal files
+ make_jrnl_files("/tmp/test_dir_1");
+ // clear dir
+ test_dir_1.clear_dir();
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_1"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_1/_test_base.bak.0001"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_1/_test_base.bak.0001/test_base.jinf"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_1/_test_base.bak.0002"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_1/_test_base.bak.0002/test_base.jinf"));
+ // add some more journal files
+ make_jrnl_files("/tmp/test_dir_1");
+ // clear dir
+ test_dir_1.clear_dir();
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_1"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_1/_test_base.bak.0001"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_1/_test_base.bak.0001/test_base.jinf"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_1/_test_base.bak.0002"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_1/_test_base.bak.0002/test_base.jinf"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_1/_test_base.bak.0003"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_1/_test_base.bak.0003/test_base.jinf"));
+ // clean up
+ test_dir_1.delete_dir();
+ BOOST_CHECK(!jdir::exists("/tmp/test_dir_1"));
+
+ // non-existent dir with auto-create true
+ BOOST_CHECK(!jdir::exists("/tmp/test_dir_2"));
+ jdir test_dir_2("/tmp/test_dir_2", "test_base");
+ // clear dir
+ test_dir_2.clear_dir(); // create flag is true by default
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_2"));
+ // add some journal files
+ make_jrnl_files("/tmp/test_dir_2");
+ // clear dir
+ test_dir_2.clear_dir();
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_2"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_2/_test_base.bak.0001"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_2/_test_base.bak.0001/test_base.jinf"));
+ // clean up
+ test_dir_2.delete_dir();
+ BOOST_CHECK(!jdir::exists("/tmp/test_dir_2"));
+
+ // non-existent dir with auto-create false
+ BOOST_CHECK(!jdir::exists("/tmp/test_dir_3"));
+ jdir test_dir_3("/tmp/test_dir_3", "test_base");
try
{
- jdir::is_dir(dir_Xts);
- BOOST_ERROR("jdir::is_dir() failed to throw jexeption for non-existent directory.");
+ test_dir_3.clear_dir(false);
+ BOOST_ERROR("jdir::clear_dir(flase) failed to throw jexeption for non-existent directory.");
}
catch(const jexception e)
{
- BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_JDIR_STAT);
+ BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_JDIR_OPENDIR);
}
- jdir dir2(dir_Bts, bfn);
- dir2.create_dir();
- BOOST_CHECK(jdir::is_dir(dir_Bts));
-
// static fn
- jdir::create_dir(dir_C);
- BOOST_CHECK(jdir::is_dir(dir_C));
- jdir::create_dir(dir_Dts);
- BOOST_CHECK(jdir::is_dir(dir_Dts));
-
- // Clean up with delete_dir
- dir1.delete_dir();
- BOOST_CHECK(!jdir::exists(dir_A));
- dir2.delete_dir();
- BOOST_CHECK(!jdir::exists(dir_Bts));
- // static fn
- jdir::delete_dir(dir_C);
- BOOST_CHECK(!jdir::exists(dir_C));
- jdir::delete_dir(dir_Dts);
- BOOST_CHECK(!jdir::exists(dir_Dts));
+ BOOST_CHECK(!jdir::exists("/tmp/test_dir_4"));
+ jdir::create_dir("/tmp/test_dir_4");
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_4"));
+ // add some journal files
+ make_jrnl_files("/tmp/test_dir_4");
+ // clear dir
+ jdir::clear_dir("/tmp/test_dir_4", "test_base");
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_4"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_4/_test_base.bak.0001"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_4/_test_base.bak.0001/test_base.jinf"));
+ // add some more journal files
+ make_jrnl_files("/tmp/test_dir_4");
+ // clear dir
+ jdir::clear_dir("/tmp/test_dir_4", "test_base");
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_4"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_4/_test_base.bak.0001"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_4/_test_base.bak.0001/test_base.jinf"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_4/_test_base.bak.0002"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_4/_test_base.bak.0002/test_base.jinf"));
+ // add some more journal files
+ make_jrnl_files("/tmp/test_dir_4");
+ // clear dir
+ jdir::clear_dir("/tmp/test_dir_4", "test_base");
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_4"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_4/_test_base.bak.0001"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_4/_test_base.bak.0001/test_base.jinf"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_4/_test_base.bak.0002"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_4/_test_base.bak.0002/test_base.jinf"));
+ BOOST_CHECK(jdir::is_dir("/tmp/test_dir_4/_test_base.bak.0003"));
+ BOOST_CHECK(jdir::exists("/tmp/test_dir_4/_test_base.bak.0003/test_base.jinf"));
+ // clean up
+ jdir::delete_dir("/tmp/test_dir_4");
+ BOOST_CHECK(!jdir::exists("/tmp/test_dir_4"));
}
-void test_create_delete_dir_recursive()
+// Helper functions
+
+void make_file(const char* filename, mode_t fmode)
{
- std::string dir_E("/tmp/E/F/G/H");
- std::string dir_Eb("/tmp/E"); // base dir
- std::string dir_F("/tmp/F/G/H/I/"); // trailing '/'
- std::string dir_Fb("/tmp/F"); // base dir
- std::string dir_G("/tmp/G/H/I/J");
- std::string dir_Gb("/tmp/G"); // base dir
- std::string dir_H("/tmp/H/I/J/K/"); // trailing '/'
- std::string dir_Hb("/tmp/H"); // base dir
- std::string bfn("test_base");
+ std::ofstream of(filename, std::ofstream::out | std::ofstream::trunc);
+ if (!of.good())
+ BOOST_FAIL("Unable to open file " << filename << " for writing.");
+ of.write(filename, ::strlen(filename));
+ of.close();
+ ::chmod(filename, fmode);
+}
- // Use instances
- jdir dir1(dir_E, bfn);
- dir1.create_dir();
- BOOST_CHECK(jdir::is_dir(dir_E));
- jdir dir2(dir_F, bfn);
- dir2.create_dir();
- BOOST_CHECK(jdir::is_dir(dir_F));
-
- // static fn
- jdir::create_dir(dir_G);
- BOOST_CHECK(jdir::is_dir(dir_G));
- jdir::create_dir(dir_H);
- BOOST_CHECK(jdir::is_dir(dir_H));
-
- // Clean up with delete_dir
- dir1.delete_dir();
- BOOST_CHECK(!jdir::exists(dir_E)); // only H deleted, E/F/G remain
- BOOST_CHECK(jdir::exists(dir_Eb));
- jdir::delete_dir(dir_Eb); // delete remaining dirs
- BOOST_CHECK(!jdir::exists(dir_Eb));
-
- dir2.delete_dir();
- BOOST_CHECK(!jdir::exists(dir_F));
- BOOST_CHECK(jdir::exists(dir_Fb));
- jdir::delete_dir(dir_Fb);
- BOOST_CHECK(!jdir::exists(dir_Fb));
-
- // static fn
- jdir::delete_dir(dir_G);
- BOOST_CHECK(!jdir::exists(dir_G));
- BOOST_CHECK(jdir::exists(dir_Gb));
- jdir::delete_dir(dir_Gb);
- BOOST_CHECK(!jdir::exists(dir_Gb));
-
- jdir::delete_dir(dir_H);
- BOOST_CHECK(!jdir::exists(dir_H));
- BOOST_CHECK(jdir::exists(dir_Hb));
- jdir::delete_dir(dir_Hb);
- BOOST_CHECK(!jdir::exists(dir_Hb));
+void make_jrnl_files(const char* dirname)
+{
+ make_file(std::string(dirname).append("/test_base.0000.jdat").c_str());
+ make_file(std::string(dirname).append("/test_base.0001.jdat").c_str());
+ make_file(std::string(dirname).append("/test_base.0002.jdat").c_str());
+ make_file(std::string(dirname).append("/test_base.0003.jdat").c_str());
+ make_file(std::string(dirname).append("/test_base.0004.jdat").c_str());
+ make_file(std::string(dirname).append("/test_base.jinf").c_str());
+ make_file(std::string(dirname).append("/test_base.12345.abcdef.crazy-filename").c_str());
}
// Initialize test suite and include test functions
@@ -188,6 +318,7 @@
ts->add(BOOST_TEST_CASE(&test_constructor));
ts->add(BOOST_TEST_CASE(&test_create_delete_dir));
ts->add(BOOST_TEST_CASE(&test_create_delete_dir_recursive));
+ ts->add(BOOST_TEST_CASE(&test_clear_dir));
return ts;
}
Modified: store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp 2007-11-14 22:20:42 UTC (rev 1315)
+++ store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp 2007-11-15 04:21:08 UTC (rev 1316)
@@ -43,6 +43,7 @@
using namespace boost::unit_test;
using namespace rhm::journal;
+// Helper function declarations
const std::string jid("test journal id");
const std::string jdir("/tmp");
const std::string base_filename("test_base");
17 years, 1 month
rhmessaging commits: r1315 - in store/trunk/cpp: tests/jrnl and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-14 17:20:42 -0500 (Wed, 14 Nov 2007)
New Revision: 1315
Modified:
store/trunk/cpp/lib/jrnl/rmgr.cpp
store/trunk/cpp/tests/jrnl/Makefile.rtest
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_producer.cpp
store/trunk/cpp/tests/jrnl/msg_producer.hpp
Log:
Fixed some bugs in test framewrok
Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-11-14 20:35:07 UTC (rev 1314)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-11-14 22:20:42 UTC (rev 1315)
@@ -216,7 +216,7 @@
rmgr::read(void** const datapp, size_t& dsize, void** const xidpp, size_t& xidsize, bool& transient,
bool& external, data_tok* dtokp) throw (jexception)
{
-//std::cout << " rmgr::read() ro=" << (_jc->is_read_only()?"T":"F") << " po=" << _pg_offset_dblks << " ems=" << _emap.size() << std::flush;
+//std::cout << " rmgr::read() ro=" << (_jc->is_read_only()?"T":"F") << " po=" << _pg_offset_dblks << " ems=" << _emap.size() << " tms=" << _tmap.size() << std::flush;
iores res = pre_read_check(dtokp);
if (res != RHM_IORES_SUCCESS)
Modified: store/trunk/cpp/tests/jrnl/Makefile.rtest
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-11-14 20:35:07 UTC (rev 1314)
+++ store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-11-14 22:20:42 UTC (rev 1315)
@@ -77,7 +77,7 @@
CXX = g++
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)
+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 -g -O0 -pthread $(CXXINCLUDES)
LDFLAGS = -lpthread -laio -lrt -lqpidcommon -L$(QPID_HOME_DIR)/cpp/src/.libs
.SUFFIXES:
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-11-14 20:35:07 UTC (rev 1314)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-11-14 22:20:42 UTC (rev 1315)
@@ -217,6 +217,9 @@
gettimeofday(_end_time, _tz_ptr);
string str;
cout << "run(): " << report_time(str) << endl;
+ double rate = c_args->_num_msgs / time_diff(_start_time, _end_time) / 1000.0;
+ cout.precision(3);
+ cout << "rate = " << fixed << rate << " kmsgs/sec" << endl;
#endif
}
@@ -250,11 +253,16 @@
_dtok_master_list.clear();
}
+double
+jtest::time_diff(const struct timeval* start, const struct timeval* end)
+{
+ return end->tv_sec - start->tv_sec + (end->tv_usec - start->tv_usec)/1e6;
+}
+
string&
jtest::report_time(string& str) const
{
- double diff = _end_time->tv_sec - _start_time->tv_sec +
- (_end_time->tv_usec - _start_time->tv_usec)/1e6;
+ double diff = time_diff(_start_time, _end_time);
stringstream ss;
ss.precision(6);
ss << fixed << diff << " sec";
Modified: store/trunk/cpp/tests/jrnl/jtest.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.hpp 2007-11-14 20:35:07 UTC (rev 1314)
+++ store/trunk/cpp/tests/jrnl/jtest.hpp 2007-11-14 22:20:42 UTC (rev 1315)
@@ -100,6 +100,7 @@
static msg_consumer _mc;
private:
+ static double time_diff(const struct timeval* start, const struct timeval* end);
string& report_time(string& str) const;
// AIO callback functions
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-11-14 20:35:07 UTC (rev 1314)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-11-14 22:20:42 UTC (rev 1315)
@@ -290,10 +290,15 @@
}
if (chk_xid_data)
{
+ int xid_num_size = xid_size - 5 > 16 ? 16 : xid_size - 5;
+ std::stringstream xid;
+ xid << "xid:" << std::hex << std::setfill('0') << std::setw(xid_num_size) << msgCntr << ":";
+ for (unsigned i = xid_num_size + 5; i < xid_size; i++)
+ xid << (char)('a' + (i%26));
for (unsigned i=0; i<xid_size; i++)
{
char found = ((char*)xidp)[i];
- char expected = 'a' + (((msgCntr%26) + i) % 26);
+ char expected = xid.str().at(i);
if (found != expected)
{
std::stringstream ss;
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-11-14 20:35:07 UTC (rev 1314)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-11-14 22:20:42 UTC (rev 1315)
@@ -67,7 +67,6 @@
{
instance_cnt++;
init_msg_buff();
- init_xid_buff();
_aio_cmpl_dtok_list.clear();
_dd_dtok_list.clear();
}
@@ -117,9 +116,6 @@
if (maxMsgSize > _msg_buff_size)
throw rhm::journal::jexception(EXCEPTION_BASE+0,
"Message size exceeds internal buffer limit", "msg_producer", "produce");
- if (maxXidSize > _xid_buff_size)
- throw rhm::journal::jexception(EXCEPTION_BASE+1,
- "XID size exceeds internal buffer limit", "msg_producer", "produce");
{
//std::cout << "[" << _num_msgs << "]" << std::flush;
@@ -133,7 +129,12 @@
size_t sizeRange = maxXidSize - minXidSize + 1;
xid_size = minXidSize + (int)(1.0*rand()*sizeRange/(RAND_MAX + 1.0));
}
- const std::string xid((char*)_xid_buff + (msgCntr%26), xid_size);
+ int xid_num_size = xid_size - 5 > 16 ? 16 : xid_size - 5;
+ std::stringstream xid;
+ xid << "xid:" << std::hex << std::setfill('0');
+ xid << std::setw(xid_num_size) << msgCntr << ":";
+ for (unsigned i = xid_num_size + 5; i < xid_size; i++)
+ xid << (char)('a' + (i%26));
size_t size = maxMsgSize;
if (minMsgSize < maxMsgSize)
{
@@ -150,9 +151,10 @@
if (maxXidSize)
{
if (external)
- eres = jc.enqueue_extern_txn_data_record(size, dtokp, xid, transient);
+ eres = jc.enqueue_extern_txn_data_record(size, dtokp, xid.str(), transient);
else
- eres = jc.enqueue_txn_data_record(msg, size, size, dtokp, xid, transient);
+ eres = jc.enqueue_txn_data_record(msg, size, size, dtokp, xid.str(),
+ transient);
}
else
{
@@ -220,6 +222,46 @@
//print_dbug(msgCntr, size, (char*)msg, true);
}
+ // If transactional, write commit
+ if (xid_size)
+ {
+ written = false;
+ // Create new data_tok, push to back of maseter list
+ rhm::journal::data_tok* txn_dtokp = new rhm::journal::data_tok;
+ _dtok_master_list.push_back(txn_dtokp);
+//std::cout << " T" << dtokp->id() << " " << std::flush;
+ while (!written)
+ {
+ rhm::journal::iores dres;
+ dres = _jcptr->txn_commit(txn_dtokp, dtokp->xid());
+
+ const char* wsstr = dtokp->wstate_str();
+ switch (dres)
+ {
+ case rhm::journal::RHM_IORES_SUCCESS:
+ written = true;
+ _num_txn_subm++;
+ break;
+ case rhm::journal::RHM_IORES_AIO_WAIT:
+ if (aio_sleep_cnt >= MAX_AIO_SLEEPS)
+ throw rhm::journal::jexception(EXCEPTION_BASE+8,
+ "Page cache full (AIO events outstanding for all pages); "
+ "exceeded wait time for pages to free.", "msg_producer",
+ "send_deferred_dequeues");
+ jc.get_wr_events();
+ usleep(AIO_SLEEP_TIME);
+ aio_sleep_cnt++;
+ break;
+ default:
+ std::stringstream ss;
+ ss << "msg_producer::send_deferred_dequeues() "
+ "Unexpected msg state: id=" << dtokp->id() << " ws=" <<
+ wsstr << " res=" << iores_str[dres];
+ throw rhm::journal::jexception(EXCEPTION_BASE+9, ss.str().c_str(),
+ "msg_producer", "send_deferred_dequeues");
+ }
+ }
+ }
// Submit deferred dequeues (if any)
if (_auto_dequeue)
@@ -272,21 +314,21 @@
if (st == rhm::journal::data_tok::ENQ)
{
_num_msgs_enq++;
-//std::cout << ">E" << dtokp->id() << " " << std::flush;
+//std::cout << " >E" << dtokp->id() << " " << std::flush;
_dd_dtok_list.push_back(dtokp);
}
else if (dtokp->wstate() == rhm::journal::data_tok::DEQ)
{
-//std::cout << ">D" << dtokp->id() << " " << std::flush;
+//std::cout << " >D" << dtokp->id() << " " << std::flush;
_num_msgs_deq++;
}
else if (dtokp->wstate() == rhm::journal::data_tok::ABORTED ||
dtokp->wstate() == rhm::journal::data_tok::COMMITTED)
{
-//std::cout << ">T" << dtokp->id() << " " << std::flush;
+//std::cout << " >T" << dtokp->id() << " " << std::flush;
_num_txn++;
}
-//else std::cout << ">?" << dtokp->id() << " st=" << dtokp->wstate_str() << " " << std::flush;
+//else std::cout << " >?" << dtokp->id() << " st=" << dtokp->wstate_str() << " " << std::flush;
this_dtok_list.pop_front();
}
}
@@ -305,13 +347,6 @@
}
void
-msg_producer::init_xid_buff()
-{
- for (unsigned int i=0; i<_xid_buff_size; i++)
- _xid_buff[i] = 'a' + i%26;
-}
-
-void
msg_producer::send_deferred_dequeues(rhm::journal::jcntl& jc)
{
for (unsigned i=0; i<_dd_dtok_list.size(); i++)
@@ -325,86 +360,47 @@
{
//std::cout << " D" << ddtokp->id() << " " << std::flush;
_dd_dtok_list.erase(_dd_dtok_list.begin() + i--);
- unsigned aio_sleep_cnt = 0;
- bool written = false;
- while (!written)
+ unsigned aio_sleep_cnt;
+ bool written;
+ if (_auto_dequeue)
{
- rhm::journal::iores dres;
- if (ddtokp->has_xid())
- dres = _jcptr->dequeue_txn_data_record(ddtokp, ddtokp->xid());
- else
- dres = _jcptr->dequeue_data_record(ddtokp);
-
- const char* wsstr = ddtokp->wstate_str();
- switch (dres)
- {
- case rhm::journal::RHM_IORES_SUCCESS:
- written = true;
- _num_msgs_deq_subm++;
- break;
- case rhm::journal::RHM_IORES_AIO_WAIT:
- if (aio_sleep_cnt >= MAX_AIO_SLEEPS)
- throw rhm::journal::jexception(EXCEPTION_BASE+6,
- "Page cache full (AIO events outstanding for all pages); "
- "exceeded wait time for pages to free.", "msg_producer",
- "send_deferred_dequeues");
-//std::cout << "$" << dres << " " << std::flush;
- jc.get_wr_events();
- usleep(AIO_SLEEP_TIME);
- aio_sleep_cnt++;
- break;
- default:
- std::stringstream ss;
- ss << "msg_producer::send_deferred_dequeues() Unexpected msg state: id=" <<
- ddtokp->id() << " ws=" << wsstr << " res=" << iores_str[dres];
- throw rhm::journal::jexception(EXCEPTION_BASE+7, ss.str().c_str(),
- "msg_producer", "send_deferred_dequeues");
- }
- }
-
- // If transactional, commit for even rids, abort for odd rids
- if (ddtokp->has_xid())
- {
+ aio_sleep_cnt = 0;
written = false;
- // Create new data_tok, push to back of maseter list
- rhm::journal::data_tok* txn_dtokp = new rhm::journal::data_tok;
- _dtok_master_list.push_back(txn_dtokp);
-//std::cout << " T" << ddtokp->id() << " " << std::flush;
while (!written)
{
rhm::journal::iores dres;
- if (ddtokp->rid()%2)
- dres = _jcptr->txn_abort(txn_dtokp, ddtokp->xid());
+ if (ddtokp->has_xid())
+ dres = _jcptr->dequeue_txn_data_record(ddtokp, ddtokp->xid());
else
- dres = _jcptr->txn_commit(txn_dtokp, ddtokp->xid());
-
+ dres = _jcptr->dequeue_data_record(ddtokp);
+
const char* wsstr = ddtokp->wstate_str();
switch (dres)
{
case rhm::journal::RHM_IORES_SUCCESS:
written = true;
- _num_txn_subm++;
+ _num_msgs_deq_subm++;
break;
case rhm::journal::RHM_IORES_AIO_WAIT:
if (aio_sleep_cnt >= MAX_AIO_SLEEPS)
- throw rhm::journal::jexception(EXCEPTION_BASE+8,
+ throw rhm::journal::jexception(EXCEPTION_BASE+6,
"Page cache full (AIO events outstanding for all pages); "
"exceeded wait time for pages to free.", "msg_producer",
"send_deferred_dequeues");
+//std::cout << "$" << dres << " " << std::flush;
jc.get_wr_events();
usleep(AIO_SLEEP_TIME);
aio_sleep_cnt++;
break;
default:
std::stringstream ss;
- ss << "msg_producer::send_deferred_dequeues() "
- "Unexpected msg state: id=" << ddtokp->id() << " ws=" <<
- wsstr << " res=" << iores_str[dres];
- throw rhm::journal::jexception(EXCEPTION_BASE+9, ss.str().c_str(),
+ ss << "Unexpected msg state: id=" << ddtokp->id();
+ ss << " ws=" << wsstr << " res=" << iores_str[dres];
+ throw rhm::journal::jexception(EXCEPTION_BASE+7, ss.str().c_str(),
"msg_producer", "send_deferred_dequeues");
- }
- }
- }
+ } // switch (dres)
+ } // while (!written)
+ } // if (_auto_dequeue)
}
}
}
@@ -412,6 +408,7 @@
void
msg_producer::jrnl_flush(rhm::journal::jcntl& jc, u_int32_t num_msgs_sent)
{
+std::cout << "msg_producer::jrnl_flush(" << num_msgs_sent << ")" << std::endl << std::flush;
// Clear any unsent enqueues in buffer, then wait for all enqueues to return
unsigned flush_cnt = 0;
assert(num_msgs_sent == _num_msgs_enq_subm);
@@ -428,7 +425,7 @@
throw rhm::journal::jexception(EXCEPTION_BASE+10, ss.str().c_str(), "msg_producer",
"jrnl_flush");
}
-//std::cout << "+" << std::flush;
+std::cout << "+" << std::flush;
jc.get_wr_events();
usleep(FLUSH_SLEEPTIME);
flush_cnt++;
@@ -438,7 +435,7 @@
// Submit deferred dequeues (if any)
if (_auto_dequeue)
{
-//std::cout << "auto_dequeue: " << _dd_dtok_list.size() << " dequeues waiting. " << std::flush;
+std::cout << "auto_dequeue: " << _dd_dtok_list.size() << " dequeues waiting. " << std::flush;
u_int32_t cnt = 0;
send_deferred_dequeues(jc);
while (!_dd_dtok_list.empty() && !_interrupt_flag)
@@ -450,10 +447,11 @@
usleep(1000);
send_deferred_dequeues(jc);
}
-//std::cout << "auto_dequeue: done. " << std::flush;
+std::cout << "auto_dequeue: done. " << std::flush;
// Clear any unsent dequeues in buffer, then wait for all dequeues to return
flush_cnt = 0;
+std::cout << "_num_msgs_deq_subm=" << _num_msgs_deq_subm << std::endl << std::flush;
assert(num_msgs_sent == _num_msgs_deq_subm);
if (_num_msgs_deq < _num_msgs_deq_subm || _num_txn < _num_txn_subm)
{
@@ -469,7 +467,7 @@
throw rhm::journal::jexception(EXCEPTION_BASE+12, ss.str().c_str(),
"msg_producer", "jrnl_flush");
}
-//std::cout << "*" << std::flush;
+std::cout << "*" << std::flush;
jc.get_wr_events();
usleep(1000);
flush_cnt++;
@@ -522,8 +520,6 @@
u_int16_t msg_producer::instance_cnt = 0;
const size_t msg_producer::_msg_buff_size = JRNL_DBLK_SIZE * JRNL_SBLK_SIZE * JRNL_FILE_SIZE * JRNL_NUM_FILES;
-const size_t msg_producer::_xid_buff_size = JRNL_DBLK_SIZE * JRNL_SBLK_SIZE * JRNL_FILE_SIZE * JRNL_NUM_FILES;
char msg_producer::_msg_buff[msg_producer::_msg_buff_size];
-char msg_producer::_xid_buff[msg_producer::_xid_buff_size];
bool msg_producer::_interrupt_flag = false;
Modified: store/trunk/cpp/tests/jrnl/msg_producer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-11-14 20:35:07 UTC (rev 1314)
+++ store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-11-14 22:20:42 UTC (rev 1315)
@@ -66,8 +66,6 @@
static u_int16_t instance_cnt;
static const size_t _msg_buff_size;
static char _msg_buff[];
- static const size_t _xid_buff_size;
- static char _xid_buff[];
static bool _interrupt_flag;
rhm::journal::jcntl* _jcptr;
u_int32_t _num_msgs;
@@ -106,7 +104,6 @@
private:
void init_msg_buff();
- void init_xid_buff();
void send_deferred_dequeues(rhm::journal::jcntl& jc);
void jrnl_flush(rhm::journal::jcntl& jc, u_int32_t num_msgs_sent);
void print_dbug(u_int32_t msg_cnt, size_t msg_size, char* _msg_buff, bool show_msg = false) const;
17 years, 1 month
rhmessaging commits: r1314 - mgmt/mint.
by rhmessaging-commits@lists.jboss.org
Author: nunofsantos
Date: 2007-11-14 15:35:07 -0500 (Wed, 14 Nov 2007)
New Revision: 1314
Modified:
mgmt/mint/schemaparser.py
Log:
fix bug introduced @r1291
Modified: mgmt/mint/schemaparser.py
===================================================================
--- mgmt/mint/schemaparser.py 2007-11-14 20:16:13 UTC (rev 1313)
+++ mgmt/mint/schemaparser.py 2007-11-14 20:35:07 UTC (rev 1314)
@@ -121,7 +121,7 @@
# generate foreign keys
refName = self.attrNameFromDbColumn(refName, "Mint", "Ref")
# add missing attribute (not added correctly with SqlObject 0.7.7; may need to be removed in later versions)
- self.pythonOutput += " _SO_class_%s = None\n" % (self.style.pythonAttrToDBColumn(refName).capitalize())
+ self.pythonOutput += " _SO_class_%s = %s\n" % (self.style.pythonAttrToDBColumn(refName).capitalize(), refName)
self.additional += "\n%s.sqlmeta.addJoin(MultipleJoin('%s" % (refName, name)
self.additional += "', joinMethodName='%ss'))" % (name.replace("Mint", "").lower())
@@ -162,7 +162,7 @@
self.additional = ""
if (name != "" and not name.endswith("Stats")):
# add missing attribute (not added correctly with SqlObject 0.7.7; may need to be removed in later versions)
- self.pythonOutput += " _SO_class_%s_stats = None\n" % (self.style.pythonAttrToDBColumn(name).capitalize())
+ self.pythonOutput += " _SO_class_%s_stats = %sStats\n" % (self.style.pythonAttrToDBColumn(name).capitalize(), name)
def getCode(self):
return self.pythonOutput
17 years, 1 month
rhmessaging commits: r1313 - mgmt/etc.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-11-14 15:16:13 -0500 (Wed, 14 Nov 2007)
New Revision: 1313
Added:
mgmt/etc/devel.profile.tcsh
Log:
A csh variant of devel.profile
Added: mgmt/etc/devel.profile.tcsh
===================================================================
--- mgmt/etc/devel.profile.tcsh (rev 0)
+++ mgmt/etc/devel.profile.tcsh 2007-11-14 20:16:13 UTC (rev 1313)
@@ -0,0 +1,40 @@
+if (! $?DEVEL_HOME) then
+ setenv DEVEL_HOME "$PWD"
+endif
+
+set DEVEL_MODULES=(mint cumin)
+
+# PYTHONPATH
+
+if ($?PYTHONPATH) then
+ if (! $?DEVEL_ORIGINAL_PYTHONPATH) then
+ setenv DEVEL_ORIGINAL_PYTHONPATH "$PYTHONPATH"
+ endif
+else
+ setenv DEVEL_ORIGINAL_PYTHONPATH
+endif
+
+set pypath="$DEVEL_HOME"/lib/python:"$HOME"/lib/python:"$DEVEL_ORIGINAL_PYTHONPATH"
+
+foreach module ($DEVEL_MODULES)
+ set pypath="$DEVEL_HOME"/"$module"/python:"$pypath"
+end
+
+setenv PYTHONPATH "$pypath"
+
+# PATH
+
+if (! $?DEVEL_ORIGINAL_PATH) then
+ setenv DEVEL_ORIGINAL_PATH "$PATH"
+endif
+
+set path="$DEVEL_HOME"/bin:"$DEVEL_ORIGINAL_PATH"
+
+foreach module ($DEVEL_MODULES)
+ set path="$DEVEL_HOME"/"$module"/bin:"$path"
+end
+
+setenv PATH "$path"
+
+# cumin test instance
+setenv CUMIN_HOME "$DEVEL_HOME"/cumin-test-0
17 years, 1 month
rhmessaging commits: r1312 - mgmt.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-11-14 14:19:38 -0500 (Wed, 14 Nov 2007)
New Revision: 1312
Modified:
mgmt/README
Log:
Corrections from Ted's trial run.
Modified: mgmt/README
===================================================================
--- mgmt/README 2007-11-14 16:11:17 UTC (rev 1311)
+++ mgmt/README 2007-11-14 19:19:38 UTC (rev 1312)
@@ -20,16 +20,23 @@
haven't already done it, you'll need to initialize the postgres
database and start it up:
+To initialize the postgresql data files:
+
$ su -
Password:
- # /sbin/service postgresql initdb
+ # su - postgres # Now you're the postgres user
+ $ initdb -D /var/lib/pgsql/data
+
+To start the postgresql service:
+
+ $ exit # Back to the root user
# /sbin/service postgresql start
Starting postgresql service: [ OK ]
Then you can create a database. First you have to switch to the
postgres user, and then you can use the create* scripts:
- # su - postgres
+ # su - postgres # Become the postgres user again
$ createuser --superuser exampleuser
CREATE ROLE
$ createdb --owner=exampleuser exampledb
17 years, 1 month
rhmessaging commits: r1311 - in mgmt/mint: python/mint and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: nunofsantos
Date: 2007-11-14 11:11:17 -0500 (Wed, 14 Nov 2007)
New Revision: 1311
Modified:
mgmt/mint/python/mint/__init__.py
mgmt/mint/schemaparser.py
Log:
global rename of MgmtXXX to MintXXX; rename of allXXX methods to simply XXX (allQueues becomes queues)
Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py 2007-11-14 00:54:29 UTC (rev 1310)
+++ mgmt/mint/python/mint/__init__.py 2007-11-14 16:11:17 UTC (rev 1311)
@@ -13,57 +13,57 @@
def getQueueByOriginalId(self, id, create=False):
queue = None
try:
- queue = MgmtQueue.selectBy(idOriginal=id)[:1][0]
+ queue = MintQueue.selectBy(idOriginal=id)[:1][0]
except IndexError:
- if (create): queue = MgmtQueue(idOriginal=id)
+ if (create): queue = MintQueue(idOriginal=id)
return queue
def getQueueByName(self, name, vhost, create=False):
queue = None
try:
- queue = MgmtQueue.selectBy(name=name, mgmtVhost=vhost)[:1][0]
+ queue = MintQueue.selectBy(name=name, mintVhost=vhost)[:1][0]
except IndexError:
- if (create): queue = MgmtQueue(name=name, mgmtVhost=vhost)
+ if (create): queue = MintQueue(name=name, mintVhost=vhost)
return queue
def getVhostByName(self, name, broker, create=False):
vhost = None
try:
- vhost = MgmtVhost.selectBy(name=name, mgmtBroker=broker)[:1][0]
+ vhost = MintVhost.selectBy(name=name, mintBroker=broker)[:1][0]
except IndexError:
- if (create): vhost = MgmtVhost(name=name, mgmtBroker=broker)
+ if (create): vhost = MintVhost(name=name, mintBroker=broker)
return vhost
def getVhostByOriginalId(self, id, create=False):
vhost = None
try:
- vhost = MgmtVhost.selectBy(idOriginal=id)[:1][0]
+ vhost = MintVhost.selectBy(idOriginal=id)[:1][0]
except IndexError:
- if (create): vhost = MgmtVhost(idOriginal=id)
+ if (create): vhost = MintVhost(idOriginal=id)
return vhost
def getBrokerByPort(self, port, system, create=False):
broker = None
try:
- broker = MgmtBroker.selectBy(port=port, mgmtSystem=system)[:1][0]
+ broker = MintBroker.selectBy(port=port, mintSystem=system)[:1][0]
except IndexError:
- if (create): broker = MgmtBroker(port=port, mgmtSystem=system)
+ if (create): broker = MintBroker(port=port, mintSystem=system)
return broker
def getBrokerByOriginalId(self, id, create=False):
broker = None
try:
- broker = MgmtBroker.selectBy(idOriginal=id)[:1][0]
+ broker = MintBroker.selectBy(idOriginal=id)[:1][0]
except IndexError:
- if (create): broker = MgmtBroker(idOriginal=id)
+ if (create): broker = MintBroker(idOriginal=id)
return broker
def getSystemByOriginalId(self, id, create=False):
system = None
try:
- system = MgmtSystem.selectBy(idOriginal=id)[:1][0]
+ system = MintSystem.selectBy(idOriginal=id)[:1][0]
except IndexError:
- if (create): system = MgmtSystem(idOriginal=id)
+ if (create): system = MintSystem(idOriginal=id)
return system
def sanitizeDict(self, d):
@@ -85,7 +85,7 @@
elif (k.endswith("Ref")):
oldK = k
k = k[0].upper() + k[1:]
- return "mgmt" + k.replace("Ref", "ID")
+ return "mint" + k.replace("Ref", "ID")
def configCallback(self, broker, objectName, list, timestamps):
print "\nCONFIG---------------------------------------------------"
@@ -132,14 +132,14 @@
if (objectName == "queue"):
print "* QUEUE"
queue = self.getQueueByOriginalId(d[self.convertKey("id")])
- d["mgmtQueue"] = queue.id
+ d["mintQueue"] = queue.id
d["recTime"] = datetime.fromtimestamp(timestamps[0]/1000000000)
- queueStats = MgmtQueueStats()
+ queueStats = MintQueueStats()
queueStats.set(**d)
d = dict()
if (timestamps[2] != 0):
d["deletionTime"] = datetime.fromtimestamp(timestamps[2]/1000000000)
- d["mgmtQueueStats"] = queueStats
+ d["mintQueueStats"] = queueStats
queue.set(**d)
print queue.id
result = queueStats
@@ -176,5 +176,5 @@
self.outstandingMethodCalls[methodId] = callback
return methodId
- def allSystems(self):
- return MgmtSystem.select()
+ def systems(self):
+ return MintSystem.select()
Modified: mgmt/mint/schemaparser.py
===================================================================
--- mgmt/mint/schemaparser.py 2007-11-14 00:54:29 UTC (rev 1310)
+++ mgmt/mint/schemaparser.py 2007-11-14 16:11:17 UTC (rev 1311)
@@ -11,7 +11,7 @@
self.currentTable = ""
self.style = style
# mapping between xml schema types and database column types
- # see xml/MgmtTypes.xml
+ # see xml/MintTypes.xml
self.dataTypesMap = dict()
self.dataTypesMap["objId"] = "INT8"
self.dataTypesMap["uint8"] = self.dataTypesMap["hilo8"] = self.dataTypesMap["count8"] = "INT2"
@@ -67,7 +67,7 @@
actualType = elem["@type"]
params = ""
if (elem["@name"].endswith("Ref")):
- foreignKeyTable = "mgmt_" + actualName.replace("_ref", "")
+ foreignKeyTable = "mint_" + actualName.replace("_ref", "")
self.sqlOutput += " %s_id BIGINT REFERENCES %s,\n" % (foreignKeyTable, foreignKeyTable)
else:
self.sqlOutput += " %s %s %s,\n" % (actualName, self.dataTypesMap[actualType], params)
@@ -119,11 +119,11 @@
refName = elem["@name"]
if (refName.endswith("Ref")):
# generate foreign keys
- refName = self.attrNameFromDbColumn(refName, "Mgmt", "Ref")
+ refName = self.attrNameFromDbColumn(refName, "Mint", "Ref")
# add missing attribute (not added correctly with SqlObject 0.7.7; may need to be removed in later versions)
self.pythonOutput += " _SO_class_%s = None\n" % (self.style.pythonAttrToDBColumn(refName).capitalize())
self.additional += "\n%s.sqlmeta.addJoin(MultipleJoin('%s" % (refName, name)
- self.additional += "', joinMethodName='all%ss'))" % (name.replace("Mgmt", ""))
+ self.additional += "', joinMethodName='%ss'))" % (name.replace("Mint", "").lower())
def startClass(self, pythonName, schemaName="", schemaId=""):
self.pythonOutput += "\nclass %s(SQLObject):\n" % (pythonName)
@@ -193,7 +193,7 @@
schema = mllib.xml_parse(self.options["schemaXML"])
classes = schema.query["schema/class"]
for cls in classes:
- actualName = "mgmt_" + cls["@name"]
+ actualName = "mint_" + cls["@name"]
self.sqlGen.generate(actualName, cls.query["configElement"], "config")
self.sqlGen.generate(actualName, cls.query["instElement"], "inst")
self.pythonGen.generate(actualName, cls["@name"], cls["@schemaId"], cls.query["method"])
17 years, 1 month
rhmessaging commits: r1310 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-11-13 19:54:29 -0500 (Tue, 13 Nov 2007)
New Revision: 1310
Modified:
mgmt/cumin/python/cumin/__init__.py
mgmt/cumin/python/cumin/brokergroup.py
Log:
Adds a bit of logic to add a MgmtSystem if it isn't already there.
Fixes a leftover buglet from the Widget.parent rename.
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2007-11-14 00:43:49 UTC (rev 1309)
+++ mgmt/cumin/python/cumin/__init__.py 2007-11-14 00:54:29 UTC (rev 1310)
@@ -6,6 +6,9 @@
from wooly.server import WebServer
from wooly.devel import DevelPage
from wooly.parameters import IntegerParameter
+from mint import *
+from mint.schema import *
+from sqlobject.main import *
from model import CuminModel
from demo import DemoData
@@ -27,6 +30,16 @@
self.model = model
+ self.mint = MintModel()
+
+ try:
+ sys = MgmtSystem.get(1)
+ except SQLObjectNotFound:
+ sys = MgmtSystem()
+ sys.set(sysIdent=0, idOriginal=0)
+
+ self.model.sys = sys
+
self.cumin_page = CuminPage(self, "cumin.html")
self.set_default_page(self.cumin_page)
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2007-11-14 00:43:49 UTC (rev 1309)
+++ mgmt/cumin/python/cumin/brokergroup.py 2007-11-14 00:54:29 UTC (rev 1310)
@@ -135,7 +135,7 @@
def process_cancel(self, session, group):
branch = session.branch()
- self.parent.show_view(branch)
+ self.parent().show_view(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, group):
17 years, 1 month
rhmessaging commits: r1309 - in mgmt: cumin/bin and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-11-13 19:43:49 -0500 (Tue, 13 Nov 2007)
New Revision: 1309
Modified:
mgmt/README
mgmt/cumin/bin/cumin-test
Log:
Expands the instructions in README.
Fixes the no-conf file case in cumin-test.
Modified: mgmt/README
===================================================================
--- mgmt/README 2007-11-14 00:17:50 UTC (rev 1308)
+++ mgmt/README 2007-11-14 00:43:49 UTC (rev 1309)
@@ -1,16 +1,64 @@
-This is the development environment for the Red Hat messaging
+This is the development environment for the Red Hat Messaging
management suite.
-To use the development environment, you need to source the
-etc/devel.profile file in your shell. Then commands such as
-cumin-test can be run.
+DEPENDENCIES
+------------
+
+To run the management code, you need the following packages (on top of
+what you get in a typical Fedora install):
+
+ postgresql-server
+ python-sqlobject
+ python-psycopg2
+
+
+PREPARING THE DATABASE
+----------------------
+
+You will also need to create a database and load the schema. If you
+haven't already done it, you'll need to initialize the postgres
+database and start it up:
+
+ $ su -
+ Password:
+ # /sbin/service postgresql initdb
+ # /sbin/service postgresql start
+ Starting postgresql service: [ OK ]
+
+Then you can create a database. First you have to switch to the
+postgres user, and then you can use the create* scripts:
+
+ # su - postgres
+ $ createuser --superuser exampleuser
+ CREATE ROLE
+ $ createdb --owner=exampleuser exampledb
+ CREATE DATABASE
+
+Now you can load the scheme definition:
+
+ $ exit # Leave the postgres user
+ # exit # Leave the root user (be yourself!)
+ $ cd mgmt
+ $ psql -d exampledb -f mint/python/mint/schema.sql
+ ...many statements about schema objects...
+
+At this point you should have a working database that you can connect
+to at postgresql://exampleuser@localhost/exampledb.
+
+
+USING THE DEVEL ENVIRONMENT
+---------------------------
+
+First, you need to source the etc/devel.profile file in your shell.
+Then commands such as cumin-test can be run.
+
For instance:
- $ svn co https://svn.jboss.org/repos/rhmessaging/mgmt/
$ cd mgmt
$ . etc/devel.profile
- $ cumin-test
+ $ cumin-test --data postgresql://exampleuser@localhost/exampledb
+ Cumin server started on port 9090
For your convenience, there is a script, bin/devel, which you can use
to start up the devel environment. I recommend putting a small
Modified: mgmt/cumin/bin/cumin-test
===================================================================
--- mgmt/cumin/bin/cumin-test 2007-11-14 00:17:50 UTC (rev 1308)
+++ mgmt/cumin/bin/cumin-test 2007-11-14 00:43:49 UTC (rev 1309)
@@ -9,8 +9,9 @@
conf = SafeConfigParser()
conf.read(os.path.expanduser("~/.cumin.conf"))
- for key, value in conf.items("main"):
- args[key] = value
+ if (conf.has_section("main")):
+ for key, value in conf.items("main"):
+ args[key] = value
key = None
@@ -22,10 +23,12 @@
args[key] = arg
key = None
- print "Parameters:"
- for key in args:
- print " %10s %s" % (key, args[key])
+ if args:
+ print "Parameters:"
+ for key in args:
+ print " %10s %s" % (key, args[key])
+
return args
from sqlobject import *
17 years, 1 month
rhmessaging commits: r1308 - in store/trunk/cpp: tests/jrnl and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-13 19:17:50 -0500 (Tue, 13 Nov 2007)
New Revision: 1308
Modified:
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jcntl.hpp
store/trunk/cpp/lib/jrnl/jexception.cpp
store/trunk/cpp/lib/jrnl/jexception.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/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
store/trunk/cpp/tests/jrnl/prof
store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
Log:
Fixes to jexception (again) and to the unit tests for jexception. This time no out-of-scope pointers... Also solved problem with message producer's send_deferred_dequeues() method which had intermittent hangs and double dequeueing when auto-dequeue was active.
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -84,8 +84,8 @@
}
void
-jcntl::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)
+jcntl::initialize(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb,
+ std::deque<data_tok*>* wdtoklp, const aio_cb wr_cb) throw (jexception)
{
// Prepare journal dir, journal files and file handles
_jdir.clear_dir();
@@ -116,8 +116,8 @@
// constrains read activity (i.e. one can't read what has not yet been written).
_wrfc.initialize(JRNL_NUM_FILES, (nlfh**)_datafh);
_rrfc.initialize(JRNL_NUM_FILES, (nlfh**)_datafh);
- _rmgr.initialize(rd_dtokl, rd_cb);
- _wmgr.initialize(wr_dtokl, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
+ _rmgr.initialize(rdtoklp, rd_cb);
+ _wmgr.initialize(wdtoklp, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
// Write info file (<basename>.jinf) to disk
write_infofile();
@@ -126,7 +126,7 @@
}
void
-jcntl::recover(std::deque<data_tok*>* rd_dtokl, const aio_cb rd_cb, std::deque<data_tok*>* wr_dtokl,
+jcntl::recover(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb, std::deque<data_tok*>* wdtoklp,
const aio_cb wr_cb, const std::vector<std::string>& prep_txn_list) throw (jexception)
{
// Verify journal dir and journal files
@@ -160,8 +160,8 @@
// constrains read activity (i.e. one can't read what has not yet been written).
_wrfc.initialize(JRNL_NUM_FILES, (nlfh**)_datafh, &_rcvdat);
_rrfc.initialize(JRNL_NUM_FILES, (nlfh**)_datafh, _rcvdat._ffid);
- _rmgr.initialize(rd_dtokl, rd_cb);
- _wmgr.initialize(wr_dtokl, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
+ _rmgr.initialize(rdtoklp, rd_cb);
+ _wmgr.initialize(wdtoklp, wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
_readonly_flag = true;
_init_flag = true;
Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -176,16 +176,16 @@
* <b>NOTE: If <i>NULL</i> is passed to the callbacks, internal default callbacks will be
* used.</b>
*
- * \param rd_dtokl deque for storing data tokens retruning from read AIO operations.
+ * \param rdtoklp 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)
+ * \param wdtoklp deque for storing data tokens retruning from enqueue and dequeue (write)
* AIO operations.
* \param wr_cb Function pointer to callback function for write operations. May be NULL.
*
* \exception TODO
*/
- 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);
+ void initialize(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb,
+ std::deque<data_tok*>* wdtoklp, const aio_cb wr_cb) throw (jexception);
/**
* \brief Initialize using internal default callbacks and data_tok lists.
@@ -215,17 +215,17 @@
* <b>NOTE: If <i>NULL</i> is passed to the callbacks, internal default callbacks will be
* used.</b>
*
- * \param rd_dtokl deque for storing data tokens retruning from read AIO operations.
+ * \param rdtoklp 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)
+ * \param wdtoklp deque for storing data tokens retruning from enqueue and dequeue (write)
* AIO operations.
* \param wr_cb Function pointer to callback function for write operations. May be NULL.
* \param prep_txn_list
*
* \exception TODO
*/
- void recover(std::deque<data_tok*>* rd_dtokl, const aio_cb rd_cb,
- std::deque<data_tok*>* wr_dtokl, const aio_cb wr_cb,
+ void recover(std::deque<data_tok*>* rdtoklp, const aio_cb rd_cb,
+ std::deque<data_tok*>* wdtoklp, const aio_cb wr_cb,
const std::vector<std::string>& prep_txn_list) throw (jexception);
/**
Modified: store/trunk/cpp/lib/jrnl/jexception.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/jexception.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -44,54 +44,59 @@
jexception::jexception() throw ():
std::exception(),
- _err_code(0),
- _additional_info(NULL),
- _throwing_class(NULL),
- _throwing_fn(NULL)
-{}
+ _err_code(0)
+{
+ *_additional_info = '\0';
+ *_throwing_class = '\0';
+ *_throwing_fn = '\0';
+}
jexception::jexception(const u_int32_t err_code) throw ():
std::exception(),
- _err_code(err_code),
- _additional_info(NULL),
- _throwing_class(NULL),
- _throwing_fn(NULL)
+ _err_code(err_code)
+{
+ *_additional_info = '\0';
+ *_throwing_class = '\0';
+ *_throwing_fn = '\0';
+}
-{}
-
jexception::jexception(const char* additional_info) throw ():
std::exception(),
- _err_code(0),
- _additional_info(additional_info),
- _throwing_class(NULL),
- _throwing_fn(NULL)
-{}
+ _err_code(0)
+{
+ if (additional_info) ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE);
+ *_throwing_class = '\0';
+ *_throwing_fn = '\0';
+}
jexception::jexception(const u_int32_t err_code, const char* additional_info) throw ():
std::exception(),
- _err_code(err_code),
- _additional_info(additional_info),
- _throwing_class(NULL),
- _throwing_fn(NULL)
-{}
+ _err_code(err_code)
+{
+ if (additional_info) ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE);
+ *_throwing_class = '\0';
+ *_throwing_fn = '\0';
+}
jexception::jexception(const u_int32_t err_code, const char* throwing_class,
const char* throwing_fn) throw ():
std::exception(),
- _err_code(err_code),
- _additional_info(NULL),
- _throwing_class(throwing_class),
- _throwing_fn(throwing_fn)
-{}
+ _err_code(err_code)
+{
+ *_additional_info = '\0';
+ if (throwing_class) ::strncpy(_throwing_class, throwing_class, MAX_THROWING_SIZE);
+ if (throwing_fn) ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE);
+}
jexception::jexception(const u_int32_t err_code, const char* additional_info,
const char* throwing_class, const char* throwing_fn) throw ():
std::exception(),
- _err_code(err_code),
- _additional_info(additional_info),
- _throwing_class(throwing_class),
- _throwing_fn(throwing_fn)
-{}
+ _err_code(err_code)
+{
+ if (additional_info) ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE);
+ if (throwing_class) ::strncpy(_throwing_class, throwing_class, MAX_THROWING_SIZE);
+ if (throwing_fn) ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE);
+}
jexception::~jexception() throw ()
{}
@@ -100,11 +105,11 @@
jexception::what() const throw ()
{
std::stringstream ss;
- if (_throwing_class && _throwing_fn)
+ if (::strlen(_throwing_class) &&::strlen( _throwing_fn))
ss << _throwing_class << "::" << _throwing_fn << "() threw ";
ss << "jexception: 0x" << std::hex << std::setw(4) << std::setfill('0') << _err_code;
ss << " " << jerrno::err_msg(_err_code);
- if (_additional_info)
+ if (::strlen(_additional_info))
ss << " (" << _additional_info << ")";
return ss.str().c_str();
}
Modified: store/trunk/cpp/lib/jrnl/jexception.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/jexception.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -47,6 +47,9 @@
#include <string>
#include <sys/types.h>
+#define MAX_MSG_SIZE 1024
+#define MAX_THROWING_SIZE 128
+
namespace rhm
{
namespace journal
@@ -59,9 +62,9 @@
{
private:
u_int32_t _err_code;
- const char* _additional_info;
- const char* _throwing_class;
- const char* _throwing_fn;
+ char _additional_info[MAX_MSG_SIZE];
+ char _throwing_class[MAX_THROWING_SIZE];
+ char _throwing_fn[MAX_THROWING_SIZE];
public:
jexception() throw ();
Modified: store/trunk/cpp/lib/jrnl/pmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -80,7 +80,7 @@
_jc(jc),
_emap(emap),
_tmap(tmap),
- _dtokl(NULL),
+ _dtoklp(NULL),
_page_base_ptr(NULL),
_page_ptr_arr(NULL),
_page_cb_arr(NULL),
@@ -98,13 +98,13 @@
{}
pmgr::pmgr(jcntl* jc, enq_map& emap, txn_map& tmap, const u_int32_t pagesize, const u_int16_t pages,
- std::deque<data_tok*>* const dtokl) throw (jexception):
+ std::deque<data_tok*>* const dtoklp) throw (jexception):
_pagesize(pagesize),
_pages(pages),
_jc(jc),
_emap(emap),
_tmap(tmap),
- _dtokl(dtokl),
+ _dtoklp(dtoklp),
_page_base_ptr(NULL),
_page_ptr_arr(NULL),
_page_cb_arr(NULL),
Modified: store/trunk/cpp/lib/jrnl/pmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/pmgr.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -118,7 +118,7 @@
jcntl* _jc; ///< Pointer to journal controller
enq_map& _emap; ///< Ref to enqueue map
txn_map& _tmap; ///< Ref to transaction map
- std::deque<data_tok*>* _dtokl; ///< Pointer to external data token list
+ std::deque<data_tok*>* _dtoklp; ///< Pointer to external data token list
void* _page_base_ptr; ///< Base pointer to page memory
void** _page_ptr_arr; ///< Array of pointers to pages in page memory
page_cb* _page_cb_arr; ///< Array of page_cb structs
@@ -140,7 +140,7 @@
pmgr(jcntl* jc, enq_map& emap, txn_map& tmap, const u_int32_t pagesize,
const u_int16_t pages);
pmgr(jcntl* jc, enq_map& emap, txn_map& tmap, const u_int32_t pagesize,
- const u_int16_t pages, std::deque<data_tok*>* const dtokl) throw (jexception);
+ const u_int16_t pages, std::deque<data_tok*>* const dtoklp) throw (jexception);
virtual ~pmgr();
virtual const u_int32_t get_events(page_state state) throw (jexception) = 0;
Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -60,9 +60,9 @@
{}
void
-rmgr::initialize(std::deque<data_tok*>* const dtokl, const aio_cb rd_cb) throw (jexception)
+rmgr::initialize(std::deque<data_tok*>* const dtoklp, const aio_cb rd_cb) throw (jexception)
{
- _dtokl = dtokl;
+ _dtoklp = dtoklp;
_cb = rd_cb;
initialize();
}
@@ -444,7 +444,7 @@
// Transfer all data tokens
u_int32_t s = pcbp->_pdtokl->size();
for (u_int32_t k=0; k<s; k++)
- _dtokl->push_back(pcbp->_pdtokl->at(k));
+ _dtoklp->push_back(pcbp->_pdtokl->at(k));
tot_data_toks += s;
// Increment the completed read offset
Modified: store/trunk/cpp/lib/jrnl/rmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/rmgr.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -67,7 +67,7 @@
std::deque<data_tok*>* const dtokl) throw (jexception);
~rmgr();
- void initialize(std::deque<data_tok*>* const dtokl, const aio_cb rd_cb) throw (jexception);
+ void initialize(std::deque<data_tok*>* const dtoklp, const aio_cb rd_cb) throw (jexception);
const iores get(const u_int64_t& rid, const size_t& dsize, const size_t& dsize_avail,
const void** const data, bool auto_discard) throw (jexception);
const iores discard(data_tok* dtok) throw (jexception);
Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -58,9 +58,9 @@
_txn_pending_set()
{}
-wmgr::wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc, std::deque<data_tok*>* const dtokl,
+wmgr::wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc, std::deque<data_tok*>* const dtoklp,
const u_int32_t max_dtokpp, const u_int32_t max_iowait_us) throw (jexception):
- pmgr(jc, emap, tmap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES, dtokl),
+ pmgr(jc, emap, tmap, JRNL_WMGR_PAGE_SIZE, JRNL_WMGR_PAGES, dtoklp),
_wrfc(wrfc),
_max_dtokpp(max_dtokpp),
_max_io_wait_us(max_iowait_us),
@@ -81,10 +81,10 @@
}
void
-wmgr::initialize(std::deque<data_tok*>* dtokl, const aio_cb wr_cb, const u_int32_t max_dtokpp,
+wmgr::initialize(std::deque<data_tok*>* dtoklp, const aio_cb wr_cb, const u_int32_t max_dtokpp,
const u_int32_t max_iowait_us) throw (jexception)
{
- _dtokl = dtokl;
+ _dtoklp = dtoklp;
_max_dtokpp = max_dtokpp;
_max_io_wait_us = max_iowait_us;
_cb = wr_cb;
@@ -783,19 +783,16 @@
switch (dtp->wstate())
{
case data_tok::ENQ_SUBM:
- assert(dtp->wstate() == data_tok::ENQ_SUBM);
dtp->set_wstate(data_tok::ENQ);
if (dtp->has_xid())
_tmap.set_aio_compl(dtp->xid(), dtp->rid());
break;
case data_tok::DEQ_SUBM:
- assert(dtp->wstate() == data_tok::DEQ_SUBM);
dtp->set_wstate(data_tok::DEQ);
if (dtp->has_xid())
_tmap.set_aio_compl(dtp->xid(), dtp->rid());
break;
case data_tok::ABORT_SUBM:
- assert(dtp->wstate() == data_tok::ABORT_SUBM);
dtp->set_wstate(data_tok::ABORTED);
#if !(defined(RHM_WRONLY) || defined(RHM_RDONLY))
it = _txn_pending_set.find(dtp->xid());
@@ -810,7 +807,6 @@
#endif
break;
case data_tok::COMMIT_SUBM:
- assert(dtp->wstate() == data_tok::COMMIT_SUBM);
dtp->set_wstate(data_tok::COMMITTED);
#if !(defined(RHM_WRONLY) || defined(RHM_RDONLY))
it = _txn_pending_set.find(dtp->xid());
@@ -830,7 +826,7 @@
throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str().c_str(), "wmgr",
"get_events");
}
- _dtokl->push_back(dtp);
+ _dtoklp->push_back(dtp);
}
tot_data_toks += s;
@@ -905,7 +901,7 @@
{
clean();
std::stringstream ss;
- ss << "_iocba new(): errno=" << errno;
+ ss << "_iocba malloc(): errno=" << errno;
throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "wmgr", "initialize");
}
::memset(_iocba, 0, sizeof(iocb*) * JRNL_NUM_FILES);
Modified: store/trunk/cpp/lib/jrnl/wmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/lib/jrnl/wmgr.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -97,11 +97,11 @@
public:
wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc);
wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc,
- std::deque<data_tok*>* const dtokl, const u_int32_t max_dtokpp,
+ std::deque<data_tok*>* const dtoklp, const u_int32_t max_dtokpp,
const u_int32_t max_iowait_us) throw (jexception);
~wmgr();
- void initialize(std::deque<data_tok*>* const dtokl, aio_cb wr_cb,
+ void initialize(std::deque<data_tok*>* const dtoklp, aio_cb wr_cb,
const u_int32_t max_dtokpp, const u_int32_t max_iowait_us) throw (jexception);
const iores enqueue(const void* const data_buff, const size_t tot_data_len,
const size_t this_data_len, data_tok* dtokp, const void* const xid_ptr,
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -130,6 +130,10 @@
void
jtest::initialize(const targs& ta) throw (rhm::journal::jexception)
{
+ assert(_dtok_master_list.size() == 0);
+ assert(_dtok_wr_aio_list.size() == 0);
+ assert(_dtok_rd_aio_list.size() == 0);
+
#ifdef RHM_TIMERS
gettimeofday(_start_time, _tz_ptr);
#endif
@@ -145,9 +149,8 @@
#ifndef RHM_WRONLY
_mc.initialize(c_args);
#endif
- _jc.initialize(&_mc.aio_dtokl(), NULL, &_mp.aio_dtokl(), &mp_aio_cb);
+ _jc.initialize(&_dtok_rd_aio_list, NULL, &_dtok_wr_aio_list, &mp_aio_cb);
- assert(_dtok_master_list.size() == 0);
for (u_int32_t i=0; i<p_args->_num_msgs; i++)
{
rhm::journal::data_tok* dtp = new rhm::journal::data_tok;
@@ -261,10 +264,12 @@
// static varialbe declarations
std::deque<rhm::journal::data_tok*> jtest::_dtok_master_list;
+std::deque<rhm::journal::data_tok*> jtest::_dtok_wr_aio_list;
+std::deque<rhm::journal::data_tok*> jtest::_dtok_rd_aio_list;
msg_producer::_p_args* jtest::p_args = NULL;
msg_consumer::_c_args* jtest::c_args = NULL;
-msg_producer jtest::_mp(_dtok_master_list);
-msg_consumer jtest::_mc(_dtok_master_list);
+msg_producer jtest::_mp(_dtok_master_list, _dtok_wr_aio_list);
+msg_consumer jtest::_mc(_dtok_master_list, _dtok_rd_aio_list);
rhm::journal::jcntl jtest::_jc(JOURNAL_ID, JOURNAL_DIR, JOURNAL_BASE_FILENAME);
// static method
Modified: store/trunk/cpp/tests/jrnl/jtest.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/jtest.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -69,6 +69,8 @@
static msg_consumer::_c_args* c_args;
static rhm::journal::jcntl _jc;
static std::deque<rhm::journal::data_tok*> _dtok_master_list;
+ static std::deque<rhm::journal::data_tok*> _dtok_wr_aio_list;
+ static std::deque<rhm::journal::data_tok*> _dtok_rd_aio_list;
struct timeval* _start_time;
struct timeval* _end_time;
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -51,8 +51,10 @@
_err(0)
{}
-msg_consumer::msg_consumer(std::deque<rhm::journal::data_tok*>& dtok_master_list):
+msg_consumer::msg_consumer(std::deque<rhm::journal::data_tok*>& dtok_master_list,
+ std::deque<rhm::journal::data_tok*>& aio_cmpl_dtok_list):
_dtok_master_list(dtok_master_list),
+ _aio_cmpl_dtok_list(aio_cmpl_dtok_list),
_tot_dblks(0),
_tot_dsize(0)
{
@@ -95,8 +97,12 @@
u_int32_t
msg_consumer::consume(rhm::journal::jcntl& _jcntl, const u_int32_t num_msgs,
+#ifdef RHM_TIMERS
+ const size_t, const size_t, const size_t, const size_t, const bool, const bool)
+#else
const size_t min_msg_size, const size_t max_msg_size, const size_t min_xid_size,
const size_t max_xid_size, const bool transient_expected, const bool external_expected)
+#endif
throw (rhm::journal::jexception)
{
//std::cout << "msg_consumer::consume() num_msgs=" << num_msgs << std::endl;
@@ -136,7 +142,7 @@
_tot_dblks += dtokp->dblocks_read();
_tot_dsize += data_size;
-#ifdef RHM_TIMERS
+#ifndef RHM_TIMERS
// Comment out these for performance checks/measurements
check_msg(msgCntr, data_size, min_msg_size, max_msg_size, !external_flag,
datap);
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -68,12 +68,13 @@
static bool _interrupt_flag;
u_int32_t _num_msgs;
std::deque<rhm::journal::data_tok*>& _dtok_master_list; // One dtok per msg to be received
- std::deque<rhm::journal::data_tok*> _aio_cmpl_dtok_list; // Dtoks from completed AIOs go here
+ std::deque<rhm::journal::data_tok*>& _aio_cmpl_dtok_list; // Dtoks from completed AIOs go here
u_int64_t _tot_dblks;
u_int64_t _tot_dsize;
public:
- msg_consumer(std::deque<rhm::journal::data_tok*>& dtok_master_list);
+ msg_consumer(std::deque<rhm::journal::data_tok*>& dtok_master_list,
+ std::deque<rhm::journal::data_tok*>& aio_cmpl_dtok_list);
~msg_consumer();
void initialize(const u_int32_t numMsgs);
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -50,7 +50,8 @@
_err(0)
{}
-msg_producer::msg_producer(std::deque<rhm::journal::data_tok*>& dtok_master_list):
+msg_producer::msg_producer(std::deque<rhm::journal::data_tok*>& dtok_master_list,
+ std::deque<rhm::journal::data_tok*>& aio_cmpl_dtok_list):
_jcptr(NULL),
_num_msgs(0),
_num_msgs_enq_subm(0),
@@ -60,6 +61,7 @@
_num_txn_subm(0),
_num_txn(0),
_dtok_master_list(dtok_master_list),
+ _aio_cmpl_dtok_list(aio_cmpl_dtok_list),
_tot_dblks(0),
_tot_dsize(0)
{
@@ -312,10 +314,9 @@
void
msg_producer::send_deferred_dequeues(rhm::journal::jcntl& jc)
{
- std::deque<rhm::journal::data_tok*>::iterator ditr = _dd_dtok_list.begin();
- while (ditr != _dd_dtok_list.end())
+ for (unsigned i=0; i<_dd_dtok_list.size(); i++)
{
- rhm::journal::data_tok* ddtokp = *ditr;
+ rhm::journal::data_tok* ddtokp = _dd_dtok_list[i];
#ifndef RHM_WRONLY
// Wait until data token is read before dequeueing
@@ -323,6 +324,7 @@
#endif
{
//std::cout << " D" << ddtokp->id() << " " << std::flush;
+ _dd_dtok_list.erase(_dd_dtok_list.begin() + i--);
unsigned aio_sleep_cnt = 0;
bool written = false;
while (!written)
@@ -403,12 +405,7 @@
}
}
}
- ditr = _dd_dtok_list.erase(ditr);
}
-#ifndef RHM_WRONLY
- else
- ditr++;
-#endif
}
}
Modified: store/trunk/cpp/tests/jrnl/msg_producer.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/msg_producer.hpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -79,13 +79,14 @@
u_int32_t _num_txn_subm;
u_int32_t _num_txn;
std::deque<rhm::journal::data_tok*>& _dtok_master_list; // One dtok per msg to be sent
- std::deque<rhm::journal::data_tok*> _aio_cmpl_dtok_list; // Dtoks from completed AIOs go here
+ std::deque<rhm::journal::data_tok*>& _aio_cmpl_dtok_list; // Dtoks from completed AIOs go here
std::deque<rhm::journal::data_tok*> _dd_dtok_list; // Deferred dequeues
u_int64_t _tot_dblks;
u_int64_t _tot_dsize;
public:
- msg_producer(std::deque<rhm::journal::data_tok*>& dtok_master_list);
+ msg_producer(std::deque<rhm::journal::data_tok*>& dtok_master_list,
+ std::deque<rhm::journal::data_tok*>& aio_cmpl_dtok_list);
~msg_producer();
void initialize(const u_int32_t numMsgs, bool auto_dequeue);
Modified: store/trunk/cpp/tests/jrnl/prof
===================================================================
--- store/trunk/cpp/tests/jrnl/prof 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/prof 2007-11-14 00:17:50 UTC (rev 1308)
@@ -4,7 +4,7 @@
opcontrol --setup --no-vmlinux --separate=library
opcontrol --start
# -- Do stuff here --
-./jtest
+./jtest wtests.csv 264
# -- End of stuff --
opcontrol --stop
opcontrol --dump
Modified: store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp 2007-11-13 20:52:35 UTC (rev 1307)
+++ store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp 2007-11-14 00:17:50 UTC (rev 1308)
@@ -47,19 +47,19 @@
{
jexception e1;
BOOST_CHECK_EQUAL(e1.err_code(), (u_int32_t)0);
- BOOST_CHECK(e1.additional_info() == NULL);
- BOOST_CHECK(e1.throwing_class() == NULL);
- BOOST_CHECK(e1.throwing_fn() == NULL);
- BOOST_CHECK(e1.what() != NULL);
+ BOOST_CHECK(::strlen(e1.additional_info()) == 0);
+ BOOST_CHECK(::strlen(e1.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e1.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e1.what()) > 0);
throw e1;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
- BOOST_CHECK(e.additional_info() == NULL);
- BOOST_CHECK(e.throwing_class() == NULL);
- BOOST_CHECK(e.throwing_fn() == NULL);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.additional_info()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
@@ -70,19 +70,19 @@
{
jexception e2(err_code);
BOOST_CHECK_EQUAL(e2.err_code(), err_code);
- BOOST_CHECK(e2.additional_info() == NULL);
- BOOST_CHECK(e2.throwing_class() == NULL);
- BOOST_CHECK(e2.throwing_fn() == NULL);
- BOOST_CHECK(e2.what() != NULL);
+ BOOST_CHECK(::strlen(e2.additional_info()) == 0);
+ BOOST_CHECK(::strlen(e2.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e2.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e2.what()) > 0);
throw e2;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), err_code);
- BOOST_CHECK(e.additional_info() == NULL);
- BOOST_CHECK(e.throwing_class() == NULL);
- BOOST_CHECK(e.throwing_fn() == NULL);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.additional_info()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
@@ -94,18 +94,18 @@
jexception e3(err_msg);
BOOST_CHECK_EQUAL(e3.err_code(), (u_int32_t)0);
BOOST_CHECK(::strcmp(e3.additional_info(), err_msg) == 0);
- BOOST_CHECK(e3.throwing_class() == NULL);
- BOOST_CHECK(e3.throwing_fn() == NULL);
- BOOST_CHECK(e3.what() != NULL);
+ BOOST_CHECK(::strlen(e3.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e3.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e3.what()) > 0);
throw e3;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
BOOST_CHECK(::strcmp(e.additional_info(), err_msg) == 0);
- BOOST_CHECK(e.throwing_class() == NULL);
- BOOST_CHECK(e.throwing_fn() == NULL);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
@@ -118,18 +118,18 @@
jexception e4(err_code, err_msg);
BOOST_CHECK_EQUAL(e4.err_code(), err_code);
BOOST_CHECK(::strcmp(e4.additional_info(), err_msg) == 0);
- BOOST_CHECK(e4.throwing_class() == NULL);
- BOOST_CHECK(e4.throwing_fn() == NULL);
- BOOST_CHECK(e4.what() != NULL);
+ BOOST_CHECK(::strlen(e4.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e4.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e4.what()) > 0);
throw e4;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), err_code);
BOOST_CHECK(::strcmp(e.additional_info(), err_msg) == 0);
- BOOST_CHECK(e.throwing_class() == NULL);
- BOOST_CHECK(e.throwing_fn() == NULL);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.throwing_class()) == 0);
+ BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
@@ -142,19 +142,19 @@
{
jexception e5(err_code, err_class, err_fn);
BOOST_CHECK_EQUAL(e5.err_code(), err_code);
- BOOST_CHECK(e5.additional_info() == NULL);
+ BOOST_CHECK(::strlen(e5.additional_info()) == 0);
BOOST_CHECK(::strcmp(e5.throwing_class(), err_class) == 0);
BOOST_CHECK(::strcmp(e5.throwing_fn(), err_fn) == 0);
- BOOST_CHECK(e5.what() != NULL);
+ BOOST_CHECK(::strlen(e5.what()) > 0);
throw e5;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), err_code);
- BOOST_CHECK(e.additional_info() == NULL);
+ BOOST_CHECK(::strlen(e.additional_info()) == 0);
BOOST_CHECK(::strcmp(e.throwing_class(), err_class) == 0);
BOOST_CHECK(::strcmp(e.throwing_fn(), err_fn) == 0);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
@@ -171,7 +171,7 @@
BOOST_CHECK(::strcmp(e6.additional_info(), err_msg) == 0);
BOOST_CHECK(::strcmp(e6.throwing_class(), err_class) == 0);
BOOST_CHECK(::strcmp(e6.throwing_fn(), err_fn) == 0);
- BOOST_CHECK(e6.what() != NULL);
+ BOOST_CHECK(::strlen(e6.what()) > 0);
throw e6;
}
catch (const jexception& e)
@@ -180,9 +180,27 @@
BOOST_CHECK(::strcmp(e.additional_info(), err_msg) == 0);
BOOST_CHECK(::strcmp(e.throwing_class(), err_class) == 0);
BOOST_CHECK(::strcmp(e.throwing_fn(), err_fn) == 0);
- BOOST_CHECK(e.what() != NULL);
+ BOOST_CHECK(::strlen(e.what()) > 0);
}
}
+
+void test_msg_scope()
+{
+ try
+ {
+ // These will go out of scope as soon as jexception is thrown...
+ std::string msg("Error message");
+ std::string cls("class");
+ std::string fn("function");
+ throw jexception(100, msg.c_str(), cls.c_str(), fn.c_str());
+ }
+ catch (const jexception& e)
+ {
+ std::stringstream ss;
+ ss << e;
+ BOOST_CHECK(ss.str().size() > 0);
+ }
+}
// Initialize test suite and include test functions
@@ -200,6 +218,7 @@
ts->add(BOOST_TEST_CASE(&test_constructor_4));
ts->add(BOOST_TEST_CASE(&test_constructor_5));
ts->add(BOOST_TEST_CASE(&test_constructor_6));
+ ts->add(BOOST_TEST_CASE(&test_msg_scope));
return ts;
}
17 years, 1 month