rhmessaging commits: r1649 - in store/trunk/cpp: tests/jrnl/jtt and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2008-02-06 16:14:48 -0500 (Wed, 06 Feb 2008)
New Revision: 1649
Removed:
store/trunk/cpp/tests/jrnl/jtt/bootstrap
store/trunk/cpp/tests/jrnl/jtt/configure.ac
Modified:
store/trunk/cpp/bootstrap
store/trunk/cpp/configure.ac
store/trunk/cpp/tests/jrnl/jtt/
store/trunk/cpp/tests/jrnl/jtt/Makefile.am
store/trunk/cpp/tests/jrnl/jtt/main.cpp
Log:
Fixed error in jtt Makefile.am which broke cruisecontrol build
Modified: store/trunk/cpp/bootstrap
===================================================================
--- store/trunk/cpp/bootstrap 2008-02-06 19:31:17 UTC (rev 1648)
+++ store/trunk/cpp/bootstrap 2008-02-06 21:14:48 UTC (rev 1649)
@@ -33,5 +33,3 @@
automake --add-missing
autoconf
-
-cd tests/jrnl/jtt && ./bootstrap
Modified: store/trunk/cpp/configure.ac
===================================================================
--- store/trunk/cpp/configure.ac 2008-02-06 19:31:17 UTC (rev 1648)
+++ store/trunk/cpp/configure.ac 2008-02-06 21:14:48 UTC (rev 1649)
@@ -186,10 +186,9 @@
Makefile
tests/Makefile
tests/jrnl/Makefile
+ tests/jrnl/jtt/Makefile
lib/Makefile
docs/Makefile
])
-AC_CONFIG_SUBDIRS([tests/jrnl/jtt])
-
AC_OUTPUT
Property changes on: store/trunk/cpp/tests/jrnl/jtt
___________________________________________________________________
Name: svn:ignore
- aclocal.m4
autom4te.cache
config.hpp
config.hpp.in
config.log
config.status
configure
depcomp
install-sh
jtt
Makefile
Makefile.in
missing
stamp-h1
_ut_data_src
_ut_jrnl_init_params
_ut_jrnl_instance
_ut_read_arg
_ut_test_case
_ut_test_case_set
_ut_test_case_result
_ut_test_case_result_agregation
.deps
+ jtt
Makefile
Makefile.in
_ut_data_src
_ut_jrnl_init_params
_ut_jrnl_instance
_ut_read_arg
_ut_test_case
_ut_test_case_set
_ut_test_case_result
_ut_test_case_result_agregation
.deps
.libs
Modified: store/trunk/cpp/tests/jrnl/jtt/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/Makefile.am 2008-02-06 19:31:17 UTC (rev 1648)
+++ store/trunk/cpp/tests/jrnl/jtt/Makefile.am 2008-02-06 21:14:48 UTC (rev 1649)
@@ -157,6 +157,6 @@
${LIBOBJDIR}/time_ns.o
EXTRA_DIST = \
- file_chk.py \
+ jfile_chk.py \
jtt.csv \
_ut_test_case_set.csv
Deleted: store/trunk/cpp/tests/jrnl/jtt/bootstrap
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/bootstrap 2008-02-06 19:31:17 UTC (rev 1648)
+++ store/trunk/cpp/tests/jrnl/jtt/bootstrap 2008-02-06 21:14:48 UTC (rev 1649)
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2008 Red Hat Inc.
-#
-# This file is part of Red Hat Messaging.
-#
-# Red Hat Messaging is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
-# USA
-#
-# The GNU Lesser General Public License is available in the file COPYING.
-
-autoreconf --install
Deleted: store/trunk/cpp/tests/jrnl/jtt/configure.ac
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/configure.ac 2008-02-06 19:31:17 UTC (rev 1648)
+++ store/trunk/cpp/tests/jrnl/jtt/configure.ac 2008-02-06 21:14:48 UTC (rev 1649)
@@ -1,29 +0,0 @@
-dnl # Copyright (C) 2008 Red Hat Inc.
-dnl #
-dnl # This file is part of Red Hat Messaging.
-dnl #
-dnl # Red Hat Messaging is free software; you can redistribute it and/or
-dnl # modify it under the terms of the GNU Lesser General Public
-dnl # License as published by the Free Software Foundation; either
-dnl # version 2.1 of the License, or (at your option) any later version.
-dnl #
-dnl # This library is distributed in the hope that it will be useful,
-dnl # but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl # Lesser General Public License for more details.
-dnl #
-dnl # You should have received a copy of the GNU Lesser General Public
-dnl # License along with this library; if not, write to the Free Software
-dnl # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
-dnl # USA
-dnl #
-dnl # The GNU Lesser General Public License is available in the file COPYING.
-
-AC_INIT([Journal Test Tool], [0.1], [rhemrg-users-list(a)redhat.com])
-AM_INIT_AUTOMAKE([-Wall -Werror foreign])
-AC_PROG_CXX
-AC_CONFIG_HEADERS([config.hpp])
-AC_CONFIG_FILES([
- Makefile
-])
-AC_OUTPUT
Modified: store/trunk/cpp/tests/jrnl/jtt/main.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/main.cpp 2008-02-06 19:31:17 UTC (rev 1648)
+++ store/trunk/cpp/tests/jrnl/jtt/main.cpp 2008-02-06 21:14:48 UTC (rev 1649)
@@ -21,13 +21,15 @@
* The GNU Lesser General Public License is available in the file COPYING.
*/
-#include "config.hpp"
#include "test_mgr.hpp"
#include <iostream>
#include "args.hpp"
#include <signal.h>
+#define PACKAGE_NAME "Journal Test Tool"
+#define VERSION "0.1"
+
namespace po = boost::program_options;
int main(int argc, char** argv)
16 years, 11 months
rhmessaging commits: r1648 - in store/trunk/cpp: tests/jrnl and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2008-02-06 14:31:17 -0500 (Wed, 06 Feb 2008)
New Revision: 1648
Modified:
store/trunk/cpp/bootstrap
store/trunk/cpp/configure.ac
store/trunk/cpp/tests/jrnl/Makefile.am
store/trunk/cpp/tests/jrnl/jtt/Makefile.am
store/trunk/cpp/tests/jrnl/jtt/args.cpp
store/trunk/cpp/tests/jrnl/jtt/args.hpp
store/trunk/cpp/tests/jrnl/jtt/configure.ac
store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp
store/trunk/cpp/tests/jrnl/run-journal-tests
Log:
Linked Journal Test Tool (jtt) to top-level make, added jtt as part of journal test
Modified: store/trunk/cpp/bootstrap
===================================================================
--- store/trunk/cpp/bootstrap 2008-02-06 19:27:44 UTC (rev 1647)
+++ store/trunk/cpp/bootstrap 2008-02-06 19:31:17 UTC (rev 1648)
@@ -34,4 +34,4 @@
automake --add-missing
autoconf
-# cd tests/jrnl/jtt && ./bootstrap
+cd tests/jrnl/jtt && ./bootstrap
Modified: store/trunk/cpp/configure.ac
===================================================================
--- store/trunk/cpp/configure.ac 2008-02-06 19:27:44 UTC (rev 1647)
+++ store/trunk/cpp/configure.ac 2008-02-06 19:31:17 UTC (rev 1648)
@@ -21,7 +21,7 @@
dnl
dnl Process this file with autoconf to produce a configure script.
-AC_INIT([rhm], [0.2], [rhm-users(a)redhat.com])
+AC_INIT([rhm], [0.2], [rhemrg-users-list(a)redhat.com])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([dist-bzip2])
@@ -190,6 +190,6 @@
docs/Makefile
])
-dnl AC_CONFIG_SUBDIRS([tests/jrnl/jtt])
+AC_CONFIG_SUBDIRS([tests/jrnl/jtt])
AC_OUTPUT
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2008-02-06 19:27:44 UTC (rev 1647)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2008-02-06 19:31:17 UTC (rev 1648)
@@ -25,7 +25,7 @@
INCLUDES=-I../../lib
-# SUBDIRS = jtt
+SUBDIRS = jtt
TESTS = \
_ut_time_ns \
Modified: store/trunk/cpp/tests/jrnl/jtt/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/Makefile.am 2008-02-06 19:27:44 UTC (rev 1647)
+++ store/trunk/cpp/tests/jrnl/jtt/Makefile.am 2008-02-06 19:31:17 UTC (rev 1648)
@@ -36,9 +36,7 @@
_ut_test_case_set \
_ut_jrnl_instance
-bin_PROGRAMS = jtt
-
-check_PROGRAMS = \
+check_PROGRAMS = jtt \
_ut_data_src \
_ut_jrnl_init_params \
_ut_read_arg \
@@ -159,5 +157,6 @@
${LIBOBJDIR}/time_ns.o
EXTRA_DIST = \
+ file_chk.py \
jtt.csv \
_ut_test_case_set.csv
Modified: store/trunk/cpp/tests/jrnl/jtt/args.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/args.cpp 2008-02-06 19:27:44 UTC (rev 1647)
+++ store/trunk/cpp/tests/jrnl/jtt/args.cpp 2008-02-06 19:31:17 UTC (rev 1648)
@@ -86,6 +86,7 @@
const bool
args::parse(int argc, char** argv) // return true if error, false if ok
{
+ get_jtt_path(argv[0]);
try
{
po::store(po::parse_command_line(argc, argv, _options_descr), _vmap);
@@ -135,6 +136,20 @@
return false;
}
+void
+args::get_jtt_path(const char* argv0)
+{
+ std::string s(argv0);
+ size_t pos = s.rfind("/jtt");
+ assert(pos != std::string::npos);
+ if (pos > 1)
+ {
+ size_t start = s.substr(0, 2).compare("./") == 0 ? 2 : 0;
+ size_t len = s.size() - start - 3;
+ jtt_path = s.substr(start, len);
+ }
+}
+
const bool
args::usage() const
{
Modified: store/trunk/cpp/tests/jrnl/jtt/args.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/args.hpp 2008-02-06 19:27:44 UTC (rev 1647)
+++ store/trunk/cpp/tests/jrnl/jtt/args.hpp 2008-02-06 19:31:17 UTC (rev 1648)
@@ -38,6 +38,7 @@
boost::program_options::variables_map _vmap;
// Add args here
+ std::string jtt_path;
std::string test_case_csv_file_name;
bool format_chk;
bool keep_jrnls;
@@ -55,6 +56,7 @@
args(std::string opt_title);
const bool parse(int argc, char** argv); // return true if error, false if ok
+ void get_jtt_path(const char* argv0);
const bool usage() const; // return true
void print_args() const;
void print_flags() const;
Modified: store/trunk/cpp/tests/jrnl/jtt/configure.ac
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/configure.ac 2008-02-06 19:27:44 UTC (rev 1647)
+++ store/trunk/cpp/tests/jrnl/jtt/configure.ac 2008-02-06 19:31:17 UTC (rev 1648)
@@ -19,7 +19,7 @@
dnl #
dnl # The GNU Lesser General Public License is available in the file COPYING.
-AC_INIT([Journal Test Tool], [0.1], [kim.vdriet(a)redhat.com])
+AC_INIT([Journal Test Tool], [0.1], [rhemrg-users-list(a)redhat.com])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CXX
AC_CONFIG_HEADERS([config.hpp])
Modified: store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp 2008-02-06 19:27:44 UTC (rev 1647)
+++ store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp 2008-02-06 19:31:17 UTC (rev 1648)
@@ -93,8 +93,9 @@
for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
{
jrnl_init_params::shared_ptr jpp = (*jii)->params();
+ std::string path = _args.jtt_path.size() ? _args.jtt_path : "./";
std::ostringstream oss;
- oss << "./jfile_chk.py -q";
+ oss << path << "jfile_chk.py -q";
oss << " -d " << jpp->jdir();
oss << " -b " << jpp->base_filename();
oss << " -c" << _args.test_case_csv_file_name;
Modified: store/trunk/cpp/tests/jrnl/run-journal-tests
===================================================================
--- store/trunk/cpp/tests/jrnl/run-journal-tests 2008-02-06 19:27:44 UTC (rev 1647)
+++ store/trunk/cpp/tests/jrnl/run-journal-tests 2008-02-06 19:31:17 UTC (rev 1648)
@@ -4,6 +4,12 @@
fail=0
+# Run jtt using default test set
+echo
+$pwd/jtt/jtt --csv $pwd/jtt/jtt.csv --format-chk || fail = 1
+echo
+
+# Run cpp-unit tests
LD_PRELOAD=$pwd/.libs/libdlclose_noop.so DllPlugInTester -c -b $pwd/.libs/Journal*Tests.so || fail=1
exit $fail
16 years, 11 months
rhmessaging commits: r1647 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-06 14:27:44 -0500 (Wed, 06 Feb 2008)
New Revision: 1647
Modified:
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/widgets.py
Log:
Move broker group add to the broker group frame.
Make the messaging tab selected by default.
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2008-02-06 17:04:54 UTC (rev 1646)
+++ mgmt/cumin/python/cumin/brokergroup.py 2008-02-06 19:27:44 UTC (rev 1647)
@@ -25,7 +25,7 @@
def render_group_add_href(self, session, model):
branch = session.branch()
- self.frame().show_broker_group_add(branch)
+ self.frame().show_broker_group(branch, None).show_add(branch)
return branch.marshal()
class NameColumn(SqlTableColumn):
@@ -42,25 +42,34 @@
def __init__(self, app, name):
super(BrokerGroupFrame, self).__init__(app, name)
- self.param = BrokerGroupParameter(app, "id")
- self.add_parameter(self.param)
- self.set_object_parameter(self.param)
+ param = BrokerGroupParameter(app, "id")
+ self.add_parameter(param)
+ self.set_object_parameter(param)
- self.view = BrokerGroupView(app, "view")
- self.add_child(self.view)
- self.set_view_mode(self.view)
+ view = BrokerGroupView(app, "view")
+ self.add_child(view)
+ self.set_view_mode(view)
- self.edit = BrokerGroupEdit(app, "edit")
- self.add_child(self.edit)
- self.set_edit_mode(self.edit)
+ add = BrokerGroupAdd(app, "add")
+ self.add_child(add)
+ self.set_add_mode(add)
- self.remove = BrokerGroupRemove(app, "remove")
- self.add_child(self.remove)
- self.set_remove_mode(self.remove)
+ edit = BrokerGroupEdit(app, "edit")
+ self.add_child(edit)
+ self.set_edit_mode(edit)
+ remove = BrokerGroupRemove(app, "remove")
+ self.add_child(remove)
+ self.set_remove_mode(remove)
+
def get_title(self, session, group):
- return "Broker Group '%s'" % group.name
+ if group:
+ title = "Broker Group '%s'" % group.name
+ else:
+ title = "Broker Group"
+ return title
+
class BrokerGroupStatus(CuminStatus):
pass
@@ -108,8 +117,9 @@
def process_cancel(self, session, model):
branch = session.branch()
- self.frame().show_view(branch)
+ self.frame().frame().show_view(branch)
self.page().pop_current_frame(branch)
+ self.page().pop_current_frame(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, model):
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2008-02-06 17:04:54 UTC (rev 1646)
+++ mgmt/cumin/python/cumin/page.py 2008-02-06 19:27:44 UTC (rev 1647)
@@ -84,9 +84,6 @@
self.__group = BrokerGroupFrame(app, "group")
self.add_mode(self.__group)
- self.__group_add = BrokerGroupAdd(app, "groupadd")
- self.add_mode(self.__group_add)
-
self.__profile = BrokerProfileFrame(app, "profile")
self.add_mode(self.__profile)
@@ -155,10 +152,6 @@
frame.set_object(session, group)
return self.page().set_current_frame(session, frame)
- def show_broker_group_add(self, session):
- frame = self.show_mode(session, self.__group_add)
- return self.page().set_current_frame(session, frame)
-
def show_broker_profile(self, session, profile):
frame = self.show_mode(session, self.__profile)
frame.set_object(session, profile)
@@ -184,6 +177,7 @@
self.html_class = "tabs"
self.selection = Parameter(app, "sel")
+ self.selection.default = "mtab"
self.add_parameter(self.selection)
self.add_link(self.MessagingTab(app, "mtab"))
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2008-02-06 17:04:54 UTC (rev 1646)
+++ mgmt/cumin/python/cumin/widgets.py 2008-02-06 19:27:44 UTC (rev 1647)
@@ -20,6 +20,7 @@
self.__param = None
self.__view = None
+ self.__add = None
self.__edit = None
self.__remove = None
@@ -39,23 +40,27 @@
def show_view(self, session):
return self.show_mode(session, self.__view)
+ def set_add_mode(self, mode):
+ self.__add = mode
+
+ def show_add(self, session):
+ return self.show_frame_mode(session, self.__add)
+
def set_edit_mode(self, mode):
self.__edit = mode
def show_edit(self, session):
- mode = self.show_mode(session, self.__edit)
+ return self.show_frame_mode(session, self.__edit)
- if isinstance(mode, Frame):
- self.page().set_current_frame(session, mode)
-
- return mode
-
def set_remove_mode(self, mode):
self.__remove = mode
def show_remove(self, session):
- mode = self.show_mode(session, self.__remove)
+ return self.show_frame_mode(session, self.__remove)
+ def show_frame_mode(self, session, mode):
+ self.show_mode(session, mode)
+
if isinstance(mode, Frame):
self.page().set_current_frame(session, mode)
16 years, 11 months
rhmessaging commits: r1646 - in mgmt/cumin/python: wooly and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-06 12:04:54 -0500 (Wed, 06 Feb 2008)
New Revision: 1646
Modified:
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/widgets.py
mgmt/cumin/python/wooly/__init__.py
Log:
Fixes a number of problems with the broker group add/edit/remove
forms.
Adds a pop_current_frame on Page.
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2008-02-06 15:39:52 UTC (rev 1645)
+++ mgmt/cumin/python/cumin/brokergroup.py 2008-02-06 17:04:54 UTC (rev 1646)
@@ -95,20 +95,21 @@
return "where exists (%s)" % subquery
-class BrokerGroupForm(CuminForm):
+class BrokerGroupForm(CuminForm, Frame):
def __init__(self, app, name):
super(BrokerGroupForm, self).__init__(app, name)
self.group_name = TextInput(app, "name", self)
self.add_child(self.group_name)
-class BrokerGroupAdd(BrokerGroupForm, Frame):
+class BrokerGroupAdd(BrokerGroupForm):
def get_title(self, session, model):
return "Add Group"
def process_cancel(self, session, model):
branch = session.branch()
self.frame().show_view(branch)
+ self.page().pop_current_frame(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, model):
@@ -118,13 +119,14 @@
self.process_cancel(session, model)
-class BrokerGroupEdit(BrokerGroupForm, Frame):
+class BrokerGroupEdit(BrokerGroupForm):
def get_title(self, session, group):
return "Edit Group '%s'" % group.name
def process_cancel(self, session, group):
branch = session.branch()
self.frame().show_view(branch)
+ self.page().pop_current_frame(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, group):
@@ -137,13 +139,15 @@
def process_display(self, session, group):
self.group_name.set(session, group.name)
-class BrokerGroupRemove(CuminConfirmForm):
+class BrokerGroupRemove(CuminConfirmForm, Frame):
def get_title(self, session, group):
return "Remove Broker Group '%s'" % group.name
def process_cancel(self, session, group):
branch = session.branch()
- self.app.model.broker_group.show(branch, group).show_view(branch)
+
+ self.frame().show_view(branch)
+ self.page().pop_current_frame(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, group):
@@ -151,7 +155,9 @@
method.invoke(group)
branch = session.branch()
- self.page().show_main(branch)
+ self.frame().frame().show_view(branch)
+ self.page().pop_current_frame(branch)
+ self.page().pop_current_frame(branch)
self.page().set_redirect_url(session, branch.marshal())
def render_submit_content(self, session, group):
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2008-02-06 15:39:52 UTC (rev 1645)
+++ mgmt/cumin/python/cumin/widgets.py 2008-02-06 17:04:54 UTC (rev 1646)
@@ -43,14 +43,24 @@
self.__edit = mode
def show_edit(self, session):
- return self.show_mode(session, self.__edit)
+ mode = self.show_mode(session, self.__edit)
+ if isinstance(mode, Frame):
+ self.page().set_current_frame(session, mode)
+
+ return mode
+
def set_remove_mode(self, mode):
self.__remove = mode
def show_remove(self, session):
- return self.show_mode(session, self.__remove)
+ mode = self.show_mode(session, self.__remove)
+ if isinstance(mode, Frame):
+ self.page().set_current_frame(session, mode)
+
+ return mode
+
def do_process(self, session, object):
self.page().get_frames(session).append(self)
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2008-02-06 15:39:52 UTC (rev 1645)
+++ mgmt/cumin/python/wooly/__init__.py 2008-02-06 17:04:54 UTC (rev 1646)
@@ -380,6 +380,7 @@
def get_redirect_url(self, session):
return self.redirect.get(session)
+ # XXX take "current" out of these
def set_current_frame(self, session, frame):
self.frame.set(session, frame)
@@ -388,6 +389,13 @@
def get_current_frame(self, session):
return self.frame.get(session)
+ def pop_current_frame(self, session):
+ frame = self.get_current_frame(session)
+
+ print "Popping current frame", frame
+
+ return self.set_current_frame(session, frame.frame())
+
def set_default_frame(self, frame):
self.frame.default = frame
16 years, 11 months
rhmessaging commits: r1645 - in store/trunk/cpp: lib/jrnl and 2 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2008-02-06 10:39:52 -0500 (Wed, 06 Feb 2008)
New Revision: 1645
Added:
store/trunk/cpp/lib/jrnl/cvar.cpp
store/trunk/cpp/lib/jrnl/cvar.hpp
store/trunk/cpp/lib/jrnl/slock.cpp
store/trunk/cpp/lib/jrnl/time_ns.cpp
store/trunk/cpp/lib/jrnl/time_ns.hpp
store/trunk/cpp/tests/jrnl/_ut_time_ns.cpp
Modified:
store/trunk/cpp/lib/JournalImpl.cpp
store/trunk/cpp/lib/JournalImpl.h
store/trunk/cpp/lib/Makefile.am
store/trunk/cpp/lib/jrnl/aio_cb.hpp
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jcntl.hpp
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/slock.hpp
store/trunk/cpp/lib/jrnl/wmgr.cpp
store/trunk/cpp/lib/jrnl/wmgr.hpp
store/trunk/cpp/tests/jrnl/
store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp
store/trunk/cpp/tests/jrnl/Makefile.am
store/trunk/cpp/tests/jrnl/jtt/Makefile.am
store/trunk/cpp/tests/jrnl/jtt/_ut_test_case_result.cpp
store/trunk/cpp/tests/jrnl/jtt/_ut_test_case_result_agregation.cpp
store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp
store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp
store/trunk/cpp/tests/jrnl/jtt/test_case_result.cpp
store/trunk/cpp/tests/jrnl/jtt/test_case_result.hpp
store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp
store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp
Log:
Bugfixes to read pipeline in journal; updates to journal test tool (jtt) to test read. Also changed usleep() calls in jtt to use pthread condition variables instead.
Modified: store/trunk/cpp/lib/JournalImpl.cpp
===================================================================
--- store/trunk/cpp/lib/JournalImpl.cpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/JournalImpl.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -80,7 +80,7 @@
}
void
-JournalImpl::recover(const aio_cb wr_cb,
+JournalImpl::recover(const journal::rd_aio_cb rd_cb, const wr_aio_cb wr_cb,
boost::ptr_list<bdbstore::PreparedTransaction>& prep_tx_list, u_int64_t& highest_rid,
u_int64_t queue_id)
{
@@ -91,7 +91,7 @@
prep_xid_list.push_back(i->xid);
}
- jcntl::recover(wr_cb, prep_xid_list, highest_rid);
+ jcntl::recover(rd_cb, wr_cb, prep_xid_list, highest_rid);
// Populate PreparedTransaction lists from _tmap
for (bdbstore::PreparedTransaction::list::iterator i = prep_tx_list.begin();
@@ -341,3 +341,7 @@
dtokp->release();
}
}
+
+// void
+// JournalImpl::aio_rd_callback(jcntl* /*journal*/, std::vector<u_int16_t>& /*pil*/)
+// {}
Modified: store/trunk/cpp/lib/JournalImpl.h
===================================================================
--- store/trunk/cpp/lib/JournalImpl.h 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/JournalImpl.h 2008-02-06 15:39:52 UTC (rev 1645)
@@ -92,15 +92,15 @@
const qpid::sys::Duration flushTimeout);
virtual ~JournalImpl();
- inline void initialize() { jcntl::initialize(&aio_wr_callback); }
+ inline void initialize() { jcntl::initialize(0, &aio_wr_callback); }
- void recover(const journal::aio_cb wr_cb,
+ void recover(const journal::rd_aio_cb rd_cb, const journal::wr_aio_cb wr_cb,
boost::ptr_list<bdbstore::PreparedTransaction>& prep_tx_list,
u_int64_t& highest_rid, u_int64_t queue_id);
inline void recover(boost::ptr_list<bdbstore::PreparedTransaction>& prep_tx_list,
u_int64_t& highest_rid, u_int64_t queue_id) {
- recover(&aio_wr_callback, prep_tx_list, highest_rid, queue_id);
+ recover(0, &aio_wr_callback, prep_tx_list, highest_rid, queue_id);
}
// Temporary fn to read and save last msg read from journal so it can be assigned
@@ -144,6 +144,7 @@
private:
void handleIoResult(const journal::iores r);
static void aio_wr_callback(jcntl* journal, std::vector<journal::data_tok*>& dtokl);
+ // static void aio_rd_callback(jcntl* journal, std::vector<u_int16_t>& pil);
}; // class JournalImpl
} // namespace bdbstore
Modified: store/trunk/cpp/lib/Makefile.am
===================================================================
--- store/trunk/cpp/lib/Makefile.am 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/Makefile.am 2008-02-06 15:39:52 UTC (rev 1645)
@@ -38,6 +38,7 @@
StoreException.h \
StringDbt.h \
TxnCtxt.h \
+ jrnl/cvar.cpp \
jrnl/data_tok.cpp \
jrnl/deq_rec.cpp \
jrnl/enq_map.cpp \
@@ -52,12 +53,15 @@
jrnl/nlfh.cpp \
jrnl/pmgr.cpp \
jrnl/rmgr.cpp \
+ jrnl/slock.cpp \
jrnl/rrfc.cpp \
+ jrnl/time_ns.cpp \
jrnl/txn_map.cpp \
jrnl/txn_rec.cpp \
jrnl/wmgr.cpp \
jrnl/wrfc.cpp \
jrnl/aio_cb.hpp \
+ jrnl/cvar.hpp \
jrnl/data_tok.hpp \
jrnl/deq_hdr.hpp \
jrnl/deq_rec.hpp \
@@ -82,6 +86,7 @@
jrnl/rmgr.hpp \
jrnl/rrfc.hpp \
jrnl/slock.hpp \
+ jrnl/time_ns.hpp \
jrnl/txn_hdr.hpp \
jrnl/txn_map.hpp \
jrnl/txn_rec.hpp \
Modified: store/trunk/cpp/lib/jrnl/aio_cb.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/aio_cb.hpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/jrnl/aio_cb.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -44,7 +44,8 @@
/**
* \brief Callback function pointer to be called when AIO events arrive.
*/
- typedef void (*aio_cb)(jcntl* journal, std::vector<data_tok*>& dtokl);
+ typedef void (*wr_aio_cb)(jcntl* journal, std::vector<data_tok*>& dtokl);
+ typedef void (*rd_aio_cb)(jcntl* journal, std::vector<u_int16_t>& pil);
}
}
Added: store/trunk/cpp/lib/jrnl/cvar.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/cvar.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/cvar.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -0,0 +1,31 @@
+/**
+* \file cvar.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::cvar (condition variable). See
+* comments in file cvar.hpp for details.
+*
+* Copyright (C) 2007, 2008 Red Hat Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include <jrnl/cvar.hpp>
Added: store/trunk/cpp/lib/jrnl/cvar.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/cvar.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/cvar.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -0,0 +1,85 @@
+/**
+* \file cvar.hpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains a posix condition variable class.
+*
+* Copyright 2007, 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#ifndef rhm_journal_cvar_hpp
+#define rhm_journal_cvar_hpp
+
+#include <jrnl/jerrno.hpp>
+#include <jrnl/jexception.hpp>
+#include <jrnl/time_ns.hpp>
+#include <pthread.h>
+#include <sstream>
+
+namespace rhm
+{
+namespace journal
+{
+
+ // Ultra-simple thread condition variable class
+ class cvar
+ {
+ private:
+ pthread_mutex_t& _m;
+ pthread_cond_t _c;
+ public:
+ inline cvar(pthread_mutex_t& m) : _m(m) { ::pthread_cond_init(&_c, 0); }
+ inline ~cvar() { ::pthread_cond_destroy(&_c); }
+ inline void wait()
+ {
+ PTHREAD_CHK(::pthread_cond_wait(&_c, &_m), "pthread_cond_wait", "cvar", "wait");
+ }
+ inline void timedwait(timespec& ts)
+ {
+ PTHREAD_CHK(::pthread_cond_timedwait(&_c, &_m, &ts), "pthread_cond_timedwait", "cvar",
+ "timedwait");
+ }
+ inline const bool waitintvl(const long intvl_ns)
+ {
+ time_ns t; t.now(); t+=intvl_ns;
+ int ret = ::pthread_cond_timedwait(&_c, &_m, &t);
+ if (ret == ETIMEDOUT)
+ return true;
+ PTHREAD_CHK(ret, "pthread_cond_timedwait", "cvar", "waitintvl");
+ return false;
+ }
+ inline void signal()
+ {
+ PTHREAD_CHK(::pthread_cond_signal(&_c), "pthread_cond_signal", "cvar", "notify");
+ }
+ inline void broadcast()
+ {
+ PTHREAD_CHK(::pthread_cond_broadcast(&_c), "pthread_cond_broadcast", "cvar",
+ "broadcast");
+ }
+ };
+
+}
+}
+
+#endif
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -71,8 +71,8 @@
_wmgr(this, _emap, _tmap, _wrfc),
_rcvdat(_num_jfiles)
{
- pthread_mutex_init(&_wr_mutex, 0);
- pthread_mutex_init(&_gev_mutex, 0);
+ ::pthread_mutex_init(&_wr_mutex, 0);
+ ::pthread_mutex_init(&_gev_mutex, 0);
}
jcntl::~jcntl()
@@ -86,12 +86,12 @@
delete _datafh[i];
delete[] _datafh;
}
- pthread_mutex_destroy(&_gev_mutex);
- pthread_mutex_destroy(&_wr_mutex);
+ ::pthread_mutex_destroy(&_gev_mutex);
+ ::pthread_mutex_destroy(&_wr_mutex);
}
void
-jcntl::initialize(const aio_cb wr_cb)
+jcntl::initialize(const rd_aio_cb rd_cb, const wr_aio_cb wr_cb)
{
_init_flag = false;
_stop_flag = false;
@@ -125,7 +125,7 @@
// constrains read activity (i.e. one can't read what has not yet been written).
_wrfc.initialize(_num_jfiles, _jfsize_sblks, (nlfh**)_datafh);
_rrfc.initialize(_num_jfiles, (nlfh**)_datafh);
- _rmgr.initialize(0);
+ _rmgr.initialize(rd_cb, 0);
_wmgr.initialize(wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
// Write info file (<basename>.jinf) to disk
@@ -135,8 +135,8 @@
}
void
-jcntl::recover(const aio_cb wr_cb, const std::vector<std::string>& prep_txn_list,
- u_int64_t& highest_rid)
+jcntl::recover(const rd_aio_cb rd_cb, const wr_aio_cb wr_cb,
+ const std::vector<std::string>& prep_txn_list, u_int64_t& highest_rid)
{
_init_flag = false;
_stop_flag = false;
@@ -180,7 +180,7 @@
// constrains read activity (i.e. one can't read what has not yet been written).
_wrfc.initialize(_num_jfiles, _jfsize_sblks, (nlfh**)_datafh, &_rcvdat);
_rrfc.initialize(_num_jfiles, (nlfh**)_datafh, _rcvdat._ffid);
- _rmgr.initialize(_rcvdat._fro);
+ _rmgr.initialize(rd_cb, _rcvdat._fro);
_wmgr.initialize(wr_cb, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS, _rcvdat._eo);
_readonly_flag = true;
@@ -430,7 +430,7 @@
u_int32_t cnt = 0;
while (_wmgr.get_aio_evt_rem())
{
- _wmgr.get_events(pmgr::UNUSED);
+ get_wr_events();
if (cnt++ > MAX_AIO_CMPL_SLEEPS)
throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl", "aio_cmpl_wait");
::usleep(AIO_CMPL_SLEEP);
Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -178,11 +178,12 @@
* <b>NOTE: If <i>NULL</i> is passed to the callbacks, internal default callbacks will be
* used.</b>
*
+ * \param rd_cb Function pointer to callback function for read operations. May be 0 (NULL).
* \param wr_cb Function pointer to callback function for write operations. May be 0 (NULL).
*
* \exception TODO
*/
- void initialize(const aio_cb wr_cb);
+ void initialize(const rd_aio_cb rd_cb, const wr_aio_cb wr_cb);
/**
* /brief Initialize journal by recovering state from previously written journal.
@@ -199,14 +200,15 @@
* <b>NOTE: If <i>NULL</i> is passed to the callbacks, internal default callbacks will be
* used.</b>
*
+ * \param rd_cb Function pointer to callback function for read operations. May be 0 (NULL).
* \param wr_cb Function pointer to callback function for write operations. May be 0 (NULL).
* \param prep_txn_list
* \param highest_rid Returns the highest rid found in the journal during recover
*
* \exception TODO
*/
- void recover(const aio_cb wr_cb, const std::vector<std::string>& prep_txn_list,
- u_int64_t& highest_rid);
+ void recover(const rd_aio_cb rd_cb, const wr_aio_cb wr_cb,
+ const std::vector<std::string>& prep_txn_list, u_int64_t& highest_rid);
/**
* \brief Notification to the journal that recovery is complete and that normal operation
Modified: store/trunk/cpp/lib/jrnl/pmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.hpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/jrnl/pmgr.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -42,7 +42,6 @@
#include <deque>
#include <libaio.h>
-#include <jrnl/aio_cb.hpp>
#include <jrnl/data_tok.hpp>
#include <jrnl/deq_rec.hpp>
#include <jrnl/enq_map.hpp>
Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -51,8 +51,9 @@
{}
void
-rmgr::initialize(size_t fro)
+rmgr::initialize(const rd_aio_cb rd_cb, const size_t fro)
{
+ _cb = rd_cb;
initialize();
if (fro)
{
@@ -390,6 +391,8 @@
throw jexception(jerrno::JERR__AIO, oss.str(), "rmgr", "get_events");
}
+ std::vector<u_int16_t> pil;
+ pil.reserve(ret);
for (int i=0; i<ret; i++) // Index of returned AIOs
{
if (_aio_evt_rem == 0)
@@ -419,8 +422,12 @@
pcbp->_rdblks = iocbp->u.c.nbytes / JRNL_DBLK_SIZE;
pcbp->_rfh->add_rd_cmpl_cnt_dblks(pcbp->_rdblks);
pcbp->_state = state;
+ pil[i] = pcbp->_index;
}
+ // Perform AIO return callback
+ if (_cb && ret)
+ (_cb)(_jc, pil);
return ret;
}
@@ -583,7 +590,7 @@
// If skip still incomplete, move to next page and decode again
if (tot_dblk_cnt < dsize_dblks)
{
- if (_pg_offset_dblks == JRNL_SBLK_SIZE * JRNL_RMGR_PAGE_SIZE)
+ if (dblks_rem() == 0)
rotate_page();
if (_page_cb_arr[_pg_index]._state != AIO_COMPLETE)
{
Modified: store/trunk/cpp/lib/jrnl/rmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.hpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/jrnl/rmgr.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -39,6 +39,7 @@
}
}
+#include <jrnl/aio_cb.hpp>
#include <jrnl/enums.hpp>
#include <jrnl/pmgr.hpp>
#include <jrnl/rec_hdr.hpp>
@@ -58,14 +59,15 @@
class rmgr : public pmgr
{
private:
- rrfc& _rrfc; ///< Ref to read rotating file controller
+ rrfc& _rrfc; ///< Ref to read rotating file controller
rec_hdr _hdr; ///< Header used to determind record type
+ rd_aio_cb _cb; ///< Callback function pointer for AIO events
public:
rmgr(jcntl* jc, enq_map& emap, txn_map& tmap, rrfc& rrfc);
virtual ~rmgr();
- void initialize(size_t fro);
+ void initialize(const rd_aio_cb rd_cb, const size_t fro);
const iores get(const u_int64_t& rid, const size_t& dsize, const size_t& dsize_avail,
const void** const data, bool auto_discard);
const iores discard(data_tok* dtok);
Added: store/trunk/cpp/lib/jrnl/slock.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/slock.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/slock.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -0,0 +1,31 @@
+/**
+* \file slock.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* File containing code for class rhm::journal::slock (scoped lock). See
+* comments in file slock.hpp for details.
+*
+* Copyright (C) 2007, 2008 Red Hat Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include <jrnl/slock.hpp>
Modified: store/trunk/cpp/lib/jrnl/slock.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/slock.hpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/jrnl/slock.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -31,11 +31,11 @@
#ifndef rhm_journal_slock_hpp
#define rhm_journal_slock_hpp
-#include <sstream>
-#include <pthread.h>
#include <errno.h>
#include <jrnl/jerrno.hpp>
#include <jrnl/jexception.hpp>
+#include <pthread.h>
+#include <sstream>
namespace rhm
{
@@ -50,11 +50,11 @@
public:
inline slock(pthread_mutex_t* m) : _m(m)
{
- PTHREAD_CHK(pthread_mutex_lock(_m), "pthread_mutex_lock", "slock", "slock");
+ PTHREAD_CHK(::pthread_mutex_lock(_m), "pthread_mutex_lock", "slock", "slock");
}
inline ~slock()
{
- PTHREAD_CHK(pthread_mutex_unlock(_m), "pthread_mutex_unlock", "slock", "~slock");
+ PTHREAD_CHK(::pthread_mutex_unlock(_m), "pthread_mutex_unlock", "slock", "~slock");
}
};
@@ -67,7 +67,7 @@
public:
inline stlock(pthread_mutex_t* m) : _m(m), _locked(false)
{
- int ret = pthread_mutex_trylock(_m);
+ int ret = ::pthread_mutex_trylock(_m);
_locked = (ret == 0); // check if lock obtained
if (!_locked && ret != EBUSY) PTHREAD_CHK(ret, "pthread_mutex_trylock", "stlock",
"stlock");
@@ -75,7 +75,8 @@
inline ~stlock()
{
if (_locked)
- PTHREAD_CHK(pthread_mutex_unlock(_m), "pthread_mutex_unlock", "stlock", "~stlock");
+ PTHREAD_CHK(::pthread_mutex_unlock(_m), "pthread_mutex_unlock", "stlock",
+ "~stlock");
}
inline const bool locked() const { return _locked; }
};
Added: store/trunk/cpp/lib/jrnl/time_ns.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/time_ns.cpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/time_ns.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -0,0 +1,47 @@
+/**
+* \file time_ns.cpp
+*
+* Copyright 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "time_ns.hpp"
+#include <sstream>
+
+namespace rhm
+{
+namespace journal
+{
+
+const std::string
+time_ns::str(int precision) const
+{
+ const double t = tv_sec + (tv_nsec/1e9);
+ std::ostringstream oss;
+ oss.setf(std::ios::fixed, std::ios::floatfield);
+ oss.precision(precision);
+ oss << t;
+ return oss.str();
+}
+
+
+} // namespace jtt
+} // namespace rhm
Added: store/trunk/cpp/lib/jrnl/time_ns.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/time_ns.hpp (rev 0)
+++ store/trunk/cpp/lib/jrnl/time_ns.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -0,0 +1,97 @@
+/**
+* \file time_ns.hpp
+*
+* Copyright 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+#ifndef rhm_jtt_time_ns_hpp
+#define rhm_jtt_time_ns_hpp
+
+#include <errno.h>
+#include <string>
+#include <time.h>
+
+namespace rhm
+{
+namespace journal
+{
+
+struct time_ns : public timespec
+{
+ inline time_ns() { tv_sec = 0; tv_nsec = 0; }
+ inline time_ns(const time_t sec, const long nsec = 0) { tv_sec = sec; tv_nsec = nsec; }
+ inline time_ns(const time_ns& t) { tv_sec = t.tv_sec; tv_nsec = t.tv_nsec; }
+
+ inline void set_zero() { tv_sec = 0; tv_nsec = 0; }
+ inline bool is_zero() const { return tv_sec == 0 && tv_nsec == 0; }
+ inline int now() { if(::clock_gettime(CLOCK_REALTIME, this)) return errno; return 0; }
+ const std::string str(int precision = 6) const;
+
+ inline time_ns& operator=(const time_ns& rhs)
+ { tv_sec = rhs.tv_sec; tv_nsec = rhs.tv_nsec; return *this; }
+ inline time_ns& operator+=(const time_ns& rhs)
+ {
+ tv_nsec += rhs.tv_nsec;
+ if (tv_nsec >= 1000000000L) { tv_sec++; tv_nsec -= 1000000000L; }
+ tv_sec += rhs.tv_sec;
+ return *this;
+ }
+ inline time_ns& operator+=(const long ns)
+ {
+ tv_nsec += ns;
+ if (tv_nsec >= 1000000000L) { tv_sec++; tv_nsec -= 1000000000L; }
+ return *this;
+ }
+ inline time_ns& operator-=(const long ns)
+ {
+ tv_nsec -= ns;
+ if (tv_nsec < 0) { tv_sec--; tv_nsec += 1000000000L; }
+ return *this;
+ }
+ inline time_ns& operator-=(const time_ns& rhs)
+ {
+ tv_nsec -= rhs.tv_nsec;
+ if (tv_nsec < 0) { tv_sec--; tv_nsec += 1000000000L; }
+ tv_sec -= rhs.tv_sec;
+ return *this;
+ }
+ inline const time_ns operator+(const time_ns& rhs)
+ { time_ns t(*this); t += rhs; return t; }
+ inline const time_ns operator-(const time_ns& rhs)
+ { time_ns t(*this); t -= rhs; return t; }
+ inline bool operator==(const time_ns& rhs)
+ { return tv_sec == rhs.tv_sec && tv_nsec == rhs.tv_nsec; }
+ inline bool operator!=(const time_ns& rhs)
+ { return tv_sec != rhs.tv_sec || tv_nsec != rhs.tv_nsec; }
+ inline bool operator>(const time_ns& rhs)
+ { if(tv_sec == rhs.tv_sec) return tv_nsec > rhs.tv_nsec; return tv_sec > rhs.tv_sec; }
+ inline bool operator>=(const time_ns& rhs)
+ { if(tv_sec == rhs.tv_sec) return tv_nsec >= rhs.tv_nsec; return tv_sec >= rhs.tv_sec; }
+ inline bool operator<(const time_ns& rhs)
+ { if(tv_sec == rhs.tv_sec) return tv_nsec < rhs.tv_nsec; return tv_sec < rhs.tv_sec; }
+ inline bool operator<=(const time_ns& rhs)
+ { if(tv_sec == rhs.tv_sec) return tv_nsec <= rhs.tv_nsec; return tv_sec <= rhs.tv_sec; }
+};
+
+} // namespace jtt
+} // namespace rhm
+
+#endif // ifndef rhm_jtt_time_ns_hpp
Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -37,8 +37,6 @@
#include <jrnl/jcntl.hpp>
#include <jrnl/jerrno.hpp>
-#include <iostream> // debug
-
namespace rhm
{
namespace journal
@@ -91,7 +89,7 @@
}
void
-wmgr::initialize(const aio_cb wr_cb, const u_int32_t max_dtokpp, const u_int32_t max_iowait_us,
+wmgr::initialize(const wr_aio_cb wr_cb, const u_int32_t max_dtokpp, const u_int32_t max_iowait_us,
size_t eo)
{
_enq_busy = false;
@@ -758,8 +756,6 @@
int ret = 0;
if ((ret = ::io_getevents(_ioctx, 0, JRNL_RMGR_PAGES + JRNL_WMGR_PAGES, _ioevt_arr, 0)) < 0)
{
- if (ret == -EINTR) // No events
- return 0;
std::ostringstream oss;
oss << "io_getevents() failed: " << strerror(-ret) << " (" << ret << ")";
throw jexception(jerrno::JERR__AIO, oss.str(), "wmgr", "get_events");
@@ -781,8 +777,15 @@
if (aioret < 0)
{
std::ostringstream oss;
- oss << "AIO write operation failed: " << strerror(-aioret) << " (" << aioret << ")";
- oss << " [pg=" << pcbp->_index << " size=" << iocbp->u.c.nbytes;
+ oss << "AIO write operation failed: " << strerror(-aioret) << " (" << aioret << ") [";
+ if (pcbp)
+ oss << "pg=" << pcbp->_index;
+ else
+ {
+ file_hdr* fhp = (file_hdr*)iocbp->u.c.buf;
+ oss << "fid=" << fhp->_fid;
+ }
+ oss << " size=" << iocbp->u.c.nbytes;
oss << " offset=" << iocbp->u.c.offset << " fh=" << iocbp->aio_fildes << "]";
throw jexception(jerrno::JERR__AIO, oss.str(), "wmgr", "get_events");
}
Modified: store/trunk/cpp/lib/jrnl/wmgr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.hpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/lib/jrnl/wmgr.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -39,6 +39,7 @@
}
}
+#include <jrnl/aio_cb.hpp>
#include <jrnl/enums.hpp>
#include <jrnl/pmgr.hpp>
#include <jrnl/wrfc.hpp>
@@ -93,7 +94,7 @@
deq_rec _deq_rec; ///< Dequeue record used for encoding/decoding
txn_rec _txn_rec; ///< Transaction record used for encoding/decoding
std::set<std::string> _txn_pending_set; ///< Set containing xids of pending commits/aborts
- aio_cb _cb; ///< Callback function pointer for AIO events
+ wr_aio_cb _cb; ///< Callback function pointer for AIO events
public:
wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc);
@@ -101,7 +102,7 @@
const u_int32_t max_iowait_us);
virtual ~wmgr();
- void initialize(aio_cb wr_cb, const u_int32_t max_dtokpp, const u_int32_t max_iowait_us,
+ void initialize(wr_aio_cb wr_cb, const u_int32_t max_dtokpp, const u_int32_t max_iowait_us,
size_t eo = 0);
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,
Property changes on: store/trunk/cpp/tests/jrnl
___________________________________________________________________
Name: svn:ignore
- .deps
.libs
Makefile
Makefile.in
jtest
_ut_enq_map
_ut_jdir
_ut_jerrno
_ut_jexception
_ut_jinf
_ut_rec_hdr
_ut_txn_map
+ .deps
.libs
Makefile
Makefile.in
jtest
_ut_enq_map
_ut_jdir
_ut_jerrno
_ut_jexception
_ut_jinf
_ut_rec_hdr
_ut_time_ns
_ut_txn_map
Modified: store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/JournalSystemTests.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -647,14 +647,14 @@
void
JournalSystemTests::jrnl_init(rhm::journal::jcntl* jc)
{
- jc->initialize(0);
+ jc->initialize(0, 0);
}
void
JournalSystemTests::jrnl_recover(rhm::journal::jcntl* jc, vector<string> txn_list,
u_int64_t& highest_rid)
{
- jc->recover(0, txn_list, highest_rid);
+ jc->recover(0, 0, txn_list, highest_rid);
}
void
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2008-02-06 15:39:52 UTC (rev 1645)
@@ -28,6 +28,7 @@
# SUBDIRS = jtt
TESTS = \
+ _ut_time_ns \
_ut_jexception \
_ut_jerrno \
_ut_rec_hdr \
@@ -42,6 +43,7 @@
libdlclose_noop.la
check_PROGRAMS = \
+ _ut_time_ns \
_ut_jexception \
_ut_jerrno \
_ut_rec_hdr \
@@ -53,6 +55,9 @@
UNIT_TEST_SRCS = ../unit_test.cpp
UNIT_TEST_LDADD = -lboost_unit_test_framework -lbdbstore -L../../lib/.libs
+_ut_time_ns_SOURCES = _ut_time_ns.cpp $(UNIT_TEST_SRCS)
+_ut_time_ns_LDFLAGS = $(UNIT_TEST_LDADD)
+
_ut_jexception_SOURCES = _ut_jexception.cpp $(UNIT_TEST_SRCS)
_ut_jexception_LDFLAGS = $(UNIT_TEST_LDADD)
Added: store/trunk/cpp/tests/jrnl/_ut_time_ns.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_time_ns.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/_ut_time_ns.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -0,0 +1,151 @@
+/**
+* Copyright 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "../unit_test.h"
+#include <jrnl/time_ns.hpp>
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+QPID_AUTO_TEST_SUITE(jtt_time_ns)
+
+BOOST_AUTO_TEST_CASE(time_ns_constructors)
+{
+ const time_t sec = 123;
+ const long nsec = 123456789;
+
+ time_ns t1;
+ BOOST_CHECK_EQUAL(t1.tv_sec, 0);
+ BOOST_CHECK_EQUAL(t1.tv_nsec, 0);
+ BOOST_CHECK_EQUAL(t1.is_zero(), true);
+ time_ns t2(sec, nsec);
+ BOOST_CHECK_EQUAL(t2.tv_sec, sec);
+ BOOST_CHECK_EQUAL(t2.tv_nsec, nsec);
+ BOOST_CHECK_EQUAL(t2.is_zero(), false);
+ time_ns t3(t1);
+ BOOST_CHECK_EQUAL(t3.tv_sec, 0);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, 0);
+ BOOST_CHECK_EQUAL(t3.is_zero(), true);
+ time_ns t4(t2);
+ BOOST_CHECK_EQUAL(t4.tv_sec, sec);
+ BOOST_CHECK_EQUAL(t4.tv_nsec, nsec);
+ BOOST_CHECK_EQUAL(t4.is_zero(), false);
+ t4.set_zero();
+ BOOST_CHECK_EQUAL(t4.tv_sec, 0);
+ BOOST_CHECK_EQUAL(t4.tv_nsec, 0);
+ BOOST_CHECK_EQUAL(t4.is_zero(), true);
+}
+
+BOOST_AUTO_TEST_CASE(time_ns_operators)
+{
+ const time_t sec1 = 123;
+ const long nsec1 = 123456789;
+ const time_t sec2 = 1;
+ const long nsec2 = 999999999;
+ const time_t sec_sum = sec1 + sec2 + 1;
+ const long nsec_sum = nsec1 + nsec2 - 1000000000;
+ const time_t sec_1_minus_2 = sec1 - sec2 - 1;
+ const long nsec_1_minus_2 = nsec1 - nsec2 + 1000000000;
+ const time_t sec_2_minus_1 = sec2 - sec1;
+ const long nsec_2_minus_1 = nsec2 - nsec1;
+ time_ns z;
+ time_ns t1(sec1, nsec1);
+ time_ns t2(sec2, nsec2);
+
+ time_ns t3 = z;
+ BOOST_CHECK_EQUAL(t3.tv_sec, 0);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, 0);
+ BOOST_CHECK_EQUAL(t3 == z, true);
+ BOOST_CHECK_EQUAL(t3 != z, false);
+ BOOST_CHECK_EQUAL(t3 > z, false);
+ BOOST_CHECK_EQUAL(t3 >= z, true);
+ BOOST_CHECK_EQUAL(t3 < z, false);
+ BOOST_CHECK_EQUAL(t3 <= z, true);
+
+ t3 = t1;
+ BOOST_CHECK_EQUAL(t3.tv_sec, sec1);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, nsec1);
+ BOOST_CHECK_EQUAL(t3 == t1, true);
+ BOOST_CHECK_EQUAL(t3 != t1, false);
+ BOOST_CHECK_EQUAL(t3 > t1, false);
+ BOOST_CHECK_EQUAL(t3 >= t1, true);
+ BOOST_CHECK_EQUAL(t3 < t1, false);
+ BOOST_CHECK_EQUAL(t3 <= t1, true);
+
+ t3 += z;
+ BOOST_CHECK_EQUAL(t3.tv_sec, sec1);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, nsec1);
+
+ t3 = t2;
+ BOOST_CHECK_EQUAL(t3.tv_sec, sec2);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, nsec2);
+ BOOST_CHECK_EQUAL(t3 == t2, true);
+ BOOST_CHECK_EQUAL(t3 != t2, false);
+ BOOST_CHECK_EQUAL(t3 > t2, false);
+ BOOST_CHECK_EQUAL(t3 >= t2, true);
+ BOOST_CHECK_EQUAL(t3 < t2, false);
+ BOOST_CHECK_EQUAL(t3 <= t2, true);
+
+ t3 += z;
+ BOOST_CHECK_EQUAL(t3.tv_sec, sec2);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, nsec2);
+
+ t3 = t1;
+ t3 += t2;
+ BOOST_CHECK_EQUAL(t3.tv_sec, sec_sum);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, nsec_sum);
+
+ t3 = t1;
+ t3 -= t2;
+ BOOST_CHECK_EQUAL(t3.tv_sec, sec_1_minus_2);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, nsec_1_minus_2);
+
+ t3 = t2;
+ t3 -= t1;
+ BOOST_CHECK_EQUAL(t3.tv_sec, sec_2_minus_1);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, nsec_2_minus_1);
+
+ t3 = t1 + t2;
+ BOOST_CHECK_EQUAL(t3.tv_sec, sec_sum);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, nsec_sum);
+
+ t3 = t1 - t2;
+ BOOST_CHECK_EQUAL(t3.tv_sec, sec_1_minus_2);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, nsec_1_minus_2);
+
+ t3 = t2 - t1;
+ BOOST_CHECK_EQUAL(t3.tv_sec, sec_2_minus_1);
+ BOOST_CHECK_EQUAL(t3.tv_nsec, nsec_2_minus_1);
+}
+
+BOOST_AUTO_TEST_CASE(time_ns_str)
+{
+ time_ns t1(123, 123456789);
+ BOOST_CHECK_EQUAL(t1.str(), "123.123457");
+ BOOST_CHECK_EQUAL(t1.str(9), "123.123456789");
+ BOOST_CHECK_EQUAL(t1.str(0), "123");
+ time_ns t2(1, 1);
+ BOOST_CHECK_EQUAL(t2.str(9), "1.000000001");
+ time_ns t3(-12, 345);
+ BOOST_CHECK_EQUAL(t3.str(9), "-11.999999655");
+}
Modified: store/trunk/cpp/tests/jrnl/jtt/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/Makefile.am 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/jtt/Makefile.am 2008-02-06 15:39:52 UTC (rev 1645)
@@ -76,6 +76,7 @@
${LIBOBJDIR}/pmgr.o \
${LIBOBJDIR}/rmgr.o \
${LIBOBJDIR}/rrfc.o \
+ ${LIBOBJDIR}/time_ns.o \
${LIBOBJDIR}/txn_map.o \
${LIBOBJDIR}/txn_rec.o \
${LIBOBJDIR}/wmgr.o \
@@ -122,6 +123,7 @@
${LIBOBJDIR}/pmgr.o \
${LIBOBJDIR}/rmgr.o \
${LIBOBJDIR}/rrfc.o \
+ ${LIBOBJDIR}/time_ns.o \
${LIBOBJDIR}/txn_map.o \
${LIBOBJDIR}/txn_rec.o \
${LIBOBJDIR}/wmgr.o \
@@ -129,23 +131,32 @@
_ut_test_case_SOURCES = _ut_test_case.cpp ../../unit_test.cpp
_ut_test_case_LDFLAGS = -lboost_unit_test_framework -lrt
-_ut_test_case_LDADD = test_case.o test_case_result.o test_case_result_agregation.o
+_ut_test_case_LDADD = test_case.o test_case_result.o test_case_result_agregation.o \
+ ${LIBOBJDIR}/time_ns.o
+
_ut_test_case_result_SOURCES = _ut_test_case_result.cpp ../../unit_test.cpp
_ut_test_case_result_LDFLAGS = -lboost_unit_test_framework -lrt
_ut_test_case_result_LDADD = test_case_result.o \
${LIBOBJDIR}/jerrno.o \
- ${LIBOBJDIR}/jexception.o
+ ${LIBOBJDIR}/jexception.o \
+ ${LIBOBJDIR}/time_ns.o
_ut_test_case_result_agregation_SOURCES = _ut_test_case_result_agregation.cpp ../../unit_test.cpp
_ut_test_case_result_agregation_LDFLAGS = -lboost_unit_test_framework -lrt
_ut_test_case_result_agregation_LDADD = test_case_result.o test_case_result_agregation.o \
${LIBOBJDIR}/jerrno.o \
- ${LIBOBJDIR}/jexception.o
+ ${LIBOBJDIR}/jexception.o \
+ ${LIBOBJDIR}/time_ns.o
_ut_test_case_set_SOURCES = _ut_test_case_set.cpp ../../unit_test.cpp
_ut_test_case_set_LDFLAGS = -lboost_unit_test_framework -lrt
-_ut_test_case_set_LDADD = test_case.o test_case_set.o test_case_result.o test_case_result_agregation.o
+_ut_test_case_set_LDADD = \
+ test_case.o \
+ test_case_set.o \
+ test_case_result.o \
+ test_case_result_agregation.o \
+ ${LIBOBJDIR}/time_ns.o
EXTRA_DIST = \
jtt.csv \
Modified: store/trunk/cpp/tests/jrnl/jtt/_ut_test_case_result.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/_ut_test_case_result.cpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/jtt/_ut_test_case_result.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -38,15 +38,12 @@
BOOST_CHECK_EQUAL(tcr.jid(), jid);
BOOST_CHECK_EQUAL(tcr.exception(), false);
BOOST_CHECK_EQUAL(tcr.exception_count(), 0U);
- const timespec& ts1 = tcr.start_time();
- BOOST_CHECK_EQUAL(ts1.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts1.tv_nsec, 0);
- const timespec& ts2 = tcr.stop_time();
- BOOST_CHECK_EQUAL(ts2.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts2.tv_nsec, 0);
- const timespec& ts3 = tcr.test_time();
- BOOST_CHECK_EQUAL(ts3.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts3.tv_nsec, 0);
+ const time_ns& ts1 = tcr.start_time();
+ BOOST_CHECK(ts1.is_zero());
+ const time_ns& ts2 = tcr.stop_time();
+ BOOST_CHECK(ts2.is_zero());
+ const time_ns& ts3 = tcr.test_time();
+ BOOST_CHECK(ts3.is_zero());
}
BOOST_AUTO_TEST_CASE(test_case_result_start_stop)
@@ -55,37 +52,30 @@
test_case_result tcr(jid);
BOOST_CHECK_EQUAL(tcr.exception(), false);
BOOST_CHECK_EQUAL(tcr.exception_count(), 0U);
- const timespec& ts1 = tcr.start_time();
- BOOST_CHECK_EQUAL(ts1.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts1.tv_nsec, 0);
- const timespec& ts2 = tcr.stop_time();
- BOOST_CHECK_EQUAL(ts2.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts2.tv_nsec, 0);
- const timespec& ts3 = tcr.test_time();
- BOOST_CHECK_EQUAL(ts3.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts3.tv_nsec, 0);
+ const time_ns& ts1 = tcr.start_time();
+ BOOST_CHECK(ts1.is_zero());
+ const time_ns& ts2 = tcr.stop_time();
+ BOOST_CHECK(ts2.is_zero());
+ const time_ns& ts3 = tcr.test_time();
+ BOOST_CHECK(ts3.is_zero());
tcr.set_start_time();
BOOST_CHECK_EQUAL(tcr.exception(), false);
BOOST_CHECK_EQUAL(tcr.exception_count(), 0U);
- const timespec& ts4 = tcr.start_time();
- BOOST_CHECK(ts4.tv_sec > 0);
- BOOST_CHECK(ts4.tv_nsec > 0);
- const timespec& ts5 = tcr.stop_time();
- BOOST_CHECK_EQUAL(ts5.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts5.tv_nsec, 0);
- const timespec& ts6 = tcr.test_time();
- BOOST_CHECK_EQUAL(ts6.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts6.tv_nsec, 0);
+ const time_ns& ts4 = tcr.start_time();
+ BOOST_CHECK(!ts4.is_zero());
+ const time_ns& ts5 = tcr.stop_time();
+ BOOST_CHECK(ts5.is_zero());
+ const time_ns& ts6 = tcr.test_time();
+ BOOST_CHECK(ts6.is_zero());
::usleep(1100000); // 1.1 sec in microseconds
tcr.set_stop_time();
BOOST_CHECK_EQUAL(tcr.exception(), false);
BOOST_CHECK_EQUAL(tcr.exception_count(), 0U);
- const timespec& ts7 = tcr.stop_time();
- BOOST_CHECK(ts7.tv_sec > 0);
- BOOST_CHECK(ts7.tv_nsec > 0);
- const timespec& ts8 = tcr.test_time();
+ const time_ns& ts7 = tcr.stop_time();
+ BOOST_CHECK(!ts7.is_zero());
+ const time_ns& ts8 = tcr.test_time();
BOOST_CHECK(ts8.tv_sec == 1);
BOOST_CHECK(ts8.tv_nsec > 100000000); // 0.1 sec in nanoseconds
BOOST_CHECK(ts8.tv_nsec < 200000000); // 0.2 sec in nanoseconds
@@ -104,10 +94,9 @@
BOOST_CHECK_EQUAL(tcr.exception(), true);
BOOST_CHECK_EQUAL(tcr.exception_count(), 1U);
BOOST_CHECK_EQUAL(tcr[0], e.what());
- const timespec& ts1 = tcr.stop_time();
- BOOST_CHECK(ts1.tv_sec > 0);
- BOOST_CHECK(ts1.tv_nsec > 0);
- const timespec& ts2 = tcr.test_time();
+ const time_ns& ts1 = tcr.stop_time();
+ BOOST_CHECK(!ts1.is_zero());
+ const time_ns& ts2 = tcr.test_time();
BOOST_CHECK(ts2.tv_sec == 1);
BOOST_CHECK(ts2.tv_nsec > 100000000); // 0.1 sec in nanoseconds
BOOST_CHECK(ts2.tv_nsec < 200000000); // 0.2 sec in nanoseconds
@@ -124,10 +113,9 @@
BOOST_CHECK_EQUAL(tcr.exception(), true);
BOOST_CHECK_EQUAL(tcr.exception_count(), 1U);
BOOST_CHECK_EQUAL(tcr[0], err_msg);
- const timespec& ts1 = tcr.stop_time();
- BOOST_CHECK(ts1.tv_sec > 0);
- BOOST_CHECK(ts1.tv_nsec > 0);
- const timespec& ts2 = tcr.test_time();
+ const time_ns& ts1 = tcr.stop_time();
+ BOOST_CHECK(!ts1.is_zero());
+ const time_ns& ts2 = tcr.test_time();
BOOST_CHECK(ts2.tv_sec == 1);
BOOST_CHECK(ts2.tv_nsec > 100000000); // 0.1 sec in nanoseconds
BOOST_CHECK(ts2.tv_nsec < 200000000); // 0.2 sec in nanoseconds
@@ -144,10 +132,9 @@
BOOST_CHECK_EQUAL(tcr.exception(), true);
BOOST_CHECK_EQUAL(tcr.exception_count(), 1U);
BOOST_CHECK_EQUAL(tcr[0], err_msg);
- const timespec& ts1 = tcr.stop_time();
- BOOST_CHECK(ts1.tv_sec > 0);
- BOOST_CHECK(ts1.tv_nsec > 0);
- const timespec& ts2 = tcr.test_time();
+ const time_ns& ts1 = tcr.stop_time();
+ BOOST_CHECK(!ts1.is_zero());
+ const time_ns& ts2 = tcr.test_time();
BOOST_CHECK(ts2.tv_sec == 1);
BOOST_CHECK(ts2.tv_nsec > 100000000); // 0.1 sec in nanoseconds
BOOST_CHECK(ts2.tv_nsec < 200000000); // 0.2 sec in nanoseconds
@@ -166,12 +153,10 @@
BOOST_CHECK_EQUAL(tcr.exception(), true);
BOOST_CHECK_EQUAL(tcr.exception_count(), 1U);
BOOST_CHECK_EQUAL(tcr[0], e.what());
- const timespec& ts1 = tcr.stop_time();
- BOOST_CHECK_EQUAL(ts1.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts1.tv_nsec, 0);
- const timespec& ts2 = tcr.test_time();
- BOOST_CHECK_EQUAL(ts2.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts2.tv_nsec, 0);
+ const time_ns& ts1 = tcr.stop_time();
+ BOOST_CHECK(ts1.is_zero());
+ const time_ns& ts2 = tcr.test_time();
+ BOOST_CHECK(ts2.is_zero());
}
BOOST_AUTO_TEST_CASE(test_case_counters)
Modified: store/trunk/cpp/tests/jrnl/jtt/_ut_test_case_result_agregation.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/_ut_test_case_result_agregation.cpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/jtt/_ut_test_case_result_agregation.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -46,15 +46,12 @@
BOOST_CHECK_EQUAL(tcra.jid(), "Average");
BOOST_CHECK_EQUAL(tcra.exception(), false);
BOOST_CHECK_EQUAL(tcra.exception_count(), 0U);
- const timespec& ts1 = tcra.start_time();
- BOOST_CHECK_EQUAL(ts1.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts1.tv_nsec, 0);
- const timespec& ts2 = tcra.stop_time();
- BOOST_CHECK_EQUAL(ts2.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts2.tv_nsec, 0);
- const timespec& ts3 = tcra.test_time();
- BOOST_CHECK_EQUAL(ts3.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts3.tv_nsec, 0);
+ const time_ns& ts1 = tcra.start_time();
+ BOOST_CHECK(ts1.is_zero());
+ const time_ns& ts2 = tcra.stop_time();
+ BOOST_CHECK(ts2.is_zero());
+ const time_ns& ts3 = tcra.test_time();
+ BOOST_CHECK(ts3.is_zero());
}
BOOST_AUTO_TEST_CASE(test_case_result_agregation_constructor_2)
@@ -65,15 +62,12 @@
BOOST_CHECK_EQUAL(tcra.jid(), jid);
BOOST_CHECK_EQUAL(tcra.exception(), false);
BOOST_CHECK_EQUAL(tcra.exception_count(), 0U);
- const timespec& ts1 = tcra.start_time();
- BOOST_CHECK_EQUAL(ts1.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts1.tv_nsec, 0);
- const timespec& ts2 = tcra.stop_time();
- BOOST_CHECK_EQUAL(ts2.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts2.tv_nsec, 0);
- const timespec& ts3 = tcra.test_time();
- BOOST_CHECK_EQUAL(ts3.tv_sec, 0);
- BOOST_CHECK_EQUAL(ts3.tv_nsec, 0);
+ const time_ns& ts1 = tcra.start_time();
+ BOOST_CHECK(ts1.is_zero());
+ const time_ns& ts2 = tcra.stop_time();
+ BOOST_CHECK(ts2.is_zero());
+ const time_ns& ts3 = tcra.test_time();
+ BOOST_CHECK(ts3.is_zero());
}
BOOST_AUTO_TEST_CASE(test_case_result_agregation_add_test_case)
@@ -158,7 +152,7 @@
BOOST_CHECK_EQUAL(tcra.num_results(), num_results);
BOOST_CHECK_EQUAL(tcra.exception_count(), num_exceptions);
BOOST_CHECK_EQUAL(tcra.exception(), num_exceptions > 0);
- const timespec& ts1 = tcra.test_time();
+ const time_ns& ts1 = tcra.test_time();
BOOST_CHECK_EQUAL(ts1.tv_sec, secs);
BOOST_CHECK_EQUAL(ts1.tv_nsec, nsec);
}
@@ -173,9 +167,7 @@
tcrp->incr_num_deq();
for (unsigned i=0; i<num_reads; i++)
tcrp->incr_num_read();
- timespec ts;
- ts.tv_sec = secs;
- ts.tv_nsec = nsec;
+ time_ns ts(secs, nsec);
tcrp->set_test_time(ts);
return tcrp;
}
Modified: store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -28,10 +28,10 @@
#include <jrnl/data_tok.hpp>
#include <jrnl/jerrno.hpp>
-#include <iostream>
+#include <iostream> // debug
-#define SLEEP_US 1000 // 1 ms
-#define MAX_SLEEP_CNT 2000 // 2 sec max
+#define MAX_WR_WAIT 10 // in ms
+#define MAX_RD_WAIT 100 // in ms
namespace rhm
{
@@ -47,11 +47,17 @@
_dtok_master_txn_list(),
_dtok_rd_list(),
_dtok_deq_list(),
+ _rd_aio_cv(_rd_aio_mutex),
+ _wr_full_cv(_wr_full_mutex),
+ _rd_list_cv(_rd_list_mutex),
+ _deq_list_cv(_deq_list_mutex),
_tcp(),
_tcrp()
{
- pthread_mutex_init(&_rd_mutex, 0);
- pthread_mutex_init(&_deq_mutex, 0);
+ pthread_mutex_init(&_rd_aio_mutex, 0);
+ pthread_mutex_init(&_wr_full_mutex, 0);
+ pthread_mutex_init(&_rd_list_mutex, 0);
+ pthread_mutex_init(&_deq_list_mutex, 0);
}
jrnl_instance::jrnl_instance(const jrnl_init_params::shared_ptr& p):
@@ -63,17 +69,25 @@
_dtok_master_txn_list(),
_dtok_rd_list(),
_dtok_deq_list(),
+ _rd_aio_cv(_rd_aio_mutex),
+ _wr_full_cv(_wr_full_mutex),
+ _rd_list_cv(_rd_list_mutex),
+ _deq_list_cv(_deq_list_mutex),
_tcp(),
_tcrp()
{
- pthread_mutex_init(&_rd_mutex, 0);
- pthread_mutex_init(&_deq_mutex, 0);
+ pthread_mutex_init(&_rd_aio_mutex, 0);
+ pthread_mutex_init(&_wr_full_mutex, 0);
+ pthread_mutex_init(&_rd_list_mutex, 0);
+ pthread_mutex_init(&_deq_list_mutex, 0);
}
jrnl_instance::~jrnl_instance()
{
- pthread_mutex_destroy(&_rd_mutex);
- pthread_mutex_destroy(&_deq_mutex);
+ pthread_mutex_destroy(&_rd_aio_mutex);
+ pthread_mutex_destroy(&_wr_full_mutex);
+ pthread_mutex_destroy(&_rd_list_mutex);
+ pthread_mutex_destroy(&_deq_list_mutex);
}
@@ -97,19 +111,19 @@
{
std::vector<std::string> prep_txn_list;
u_int64_t highest_rid;
- recover(aio_wr_callback, prep_txn_list, highest_rid);
+ recover(aio_rd_callback, aio_wr_callback, prep_txn_list, highest_rid);
recover_complete();
}
catch (const rhm::journal::jexception& e)
{
if (e.err_code() == rhm::journal::jerrno::JERR_JDIR_STAT)
- initialize(aio_wr_callback);
+ initialize(aio_rd_callback, aio_wr_callback);
else
throw;
}
}
else
- initialize(aio_wr_callback);
+ initialize(aio_rd_callback, aio_wr_callback);
}
catch (const rhm::journal::jexception& e) { _tcrp->add_exception(e); }
catch (const std::exception& e) { _tcrp->add_exception(e.what()); }
@@ -175,33 +189,29 @@
else
res = enqueue_data_record(msgp, msg_size, msg_size, p.get(), transient);
}
- if (res == rhm::journal::RHM_IORES_SUCCESS)
+ switch (res)
{
+ case rhm::journal::RHM_IORES_SUCCESS:
sleep_cnt = 0U;
_tcrp->incr_num_enq();
- }
- else if (res == rhm::journal::RHM_IORES_ENQCAPTHRESH)
- {
- if (sleep_cnt++ > MAX_SLEEP_CNT)
+ if (p->has_xid() && !_tcp->auto_deq())
+ commit(p.get());
+ break;
+ case rhm::journal::RHM_IORES_ENQCAPTHRESH:
+ if (get_wr_events() == 0)
{
- std::ostringstream oss;
- oss << "ERROR: Timeout waiting for journal \"" << _jid;
- oss << "\" to empty. (RHM_IORES_ENQCAPTHRESH)";
- _tcrp->add_exception(oss.str());
+ rhm::journal::slock sl(&_wr_full_mutex);
+ _wr_full_cv.waitintvl(MAX_WR_WAIT * 1000000); // MAX_WR_WAIT in ms
}
- else
- ::usleep(SLEEP_US); // 1ms
- }
- else
- {
+ break;
+ default:
std::ostringstream oss;
oss << "ERROR: enqueue operation in journal \"" << _jid << "\" returned ";
oss << rhm::journal::iores_str(res) << ".";
_tcrp->add_exception(oss.str());
}
-
}
- flush();
+ flush(true);
}
catch (const rhm::journal::jexception& e) { _tcrp->add_exception(e); }
catch (const std::exception& e) { _tcrp->add_exception(e.what()); }
@@ -216,31 +226,21 @@
read_arg::read_mode_t rd_mode = _args_ptr->read_mode.val();
if (rd_mode != read_arg::NONE)
{
- unsigned sleep_cnt = 0U;
while (_tcrp->num_rproc() < _tcp->num_msgs() && !_tcrp->exception())
{
- if (_dtok_rd_list.empty())
+ journal::data_tok* dtokp = 0;
{
- if (sleep_cnt++ > MAX_SLEEP_CNT)
+ rhm::journal::slock sl(&_rd_list_mutex);
+ if (_dtok_rd_list.empty())
+ _rd_list_cv.wait();
+ if (!_dtok_rd_list.empty())
{
- std::ostringstream oss;
- oss << "ERROR: Timeout waiting for enqueue AIO in journal \"" << _jid;
- oss << "\": num_enq=" << _tcp->num_msgs();
- oss << " num_deq=" << _tcrp->num_deq();
- _tcrp->add_exception(oss.str());
- }
- if (get_wr_events() == 0)
- ::usleep(SLEEP_US); // 1ms
- }
- else
- {
- sleep_cnt = 0U;
- journal::data_tok* dtokp;
- {
- rhm::journal::slock sl(&_rd_mutex);
dtokp = _dtok_rd_list.front();
_dtok_rd_list.pop_front();
}
+ }
+ if (dtokp)
+ {
_tcrp->incr_num_rproc();
bool do_read = true;
@@ -260,15 +260,16 @@
bool ext = false;
rhm::journal::iores res = read_data_record(&dptr, dsize, &xptr, xsize, tr,
ext, dtokp);
- if (res == rhm::journal::RHM_IORES_SUCCESS)
+ switch (res)
{
+ case rhm::journal::RHM_IORES_SUCCESS:
{
- rhm::journal::slock sl(&_deq_mutex);
+ rhm::journal::slock sl(&_deq_list_mutex);
_dtok_deq_list.push_back(dtokp);
+ _deq_list_cv.broadcast();
}
read_compl = true;
_tcrp->incr_num_read();
- sleep_cnt = 0;
// clean up
if (xsize)
@@ -277,26 +278,23 @@
::free(dptr);
dptr = 0;
xptr = 0;
- }
- else if (res == rhm::journal::RHM_IORES_AIO_WAIT)
- {
- if (sleep_cnt++ > MAX_SLEEP_CNT)
+ break;
+ case rhm::journal::RHM_IORES_AIO_WAIT:
+ if (get_rd_events() == 0)
{
- std::ostringstream oss;
- oss << "ERROR: Timeout waiting for read AIO in journal \"" << _jid;
- oss << "\": num_enq=" << _tcp->num_msgs();
- oss << " num_deq=" << _tcrp->num_deq();
- _tcrp->add_exception(oss.str());
+ rhm::journal::slock sl(&_rd_aio_mutex);
+ _rd_aio_cv.waitintvl(MAX_RD_WAIT * 1000000); // MAX_RD_WAIT in ms
}
- if (get_rd_events() == 0)
- ::usleep(SLEEP_US); // 1ms
- }
- else
- {
+ break;
+ default:
std::ostringstream oss;
oss << "ERROR: read operation in journal \"" << _jid;
oss << "\" returned " << rhm::journal::iores_str(res) << ".";
_tcrp->add_exception(oss.str());
+ {
+ rhm::journal::slock sl(&_deq_list_mutex);
+ _deq_list_cv.broadcast(); // wake up deq thread
+ }
}
}
}
@@ -315,31 +313,21 @@
{
if (_tcp->auto_deq())
{
- unsigned sleep_cnt = 0U;
while(_tcrp->num_deq() < _tcp->num_msgs() && !_tcrp->exception())
{
- if (_dtok_deq_list.empty())
+ journal::data_tok* dtokp = 0;
{
- if (sleep_cnt++ > MAX_SLEEP_CNT)
+ rhm::journal::slock sl(&_deq_list_mutex);
+ if (_dtok_deq_list.empty())
+ _deq_list_cv.wait();
+ if (!_dtok_deq_list.empty())
{
- std::ostringstream oss;
- oss << "ERROR: Timeout waiting for AIO in journal \"" << _jid;
- oss << "\": num_enq=" << _tcp->num_msgs();
- oss << " num_deq=" << _tcrp->num_deq();
- _tcrp->add_exception(oss.str());
- }
- if (get_wr_events() == 0)
- ::usleep(SLEEP_US); // 1ms
- }
- else
- {
- journal::data_tok* dtokp;
- {
- rhm::journal::slock sl(&_deq_mutex);
dtokp = _dtok_deq_list.front();
_dtok_deq_list.pop_front();
}
-
+ }
+ if (dtokp)
+ {
rhm::journal::iores res;
if (dtokp->has_xid())
res = dequeue_txn_data_record(dtokp, dtokp->xid());
@@ -357,10 +345,9 @@
oss << "\" returned " << rhm::journal::iores_str(res) << ".";
_tcrp->add_exception(oss.str());
}
- sleep_cnt = 0U;
}
}
- flush();
+ flush(true);
}
}
catch (const rhm::journal::jexception& e) { _tcrp->add_exception(e); }
@@ -409,11 +396,17 @@
// static AIO callback fns
void
+jrnl_instance::aio_rd_callback(jcntl* journal, std::vector<u_int16_t>& /*pil*/)
+{
+ jrnl_instance::handle_rd_callback(journal);
+}
+
+void
jrnl_instance::aio_wr_callback(jcntl* journal, std::vector<journal::data_tok*>& dtokl)
{
for (std::vector<journal::data_tok*>::const_iterator i=dtokl.begin(); i!=dtokl.end(); i++)
- if ((*i)->wstate() == journal::data_tok::ENQ)
- jrnl_instance::push_dtokp(journal, *i);
+ if ((*i)->wstate() == journal::data_tok::ENQ || (*i)->wstate() == journal::data_tok::DEQ)
+ jrnl_instance::handle_wr_callback(journal, *i);
}
} // namespace jtt
Modified: store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -29,14 +29,13 @@
#include "test_case.hpp"
#include <boost/shared_ptr.hpp>
-#include <deque>
+#include <jrnl/cvar.hpp>
#include <jrnl/data_tok.hpp>
#include <jrnl/jcntl.hpp>
#include <jrnl/slock.hpp>
+#include <list>
#include <vector>
-#include <iostream> // debug
-
namespace rhm
{
namespace jtt
@@ -53,10 +52,16 @@
const args* _args_ptr;
std::vector<dtok_ptr> _dtok_master_enq_list;
std::vector<dtok_ptr> _dtok_master_txn_list;
- std::deque<journal::data_tok*> _dtok_rd_list;
- std::deque<journal::data_tok*> _dtok_deq_list;
- pthread_mutex_t _rd_mutex; ///< Mutex for _dtok_rd_list
- pthread_mutex_t _deq_mutex; ///< Mutex for _dtok_deq_list
+ std::list<journal::data_tok*> _dtok_rd_list;
+ std::list<journal::data_tok*> _dtok_deq_list;
+ pthread_mutex_t _rd_aio_mutex; ///< Mutex for read aio wait conditions
+ rhm::journal::cvar _rd_aio_cv; ///< Condition var for read aio wait conditions
+ pthread_mutex_t _wr_full_mutex; ///< Mutex for write full conditions
+ rhm::journal::cvar _wr_full_cv; ///< Condition var for write full conditions
+ pthread_mutex_t _rd_list_mutex; ///< Mutex for _dtok_rd_list
+ rhm::journal::cvar _rd_list_cv; ///< Condition var for _dtok_rd_list
+ pthread_mutex_t _deq_list_mutex; ///< Mutex for _dtok_deq_list
+ rhm::journal::cvar _deq_list_cv; ///< Condition var for _dtok_deq_list
pthread_t _enq_thread;
pthread_t _deq_thread;
pthread_t _read_thread;
@@ -79,16 +84,40 @@
void tc_wait_compl() throw ();
private:
- inline void push_dtokp(rhm::journal::data_tok* dtokp)
+ inline void handle_rd_callback()
{
- if (_args_ptr->read_mode.val() == read_arg::NONE)
- { rhm::journal::slock sl(&_deq_mutex); _dtok_deq_list.push_back(dtokp); }
- else
- { rhm::journal::slock sl(&_rd_mutex); _dtok_rd_list.push_back(dtokp); }
+ rhm::journal::slock sl(&_rd_aio_mutex);
+ _rd_aio_cv.broadcast();
}
- static inline void push_dtokp(jcntl* jp, rhm::journal::data_tok* dtokp)
- { static_cast<jrnl_instance*>(jp)->push_dtokp(dtokp); }
+ static inline void handle_rd_callback(jcntl* jp)
+ { static_cast<jrnl_instance*>(jp)->handle_rd_callback(); }
+ inline void handle_wr_callback(rhm::journal::data_tok* dtokp)
+ {
+ if (dtokp->wstate() == journal::data_tok::ENQ)
+ {
+ if (_args_ptr->read_mode.val() == read_arg::NONE)
+ {
+ rhm::journal::slock sl(&_deq_list_mutex);
+ _dtok_deq_list.push_back(dtokp);
+ _deq_list_cv.broadcast();
+ }
+ else
+ {
+ rhm::journal::slock sl(&_rd_list_mutex);
+ _dtok_rd_list.push_back(dtokp);
+ _rd_list_cv.broadcast();
+ }
+ }
+ else // DEQ
+ {
+ rhm::journal::slock sl(&_wr_full_mutex);
+ _wr_full_cv.broadcast();
+ }
+ }
+ static inline void handle_wr_callback(jcntl* jp, rhm::journal::data_tok* dtokp)
+ { static_cast<jrnl_instance*>(jp)->handle_wr_callback(dtokp); }
+
void run_enq() throw ();
inline static void* run_enq(void* p)
{ static_cast<jrnl_instance*>(p)->run_enq(); return 0; }
@@ -107,6 +136,7 @@
rhm::journal::data_tok* prep_txn_dtok(const rhm::journal::data_tok* dtokp);
// static callbacks
+ static void aio_rd_callback(jcntl* journal, std::vector<u_int16_t>& pil);
static void aio_wr_callback(jcntl* journal, std::vector<journal::data_tok*>& dtokl);
};
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result.cpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -37,16 +37,12 @@
_num_deq(0),
_num_read(0),
_num_rproc(0),
+ _start_time(),
+ _stop_time(),
_stopped(false),
+ _test_time(),
_exception_list()
-{
- _start_time.tv_sec = 0;
- _start_time.tv_nsec = 0;
- _stop_time.tv_sec = 0;
- _stop_time.tv_nsec = 0;
- _test_time.tv_sec = 0;
- _test_time.tv_nsec = 0;
-}
+{}
test_case_result::~test_case_result()
{}
@@ -54,12 +50,7 @@
const std::string
test_case_result::test_time_str() const
{
- if (_test_time.tv_nsec == 0)
- return "0.0";
- std::ostringstream oss;
- oss << _test_time.tv_sec << ".";
- oss << std::setfill('0') << std::setw(9) << _test_time.tv_nsec;
- return oss.str();
+ return _test_time.str(9);
}
void
@@ -101,12 +92,9 @@
_num_enq = 0;
_num_deq = 0;
_num_read = 0;
- _start_time.tv_sec = 0;
- _start_time.tv_nsec = 0;
- _stop_time.tv_sec = 0;
- _stop_time.tv_nsec = 0;
- _test_time.tv_sec = 0;
- _test_time.tv_nsec = 0;
+ _start_time.set_zero();
+ _stop_time.set_zero();
+ _test_time.set_zero();
_exception_list.clear();
}
@@ -207,16 +195,8 @@
void
test_case_result::calc_test_time()
{
- if (_start_time.tv_sec > 0 && _stop_time.tv_sec >= _start_time.tv_sec)
- {
- _test_time.tv_sec = _stop_time.tv_sec - _start_time.tv_sec;
- _test_time.tv_nsec = _stop_time.tv_nsec - _start_time.tv_nsec;
- if (_test_time.tv_nsec < 0)
- {
- _test_time.tv_nsec += 1000000000;
- _test_time.tv_sec--;
- }
- }
+ if (!_start_time.is_zero() && _stop_time >= _start_time)
+ _test_time = _stop_time - _start_time;
}
} // namespace jtt
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result.hpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -27,6 +27,7 @@
#include <boost/shared_ptr.hpp>
#include <deque>
#include <jrnl/jexception.hpp>
+#include <jrnl/time_ns.hpp>
#include <string>
namespace rhm
@@ -48,10 +49,10 @@
u_int32_t _num_deq;
u_int32_t _num_read; // Messages actually read
u_int32_t _num_rproc; // Messages handled by read thread (not all are read)
- timespec _start_time;
- timespec _stop_time;
+ journal::time_ns _start_time;
+ journal::time_ns _stop_time;
bool _stopped;
- timespec _test_time;
+ journal::time_ns _test_time;
elist _exception_list;
public:
@@ -68,14 +69,13 @@
inline const u_int32_t num_rproc() const { return _num_rproc; }
inline const u_int32_t incr_num_rproc() { return ++_num_rproc; }
- inline const timespec& start_time() const { return _start_time; }
+ inline const journal::time_ns& start_time() const { return _start_time; }
inline void set_start_time() { ::clock_gettime(CLOCK_REALTIME, &_start_time); }
- inline const timespec& stop_time() const { return _stop_time; }
+ inline const journal::time_ns& stop_time() const { return _stop_time; }
inline void set_stop_time()
{ ::clock_gettime(CLOCK_REALTIME, &_stop_time); calc_test_time(); }
- inline void set_test_time(const timespec& ts)
- { _test_time.tv_sec = ts.tv_sec; _test_time.tv_nsec = ts.tv_nsec; }
- inline const timespec& test_time() const { return _test_time; }
+ inline void set_test_time(const journal::time_ns& ts) { _test_time = ts; }
+ inline const journal::time_ns& test_time() const { return _test_time; }
const std::string test_time_str() const;
void add_exception(const journal::jexception& e, const bool set_stop_time_flag = true);
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -158,16 +158,10 @@
return oss.str();
}
-const timespec&
-test_case_result_agregation::add_test_time(const timespec& t)
+const journal::time_ns&
+test_case_result_agregation::add_test_time(const journal::time_ns& t)
{
- _test_time.tv_sec += t.tv_sec;
- _test_time.tv_nsec += t.tv_nsec;
- if (_test_time.tv_nsec > 999999999)
- {
- _test_time.tv_nsec -= 1000000000;
- _test_time.tv_sec++;
- }
+ _test_time += t;
return _test_time;
}
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp 2008-02-06 14:58:42 UTC (rev 1644)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp 2008-02-06 15:39:52 UTC (rev 1645)
@@ -71,7 +71,7 @@
private:
const std::string str_full(const bool last_only) const;
const std::string str_summary(const bool last_only) const;
- const timespec& add_test_time(const timespec& t);
+ const journal::time_ns& add_test_time(const journal::time_ns& t);
};
} // namespace jtt
16 years, 11 months
rhmessaging commits: r1644 - store/trunk/cpp/tests.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2008-02-06 09:58:42 -0500 (Wed, 06 Feb 2008)
New Revision: 1644
Modified:
store/trunk/cpp/tests/system_test.sh
Log:
Disabled management when running broker during Python tests - something in management causes a crash on broker exit at end of BDB phase 5.
Modified: store/trunk/cpp/tests/system_test.sh
===================================================================
--- store/trunk/cpp/tests/system_test.sh 2008-02-05 23:00:19 UTC (rev 1643)
+++ store/trunk/cpp/tests/system_test.sh 2008-02-06 14:58:42 UTC (rev 1644)
@@ -75,7 +75,7 @@
for p in `seq 1 6`; do
log="$abs_srcdir/vg-log.$mode.$p"
#echo "$vg $QPIDD --load-module $LIBBDBSTORE $JRNLFLAGS"
- $vg $QPIDD --load-module $LIBBDBSTORE $JRNLFLAGS >> "$abs_srcdir/qpid.log" 2> $log & pid=$!
+ $vg $QPIDD -m 0 --load-module $LIBBDBSTORE $JRNLFLAGS >> "$abs_srcdir/qpid.log" 2> $log & pid=$!
sleep 5
echo phase $p...
@@ -83,7 +83,7 @@
python "$abs_srcdir/persistence.py" -s "$xml_spec" -p $p -r 3 || fail=1
sleep 1
kill -SIGINT $pid || { echo process already died; cat qpid.log ; fail=1; }
- wait $pid || fail=1
+ wait $pid || { echo "$vg $QPIDD returned with exit code $?."; fail=1; }
vg_check $log || fail=1
done
16 years, 11 months
rhmessaging commits: r1643 - in mgmt/cumin/python: wooly and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-05 18:00:19 -0500 (Tue, 05 Feb 2008)
New Revision: 1643
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/broker.strings
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/brokergroup.strings
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/client.strings
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/exchange.strings
mgmt/cumin/python/cumin/page.strings
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/python/cumin/system.py
mgmt/cumin/python/cumin/system.strings
mgmt/cumin/python/cumin/widgets.py
mgmt/cumin/python/wooly/tables.py
Log:
Fixes the problem where null values or sorted into places we didn't
want them.
Revamps sqltable to use a sql string from the module strings file,
rather than more complex thing I was doing before.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/broker.py 2008-02-05 23:00:19 UTC (rev 1643)
@@ -20,11 +20,6 @@
def __init__(self, app, name):
super(BrokerSet, self).__init__(app, name)
- self.table_sql = "broker_registration as b"
-
- self.add_sql_column("id", "b.id")
- self.add_sql_column("name", "b.name")
-
self.ids = CheckboxIdColumn(app, "id")
self.add_column(self.ids)
self.add_form_parameter(self.ids)
@@ -484,7 +479,7 @@
return "Brokers %s" % fmt_count(BrokerRegistration.select().count())
class BrowserBrokers(BrokerSet):
- def get_where_sql(self, session):
+ def render_sql_where(self, session, object):
elems = list()
group = self.parent.group.get(session)
#profile = self.parent.profile.get(session)
@@ -494,16 +489,13 @@
subquery = \
"select 1 from broker_group_mapping " + \
"where broker_group_id = %i " % group.id + \
- "and broker_registration_id = b.id"
+ "and broker_registration_id = br.id"
elems.append("exists (%s)" % subquery)
if elems:
return "where %s" % " and ".join(elems)
- def render_none(self, session, model):
- return fmt_none()
-
def render_add_broker_href(self, session, model):
branch = session.branch()
self.frame().show_broker_add(branch)
Modified: mgmt/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/cumin/python/cumin/broker.strings 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/broker.strings 2008-02-05 23:00:19 UTC (rev 1643)
@@ -1,3 +1,15 @@
+[BrokerSet.sql]
+select br.id, br.name
+from broker_registration as br
+{sql_where}
+{sql_orderby}
+{sql_limit}
+
+[BrokerSet.count_sql]
+select count(*)
+from broker_registration as br
+{sql_where}
+
[BrokerSet.html]
<form id="{id}" method="post" action="?">
<!-- <select onchange="document.getElementById('{id}.submit').submit()"> -->
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/brokergroup.py 2008-02-05 23:00:19 UTC (rev 1643)
@@ -10,7 +10,16 @@
strings = StringCatalog(__file__)
-class BrokerGroupSet(SQLObjectItemSet):
+class BrokerGroupSet(CuminTable):
+ def __init__(self, app, name):
+ super(BrokerGroupSet, self).__init__(app, name)
+
+ col = self.NameColumn(app, "name")
+ self.add_column(col)
+
+ #col = self.StatusColumn(app, "status")
+ #self.add_column(col)
+
def get_title(self, session, model):
return "Broker Groups %s" % fmt_count(BrokerGroup.select().count())
@@ -19,28 +28,16 @@
self.frame().show_broker_group_add(branch)
return branch.marshal()
- def do_get_items(self, session, model):
- return BrokerGroup.select()
+ class NameColumn(SqlTableColumn):
+ def get_title(self, session, model):
+ return "Name"
- def render_item_link(self, session, group):
- branch = session.branch()
- self.frame().show_broker_group(branch, group).show_view(branch)
- return fmt_olink(branch, group)
+ def render_content(self, session, data):
+ group = Identifiable(data["id"])
+ branch = session.branch()
+ self.app.model.broker_group.show(branch, group).show_view(branch)
+ return fmt_olink(branch, group, name=data["name"])
- def render_item_config(self, session, group):
- return group.brokers.count()
-
- def render_item_status(self, session, group):
- writer = Writer()
-
- for broker in group.brokers:
- writer.write(fmt_ostatus(broker))
-
- return writer.to_string()
-
- def render_none(self, session, group):
- return fmt_none()
-
class BrokerGroupFrame(CuminFrame):
def __init__(self, app, name):
super(BrokerGroupFrame, self).__init__(app, name)
@@ -90,19 +87,14 @@
return "Brokers %s" % \
fmt_count(self.get_item_count(session, group))
- def get_where_sql(self, session):
- # XXX ugh, get rid of None arg
- group = self.frame().get_object(session, None)
+ def render_sql_where(self, session, group):
subquery = \
"select 1 from broker_group_mapping " + \
"where broker_group_id = %i " % group.id + \
- "and broker_registration_id = b.id"
+ "and broker_registration_id = br.id"
return "where exists (%s)" % subquery
- def render_none(self, session, model):
- return fmt_none()
-
class BrokerGroupForm(CuminForm):
def __init__(self, app, name):
super(BrokerGroupForm, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/brokergroup.strings
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.strings 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/brokergroup.strings 2008-02-05 23:00:19 UTC (rev 1643)
@@ -1,3 +1,12 @@
+[BrokerGroupSet.sql]
+select bg.id, bg.name
+from broker_group as bg
+{sql_orderby}
+{sql_limit}
+
+[BrokerGroupSet.count_sql]
+select count(*) from broker_group
+
[BrokerGroupSet.html]
<ul class="actions">
<li><a class="nav" href="{group_add_href}">Add Broker Group</a></li>
@@ -4,22 +13,18 @@
</ul>
<table class="mobjects">
- <tr>
- <th>Name</th>
- <th>Brokers</th>
- <th>Status</th>
- </tr>
-
- {items}
+ <thead>
+ <tr>
+ <th class="setnav" colspan="0">
+ <div class="rfloat">{page}</div>
+ {count}
+ </th>
+ </tr>
+ <tr>{headers}</tr>
+ </thead>
+ <tbody>{items}</tbody>
</table>
-[BrokerGroupSet.item_html]
-<tr>
- <td>{item_link}</td>
- <td>{item_config}</td>
- <td>{item_status}</td>
-</tr>
-
[BrokerGroupView.html]
{status}
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/client.py 2008-02-05 23:00:19 UTC (rev 1643)
@@ -15,26 +15,6 @@
def __init__(self, app, name):
super(ClientSet, self).__init__(app, name)
- self.table_sql = "client as l"
-
- self.add_sql_join("client_stats as c", "c.id", "l.stats_curr_id")
- self.add_sql_join("client_stats as p", "p.id", "l.stats_prev_id")
-
- self.add_sql_column("id", "l.id")
- self.add_sql_column("addr", "l.address")
- self.add_sql_column("bs",
- "(c.bytes_from_client - p.bytes_from_client)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("fs",
- "(c.frames_from_client - p.frames_from_client)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("br",
- "(c.bytes_to_client - p.bytes_to_client)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("fr",
- "(c.frames_to_client - p.frames_to_client)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
-
self.ids = CheckboxIdColumn(app, "id")
self.add_column(self.ids)
@@ -71,20 +51,10 @@
def get_unit_plural(self, session):
return self.unit.get(session) == "b" and "Bytes" or "Frames"
- def get_where_sql(self, session):
+ def render_sql_where(self, session, vhost):
elems = list()
elems.append("l.vhost_id = %(id)r")
-
- phase = self.__phase.get(session)
-
- if phase == "a":
- elems.append("c.rec_time > now() - interval '10 minutes'")
- elif phase == "i":
- elems.append("(c.rec_time <= now() - interval '10 minutes'" +
- " and l.deletion_time is null)")
- else:
- elems.append("l.deletion_time is not null")
-
+ elems.append(self.__phase.get_sql_constraint(session, vhost))
return "where %s" % " and ".join(elems)
def get_sql_values(self, session, vhost):
@@ -126,7 +96,7 @@
#return fmt_link(branch.marshal(), client.sessions.count())
return "XXX"
- class SentColumn(SqlTableColumn):
+ class SentColumn(NullSortColumn):
def get_title(self, session, vhost):
return "%s Sent" % self.parent.get_unit_plural(session)
@@ -137,7 +107,7 @@
def render_value(self, session, value):
return fmt_rate(value, "", "sec")
- class ReceivedColumn(SqlTableColumn):
+ class ReceivedColumn(NullSortColumn):
def get_title(self, session, vhost):
return "%s Received" % self.parent.get_unit_plural(session)
@@ -359,16 +329,6 @@
def __init__(self, app, name):
super(ClientSessionSet, self).__init__(app, name)
- self.table_sql = "session as s"
-
- self.add_sql_join("session_stats as c", "c.id", "s.stats_curr_id")
- self.add_sql_join("session_stats as p", "p.id", "s.stats_curr_id")
-
- self.add_sql_column("id", "s.id")
- self.add_sql_column("name", "s.name")
- self.add_sql_column("expires", "c.expire_time")
- self.add_sql_column("status", "c.attached")
-
self.ids = CheckboxIdColumn(app, "id")
self.add_column(self.ids)
@@ -395,20 +355,10 @@
def get_title(self, session, client):
return "Sessions %s" % fmt_count(client.sessions.count())
- def get_where_sql(self, session):
+ def render_sql_where(self, session, client):
elems = list()
elems.append("s.client_id = %(id)r")
-
- phase = self.__phase.get(session)
-
- if phase == "a":
- elems.append("c.rec_time > now() - interval '10 minutes'")
- elif phase == "i":
- elems.append("(c.rec_time <= now() - interval '10 minutes'" +
- " and s.deletion_time is null)")
- else:
- elems.append("s.deletion_time is not null")
-
+ elems.append(self.__phase.get_sql_constraint(session, client))
return "where %s" % " and ".join(elems)
def get_sql_values(self, session, client):
Modified: mgmt/cumin/python/cumin/client.strings
===================================================================
--- mgmt/cumin/python/cumin/client.strings 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/client.strings 2008-02-05 23:00:19 UTC (rev 1643)
@@ -1,3 +1,32 @@
+[ClientSet.sql]
+select
+ l.id,
+ l.address as addr,
+ (c.bytes_from_client - p.bytes_from_client)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as bs,
+ case when p.bytes_from_client is null then true else false end as bs_is_null,
+ (c.frames_from_client - p.frames_from_client)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as fs,
+ case when p.frames_from_client is null then true else false end as fs_is_null,
+ (c.bytes_to_client - p.bytes_to_client)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as br,
+ case when p.bytes_to_client is null then true else false end as br_is_null,
+ (c.frames_to_client - p.frames_to_client)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as fr,
+ case when p.frames_to_client is null then true else false end as fr_is_null
+from client as l
+left outer join client_stats as c on c.id = l.stats_curr_id
+left outer join client_stats as p on p.id = l.stats_prev_id
+{sql_where}
+{sql_orderby}
+{sql_limit}
+
+[ClientSet.count_sql]
+select count(*)
+from client as l
+left outer join client_stats as c on c.id = l.stats_curr_id
+{sql_where}
+
[ClientSet.html]
<form id="{id}" method="post" action="?">
<div class="rfloat">{phase}</div>
@@ -128,6 +157,21 @@
<h2>Bytes Received</h2>
<div class="iblock chart">{received}</div>
+[ClientSessionSet.sql]
+select s.id, s.name, c.expire_time as expires, c.attached as status
+from session as s
+left outer join session_stats as c on c.id = s.stats_curr_id
+left outer join session_stats as p on p.id = s.stats_prev_id
+{sql_where}
+{sql_orderby}
+{sql_limit}
+
+[ClientSessionSet.count_sql]
+select count(*)
+from session as s
+left outer join session_stats as c on c.id = s.stats_curr_id
+{sql_where}
+
[ClientSessionSet.html]
<form id="{id}" method="post" action="?">
<div class="rfloat">{phase}</div>
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/exchange.py 2008-02-05 23:00:19 UTC (rev 1643)
@@ -36,30 +36,6 @@
def __init__(self, app, name):
super(ExchangeSet, self).__init__(app, name)
- self.table_sql = "exchange as e"
-
- self.add_sql_join("exchange_stats as c", "c.id", "e.stats_curr_id")
- self.add_sql_join("exchange_stats as p", "p.id", "e.stats_prev_id")
-
- self.add_sql_column("id", "e.id")
- self.add_sql_column("name", "e.name")
- self.add_sql_column("producers", "c.producers")
- self.add_sql_column("bindings", "c.bindings")
- self.add_sql_column("mreceived",
- "(c.msg_receives - p.msg_receives)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("breceived",
- "(c.byte_receives - p.byte_receives)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("mrouted",
- "(c.msg_routes - p.msg_routes)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("brouted",
- "(c.byte_routes - p.byte_routes)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("mdropped", "c.msg_drops");
- self.add_sql_column("bdropped", "c.byte_drops");
-
col = self.NameColumn(app, "name")
self.add_column(col)
@@ -92,20 +68,10 @@
def get_title(self, session, vhost):
return "Exchanges %s" % fmt_count(vhost.exchanges.count())
- def get_where_sql(self, session):
+ def render_sql_where(self, session, vhost):
elems = list()
elems.append("e.vhost_id = %(id)r")
-
- phase = self.phase.get(session)
-
- if phase == "a":
- elems.append("c.rec_time > now() - interval '10 minutes'")
- elif phase == "i":
- elems.append("(c.rec_time <= now() - interval '10 minutes'" +
- " and e.deletion_time is null)")
- else:
- elems.append("e.deletion_time is not null")
-
+ elems.append(self.phase.get_sql_constraint(session, vhost))
return "where %s" % " and ".join(elems)
def get_sql_values(self, session, vhost):
@@ -147,7 +113,7 @@
frame.show_view(branch).show_bindings(branch)
return fmt_link(branch.marshal(), data["bindings"])
- class ReceivedColumn(SqlTableColumn):
+ class ReceivedColumn(NullSortColumn):
def get_title(self, session, object):
return "%s Received" % self.parent.unit.get_brief_plural(session)
@@ -158,7 +124,7 @@
def render_value(self, session, value):
return fmt_rate(value, "", "sec")
- class RoutedColumn(SqlTableColumn):
+ class RoutedColumn(NullSortColumn):
def get_title(self, session, object):
return "%s Routed" % self.parent.unit.get_brief_plural(session)
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/exchange.strings 2008-02-05 23:00:19 UTC (rev 1643)
@@ -4,6 +4,39 @@
{item_content}
</div>
+[ExchangeSet.sql]
+select
+ e.id,
+ e.name,
+ c.producers,
+ c.bindings,
+ (c.msg_receives - p.msg_receives)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as mreceived,
+ case when p.msg_receives is null then true else false end as mreceived_is_null,
+ (c.byte_receives - p.byte_receives)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as breceived,
+ case when p.byte_receives is null then true else false end as breceived_is_null,
+ (c.msg_routes - p.msg_routes)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as mrouted,
+ case when p.msg_routes is null then true else false end as mrouted_is_null,
+ (c.byte_routes - p.byte_routes)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as brouted,
+ case when p.byte_routes is null then true else false end as brouted_is_null,
+ c.msg_drops as mdropped,
+ c.byte_drops as bdropped
+from exchange as e
+left outer join exchange_stats as c on c.id = e.stats_curr_id
+left outer join exchange_stats as p on p.id = e.stats_prev_id
+{sql_where}
+{sql_orderby}
+{sql_limit}
+
+[ExchangeSet.count_sql]
+select count(*)
+from exchange as e
+left outer join exchange_stats as c on c.id = e.stats_curr_id
+{sql_where}
+
[ExchangeSet.css]
ul.ExchangeSet li:before {
content: url(resource?name=exchange-20.png);
Modified: mgmt/cumin/python/cumin/page.strings
===================================================================
--- mgmt/cumin/python/cumin/page.strings 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/page.strings 2008-02-05 23:00:19 UTC (rev 1643)
@@ -562,7 +562,7 @@
#head {
padding: 0;
background-color: #666;
- border-bottom: 2px solid #999;
+ border-bottom: 1px solid #999;
border-top: 3px solid #000;
color: #ddd;
}
@@ -659,6 +659,13 @@
content: "";
}
+#trans {
+ padding: 0;
+ marging: 0;
+ border-top: 1px solid #bbb;
+ border-bottom: 1px solid #ddd;
+}
+
[MainFrame.javascript]
function updateActions(id, model) {
var pcount = model.invocations.pending;
@@ -718,6 +725,7 @@
</div>
<!-- <a id="logo" href="{href}"><img src="resource?name=rhm-32x14.png"/></a> -->
</div>
+<div id="trans"></div>
<div id="body">{mode}</div>
<div id="foot"/>
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/queue.py 2008-02-05 23:00:19 UTC (rev 1643)
@@ -20,32 +20,6 @@
def __init__(self, app, name):
super(QueueSet, self).__init__(app, name)
- self.table_sql = "queue as q"
-
- self.add_sql_join("queue_stats as c", "c.id", "q.stats_curr_id")
- self.add_sql_join("queue_stats as p", "p.id", "q.stats_prev_id")
-
- self.add_sql_column("id", "q.id")
- self.add_sql_column("name", "q.name")
- self.add_sql_column("consumers", "c.consumers")
- self.add_sql_column("bindings", "c.bindings")
- self.add_sql_column("menqueued",
- "(c.msg_total_enqueues - p.msg_total_enqueues)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("benqueued",
- "(c.byte_total_enqueues - p.byte_total_enqueues)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("mdequeued",
- "(c.msg_total_dequeues - p.msg_total_dequeues)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("bdequeued",
- "(c.byte_total_dequeues - p.byte_total_dequeues)" +
- " / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001)");
- self.add_sql_column("mdepth", "c.msg_depth")
- self.add_sql_column("bdepth", "c.byte_depth")
- self.add_sql_column("mdepthaccel", "1")
- self.add_sql_column("bdepthaccel", "1")
-
self.ids = CheckboxIdColumn(app, "id")
self.add_column(self.ids)
@@ -86,20 +60,10 @@
def get_title(self, session, vhost):
return "Queues %s" % fmt_count(vhost.queues.count())
- def get_where_sql(self, session):
+ def render_sql_where(self, session, vhost):
elems = list()
elems.append("q.vhost_id = %(id)r")
-
- phase = self.phase.get(session)
-
- if phase == "a":
- elems.append("c.rec_time > now() - interval '10 minutes'")
- elif phase == "i":
- elems.append("(c.rec_time <= now() - interval '10 minutes'" +
- " and q.deletion_time is null)")
- else:
- elems.append("q.deletion_time is not null")
-
+ elems.append(self.phase.get_sql_constraint(session, vhost))
return "where %s" % " and ".join(elems)
def get_sql_values(self, session, vhost):
@@ -153,7 +117,7 @@
frame.show_view(branch).show_bindings(branch)
return fmt_link(branch.marshal(), data["bindings"])
- class EnqueuedColumn(SqlTableColumn):
+ class EnqueuedColumn(NullSortColumn):
def get_title(self, session, object):
return "%s Enqueued" % self.parent.unit.get_brief_plural(session)
@@ -164,7 +128,7 @@
def render_value(self, session, value):
return fmt_rate(value, "", "sec")
- class DequeuedColumn(SqlTableColumn):
+ class DequeuedColumn(NullSortColumn):
def get_title(self, session, object):
return "%s Dequeued" % self.parent.unit.get_brief_plural(session)
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/queue.strings 2008-02-05 23:00:19 UTC (rev 1643)
@@ -1,3 +1,38 @@
+[QueueSet.sql]
+select
+ q.id,
+ q.name,
+ c.consumers,
+ c.bindings,
+ (c.msg_total_enqueues - p.msg_total_enqueues)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as menqueued,
+ case when p.msg_total_enqueues is null then true else false end as menqueued_is_null,
+ (c.byte_total_enqueues - p.byte_total_enqueues)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as benqueued,
+ case when p.byte_total_enqueues is null then true else false end as benqueued_is_null,
+ (c.msg_total_dequeues - p.msg_total_dequeues)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as mdequeued,
+ case when p.msg_total_dequeues is null then true else false end as mdequeued_is_null,
+ (c.byte_total_dequeues - p.byte_total_dequeues)
+ / (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as bdequeued,
+ case when p.byte_total_dequeues is null then true else false end as bdequeued_is_null,
+ c.msg_depth as mdepth,
+ c.byte_depth as bdepth,
+ 1 as mdepthaccel,
+ 1 as bdepthaccel
+from queue as q
+left outer join queue_stats as c on c.id = q.stats_curr_id
+left outer join queue_stats as p on p.id = q.stats_prev_id
+{sql_where}
+{sql_orderby}
+{sql_limit}
+
+[QueueSet.count_sql]
+select count(*)
+from queue as q
+left outer join queue_stats as c on c.id = q.stats_curr_id
+{sql_where}
+
[QueueSet.html]
<form id="{id}" method="post" action="?">
<div class="rfloat">{phase}</div>
Modified: mgmt/cumin/python/cumin/system.py
===================================================================
--- mgmt/cumin/python/cumin/system.py 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/system.py 2008-02-05 23:00:19 UTC (rev 1643)
@@ -13,11 +13,6 @@
def __init__(self, app, name):
super(SystemSet, self).__init__(app, name)
- self.table_sql = "system as s"
-
- self.add_sql_column("id", "s.id")
- self.add_sql_column("name", "s.sys_id")
-
self.ids = CheckboxIdColumn(app, "id")
self.add_column(self.ids)
self.add_form_parameter(self.ids)
Modified: mgmt/cumin/python/cumin/system.strings
===================================================================
--- mgmt/cumin/python/cumin/system.strings 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/system.strings 2008-02-05 23:00:19 UTC (rev 1643)
@@ -1,3 +1,12 @@
+[SystemSet.sql]
+select s.id, s.sys_id as name
+from system as s
+{sql_orderby}
+{sql_limit}
+
+[SystemSet.count_sql]
+select count(*) from system
+
[SystemSet.html]
<form id="{id}" method="post" action="?">
<table class="mobjects">
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/cumin/widgets.py 2008-02-05 23:00:19 UTC (rev 1643)
@@ -254,6 +254,19 @@
self.add_state("i", "Idle")
self.add_state("d", "Deleted")
+ def get_sql_constraint(self, session, object):
+ phase = self.get(session)
+
+ if phase == "a":
+ sql = "c.rec_time > now() - interval '10 minutes'"
+ elif phase == "i":
+ sql = "(c.rec_time <= now() - interval '10 minutes'" + \
+ " and deletion_time is null)"
+ else:
+ sql = "deletion_time is not null"
+
+ return sql
+
class Paginator(ItemSet):
def __init__(self, app, name):
super(Paginator, self).__init__(app, name)
@@ -387,10 +400,18 @@
self.paginator.set_count(session, self.get_item_count(session, object))
- def get_limit_sql(self, session):
+ def render_sql_limit(self, session, object):
start, end = self.paginator.get_bounds(session)
return "limit %i offset %i" % (end - start, start)
+class NullSortColumn(SqlTableColumn):
+ def get_orderby_sql(self, session):
+ key = self.get_column_key(session)
+
+ if key:
+ dir = self.parent.is_reversed(session) and "desc" or "asc"
+ return "order by %s_is_null asc, %s %s" % (key, key, dir)
+
class PaginatedItemSet(ItemSet):
def __init__(self, app, name):
super(PaginatedItemSet, self).__init__(app, name)
Modified: mgmt/cumin/python/wooly/tables.py
===================================================================
--- mgmt/cumin/python/wooly/tables.py 2008-02-05 00:10:22 UTC (rev 1642)
+++ mgmt/cumin/python/wooly/tables.py 2008-02-05 23:00:19 UTC (rev 1643)
@@ -118,78 +118,40 @@
def __init__(self, app, name):
super(SqlTable, self).__init__(app, name)
- self.table_sql = None
- self.where_sql = None
- self.sql_joins = list()
- self.sql_columns = list()
+ self.__sql_tmpl = Template(self, "sql")
+ self.__count_sql_tmpl = Template(self, "count_sql")
- def add_sql_join(self, table_sql, column_sql, fk_column_sql):
- join = self.SqlJoin(self, table_sql, column_sql, fk_column_sql)
- self.sql_joins.append(join)
+ def render_sql(self, session, object):
+ writer = Writer()
+ self.__sql_tmpl.render(session, object, writer)
+ sql = writer.to_string()
- def add_sql_column(self, name, sql):
- col = self.SqlColumn(self, name, sql)
- self.sql_columns.append(col)
+ #print "sql -----------------------"
+ #print sql
- def get_sql_column(self, name):
- for col in self.sql_columns:
- if col.name == name:
- return col
-
- def get_select_sql(self, session):
- if not self.sql_columns:
- raise Exception()
-
- cols = ", ".join([col.get_sql(session) for col in self.sql_columns])
- sql = "select %s" % cols
-
return sql
- def get_from_sql(self, session):
- if not self.table_sql:
- raise Exception()
+ def render_sql_where(self, session, object):
+ pass
- elems = list()
-
- elems.append("from %s" % self.table_sql)
-
- for join in self.sql_joins:
- elems.append(join.get_sql(session))
-
- return "\n".join(elems)
-
- def get_where_sql(self, session):
- return self.where_sql
-
- def get_orderby_sql(self, session):
+ def render_sql_orderby(self, session, object):
scol = self.get_selected_column(session)
return scol.get_orderby_sql(session)
- def get_limit_sql(self, session):
+ def render_sql_limit(self, session, object):
return None
- def get_sql(self, session):
- elems = (self.get_select_sql(session),
- self.get_from_sql(session),
- self.get_where_sql(session),
- self.get_orderby_sql(session),
- self.get_limit_sql(session))
+ def render_count_sql(self, session, object):
+ writer = Writer()
+ self.__count_sql_tmpl.render(session, object, writer)
+ sql = writer.to_string()
- sql = self.build_sql(elems)
-
#print "sql -----------------------"
#print sql
return sql
- def get_count_sql(self, session):
- elems = ("select count(*)",
- self.get_from_sql(session),
- self.get_where_sql(session))
-
- return self.build_sql(elems)
-
def build_sql(self, elems):
writer = Writer()
@@ -211,7 +173,7 @@
if conn:
cursor = conn.cursor()
- sql = self.get_count_sql(session)
+ sql = self.render_count_sql(session, object)
sql_values = self.get_sql_values(session, object)
cursor.execute(sql, sql_values)
@@ -224,7 +186,7 @@
if conn:
cursor = conn.cursor()
- sql = self.get_sql(session)
+ sql = self.render_sql(session, object)
sql_values = self.get_sql_values(session, object)
#print "SQL TEXT", sql
@@ -234,57 +196,29 @@
return cursor
- def render_cells(self, session, data):
- data_map = dict()
+ def render_items(self, session, object):
+ cursor = self.get_items(session, object)
+ cols = [spec[0] for spec in cursor.description]
+ data = dict()
- for col, datum in zip(self.sql_columns, data):
- data_map[col.name] = datum
-
writer = Writer()
- for col in self.columns:
- writer.write(col.render(session, data_map))
+ for tuple in cursor:
+ for col, datum in zip(cols, tuple):
+ data[col] = datum
+ self.item_tmpl.render(session, data, writer)
+
return writer.to_string()
- class SqlColumn(object):
- def __init__(self, table, name, sql):
- self.table = table
- self.name = name
- self.sql = sql
+ def render_cells(self, session, data):
+ writer = Writer()
- def get_sql(self, session):
- return "%s as %s" % (self.sql, self.name)
+ for col in self.columns:
+ writer.write(col.render(session, data))
- class SqlJoin(object):
- def __init__(self, table,
- table_sql=None, column_sql=None, fk_column_sql=None):
- self.table = table
- self.table_sql = table_sql
- self.column_sql = column_sql
- self.fk_column_sql = fk_column_sql
- self.type_sql = "left outer join"
+ return writer.to_string()
- def get_table_sql(self, session):
- return self.table_sql
-
- def get_column_sql(self, session):
- return self.column_sql
-
- def get_fk_column_sql(self, session):
- return self.fk_column_sql
-
- def get_type_sql(self, session):
- return self.type_sql
-
- def get_sql(self, session):
- elems = (self.get_type_sql(session),
- self.get_table_sql(session),
- "on", self.get_column_sql(session),
- "=", self.get_fk_column_sql(session))
-
- return " ".join(elems)
-
class SqlTableColumn(ItemTableColumn):
def get_orderby_sql(self, session):
key = self.get_column_key(session)
16 years, 11 months
rhmessaging commits: r1642 - in mgmt/cumin/python: wooly and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-04 19:10:22 -0500 (Mon, 04 Feb 2008)
New Revision: 1642
Modified:
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/page.strings
mgmt/cumin/python/wooly/__init__.py
mgmt/cumin/python/wooly/widgets.py
mgmt/cumin/python/wooly/widgets.strings
Log:
Hilight the selected top level tab.
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2008-02-04 19:08:28 UTC (rev 1641)
+++ mgmt/cumin/python/cumin/page.py 2008-02-05 00:10:22 UTC (rev 1642)
@@ -181,31 +181,44 @@
def __init__(self, app, name):
super(MainFrameTabs, self).__init__(app, name)
+ self.html_class = "tabs"
+
+ self.selection = Parameter(app, "sel")
+ self.add_parameter(self.selection)
+
self.add_link(self.MessagingTab(app, "mtab"))
self.add_link(self.GridTab(app, "gtab"))
self.add_link(self.SystemsTab(app, "stab"))
- class MessagingTab(Link):
+ class Tab(Link):
+ def render_class(self, session, object):
+ if self.parent.selection.get(session) == self.name:
+ return "selected"
+
+ class MessagingTab(Tab):
def render_content(self, session, object):
return "Messaging"
def edit_session(self, session, object):
+ self.parent.selection.set(session, self.name)
frame = self.page().show_main(session).show_view(session)
frame.show_messaging(session)
- class GridTab(Link):
+ class GridTab(Tab):
def render_content(self, session, object):
return "Grid"
def edit_session(self, session, object):
+ self.parent.selection.set(session, self.name)
frame = self.page().show_main(session).show_view(session)
frame.show_grid(session)
- class SystemsTab(Link):
+ class SystemsTab(Tab):
def render_content(self, session, object):
return "Systems"
def edit_session(self, session, object):
+ self.parent.selection.set(session, self.name)
frame = self.page().show_main(session).show_view(session)
frame.show_systems(session)
Modified: mgmt/cumin/python/cumin/page.strings
===================================================================
--- mgmt/cumin/python/cumin/page.strings 2008-02-04 19:08:28 UTC (rev 1641)
+++ mgmt/cumin/python/cumin/page.strings 2008-02-05 00:10:22 UTC (rev 1642)
@@ -721,9 +721,6 @@
<div id="body">{mode}</div>
<div id="foot"/>
-[MainFrameTabs.html]
-<ul class="tabs">{links}</ul>
-
[MainFrame.frame_html]
<li><a href="{frame_href}">{frame_title}</a></li>
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2008-02-04 19:08:28 UTC (rev 1641)
+++ mgmt/cumin/python/wooly/__init__.py 2008-02-05 00:10:22 UTC (rev 1642)
@@ -97,6 +97,8 @@
self.children = list()
self.attributes = list()
self.parameters = list()
+
+ self.html_class = None
self.__main_tmpl = Template(self, "html")
self.__errors_tmpl = Template(self, "errors_html")
@@ -288,7 +290,7 @@
return self.path()
def render_class(self, session, object):
- return None
+ return self.html_class
def render_href(self, session, object):
return session.marshal()
Modified: mgmt/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/cumin/python/wooly/widgets.py 2008-02-04 19:08:28 UTC (rev 1641)
+++ mgmt/cumin/python/wooly/widgets.py 2008-02-05 00:10:22 UTC (rev 1642)
@@ -107,6 +107,9 @@
return link.render(session, object)
class Link(Widget):
+ def render_class(self, session, object):
+ return self.html_class
+
def edit_session(self, session, object):
pass
Modified: mgmt/cumin/python/wooly/widgets.strings
===================================================================
--- mgmt/cumin/python/wooly/widgets.strings 2008-02-04 19:08:28 UTC (rev 1641)
+++ mgmt/cumin/python/wooly/widgets.strings 2008-02-05 00:10:22 UTC (rev 1642)
@@ -50,13 +50,13 @@
<li><a href="{tab_href}" class="{tab_class}">{tab_content}</a></li>
[LinkSet.html]
-<ul class="LinkSet">{links}</ul>
+<ul class="{class}">{links}</ul>
[LinkSet.link_html]
<li>{link}</li>
[Link.html]
-<a href="{href}">{content}</a>
+<a class="{class}" href="{href}">{content}</a>
[Toggle.css]
.Toggle.on {
16 years, 11 months
rhmessaging commits: r1641 - in mgmt/cumin/python: wooly and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-04 14:08:28 -0500 (Mon, 04 Feb 2008)
New Revision: 1641
Modified:
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/page.strings
mgmt/cumin/python/wooly/widgets.py
mgmt/cumin/python/wooly/widgets.strings
Log:
Adds a LinkSet widget and uses it to render the top level tabs.
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2008-02-04 18:14:23 UTC (rev 1640)
+++ mgmt/cumin/python/cumin/page.py 2008-02-04 19:08:28 UTC (rev 1641)
@@ -58,23 +58,11 @@
def __init__(self, app, name):
super(MainFrame, self).__init__(app, name)
- self.__tab_tmpl = Template(self, "tab_html")
self.__frame_tmpl = Template(self, "frame_html")
- self.__tabs = list()
+ self.__tabs = MainFrameTabs(app, "tabs")
+ self.add_child(self.__tabs)
- tab = self.MessagingTab(app, "mtab")
- self.add_child(tab)
- self.__tabs.append(tab)
-
- tab = self.GridTab(app, "gtab")
- self.add_child(tab)
- self.__tabs.append(tab)
-
- tab = self.SystemsTab(app, "stab")
- self.add_child(tab)
- self.__tabs.append(tab)
-
# XXX get rid of this
self.__object = Attribute(app, "object")
self.add_attribute(self.__object)
@@ -114,52 +102,6 @@
def get_title(self, session, object):
return "Main"
- class MessagingTab(Widget):
- def render_content(self, session, object):
- return "Messaging"
-
- def render_href(self, session, object):
- branch = session.branch()
- frame = self.page().show_main(branch).show_view(branch)
- frame.show_messaging(branch)
- return branch.marshal()
-
- class GridTab(Widget):
- def render_content(self, session, object):
- return "Grid"
-
- def render_href(self, session, object):
- branch = session.branch()
- frame = self.page().show_main(branch).show_view(branch)
- frame.show_grid(branch)
- return branch.marshal()
-
- class SystemsTab(Widget):
- def render_content(self, session, object):
- return "Systems"
-
- def render_href(self, session, object):
- branch = session.branch()
- frame = self.page().show_main(branch).show_view(branch)
- frame.show_systems(branch)
- return branch.marshal()
-
- def render_tabs(self, session, object):
- writer = Writer()
-
- for tab in self.__tabs:
- self.__tab_tmpl.render(session, (tab, object), writer)
-
- return writer.to_string()
-
- def render_tab_href(self, session, args):
- tab, object = args
- return tab.render_href(session, object)
-
- def render_tab_content(self, session, args):
- tab, object = args
- return tab.render_content(session, object)
-
def render_frames(self, session, object):
self.__object.set(session, object)
writer = Writer()
@@ -235,6 +177,38 @@
frame = self.show_mode(session, self.__cluster_add)
return self.page().set_current_frame(session, frame)
+class MainFrameTabs(LinkSet):
+ def __init__(self, app, name):
+ super(MainFrameTabs, self).__init__(app, name)
+
+ self.add_link(self.MessagingTab(app, "mtab"))
+ self.add_link(self.GridTab(app, "gtab"))
+ self.add_link(self.SystemsTab(app, "stab"))
+
+ class MessagingTab(Link):
+ def render_content(self, session, object):
+ return "Messaging"
+
+ def edit_session(self, session, object):
+ frame = self.page().show_main(session).show_view(session)
+ frame.show_messaging(session)
+
+ class GridTab(Link):
+ def render_content(self, session, object):
+ return "Grid"
+
+ def edit_session(self, session, object):
+ frame = self.page().show_main(session).show_view(session)
+ frame.show_grid(session)
+
+ class SystemsTab(Link):
+ def render_content(self, session, object):
+ return "Systems"
+
+ def edit_session(self, session, object):
+ frame = self.page().show_main(session).show_view(session)
+ frame.show_systems(session)
+
class MainView(ModeSet):
def __init__(self, app, name):
super(MainView, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/page.strings
===================================================================
--- mgmt/cumin/python/cumin/page.strings 2008-02-04 18:14:23 UTC (rev 1640)
+++ mgmt/cumin/python/cumin/page.strings 2008-02-04 19:08:28 UTC (rev 1641)
@@ -694,11 +694,11 @@
<div id="head">
<div>
<ul id="user">
- <li>Hi, <strong>nsantos</strong></li>
+ <li>Hi, <strong>user</strong></li>
<li><a class="nav" href="">Log Out</a></li>
</ul>
- <ul class="tabs">{tabs}</ul>
+ {tabs}
</div>
<div>
@@ -721,8 +721,8 @@
<div id="body">{mode}</div>
<div id="foot"/>
-[MainFrame.tab_html]
-<li><a href="{tab_href}" class="{tab_class}">{tab_content}</a></li>
+[MainFrameTabs.html]
+<ul class="tabs">{links}</ul>
[MainFrame.frame_html]
<li><a href="{frame_href}">{frame_title}</a></li>
Modified: mgmt/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/cumin/python/wooly/widgets.py 2008-02-04 18:14:23 UTC (rev 1640)
+++ mgmt/cumin/python/wooly/widgets.py 2008-02-04 19:08:28 UTC (rev 1641)
@@ -80,14 +80,40 @@
def render_tab_content(self, session, mode):
return mode.get_title(session, self.object.get(session))
+class LinkSet(Widget):
+ def __init__(self, app, name):
+ super(LinkSet, self).__init__(app, name)
+
+ self.__links = list()
+ self.__link_tmpl = Template(self, "link_html")
+
+ def add_link(self, link):
+ self.__links.append(link)
+ self.add_child(link)
+
+ def get_links(self, session, object):
+ return self.__links
+
+ def render_links(self, session, object):
+ writer = Writer()
+
+ for link in self.get_links(session, object):
+ self.__link_tmpl.render(session, (link, object), writer)
+
+ return writer.to_string()
+
+ def render_link(self, session, args):
+ link, object = args
+ return link.render(session, object)
+
class Link(Widget):
- def update_session(self, session, object):
+ def edit_session(self, session, object):
pass
def render_href(self, session, object):
branch = session.branch()
- self.update_session(branch, object)
+ self.edit_session(branch, object)
return branch.marshal()
Modified: mgmt/cumin/python/wooly/widgets.strings
===================================================================
--- mgmt/cumin/python/wooly/widgets.strings 2008-02-04 18:14:23 UTC (rev 1640)
+++ mgmt/cumin/python/wooly/widgets.strings 2008-02-04 19:08:28 UTC (rev 1641)
@@ -49,6 +49,12 @@
[TabbedModeSet.tab_html]
<li><a href="{tab_href}" class="{tab_class}">{tab_content}</a></li>
+[LinkSet.html]
+<ul class="LinkSet">{links}</ul>
+
+[LinkSet.link_html]
+<li>{link}</li>
+
[Link.html]
<a href="{href}">{content}</a>
16 years, 11 months
rhmessaging commits: r1640 - in mgmt/cumin/python: wooly and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-04 13:14:23 -0500 (Mon, 04 Feb 2008)
New Revision: 1640
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/brokercluster.py
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/brokerprofile.py
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/page.strings
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/system.py
mgmt/cumin/python/cumin/virtualhost.py
mgmt/cumin/python/wooly/widgets.py
mgmt/cumin/python/wooly/widgets.strings
Log:
Renames TabSet to TabbedModeSet.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/broker.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -284,7 +284,7 @@
self.status = BrokerStatus(app, "status")
self.add_child(self.status)
- self.tabs = TabSet(app, "tabs")
+ self.tabs = TabbedModeSet(app, "tabs")
self.add_child(self.tabs)
self.tabs.add_tab(self.BrokerQueueTab(app, "queues"))
Modified: mgmt/cumin/python/cumin/brokercluster.py
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/brokercluster.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -80,7 +80,7 @@
self.status = BrokerClusterStatus(app, "status")
self.add_child(self.status)
- self.tabs = TabSet(app, "tabs")
+ self.tabs = TabbedModeSet(app, "tabs")
self.add_child(self.tabs)
self.tabs.add_tab(self.ClusterBrokerTab(app, "brokers"))
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/brokergroup.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -74,7 +74,7 @@
self.status = BrokerGroupStatus(app, "status")
self.add_child(self.status)
- self.tabs = TabSet(app, "tabs")
+ self.tabs = TabbedModeSet(app, "tabs")
self.add_child(self.tabs)
self.tabs.add_tab(self.GroupBrokerTab(app, "brokers"))
Modified: mgmt/cumin/python/cumin/brokerprofile.py
===================================================================
--- mgmt/cumin/python/cumin/brokerprofile.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/brokerprofile.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -55,7 +55,7 @@
def __init__(self, app, name):
super(BrokerProfileView, self).__init__(app, name)
- self.tabs = TabSet(app, "tabs")
+ self.tabs = TabbedModeSet(app, "tabs")
self.add_child(self.tabs)
self.tabs.add_tab(self.ProfileConfigTab(app, "config"))
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/client.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -252,7 +252,7 @@
self.status = ClientStatus(app, "status")
self.add_child(self.status)
- self.tabs = TabSet(app, "tabs")
+ self.tabs = TabbedModeSet(app, "tabs")
self.add_child(self.tabs)
self.tabs.add_tab(ClientStatistics(app, "stats"))
@@ -281,7 +281,7 @@
self.parent.show_close(branch)
return branch.marshal()
-class ClientStatistics(TabSet):
+class ClientStatistics(TabbedModeSet):
def __init__(self, app, name):
super(ClientStatistics, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/exchange.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -235,7 +235,7 @@
self.status = ExchangeStatus(app, "status")
self.add_child(self.status)
- self.tabs = TabSet(app, "tabs")
+ self.tabs = TabbedModeSet(app, "tabs")
self.add_child(self.tabs)
self.tabs.add_tab(ExchangeStatistics(app, "stats"))
@@ -407,7 +407,7 @@
def render_cancel_content(self, session, exchange):
return "No, Cancel"
-class ExchangeStatistics(TabSet):
+class ExchangeStatistics(TabbedModeSet):
def __init__(self, app, name):
super(ExchangeStatistics, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/page.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -257,7 +257,7 @@
def show_systems(self, session):
return self.show_mode(session, self.__systems)
-class MessagingView(TabSet):
+class MessagingView(TabbedModeSet):
def __init__(self, app, name):
super(MessagingView, self).__init__(app, name)
@@ -277,14 +277,14 @@
def get_title(self, session, model):
return "Tags"
-class GridView(TabSet):
+class GridView(TabbedModeSet):
def get_title(self, session, model):
return "Grid"
def render_data_url(self, session, model):
return "model.xml"
-class SystemsView(TabSet):
+class SystemsView(TabbedModeSet):
def __init__(self, app, name):
super(SystemsView, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/page.strings
===================================================================
--- mgmt/cumin/python/cumin/page.strings 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/page.strings 2008-02-04 18:14:23 UTC (rev 1640)
@@ -732,8 +732,8 @@
wooly.setIntervalUpdate("{data_url}", updateMain, 3000);
</script>
<div class="oblock">
- <ul class="TabSet tabs">{tabs}</ul>
- <div class="TabSet mode">{mode}</div>
+ <ul class="TabbedModeSet tabs">{tabs}</ul>
+ <div class="TabbedModeSet mode">{mode}</div>
</div>
[GridView.html]
@@ -741,8 +741,8 @@
wooly.setIntervalUpdate("{data_url}", updateMain, 3000);
</script>
<div class="oblock">
- <ul class="TabSet tabs">{tabs}</ul>
- <div class="TabSet mode">{mode}</div>
+ <ul class="TabbedModeSet tabs">{tabs}</ul>
+ <div class="TabbedModeSet mode">{mode}</div>
</div>
[SystemsView.html]
@@ -750,6 +750,6 @@
wooly.setIntervalUpdate("{data_url}", updateMain, 3000);
</script>
<div class="oblock">
- <ul class="TabSet tabs">{tabs}</ul>
- <div class="TabSet mode">{mode}</div>
+ <ul class="TabbedModeSet tabs">{tabs}</ul>
+ <div class="TabbedModeSet mode">{mode}</div>
</div>
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/queue.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -260,7 +260,7 @@
self.status = QueueStatus(app, "status")
self.add_child(self.status)
- self.tabs = TabSet(app, "tabs")
+ self.tabs = TabbedModeSet(app, "tabs")
self.add_child(self.tabs)
self.tabs.add_tab(QueueStatistics(app, "stats"))
@@ -556,7 +556,7 @@
def render_cancel_content(self, session, binding):
return "No, Cancel"
-class QueueStatistics(TabSet):
+class QueueStatistics(TabbedModeSet):
def __init__(self, app, name):
super(QueueStatistics, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/system.py
===================================================================
--- mgmt/cumin/python/cumin/system.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/system.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -69,7 +69,7 @@
self.status = SystemStatus(app, "status")
self.add_child(self.status)
- self.tabs = TabSet(app, "tabs")
+ self.tabs = TabbedModeSet(app, "tabs")
self.add_child(self.tabs)
self.add_tab(SystemStatsTab(app, "stats"))
Modified: mgmt/cumin/python/cumin/virtualhost.py
===================================================================
--- mgmt/cumin/python/cumin/virtualhost.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/cumin/virtualhost.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -64,7 +64,7 @@
def __init__(self, app, name):
super(VirtualHostView, self).__init__(app, name)
- self.tabs = TabSet(app, "tabs")
+ self.tabs = TabbedModeSet(app, "tabs")
self.add_child(self.tabs)
self.tabs.add_tab(QueueSet(app, "queues"))
Modified: mgmt/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/cumin/python/wooly/widgets.py 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/wooly/widgets.py 2008-02-04 18:14:23 UTC (rev 1640)
@@ -44,9 +44,9 @@
if mode:
return mode.render(session, object)
-class TabSet(ModeSet):
+class TabbedModeSet(ModeSet):
def __init__(self, app, name):
- super(TabSet, self).__init__(app, name)
+ super(TabbedModeSet, self).__init__(app, name)
self.__tabs = list()
self.__tab_tmpl = Template(self, "tab_html")
Modified: mgmt/cumin/python/wooly/widgets.strings
===================================================================
--- mgmt/cumin/python/wooly/widgets.strings 2008-02-04 17:55:54 UTC (rev 1639)
+++ mgmt/cumin/python/wooly/widgets.strings 2008-02-04 18:14:23 UTC (rev 1640)
@@ -1,18 +1,18 @@
[ModeSet.html]
{mode}
-[TabSet.css]
-.TabSet.tabs {
+[TabbedModeSet.css]
+.TabbedModeSet.tabs {
padding: 0;
margin: 0;
list-style: none;
}
-.TabSet.tabs li {
+.TabbedModeSet.tabs li {
display: inline;
}
-.TabSet.tabs li a {
+.TabbedModeSet.tabs li a {
padding: 0.275em 0.5em;
border-top: 1px solid #ccc;
border-right: 1px solid #ccc;
@@ -21,17 +21,17 @@
line-height: 1.5em;
}
-.TabSet.tabs li:first-child a {
+.TabbedModeSet.tabs li:first-child a {
border-left: 1px solid #ccc;
}
-.TabSet.tabs li a.selected {
+.TabbedModeSet.tabs li a.selected {
background-color: #fff;
position: relative;
z-index: 2;
}
-.TabSet.mode {
+.TabbedModeSet.mode {
background-color: white;
padding: 1em;
border: 1px solid #ccc;
@@ -42,11 +42,11 @@
min-height: 20em;
}
-[TabSet.html]
-<ul class="TabSet tabs">{tabs}</ul>
-<div class="TabSet mode">{mode}</div>
+[TabbedModeSet.html]
+<ul class="TabbedModeSet tabs">{tabs}</ul>
+<div class="TabbedModeSet mode">{mode}</div>
-[TabSet.tab_html]
+[TabbedModeSet.tab_html]
<li><a href="{tab_href}" class="{tab_class}">{tab_content}</a></li>
[Link.html]
16 years, 11 months