summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2013-08-21 14:38:12 +0000
committerKim van der Riet <kpvdr@apache.org>2013-08-21 14:38:12 +0000
commit7cfb37d4117ed1726795cd5e30f5a11ea1a555c9 (patch)
tree80c33eaa7e3aca8c497525844dbe6996d095a65c
parentce77e05f958a3ebbf8510d79de88a86e58eb6f26 (diff)
downloadqpid-python-7cfb37d4117ed1726795cd5e30f5a11ea1a555c9.tar.gz
QPID-4984: WIP - compiles, but not functional.
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/linearstore@1516176 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/Makefile.am42
-rw-r--r--qpid/cpp/configure.ac575
-rw-r--r--qpid/cpp/docs/man/qpidd.1186
-rw-r--r--qpid/cpp/src/linearstore.cmake39
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/aio.h12
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/aio_callback.h15
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/cvar.h18
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/data_tok.cpp21
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/data_tok.h68
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/deq_hdr.h141
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/deq_rec.cpp141
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/deq_rec.h43
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/enq_hdr.h165
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/enq_map.cpp41
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/enq_map.h51
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/enq_rec.cpp198
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/enq_rec.h42
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/enums.h10
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/fcntl.cpp375
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/fcntl.h156
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/file_hdr.h211
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jcfg.h82
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jcntl.cpp234
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jcntl.h117
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jdir.cpp42
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jdir.h15
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jerrno.cpp197
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jerrno.h153
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jexception.cpp29
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jexception.h34
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jinf.cpp540
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jinf.h133
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jrec.cpp55
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/jrec.h45
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/lp_map.cpp82
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/lp_map.h83
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/lpmgr.cpp226
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/lpmgr.h303
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/pmgr.cpp33
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/pmgr.h67
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/rcvdat.h86
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/rec_hdr.h143
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/rec_tail.h98
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/rfc.cpp82
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/rfc.h193
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/rmgr.cpp154
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/rmgr.h44
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/rrfc.cpp125
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/rrfc.h179
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/slock.cpp33
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/slock.h15
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/smutex.cpp33
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/smutex.h13
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/time_ns.cpp13
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/time_ns.h11
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/txn_hdr.h125
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/txn_map.cpp41
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/txn_map.h40
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.cpp160
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.h41
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c17
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h86
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c25
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h88
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c27
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h56
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.c15
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h42
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_tail.c (renamed from qpid/cpp/src/qpid/linearstore/jrnl/aio.cpp)29
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_tail.h63
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.c (renamed from qpid/cpp/src/qpid/linearstore/jrnl/cvar.cpp)22
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h73
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/wmgr.cpp72
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/wmgr.h51
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/wrfc.cpp162
-rw-r--r--qpid/cpp/src/qpid/linearstore/jrnl/wrfc.h154
-rwxr-xr-xqpid/tools/src/py/linearstore/efptool.py417
77 files changed, 1964 insertions, 6084 deletions
diff --git a/qpid/cpp/Makefile.am b/qpid/cpp/Makefile.am
index b59910af6a..c9c316cd92 100644
--- a/qpid/cpp/Makefile.am
+++ b/qpid/cpp/Makefile.am
@@ -1,41 +1 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-AUTOMAKE_OPTIONS = 1.9.2 foreign
-ACLOCAL_AMFLAGS = -I m4
-
-EXTRA_DIST = \
- LICENSE NOTICE README.txt SSL RELEASE_NOTES DESIGN \
- INSTALL-WINDOWS CMakeLists.txt BuildInstallSettings.cmake \
- cmake_uninstall.cmake.in \
- packaging/NSIS QPID_VERSION.txt bindings/CMakeLists.txt \
- include/qpid/swig_python_typemaps.i include/qpid/swig_ruby_typemaps.i include/qpid/swig_perl_typemaps.i \
- include/qpid/qpid.i include/qmf/qmfengine.i include/qmf/qmf2.i
-
-SUBDIRS = managementgen etc src docs/api docs/man examples bindings/qmf bindings/qpid bindings/qmf2
-
-# Update libtool, if needed.
-libtool: $(LIBTOOL_DEPS)
- $(SHELL) ./config.status --recheck
-
-check-long: all
- $(MAKE) -C src/tests check-long
-
+SUBDIRS=libTest include exampleProgram
diff --git a/qpid/cpp/configure.ac b/qpid/cpp/configure.ac
index 049daf64a0..2ca4592d81 100644
--- a/qpid/cpp/configure.ac
+++ b/qpid/cpp/configure.ac
@@ -1,569 +1,26 @@
dnl Process this file with autoconf to produce a configure script.
-dnl
-dnl This file is free software; as a special exception the author gives
-dnl unlimited permission to copy and/or distribute it, with or without
-dnl modifications, as long as this notice is preserved.
-dnl
-dnl This program is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-dnl
-# Pick up the version from QPID_VERSION.txt in the qpid/cpp source tree.
-# NB. You need to re-run bootstrap if the global qpid/QPID_VERSION.txt changes.
-AC_INIT([qpidc],
- [m4_esyscmd([cat QPID_VERSION.txt | tr -d '\n'])],
- [dev@qpid.apache.org])
-
-AC_CONFIG_AUX_DIR([build-aux])
-AM_INIT_AUTOMAKE([dist-bzip2 subdir-objects tar-ustar])
-
-# Minimum Autoconf version required.
AC_PREREQ(2.59)
+AC_INIT(linearstore, 1.0)
+AC_PROG_CC
-AC_CONFIG_HEADERS([src/config.h])
-
-AC_PROG_CC_STDC
-AM_PROG_CC_C_O
-AC_PROG_CXX
-AC_USE_SYSTEM_EXTENSIONS
-AC_LANG([C++])
-
-# Check whether a C++ was found (AC_PROG_CXX sets $CXX to "g++" even when it
-# doesn't exist)
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],[],[AC_MSG_ERROR([No C++ compiler found])])
-
+AC_CANONICAL_SYSTEM
-# Check for optional use of help2man
-AC_CHECK_PROG([HELP2MAN], [help2man], [help2man])
-AC_ARG_WITH([help2man],
- [AS_HELP_STRING([--with-help2man], [Use help2man to generate man pages.])],
- [case "$withval" in
- yes) test -z "$HELP2MAN" && AC_MSG_ERROR([help2man not found.]) ;;
- no) HELP2MAN="" ;;
- *) AC_MSG_ERROR([Bad value ${withval} for --with-help2man.]) ;;
- esac])
-AM_CONDITIONAL([HAVE_HELP2MAN], [test -n "$HELP2MAN"])
+dnl Initialize automake
+AM_INIT_AUTOMAKE
-# Check for optional use of doxygen
-AC_CHECK_PROG([DOXYGEN], [doxygen], [doxygen])
-AC_ARG_WITH([doxygen],
- [AS_HELP_STRING([--with-doxygen], [Use doxygen to generate API documentation.])],
- [case "$withval" in
- yes) test -z "$DOXYGEN" && AC_MSG_ERROR([doxygen not found.]) ;;
- no) DOXYGEN="" ;;
- *) AC_MSG_ERROR([Bad value ${withval} for --with-doxygen.]) ;;
- esac])
-AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
+dnl this allows us specify individual liking flags for each target
+AM_PROG_CC_C_O
-AC_ARG_ENABLE(warnings,
-[ --enable-warnings turn on lots of compiler warnings (recommended)],
-[case "${enableval}" in
- yes|no) ;;
- *) AC_MSG_ERROR([bad value ${enableval} for warnings option]) ;;
- esac],
- [enableval=yes])
+dnl Initialize Libtool
+LT_INIT
-# Set up for gcc as compiler
-if test x$GXX = xyes; then
- # Warnings: Enable as many as possible, keep the code clean. Please
- # do not disable warnings or remove -Werror without discussing on
- # qpid-dev list.
- #
- # The following warnings are deliberately omitted, they warn on valid code.
- # -Wunreachable-code -Wpadded -Winline
- # -Wshadow - warns about boost headers.
- # Can't test for -Werror as whether it fails or not depends on what's in
- # CFLAGS/CXXFLAGS. In any case it's been in gcc for a long time (since 2.95 at least)
- if test "${enableval}" = yes; then
- COMPILER_FLAGS="-Werror"
- gl_COMPILER_FLAGS(-pedantic)
- gl_COMPILER_FLAGS(-Wall)
- gl_COMPILER_FLAGS(-Wextra)
- gl_COMPILER_FLAGS(-Wno-shadow)
- gl_COMPILER_FLAGS(-Wpointer-arith)
- gl_COMPILER_FLAGS(-Wcast-qual)
- gl_COMPILER_FLAGS(-Wcast-align)
- gl_COMPILER_FLAGS(-Wno-long-long)
- gl_COMPILER_FLAGS(-Wvolatile-register-var)
- gl_COMPILER_FLAGS(-Winvalid-pch)
- gl_COMPILER_FLAGS(-Wno-system-headers)
- gl_COMPILER_FLAGS(-Woverloaded-virtual)
- AC_SUBST([WARNING_CFLAGS], [$COMPILER_FLAGS])
- AC_DEFINE([lint], 1, [Define to 1 if the compiler is checking for lint.])
- COMPILER_FLAGS=
- fi
-else
- AC_CHECK_DECL([__SUNPRO_CC], [SUNCC=yes], [SUNCC=no])
-
- # Set up for sun CC compiler
- if test x$SUNCC = xyes; then
- if test "${enableval}" = yes; then
- WARNING_FLAGS=+w
- fi
- CXXFLAGS="$CXXFLAGS -library=stlport4 -mt"
- LD="$CXX"
- LDFLAGS="$LDFLAGS -library=stlport4 -mt"
- AC_SUBST([SUNCC_RUNTIME_LIBS], [-lCrun])
- fi
-fi
-
-AC_DISABLE_STATIC
+dnl Check if Libtool is present
+dnl Libtool is used for building share libraries
AC_PROG_LIBTOOL
-AC_SUBST([LIBTOOL_DEPS])
-
-# For libraries (libcommon) that use dlopen, dlerror, etc.,
-# test whether we need to link with -ldl.
-gl_saved_libs=$LIBS
- AC_SEARCH_LIBS(dlopen, [dl],
- [test "$ac_cv_search_dlopen" = "none required" ||
- LIB_DLOPEN=$ac_cv_search_dlopen])
- AC_SUBST([LIB_DLOPEN])
-LIBS=$gl_saved_libs
-
-gl_CLOCK_TIME
-
-# Enable Valgrind
-AC_ARG_ENABLE([valgrind],
- [AS_HELP_STRING([--enable-valgrind],
- [run valgrind memory checker on tests, if available (default yes)])],
- [case $enableval in
- yes|no) enable_VALGRIND=$enableval;;
- *) AC_MSG_ERROR([Invalid value for --enable-valgrind: $enableval]);;
- esac],
- [enable_VALGRIND=yes]
-)
-
-# We use valgrind for the tests. See if it's available.
-# Check for it unconditionally, so we don't have to duplicate its
-# use of AC_SUBST([VALGRIND]).
-AC_CHECK_PROG([VALGRIND], [valgrind], [valgrind])
-test "$enable_VALGRIND" = no && VALGRIND=
-
-# If rpmlint is available we'll run it when building RPMs.
-AC_CHECK_PROG([RPMLINT], [rpmlint], [rpmlint])
-AM_CONDITIONAL([HAS_RPMLINT], [test -n "$RPMLINT"])
-
-# Code generation: generated code is included in the distribution
-# so code generation is only required in an svn checkout.
-# It requires several external tools and files, which we check for here.
-
-AC_CHECK_PROG([RUBY], [ruby], [ruby])
-
-# Swig binding generator is needed for the script (Ruby, Python, etc.) bindings.
-AC_PROG_SWIG(1.3.26)
-test ! -x "$SWIG" && SWIG=""
-AC_ARG_WITH([swig],
- [AS_HELP_STRING([--with-swig], [Use swig to generate qmf bindings.])],
- [case "$withval" in
- yes) test -z "$SWIG" && AC_MSG_ERROR([swig not found.]) ;;
- no) SWIG="" ;;
- *) AC_MSG_ERROR([Bad value ${withval} for --with-swig.]) ;;
- esac])
-AM_CONDITIONAL([HAVE_SWIG], [test -n "$SWIG"])
-
-# Ruby bindings: To build ruby wrappers, the ruby-devel files must be present.
-
-AC_PATH_PROGS(RUBY, [ruby1.8 ruby], [])
-AC_ARG_VAR(RUBY, [Ruby interpreter])
-if test -n "$RUBY" ; then
- AC_ARG_VAR(RUBY_INC, [Directory where ruby.h can be found])
- if test -z "$RUBY_INC" ; then
- [RUBY_INC=`$RUBY -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"] || Config::CONFIG["archdir"]'`]
- fi
- AC_SUBST(RUBY_INC)
-
- AC_ARG_VAR(RUBY_INC_ARCH, [Directory where ruby/config.h can be found (needed from Ruby 1.9)])
- if test -z "$RUBY_INC_ARCH" ; then
- [RUBY_INC_ARCH=`$RUBY -rrbconfig -e 'd = Config::CONFIG["rubyhdrdir"];if d != nil; print d + "/" + Config::CONFIG["arch"]; end'`]
- dnl For earlier versions, just make it the same as RUBY_INC.
- test x"$RUBY_INC_ARCH" != x || RUBY_INC_ARCH=$RUBY_INC
- fi
- AC_SUBST(RUBY_INC_ARCH)
- AC_ARG_VAR(RUBY_LIB, [Directory to install ruby files into])
- if test -z "$RUBY_LIB" ; then
- dnl Kludge to install ruby files under $prefix
- [RUBY_LIB=`$RUBY -rrbconfig -e 'puts Config::CONFIG["sitelibdir"].gsub("/usr", "${prefix}")'`]
- fi
- AC_SUBST(RUBY_LIB)
-
- AC_ARG_VAR(RUBY_LIB_ARCH, [Directory to install ruby binary modules into])
- if test -z "$RUBY_LIB_ARCH" ; then
- dnl Kludge to install ruby files under $prefix
- [RUBY_LIB_ARCH=`$RUBY -rrbconfig -e 'puts Config::CONFIG["sitearchdir"].gsub("/usr", "${prefix}")'`]
- fi
- AC_SUBST(RUBY_LIB_ARCH)
-
- RUBY_LIBS=
- case $host_os in
- cygwin*) RUBY_LIBS=-lruby ;;
- esac
- AC_SUBST(RUBY_LIBS)
-
- RUBY_DLEXT=`$RUBY -rrbconfig -e 'puts Config::CONFIG[["DLEXT"]]'`
- AC_SUBST(RUBY_DLEXT)
-fi
-AM_CONDITIONAL([HAVE_RUBY_DEVEL], [test -f $RUBY_INC/ruby.h && test -n "$SWIG"])
-
-# Python bindings: To build python wrappers, the python-devel files must be present.
-AM_PATH_PYTHON()
-AS_IF([test -n "$PYTHON"], [
- PKG_CHECK_MODULES([PYTHON], [python-$PYTHON_VERSION], [have_python_dev=yes],[
- # We didn't find pkg-config information for python-2.7 this
- # may mean we have an earlier python version:
- # Try to find the include and library files directly in the default
- # location
- AC_MSG_WARN([Didn't find Python 2.7 developer libs - looking for older version])
- PYTHON_INC=$($PYTHON -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_inc()')
- AC_CHECK_LIB([python$PYTHON_VERSION],[Py_Initialize],[
- PYTHON_LIBS="-lpython$PYTHON_VERSION"
- ])
- AC_CHECK_FILE(["$PYTHON_INC/Python.h"],[
- PYTHON_CFLAGS="-I$PYTHON_INC"
- have_python_dev=yes
- ],[
- if test yes = "$with_python" ; then
- AC_MSG_ERROR([Couldn't find Python developer libs - you probably need to install a python-dev or python-devel package])
- else
- AC_MSG_WARN([Couldn't find Python developer libs - you probably don't have a python-dev or python-devel package installed])
- fi
- ])
- ])
- AC_SUBST(PYTHON_CFLAGS)
- AC_SUBST(PYTHON_LIBS)
-])
-AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test x$have_python_dev = xyes && test -n "$SWIG"])
-
-
-# Perl bindings:
-
-AC_CHECK_PROG([PERL], [perl], [perl])
-if test -n "$PERL"; then
- PERL_ARCHLIB=`perl -MConfig -e 'print "$Config{archlib}";'`
- AC_CHECK_FILE( ["$PERL_ARCHLIB/CORE/perl.h"],
- [AC_SUBST([PERL_INC], ["$PERL_ARCHLIB/CORE"])] )
- AC_SUBST(PERL_ARCHLIB)
-fi
-AM_CONDITIONAL([HAVE_PERL_DEVEL], [test -n "$PERL" && test -n "$SWIG" && test -n "$PERL_INC"])
-
-specdir=`pwd`/$srcdir/../specs
-AMQP_FINAL_XML=$specdir/amqp.0-10-qpid-errata.stripped.xml
-AC_SUBST(AMQP_FINAL_XML)
-AM_CONDITIONAL([GENERATE], [test -f $AMQP_FINAL_XML])
-test -f $AMQP_FINAL_XML -a -z "$RUBY" && AC_MSG_ERROR([Missing ruby installation (try "yum install ruby").])
-
-# URL and download URL for the package.
-URL=http://rhm.et.redhat.com/qpidc
-AC_SUBST(URL)
-DOWNLOAD_URL=http://rhm.et.redhat.com/download
-AC_SUBST(DOWNLOAD_URL)
-
-# Check for headers from required devel kits.
-AC_CHECK_HEADERS([boost/shared_ptr.hpp uuid/uuid.h],,
- AC_MSG_ERROR([Missing required header files.]))
-
-# Setup --with-sasl/--without-sasl as arguments to configure
-AC_ARG_WITH([sasl],
- [AS_HELP_STRING([--with-sasl], [Build with SASL authentication support])],
- [WANT_SASL="$withval"],
- [WANT_SASL=check])
-
-# Make sure --with-sasl/--without-sasl were only give yes|no|check
-AS_IF([test "x$WANT_SASL" != xyes -a \
- "x$WANT_SASL" != xno -a \
- "x$WANT_SASL" != xcheck],
- [AC_MSG_ERROR([Bad value for --with-sasl: $withval])])
-
-# If we weren't explicitly asked /not/ to test, i.e. not given --without-sasl
-have_sasl=no
-AS_IF([test "x$WANT_SASL" != xno],
- # Perform tests for headers and libraries. Remember, AC_CHECK_LIB
- # will give you some useful default behavior, e.g. setup LDFLAGS, if
- # you do not give it a second argument, so try not to
- [AC_CHECK_HEADER([sasl/sasl.h], , [HAVE_SASL_H=no])
- tmp_LIBS=$LIBS
- AC_CHECK_LIB([sasl2], [sasl_checkpass], , [HAVE_SASL_LIB=no])
- # Remove from LIBS, we will link it explicitly in make files.
- LIBS=$tmp_LIBS
- # If any of the tests failed
- AS_IF([test "x$HAVE_SASL_H" = xno -o \
- "x$HAVE_SASL_LIB" = xno],
- # And we were given --with, then fail
- [AS_IF([test "x$WANT_SASL" = xyes],
- [AC_MSG_ERROR([sasl requested but not available])])],
- # Otherwise, no tests failed, setup AC_SUBST/AC_DEFINE/vars for AM_CONDITIONALs
- [AC_DEFINE([BROKER_SASL_NAME], ["qpidd"],
- [The SASL app name for the qpid Broker])
- AC_DEFINE([HAVE_SASL], [1], [Enable if libsasl is present])
- have_sasl=yes])
- AC_PATH_PROG([SASL_PASSWD], [saslpasswd2], [], [$PATH$PATH_SEPARATOR/usr/sbin])
- AS_IF([test x$SASL_PASSWD = x], [AC_MSG_ERROR([saslpasswd2 not found])], [])
- ])
-AM_CONDITIONAL([HAVE_SASL], [test "x$have_sasl" = xyes])
-AC_SUBST([SASL_PASSWD])
-
-# Allow integration against external AMQP 1.0 protocol engine
-AC_ARG_WITH([proton], AS_HELP_STRING([--with-proton], [Build with the proton toolkit for AMQP 1.0 support]))
-
-AS_IF([test "x$with_proton" = "xyes"], [
- PKG_CHECK_MODULES([PROTON], [libqpid-proton])
-])
-AM_CONDITIONAL([HAVE_PROTON], [test "x$with_proton" = "xyes"])
-
-
-# Setup --with-xml/--without-xml as arguments to configure
-use_xml=yes
-want_xml=check
-AC_ARG_WITH([xml],
- [AS_HELP_STRING([--with-xml], [Build with XML Exchange])],
- [want_xml=$withval])
-
-case $want_xml in
- yes|no|check) ;;
- *) AC_MSG_ERROR([Bad value for --with-xml: $withval]) ;;
-esac
-
-test $want_xml = no && use_xml=no
-
-
-
-# If the user doesn't say not to use XML, see if it's available.
-if test $use_xml != no; then
- # Then see if XQilla is available
- tmp_LIBS=$LIBS
- AC_CHECK_LIB([xerces-c], [_init], , [use_xml=no])
- AC_CHECK_HEADER([xercesc/framework/MemBufInputSource.hpp], , [use_xml=no])
- AC_CHECK_HEADER([xqilla/xqilla-simple.hpp], , [use_xml=no])
- AC_CHECK_LIB([xqilla], [_init], , [use_xml=no])
- # Remove from LIBS, we will link it explicitly in make files.
- LIBS=$tmp_LIBS
-
- # If XQilla is not available, yet specifically requested, die.
- test $use_xml:$want_xml = no:yes &&
- AC_MSG_ERROR([XML Exchange requested, but XQilla or Xerces-C not available])
-
- # Else XQilla is available - use it to build
- test $use_xml = yes &&
- AC_DEFINE([HAVE_XML], [1], [Compile-in XML Exchange support.])
-
- # Check to see if we need to use legacy calls for effective boolean value
- xqilla_has_ebv=yes
- AC_CHECK_HEADER([xqilla/ast/XQEffectiveBooleanValue.hpp], , [xqilla_has_ebv=no])
- test $xqilla_has_ebv = yes &&
- AC_DEFINE([XQ_EFFECTIVE_BOOLEAN_VALUE_HPP], [1], [XQilla version has xqilla/ast/XQEffectiveBooleanValue.hpp.])
-
-fi
-
-AM_CONDITIONAL([HAVE_XML], [test $use_xml = yes])
-
-# Setup --with-rdma/--without-rdma as arguments to configure
-tmp_LIBS=$LIBS
-AC_ARG_WITH([rdma],
- [AS_HELP_STRING([--with-rdma], [Build with support for Remote DMA protocols])],
- [case ${withval} in
- yes)
- with_RDMA=yes
- AC_CHECK_LIB([ibverbs],[ibv_create_qp],,[AC_MSG_ERROR([libibverbs not found])])
- AC_CHECK_LIB([rdmacm],[rdma_create_id],,[AC_MSG_ERROR([librdmacm not found])])
- AC_CHECK_HEADERS([infiniband/verbs.h],,[AC_MSG_ERROR([ibverbs header files not found])])
- AC_CHECK_HEADERS([rdma/rdma_cma.h],,[AC_MSG_ERROR([rdma_cm header files not found])])
- ;;
- no)
- with_RDMA=no
- ;;
- *)
- AC_MSG_ERROR([Bad value for --with-rdma: ${withval}])
- ;;
- esac],
- [
- with_RDMA=yes
- AC_CHECK_LIB([ibverbs],[ibv_create_qp],,[with_RDMA=no])
- AC_CHECK_LIB([rdmacm],[rdma_create_id],,[with_RDMA=no])
- AC_CHECK_HEADERS([infiniband/verbs.h],,[with_RDMA=no])
- AC_CHECK_HEADERS([rdma/rdma_cma.h],,[with_RDMA=no])
- ]
-)
-# Remove from LIBS, we will link it explicitly in make files.
-LIBS=$tmp_LIBS
-AM_CONDITIONAL([RDMA], [test x$with_RDMA = xyes])
-
-# Setup --with-ssl/--without-ssl as arguments to configure
-SSL_CFLAGS=""
-SSL_LDFLAGS=""
-AC_ARG_WITH([ssl],
- [AS_HELP_STRING([--with-ssl], [Build with support for SSL])],
- [case ${withval} in
- yes)
- with_SSL=yes
- AC_PATH_PROG([NSPR_CONFIG], [nspr-config])
- AS_IF([test x$NSPR_CONFIG = x], [AC_MSG_ERROR([libnspr not found])], [])
- AC_PATH_PROG([NSS_CONFIG], [nss-config])
- AS_IF([test x$NSS_CONFIG = x], [AC_MSG_ERROR([libnss not found])], [])
- SSL_CFLAGS="`$NSPR_CONFIG --cflags` `$NSS_CONFIG --cflags`"
- SSL_LDFLAGS="`$NSPR_CONFIG --libs` `$NSS_CONFIG --libs`"
- ;;
- no)
- with_SSL=no
- ;;
- *)
- AC_MSG_ERROR([Bad value for --with-ssl: ${withval}])
- ;;
- esac],
- [
- with_SSL=yes
- AC_PATH_PROG([NSPR_CONFIG], [nspr-config])
- AS_IF([test x$NSPR_CONFIG = x], [with_SSL=no],
- [AC_PATH_PROG([NSS_CONFIG], [nss-config])
- AS_IF([test x$NSS_CONFIG = x], [with_SSL=no],
- [SSL_CFLAGS="`$NSPR_CONFIG --cflags` `$NSS_CONFIG --cflags`"
- SSL_LDFLAGS="`$NSPR_CONFIG --libs` `$NSS_CONFIG --libs`"])])
- ]
-)
-# Remove from LIBS, we will link it explicitly in make files.
-AM_CONDITIONAL([SSL], [test x$with_SSL = xyes])
-AC_SUBST([SSL_CFLAGS])
-AC_SUBST([SSL_LDFLAGS])
-
-
-poller=no
-AC_ARG_WITH([poller],
- [AS_HELP_STRING([--with-poller], [The low level poller implementation: poll/solaris-ecf/epoll])],
- [case ${withval} in
- poll)
- AC_CHECK_HEADERS([sys/poll.h],[poller=poll],[AC_MSG_ERROR([Can't find poll.h header file for poll])])
- ;;
- solaris-ecf)
- AC_CHECK_HEADERS([port.h],[poller=solaris-ecf],[AC_MSG_ERROR([Can't find port.h header file for solaris-ecf])])
- ;;
- epoll)
- AC_CHECK_HEADERS([sys/epoll.h],[poller=epoll],[AC_MSG_ERROR([Can't find epoll.h header file for epoll])])
- ;;
- esac],
- [
- # We check for poll first so that it is overridden
- AC_CHECK_HEADERS([sys/poll.h],[poller=poll],)
- # Not currently supported - WIP
- #AC_CHECK_HEADERS([port.h],[poller=solaris-ecf],)
- AC_CHECK_HEADERS([sys/epoll.h],[poller=epoll],)
- ]
-)
-
-AM_CONDITIONAL([USE_ECF], [test x$poller = xsolaris-ecf])
-AM_CONDITIONAL([USE_POLL], [test x$poller = xpoll])
-AM_CONDITIONAL([USE_EPOLL], [test x$poller = xepoll])
-
-#Filter not implemented or invalid mechanisms
-if test $poller = xno; then
- AC_MSG_ERROR([Polling mechanism not implemented for $host])
-fi
-
-#Guess host architecture, to choose platform-dependent objects
-case "$host" in
- *sun-solaris*)
- arch=solaris
- ;;
-esac
-AM_CONDITIONAL([SUNOS], [test x$arch = xsolaris])
-
-# Check whether we've got the header for dtrace static probes
-AC_ARG_WITH([probes],
- [AS_HELP_STRING([--with-probes], [Build with dtrace/systemtap static probes])],
- [case ${withval} in
- yes)
- AC_CHECK_HEADERS([sys/sdt.h])
- ;;
- no)
- ;;
- *)
- AC_MSG_ERROR([Bad value for --with-probes: ${withval}])
- ;;
- esac],
- [
- AC_CHECK_HEADERS([sys/sdt.h])
- ]
-)
-
-# Check for some syslog capabilities not present in all systems
-AC_TRY_COMPILE([#include <sys/syslog.h>],
- [int v = LOG_AUTHPRIV;],
- [AC_DEFINE([HAVE_LOG_AUTHPRIV], [1], [Set to 1 whether LOG_AUTHPRIV is supported.])],)
-
-AC_TRY_COMPILE([#include <sys/syslog.h>],
- [int v = LOG_FTP;],
- [AC_DEFINE([HAVE_LOG_FTP], [1], [Set to 1 whether LOG_FTP is supported.])],)
-
-#Check if we need to include libacl to provide acl API
-gl_saved_libs=$LIBS
- AC_SEARCH_LIBS(acl, [acl],
- [test "$ac_cv_search_acl" = "none required" ||
- LIB_ACL=$ac_cv_search_acl])
- AC_SUBST([LIB_ACL])
-LIBS=$gl_saved_libs
-
-SOCKLIBS=""
-AC_CHECK_LIB([socket],[socket],[SOCKET_LIB="-lsocket"],[SOCKET_LIB=""],[])
-AC_CHECK_LIB([nsl],[getipnodebyname],[NSL_LIB="-lnsl"],[NSL_LIB=""],[])
-SOCKLIBS="$SOCKET_LIB $NSL_LIB"
-AC_SUBST([SOCKLIBS])
-
-# Used by env scripts to find libraries in cmake or autoconf builds.
-builddir_lib_suffix="/.libs"
-AC_SUBST([builddir_lib_suffix])
-
-# Files to generate
-AC_CONFIG_FILES([
- Makefile
- examples/Makefile
- examples/old_api/Makefile
- examples/old_api/direct/Makefile
- examples/old_api/fanout/Makefile
- examples/old_api/pub-sub/Makefile
- examples/old_api/request-response/Makefile
- examples/old_api/failover/Makefile
- examples/old_api/xml-exchange/Makefile
- examples/qmf-console/Makefile
- examples/old_api/tradedemo/Makefile
- examples/messaging/Makefile
- bindings/qpid/Makefile
- bindings/qpid/ruby/Makefile
- bindings/qpid/python/Makefile
- bindings/qpid/dotnet/Makefile
- bindings/qmf/Makefile
- bindings/qmf/ruby/Makefile
- bindings/qmf/python/Makefile
- bindings/qmf/tests/Makefile
- bindings/qmf2/Makefile
- bindings/qmf2/ruby/Makefile
- bindings/qmf2/python/Makefile
- bindings/qmf2/examples/cpp/Makefile
- managementgen/Makefile
- etc/Makefile
- src/Makefile
- src/tests/Makefile
- src/tests/test_env.sh
- src/tests/install_env.sh
- src/qpid.pc
- src/qmf2.pc
- docs/man/Makefile
- docs/api/Makefile
- docs/api/user.doxygen
- docs/api/developer.doxygen
- ])
-AC_OUTPUT
-
-cat <<EOF
-
-
- ============================== DEPRECATED ==============================
-
- The autotools build system is deprecated, use the cmake build system
- instead as described in the INSTALL file.
-
- You can continue to use the autotools system for now, but it will be
- removed in a future release. If you encounter any problems with the
- cmake system send email to dev@qpid.apache.org.
-
- ========================================================================
-
-EOF
+AC_CONFIG_FILES(Makefile
+ exampleProgram/Makefile
+ libTest/Makefile
+ include/Makefile)
+AC_OUTPUT \ No newline at end of file
diff --git a/qpid/cpp/docs/man/qpidd.1 b/qpid/cpp/docs/man/qpidd.1
index d2cff454cf..fd40413337 100644
--- a/qpid/cpp/docs/man/qpidd.1
+++ b/qpid/cpp/docs/man/qpidd.1
@@ -1,5 +1,5 @@
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.38.2.
-.TH QPIDD "1" "March 2011" "qpidd (qpidc) version 0.11" "User Commands"
+.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.41.2.
+.TH QPIDD "1" "August 2013" "qpidd (qpidc) version 0.23" "User Commands"
.SH NAME
qpidd \- the Qpid AMQP Message Broker Daemon
@@ -24,11 +24,15 @@ Displays the help message
\fB\-v\fR [ \fB\-\-version\fR ]
Displays version information
.TP
-\fB\-\-config\fR FILE
+\fB\-\-config\fR FILE (\fI/usr/local/etc/qpidd.conf\fP)
Reads configuration from FILE
+.TP
+\fB\-\-client\-config\fR FILE (\fI/usr/local/etc/qpid/qpidc.conf\fP)
+Reads client configuration from FILE
+(for cluster interconnect)
.SS "Module options:"
.TP
-\fB\-\-module\-dir\fR DIR
+\fB\-\-module\-dir\fR DIR (\fI/usr/local/lib/qpid/daemon\fP)
Load all shareable modules in this
directory
.TP
@@ -41,7 +45,7 @@ Don't load modules from module
directory
.SS "Broker Options:"
.TP
-\fB\-\-data\-dir\fR DIR
+\fB\-\-data\-dir\fR DIR (/home/kpvdr/.qpidd)
Directory to contain persistent data
generated by the broker
.TP
@@ -53,11 +57,15 @@ or stored
\fB\-p\fR [ \fB\-\-port\fR ] PORT (5672)
Tells the broker to listen on PORT
.TP
-\fB\-\-worker\-threads\fR N (3)
-Sets the broker thread pool size
+\fB\-\-interface\fR <interface name>|<interface address>
+Which network interfaces to use to
+listen for incoming connections
.TP
-\fB\-\-max\-connections\fR N (500)
-Sets the maximum allowed connections
+\fB\-\-listen\-disable\fR <transport name>
+Transports to disable listening
+.TP
+\fB\-\-worker\-threads\fR N (5)
+Sets the broker thread pool size
.TP
\fB\-\-connection\-backlog\fR N (10)
Sets the connection backlog limit for
@@ -66,6 +74,10 @@ the server socket
\fB\-m\fR [ \fB\-\-mgmt\-enable\fR ] yes|no (1)
Enable Management
.TP
+\fB\-\-mgmt\-publish\fR yes|no (1)
+Enable Publish of Management Data ('no'
+implies query\-only)
+.TP
\fB\-\-mgmt\-qmf2\fR yes|no (1)
Enable broadcast of management
information over QMF v2
@@ -74,14 +86,14 @@ information over QMF v2
Enable broadcast of management
information over QMF v1
.TP
-\fB\-\-mgmt\-pub\-interval\fR SECONDS (10)
+\fB\-\-mgmt\-pub\-interval\fR SECONDS (10s)
Management Publish Interval
.TP
-\fB\-\-queue\-purge\-interval\fR SECONDS (600)
+\fB\-\-queue\-purge\-interval\fR SECONDS (600s)
Interval between attempts to purge any
expired messages from queues
.TP
-\fB\-\-auth\fR yes|no (1)
+\fB\-\-auth\fR yes|no (0)
Enable authentication, if disabled all
incoming connections will be trusted
.TP
@@ -100,21 +112,16 @@ Set TCP_NODELAY on TCP connections
Only accept connections that are
encrypted
.TP
-\fB\-\-known\-hosts\-url\fR URL or 'none'
+\fB\-\-known\-hosts\-url\fR URL or 'none' (none)
URL to send as 'known\-hosts' to clients
('none' implies empty list)
.TP
\fB\-\-sasl\-config\fR DIR
-gets sasl config info from nonstandard
-location
-.TP
-\fB\-\-max\-session\-rate\fR MESSAGES/S (0)
-Sets the maximum message rate per
-session (0=unlimited)
-.TP
-\fB\-\-async\-queue\-events\fR yes|no (0)
-Set Queue Events async, used for
-services like replication
+Allows SASL config path, if supported
+by platform, to be overridden. For
+default location on Linux, see Cyrus
+SASL documentation. There is no SASL
+config dir on Windows.
.TP
\fB\-\-default\-flow\-stop\-threshold\fR PERCENT (80)
Percent of queue's maximum capacity at
@@ -127,6 +134,30 @@ which flow control is de\-activated.
\fB\-\-default\-event\-threshold\-ratio\fR %age of limit (80)
The ratio of any specified queue limit
at which an event will be raised
+.TP
+\fB\-\-default\-message\-group\fR GROUP\-IDENTIFER (qpid.no\-group)
+Group identifier to assign to messages
+delivered to a message group queue that
+do not contain an identifier.
+.TP
+\fB\-\-enable\-timestamp\fR yes|no (0)
+Add current time to each received
+message.
+.TP
+\fB\-\-link\-maintenance\-interval\fR SECONDS (2s)
+Interval to check link health and
+re\-connect if need be
+.TP
+\fB\-\-link\-heartbeat\-interval\fR SECONDS (120s)
+Heartbeat interval for a federation
+link
+.TP
+\fB\-\-max\-negotiate\-time\fR MILLISECONDS (10000)
+Maximum time a connection can take to
+send the initial protocol negotiation
+.TP
+\fB\-\-federation\-tag\fR NAME
+Override the federation tag
.SS "Logging options:"
.TP
\fB\-t\fR [ \fB\-\-trace\fR ]
@@ -135,16 +166,62 @@ Enables all logging
\fB\-\-log\-enable\fR RULE (notice+)
Enables logging for selected levels and
components. RULE is in the form
-\&'LEVEL[+][:PATTERN]' Levels are one of:
+\&'LEVEL[+\-][:PATTERN]'
+LEVEL is one of:
.IP
trace debug info notice warning error
.IP
critical
+PATTERN is a logging category name, or
+a namespace\-qualified function name or
+name fragment. Logging category names
+are:
+.IP
+Security Broker Management Protocol
+.IP
+System HA Messaging Store Network Test
+Client Model Unspecified
For example:
-\&'\-\-log\-enable warning+' logs all
-warning, error and critical messages.
-\&'\-\-log\-enable debug:framing' logs debug
-messages from the framing namespace.
+\&'\-\-log\-enable warning+'
+logs all warning, error and critical
+messages.
+\&'\-\-log\-enable trace+:Broker'
+logs all category 'Broker' messages.
+\&'\-\-log\-enable debug:framing'
+logs debug messages from all functions
+with 'framing' in the namespace or
+function name.
+This option can be used multiple times
+.TP
+\fB\-\-log\-disable\fR RULE
+Disables logging for selected levels
+and components. RULE is in the form
+\&'LEVEL[+\-][:PATTERN]'
+LEVEL is one of:
+.IP
+trace debug info notice warning error
+.IP
+critical
+PATTERN is a logging category name, or
+a namespace\-qualified function name or
+name fragment. Logging category names
+are:
+.IP
+Security Broker Management Protocol
+.IP
+System HA Messaging Store Network Test
+Client Model Unspecified
+For example:
+\&'\-\-log\-disable warning\-'
+disables logging all warning, notice,
+info, debug, and trace messages.
+\&'\-\-log\-disable trace:Broker'
+disables all category 'Broker' trace
+messages.
+\&'\-\-log\-disable debug\-:qmf::'
+disables logging debug and trace
+messages from all functions with
+\&'qmf::' in the namespace.
This option can be used multiple times
.TP
\fB\-\-log\-time\fR yes|no (1)
@@ -164,8 +241,15 @@ Include thread ID in log messages
Include function signature in log
messages
.TP
+\fB\-\-log\-hires\-timestamp\fR yes|no (0)
+Use hi\-resolution timestamps in log
+messages
+.TP
+\fB\-\-log\-category\fR yes|no (1)
+Include category in log messages
+.TP
\fB\-\-log\-prefix\fR STRING
-Prefix to append to all log messages
+Prefix to prepend to all log messages
.SS "Logging sink options:"
.TP
\fB\-\-log\-to\-stderr\fR yes|no (1)
@@ -197,23 +281,47 @@ default in this mode.
The transport for which to return the
port
.TP
-\fB\-\-pid\-dir\fR DIR
-Directory where port\-specific PID file
-is stored
+\fB\-\-pid\-dir\fR DIR (/home/kpvdr/.qpidd)
+Directory where port\-specific PID file is
+stored
.TP
\fB\-w\fR [ \fB\-\-wait\fR ] SECONDS (600)
-Sets the maximum wait time to
-initialize the daemon. If the daemon
-fails to initialize, prints an error
-and returns 1
+Sets the maximum wait time to initialize
+or shutdown the daemon. If the daemon
+fails to initialize/shutdown, prints an
+error and returns 1
.TP
\fB\-c\fR [ \fB\-\-check\fR ]
-Prints the daemon's process ID to
-stdout and returns 0 if the daemon is
-running, otherwise returns 1
+Prints the daemon's process ID to stdout
+and returns 0 if the daemon is running,
+otherwise returns 1
.TP
\fB\-q\fR [ \fB\-\-quit\fR ]
Tells the daemon to shut down
+.TP
+\fB\-\-socket\-fd\fR FD
+File descriptor for tcp listening socket
+.SS "ACL Options:"
+.TP
+\fB\-\-acl\-file\fR FILE
+The policy file to load from, loaded from
+data dir
+.TP
+\fB\-\-connection\-limit\-per\-user\fR N (0)
+The maximum number of connections allowed
+per user. 0 implies no limit.
+.TP
+\fB\-\-max\-connections\fR N (500)
+The maximum combined number of connections
+allowed. 0 implies no limit.
+.TP
+\fB\-\-connection\-limit\-per\-ip\fR N (0)
+The maximum number of connections allowed
+per host IP address. 0 implies no limit.
+.TP
+\fB\-\-max\-queues\-per\-user\fR N (0)
+The maximum number of queues allowed per
+user. 0 implies no limit.
.SH ENVIRONMENT
.I QPID_<option>
.RS
diff --git a/qpid/cpp/src/linearstore.cmake b/qpid/cpp/src/linearstore.cmake
index c3946c1a8a..ddf70c75b9 100644
--- a/qpid/cpp/src/linearstore.cmake
+++ b/qpid/cpp/src/linearstore.cmake
@@ -75,37 +75,33 @@ if (BUILD_LINEARSTORE)
endif (NOT HAVE_UUID_H)
# Journal source files
- set (legacy_jrnl_SOURCES
- qpid/linearstore/jrnl/aio.cpp
- qpid/linearstore/jrnl/cvar.cpp
+ set (linear_jrnl_SOURCES
qpid/linearstore/jrnl/data_tok.cpp
qpid/linearstore/jrnl/deq_rec.cpp
qpid/linearstore/jrnl/enq_map.cpp
qpid/linearstore/jrnl/enq_rec.cpp
- qpid/linearstore/jrnl/fcntl.cpp
+ #qpid/linearstore/jrnl/fcntl.cpp
qpid/linearstore/jrnl/jcntl.cpp
qpid/linearstore/jrnl/jdir.cpp
qpid/linearstore/jrnl/jerrno.cpp
qpid/linearstore/jrnl/jexception.cpp
- qpid/linearstore/jrnl/jinf.cpp
+ #qpid/linearstore/jrnl/jinf.cpp
qpid/linearstore/jrnl/jrec.cpp
- qpid/linearstore/jrnl/lp_map.cpp
- qpid/linearstore/jrnl/lpmgr.cpp
+ #qpid/linearstore/jrnl/lp_map.cpp
+ #qpid/linearstore/jrnl/lpmgr.cpp
qpid/linearstore/jrnl/pmgr.cpp
qpid/linearstore/jrnl/rmgr.cpp
- qpid/linearstore/jrnl/rfc.cpp
- qpid/linearstore/jrnl/rrfc.cpp
- qpid/linearstore/jrnl/slock.cpp
- qpid/linearstore/jrnl/smutex.cpp
+ #qpid/linearstore/jrnl/rfc.cpp
+ #qpid/linearstore/jrnl/rrfc.cpp
qpid/linearstore/jrnl/time_ns.cpp
qpid/linearstore/jrnl/txn_map.cpp
qpid/linearstore/jrnl/txn_rec.cpp
qpid/linearstore/jrnl/wmgr.cpp
- qpid/linearstore/jrnl/wrfc.cpp
+ #qpid/linearstore/jrnl/wrfc.cpp
)
# linearstore source files
- set (legacy_store_SOURCES
+ set (linear_store_SOURCES
qpid/linearstore/StorePlugin.cpp
qpid/linearstore/BindingDbt.cpp
qpid/linearstore/BufferValue.cpp
@@ -119,14 +115,17 @@ if (BUILD_LINEARSTORE)
)
set (util_SOURCES
- qpid/linearstore/jrnl/utils/file_hdr.c
- qpid/linearstore/jrnl/utils/enq_hdr.c
qpid/linearstore/jrnl/utils/deq_hdr.c
+ qpid/linearstore/jrnl/utils/enq_hdr.c
+ qpid/linearstore/jrnl/utils/file_hdr.c
+ qpid/linearstore/jrnl/utils/rec_hdr.c
+ qpid/linearstore/jrnl/utils/rec_tail.c
+ qpid/linearstore/jrnl/utils/txn_hdr.c
)
# linearstore include directories
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
- set (legacy_include_DIRECTORIES
+ set (linear_include_DIRECTORIES
${dirs}
${CMAKE_CURRENT_SOURCE_DIR}/qpid/linearstore
)
@@ -147,16 +146,16 @@ if (BUILD_LINEARSTORE)
)
add_library (linearstore MODULE
- ${legacy_jrnl_SOURCES}
- ${legacy_store_SOURCES}
- ${legacy_qmf_SOURCES}
+ ${linear_jrnl_SOURCES}
+ ${linear_store_SOURCES}
+ ${linear_qmf_SOURCES}
)
set_target_properties (linearstore PROPERTIES
PREFIX ""
COMPILE_DEFINITIONS _IN_QPID_BROKER
OUTPUT_NAME linearstore
- INCLUDE_DIRECTORIES "${legacy_include_DIRECTORIES}"
+ INCLUDE_DIRECTORIES "${linear_include_DIRECTORIES}"
)
target_link_libraries (linearstore
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/aio.h b/qpid/cpp/src/qpid/linearstore/jrnl/aio.h
index b1de5f79f7..208a94dbec 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/aio.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/aio.h
@@ -19,23 +19,11 @@
*
*/
-/**
- * \file aio.h
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains an encapsulation of the libaio interface used
- * by the journal.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_AIO_H
#define QPID_LEGACYSTORE_JRNL_AIO_H
#include <libaio.h>
#include <cstring>
-#include <sys/types.h>
#include <string.h>
namespace mrg
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/aio_callback.h b/qpid/cpp/src/qpid/linearstore/jrnl/aio_callback.h
index 90249278a5..7c086d6857 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/aio_callback.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/aio_callback.h
@@ -19,22 +19,11 @@
*
*/
-/**
- * \file aio_callback.h
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains the definition for the AIO callback function
- * pointer.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_AIO_CALLBACK_H
#define QPID_LEGACYSTORE_JRNL_AIO_CALLBACK_H
+#include <stdint.h>
#include <vector>
-#include <sys/types.h>
namespace mrg
{
@@ -48,7 +37,7 @@ namespace journal
public:
virtual ~aio_callback() {}
virtual void wr_aio_cb(std::vector<data_tok*>& dtokl) = 0;
- virtual void rd_aio_cb(std::vector<u_int16_t>& pil) = 0;
+ virtual void rd_aio_cb(std::vector<uint16_t>& pil) = 0;
};
} // namespace journal
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/cvar.h b/qpid/cpp/src/qpid/linearstore/jrnl/cvar.h
index 0498e743a2..68c1e4ad3c 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/cvar.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/cvar.h
@@ -19,24 +19,14 @@
*
*/
-/**
- * \file cvar.h
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains a posix condition variable class.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_CVAR_H
#define QPID_LEGACYSTORE_JRNL_CVAR_H
#include <cstring>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
-#include "qpid/legacystore/jrnl/smutex.h"
-#include "qpid/legacystore/jrnl/time_ns.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/smutex.h"
+#include "qpid/linearstore/jrnl/time_ns.h"
#include <pthread.h>
#include <sstream>
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/data_tok.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/data_tok.cpp
index ce7206d80d..0f283fd4ea 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/data_tok.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/data_tok.cpp
@@ -19,23 +19,12 @@
*
*/
-/**
- * \file data_tok.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::data_tok (data block token).
- * See comments in file data_tok.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/data_tok.h"
+#include "qpid/linearstore/jrnl/data_tok.h"
#include <iomanip>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
-#include "qpid/legacystore/jrnl/slock.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/slock.h"
#include <sstream>
namespace mrg
@@ -45,7 +34,7 @@ namespace journal
// Static members
-u_int64_t data_tok::_cnt = 0;
+uint64_t data_tok::_cnt = 0;
smutex data_tok::_mutex;
data_tok::data_tok():
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/data_tok.h b/qpid/cpp/src/qpid/linearstore/jrnl/data_tok.h
index e35f069399..fce6093b0c 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/data_tok.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/data_tok.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file data_tok.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::data_tok (data block token).
- * See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_DATA_TOK_H
#define QPID_LEGACYSTORE_JRNL_DATA_TOK_H
@@ -43,10 +32,9 @@ class data_tok;
#include <cassert>
#include <cstddef>
-#include "qpid/legacystore/jrnl/smutex.h"
+#include "qpid/linearstore/jrnl/smutex.h"
#include <pthread.h>
#include <string>
-#include <sys/types.h>
namespace mrg
{
@@ -96,25 +84,25 @@ namespace journal
protected:
static smutex _mutex;
- static u_int64_t _cnt;
- u_int64_t _icnt;
+ static uint64_t _cnt;
+ uint64_t _icnt;
write_state _wstate; ///< Enqueued / dequeued state of data
read_state _rstate; ///< Read state of data
std::size_t _dsize; ///< Data size in bytes
- u_int32_t _dblks_written; ///< Data blocks read/written
- u_int32_t _dblks_read; ///< Data blocks read/written
- u_int32_t _pg_cnt; ///< Page counter - incr for each page containing part of data
- u_int16_t _fid; ///< FID containing header of enqueue record
- u_int64_t _rid; ///< RID of data set by enqueue operation
+ uint32_t _dblks_written; ///< Data blocks read/written
+ uint32_t _dblks_read; ///< Data blocks read/written
+ uint32_t _pg_cnt; ///< Page counter - incr for each page containing part of data
+ uint16_t _fid; ///< FID containing header of enqueue record
+ uint64_t _rid; ///< RID of data set by enqueue operation
std::string _xid; ///< XID set by enqueue operation
- u_int64_t _dequeue_rid; ///< RID of data set by dequeue operation
+ uint64_t _dequeue_rid; ///< RID of data set by dequeue operation
bool _external_rid; ///< Flag to indicate external setting of rid
public:
data_tok();
virtual ~data_tok();
- inline u_int64_t id() const { return _icnt; }
+ inline uint64_t id() const { return _icnt; }
inline write_state wstate() const { return _wstate; }
const char* wstate_str() const;
static const char* wstate_str(write_state wstate);
@@ -131,25 +119,25 @@ namespace journal
inline std::size_t dsize() const { return _dsize; }
inline void set_dsize(std::size_t dsize) { _dsize = dsize; }
- inline u_int32_t dblocks_written() const { return _dblks_written; }
- inline void incr_dblocks_written(u_int32_t dblks_written)
+ inline uint32_t dblocks_written() const { return _dblks_written; }
+ inline void incr_dblocks_written(uint32_t dblks_written)
{ _dblks_written += dblks_written; }
- inline void set_dblocks_written(u_int32_t dblks_written) { _dblks_written = dblks_written; }
-
- inline u_int32_t dblocks_read() const { return _dblks_read; }
- inline void incr_dblocks_read(u_int32_t dblks_read) { _dblks_read += dblks_read; }
- inline void set_dblocks_read(u_int32_t dblks_read) { _dblks_read = dblks_read; }
-
- inline u_int32_t pg_cnt() const { return _pg_cnt; }
- inline u_int32_t incr_pg_cnt() { return ++_pg_cnt; }
- inline u_int32_t decr_pg_cnt() { assert(_pg_cnt != 0); return --_pg_cnt; }
-
- inline u_int16_t fid() const { return _fid; }
- inline void set_fid(const u_int16_t fid) { _fid = fid; }
- inline u_int64_t rid() const { return _rid; }
- inline void set_rid(const u_int64_t rid) { _rid = rid; }
- inline u_int64_t dequeue_rid() const {return _dequeue_rid; }
- inline void set_dequeue_rid(const u_int64_t rid) { _dequeue_rid = rid; }
+ inline void set_dblocks_written(uint32_t dblks_written) { _dblks_written = dblks_written; }
+
+ inline uint32_t dblocks_read() const { return _dblks_read; }
+ inline void incr_dblocks_read(uint32_t dblks_read) { _dblks_read += dblks_read; }
+ inline void set_dblocks_read(uint32_t dblks_read) { _dblks_read = dblks_read; }
+
+ inline uint32_t pg_cnt() const { return _pg_cnt; }
+ inline uint32_t incr_pg_cnt() { return ++_pg_cnt; }
+ inline uint32_t decr_pg_cnt() { assert(_pg_cnt != 0); return --_pg_cnt; }
+
+ inline uint16_t fid() const { return _fid; }
+ inline void set_fid(const uint16_t fid) { _fid = fid; }
+ inline uint64_t rid() const { return _rid; }
+ inline void set_rid(const uint64_t rid) { _rid = rid; }
+ inline uint64_t dequeue_rid() const {return _dequeue_rid; }
+ inline void set_dequeue_rid(const uint64_t rid) { _dequeue_rid = rid; }
inline bool external_rid() const { return _external_rid; }
inline void set_external_rid(const bool external_rid) { _external_rid = external_rid; }
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/deq_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/deq_hdr.h
deleted file mode 100644
index ae7081eac1..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/deq_hdr.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file deq_hdr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::deq_hdr (dequeue record),
- * used to dequeue a previously enqueued record.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_DEQ_HDR_H
-#define QPID_LEGACYSTORE_JRNL_DEQ_HDR_H
-
-#include <cstddef>
-#include "qpid/legacystore/jrnl/rec_hdr.h"
-
-namespace mrg
-{
-namespace journal
-{
-
-#pragma pack(1)
-
- /**
- * \brief Struct for dequeue record.
- *
- * Struct for dequeue record. If this record has a non-zero xidsize field (i.e., there is a
- * valid XID), then this header is followed by the XID of xidsize bytes and a rec_tail. If,
- * on the other hand, this record has a zero xidsize (i.e., there is no XID), then the rec_tail
- * is absent.
- *
- * Note that this record had its own rid distinct from the rid of the record it is dequeueing.
- * The rid field below is the rid of the dequeue record itself; the deq-rid field is the rid of a
- * previous enqueue record being dequeued by this record.
- *
- * Record header info in binary format (32 bytes):
- * <pre>
- * 0 7
- * +---+---+---+---+---+---+---+---+ -+
- * | magic | v | e | flags | |
- * +---+---+---+---+---+---+---+---+ | struct hdr
- * | rid | |
- * +---+---+---+---+---+---+---+---+ -+
- * | deq-rid |
- * +---+---+---+---+---+---+---+---+
- * | xidsize |
- * +---+---+---+---+---+---+---+---+
- * v = file version (If the format or encoding of this file changes, then this
- * number should be incremented)
- * e = endian flag, false (0x00) for little endian, true (0x01) for big endian
- * </pre>
- *
- * Note that journal files should be transferable between 32- and 64-bit
- * hardware of the same endianness, but not between hardware of opposite
- * entianness without some sort of binary conversion utility. Thus buffering
- * will be needed for types that change size between 32- and 64-bit compiles.
- */
- struct deq_hdr : rec_hdr
- {
- u_int64_t _deq_rid; ///< Record ID of dequeued record
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler0; ///< Big-endian filler for 32-bit size_t
-#endif
- std::size_t _xidsize; ///< XID size
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler0; ///< Little-endian filler for 32-bit size_t
-#endif
- static const u_int16_t DEQ_HDR_TXNCMPLCOMMIT_MASK = 0x10;
-
- /**
- * \brief Default constructor, which sets all values to 0.
- */
- inline deq_hdr(): rec_hdr(), _deq_rid(0),
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
- _xidsize(0)
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- , _filler0(0)
-#endif
- {}
-
- /**
- * \brief Convenience constructor which initializes values during construction.
- */
- inline deq_hdr(const u_int32_t magic, const u_int8_t version, const u_int64_t rid,
- const u_int64_t deq_rid, const std::size_t xidsize, const bool owi,
- const bool txn_coml_commit = false):
- rec_hdr(magic, version, rid, owi), _deq_rid(deq_rid),
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
- _xidsize(xidsize)
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- , _filler0(0)
-#endif
- { set_txn_coml_commit(txn_coml_commit); }
-
-
- inline bool is_txn_coml_commit() const { return _uflag & DEQ_HDR_TXNCMPLCOMMIT_MASK; }
-
- inline void set_txn_coml_commit(const bool commit)
- {
- _uflag = commit ? _uflag | DEQ_HDR_TXNCMPLCOMMIT_MASK :
- _uflag & (~DEQ_HDR_TXNCMPLCOMMIT_MASK);
- }
-
- /**
- * \brief Returns the size of the header in bytes.
- */
- inline static std::size_t size() { return sizeof(deq_hdr); }
- };
-
-#pragma pack()
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_DEQ_HDR_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/deq_rec.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/deq_rec.cpp
index f820c3c075..663431657c 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/deq_rec.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/deq_rec.cpp
@@ -30,15 +30,17 @@
* \author Kim van der Riet
*/
-#include "qpid/legacystore/jrnl/deq_rec.h"
+#include "qpid/linearstore/jrnl/deq_rec.h"
+#include "qpid/linearstore/jrnl/utils/deq_hdr.h"
+#include "qpid/linearstore/jrnl/utils/rec_tail.h"
#include <cassert>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <iomanip>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jexception.h"
#include <sstream>
namespace mrg
@@ -47,19 +49,26 @@ namespace journal
{
deq_rec::deq_rec():
- _deq_hdr(RHM_JDAT_DEQ_MAGIC, RHM_JDAT_VERSION, 0, 0, 0, false),
+// _deq_hdr(QLS_DEQ_MAGIC, QLS_JRNL_VERSION, 0, 0, 0, false),
_xidp(0),
- _buff(0),
- _deq_tail(_deq_hdr)
-{}
+ _buff(0)
+// _deq_tail(_deq_hdr)
+{
+ ::deq_hdr_init(&_deq_hdr, QLS_DEQ_MAGIC, QLS_JRNL_VERSION, 0, 0, 0, 0);
+ ::rec_tail_copy(&_deq_tail, &_deq_hdr._rhdr, 0);
+}
-deq_rec::deq_rec(const u_int64_t rid, const u_int64_t drid, const void* const xidp,
- const std::size_t xidlen, const bool owi, const bool txn_coml_commit):
- _deq_hdr(RHM_JDAT_DEQ_MAGIC, RHM_JDAT_VERSION, rid, drid, xidlen, owi, txn_coml_commit),
+deq_rec::deq_rec(const uint64_t rid, const uint64_t drid, const void* const xidp,
+ const std::size_t xidlen, const bool txn_coml_commit):
+// _deq_hdr(QLS_DEQ_MAGIC, QLS_JRNL_VERSION, rid, drid, xidlen, owi, txn_coml_commit),
_xidp(xidp),
- _buff(0),
- _deq_tail(_deq_hdr)
-{}
+ _buff(0)
+// _deq_tail(_deq_hdr)
+{
+ ::deq_hdr_init(&_deq_hdr, QLS_DEQ_MAGIC, QLS_JRNL_VERSION, 0, rid, drid, xidlen);
+ ::rec_tail_copy(&_deq_tail, &_deq_hdr._rhdr, 0);
+ ::set_txn_coml_commit(&_deq_hdr, txn_coml_commit);
+}
deq_rec::~deq_rec()
{
@@ -69,23 +78,23 @@ deq_rec::~deq_rec()
void
deq_rec::reset()
{
- _deq_hdr._rid = 0;
- _deq_hdr.set_owi(false);
- _deq_hdr.set_txn_coml_commit(false);
+ _deq_hdr._rhdr._rid = 0;
+// _deq_hdr.set_owi(false);
+ ::set_txn_coml_commit(&_deq_hdr, false);
_deq_hdr._deq_rid = 0;
_deq_hdr._xidsize = 0;
+ _deq_tail._checksum = 0;
_deq_tail._rid = 0;
_xidp = 0;
_buff = 0;
}
void
-deq_rec::reset(const u_int64_t rid, const u_int64_t drid, const void* const xidp,
- const std::size_t xidlen, const bool owi, const bool txn_coml_commit)
+deq_rec::reset(const uint64_t rid, const uint64_t drid, const void* const xidp,
+ const std::size_t xidlen, const bool txn_coml_commit)
{
- _deq_hdr._rid = rid;
- _deq_hdr.set_owi(owi);
- _deq_hdr.set_txn_coml_commit(txn_coml_commit);
+ _deq_hdr._rhdr._rid = rid;
+ ::set_txn_coml_commit(&_deq_hdr, txn_coml_commit);
_deq_hdr._deq_rid = drid;
_deq_hdr._xidsize = xidlen;
_deq_tail._rid = rid;
@@ -93,8 +102,8 @@ deq_rec::reset(const u_int64_t rid, const u_int64_t drid, const void* const xi
_buff = 0;
}
-u_int32_t
-deq_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+uint32_t
+deq_rec::encode(void* wptr, uint32_t rec_offs_dblks, uint32_t max_size_dblks)
{
assert(wptr != 0);
assert(max_size_dblks > 0);
@@ -205,8 +214,8 @@ deq_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
return size_dblks(wr_cnt);
}
-u_int32_t
-deq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+uint32_t
+deq_rec::decode(rec_hdr_t& h, void* rptr, uint32_t rec_offs_dblks, uint32_t max_size_dblks)
{
assert(rptr != 0);
assert(max_size_dblks > 0);
@@ -214,18 +223,18 @@ deq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
std::size_t rd_cnt = 0;
if (rec_offs_dblks) // Continuation of record on new page
{
- const u_int32_t hdr_xid_dblks = size_dblks(deq_hdr::size() + _deq_hdr._xidsize);
- const u_int32_t hdr_xid_tail_dblks = size_dblks(deq_hdr::size() + _deq_hdr._xidsize +
- rec_tail::size());
+ const uint32_t hdr_xid_dblks = size_dblks(sizeof(deq_hdr_t) + _deq_hdr._xidsize);
+ const uint32_t hdr_xid_tail_dblks = size_dblks(sizeof(deq_hdr_t) + _deq_hdr._xidsize +
+ sizeof(rec_tail_t));
const std::size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
if (hdr_xid_tail_dblks - rec_offs_dblks <= max_size_dblks)
{
// Remainder of xid fits within this page
- if (rec_offs - deq_hdr::size() < _deq_hdr._xidsize)
+ if (rec_offs - sizeof(deq_hdr_t) < _deq_hdr._xidsize)
{
// Part of xid still outstanding, copy remainder of xid and tail
- const std::size_t xid_offs = rec_offs - deq_hdr::size();
+ const std::size_t xid_offs = rec_offs - sizeof(deq_hdr_t);
const std::size_t xid_rem = _deq_hdr._xidsize - xid_offs;
std::memcpy((char*)_buff + xid_offs, rptr, xid_rem);
rd_cnt = xid_rem;
@@ -236,8 +245,8 @@ deq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
else
{
// Tail or part of tail only outstanding, complete tail
- const std::size_t tail_offs = rec_offs - deq_hdr::size() - _deq_hdr._xidsize;
- const std::size_t tail_rem = rec_tail::size() - tail_offs;
+ const std::size_t tail_offs = rec_offs - sizeof(deq_hdr_t) - _deq_hdr._xidsize;
+ const std::size_t tail_rem = sizeof(rec_tail_t) - tail_offs;
std::memcpy((char*)&_deq_tail + tail_offs, rptr, tail_rem);
chk_tail();
rd_cnt = tail_rem;
@@ -246,7 +255,7 @@ deq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
else if (hdr_xid_dblks - rec_offs_dblks <= max_size_dblks)
{
// Remainder of xid fits within this page, tail split
- const std::size_t xid_offs = rec_offs - deq_hdr::size();
+ const std::size_t xid_offs = rec_offs - sizeof(deq_hdr_t);
const std::size_t xid_rem = _deq_hdr._xidsize - xid_offs;
std::memcpy((char*)_buff + xid_offs, rptr, xid_rem);
rd_cnt += xid_rem;
@@ -261,30 +270,28 @@ deq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
{
// Remainder of xid split
const std::size_t xid_cp_size = (max_size_dblks * JRNL_DBLK_SIZE);
- std::memcpy((char*)_buff + rec_offs - deq_hdr::size(), rptr, xid_cp_size);
+ std::memcpy((char*)_buff + rec_offs - sizeof(deq_hdr_t), rptr, xid_cp_size);
rd_cnt += xid_cp_size;
}
}
else // Start of record
{
// Get and check header
- _deq_hdr.hdr_copy(h);
- rd_cnt = sizeof(rec_hdr);
- _deq_hdr._deq_rid = *(u_int64_t*)((char*)rptr + rd_cnt);
- rd_cnt += sizeof(u_int64_t);
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- rd_cnt += sizeof(u_int32_t); // Filler 0
-#endif
+ //_deq_hdr.hdr_copy(h);
+ ::rec_hdr_copy(&_deq_hdr._rhdr, &h);
+ rd_cnt = sizeof(rec_hdr_t);
+ _deq_hdr._deq_rid = *(uint64_t*)((char*)rptr + rd_cnt);
+ rd_cnt += sizeof(uint64_t);
_deq_hdr._xidsize = *(std::size_t*)((char*)rptr + rd_cnt);
- rd_cnt = _deq_hdr.size();
+ rd_cnt = sizeof(deq_hdr_t);
chk_hdr();
if (_deq_hdr._xidsize)
{
_buff = std::malloc(_deq_hdr._xidsize);
MALLOC_CHK(_buff, "_buff", "deq_rec", "decode");
- const u_int32_t hdr_xid_dblks = size_dblks(deq_hdr::size() + _deq_hdr._xidsize);
- const u_int32_t hdr_xid_tail_dblks = size_dblks(deq_hdr::size() + _deq_hdr._xidsize +
- rec_tail::size());
+ const uint32_t hdr_xid_dblks = size_dblks(sizeof(deq_hdr_t) + _deq_hdr._xidsize);
+ const uint32_t hdr_xid_tail_dblks = size_dblks(sizeof(deq_hdr_t) + _deq_hdr._xidsize +
+ sizeof(rec_tail_t));
// Check if record (header + xid + tail) fits within this page, we can check the
// tail before the expense of copying data to memory
@@ -322,18 +329,16 @@ deq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
}
bool
-deq_rec::rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs)
+deq_rec::rcv_decode(rec_hdr_t h, std::ifstream* ifsp, std::size_t& rec_offs)
{
if (rec_offs == 0)
{
- _deq_hdr.hdr_copy(h);
- ifsp->read((char*)&_deq_hdr._deq_rid, sizeof(u_int64_t));
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- ifsp->ignore(sizeof(u_int32_t)); // _filler0
-#endif
+ //_deq_hdr.hdr_copy(h);
+ ::rec_hdr_copy(&_deq_hdr._rhdr, &h);
+ ifsp->read((char*)&_deq_hdr._deq_rid, sizeof(uint64_t));
ifsp->read((char*)&_deq_hdr._xidsize, sizeof(std::size_t));
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- ifsp->ignore(sizeof(u_int32_t)); // _filler0
+#if defined(JRNL_32_BIT)
+ ifsp->ignore(sizeof(uint32_t)); // _filler0
#endif
rec_offs = sizeof(_deq_hdr);
// Read header, allocate (if req'd) for xid
@@ -360,14 +365,14 @@ deq_rec::rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs)
}
}
if (rec_offs < sizeof(_deq_hdr) +
- (_deq_hdr._xidsize ? _deq_hdr._xidsize + sizeof(rec_tail) : 0))
+ (_deq_hdr._xidsize ? _deq_hdr._xidsize + sizeof(rec_tail_t) : 0))
{
// Read tail (or continue reading tail)
std::size_t offs = rec_offs - sizeof(_deq_hdr) - _deq_hdr._xidsize;
- ifsp->read((char*)&_deq_tail + offs, sizeof(rec_tail) - offs);
+ ifsp->read((char*)&_deq_tail + offs, sizeof(rec_tail_t) - offs);
std::size_t size_read = ifsp->gcount();
rec_offs += size_read;
- if (size_read < sizeof(rec_tail) - offs)
+ if (size_read < sizeof(rec_tail_t) - offs)
{
assert(ifsp->eof());
// As we may have read past eof, turn off fail bit
@@ -399,9 +404,9 @@ std::string&
deq_rec::str(std::string& str) const
{
std::ostringstream oss;
- oss << "deq_rec: m=" << _deq_hdr._magic;
- oss << " v=" << (int)_deq_hdr._version;
- oss << " rid=" << _deq_hdr._rid;
+ oss << "deq_rec: m=" << _deq_hdr._rhdr._magic;
+ oss << " v=" << (int)_deq_hdr._rhdr._version;
+ oss << " rid=" << _deq_hdr._rhdr._rid;
oss << " drid=" << _deq_hdr._deq_rid;
if (_xidp)
oss << " xid=\"" << _xidp << "\"";
@@ -418,35 +423,35 @@ deq_rec::xid_size() const
std::size_t
deq_rec::rec_size() const
{
- return deq_hdr::size() + (_deq_hdr._xidsize ? _deq_hdr._xidsize + rec_tail::size() : 0);
+ return sizeof(deq_hdr_t) + (_deq_hdr._xidsize ? _deq_hdr._xidsize + sizeof(rec_tail_t) : 0);
}
void
deq_rec::chk_hdr() const
{
- jrec::chk_hdr(_deq_hdr);
- if (_deq_hdr._magic != RHM_JDAT_DEQ_MAGIC)
+ jrec::chk_hdr(_deq_hdr._rhdr);
+ if (_deq_hdr._rhdr._magic != QLS_DEQ_MAGIC)
{
std::ostringstream oss;
oss << std::hex << std::setfill('0');
- oss << "deq magic: rid=0x" << std::setw(16) << _deq_hdr._rid;
- oss << ": expected=0x" << std::setw(8) << RHM_JDAT_DEQ_MAGIC;
- oss << " read=0x" << std::setw(2) << (int)_deq_hdr._magic;
+ oss << "deq magic: rid=0x" << std::setw(16) << _deq_hdr._rhdr._rid;
+ oss << ": expected=0x" << std::setw(8) << QLS_DEQ_MAGIC;
+ oss << " read=0x" << std::setw(2) << (int)_deq_hdr._rhdr._magic;
throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "deq_rec", "chk_hdr");
}
}
void
-deq_rec::chk_hdr(u_int64_t rid) const
+deq_rec::chk_hdr(uint64_t rid) const
{
chk_hdr();
- jrec::chk_rid(_deq_hdr, rid);
+ jrec::chk_rid(_deq_hdr._rhdr, rid);
}
void
deq_rec::chk_tail() const
{
- jrec::chk_tail(_deq_tail, _deq_hdr);
+ jrec::chk_tail(_deq_tail, _deq_hdr._rhdr);
}
void
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/deq_rec.h b/qpid/cpp/src/qpid/linearstore/jrnl/deq_rec.h
index d870b658da..96415c65df 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/deq_rec.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/deq_rec.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file deq_rec.h
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains the code for the mrg::journal::deq_rec (journal dequeue
- * record) class. See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_DEQ_REQ_H
#define QPID_LEGACYSTORE_JRNL_DEQ_REQ_H
@@ -42,8 +31,8 @@ class deq_rec;
}
#include <cstddef>
-#include "qpid/legacystore/jrnl/deq_hdr.h"
-#include "qpid/legacystore/jrnl/jrec.h"
+#include "qpid/linearstore/jrnl/utils/deq_hdr.h"
+#include "qpid/linearstore/jrnl/jrec.h"
namespace mrg
{
@@ -57,33 +46,33 @@ namespace journal
class deq_rec : public jrec
{
private:
- deq_hdr _deq_hdr; ///< Dequeue header
+ deq_hdr_t _deq_hdr; ///< Dequeue header
const void* _xidp; ///< xid pointer for encoding (writing to disk)
void* _buff; ///< Pointer to buffer to receive data read from disk
- rec_tail _deq_tail; ///< Record tail, only encoded if XID is present
+ rec_tail_t _deq_tail; ///< Record tail, only encoded if XID is present
public:
// constructor used for read operations and xid will have memory allocated
deq_rec();
// constructor used for write operations, where xid already exists
- deq_rec(const u_int64_t rid, const u_int64_t drid, const void* const xidp,
- const std::size_t xidlen, const bool owi, const bool txn_coml_commit);
+ deq_rec(const uint64_t rid, const uint64_t drid, const void* const xidp,
+ const std::size_t xidlen, const bool txn_coml_commit);
virtual ~deq_rec();
// Prepare instance for use in reading data from journal
void reset();
// Prepare instance for use in writing data to journal
- void reset(const u_int64_t rid, const u_int64_t drid, const void* const xidp,
- const std::size_t xidlen, const bool owi, const bool txn_coml_commit);
- u_int32_t encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks);
- u_int32_t decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks,
- u_int32_t max_size_dblks);
+ void reset(const uint64_t rid, const uint64_t drid, const void* const xidp,
+ const std::size_t xidlen, const bool txn_coml_commit);
+ uint32_t encode(void* wptr, uint32_t rec_offs_dblks, uint32_t max_size_dblks);
+ uint32_t decode(rec_hdr_t& h, void* rptr, uint32_t rec_offs_dblks,
+ uint32_t max_size_dblks);
// Decode used for recover
- bool rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs);
+ bool rcv_decode(rec_hdr_t h, std::ifstream* ifsp, std::size_t& rec_offs);
- inline bool is_txn_coml_commit() const { return _deq_hdr.is_txn_coml_commit(); }
- inline u_int64_t rid() const { return _deq_hdr._rid; }
- inline u_int64_t deq_rid() const { return _deq_hdr._deq_rid; }
+ inline bool is_txn_coml_commit() const { return ::is_txn_coml_commit(&_deq_hdr); }
+ inline uint64_t rid() const { return _deq_hdr._rhdr._rid; }
+ inline uint64_t deq_rid() const { return _deq_hdr._deq_rid; }
std::size_t get_xid(void** const xidpp);
std::string& str(std::string& str) const;
inline std::size_t data_size() const { return 0; } // This record never carries data
@@ -92,7 +81,7 @@ namespace journal
private:
virtual void chk_hdr() const;
- virtual void chk_hdr(u_int64_t rid) const;
+ virtual void chk_hdr(uint64_t rid) const;
virtual void chk_tail() const;
virtual void clean();
}; // class deq_rec
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/enq_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/enq_hdr.h
deleted file mode 100644
index 0d1e6116be..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/enq_hdr.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file enq_hdr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::enq_hdr (enueue header),
- * used to start an enqueue record in the journal.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_ENQ_HDR_H
-#define QPID_LEGACYSTORE_JRNL_ENQ_HDR_H
-
-#include <cstddef>
-#include "qpid/legacystore/jrnl/rec_hdr.h"
-
-namespace mrg
-{
-namespace journal
-{
-
-#pragma pack(1)
-
- /**
- * \brief Struct for enqueue record.
- *
- * Struct for enqueue record. In addition to the common data, this header includes both the
- * xid and data blob sizes.
- *
- * This header precedes all enqueue data in journal files.
- *
- * Record header info in binary format (32 bytes):
- * <pre>
- * 0 7
- * +---+---+---+---+---+---+---+---+ -+
- * | magic | v | e | flags | |
- * +---+---+---+---+---+---+---+---+ | struct hdr
- * | rid | |
- * +---+---+---+---+---+---+---+---+ -+
- * | xidsize |
- * +---+---+---+---+---+---+---+---+
- * | dsize |
- * +---+---+---+---+---+---+---+---+
- * v = file version (If the format or encoding of this file changes, then this
- * number should be incremented)
- * e = endian flag, false (0x00) for little endian, true (0x01) for big endian
- * </pre>
- *
- * Note that journal files should be transferable between 32- and 64-bit
- * hardware of the same endianness, but not between hardware of opposite
- * entianness without some sort of binary conversion utility. Thus buffering
- * will be needed for types that change size between 32- and 64-bit compiles.
- */
- struct enq_hdr : rec_hdr
- {
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler0; ///< Big-endian filler for 32-bit size_t
-#endif
- std::size_t _xidsize; ///< XID size
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler0; ///< Little-endian filler for 32-bit size_t
-#endif
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler1; ///< Big-endian filler for 32-bit size_t
-#endif
- std::size_t _dsize; ///< Record data size
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler1; ///< Little-endian filler for 32-bit size_t
-#endif
- static const u_int16_t ENQ_HDR_TRANSIENT_MASK = 0x10;
- static const u_int16_t ENQ_HDR_EXTERNAL_MASK = 0x20;
-
- /**
- * \brief Default constructor, which sets all values to 0.
- */
- inline enq_hdr(): rec_hdr(),
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
- _xidsize(0),
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler1(0),
-#endif
- _dsize(0)
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- , _filler1(0)
-#endif
- {}
-
- /**
- * \brief Convenience constructor which initializes values during construction.
- */
- inline enq_hdr(const u_int32_t magic, const u_int8_t version, const u_int64_t rid,
- const std::size_t xidsize, const std::size_t dsize, const bool owi,
- const bool transient = false): rec_hdr(magic, version, rid, owi),
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
- _xidsize(xidsize),
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler1(0),
-#endif
- _dsize(dsize)
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- , _filler1(0)
-#endif
- { set_transient(transient); }
-
-
- inline bool is_transient() const { return _uflag & ENQ_HDR_TRANSIENT_MASK; }
-
- inline void set_transient(const bool transient)
- {
- _uflag = transient ? _uflag | ENQ_HDR_TRANSIENT_MASK :
- _uflag & (~ENQ_HDR_TRANSIENT_MASK);
- }
-
- inline bool is_external() const { return _uflag & ENQ_HDR_EXTERNAL_MASK; }
-
- inline void set_external(const bool external)
- {
- _uflag = external ? _uflag | ENQ_HDR_EXTERNAL_MASK :
- _uflag & (~ENQ_HDR_EXTERNAL_MASK);
- }
-
- /**
- * \brief Returns the size of the header in bytes.
- */
- inline static std::size_t size() { return sizeof(enq_hdr); }
- };
-
-#pragma pack()
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_ENQ_HDR_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/enq_map.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/enq_map.cpp
index d024b704a7..1ee65e6f72 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/enq_map.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/enq_map.cpp
@@ -19,22 +19,11 @@
*
*/
-/**
- * \file enq_map.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::enq_map (enqueue map). See
- * comments in file enq_map.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/enq_map.h"
+#include "qpid/linearstore/jrnl/enq_map.h"
#include <iomanip>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/slock.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/slock.h"
#include <sstream>
@@ -59,20 +48,20 @@ enq_map::enq_map():
enq_map::~enq_map() {}
void
-enq_map::set_num_jfiles(const u_int16_t num_jfiles)
+enq_map::set_num_jfiles(const uint16_t num_jfiles)
{
_pfid_enq_cnt.resize(num_jfiles, 0);
}
int16_t
-enq_map::insert_pfid(const u_int64_t rid, const u_int16_t pfid)
+enq_map::insert_pfid(const uint64_t rid, const uint16_t pfid)
{
return insert_pfid(rid, pfid, false);
}
int16_t
-enq_map::insert_pfid(const u_int64_t rid, const u_int16_t pfid, const bool locked)
+enq_map::insert_pfid(const uint64_t rid, const uint16_t pfid, const bool locked)
{
std::pair<emap_itr, bool> ret;
emap_data_struct rec(pfid, locked);
@@ -87,7 +76,7 @@ enq_map::insert_pfid(const u_int64_t rid, const u_int16_t pfid, const bool locke
}
int16_t
-enq_map::get_pfid(const u_int64_t rid)
+enq_map::get_pfid(const uint64_t rid)
{
slock s(_mutex);
emap_itr itr = _map.find(rid);
@@ -99,7 +88,7 @@ enq_map::get_pfid(const u_int64_t rid)
}
int16_t
-enq_map::get_remove_pfid(const u_int64_t rid, const bool txn_flag)
+enq_map::get_remove_pfid(const uint64_t rid, const bool txn_flag)
{
slock s(_mutex);
emap_itr itr = _map.find(rid);
@@ -107,14 +96,14 @@ enq_map::get_remove_pfid(const u_int64_t rid, const bool txn_flag)
return EMAP_RID_NOT_FOUND;
if (itr->second._lock && !txn_flag) // locked, but not a commit/abort
return EMAP_LOCKED;
- u_int16_t pfid = itr->second._pfid;
+ uint16_t pfid = itr->second._pfid;
_map.erase(itr);
_pfid_enq_cnt.at(pfid)--;
return pfid;
}
bool
-enq_map::is_enqueued(const u_int64_t rid, bool ignore_lock)
+enq_map::is_enqueued(const uint64_t rid, bool ignore_lock)
{
slock s(_mutex);
emap_itr itr = _map.find(rid);
@@ -126,7 +115,7 @@ enq_map::is_enqueued(const u_int64_t rid, bool ignore_lock)
}
int16_t
-enq_map::lock(const u_int64_t rid)
+enq_map::lock(const uint64_t rid)
{
slock s(_mutex);
emap_itr itr = _map.find(rid);
@@ -137,7 +126,7 @@ enq_map::lock(const u_int64_t rid)
}
int16_t
-enq_map::unlock(const u_int64_t rid)
+enq_map::unlock(const uint64_t rid)
{
slock s(_mutex);
emap_itr itr = _map.find(rid);
@@ -148,7 +137,7 @@ enq_map::unlock(const u_int64_t rid)
}
int16_t
-enq_map::is_locked(const u_int64_t rid)
+enq_map::is_locked(const uint64_t rid)
{
slock s(_mutex);
emap_itr itr = _map.find(rid);
@@ -158,7 +147,7 @@ enq_map::is_locked(const u_int64_t rid)
}
void
-enq_map::rid_list(std::vector<u_int64_t>& rv)
+enq_map::rid_list(std::vector<uint64_t>& rv)
{
rv.clear();
{
@@ -169,7 +158,7 @@ enq_map::rid_list(std::vector<u_int64_t>& rv)
}
void
-enq_map::pfid_list(std::vector<u_int16_t>& fv)
+enq_map::pfid_list(std::vector<uint16_t>& fv)
{
fv.clear();
{
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/enq_map.h b/qpid/cpp/src/qpid/linearstore/jrnl/enq_map.h
index 75404afebe..603993ce59 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/enq_map.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/enq_map.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file enq_map.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::enq_map (enqueue map).
- * See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_ENQ_MAP_H
#define QPID_LEGACYSTORE_JRNL_ENQ_MAP_H
@@ -41,8 +30,8 @@ class enq_map;
}
}
-#include "qpid/legacystore/jrnl/jexception.h"
-#include "qpid/legacystore/jrnl/smutex.h"
+#include "qpid/linearstore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/smutex.h"
#include <map>
#include <pthread.h>
#include <vector>
@@ -87,38 +76,38 @@ namespace journal
struct emap_data_struct
{
- u_int16_t _pfid;
+ uint16_t _pfid;
bool _lock;
- emap_data_struct(const u_int16_t pfid, const bool lock) : _pfid(pfid), _lock(lock) {}
+ emap_data_struct(const uint16_t pfid, const bool lock) : _pfid(pfid), _lock(lock) {}
};
- typedef std::pair<u_int64_t, emap_data_struct> emap_param;
- typedef std::map<u_int64_t, emap_data_struct> emap;
+ typedef std::pair<uint64_t, emap_data_struct> emap_param;
+ typedef std::map<uint64_t, emap_data_struct> emap;
typedef emap::iterator emap_itr;
emap _map;
smutex _mutex;
- std::vector<u_int32_t> _pfid_enq_cnt;
+ std::vector<uint32_t> _pfid_enq_cnt;
public:
enq_map();
virtual ~enq_map();
- void set_num_jfiles(const u_int16_t num_jfiles);
- inline u_int32_t get_enq_cnt(const u_int16_t pfid) const { return _pfid_enq_cnt.at(pfid); };
+ void set_num_jfiles(const uint16_t num_jfiles);
+ inline uint32_t get_enq_cnt(const uint16_t pfid) const { return _pfid_enq_cnt.at(pfid); };
- int16_t insert_pfid(const u_int64_t rid, const u_int16_t pfid); // 0=ok; -3=duplicate rid;
- int16_t insert_pfid(const u_int64_t rid, const u_int16_t pfid, const bool locked); // 0=ok; -3=duplicate rid;
- int16_t get_pfid(const u_int64_t rid); // >=0=pfid; -1=rid not found; -2=locked
- int16_t get_remove_pfid(const u_int64_t rid, const bool txn_flag = false); // >=0=pfid; -1=rid not found; -2=locked
- bool is_enqueued(const u_int64_t rid, bool ignore_lock = false);
- int16_t lock(const u_int64_t rid); // 0=ok; -1=rid not found
- int16_t unlock(const u_int64_t rid); // 0=ok; -1=rid not found
- int16_t is_locked(const u_int64_t rid); // 1=true; 0=false; -1=rid not found
+ int16_t insert_pfid(const uint64_t rid, const uint16_t pfid); // 0=ok; -3=duplicate rid;
+ int16_t insert_pfid(const uint64_t rid, const uint16_t pfid, const bool locked); // 0=ok; -3=duplicate rid;
+ int16_t get_pfid(const uint64_t rid); // >=0=pfid; -1=rid not found; -2=locked
+ int16_t get_remove_pfid(const uint64_t rid, const bool txn_flag = false); // >=0=pfid; -1=rid not found; -2=locked
+ bool is_enqueued(const uint64_t rid, bool ignore_lock = false);
+ int16_t lock(const uint64_t rid); // 0=ok; -1=rid not found
+ int16_t unlock(const uint64_t rid); // 0=ok; -1=rid not found
+ int16_t is_locked(const uint64_t rid); // 1=true; 0=false; -1=rid not found
inline void clear() { _map.clear(); }
inline bool empty() const { return _map.empty(); }
- inline u_int32_t size() const { return u_int32_t(_map.size()); }
- void rid_list(std::vector<u_int64_t>& rv);
- void pfid_list(std::vector<u_int16_t>& fv);
+ inline uint32_t size() const { return uint32_t(_map.size()); }
+ void rid_list(std::vector<uint64_t>& rv);
+ void pfid_list(std::vector<uint16_t>& fv);
};
} // namespace journal
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/enq_rec.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/enq_rec.cpp
index 468599836b..d9c3896929 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/enq_rec.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/enq_rec.cpp
@@ -19,26 +19,15 @@
*
*/
-/**
- * \file enq_rec.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains the code for the mrg::journal::enq_rec (journal enqueue
- * record) class. See comments in file enq_rec.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/enq_rec.h"
+#include "qpid/linearstore/jrnl/enq_rec.h"
#include <cassert>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <iomanip>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jexception.h"
#include <sstream>
namespace mrg
@@ -49,23 +38,30 @@ namespace journal
// Constructor used for read operations, where buf contains preallocated space to receive data.
enq_rec::enq_rec():
jrec(), // superclass
- _enq_hdr(RHM_JDAT_ENQ_MAGIC, RHM_JDAT_VERSION, 0, 0, 0, false, false),
+ //_enq_hdr(QLS_ENQ_MAGIC, QLS_JRNL_VERSION, 0, 0, 0, false, false),
_xidp(0),
_data(0),
- _buff(0),
- _enq_tail(_enq_hdr)
-{}
+ _buff(0)
+ //_enq_tail(_enq_hdr)
+{
+ ::enq_hdr_init(&_enq_hdr, QLS_ENQ_MAGIC, QLS_JRNL_VERSION, 0, 0, 0, false);
+ ::rec_tail_copy(&_enq_tail, &_enq_hdr._rhdr, 0);
+}
// Constructor used for transactional write operations, where dbuf contains data to be written.
-enq_rec::enq_rec(const u_int64_t rid, const void* const dbuf, const std::size_t dlen,
- const void* const xidp, const std::size_t xidlen, const bool owi, const bool transient):
+enq_rec::enq_rec(const uint64_t rid, const void* const dbuf, const std::size_t dlen,
+ const void* const xidp, const std::size_t xidlen, const bool transient):
jrec(), // superclass
- _enq_hdr(RHM_JDAT_ENQ_MAGIC, RHM_JDAT_VERSION, rid, xidlen, dlen, owi, transient),
+ //_enq_hdr(QLS_ENQ_MAGIC, QLS_JRNL_VERSION, rid, xidlen, dlen, owi, transient),
_xidp(xidp),
_data(dbuf),
- _buff(0),
- _enq_tail(_enq_hdr)
-{}
+ _buff(0)
+ //_enq_tail(_enq_hdr)
+{
+ ::enq_hdr_init(&_enq_hdr, QLS_ENQ_MAGIC, QLS_JRNL_VERSION, 0, rid, xidlen, dlen);
+ ::rec_tail_copy(&_enq_tail, &_enq_hdr._rhdr, 0);
+ ::set_enq_transient(&_enq_hdr, transient);
+}
enq_rec::~enq_rec()
{
@@ -77,9 +73,8 @@ enq_rec::~enq_rec()
void
enq_rec::reset()
{
- _enq_hdr._rid = 0;
- _enq_hdr.set_owi(false);
- _enq_hdr.set_transient(false);
+ _enq_hdr._rhdr._rid = 0;
+ ::set_enq_transient(&_enq_hdr, false);
_enq_hdr._xidsize = 0;
_enq_hdr._dsize = 0;
_xidp = 0;
@@ -91,14 +86,13 @@ enq_rec::reset()
// Prepare instance for use in writing transactional data to journal, where dbuf contains data to
// be written.
void
-enq_rec::reset(const u_int64_t rid, const void* const dbuf, const std::size_t dlen,
- const void* const xidp, const std::size_t xidlen, const bool owi, const bool transient,
+enq_rec::reset(const uint64_t rid, const void* const dbuf, const std::size_t dlen,
+ const void* const xidp, const std::size_t xidlen, const bool transient,
const bool external)
{
- _enq_hdr._rid = rid;
- _enq_hdr.set_owi(owi);
- _enq_hdr.set_transient(transient);
- _enq_hdr.set_external(external);
+ _enq_hdr._rhdr._rid = rid;
+ ::set_enq_transient(&_enq_hdr, transient);
+ ::set_enq_external(&_enq_hdr, external);
_enq_hdr._xidsize = xidlen;
_enq_hdr._dsize = dlen;
_xidp = xidp;
@@ -107,8 +101,8 @@ enq_rec::reset(const u_int64_t rid, const void* const dbuf, const std::size_t dl
_enq_tail._rid = rid;
}
-u_int32_t
-enq_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+uint32_t
+enq_rec::encode(void* wptr, uint32_t rec_offs_dblks, uint32_t max_size_dblks)
{
assert(wptr != 0);
assert(max_size_dblks > 0);
@@ -134,7 +128,7 @@ enq_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
rem -= wsize;
}
rec_offs -= _enq_hdr._xidsize - wsize2;
- if (rem && !_enq_hdr.is_external())
+ if (rem && !::is_enq_external(&_enq_hdr))
{
wsize = _enq_hdr._dsize > rec_offs ? _enq_hdr._dsize - rec_offs : 0;
wsize2 = wsize;
@@ -176,7 +170,7 @@ enq_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
}
rec_offs -= _enq_hdr._xidsize - wsize;
wsize = _enq_hdr._dsize > rec_offs ? _enq_hdr._dsize - rec_offs : 0;
- if (wsize && !_enq_hdr.is_external())
+ if (wsize && !::is_enq_external(&_enq_hdr))
{
std::memcpy((char*)wptr + wr_cnt, (const char*)_data + rec_offs, wsize);
wr_cnt += wsize;
@@ -213,7 +207,7 @@ enq_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
wr_cnt += wsize;
rem -= wsize;
}
- if (rem && !_enq_hdr.is_external())
+ if (rem && !::is_enq_external(&_enq_hdr))
{
wsize = rem >= _enq_hdr._dsize ? _enq_hdr._dsize : rem;
std::memcpy((char*)wptr + wr_cnt, _data, wsize);
@@ -236,7 +230,7 @@ enq_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
std::memcpy((char*)wptr + wr_cnt, _xidp, _enq_hdr._xidsize);
wr_cnt += _enq_hdr._xidsize;
}
- if (!_enq_hdr.is_external())
+ if (!::is_enq_external(&_enq_hdr))
{
std::memcpy((char*)wptr + wr_cnt, _data, _enq_hdr._dsize);
wr_cnt += _enq_hdr._dsize;
@@ -252,8 +246,8 @@ enq_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
return size_dblks(wr_cnt);
}
-u_int32_t
-enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+uint32_t
+enq_rec::decode(rec_hdr_t& h, void* rptr, uint32_t rec_offs_dblks, uint32_t max_size_dblks)
{
assert(rptr != 0);
assert(max_size_dblks > 0);
@@ -261,13 +255,13 @@ enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
std::size_t rd_cnt = 0;
if (rec_offs_dblks) // Continuation of record on new page
{
- const u_int32_t hdr_xid_data_size = enq_hdr::size() + _enq_hdr._xidsize +
- (_enq_hdr.is_external() ? 0 : _enq_hdr._dsize);
- const u_int32_t hdr_xid_data_tail_size = hdr_xid_data_size + rec_tail::size();
- const u_int32_t hdr_data_dblks = size_dblks(hdr_xid_data_size);
- const u_int32_t hdr_tail_dblks = size_dblks(hdr_xid_data_tail_size);
+ const uint32_t hdr_xid_data_size = sizeof(enq_hdr_t) + _enq_hdr._xidsize +
+ (::is_enq_external(&_enq_hdr) ? 0 : _enq_hdr._dsize);
+ const uint32_t hdr_xid_data_tail_size = hdr_xid_data_size + sizeof(rec_tail_t);
+ const uint32_t hdr_data_dblks = size_dblks(hdr_xid_data_size);
+ const uint32_t hdr_tail_dblks = size_dblks(hdr_xid_data_tail_size);
const std::size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
- const std::size_t offs = rec_offs - enq_hdr::size();
+ const std::size_t offs = rec_offs - sizeof(enq_hdr_t);
if (hdr_tail_dblks - rec_offs_dblks <= max_size_dblks)
{
@@ -282,7 +276,7 @@ enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
chk_tail();
rd_cnt += sizeof(_enq_tail);
}
- else if (offs < _enq_hdr._xidsize + _enq_hdr._dsize && !_enq_hdr.is_external())
+ else if (offs < _enq_hdr._xidsize + _enq_hdr._dsize && !::is_enq_external(&_enq_hdr))
{
// some data still outstanding, copy remainder of data and tail
const std::size_t data_offs = offs - _enq_hdr._xidsize;
@@ -296,9 +290,9 @@ enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
else
{
// Tail or part of tail only outstanding, complete tail
- const std::size_t tail_offs = rec_offs - enq_hdr::size() - _enq_hdr._xidsize -
+ const std::size_t tail_offs = rec_offs - sizeof(enq_hdr_t) - _enq_hdr._xidsize -
_enq_hdr._dsize;
- const std::size_t tail_rem = rec_tail::size() - tail_offs;
+ const std::size_t tail_rem = sizeof(rec_tail_t) - tail_offs;
std::memcpy((char*)&_enq_tail + tail_offs, rptr, tail_rem);
chk_tail();
rd_cnt = tail_rem;
@@ -329,7 +323,7 @@ enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
std::memcpy((char*)_buff + offs, rptr, rem);
rd_cnt += rem;
}
- else if (offs < _enq_hdr._xidsize + _enq_hdr._dsize && !_enq_hdr.is_external()) // 2
+ else if (offs < _enq_hdr._xidsize + _enq_hdr._dsize && !::is_enq_external(&_enq_hdr)) // 2
{
// some data still outstanding, copy remainder of data
const std::size_t data_offs = offs - _enq_hdr._xidsize;
@@ -355,33 +349,28 @@ enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
else // Start of record
{
// Get and check header
- _enq_hdr.hdr_copy(h);
- rd_cnt = sizeof(rec_hdr);
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- rd_cnt += sizeof(u_int32_t); // Filler 0
-#endif
+ //_enq_hdr.hdr_copy(h);
+ ::rec_hdr_copy(&_enq_hdr._rhdr, &h);
+ rd_cnt = sizeof(rec_hdr_t);
_enq_hdr._xidsize = *(std::size_t*)((char*)rptr + rd_cnt);
rd_cnt += sizeof(std::size_t);
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- rd_cnt += sizeof(u_int32_t); // Filler 0
-#endif
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- rd_cnt += sizeof(u_int32_t); // Filler 1
+#if defined(JRNL_32_BIT)
+ rd_cnt += sizeof(uint32_t); // Filler 0
#endif
_enq_hdr._dsize = *(std::size_t*)((char*)rptr + rd_cnt);
- rd_cnt = _enq_hdr.size();
+ rd_cnt = sizeof(enq_hdr_t);
chk_hdr();
- if (_enq_hdr._xidsize + (_enq_hdr.is_external() ? 0 : _enq_hdr._dsize))
+ if (_enq_hdr._xidsize + (::is_enq_external(&_enq_hdr) ? 0 : _enq_hdr._dsize))
{
- _buff = std::malloc(_enq_hdr._xidsize + (_enq_hdr.is_external() ? 0 : _enq_hdr._dsize));
+ _buff = std::malloc(_enq_hdr._xidsize + (::is_enq_external(&_enq_hdr) ? 0 : _enq_hdr._dsize));
MALLOC_CHK(_buff, "_buff", "enq_rec", "decode");
- const u_int32_t hdr_xid_size = enq_hdr::size() + _enq_hdr._xidsize;
- const u_int32_t hdr_xid_data_size = hdr_xid_size + (_enq_hdr.is_external() ? 0 : _enq_hdr._dsize);
- const u_int32_t hdr_xid_data_tail_size = hdr_xid_data_size + rec_tail::size();
- const u_int32_t hdr_xid_dblks = size_dblks(hdr_xid_size);
- const u_int32_t hdr_data_dblks = size_dblks(hdr_xid_data_size);
- const u_int32_t hdr_tail_dblks = size_dblks(hdr_xid_data_tail_size);
+ const uint32_t hdr_xid_size = sizeof(enq_hdr_t) + _enq_hdr._xidsize;
+ const uint32_t hdr_xid_data_size = hdr_xid_size + (::is_enq_external(&_enq_hdr) ? 0 : _enq_hdr._dsize);
+ const uint32_t hdr_xid_data_tail_size = hdr_xid_data_size + sizeof(rec_tail_t);
+ const uint32_t hdr_xid_dblks = size_dblks(hdr_xid_size);
+ const uint32_t hdr_data_dblks = size_dblks(hdr_xid_data_size);
+ const uint32_t hdr_tail_dblks = size_dblks(hdr_xid_data_tail_size);
// Check if record (header + data + tail) fits within this page, we can check the
// tail before the expense of copying data to memory
if (hdr_tail_dblks <= max_size_dblks)
@@ -392,7 +381,7 @@ enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
std::memcpy(_buff, (char*)rptr + rd_cnt, _enq_hdr._xidsize);
rd_cnt += _enq_hdr._xidsize;
}
- if (_enq_hdr._dsize && !_enq_hdr.is_external())
+ if (_enq_hdr._dsize && !::is_enq_external(&_enq_hdr))
{
std::memcpy((char*)_buff + _enq_hdr._xidsize, (char*)rptr + rd_cnt,
_enq_hdr._dsize);
@@ -410,7 +399,7 @@ enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
std::memcpy(_buff, (char*)rptr + rd_cnt, _enq_hdr._xidsize);
rd_cnt += _enq_hdr._xidsize;
}
- if (_enq_hdr._dsize && !_enq_hdr.is_external())
+ if (_enq_hdr._dsize && !::is_enq_external(&_enq_hdr))
{
std::memcpy((char*)_buff + _enq_hdr._xidsize, (char*)rptr + rd_cnt,
_enq_hdr._dsize);
@@ -431,7 +420,7 @@ enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
std::memcpy(_buff, (char*)rptr + rd_cnt, _enq_hdr._xidsize);
rd_cnt += _enq_hdr._xidsize;
}
- if (_enq_hdr._dsize && !_enq_hdr.is_external())
+ if (_enq_hdr._dsize && !::is_enq_external(&_enq_hdr))
{
const std::size_t data_cp_size = (max_size_dblks * JRNL_DBLK_SIZE) - rd_cnt;
std::memcpy((char*)_buff + _enq_hdr._xidsize, (char*)rptr + rd_cnt, data_cp_size);
@@ -451,25 +440,20 @@ enq_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
}
bool
-enq_rec::rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs)
+enq_rec::rcv_decode(rec_hdr_t h, std::ifstream* ifsp, std::size_t& rec_offs)
{
if (rec_offs == 0)
{
// Read header, allocate (if req'd) for xid
- _enq_hdr.hdr_copy(h);
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- ifsp->ignore(sizeof(u_int32_t)); // _filler0
-#endif
+ //_enq_hdr.hdr_copy(h);
+ ::rec_hdr_copy(&_enq_hdr._rhdr, &h);
ifsp->read((char*)&_enq_hdr._xidsize, sizeof(std::size_t));
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- ifsp->ignore(sizeof(u_int32_t)); // _filler0
-#endif
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- ifsp->ignore(sizeof(u_int32_t)); // _filler1
+#if defined(JRNL_32_BIT)
+ ifsp->ignore(sizeof(uint32_t)); // _filler0
#endif
ifsp->read((char*)&_enq_hdr._dsize, sizeof(std::size_t));
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- ifsp->ignore(sizeof(u_int32_t)); // _filler1
+#if defined(JRNL_32_BIT)
+ ifsp->ignore(sizeof(uint32_t)); // _filler1
#endif
rec_offs = sizeof(_enq_hdr);
if (_enq_hdr._xidsize)
@@ -494,7 +478,7 @@ enq_rec::rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs)
return false;
}
}
- if (!_enq_hdr.is_external())
+ if (!::is_enq_external(&_enq_hdr))
{
if (rec_offs < sizeof(_enq_hdr) + _enq_hdr._xidsize + _enq_hdr._dsize)
{
@@ -514,16 +498,16 @@ enq_rec::rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs)
}
}
if (rec_offs < sizeof(_enq_hdr) + _enq_hdr._xidsize +
- (_enq_hdr.is_external() ? 0 : _enq_hdr._dsize) + sizeof(rec_tail))
+ (::is_enq_external(&_enq_hdr) ? 0 : _enq_hdr._dsize) + sizeof(rec_tail_t))
{
// Read tail (or continue reading tail)
std::size_t offs = rec_offs - sizeof(_enq_hdr) - _enq_hdr._xidsize;
- if (!_enq_hdr.is_external())
+ if (!::is_enq_external(&_enq_hdr))
offs -= _enq_hdr._dsize;
- ifsp->read((char*)&_enq_tail + offs, sizeof(rec_tail) - offs);
+ ifsp->read((char*)&_enq_tail + offs, sizeof(rec_tail_t) - offs);
std::size_t size_read = ifsp->gcount();
rec_offs += size_read;
- if (size_read < sizeof(rec_tail) - offs)
+ if (size_read < sizeof(rec_tail_t) - offs)
{
assert(ifsp->eof());
// As we may have read past eof, turn off fail bit
@@ -558,7 +542,7 @@ enq_rec::get_data(void** const datapp)
*datapp = 0;
return 0;
}
- if (_enq_hdr.is_external())
+ if (::is_enq_external(&_enq_hdr))
*datapp = 0;
else
*datapp = (void*)((char*)_buff + _enq_hdr._xidsize);
@@ -569,9 +553,9 @@ std::string&
enq_rec::str(std::string& str) const
{
std::ostringstream oss;
- oss << "enq_rec: m=" << _enq_hdr._magic;
- oss << " v=" << (int)_enq_hdr._version;
- oss << " rid=" << _enq_hdr._rid;
+ oss << "enq_rec: m=" << _enq_hdr._rhdr._magic;
+ oss << " v=" << (int)_enq_hdr._rhdr._version;
+ oss << " rid=" << _enq_hdr._rhdr._rid;
if (_xidp)
oss << " xid=\"" << _xidp << "\"";
oss << " len=" << _enq_hdr._dsize;
@@ -582,50 +566,50 @@ enq_rec::str(std::string& str) const
std::size_t
enq_rec::rec_size() const
{
- return rec_size(_enq_hdr._xidsize, _enq_hdr._dsize, _enq_hdr.is_external());
+ return rec_size(_enq_hdr._xidsize, _enq_hdr._dsize, ::is_enq_external(&_enq_hdr));
}
std::size_t
enq_rec::rec_size(const std::size_t xidsize, const std::size_t dsize, const bool external)
{
if (external)
- return enq_hdr::size() + xidsize + rec_tail::size();
- return enq_hdr::size() + xidsize + dsize + rec_tail::size();
+ return sizeof(enq_hdr_t) + xidsize + sizeof(rec_tail_t);
+ return sizeof(enq_hdr_t) + xidsize + dsize + sizeof(rec_tail_t);
}
void
-enq_rec::set_rid(const u_int64_t rid)
+enq_rec::set_rid(const uint64_t rid)
{
- _enq_hdr._rid = rid;
+ _enq_hdr._rhdr._rid = rid;
_enq_tail._rid = rid;
}
void
enq_rec::chk_hdr() const
{
- jrec::chk_hdr(_enq_hdr);
- if (_enq_hdr._magic != RHM_JDAT_ENQ_MAGIC)
+ jrec::chk_hdr(_enq_hdr._rhdr);
+ if (_enq_hdr._rhdr._magic != QLS_ENQ_MAGIC)
{
std::ostringstream oss;
oss << std::hex << std::setfill('0');
- oss << "enq magic: rid=0x" << std::setw(16) << _enq_hdr._rid;
- oss << ": expected=0x" << std::setw(8) << RHM_JDAT_ENQ_MAGIC;
- oss << " read=0x" << std::setw(2) << (int)_enq_hdr._magic;
+ oss << "enq magic: rid=0x" << std::setw(16) << _enq_hdr._rhdr._rid;
+ oss << ": expected=0x" << std::setw(8) << QLS_ENQ_MAGIC;
+ oss << " read=0x" << std::setw(2) << (int)_enq_hdr._rhdr._magic;
throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "enq_rec", "chk_hdr");
}
}
void
-enq_rec::chk_hdr(u_int64_t rid) const
+enq_rec::chk_hdr(uint64_t rid) const
{
chk_hdr();
- jrec::chk_rid(_enq_hdr, rid);
+ jrec::chk_rid(_enq_hdr._rhdr, rid);
}
void
enq_rec::chk_tail() const
{
- jrec::chk_tail(_enq_tail, _enq_hdr);
+ jrec::chk_tail(_enq_tail, _enq_hdr._rhdr);
}
void
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/enq_rec.h b/qpid/cpp/src/qpid/linearstore/jrnl/enq_rec.h
index 805a96a1aa..0a2ac2ce69 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/enq_rec.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/enq_rec.h
@@ -19,15 +19,6 @@
*
*/
-/**
- * \file enq_rec.h
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains the code for the mrg::journal::enq_rec (journal enqueue
- * record) class. See class documentation for details.
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_ENQ_REC_H
#define QPID_LEGACYSTORE_JRNL_ENQ_REC_H
@@ -40,8 +31,8 @@ class enq_rec;
}
#include <cstddef>
-#include "qpid/legacystore/jrnl/enq_hdr.h"
-#include "qpid/legacystore/jrnl/jrec.h"
+#include "qpid/linearstore/jrnl/utils/enq_hdr.h"
+#include "qpid/linearstore/jrnl/jrec.h"
namespace mrg
{
@@ -55,11 +46,11 @@ namespace journal
class enq_rec : public jrec
{
private:
- enq_hdr _enq_hdr;
+ enq_hdr_t _enq_hdr;
const void* _xidp; ///< xid pointer for encoding (for writing to disk)
const void* _data; ///< Pointer to data to be written to disk
void* _buff; ///< Pointer to buffer to receive data read from disk
- rec_tail _enq_tail;
+ rec_tail_t _enq_tail;
public:
/**
@@ -70,8 +61,8 @@ namespace journal
/**
* \brief Constructor used for write operations, where mbuf contains data to be written.
*/
- enq_rec(const u_int64_t rid, const void* const dbuf, const std::size_t dlen,
- const void* const xidp, const std::size_t xidlen, const bool owi, const bool transient);
+ enq_rec(const uint64_t rid, const void* const dbuf, const std::size_t dlen,
+ const void* const xidp, const std::size_t xidlen, const bool transient);
/**
* \brief Destructor
@@ -81,31 +72,30 @@ namespace journal
// Prepare instance for use in reading data from journal, xid and data will be allocated
void reset();
// Prepare instance for use in writing data to journal
- void reset(const u_int64_t rid, const void* const dbuf, const std::size_t dlen,
- const void* const xidp, const std::size_t xidlen, const bool owi, const bool transient,
+ void reset(const uint64_t rid, const void* const dbuf, const std::size_t dlen,
+ const void* const xidp, const std::size_t xidlen, const bool transient,
const bool external);
- u_int32_t encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks);
- u_int32_t decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks,
- u_int32_t max_size_dblks);
+ uint32_t encode(void* wptr, uint32_t rec_offs_dblks, uint32_t max_size_dblks);
+ uint32_t decode(rec_hdr_t& h, void* rptr, uint32_t rec_offs_dblks, uint32_t max_size_dblks);
// Decode used for recover
- bool rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs);
+ bool rcv_decode(rec_hdr_t h, std::ifstream* ifsp, std::size_t& rec_offs);
std::size_t get_xid(void** const xidpp);
std::size_t get_data(void** const datapp);
- inline bool is_transient() const { return _enq_hdr.is_transient(); }
- inline bool is_external() const { return _enq_hdr.is_external(); }
+ inline bool is_transient() const { return ::is_enq_transient(&_enq_hdr); }
+ inline bool is_external() const { return ::is_enq_external(&_enq_hdr); }
std::string& str(std::string& str) const;
inline std::size_t data_size() const { return _enq_hdr._dsize; }
inline std::size_t xid_size() const { return _enq_hdr._xidsize; }
std::size_t rec_size() const;
static std::size_t rec_size(const std::size_t xidsize, const std::size_t dsize, const bool external);
- inline u_int64_t rid() const { return _enq_hdr._rid; }
- void set_rid(const u_int64_t rid);
+ inline uint64_t rid() const { return _enq_hdr._rhdr._rid; }
+ void set_rid(const uint64_t rid);
private:
void chk_hdr() const;
- void chk_hdr(u_int64_t rid) const;
+ void chk_hdr(uint64_t rid) const;
void chk_tail() const;
virtual void clean();
}; // class enq_rec
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/enums.h b/qpid/cpp/src/qpid/linearstore/jrnl/enums.h
index 169a13fa4d..bbb42f19f3 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/enums.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/enums.h
@@ -19,16 +19,6 @@
*
*/
-/**
- * \file enums.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing definitions for namespace mrg::journal enums.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_ENUMS_H
#define QPID_LEGACYSTORE_JRNL_ENUMS_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/fcntl.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/fcntl.cpp
deleted file mode 100644
index fbb176667e..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/fcntl.cpp
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file fcntl.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::fcntl (non-logging file
- * handle), used for controlling journal log files. See comments in file
- * fcntl.h for details.
- */
-
-#include "qpid/legacystore/jrnl/fcntl.h"
-
-#include <cerrno>
-#include <cstdlib>
-#include <cstring>
-#include <fcntl.h>
-#include <iomanip>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
-#include <sstream>
-#include <unistd.h>
-
-namespace mrg
-{
-namespace journal
-{
-
-fcntl::fcntl(const std::string& fbasename, const u_int16_t pfid, const u_int16_t lfid, const u_int32_t jfsize_sblks,
- const rcvdat* const ro):
- _fname(),
- _pfid(pfid),
- _lfid(lfid),
- _ffull_dblks(JRNL_SBLK_SIZE * (jfsize_sblks + 1)),
- _wr_fh(-1),
- _rec_enqcnt(0),
- _rd_subm_cnt_dblks(0),
- _rd_cmpl_cnt_dblks(0),
- _wr_subm_cnt_dblks(0),
- _wr_cmpl_cnt_dblks(0),
- _aio_cnt(0),
- _fhdr_wr_aio_outstanding(false)
-{
- initialize(fbasename, pfid, lfid, jfsize_sblks, ro);
- open_wr_fh();
-}
-
-fcntl::~fcntl()
-{
- close_wr_fh();
-}
-
-bool
-fcntl::reset(const rcvdat* const ro)
-{
- rd_reset();
- return wr_reset(ro);
-}
-
-void
-fcntl::rd_reset()
-{
- _rd_subm_cnt_dblks = 0;
- _rd_cmpl_cnt_dblks = 0;
-}
-
-bool
-fcntl::wr_reset(const rcvdat* const ro)
-{
- if (ro)
- {
- if (!ro->_jempty)
- {
- if (ro->_lfid == _pfid)
- {
- _wr_subm_cnt_dblks = ro->_eo/JRNL_DBLK_SIZE;
- _wr_cmpl_cnt_dblks = ro->_eo/JRNL_DBLK_SIZE;
- }
- else
- {
- _wr_subm_cnt_dblks = _ffull_dblks;
- _wr_cmpl_cnt_dblks = _ffull_dblks;
- }
- _rec_enqcnt = ro->_enq_cnt_list[_pfid];
- return true;
- }
- }
- // Journal overflow test - checks if the file to be reset still contains enqueued records
- // or outstanding aios
- if (_rec_enqcnt || _aio_cnt)
- return false;
- _wr_subm_cnt_dblks = 0;
- _wr_cmpl_cnt_dblks = 0;
- return true;
-}
-
-int
-fcntl::open_wr_fh()
-{
- if (_wr_fh < 0)
- {
- _wr_fh = ::open(_fname.c_str(), O_WRONLY | O_DIRECT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // 0644 -rw-r--r--
- if (_wr_fh < 0)
- {
- std::ostringstream oss;
- oss << "pfid=" << _pfid << " lfid=" << _lfid << " file=\"" << _fname << "\"" << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR_FCNTL_OPENWR, oss.str(), "fcntl", "open_fh");
- }
- }
- return _wr_fh;
-}
-
-void
-fcntl::close_wr_fh()
-{
- if (_wr_fh >= 0)
- {
- ::close(_wr_fh);
- _wr_fh = -1;
- }
-}
-
-u_int32_t
-fcntl::add_enqcnt(u_int32_t a)
-{
- _rec_enqcnt += a;
- return _rec_enqcnt;
-}
-
-u_int32_t
-fcntl::decr_enqcnt()
-{
- if (_rec_enqcnt == 0)
- {
- std::ostringstream oss;
- oss << "pfid=" << _pfid << " lfid=" << _lfid;
- throw jexception(jerrno::JERR__UNDERFLOW, oss.str(), "fcntl", "decr_enqcnt");
- }
- return --_rec_enqcnt;
-}
-
-u_int32_t
-fcntl::subtr_enqcnt(u_int32_t s)
-{
- if (_rec_enqcnt < s)
- {
- std::ostringstream oss;
- oss << "pfid=" << _pfid << " lfid=" << _lfid << " rec_enqcnt=" << _rec_enqcnt << " decr=" << s;
- throw jexception(jerrno::JERR__UNDERFLOW, oss.str(), "fcntl", "subtr_enqcnt");
- }
- _rec_enqcnt -= s;
- return _rec_enqcnt;
-}
-
-u_int32_t
-fcntl::add_rd_subm_cnt_dblks(u_int32_t a)
-{
- if (_rd_subm_cnt_dblks + a > _wr_subm_cnt_dblks)
- {
- std::ostringstream oss;
- oss << "pfid=" << _pfid << " lfid=" << _lfid << " rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks << " incr=" << a;
- oss << " wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
- throw jexception(jerrno::JERR_FCNTL_RDOFFSOVFL, oss.str(), "fcntl", "add_rd_subm_cnt_dblks");
- }
- _rd_subm_cnt_dblks += a;
- return _rd_subm_cnt_dblks;
-}
-
-u_int32_t
-fcntl::add_rd_cmpl_cnt_dblks(u_int32_t a)
-{
- if (_rd_cmpl_cnt_dblks + a > _rd_subm_cnt_dblks)
- {
- std::ostringstream oss;
- oss << "pfid=" << _pfid << " lfid=" << _lfid << " rd_cmpl_cnt_dblks=" << _rd_cmpl_cnt_dblks << " incr=" << a;
- oss << " rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks;
- throw jexception(jerrno::JERR_FCNTL_CMPLOFFSOVFL, oss.str(), "fcntl", "add_rd_cmpl_cnt_dblks");
- }
- _rd_cmpl_cnt_dblks += a;
- return _rd_cmpl_cnt_dblks;
-}
-
-u_int32_t
-fcntl::add_wr_subm_cnt_dblks(u_int32_t a)
-{
- if (_wr_subm_cnt_dblks + a > _ffull_dblks) // Allow for file header
- {
- std::ostringstream oss;
- oss << "pfid=" << _pfid << " lfid=" << _lfid << " wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks << " incr=" << a;
- oss << " fsize=" << _ffull_dblks << " dblks";
- throw jexception(jerrno::JERR_FCNTL_FILEOFFSOVFL, oss.str(), "fcntl", "add_wr_subm_cnt_dblks");
- }
- _wr_subm_cnt_dblks += a;
- return _wr_subm_cnt_dblks;
-}
-
-u_int32_t
-fcntl::add_wr_cmpl_cnt_dblks(u_int32_t a)
-{
- if (_wr_cmpl_cnt_dblks + a > _wr_subm_cnt_dblks)
- {
- std::ostringstream oss;
- oss << "pfid=" << _pfid << " lfid=" << _lfid << " wr_cmpl_cnt_dblks=" << _wr_cmpl_cnt_dblks << " incr=" << a;
- oss << " wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
- throw jexception(jerrno::JERR_FCNTL_CMPLOFFSOVFL, oss.str(), "fcntl", "add_wr_cmpl_cnt_dblks");
- }
- _wr_cmpl_cnt_dblks += a;
- return _wr_cmpl_cnt_dblks;
-}
-
-u_int16_t
-fcntl::decr_aio_cnt()
-{
- if(_aio_cnt == 0)
- {
- std::ostringstream oss;
- oss << "pfid=" << _pfid << " lfid=" << _lfid << " Decremented aio_cnt to below zero";
- throw jexception(jerrno::JERR__UNDERFLOW, oss.str(), "fcntl", "decr_aio_cnt");
- }
- return --_aio_cnt;
-}
-
-// Debug function
-const std::string
-fcntl::status_str() const
-{
- std::ostringstream oss;
- oss << "pfid=" << _pfid << " ws=" << _wr_subm_cnt_dblks << " wc=" << _wr_cmpl_cnt_dblks;
- oss << " rs=" << _rd_subm_cnt_dblks << " rc=" << _rd_cmpl_cnt_dblks;
- oss << " ec=" << _rec_enqcnt << " ac=" << _aio_cnt;
- return oss.str();
-}
-
-// Protected functions
-
-void
-fcntl::initialize(const std::string& fbasename, const u_int16_t pfid, const u_int16_t lfid, const u_int32_t jfsize_sblks,
- const rcvdat* const ro)
-{
- _pfid = pfid;
- _lfid = lfid;
- _fname = filename(fbasename, pfid);
-
-#ifdef RHM_JOWRITE
- // In test mode, only create file if it does not exist
- struct stat s;
- if (::stat(_fname.c_str(), &s))
- {
-#endif
- if (ro) // Recovery initialization: set counters only
- {
- if (!ro->_jempty)
- {
- // For last file only, set write counters to end of last record (the
- // continuation point); for all others, set to eof.
- if (ro->_lfid == _pfid)
- {
- _wr_subm_cnt_dblks = ro->_eo/JRNL_DBLK_SIZE;
- _wr_cmpl_cnt_dblks = ro->_eo/JRNL_DBLK_SIZE;
- }
- else
- {
- _wr_subm_cnt_dblks = _ffull_dblks;
- _wr_cmpl_cnt_dblks = _ffull_dblks;
- }
- // Set the number of enqueued records for this file.
- _rec_enqcnt = ro->_enq_cnt_list[_pfid];
- }
- }
- else // Normal initialization: create empty journal files
- create_jfile(jfsize_sblks);
-#ifdef RHM_JOWRITE
- }
-#endif
-}
-
-std::string
-fcntl::filename(const std::string& fbasename, const u_int16_t pfid)
-{
- std::ostringstream oss;
- oss << fbasename << ".";
- oss << std::setw(4) << std::setfill('0') << std::hex << pfid;
- oss << "." << JRNL_DATA_EXTENSION;
- return oss.str();
-}
-
-void
-fcntl::clean_file(const u_int32_t jfsize_sblks)
-{
- // NOTE: The journal file size is always one sblock bigger than the specified journal
- // file size, which is the data content size. The extra block is for the journal file
- // header which precedes all data on each file and is exactly one sblock in size.
- u_int32_t nsblks = jfsize_sblks + 1;
-
- // TODO - look at more efficient alternatives to allocating a null block:
- // 1. mmap() against /dev/zero, but can alignment for O_DIRECT be assured?
- // 2. ftruncate(), but does this result in a sparse file? If so, then this is no good.
-
- // Create temp null block for writing
- const std::size_t sblksize = JRNL_DBLK_SIZE * JRNL_SBLK_SIZE;
- void* nullbuf = 0;
- // Allocate no more than 2MB (4096 sblks) as a null buffer
- const u_int32_t nullbuffsize_sblks = nsblks > 4096 ? 4096 : nsblks;
- const std::size_t nullbuffsize = nullbuffsize_sblks * sblksize;
- if (::posix_memalign(&nullbuf, sblksize, nullbuffsize))
- {
- std::ostringstream oss;
- oss << "posix_memalign() failed: size=" << nullbuffsize << " blk_size=" << sblksize;
- oss << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR__MALLOC, oss.str(), "fcntl", "clean_file");
- }
- std::memset(nullbuf, 0, nullbuffsize);
-
- int fh = ::open(_fname.c_str(), O_WRONLY | O_CREAT | O_DIRECT,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // 0644 -rw-r--r--
- if (fh < 0)
- {
- std::free(nullbuf);
- std::ostringstream oss;
- oss << "open() failed:" << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR_FCNTL_OPENWR, oss.str(), "fcntl", "clean_file");
- }
-
- while (nsblks > 0)
- {
- u_int32_t this_write_sblks = nsblks >= nullbuffsize_sblks ? nullbuffsize_sblks : nsblks;
- if (::write(fh, nullbuf, this_write_sblks * sblksize) == -1)
- {
- ::close(fh);
- std::free(nullbuf);
- std::ostringstream oss;
- oss << "wr_size=" << (this_write_sblks * sblksize) << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR_FCNTL_WRITE, oss.str(), "fcntl", "clean_file");
- }
- nsblks -= this_write_sblks;
- }
-
- // Clean up
- std::free(nullbuf);
- if (::close(fh))
- {
- std::ostringstream oss;
- oss << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR_FCNTL_CLOSE, oss.str(), "fcntl", "clean_file");
- }
-}
-
-void
-fcntl::create_jfile(const u_int32_t jfsize_sblks)
-{
- clean_file(jfsize_sblks);
-}
-
-} // namespace journal
-} // namespace mrg
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/fcntl.h b/qpid/cpp/src/qpid/linearstore/jrnl/fcntl.h
deleted file mode 100644
index a75e3bc84d..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/fcntl.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file fcntl.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::fcntl (non-logging file
- * handle), used for controlling journal log files. See class documentation for
- * details.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_FCNTL_H
-#define QPID_LEGACYSTORE_JRNL_FCNTL_H
-
-namespace mrg
-{
-namespace journal
-{
-class fcntl;
-}
-}
-
-#include <cstddef>
-#include <string>
-#include "qpid/legacystore/jrnl/rcvdat.h"
-#include <sys/types.h>
-
-namespace mrg
-{
-namespace journal
-{
-
- /**
- * \class fcntl
- * \brief Journal file controller. There is one instance per journal file.
- */
- class fcntl
- {
- protected:
- std::string _fname; ///< File name
- u_int16_t _pfid; ///< Physical file ID (file number in order of creation)
- u_int16_t _lfid; ///< Logical file ID (ordinal number in ring store)
- const u_int32_t _ffull_dblks; ///< File size in dblks (incl. file header)
- int _wr_fh; ///< Write file handle
- u_int32_t _rec_enqcnt; ///< Count of enqueued records
- u_int32_t _rd_subm_cnt_dblks; ///< Read file count (data blocks) for submitted AIO
- u_int32_t _rd_cmpl_cnt_dblks; ///< Read file count (data blocks) for completed AIO
- u_int32_t _wr_subm_cnt_dblks; ///< Write file count (data blocks) for submitted AIO
- u_int32_t _wr_cmpl_cnt_dblks; ///< Write file count (data blocks) for completed AIO
- u_int16_t _aio_cnt; ///< Outstanding AIO operations on this file
- bool _fhdr_wr_aio_outstanding; ///< Outstanding file header write on this file
-
- public:
- // Constructors with implicit initialize() and open()
- fcntl(const std::string& fbasename, const u_int16_t pfid, const u_int16_t lfid, const u_int32_t jfsize_sblks,
- const rcvdat* const ro);
- virtual ~fcntl();
-
- virtual bool reset(const rcvdat* const ro = 0);
- virtual void rd_reset();
- virtual bool wr_reset(const rcvdat* const ro = 0);
-
- virtual int open_wr_fh();
- virtual void close_wr_fh();
- inline bool is_wr_fh_open() const { return _wr_fh >= 0; }
-
- inline const std::string& fname() const { return _fname; }
- inline u_int16_t pfid() const { return _pfid; }
- inline u_int16_t lfid() const { return _lfid; }
- inline void set_lfid(const u_int16_t lfid) { _lfid = lfid; }
- inline int wr_fh() const { return _wr_fh; }
- inline u_int32_t enqcnt() const { return _rec_enqcnt; }
- inline u_int32_t incr_enqcnt() { return ++_rec_enqcnt; }
- u_int32_t add_enqcnt(u_int32_t a);
- u_int32_t decr_enqcnt();
- u_int32_t subtr_enqcnt(u_int32_t s);
-
- inline u_int32_t rd_subm_cnt_dblks() const { return _rd_subm_cnt_dblks; }
- inline std::size_t rd_subm_offs() const { return _rd_subm_cnt_dblks * JRNL_DBLK_SIZE; }
- u_int32_t add_rd_subm_cnt_dblks(u_int32_t a);
-
- inline u_int32_t rd_cmpl_cnt_dblks() const { return _rd_cmpl_cnt_dblks; }
- inline std::size_t rd_cmpl_offs() const { return _rd_cmpl_cnt_dblks * JRNL_DBLK_SIZE; }
- u_int32_t add_rd_cmpl_cnt_dblks(u_int32_t a);
-
- inline u_int32_t wr_subm_cnt_dblks() const { return _wr_subm_cnt_dblks; }
- inline std::size_t wr_subm_offs() const { return _wr_subm_cnt_dblks * JRNL_DBLK_SIZE; }
- u_int32_t add_wr_subm_cnt_dblks(u_int32_t a);
-
- inline u_int32_t wr_cmpl_cnt_dblks() const { return _wr_cmpl_cnt_dblks; }
- inline std::size_t wr_cmpl_offs() const { return _wr_cmpl_cnt_dblks * JRNL_DBLK_SIZE; }
- u_int32_t add_wr_cmpl_cnt_dblks(u_int32_t a);
-
- inline u_int16_t aio_cnt() const { return _aio_cnt; }
- inline u_int16_t incr_aio_cnt() { return ++_aio_cnt; }
- u_int16_t decr_aio_cnt();
-
- inline bool wr_fhdr_aio_outstanding() { return _fhdr_wr_aio_outstanding; }
- inline void set_wr_fhdr_aio_outstanding(const bool wfao) { _fhdr_wr_aio_outstanding = wfao; }
-
- // Derived helper functions
-
- inline bool rd_void() const { return _wr_cmpl_cnt_dblks == 0; }
- inline bool rd_empty() const { return _wr_cmpl_cnt_dblks <= JRNL_SBLK_SIZE; }
- inline u_int32_t rd_remaining_dblks() const { return _wr_cmpl_cnt_dblks - _rd_subm_cnt_dblks; }
- inline bool is_rd_full() const { return _wr_cmpl_cnt_dblks == _rd_subm_cnt_dblks; }
- inline bool is_rd_compl() const { return _wr_cmpl_cnt_dblks == _rd_cmpl_cnt_dblks; }
- inline u_int32_t rd_aio_outstanding_dblks() const { return _rd_subm_cnt_dblks - _rd_cmpl_cnt_dblks; }
- inline bool rd_file_rotate() const { return is_rd_full() && is_wr_compl(); }
-
- inline bool wr_void() const { return _wr_subm_cnt_dblks == 0; }
- inline bool wr_empty() const { return _wr_subm_cnt_dblks <= JRNL_SBLK_SIZE; }
- inline u_int32_t wr_remaining_dblks() const { return _ffull_dblks - _wr_subm_cnt_dblks; }
- inline bool is_wr_full() const { return _ffull_dblks == _wr_subm_cnt_dblks; }
- inline bool is_wr_compl() const { return _ffull_dblks == _wr_cmpl_cnt_dblks; }
- inline u_int32_t wr_aio_outstanding_dblks() const { return _wr_subm_cnt_dblks - _wr_cmpl_cnt_dblks; }
- inline bool wr_file_rotate() const { return is_wr_full(); }
-
- // Debug aid
- const std::string status_str() const;
-
- protected:
- virtual void initialize(const std::string& fbasename, const u_int16_t pfid, const u_int16_t lfid,
- const u_int32_t jfsize_sblks, const rcvdat* const ro);
-
- static std::string filename(const std::string& fbasename, const u_int16_t pfid);
- void clean_file(const u_int32_t jfsize_sblks);
- void create_jfile(const u_int32_t jfsize_sblks);
- };
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_FCNTL_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/file_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/file_hdr.h
deleted file mode 100644
index db20834cbb..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/file_hdr.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file file_hdr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::file_hdr (file
- * record header), used to start a journal file. It contains some
- * file metadata and information to aid journal recovery.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_FILE_HDR_H
-#define QPID_LEGACYSTORE_JRNL_FILE_HDR_H
-
-#include <cerrno>
-#include <ctime>
-#include "qpid/legacystore/jrnl/rec_hdr.h"
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
-#include <sstream>
-
-namespace mrg
-{
-namespace journal
-{
-
-#pragma pack(1)
-
- /**
- * \brief Struct for data common to the head of all journal files. In addition to
- * the common data, this includes the record ID and offset of the first record in
- * the file.
- *
- * This header precedes all data in journal files and occupies the first complete
- * block in the file. The record ID and offset are updated on each overwrite of the
- * file.
- *
- * File header info in binary format (48 bytes):
- * <pre>
- * 0 7
- * +---+---+---+---+---+---+---+---+ -+
- * | magic | v | e | flags | |
- * +---+---+---+---+---+---+---+---+ | struct hdr
- * | first rid in file | |
- * +---+---+---+---+---+---+---+---+ -+
- * | pfid | lfid | reserved (0) |
- * +---+---+---+---+---+---+---+---+
- * | fro |
- * +---+---+---+---+---+---+---+---+
- * | timestamp (sec) |
- * +---+---+---+---+---+---+---+---+
- * | timestamp (ns) |
- * +---+---+---+---+---+---+---+---+
- * v = file version (If the format or encoding of this file changes, then this
- * number should be incremented)
- * e = endian flag, false (0x00) for little endian, true (0x01) for big endian
- * pfid = File ID (number used in naming file)
- * lfid = Logical ID (order used in circular buffer)
- * fro = First record offset, offset from start of file to first record header
- * </pre>
- *
- * Note that journal files should be transferable between 32- and 64-bit
- * hardware of the same endianness, but not between hardware of opposite
- * entianness without some sort of binary conversion utility. Thus buffering
- * will be needed for types that change size between 32- and 64-bit compiles.
- */
- struct file_hdr : rec_hdr
- {
- u_int16_t _pfid; ///< Physical file ID (pfid)
- u_int16_t _lfid; ///< Logical file ID (lfid)
- u_int32_t _res; ///< Reserved (for alignment/flags)
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler0; ///< Big-endian filler for 32-bit size_t
-#endif
- std::size_t _fro; ///< First record offset
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler0; ///< Little-endian filler for 32-bit size_t
-#endif
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler1; ///< Big-endian filler for 32-bit time_t
-#endif
- std::time_t _ts_sec; ///< Timestamp of journal initilailization
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler1; ///< Little-endian filler for 32-bit time_t
-#endif
-#if defined(JRNL_BIG_ENDIAN)
- u_int32_t _filler2; ///< Big endian filler for u_int32_t
-#endif
- u_int32_t _ts_nsec; ///< Timestamp of journal initilailization
-#if defined(JRNL_LITTLE_ENDIAN)
- u_int32_t _filler2; ///< Little-endian filler for u_int32_t
-#endif
-
- /**
- * \brief Default constructor, which sets all values to 0.
- */
- inline file_hdr(): rec_hdr(), _pfid(0), _lfid(0), _res(0),
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
- _fro(0),
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler1(0),
-#endif
- _ts_sec(0),
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- _filler1(0),
-#endif
-#if defined(JRNL_BIG_ENDIAN)
- _filler2(0),
-#endif
- _ts_nsec(0)
-#if defined(JRNL_LITTLE_ENDIAN)
- , _filler2(0)
-#endif
- {}
-
- /**
- * \brief Convenience constructor which initializes values during construction.
- */
- inline file_hdr(const u_int32_t magic, const u_int8_t version, const u_int64_t rid,
- const u_int16_t pfid, const u_int16_t lfid, const std::size_t fro,
- const bool owi, const bool settime = false):
- rec_hdr(magic, version, rid, owi), _pfid(pfid), _lfid(lfid), _res(0),
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
- _fro(fro),
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler1(0),
-#endif
- _ts_sec(0),
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- _filler1(0),
-#endif
-#if defined(JRNL_BIG_ENDIAN)
- _filler2(0),
-#endif
- _ts_nsec(0)
-#if defined(JRNL_LITTLE_ENDIAN)
- , _filler2(0)
-#endif
- { if (settime) set_time(); }
-
- /**
- * \brief Gets the current time from the system clock and sets the timestamp in the struct.
- */
- inline void set_time()
- {
- // TODO: Standardize on method for getting time that does not requrie a context switch.
- timespec ts;
- if (::clock_gettime(CLOCK_REALTIME, &ts))
- {
- std::ostringstream oss;
- oss << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR__RTCLOCK, oss.str(), "file_hdr", "set_time");
- }
- _ts_sec = ts.tv_sec;
- _ts_nsec = ts.tv_nsec;
- }
-
- /**
- * \brief Sets the timestamp in the struct to the provided value (in seconds and
- * nanoseconds).
- */
- inline void set_time(timespec& ts)
- {
- _ts_sec = ts.tv_sec;
- _ts_nsec = ts.tv_nsec;
- }
-
- /**
- * \brief Returns the size of the header in bytes.
- */
- inline static std::size_t size() { return sizeof(file_hdr); }
- }; // struct file_hdr
-
-#pragma pack()
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_FILE_HDR_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jcfg.h b/qpid/cpp/src/qpid/linearstore/jrnl/jcfg.h
index 0a0d0df28d..ab94b6914d 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jcfg.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jcfg.h
@@ -19,35 +19,26 @@
*
*/
-/**
- * \file jcfg.h
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains \#defines that control the implementation details of
- * the journal.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_JCFG_H
#define QPID_LEGACYSTORE_JRNL_JCFG_H
-#if defined(__i386__) /* little endian, 32 bits */
+/*
+#if defined(__i386__) little endian, 32 bits
#define JRNL_LITTLE_ENDIAN
#define JRNL_32_BIT
-#elif defined(__PPC__) || defined(__s390__) /* big endian, 32 bits */
+#elif defined(__PPC__) || defined(__s390__) big endian, 32 bits
#define JRNL_BIG_ENDIAN
#define JRNL_32_BIT
-#elif defined(__ia64__) || defined(__x86_64__) || defined(__alpha__) /* little endian, 64 bits */
+#elif defined(__ia64__) || defined(__x86_64__) || defined(__alpha__) little endian, 64 bits
#define JRNL_LITTLE_ENDIAN
#define JRNL_64_BIT
-#elif defined(__powerpc64__) || defined(__s390x__) /* big endian, 64 bits */
+#elif defined(__powerpc64__) || defined(__s390x__) big endian, 64 bits
#define JRNL_BIG_ENDIAN
#define JRNL_64_BIT
#else
#error endian?
#endif
+*/
/**
@@ -57,35 +48,44 @@
* </pre>
* (The disk softblock size is 512 for Linux kernels >= 2.6)
*/
-#define JRNL_DBLK_SIZE 128 ///< Data block size in bytes (CANNOT BE LESS THAN 32!)
-#define JRNL_SBLK_SIZE 4 ///< Disk softblock size in multiples of JRNL_DBLK_SIZE
-#define JRNL_MIN_FILE_SIZE 128 ///< Min. jrnl file size in sblks (excl. file_hdr)
-#define JRNL_MAX_FILE_SIZE 4194176 ///< Max. jrnl file size in sblks (excl. file_hdr)
-#define JRNL_MIN_NUM_FILES 4 ///< Min. number of journal files
-#define JRNL_MAX_NUM_FILES 64 ///< Max. number of journal files
-#define JRNL_ENQ_THRESHOLD 80 ///< Percent full when enqueue connection will be closed
-
+#define JRNL_DBLK_SIZE 128 /**< Data block size in bytes (CANNOT BE LESS THAN 32!) */
+#define JRNL_SBLK_SIZE 32 /**< Disk softblock size in multiples of JRNL_DBLK_SIZE */
+//#define JRNL_MIN_FILE_SIZE 128 ///< Min. jrnl file size in sblks (excl. file_hdr)
+//#define JRNL_MAX_FILE_SIZE 4194176 ///< Max. jrnl file size in sblks (excl. file_hdr)
+//#define JRNL_MIN_NUM_FILES 4 ///< Min. number of journal files
+//#define JRNL_MAX_NUM_FILES 64 ///< Max. number of journal files
+//#define JRNL_ENQ_THRESHOLD 80 ///< Percent full when enqueue connection will be closed
+//
#define JRNL_RMGR_PAGE_SIZE 128 ///< Journal page size in softblocks
#define JRNL_RMGR_PAGES 16 ///< Number of pages to use in wmgr
-
-#define JRNL_WMGR_DEF_PAGE_SIZE 64 ///< Journal write page size in softblocks (default)
-#define JRNL_WMGR_DEF_PAGES 32 ///< Number of pages to use in wmgr (default)
-
+//
+//#define JRNL_WMGR_DEF_PAGE_SIZE 64 ///< Journal write page size in softblocks (default)
+//#define JRNL_WMGR_DEF_PAGES 32 ///< Number of pages to use in wmgr (default)
+//
#define JRNL_WMGR_MAXDTOKPP 1024 ///< Max. dtoks (data blocks) per page in wmgr
#define JRNL_WMGR_MAXWAITUS 100 ///< Max. wait time (us) before submitting AIO
-
-#define JRNL_INFO_EXTENSION "jinf" ///< Extension for journal info files
-#define JRNL_DATA_EXTENSION "jdat" ///< Extension for journal data files
-#define RHM_JDAT_TXA_MAGIC 0x614d4852 ///< ("RHMa" in little endian) Magic for dtx abort hdrs
-#define RHM_JDAT_TXC_MAGIC 0x634d4852 ///< ("RHMc" in little endian) Magic for dtx commit hdrs
-#define RHM_JDAT_DEQ_MAGIC 0x644d4852 ///< ("RHMd" in little endian) Magic for deq rec hdrs
-#define RHM_JDAT_ENQ_MAGIC 0x654d4852 ///< ("RHMe" in little endian) Magic for enq rec hdrs
-#define RHM_JDAT_FILE_MAGIC 0x664d4852 ///< ("RHMf" in little endian) Magic for file hdrs
-#define RHM_JDAT_EMPTY_MAGIC 0x784d4852 ///< ("RHMx" in little endian) Magic for empty dblk
-#define RHM_JDAT_VERSION 0x01 ///< Version (of file layout)
-#define RHM_CLEAN_CHAR 0xff ///< Char used to clear empty space on disk
-
-#define RHM_LENDIAN_FLAG 0 ///< Value of little endian flag on disk
-#define RHM_BENDIAN_FLAG 1 ///< Value of big endian flag on disk
+//
+//#define JRNL_INFO_EXTENSION "jinf" ///< Extension for journal info files
+//#define JRNL_DATA_EXTENSION "jdat" ///< Extension for journal data files
+#define QLS_JRNL_FILE_EXTENSION "jdat" /**< Extension for journal data files */
+//#define RHM_JDAT_TXA_MAGIC 0x614d4852 ///< ("RHMa" in little endian) Magic for dtx abort hdrs
+#define QLS_TXA_MAGIC 0x61534c51 /**< ("RHMa" in little endian) Magic for dtx abort hdrs */
+//#define RHM_JDAT_TXC_MAGIC 0x634d4852 ///< ("RHMc" in little endian) Magic for dtx commit hdrs
+#define QLS_TXC_MAGIC 0x63534c51 ///< ("RHMc" in little endian) Magic for dtx commit hdrs
+//#define RHM_JDAT_DEQ_MAGIC 0x644d4852 ///< ("RHMd" in little endian) Magic for deq rec hdrs
+#define QLS_DEQ_MAGIC 0x64534c51 /**< ("QLSd" in little endian) Magic for deq rec hdrs */
+//#define RHM_JDAT_ENQ_MAGIC 0x654d4852 ///< ("RHMe" in little endian) Magic for enq rec hdrs
+#define QLS_ENQ_MAGIC 0x65534c51 /**< ("QLSe" in little endian) Magic for enq rec hdrs */
+//#define RHM_JDAT_FILE_MAGIC 0x664d4852 ///< ("RHMf" in little endian) Magic for file hdrs
+#define QLS_FILE_MAGIC 0x66534c51 /**< ("QLSf" in little endian) Magic for file hdrs */
+//#define RHM_JDAT_EMPTY_MAGIC 0x784d4852 ///< ("RHMx" in little endian) Magic for empty dblk
+#define QLS_EMPTY_MAGIC 0x78534c51 /**< ("QLSx" in little endian) Magic for empty dblk */
+//#define RHM_JDAT_VERSION 0x01 ///< Version (of file layout)
+#define QLS_JRNL_VERSION 0x0002 /**< Version (of file layout) */
+//#define RHM_CLEAN_CHAR 0xff ///< Char used to clear empty space on disk
+#define QLS_CLEAN_CHAR 0xff ///< Char used to clear empty space on disk
+//
+//#define RHM_LENDIAN_FLAG 0 ///< Value of little endian flag on disk
+//#define RHM_BENDIAN_FLAG 1 ///< Value of big endian flag on disk
#endif // ifndef QPID_LEGACYSTORE_JRNL_JCFG_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jcntl.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/jcntl.cpp
index 21fcf099b4..08752b27c1 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jcntl.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jcntl.cpp
@@ -19,19 +19,7 @@
*
*/
-/**
- * \file jcntl.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * Messaging journal top-level control and interface class
- * mrg::journal::jcntl. See comments in file jcntl.h for details.
- *
- * \author Kim van der Riet
- */
-
-
-#include "qpid/legacystore/jrnl/jcntl.h"
+#include "qpid/linearstore/jrnl/jcntl.h"
#include <algorithm>
#include <cassert>
@@ -41,9 +29,9 @@
#include <fstream>
#include <iomanip>
#include <iostream>
-#include "qpid/legacystore/jrnl/file_hdr.h"
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jinf.h"
+//#include "qpid/linearstore/jrnl/file_hdr.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
+//#include "qpid/linearstore/jrnl/jinf.h"
#include <limits>
#include <sstream>
#include <unistd.h>
@@ -83,13 +71,13 @@ jcntl::jcntl(const std::string& jid, const std::string& jdir, const std::string&
_readonly_flag(false),
_autostop(true),
_jfsize_sblks(0),
- _lpmgr(),
+// _lpmgr(),
_emap(),
_tmap(),
- _rrfc(&_lpmgr),
- _wrfc(&_lpmgr),
- _rmgr(this, _emap, _tmap, _rrfc),
- _wmgr(this, _emap, _tmap, _wrfc),
+// _rrfc(&_lpmgr),
+// _wrfc(&_lpmgr),
+ _rmgr(this, _emap, _tmap/*, _rrfc*/),
+ _wmgr(this, _emap, _tmap/*, _wrfc*/),
_rcvdat()
{}
@@ -98,12 +86,12 @@ jcntl::~jcntl()
if (_init_flag && !_stop_flag)
try { stop(true); }
catch (const jexception& e) { std::cerr << e << std::endl; }
- _lpmgr.finalize();
+// _lpmgr.finalize();
}
void
-jcntl::initialize(const u_int16_t num_jfiles, const bool ae, const u_int16_t ae_max_jfiles,
- const u_int32_t jfsize_sblks, const u_int16_t wcache_num_pages, const u_int32_t wcache_pgsize_sblks,
+jcntl::initialize(const uint16_t num_jfiles/*, const bool ae, const uint16_t ae_max_jfiles*/,
+ const uint32_t jfsize_sblks, const uint16_t wcache_num_pages, const uint32_t wcache_pgsize_sblks,
aio_callback* const cbp)
{
_init_flag = false;
@@ -113,40 +101,40 @@ jcntl::initialize(const u_int16_t num_jfiles, const bool ae, const u_int16_t ae_
_emap.clear();
_tmap.clear();
- _lpmgr.finalize();
+// _lpmgr.finalize();
// Set new file geometry parameters
- assert(num_jfiles >= JRNL_MIN_NUM_FILES);
- assert(num_jfiles <= JRNL_MAX_NUM_FILES);
+// assert(num_jfiles >= JRNL_MIN_NUM_FILES);
+// assert(num_jfiles <= JRNL_MAX_NUM_FILES);
_emap.set_num_jfiles(num_jfiles);
_tmap.set_num_jfiles(num_jfiles);
- assert(jfsize_sblks >= JRNL_MIN_FILE_SIZE);
- assert(jfsize_sblks <= JRNL_MAX_FILE_SIZE);
+// assert(jfsize_sblks >= JRNL_MIN_FILE_SIZE);
+// assert(jfsize_sblks <= JRNL_MAX_FILE_SIZE);
_jfsize_sblks = jfsize_sblks;
// Clear any existing journal files
_jdir.clear_dir();
- _lpmgr.initialize(num_jfiles, ae, ae_max_jfiles, this, &new_fcntl);
+// _lpmgr.initialize(num_jfiles, ae, ae_max_jfiles, this, &new_fcntl);
- _wrfc.initialize(_jfsize_sblks);
- _rrfc.initialize();
- _rrfc.set_findex(0);
+// _wrfc.initialize(_jfsize_sblks);
+// _rrfc.initialize();
+// _rrfc.set_findex(0);
_rmgr.initialize(cbp);
_wmgr.initialize(cbp, wcache_pgsize_sblks, wcache_num_pages, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS);
// Write info file (<basename>.jinf) to disk
- write_infofile();
+// write_infofile();
_init_flag = true;
}
void
-jcntl::recover(const u_int16_t num_jfiles, const bool ae, const u_int16_t ae_max_jfiles,
- const u_int32_t jfsize_sblks, const u_int16_t wcache_num_pages, const u_int32_t wcache_pgsize_sblks,
+jcntl::recover(const uint16_t num_jfiles/*, const bool ae, const uint16_t ae_max_jfiles*/,
+ const uint32_t jfsize_sblks, const uint16_t wcache_num_pages, const uint32_t wcache_pgsize_sblks,
// const rd_aio_cb rd_cb, const wr_aio_cb wr_cb, const std::vector<std::string>* prep_txn_list_ptr,
aio_callback* const cbp, const std::vector<std::string>* prep_txn_list_ptr,
- u_int64_t& highest_rid)
+ uint64_t& highest_rid)
{
_init_flag = false;
_stop_flag = false;
@@ -155,17 +143,17 @@ jcntl::recover(const u_int16_t num_jfiles, const bool ae, const u_int16_t ae_max
_emap.clear();
_tmap.clear();
- _lpmgr.finalize();
+// _lpmgr.finalize();
- assert(num_jfiles >= JRNL_MIN_NUM_FILES);
- assert(num_jfiles <= JRNL_MAX_NUM_FILES);
- assert(jfsize_sblks >= JRNL_MIN_FILE_SIZE);
- assert(jfsize_sblks <= JRNL_MAX_FILE_SIZE);
+// assert(num_jfiles >= JRNL_MIN_NUM_FILES);
+// assert(num_jfiles <= JRNL_MAX_NUM_FILES);
+// assert(jfsize_sblks >= JRNL_MIN_FILE_SIZE);
+// assert(jfsize_sblks <= JRNL_MAX_FILE_SIZE);
_jfsize_sblks = jfsize_sblks;
// Verify journal dir and journal files
_jdir.verify_dir();
- _rcvdat.reset(num_jfiles, ae, ae_max_jfiles);
+ _rcvdat.reset(num_jfiles/*, ae, ae_max_jfiles*/);
rcvr_janalyze(_rcvdat, prep_txn_list_ptr);
highest_rid = _rcvdat._h_rid;
@@ -173,11 +161,11 @@ jcntl::recover(const u_int16_t num_jfiles, const bool ae, const u_int16_t ae_max
throw jexception(jerrno::JERR_JCNTL_RECOVERJFULL, "jcntl", "recover");
this->log(LOG_DEBUG, _rcvdat.to_log(_jid));
- _lpmgr.recover(_rcvdat, this, &new_fcntl);
+// _lpmgr.recover(_rcvdat, this, &new_fcntl);
- _wrfc.initialize(_jfsize_sblks, &_rcvdat);
- _rrfc.initialize();
- _rrfc.set_findex(_rcvdat.ffid());
+// _wrfc.initialize(_jfsize_sblks, &_rcvdat);
+// _rrfc.initialize();
+// _rrfc.set_findex(_rcvdat.ffid());
_rmgr.initialize(cbp);
_wmgr.initialize(cbp, wcache_pgsize_sblks, wcache_num_pages, JRNL_WMGR_MAXDTOKPP, JRNL_WMGR_MAXWAITUS,
(_rcvdat._lffull ? 0 : _rcvdat._eo));
@@ -191,11 +179,11 @@ jcntl::recover_complete()
{
if (!_readonly_flag)
throw jexception(jerrno::JERR_JCNTL_NOTRECOVERED, "jcntl", "recover_complete");
- for (u_int16_t i=0; i<_lpmgr.num_jfiles(); i++)
- _lpmgr.get_fcntlp(i)->reset(&_rcvdat);
- _wrfc.initialize(_jfsize_sblks, &_rcvdat);
- _rrfc.initialize();
- _rrfc.set_findex(_rcvdat.ffid());
+// for (uint16_t i=0; i<_lpmgr.num_jfiles(); i++)
+// _lpmgr.get_fcntlp(i)->reset(&_rcvdat);
+// _wrfc.initialize(_jfsize_sblks, &_rcvdat);
+// _rrfc.initialize();
+// _rrfc.set_findex(_rcvdat.ffid());
_rmgr.recover_complete();
_readonly_flag = false;
}
@@ -265,7 +253,7 @@ jcntl::enqueue_extern_txn_data_record(const std::size_t tot_data_len, data_tok*
/* TODO
iores
-jcntl::get_data_record(const u_int64_t& rid, const std::size_t& dsize, const std::size_t& dsize_avail,
+jcntl::get_data_record(const uint64_t& rid, const std::size_t& dsize, const std::size_t& dsize_avail,
const void** const data, bool auto_discard)
{
check_rstatus("get_data_record");
@@ -292,7 +280,8 @@ jcntl::read_data_record(void** const datapp, std::size_t& dsize, void** const xi
iores sres = _rmgr.synchronize(); // flushes all outstanding read events
if (sres != RHM_IORES_SUCCESS)
return sres;
- _rmgr.wait_for_validity(&_aio_cmpl_timeout, true); // throw if timeout occurs
+ // TODO: Does linear store need this?
+// _rmgr.wait_for_validity(&_aio_cmpl_timeout, true); // throw if timeout occurs
res = _rmgr.read(datapp, dsize, xidpp, xidsize, transient, external, dtokp, ignore_pending_txns);
}
return res;
@@ -380,15 +369,16 @@ jcntl::stop(const bool block_till_aio_cmpl)
_stop_flag = true;
if (!_readonly_flag)
flush(block_till_aio_cmpl);
- _rrfc.finalize();
- _lpmgr.finalize();
+// _rrfc.finalize();
+// _lpmgr.finalize();
}
-u_int16_t
+/*
+uint16_t
jcntl::get_earliest_fid()
{
- u_int16_t ffid = _wrfc.earliest_index();
- u_int16_t fid = _wrfc.index();
+ uint16_t ffid = _wrfc.earliest_index();
+ uint16_t fid = _wrfc.index();
while ( _emap.get_enq_cnt(ffid) == 0 && _tmap.get_txn_pfid_cnt(ffid) == 0 && ffid != fid)
{
if (++ffid >= _lpmgr.num_jfiles())
@@ -398,6 +388,7 @@ jcntl::get_earliest_fid()
_rrfc.set_findex(ffid);
return ffid;
}
+*/
iores
jcntl::flush(const bool block_till_aio_cmpl)
@@ -431,26 +422,30 @@ jcntl::log(log_level ll, const char* const log_stmt) const
}
}
+/*
void
jcntl::chk_wr_frot()
{
if (_wrfc.index() == _rrfc.index())
_rmgr.invalidate();
}
+*/
void
-jcntl::fhdr_wr_sync(const u_int16_t lid)
+jcntl::fhdr_wr_sync(const uint16_t /*lid*/)
{
+/*
fcntl* fcntlp = _lpmgr.get_fcntlp(lid);
while (fcntlp->wr_fhdr_aio_outstanding())
{
if (get_wr_events(&_aio_cmpl_timeout) == jerrno::AIO_TIMEOUT)
throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl", "fhdr_wr_sync");
}
+*/
}
fcntl*
-jcntl::new_fcntl(jcntl* const jcp, const u_int16_t lid, const u_int16_t fid, const rcvdat* const rdp)
+jcntl::new_fcntl(jcntl* const jcp, const uint16_t lid, const uint16_t fid, const rcvdat* const rdp)
{
if (!jcp) return 0;
std::ostringstream oss;
@@ -480,6 +475,7 @@ jcntl::check_rstatus(const char* fn_name) const
throw jexception(jerrno::JERR_JCNTL_STOPPED, "jcntl", fn_name);
}
+/*
void
jcntl::write_infofile() const
{
@@ -494,6 +490,7 @@ jcntl::write_infofile() const
_jfsize_sblks, _wmgr.cache_pgsize_sblks(), _wmgr.cache_num_pages(), ts);
ji.write();
}
+*/
void
jcntl::aio_cmpl_wait()
@@ -501,7 +498,7 @@ jcntl::aio_cmpl_wait()
//while (_wmgr.get_aio_evt_rem())
while (true)
{
- u_int32_t aer;
+ uint32_t aer;
{
slock s(_wr_mutex);
aer = _wmgr.get_aio_evt_rem();
@@ -532,17 +529,17 @@ jcntl::handle_aio_wait(const iores res, iores& resout, const data_tok* dtp)
}
else if (res == RHM_IORES_FILE_AIOWAIT)
{
- while (_wmgr.curr_file_blocked())
- {
- if (_wmgr.get_events(pmgr::UNUSED, &_aio_cmpl_timeout) == jerrno::AIO_TIMEOUT)
- {
- std::ostringstream oss;
- oss << "get_events() returned JERR_JCNTL_AIOCMPLWAIT; wmgr_status: " << _wmgr.status_str();
- this->log(LOG_CRITICAL, oss.str());
- throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl", "handle_aio_wait");
- }
- }
- _wrfc.wr_reset();
+// while (_wmgr.curr_file_blocked())
+// {
+// if (_wmgr.get_events(pmgr::UNUSED, &_aio_cmpl_timeout) == jerrno::AIO_TIMEOUT)
+// {
+// std::ostringstream oss;
+// oss << "get_events() returned JERR_JCNTL_AIOCMPLWAIT; wmgr_status: " << _wmgr.status_str();
+// this->log(LOG_CRITICAL, oss.str());
+// throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl", "handle_aio_wait");
+// }
+// }
+// _wrfc.wr_reset();
resout = RHM_IORES_SUCCESS;
data_tok::write_state ws = dtp->wstate();
return ws == data_tok::ENQ_PART || ws == data_tok::DEQ_PART || ws == data_tok::ABORT_PART ||
@@ -552,8 +549,9 @@ jcntl::handle_aio_wait(const iores res, iores& resout, const data_tok* dtp)
}
void
-jcntl::rcvr_janalyze(rcvdat& rd, const std::vector<std::string>* prep_txn_list_ptr)
+jcntl::rcvr_janalyze(rcvdat& /*rd*/, const std::vector<std::string>* /*prep_txn_list_ptr*/)
{
+/*
jinf ji(_jdir.dirname() + "/" + _base_filename + "." + JRNL_INFO_EXTENSION, true);
// If the number of files does not tie up with the jinf file from the journal being recovered,
@@ -604,7 +602,7 @@ jcntl::rcvr_janalyze(rcvdat& rd, const std::vector<std::string>* prep_txn_list_p
// Restore all read and write pointers and transactions
if (!rd._jempty)
{
- u_int16_t fid = rd._ffid;
+ uint16_t fid = rd._ffid;
std::ifstream ifs;
bool lowi = rd._owi; // local copy of owi to be used during analysis
while (rcvr_get_next_record(fid, &ifs, lowi, rd)) ;
@@ -647,17 +645,18 @@ jcntl::rcvr_janalyze(rcvdat& rd, const std::vector<std::string>* prep_txn_list_p
rd._lffull = rd._eo == (1 + _jfsize_sblks) * JRNL_SBLK_SIZE * JRNL_DBLK_SIZE;
// Check for journal full condition
- u_int16_t next_wr_fid = (rd._lfid + 1) % rd._njf;
+ uint16_t next_wr_fid = (rd._lfid + 1) % rd._njf;
rd._jfull = rd._ffid == next_wr_fid && rd._enq_cnt_list[next_wr_fid] && rd._lffull;
}
+*/
}
bool
-jcntl::rcvr_get_next_record(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcvdat& rd)
+jcntl::rcvr_get_next_record(uint16_t& fid, std::ifstream* ifsp/*, bool& lowi*/, rcvdat& rd)
{
std::size_t cum_size_read = 0;
void* xidp = 0;
- rec_hdr h;
+ rec_hdr_t h;
bool hdr_ok = false;
std::streampos file_pos;
@@ -665,27 +664,27 @@ jcntl::rcvr_get_next_record(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcv
{
if (!ifsp->is_open())
{
- if (!jfile_cycle(fid, ifsp, lowi, rd, true))
+ if (!jfile_cycle(fid, ifsp/*, lowi*/, rd, true))
return false;
}
file_pos = ifsp->tellg();
- ifsp->read((char*)&h, sizeof(rec_hdr));
- if (ifsp->gcount() == sizeof(rec_hdr))
+ ifsp->read((char*)&h, sizeof(rec_hdr_t));
+ if (ifsp->gcount() == sizeof(rec_hdr_t))
hdr_ok = true;
else
{
- if (!jfile_cycle(fid, ifsp, lowi, rd, true))
+ if (!jfile_cycle(fid, ifsp/*, lowi*/, rd, true))
return false;
}
}
switch(h._magic)
{
- case RHM_JDAT_ENQ_MAGIC:
+ case QLS_ENQ_MAGIC:
{
enq_rec er;
- u_int16_t start_fid = fid; // fid may increment in decode() if record folds over file boundary
- if (!decode(er, fid, ifsp, cum_size_read, h, lowi, rd, file_pos))
+ uint16_t start_fid = fid; // fid may increment in decode() if record folds over file boundary
+ if (!decode(er, fid, ifsp, cum_size_read, h/*, lowi*/, rd, file_pos))
return false;
if (!er.is_transient()) // Ignore transient msgs
{
@@ -717,11 +716,11 @@ jcntl::rcvr_get_next_record(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcv
}
}
break;
- case RHM_JDAT_DEQ_MAGIC:
+ case QLS_DEQ_MAGIC:
{
deq_rec dr;
- u_int16_t start_fid = fid; // fid may increment in decode() if record folds over file boundary
- if (!decode(dr, fid, ifsp, cum_size_read, h, lowi, rd, file_pos))
+ uint16_t start_fid = fid; // fid may increment in decode() if record folds over file boundary
+ if (!decode(dr, fid, ifsp, cum_size_read, h/*, lowi*/, rd, file_pos))
return false;
if (dr.xid_size())
{
@@ -748,10 +747,10 @@ jcntl::rcvr_get_next_record(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcv
}
}
break;
- case RHM_JDAT_TXA_MAGIC:
+ case QLS_TXA_MAGIC:
{
txn_rec ar;
- if (!decode(ar, fid, ifsp, cum_size_read, h, lowi, rd, file_pos))
+ if (!decode(ar, fid, ifsp, cum_size_read, h/*, lowi*/, rd, file_pos))
return false;
// Delete this txn from tmap, unlock any locked records in emap
ar.get_xid(&xidp);
@@ -768,10 +767,10 @@ jcntl::rcvr_get_next_record(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcv
std::free(xidp);
}
break;
- case RHM_JDAT_TXC_MAGIC:
+ case QLS_TXC_MAGIC:
{
txn_rec cr;
- if (!decode(cr, fid, ifsp, cum_size_read, h, lowi, rd, file_pos))
+ if (!decode(cr, fid, ifsp, cum_size_read, h/*, lowi*/, rd, file_pos))
return false;
// Delete this txn from tmap, process records into emap
cr.get_xid(&xidp);
@@ -800,12 +799,12 @@ jcntl::rcvr_get_next_record(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcv
std::free(xidp);
}
break;
- case RHM_JDAT_EMPTY_MAGIC:
+ case QLS_EMPTY_MAGIC:
{
- u_int32_t rec_dblks = jrec::size_dblks(sizeof(rec_hdr));
- ifsp->ignore(rec_dblks * JRNL_DBLK_SIZE - sizeof(rec_hdr));
+ uint32_t rec_dblks = jrec::size_dblks(sizeof(rec_hdr_t));
+ ifsp->ignore(rec_dblks * JRNL_DBLK_SIZE - sizeof(rec_hdr_t));
assert(!ifsp->fail() && !ifsp->bad());
- if (!jfile_cycle(fid, ifsp, lowi, rd, false))
+ if (!jfile_cycle(fid, ifsp/*, lowi*/, rd, false))
return false;
}
break;
@@ -821,13 +820,13 @@ jcntl::rcvr_get_next_record(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcv
}
bool
-jcntl::decode(jrec& rec, u_int16_t& fid, std::ifstream* ifsp, std::size_t& cum_size_read,
- rec_hdr& h, bool& lowi, rcvdat& rd, std::streampos& file_offs)
+jcntl::decode(jrec& rec, uint16_t& fid, std::ifstream* ifsp, std::size_t& cum_size_read,
+ rec_hdr_t& h/*, bool& lowi*/, rcvdat& rd, std::streampos& file_offs)
{
- u_int16_t start_fid = fid;
+ uint16_t start_fid = fid;
std::streampos start_file_offs = file_offs;
- if (!check_owi(fid, h, lowi, rd, file_offs))
- return false;
+// if (!check_owi(fid, h, lowi, rd, file_offs))
+// return false;
bool done = false;
while (!done)
{
@@ -844,7 +843,7 @@ jcntl::decode(jrec& rec, u_int16_t& fid, std::ifstream* ifsp, std::size_t& cum_s
// rd._lfid = start_fid;
return false;
}
- if (!done && !jfile_cycle(fid, ifsp, lowi, rd, false))
+ if (!done && !jfile_cycle(fid, ifsp/*, lowi*/, rd, false))
{
check_journal_alignment(start_fid, start_file_offs, rd);
return false;
@@ -854,7 +853,7 @@ jcntl::decode(jrec& rec, u_int16_t& fid, std::ifstream* ifsp, std::size_t& cum_s
}
bool
-jcntl::jfile_cycle(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcvdat& rd, const bool jump_fro)
+jcntl::jfile_cycle(uint16_t& fid, std::ifstream* ifsp/*, bool& lowi*/, rcvdat& rd, const bool jump_fro)
{
if (ifsp->is_open())
{
@@ -867,7 +866,7 @@ jcntl::jfile_cycle(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcvdat& rd,
if (++fid >= rd._njf)
{
fid = 0;
- lowi = !lowi; // Flip local owi
+// lowi = !lowi; // Flip local owi
}
if (fid == rd._ffid) // used up all journal files
return false;
@@ -877,19 +876,19 @@ jcntl::jfile_cycle(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcvdat& rd,
{
std::ostringstream oss;
oss << _jdir.dirname() << "/" << _base_filename << ".";
- oss << std::hex << std::setfill('0') << std::setw(4) << fid << "." << JRNL_DATA_EXTENSION;
+ oss << std::hex << std::setfill('0') << std::setw(4) << fid << "." << QLS_JRNL_FILE_EXTENSION;
ifsp->clear(); // clear eof flag, req'd for older versions of c++
ifsp->open(oss.str().c_str(), std::ios_base::in | std::ios_base::binary);
if (!ifsp->good())
throw jexception(jerrno::JERR__FILEIO, oss.str(), "jcntl", "jfile_cycle");
// Read file header
- file_hdr fhdr;
+ file_hdr_t fhdr;
ifsp->read((char*)&fhdr, sizeof(fhdr));
assert(ifsp->good());
- if (fhdr._magic == RHM_JDAT_FILE_MAGIC)
+ if (fhdr._rhdr._magic == QLS_FILE_MAGIC)
{
- assert(fhdr._lfid == fid);
+// assert(fhdr._lfid == fid);
if (!rd._fro)
rd._fro = fhdr._fro;
std::streamoff foffs = jump_fro ? fhdr._fro : JRNL_DBLK_SIZE * JRNL_SBLK_SIZE;
@@ -904,12 +903,14 @@ jcntl::jfile_cycle(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcvdat& rd,
return true;
}
+
+/*
bool
-jcntl::check_owi(const u_int16_t fid, rec_hdr& h, bool& lowi, rcvdat& rd, std::streampos& file_pos)
+jcntl::check_owi(const uint16_t fid, rec_hdr& h, bool& lowi, rcvdat& rd, std::streampos& file_pos)
{
if (rd._ffid ? h.get_owi() == lowi : h.get_owi() != lowi) // Overwrite indicator changed
{
- u_int16_t expected_fid = rd._ffid ? rd._ffid - 1 : rd._njf - 1;
+ uint16_t expected_fid = rd._ffid ? rd._ffid - 1 : rd._njf - 1;
if (fid == expected_fid)
{
check_journal_alignment(fid, file_pos, rd);
@@ -929,10 +930,11 @@ jcntl::check_owi(const u_int16_t fid, rec_hdr& h, bool& lowi, rcvdat& rd, std::s
rd._h_rid = h._rid;
return true;
}
+*/
void
-jcntl::check_journal_alignment(const u_int16_t fid, std::streampos& file_pos, rcvdat& rd)
+jcntl::check_journal_alignment(const uint16_t fid, std::streampos& file_pos, rcvdat& rd)
{
unsigned sblk_offs = file_pos % (JRNL_DBLK_SIZE * JRNL_SBLK_SIZE);
if (sblk_offs)
@@ -944,10 +946,10 @@ jcntl::check_journal_alignment(const u_int16_t fid, std::streampos& file_pos, rc
oss << (JRNL_SBLK_SIZE - (sblk_offs/JRNL_DBLK_SIZE)) << " filler record(s) required.";
this->log(LOG_WARN, oss.str());
}
- const u_int32_t xmagic = RHM_JDAT_EMPTY_MAGIC;
+ const uint32_t xmagic = QLS_EMPTY_MAGIC;
std::ostringstream oss;
oss << _jdir.dirname() << "/" << _base_filename << ".";
- oss << std::hex << std::setfill('0') << std::setw(4) << fid << "." << JRNL_DATA_EXTENSION;
+ oss << std::hex << std::setfill('0') << std::setw(4) << fid << "." << QLS_JRNL_FILE_EXTENSION;
std::ofstream ofsp(oss.str().c_str(),
std::ios_base::in | std::ios_base::out | std::ios_base::binary);
if (!ofsp.good())
@@ -959,7 +961,7 @@ jcntl::check_journal_alignment(const u_int16_t fid, std::streampos& file_pos, rc
// Normally, RHM_CLEAN must be set before these fills are done, but this is a recover
// situation (i.e. performance is not an issue), and it makes the location of the write
// clear should inspection of the file be required.
- std::memset((char*)buff + sizeof(xmagic), RHM_CLEAN_CHAR, JRNL_DBLK_SIZE - sizeof(xmagic));
+ std::memset((char*)buff + sizeof(xmagic), QLS_CLEAN_CHAR, JRNL_DBLK_SIZE - sizeof(xmagic));
while (file_pos % (JRNL_DBLK_SIZE * JRNL_SBLK_SIZE))
{
@@ -973,8 +975,8 @@ jcntl::check_journal_alignment(const u_int16_t fid, std::streampos& file_pos, rc
ofsp.close();
std::free(buff);
rd._lfid = fid;
- if (!rd._frot)
- rd._ffid = (fid + 1) % rd._njf;
+// if (!rd._frot)
+// rd._ffid = (fid + 1) % rd._njf;
this->log(LOG_INFO, "Bad record alignment fixed.");
}
rd._eo = file_pos;
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jcntl.h b/qpid/cpp/src/qpid/linearstore/jrnl/jcntl.h
index 294e9ced05..868cc5be31 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jcntl.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jcntl.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file jcntl.h
- *
- * Qpid asynchronous store plugin library
- *
- * Messaging journal top-level control and interface class
- * mrg::journal::jcntl. See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_JCNTL_H
#define QPID_LEGACYSTORE_JRNL_JCNTL_H
@@ -43,15 +32,15 @@ namespace journal
#include <cstddef>
#include <deque>
-#include "qpid/legacystore/jrnl/jdir.h"
-#include "qpid/legacystore/jrnl/fcntl.h"
-#include "qpid/legacystore/jrnl/lpmgr.h"
-#include "qpid/legacystore/jrnl/rcvdat.h"
-#include "qpid/legacystore/jrnl/slock.h"
-#include "qpid/legacystore/jrnl/smutex.h"
-#include "qpid/legacystore/jrnl/rmgr.h"
-#include "qpid/legacystore/jrnl/wmgr.h"
-#include "qpid/legacystore/jrnl/wrfc.h"
+#include "qpid/linearstore/jrnl/jdir.h"
+//#include "qpid/linearstore/jrnl/fcntl.h"
+//#include "qpid/linearstore/jrnl/lpmgr.h"
+#include "qpid/linearstore/jrnl/rcvdat.h"
+#include "qpid/linearstore/jrnl/slock.h"
+#include "qpid/linearstore/jrnl/smutex.h"
+#include "qpid/linearstore/jrnl/rmgr.h"
+#include "qpid/linearstore/jrnl/wmgr.h"
+//#include "qpid/linearstore/jrnl/wrfc.h"
namespace mrg
{
@@ -136,12 +125,12 @@ namespace journal
bool _autostop; ///< Autostop flag - stops journal when overrun occurs
// Journal control structures
- u_int32_t _jfsize_sblks; ///< Journal file size in sblks
- lpmgr _lpmgr; ///< LFID-PFID manager tracks inserted journal files
+ uint32_t _jfsize_sblks; ///< Journal file size in sblks
+ //lpmgr _lpmgr; ///< LFID-PFID manager tracks inserted journal files
enq_map _emap; ///< Enqueue map for low water mark management
txn_map _tmap; ///< Transaction map open transactions
- rrfc _rrfc; ///< Read journal rotating file controller
- wrfc _wrfc; ///< Write journal rotating file controller
+ //rrfc _rrfc; ///< Read journal rotating file controller
+ //wrfc _wrfc; ///< Write journal rotating file controller
rmgr _rmgr; ///< Read page manager which manages AIO
wmgr _wmgr; ///< Write page manager which manages AIO
rcvdat _rcvdat; ///< Recovery data used for recovery
@@ -201,8 +190,8 @@ namespace journal
*
* \exception TODO
*/
- void initialize(const u_int16_t num_jfiles, const bool auto_expand, const u_int16_t ae_max_jfiles,
- const u_int32_t jfsize_sblks, const u_int16_t wcache_num_pages, const u_int32_t wcache_pgsize_sblks,
+ void initialize(const uint16_t num_jfiles/*, const bool auto_expand, const uint16_t ae_max_jfiles*/,
+ const uint32_t jfsize_sblks, const uint16_t wcache_num_pages, const uint32_t wcache_pgsize_sblks,
aio_callback* const cbp);
/**
@@ -238,9 +227,9 @@ namespace journal
*
* \exception TODO
*/
- void recover(const u_int16_t num_jfiles, const bool auto_expand, const u_int16_t ae_max_jfiles,
- const u_int32_t jfsize_sblks, const u_int16_t wcache_num_pages, const u_int32_t wcache_pgsize_sblks,
- aio_callback* const cbp, const std::vector<std::string>* prep_txn_list_ptr, u_int64_t& highest_rid);
+ void recover(const uint16_t num_jfiles/*, const bool auto_expand, const uint16_t ae_max_jfiles*/,
+ const uint32_t jfsize_sblks, const uint16_t wcache_num_pages, const uint32_t wcache_pgsize_sblks,
+ aio_callback* const cbp, const std::vector<std::string>* prep_txn_list_ptr, uint64_t& highest_rid);
/**
* \brief Notification to the journal that recovery is complete and that normal operation
@@ -385,7 +374,7 @@ namespace journal
* \exception TODO
*
// *** NOT YET IMPLEMENTED ***
- iores get_data_record(const u_int64_t& rid, const std::size_t& dsize,
+ iores get_data_record(const uint64_t& rid, const std::size_t& dsize,
const std::size_t& dsize_avail, const void** const data, bool auto_discard = false);
*/
@@ -562,40 +551,40 @@ namespace journal
*/
iores flush(const bool block_till_aio_cmpl = false);
- inline u_int32_t get_enq_cnt() const { return _emap.size(); }
+ inline uint32_t get_enq_cnt() const { return _emap.size(); }
- inline u_int32_t get_wr_aio_evt_rem() const { slock l(_wr_mutex); return _wmgr.get_aio_evt_rem(); }
+ inline uint32_t get_wr_aio_evt_rem() const { slock l(_wr_mutex); return _wmgr.get_aio_evt_rem(); }
- inline u_int32_t get_rd_aio_evt_rem() const { return _rmgr.get_aio_evt_rem(); }
+ inline uint32_t get_rd_aio_evt_rem() const { return _rmgr.get_aio_evt_rem(); }
- inline u_int32_t get_wr_outstanding_aio_dblks() const
- { return _wrfc.aio_outstanding_dblks(); }
+ inline uint32_t get_wr_outstanding_aio_dblks() const;
+ /*{ return _wrfc.aio_outstanding_dblks(); }*/
- inline u_int32_t get_wr_outstanding_aio_dblks(u_int16_t lfid) const
- { return _lpmgr.get_fcntlp(lfid)->wr_aio_outstanding_dblks(); }
+// inline uint32_t get_wr_outstanding_aio_dblks(uint16_t lfid) const;
+// { return _lpmgr.get_fcntlp(lfid)->wr_aio_outstanding_dblks(); }
- inline u_int32_t get_rd_outstanding_aio_dblks() const
- { return _rrfc.aio_outstanding_dblks(); }
+ inline uint32_t get_rd_outstanding_aio_dblks() const;
+// { return _rrfc.aio_outstanding_dblks(); }
- inline u_int32_t get_rd_outstanding_aio_dblks(u_int16_t lfid) const
- { return _lpmgr.get_fcntlp(lfid)->rd_aio_outstanding_dblks(); }
+// inline uint32_t get_rd_outstanding_aio_dblks(uint16_t lfid) const;
+// { return _lpmgr.get_fcntlp(lfid)->rd_aio_outstanding_dblks(); }
- inline u_int16_t get_rd_fid() const { return _rrfc.index(); }
- inline u_int16_t get_wr_fid() const { return _wrfc.index(); }
- u_int16_t get_earliest_fid();
+// inline uint16_t get_rd_fid() const { return _rrfc.index(); }
+// inline uint16_t get_wr_fid() const { return _wrfc.index(); }
+// uint16_t get_earliest_fid();
/**
* \brief Check if a particular rid is enqueued. Note that this function will return
* false if the rid is transactionally enqueued and is not committed, or if it is
* locked (i.e. transactionally dequeued, but the dequeue has not been committed).
*/
- inline bool is_enqueued(const u_int64_t rid, bool ignore_lock = false)
+ inline bool is_enqueued(const uint64_t rid, bool ignore_lock = false)
{ return _emap.is_enqueued(rid, ignore_lock); }
- inline bool is_locked(const u_int64_t rid)
+ inline bool is_locked(const uint64_t rid)
{ if (_emap.is_enqueued(rid, true) < enq_map::EMAP_OK) return false; return _emap.is_locked(rid) == enq_map::EMAP_TRUE; }
- inline void enq_rid_list(std::vector<u_int64_t>& rids) { _emap.rid_list(rids); }
+ inline void enq_rid_list(std::vector<uint64_t>& rids) { _emap.rid_list(rids); }
inline void enq_xid_list(std::vector<std::string>& xids) { _tmap.xid_list(xids); }
- inline u_int32_t get_open_txn_cnt() const { return _tmap.size(); }
+ inline uint32_t get_open_txn_cnt() const { return _tmap.size(); }
// TODO Make this a const, but txn_map must support const first.
inline txn_map& get_txn_map() { return _tmap; }
@@ -642,21 +631,21 @@ namespace journal
*/
inline const std::string& base_filename() const { return _base_filename; }
- inline u_int16_t num_jfiles() const { return _lpmgr.num_jfiles(); }
+// inline uint16_t num_jfiles() const; { return _lpmgr.num_jfiles(); }
- inline fcntl* get_fcntlp(const u_int16_t lfid) const { return _lpmgr.get_fcntlp(lfid); }
+// inline fcntl* get_fcntlp(const uint16_t lfid) const { return _lpmgr.get_fcntlp(lfid); }
- inline u_int32_t jfsize_sblks() const { return _jfsize_sblks; }
+ inline uint32_t jfsize_sblks() const { return _jfsize_sblks; }
// Logging
virtual void log(log_level level, const std::string& log_stmt) const;
virtual void log(log_level level, const char* const log_stmt) const;
// FIXME these are _rmgr to _wmgr interactions, remove when _rmgr contains ref to _wmgr:
- void chk_wr_frot();
- inline u_int32_t unflushed_dblks() { return _wmgr.unflushed_dblks(); }
- void fhdr_wr_sync(const u_int16_t lid);
- inline u_int32_t wr_subm_cnt_dblks(const u_int16_t lfid) const { return _lpmgr.get_fcntlp(lfid)->wr_subm_cnt_dblks(); }
+ //void chk_wr_frot();
+ inline uint32_t unflushed_dblks() { return _wmgr.unflushed_dblks(); }
+ void fhdr_wr_sync(const uint16_t lid);
+ inline uint32_t wr_subm_cnt_dblks(const uint16_t lfid) const; /*{ return _lpmgr.get_fcntlp(lfid)->wr_subm_cnt_dblks(); }*/
// Management instrumentation callbacks
inline virtual void instr_incr_outstanding_aio_cnt() {}
@@ -665,7 +654,7 @@ namespace journal
/**
* /brief Static function for creating new fcntl objects for use with obj_arr.
*/
- static fcntl* new_fcntl(jcntl* const jcp, const u_int16_t lid, const u_int16_t fid, const rcvdat* const rdp);
+ static fcntl* new_fcntl(jcntl* const jcp, const uint16_t lid, const uint16_t fid, const rcvdat* const rdp);
protected:
static bool _init;
@@ -684,7 +673,7 @@ namespace journal
/**
* \brief Write info file &lt;basefilename&gt;.jinf to disk
*/
- void write_infofile() const;
+// void write_infofile() const;
/**
* \brief Call that blocks while waiting for all outstanding AIOs to complete
@@ -702,18 +691,18 @@ namespace journal
*/
void rcvr_janalyze(rcvdat& rd, const std::vector<std::string>* prep_txn_list_ptr);
- bool rcvr_get_next_record(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcvdat& rd);
+ bool rcvr_get_next_record(uint16_t& fid, std::ifstream* ifsp/*, bool& lowi*/, rcvdat& rd);
- bool decode(jrec& rec, u_int16_t& fid, std::ifstream* ifsp, std::size_t& cum_size_read,
- rec_hdr& h, bool& lowi, rcvdat& rd, std::streampos& rec_offset);
+ bool decode(jrec& rec, uint16_t& fid, std::ifstream* ifsp, std::size_t& cum_size_read,
+ rec_hdr_t& h/*, bool& lowi*/, rcvdat& rd, std::streampos& rec_offset);
- bool jfile_cycle(u_int16_t& fid, std::ifstream* ifsp, bool& lowi, rcvdat& rd,
+ bool jfile_cycle(uint16_t& fid, std::ifstream* ifsp/*, bool& lowi*/, rcvdat& rd,
const bool jump_fro);
- bool check_owi(const u_int16_t fid, rec_hdr& h, bool& lowi, rcvdat& rd,
- std::streampos& read_pos);
+ //bool check_owi(const uint16_t fid, rec_hdr_t& h, bool& lowi, rcvdat& rd,
+ // std::streampos& read_pos);
- void check_journal_alignment(const u_int16_t fid, std::streampos& rec_offset, rcvdat& rd);
+ void check_journal_alignment(const uint16_t fid, std::streampos& rec_offset, rcvdat& rd);
};
} // namespace journal
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jdir.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/jdir.cpp
index a874c6c945..d89b63bea6 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jdir.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jdir.cpp
@@ -19,27 +19,15 @@
*
*/
-/**
- * \file jdir.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::jdir (journal data
- * directory), used for controlling and manipulating journal data
- * direcories and files. See comments in file jdir.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/jdir.h"
+#include "qpid/linearstore/jrnl/jdir.h"
#include <cstdlib>
#include <cstring>
#include <cerrno>
#include <iomanip>
-#include "qpid/legacystore/jrnl/jcfg.h"
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/jcfg.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jexception.h"
#include <sstream>
#include <sys/stat.h>
#include <unistd.h>
@@ -225,7 +213,7 @@ jdir::verify_dir(const char* dirname, const char* base_filename)
void
-jdir::verify_dir(const std::string& dirname, const std::string& base_filename)
+jdir::verify_dir(const std::string& dirname, const std::string& /*base_filename*/)
{
if (!is_dir(dirname))
{
@@ -235,16 +223,16 @@ jdir::verify_dir(const std::string& dirname, const std::string& base_filename)
}
// Read jinf file, then verify all journal files are present
- jinf ji(dirname + "/" + base_filename + "." + JRNL_INFO_EXTENSION, true);
- for (u_int16_t fnum=0; fnum < ji.num_jfiles(); fnum++)
- {
- std::ostringstream oss;
- oss << dirname << "/" << base_filename << ".";
- oss << std::setw(4) << std::setfill('0') << std::hex << fnum;
- oss << "." << JRNL_DATA_EXTENSION;
- if (!exists(oss.str()))
- throw jexception(jerrno::JERR_JDIR_NOSUCHFILE, oss.str(), "jdir", "verify_dir");
- }
+// jinf ji(dirname + "/" + base_filename + "." + QLS_JRNL_FILE_EXTENSION, true);
+// for (uint16_t fnum=0; fnum < ji.num_jfiles(); fnum++)
+// {
+// std::ostringstream oss;
+// oss << dirname << "/" << base_filename << ".";
+// oss << std::setw(4) << std::setfill('0') << std::hex << fnum;
+// oss << "." << QLS_JRNL_FILE_EXTENSION;
+// if (!exists(oss.str()))
+// throw jexception(jerrno::JERR_JDIR_NOSUCHFILE, oss.str(), "jdir", "verify_dir");
+// }
}
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jdir.h b/qpid/cpp/src/qpid/linearstore/jrnl/jdir.h
index e129b794d6..ea294ade83 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jdir.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jdir.h
@@ -19,18 +19,6 @@
*
*/
-/**
- * \file jdir.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::jdir (%journal data
- * directory), used for controlling and manipulating %journal data
- * directories and files. See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_JDIR_H
#define QPID_LEGACYSTORE_JRNL_JDIR_H
@@ -42,8 +30,9 @@ class jdir;
}
}
-#include "qpid/legacystore/jrnl/jinf.h"
+//#include "qpid/linearstore/jrnl/jinf.h"
#include <dirent.h>
+#include <string>
namespace mrg
{
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jerrno.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/jerrno.cpp
index 4962ce63ab..d682f87529 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jerrno.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jerrno.cpp
@@ -19,120 +19,107 @@
*
*/
-/**
- * \file jerrno.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::jerrno (journal error
- * codes). See comments in file jerrno.h for details.
- *
- * See file jerrno.h for class details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
namespace mrg
{
namespace journal
{
-std::map<u_int32_t, const char*> jerrno::_err_map;
-std::map<u_int32_t, const char*>::iterator jerrno::_err_map_itr;
+std::map<uint32_t, const char*> jerrno::_err_map;
+std::map<uint32_t, const char*>::iterator jerrno::_err_map_itr;
bool jerrno::_initialized = jerrno::__init();
// generic errors
-const u_int32_t jerrno::JERR__MALLOC = 0x0100;
-const u_int32_t jerrno::JERR__UNDERFLOW = 0x0101;
-const u_int32_t jerrno::JERR__NINIT = 0x0102;
-const u_int32_t jerrno::JERR__AIO = 0x0103;
-const u_int32_t jerrno::JERR__FILEIO = 0x0104;
-const u_int32_t jerrno::JERR__RTCLOCK = 0x0105;
-const u_int32_t jerrno::JERR__PTHREAD = 0x0106;
-const u_int32_t jerrno::JERR__TIMEOUT = 0x0107;
-const u_int32_t jerrno::JERR__UNEXPRESPONSE = 0x0108;
-const u_int32_t jerrno::JERR__RECNFOUND = 0x0109;
-const u_int32_t jerrno::JERR__NOTIMPL = 0x010a;
+const uint32_t jerrno::JERR__MALLOC = 0x0100;
+const uint32_t jerrno::JERR__UNDERFLOW = 0x0101;
+const uint32_t jerrno::JERR__NINIT = 0x0102;
+const uint32_t jerrno::JERR__AIO = 0x0103;
+const uint32_t jerrno::JERR__FILEIO = 0x0104;
+const uint32_t jerrno::JERR__RTCLOCK = 0x0105;
+const uint32_t jerrno::JERR__PTHREAD = 0x0106;
+const uint32_t jerrno::JERR__TIMEOUT = 0x0107;
+const uint32_t jerrno::JERR__UNEXPRESPONSE = 0x0108;
+const uint32_t jerrno::JERR__RECNFOUND = 0x0109;
+const uint32_t jerrno::JERR__NOTIMPL = 0x010a;
// class jcntl
-const u_int32_t jerrno::JERR_JCNTL_STOPPED = 0x0200;
-const u_int32_t jerrno::JERR_JCNTL_READONLY = 0x0201;
-const u_int32_t jerrno::JERR_JCNTL_AIOCMPLWAIT = 0x0202;
-const u_int32_t jerrno::JERR_JCNTL_UNKNOWNMAGIC = 0x0203;
-const u_int32_t jerrno::JERR_JCNTL_NOTRECOVERED = 0x0204;
-const u_int32_t jerrno::JERR_JCNTL_RECOVERJFULL = 0x0205;
-const u_int32_t jerrno::JERR_JCNTL_OWIMISMATCH = 0x0206;
+const uint32_t jerrno::JERR_JCNTL_STOPPED = 0x0200;
+const uint32_t jerrno::JERR_JCNTL_READONLY = 0x0201;
+const uint32_t jerrno::JERR_JCNTL_AIOCMPLWAIT = 0x0202;
+const uint32_t jerrno::JERR_JCNTL_UNKNOWNMAGIC = 0x0203;
+const uint32_t jerrno::JERR_JCNTL_NOTRECOVERED = 0x0204;
+const uint32_t jerrno::JERR_JCNTL_RECOVERJFULL = 0x0205;
+const uint32_t jerrno::JERR_JCNTL_OWIMISMATCH = 0x0206;
// class jdir
-const u_int32_t jerrno::JERR_JDIR_NOTDIR = 0x0300;
-const u_int32_t jerrno::JERR_JDIR_MKDIR = 0x0301;
-const u_int32_t jerrno::JERR_JDIR_OPENDIR = 0x0302;
-const u_int32_t jerrno::JERR_JDIR_READDIR = 0x0303;
-const u_int32_t jerrno::JERR_JDIR_CLOSEDIR = 0x0304;
-const u_int32_t jerrno::JERR_JDIR_RMDIR = 0x0305;
-const u_int32_t jerrno::JERR_JDIR_NOSUCHFILE = 0x0306;
-const u_int32_t jerrno::JERR_JDIR_FMOVE = 0x0307;
-const u_int32_t jerrno::JERR_JDIR_STAT = 0x0308;
-const u_int32_t jerrno::JERR_JDIR_UNLINK = 0x0309;
-const u_int32_t jerrno::JERR_JDIR_BADFTYPE = 0x030a;
+const uint32_t jerrno::JERR_JDIR_NOTDIR = 0x0300;
+const uint32_t jerrno::JERR_JDIR_MKDIR = 0x0301;
+const uint32_t jerrno::JERR_JDIR_OPENDIR = 0x0302;
+const uint32_t jerrno::JERR_JDIR_READDIR = 0x0303;
+const uint32_t jerrno::JERR_JDIR_CLOSEDIR = 0x0304;
+const uint32_t jerrno::JERR_JDIR_RMDIR = 0x0305;
+const uint32_t jerrno::JERR_JDIR_NOSUCHFILE = 0x0306;
+const uint32_t jerrno::JERR_JDIR_FMOVE = 0x0307;
+const uint32_t jerrno::JERR_JDIR_STAT = 0x0308;
+const uint32_t jerrno::JERR_JDIR_UNLINK = 0x0309;
+const uint32_t jerrno::JERR_JDIR_BADFTYPE = 0x030a;
// class fcntl
-const u_int32_t jerrno::JERR_FCNTL_OPENWR = 0x0400;
-const u_int32_t jerrno::JERR_FCNTL_WRITE = 0x0401;
-const u_int32_t jerrno::JERR_FCNTL_CLOSE = 0x0402;
-const u_int32_t jerrno::JERR_FCNTL_FILEOFFSOVFL = 0x0403;
-const u_int32_t jerrno::JERR_FCNTL_CMPLOFFSOVFL = 0x0404;
-const u_int32_t jerrno::JERR_FCNTL_RDOFFSOVFL = 0x0405;
+//const uint32_t jerrno::JERR_FCNTL_OPENWR = 0x0400;
+//const uint32_t jerrno::JERR_FCNTL_WRITE = 0x0401;
+//const uint32_t jerrno::JERR_FCNTL_CLOSE = 0x0402;
+//const uint32_t jerrno::JERR_FCNTL_FILEOFFSOVFL = 0x0403;
+//const uint32_t jerrno::JERR_FCNTL_CMPLOFFSOVFL = 0x0404;
+//const uint32_t jerrno::JERR_FCNTL_RDOFFSOVFL = 0x0405;
// class lfmgr
-const u_int32_t jerrno::JERR_LFMGR_BADAEFNUMLIM = 0x0500;
-const u_int32_t jerrno::JERR_LFMGR_AEFNUMLIMIT = 0x0501;
-const u_int32_t jerrno::JERR_LFMGR_AEDISABLED = 0x0502;
+//const uint32_t jerrno::JERR_LFMGR_BADAEFNUMLIM = 0x0500;
+//const uint32_t jerrno::JERR_LFMGR_AEFNUMLIMIT = 0x0501;
+//const uint32_t jerrno::JERR_LFMGR_AEDISABLED = 0x0502;
// class rrfc
-const u_int32_t jerrno::JERR_RRFC_OPENRD = 0x0600;
+//const uint32_t jerrno::JERR_RRFC_OPENRD = 0x0600;
// class jrec, enq_rec, deq_rec, txn_rec
-const u_int32_t jerrno::JERR_JREC_BADRECHDR = 0x0700;
-const u_int32_t jerrno::JERR_JREC_BADRECTAIL = 0x0701;
+const uint32_t jerrno::JERR_JREC_BADRECHDR = 0x0700;
+const uint32_t jerrno::JERR_JREC_BADRECTAIL = 0x0701;
// class wmgr
-const u_int32_t jerrno::JERR_WMGR_BADPGSTATE = 0x0801;
-const u_int32_t jerrno::JERR_WMGR_BADDTOKSTATE = 0x0802;
-const u_int32_t jerrno::JERR_WMGR_ENQDISCONT = 0x0803;
-const u_int32_t jerrno::JERR_WMGR_DEQDISCONT = 0x0804;
-const u_int32_t jerrno::JERR_WMGR_DEQRIDNOTENQ = 0x0805;
+const uint32_t jerrno::JERR_WMGR_BADPGSTATE = 0x0801;
+const uint32_t jerrno::JERR_WMGR_BADDTOKSTATE = 0x0802;
+const uint32_t jerrno::JERR_WMGR_ENQDISCONT = 0x0803;
+const uint32_t jerrno::JERR_WMGR_DEQDISCONT = 0x0804;
+const uint32_t jerrno::JERR_WMGR_DEQRIDNOTENQ = 0x0805;
// class rmgr
-const u_int32_t jerrno::JERR_RMGR_UNKNOWNMAGIC = 0x0900;
-const u_int32_t jerrno::JERR_RMGR_RIDMISMATCH = 0x0901;
-//const u_int32_t jerrno::JERR_RMGR_FIDMISMATCH = 0x0902;
-const u_int32_t jerrno::JERR_RMGR_ENQSTATE = 0x0903;
-const u_int32_t jerrno::JERR_RMGR_BADRECTYPE = 0x0904;
+const uint32_t jerrno::JERR_RMGR_UNKNOWNMAGIC = 0x0900;
+const uint32_t jerrno::JERR_RMGR_RIDMISMATCH = 0x0901;
+//const uint32_t jerrno::JERR_RMGR_FIDMISMATCH = 0x0902;
+const uint32_t jerrno::JERR_RMGR_ENQSTATE = 0x0903;
+const uint32_t jerrno::JERR_RMGR_BADRECTYPE = 0x0904;
// class data_tok
-const u_int32_t jerrno::JERR_DTOK_ILLEGALSTATE = 0x0a00;
-// const u_int32_t jerrno::JERR_DTOK_RIDNOTSET = 0x0a01;
+const uint32_t jerrno::JERR_DTOK_ILLEGALSTATE = 0x0a00;
+// const uint32_t jerrno::JERR_DTOK_RIDNOTSET = 0x0a01;
// class enq_map, txn_map
-const u_int32_t jerrno::JERR_MAP_DUPLICATE = 0x0b00;
-const u_int32_t jerrno::JERR_MAP_NOTFOUND = 0x0b01;
-const u_int32_t jerrno::JERR_MAP_LOCKED = 0x0b02;
+const uint32_t jerrno::JERR_MAP_DUPLICATE = 0x0b00;
+const uint32_t jerrno::JERR_MAP_NOTFOUND = 0x0b01;
+const uint32_t jerrno::JERR_MAP_LOCKED = 0x0b02;
// class jinf
-const u_int32_t jerrno::JERR_JINF_CVALIDFAIL = 0x0c00;
-const u_int32_t jerrno::JERR_JINF_NOVALUESTR = 0x0c01;
-const u_int32_t jerrno::JERR_JINF_BADVALUESTR = 0x0c02;
-const u_int32_t jerrno::JERR_JINF_JDATEMPTY = 0x0c03;
-const u_int32_t jerrno::JERR_JINF_TOOMANYFILES = 0x0c04;
-const u_int32_t jerrno::JERR_JINF_INVALIDFHDR = 0x0c05;
-const u_int32_t jerrno::JERR_JINF_STAT = 0x0c06;
-const u_int32_t jerrno::JERR_JINF_NOTREGFILE = 0x0c07;
-const u_int32_t jerrno::JERR_JINF_BADFILESIZE = 0x0c08;
-const u_int32_t jerrno::JERR_JINF_OWIBAD = 0x0c09;
-const u_int32_t jerrno::JERR_JINF_ZEROLENFILE = 0x0c0a;
+//const uint32_t jerrno::JERR_JINF_CVALIDFAIL = 0x0c00;
+//const uint32_t jerrno::JERR_JINF_NOVALUESTR = 0x0c01;
+//const uint32_t jerrno::JERR_JINF_BADVALUESTR = 0x0c02;
+//const uint32_t jerrno::JERR_JINF_JDATEMPTY = 0x0c03;
+//const uint32_t jerrno::JERR_JINF_TOOMANYFILES = 0x0c04;
+//const uint32_t jerrno::JERR_JINF_INVALIDFHDR = 0x0c05;
+//const uint32_t jerrno::JERR_JINF_STAT = 0x0c06;
+//const uint32_t jerrno::JERR_JINF_NOTREGFILE = 0x0c07;
+//const uint32_t jerrno::JERR_JINF_BADFILESIZE = 0x0c08;
+//const uint32_t jerrno::JERR_JINF_OWIBAD = 0x0c09;
+//const uint32_t jerrno::JERR_JINF_ZEROLENFILE = 0x0c0a;
// Negative returns for some functions
const int32_t jerrno::AIO_TIMEOUT = -1;
@@ -180,20 +167,20 @@ jerrno::__init()
_err_map[JERR_JDIR_BADFTYPE] = "JERR_JDIR_BADFTYPE: Bad or unknown file type (stat mode).";
// class fcntl
- _err_map[JERR_FCNTL_OPENWR] = "JERR_FCNTL_OPENWR: Unable to open file for write.";
- _err_map[JERR_FCNTL_WRITE] = "JERR_FCNTL_WRITE: Unable to write to file.";
- _err_map[JERR_FCNTL_CLOSE] = "JERR_FCNTL_CLOSE: File close failed.";
- _err_map[JERR_FCNTL_FILEOFFSOVFL] = "JERR_FCNTL_FILEOFFSOVFL: Attempted increase file offset past file size.";
- _err_map[JERR_FCNTL_CMPLOFFSOVFL] = "JERR_FCNTL_CMPLOFFSOVFL: Attempted increase completed file offset past submitted offset.";
- _err_map[JERR_FCNTL_RDOFFSOVFL] = "JERR_FCNTL_RDOFFSOVFL: Attempted increase read offset past write offset.";
+// _err_map[JERR_FCNTL_OPENWR] = "JERR_FCNTL_OPENWR: Unable to open file for write.";
+// _err_map[JERR_FCNTL_WRITE] = "JERR_FCNTL_WRITE: Unable to write to file.";
+// _err_map[JERR_FCNTL_CLOSE] = "JERR_FCNTL_CLOSE: File close failed.";
+// _err_map[JERR_FCNTL_FILEOFFSOVFL] = "JERR_FCNTL_FILEOFFSOVFL: Attempted increase file offset past file size.";
+// _err_map[JERR_FCNTL_CMPLOFFSOVFL] = "JERR_FCNTL_CMPLOFFSOVFL: Attempted increase completed file offset past submitted offset.";
+// _err_map[JERR_FCNTL_RDOFFSOVFL] = "JERR_FCNTL_RDOFFSOVFL: Attempted increase read offset past write offset.";
// class lfmgr
- _err_map[JERR_LFMGR_BADAEFNUMLIM] = "JERR_LFMGR_BADAEFNUMLIM: Auto-expand file number limit lower than initial number of journal files.";
- _err_map[JERR_LFMGR_AEFNUMLIMIT] = "JERR_LFMGR_AEFNUMLIMIT: Exceeded auto-expand file number limit.";
- _err_map[JERR_LFMGR_AEDISABLED] = "JERR_LFMGR_AEDISABLED: Attempted to expand with auto-expand disabled.";
+// _err_map[JERR_LFMGR_BADAEFNUMLIM] = "JERR_LFMGR_BADAEFNUMLIM: Auto-expand file number limit lower than initial number of journal files.";
+// _err_map[JERR_LFMGR_AEFNUMLIMIT] = "JERR_LFMGR_AEFNUMLIMIT: Exceeded auto-expand file number limit.";
+// _err_map[JERR_LFMGR_AEDISABLED] = "JERR_LFMGR_AEDISABLED: Attempted to expand with auto-expand disabled.";
// class rrfc
- _err_map[JERR_RRFC_OPENRD] = "JERR_RRFC_OPENRD: Unable to open file for read.";
+// _err_map[JERR_RRFC_OPENRD] = "JERR_RRFC_OPENRD: Unable to open file for read.";
// class jrec, enq_rec, deq_rec, txn_rec
_err_map[JERR_JREC_BADRECHDR] = "JERR_JREC_BADRECHDR: Invalid data record header.";
@@ -223,17 +210,17 @@ jerrno::__init()
_err_map[JERR_MAP_LOCKED] = "JERR_MAP_LOCKED: Record ID locked by a pending transaction.";
// class jinf
- _err_map[JERR_JINF_CVALIDFAIL] = "JERR_JINF_CVALIDFAIL: Journal compatibility validation failure.";
- _err_map[JERR_JINF_NOVALUESTR] = "JERR_JINF_NOVALUESTR: No value attribute found in jinf file.";
- _err_map[JERR_JINF_BADVALUESTR] = "JERR_JINF_BADVALUESTR: Bad format for value attribute in jinf file";
- _err_map[JERR_JINF_JDATEMPTY] = "JERR_JINF_JDATEMPTY: Journal data files empty.";
- _err_map[JERR_JINF_TOOMANYFILES] = "JERR_JINF_TOOMANYFILES: Too many journal data files.";
- _err_map[JERR_JINF_INVALIDFHDR] = "JERR_JINF_INVALIDFHDR: Invalid journal data file header";
- _err_map[JERR_JINF_STAT] = "JERR_JINF_STAT: Error while trying to stat a journal data file";
- _err_map[JERR_JINF_NOTREGFILE] = "JERR_JINF_NOTREGFILE: Target journal data file is not a regular file";
- _err_map[JERR_JINF_BADFILESIZE] = "JERR_JINF_BADFILESIZE: Journal data file is of incorrect or unexpected size";
- _err_map[JERR_JINF_OWIBAD] = "JERR_JINF_OWIBAD: Journal data files have inconsistent OWI flags; >1 transition found in non-auto-expand or min-size journal";
- _err_map[JERR_JINF_ZEROLENFILE] = "JERR_JINF_ZEROLENFILE: Journal info file zero length";
+// _err_map[JERR_JINF_CVALIDFAIL] = "JERR_JINF_CVALIDFAIL: Journal compatibility validation failure.";
+// _err_map[JERR_JINF_NOVALUESTR] = "JERR_JINF_NOVALUESTR: No value attribute found in jinf file.";
+// _err_map[JERR_JINF_BADVALUESTR] = "JERR_JINF_BADVALUESTR: Bad format for value attribute in jinf file";
+// _err_map[JERR_JINF_JDATEMPTY] = "JERR_JINF_JDATEMPTY: Journal data files empty.";
+// _err_map[JERR_JINF_TOOMANYFILES] = "JERR_JINF_TOOMANYFILES: Too many journal data files.";
+// _err_map[JERR_JINF_INVALIDFHDR] = "JERR_JINF_INVALIDFHDR: Invalid journal data file header";
+// _err_map[JERR_JINF_STAT] = "JERR_JINF_STAT: Error while trying to stat a journal data file";
+// _err_map[JERR_JINF_NOTREGFILE] = "JERR_JINF_NOTREGFILE: Target journal data file is not a regular file";
+// _err_map[JERR_JINF_BADFILESIZE] = "JERR_JINF_BADFILESIZE: Journal data file is of incorrect or unexpected size";
+// _err_map[JERR_JINF_OWIBAD] = "JERR_JINF_OWIBAD: Journal data files have inconsistent OWI flags; >1 transition found in non-auto-expand or min-size journal";
+// _err_map[JERR_JINF_ZEROLENFILE] = "JERR_JINF_ZEROLENFILE: Journal info file zero length";
//_err_map[] = "";
@@ -241,7 +228,7 @@ jerrno::__init()
}
const char*
-jerrno::err_msg(const u_int32_t err_no) throw ()
+jerrno::err_msg(const uint32_t err_no) throw ()
{
_err_map_itr = _err_map.find(err_no);
if (_err_map_itr == _err_map.end())
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jerrno.h b/qpid/cpp/src/qpid/linearstore/jrnl/jerrno.h
index 4c8b71c423..3d43c986b7 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jerrno.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jerrno.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file jerrno.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::jerrno (journal error
- * codes). See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_JERRNO_H
#define QPID_LEGACYSTORE_JRNL_JERRNO_H
@@ -42,8 +31,8 @@ class jerrno;
}
#include <map>
+#include <stdint.h>
#include <string>
-#include <sys/types.h>
namespace mrg
{
@@ -56,101 +45,101 @@ namespace journal
*/
class jerrno
{
- static std::map<u_int32_t, const char*> _err_map; ///< Map of error messages
- static std::map<u_int32_t, const char*>::iterator _err_map_itr; ///< Iterator
+ static std::map<uint32_t, const char*> _err_map; ///< Map of error messages
+ static std::map<uint32_t, const char*>::iterator _err_map_itr; ///< Iterator
static bool _initialized; ///< Dummy flag, used to initialise map.
public:
// generic errors
- static const u_int32_t JERR__MALLOC; ///< Buffer memory allocation failed
- static const u_int32_t JERR__UNDERFLOW; ///< Underflow error
- static const u_int32_t JERR__NINIT; ///< Operation on uninitialized class
- static const u_int32_t JERR__AIO; ///< AIO failure
- static const u_int32_t JERR__FILEIO; ///< File read or write failure
- static const u_int32_t JERR__RTCLOCK; ///< Reading real-time clock failed
- static const u_int32_t JERR__PTHREAD; ///< pthread failure
- static const u_int32_t JERR__TIMEOUT; ///< Timeout waiting for an event
- static const u_int32_t JERR__UNEXPRESPONSE; ///< Unexpected response to call or event
- static const u_int32_t JERR__RECNFOUND; ///< Record not found
- static const u_int32_t JERR__NOTIMPL; ///< Not implemented
+ static const uint32_t JERR__MALLOC; ///< Buffer memory allocation failed
+ static const uint32_t JERR__UNDERFLOW; ///< Underflow error
+ static const uint32_t JERR__NINIT; ///< Operation on uninitialized class
+ static const uint32_t JERR__AIO; ///< AIO failure
+ static const uint32_t JERR__FILEIO; ///< File read or write failure
+ static const uint32_t JERR__RTCLOCK; ///< Reading real-time clock failed
+ static const uint32_t JERR__PTHREAD; ///< pthread failure
+ static const uint32_t JERR__TIMEOUT; ///< Timeout waiting for an event
+ static const uint32_t JERR__UNEXPRESPONSE; ///< Unexpected response to call or event
+ static const uint32_t JERR__RECNFOUND; ///< Record not found
+ static const uint32_t JERR__NOTIMPL; ///< Not implemented
// class jcntl
- static const u_int32_t JERR_JCNTL_STOPPED; ///< Operation on stopped journal
- static const u_int32_t JERR_JCNTL_READONLY; ///< Write operation on read-only journal
- static const u_int32_t JERR_JCNTL_AIOCMPLWAIT; ///< Timeout waiting for AIOs to complete
- static const u_int32_t JERR_JCNTL_UNKNOWNMAGIC; ///< Found record with unknown magic
- static const u_int32_t JERR_JCNTL_NOTRECOVERED; ///< Req' recover() to be called first
- static const u_int32_t JERR_JCNTL_RECOVERJFULL; ///< Journal data files full, cannot write
- static const u_int32_t JERR_JCNTL_OWIMISMATCH; ///< OWI change found in unexpected location
+ static const uint32_t JERR_JCNTL_STOPPED; ///< Operation on stopped journal
+ static const uint32_t JERR_JCNTL_READONLY; ///< Write operation on read-only journal
+ static const uint32_t JERR_JCNTL_AIOCMPLWAIT; ///< Timeout waiting for AIOs to complete
+ static const uint32_t JERR_JCNTL_UNKNOWNMAGIC; ///< Found record with unknown magic
+ static const uint32_t JERR_JCNTL_NOTRECOVERED; ///< Req' recover() to be called first
+ static const uint32_t JERR_JCNTL_RECOVERJFULL; ///< Journal data files full, cannot write
+ static const uint32_t JERR_JCNTL_OWIMISMATCH; ///< OWI change found in unexpected location
// class jdir
- static const u_int32_t JERR_JDIR_NOTDIR; ///< Exists but is not a directory
- static const u_int32_t JERR_JDIR_MKDIR; ///< Directory creation failed
- static const u_int32_t JERR_JDIR_OPENDIR; ///< Directory open failed
- static const u_int32_t JERR_JDIR_READDIR; ///< Directory read failed
- static const u_int32_t JERR_JDIR_CLOSEDIR; ///< Directory close failed
- static const u_int32_t JERR_JDIR_RMDIR; ///< Directory delete failed
- static const u_int32_t JERR_JDIR_NOSUCHFILE; ///< File does not exist
- static const u_int32_t JERR_JDIR_FMOVE; ///< File move failed
- static const u_int32_t JERR_JDIR_STAT; ///< File stat failed
- static const u_int32_t JERR_JDIR_UNLINK; ///< File delete failed
- static const u_int32_t JERR_JDIR_BADFTYPE; ///< Bad or unknown file type (stat mode)
+ static const uint32_t JERR_JDIR_NOTDIR; ///< Exists but is not a directory
+ static const uint32_t JERR_JDIR_MKDIR; ///< Directory creation failed
+ static const uint32_t JERR_JDIR_OPENDIR; ///< Directory open failed
+ static const uint32_t JERR_JDIR_READDIR; ///< Directory read failed
+ static const uint32_t JERR_JDIR_CLOSEDIR; ///< Directory close failed
+ static const uint32_t JERR_JDIR_RMDIR; ///< Directory delete failed
+ static const uint32_t JERR_JDIR_NOSUCHFILE; ///< File does not exist
+ static const uint32_t JERR_JDIR_FMOVE; ///< File move failed
+ static const uint32_t JERR_JDIR_STAT; ///< File stat failed
+ static const uint32_t JERR_JDIR_UNLINK; ///< File delete failed
+ static const uint32_t JERR_JDIR_BADFTYPE; ///< Bad or unknown file type (stat mode)
// class fcntl
- static const u_int32_t JERR_FCNTL_OPENWR; ///< Unable to open file for write
- static const u_int32_t JERR_FCNTL_WRITE; ///< Unable to write to file
- static const u_int32_t JERR_FCNTL_CLOSE; ///< File close failed
- static const u_int32_t JERR_FCNTL_FILEOFFSOVFL; ///< Increased offset past file size
- static const u_int32_t JERR_FCNTL_CMPLOFFSOVFL; ///< Increased cmpl offs past subm offs
- static const u_int32_t JERR_FCNTL_RDOFFSOVFL; ///< Increased read offs past write offs
+// static const uint32_t JERR_FCNTL_OPENWR; ///< Unable to open file for write
+// static const uint32_t JERR_FCNTL_WRITE; ///< Unable to write to file
+// static const uint32_t JERR_FCNTL_CLOSE; ///< File close failed
+// static const uint32_t JERR_FCNTL_FILEOFFSOVFL; ///< Increased offset past file size
+// static const uint32_t JERR_FCNTL_CMPLOFFSOVFL; ///< Increased cmpl offs past subm offs
+// static const uint32_t JERR_FCNTL_RDOFFSOVFL; ///< Increased read offs past write offs
// class lfmgr
- static const u_int32_t JERR_LFMGR_BADAEFNUMLIM; ///< Bad auto-expand file number limit
- static const u_int32_t JERR_LFMGR_AEFNUMLIMIT; ///< Exceeded auto-expand file number limit
- static const u_int32_t JERR_LFMGR_AEDISABLED; ///< Attempted to expand with auto-expand disabled
+// static const uint32_t JERR_LFMGR_BADAEFNUMLIM; ///< Bad auto-expand file number limit
+// static const uint32_t JERR_LFMGR_AEFNUMLIMIT; ///< Exceeded auto-expand file number limit
+// static const uint32_t JERR_LFMGR_AEDISABLED; ///< Attempted to expand with auto-expand disabled
// class rrfc
- static const u_int32_t JERR_RRFC_OPENRD; ///< Unable to open file for read
+// static const uint32_t JERR_RRFC_OPENRD; ///< Unable to open file for read
// class jrec, enq_rec, deq_rec, txn_rec
- static const u_int32_t JERR_JREC_BADRECHDR; ///< Invalid data record header
- static const u_int32_t JERR_JREC_BADRECTAIL; ///< Invalid data record tail
+ static const uint32_t JERR_JREC_BADRECHDR; ///< Invalid data record header
+ static const uint32_t JERR_JREC_BADRECTAIL; ///< Invalid data record tail
// class wmgr
- static const u_int32_t JERR_WMGR_BADPGSTATE; ///< Page buffer in illegal state.
- static const u_int32_t JERR_WMGR_BADDTOKSTATE; ///< Data token in illegal state.
- static const u_int32_t JERR_WMGR_ENQDISCONT; ///< Enq. new dtok when previous part compl.
- static const u_int32_t JERR_WMGR_DEQDISCONT; ///< Deq. new dtok when previous part compl.
- static const u_int32_t JERR_WMGR_DEQRIDNOTENQ; ///< Deq. rid not enqueued
+ static const uint32_t JERR_WMGR_BADPGSTATE; ///< Page buffer in illegal state.
+ static const uint32_t JERR_WMGR_BADDTOKSTATE; ///< Data token in illegal state.
+ static const uint32_t JERR_WMGR_ENQDISCONT; ///< Enq. new dtok when previous part compl.
+ static const uint32_t JERR_WMGR_DEQDISCONT; ///< Deq. new dtok when previous part compl.
+ static const uint32_t JERR_WMGR_DEQRIDNOTENQ; ///< Deq. rid not enqueued
// class rmgr
- static const u_int32_t JERR_RMGR_UNKNOWNMAGIC; ///< Found record with unknown magic
- static const u_int32_t JERR_RMGR_RIDMISMATCH; ///< RID mismatch between rec and dtok
- //static const u_int32_t JERR_RMGR_FIDMISMATCH; ///< FID mismatch between emap and rrfc
- static const u_int32_t JERR_RMGR_ENQSTATE; ///< Attempted read when wstate not ENQ
- static const u_int32_t JERR_RMGR_BADRECTYPE; ///< Attempted op on incorrect rec type
+ static const uint32_t JERR_RMGR_UNKNOWNMAGIC; ///< Found record with unknown magic
+ static const uint32_t JERR_RMGR_RIDMISMATCH; ///< RID mismatch between rec and dtok
+ //static const uint32_t JERR_RMGR_FIDMISMATCH; ///< FID mismatch between emap and rrfc
+ static const uint32_t JERR_RMGR_ENQSTATE; ///< Attempted read when wstate not ENQ
+ static const uint32_t JERR_RMGR_BADRECTYPE; ///< Attempted op on incorrect rec type
// class data_tok
- static const u_int32_t JERR_DTOK_ILLEGALSTATE; ///< Attempted to change to illegal state
-// static const u_int32_t JERR_DTOK_RIDNOTSET; ///< Record ID not set
+ static const uint32_t JERR_DTOK_ILLEGALSTATE; ///< Attempted to change to illegal state
+// static const uint32_t JERR_DTOK_RIDNOTSET; ///< Record ID not set
// class enq_map, txn_map
- static const u_int32_t JERR_MAP_DUPLICATE; ///< Attempted to insert using duplicate key
- static const u_int32_t JERR_MAP_NOTFOUND; ///< Key not found in map
- static const u_int32_t JERR_MAP_LOCKED; ///< rid locked by pending txn
+ static const uint32_t JERR_MAP_DUPLICATE; ///< Attempted to insert using duplicate key
+ static const uint32_t JERR_MAP_NOTFOUND; ///< Key not found in map
+ static const uint32_t JERR_MAP_LOCKED; ///< rid locked by pending txn
// class jinf
- static const u_int32_t JERR_JINF_CVALIDFAIL; ///< Compatibility validation failure
- static const u_int32_t JERR_JINF_NOVALUESTR; ///< No value attr found in jinf file
- static const u_int32_t JERR_JINF_BADVALUESTR; ///< Bad format for value attr in jinf file
- static const u_int32_t JERR_JINF_JDATEMPTY; ///< Journal data files empty
- static const u_int32_t JERR_JINF_TOOMANYFILES; ///< Too many journal data files
- static const u_int32_t JERR_JINF_INVALIDFHDR; ///< Invalid file header
- static const u_int32_t JERR_JINF_STAT; ///< Error while trying to stat a file
- static const u_int32_t JERR_JINF_NOTREGFILE; ///< Target file is not a regular file
- static const u_int32_t JERR_JINF_BADFILESIZE; ///< File is of incorrect or unexpected size
- static const u_int32_t JERR_JINF_OWIBAD; ///< OWI inconsistent (>1 transition in non-ae journal)
- static const u_int32_t JERR_JINF_ZEROLENFILE; ///< Journal info file is zero length (empty).
+// static const uint32_t JERR_JINF_CVALIDFAIL; ///< Compatibility validation failure
+// static const uint32_t JERR_JINF_NOVALUESTR; ///< No value attr found in jinf file
+// static const uint32_t JERR_JINF_BADVALUESTR; ///< Bad format for value attr in jinf file
+// static const uint32_t JERR_JINF_JDATEMPTY; ///< Journal data files empty
+// static const uint32_t JERR_JINF_TOOMANYFILES; ///< Too many journal data files
+// static const uint32_t JERR_JINF_INVALIDFHDR; ///< Invalid file header
+// static const uint32_t JERR_JINF_STAT; ///< Error while trying to stat a file
+// static const uint32_t JERR_JINF_NOTREGFILE; ///< Target file is not a regular file
+// static const uint32_t JERR_JINF_BADFILESIZE; ///< File is of incorrect or unexpected size
+// static const uint32_t JERR_JINF_OWIBAD; ///< OWI inconsistent (>1 transition in non-ae journal)
+// static const uint32_t JERR_JINF_ZEROLENFILE; ///< Journal info file is zero length (empty).
// Negative returns for some functions
static const int32_t AIO_TIMEOUT; ///< Timeout waiting for AIO return
@@ -158,7 +147,7 @@ namespace journal
/**
* \brief Method to access error message from known error number.
*/
- static const char* err_msg(const u_int32_t err_no) throw ();
+ static const char* err_msg(const uint32_t err_no) throw ();
private:
/**
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jexception.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/jexception.cpp
index 5c571020e4..69d59c6d13 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jexception.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jexception.cpp
@@ -19,22 +19,11 @@
*
*/
-/**
- * \file jexception.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * Generic journal exception class mrg::journal::jexception. See comments
- * in file jexception.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/jexception.h"
#include <iomanip>
#include <sstream>
-#include "qpid/legacystore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
#define CATLEN(p) MAX_MSG_SIZE - std::strlen(p) - 1
@@ -50,7 +39,7 @@ jexception::jexception() throw ():
format();
}
-jexception::jexception(const u_int32_t err_code) throw ():
+jexception::jexception(const uint32_t err_code) throw ():
std::exception(),
_err_code(err_code)
{
@@ -73,7 +62,7 @@ jexception::jexception(const std::string& additional_info) throw ():
format();
}
-jexception::jexception(const u_int32_t err_code, const char* additional_info) throw ():
+jexception::jexception(const uint32_t err_code, const char* additional_info) throw ():
std::exception(),
_err_code(err_code),
_additional_info(additional_info)
@@ -81,7 +70,7 @@ jexception::jexception(const u_int32_t err_code, const char* additional_info) th
format();
}
-jexception::jexception(const u_int32_t err_code, const std::string& additional_info) throw ():
+jexception::jexception(const uint32_t err_code, const std::string& additional_info) throw ():
std::exception(),
_err_code(err_code),
_additional_info(additional_info)
@@ -89,7 +78,7 @@ jexception::jexception(const u_int32_t err_code, const std::string& additional_i
format();
}
-jexception::jexception(const u_int32_t err_code, const char* throwing_class,
+jexception::jexception(const uint32_t err_code, const char* throwing_class,
const char* throwing_fn) throw ():
std::exception(),
_err_code(err_code),
@@ -99,7 +88,7 @@ jexception::jexception(const u_int32_t err_code, const char* throwing_class,
format();
}
-jexception::jexception(const u_int32_t err_code, const std::string& throwing_class,
+jexception::jexception(const uint32_t err_code, const std::string& throwing_class,
const std::string& throwing_fn) throw ():
std::exception(),
_err_code(err_code),
@@ -109,7 +98,7 @@ jexception::jexception(const u_int32_t err_code, const std::string& throwing_cla
format();
}
-jexception::jexception(const u_int32_t err_code, const char* additional_info,
+jexception::jexception(const uint32_t err_code, const char* additional_info,
const char* throwing_class, const char* throwing_fn) throw ():
std::exception(),
_err_code(err_code),
@@ -120,7 +109,7 @@ jexception::jexception(const u_int32_t err_code, const char* additional_info,
format();
}
-jexception::jexception(const u_int32_t err_code, const std::string& additional_info,
+jexception::jexception(const uint32_t err_code, const std::string& additional_info,
const std::string& throwing_class, const std::string& throwing_fn) throw ():
std::exception(),
_err_code(err_code),
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jexception.h b/qpid/cpp/src/qpid/linearstore/jrnl/jexception.h
index 34d8373235..4716638008 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jexception.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jexception.h
@@ -19,19 +19,6 @@
*
*/
-/**
- * \file jexception.h
- *
- * Qpid asynchronous store plugin library
- *
- * Generic journal exception class mrg::journal::jexception (derived
- * from class std::exception). Intended to serve as a common exception
- * class for all more speicalized exceptions in the message journal. See
- * class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_JEXCEPTION_H
#define QPID_LEGACYSTORE_JRNL_JEXCEPTION_H
@@ -48,10 +35,9 @@ class jexception;
#include <cstdlib>
#include <cstring>
#include <exception>
-#include "qpid/legacystore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
#include <sstream>
#include <string>
-#include <sys/types.h>
// Macro for formatting commom system errors
#define FORMAT_SYSERR(errno) " errno=" << errno << " (" << std::strerror(errno) << ")"
@@ -96,7 +82,7 @@ namespace journal
class jexception : public std::exception
{
private:
- u_int32_t _err_code;
+ uint32_t _err_code;
std::string _additional_info;
std::string _throwing_class;
std::string _throwing_fn;
@@ -106,28 +92,28 @@ namespace journal
public:
jexception() throw ();
- jexception(const u_int32_t err_code) throw ();
+ jexception(const uint32_t err_code) throw ();
jexception(const char* additional_info) throw ();
jexception(const std::string& additional_info) throw ();
- jexception(const u_int32_t err_code, const char* additional_info) throw ();
- jexception(const u_int32_t err_code, const std::string& additional_info) throw ();
+ jexception(const uint32_t err_code, const char* additional_info) throw ();
+ jexception(const uint32_t err_code, const std::string& additional_info) throw ();
- jexception(const u_int32_t err_code, const char* throwing_class, const char* throwing_fn)
+ jexception(const uint32_t err_code, const char* throwing_class, const char* throwing_fn)
throw ();
- jexception(const u_int32_t err_code, const std::string& throwing_class,
+ jexception(const uint32_t err_code, const std::string& throwing_class,
const std::string& throwing_fn) throw ();
- jexception(const u_int32_t err_code, const char* additional_info,
+ jexception(const uint32_t err_code, const char* additional_info,
const char* throwing_class, const char* throwing_fn) throw ();
- jexception(const u_int32_t err_code, const std::string& additional_info,
+ jexception(const uint32_t err_code, const std::string& additional_info,
const std::string& throwing_class, const std::string& throwing_fn) throw ();
virtual ~jexception() throw ();
virtual const char* what() const throw (); // override std::exception::what()
- inline u_int32_t err_code() const throw () { return _err_code; }
+ inline uint32_t err_code() const throw () { return _err_code; }
inline const std::string additional_info() const throw () { return _additional_info; }
inline const std::string throwing_class() const throw () { return _throwing_class; }
inline const std::string throwing_fn() const throw () { return _throwing_fn; }
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jinf.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/jinf.cpp
deleted file mode 100644
index 3326005d9b..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jinf.cpp
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file jinf.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains the code for the mrg::journal::jinf class.
- *
- * See jinf.h comments for details of this class.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/jinf.h"
-
-#include <cstdlib>
-#include <cstring>
-#include <ctime>
-#include <fstream>
-#include "qpid/legacystore/jrnl/file_hdr.h"
-#include "qpid/legacystore/jrnl/jcntl.h"
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/lp_map.h"
-#include <sstream>
-#include <sys/stat.h>
-
-namespace mrg
-{
-namespace journal
-{
-
-jinf::jinf(const std::string& jinf_filename, bool validate_flag):
- _jver(0),
- _filename(jinf_filename),
- _num_jfiles(0),
- _ae(false),
- _ae_max_jfiles(0),
- _jfsize_sblks(0),
- _sblk_size_dblks(0),
- _dblk_size(0),
- _wcache_pgsize_sblks(0),
- _wcache_num_pages(0),
- _rcache_pgsize_sblks(0),
- _rcache_num_pages(0),
- _tm_ptr(0),
- _valid_flag(false),
- _analyzed_flag(false),
- _initial_owi(false),
- _frot(false)
-{
- read(_filename);
- if (validate_flag)
- validate();
-}
-
-jinf::jinf(const std::string& jid, const std::string& jdir, const std::string& base_filename, const u_int16_t num_jfiles,
- const bool auto_expand, const u_int16_t ae_max_jfiles, const u_int32_t jfsize_sblks,
- const u_int32_t wcache_pgsize_sblks, const u_int16_t wcache_num_pages, const timespec& ts):
- _jver(RHM_JDAT_VERSION),
- _jid(jid),
- _jdir(jdir),
- _base_filename(base_filename),
- _ts(ts),
- _num_jfiles(num_jfiles),
- _ae(auto_expand),
- _ae_max_jfiles(ae_max_jfiles),
- _jfsize_sblks(jfsize_sblks),
- _sblk_size_dblks(JRNL_SBLK_SIZE),
- _dblk_size(JRNL_DBLK_SIZE),
- _wcache_pgsize_sblks(wcache_pgsize_sblks),
- _wcache_num_pages(wcache_num_pages),
- _rcache_pgsize_sblks(JRNL_RMGR_PAGE_SIZE),
- _rcache_num_pages(JRNL_RMGR_PAGES),
- _tm_ptr(std::localtime(&ts.tv_sec)),
- _valid_flag(false),
- _analyzed_flag(false),
- _initial_owi(false)
-{
- set_filename();
-}
-
-jinf::~jinf()
-{}
-
-void
-jinf::validate()
-{
- bool err = false;
- std::ostringstream oss;
- if (_jver != RHM_JDAT_VERSION)
- {
- oss << "File \"" << _filename << "\": ";
- oss << "RHM_JDAT_VERSION mismatch: found=" << (int)_jver;
- oss << "; required=" << RHM_JDAT_VERSION << std::endl;
- err = true;
- }
- if (_num_jfiles < JRNL_MIN_NUM_FILES)
- {
- oss << "File \"" << _filename << "\": ";
- oss << "Number of journal files too small: found=" << _num_jfiles;
- oss << "; minimum=" << JRNL_MIN_NUM_FILES << std::endl;
- err = true;
- }
- if (_num_jfiles > JRNL_MAX_NUM_FILES)
- {
- oss << "File \"" << _filename << "\": ";
- oss << "Number of journal files too large: found=" << _num_jfiles;
- oss << "; maximum=" << JRNL_MAX_NUM_FILES << std::endl;
- err = true;
- }
- if (_ae)
- {
- if (_ae_max_jfiles < _num_jfiles)
- {
- oss << "File \"" << _filename << "\": ";
- oss << "Number of journal files exceeds auto-expansion limit: found=" << _num_jfiles;
- oss << "; maximum=" << _ae_max_jfiles;
- err = true;
- }
- if (_ae_max_jfiles > JRNL_MAX_NUM_FILES)
- {
- oss << "File \"" << _filename << "\": ";
- oss << "Auto-expansion file limit too large: found=" << _ae_max_jfiles;
- oss << "; maximum=" << JRNL_MAX_NUM_FILES;
- err = true;
- }
- }
- if (_jfsize_sblks < JRNL_MIN_FILE_SIZE)
- {
- oss << "File \"" << _filename << "\": ";
- oss << "Journal file size too small: found=" << _jfsize_sblks;
- oss << "; minimum=" << JRNL_MIN_FILE_SIZE << " (sblks)" << std::endl;
- err = true;
- }
- if (_sblk_size_dblks != JRNL_SBLK_SIZE)
- {
- oss << "File \"" << _filename << "\": ";
- oss << "JRNL_SBLK_SIZE mismatch: found=" << _sblk_size_dblks;
- oss << "; required=" << JRNL_SBLK_SIZE << std::endl;
- err = true;
- }
- if (_dblk_size != JRNL_DBLK_SIZE)
- {
- oss << "File \"" << _filename << "\": ";
- oss << "JRNL_DBLK_SIZE mismatch: found=" << _dblk_size;
- oss << "; required=" << JRNL_DBLK_SIZE << std::endl;
- err = true;
- }
- if (err)
- throw jexception(jerrno::JERR_JINF_CVALIDFAIL, oss.str(), "jinf", "validate");
- _valid_flag = true;
-}
-
-void
-jinf::analyze()
-{
- lp_map early_map; // map for all owi flags same as pfid 0
- lp_map late_map; // map for all owi flags opposite to pfid 0
- bool late_latch = false; // latch for owi switchover
-
- if (!_valid_flag)
- validate();
- bool done = false;
- for (u_int16_t pfid=0; pfid<_num_jfiles && !done; pfid++)
- {
- std::ostringstream oss;
- if (_jdir.at(_jdir.size() - 1) == '/')
- oss << _jdir << _base_filename << ".";
- else
- oss << _jdir << "/" << _base_filename << ".";
- oss << std::setw(4) << std::setfill('0') << std::hex << pfid;
- oss << "." << JRNL_DATA_EXTENSION;
-
- // Check size of each file is consistent and expected
- u_int32_t fsize = get_filesize(oss.str());
- if (fsize != (_jfsize_sblks + 1) * _sblk_size_dblks * _dblk_size)
- {
- std::ostringstream oss1;
- oss1 << "File \"" << oss.str() << "\": size=" << fsize << "; expected=" << ((_jfsize_sblks + 1) * _sblk_size_dblks * _dblk_size);
- throw jexception(jerrno::JERR_JINF_BADFILESIZE, oss1.str(), "jinf", "analyze");
- }
-
- std::ifstream jifs(oss.str().c_str());
- if (!jifs.good())
- throw jexception(jerrno::JERR__FILEIO, oss.str(), "jinf", "analyze");
- file_hdr fhdr;
- jifs.read((char*)&fhdr, sizeof(fhdr));
- if (fhdr._magic != RHM_JDAT_FILE_MAGIC) // No file header
- {
- if (fhdr._magic != 0)
- throw jexception(jerrno::JERR_JINF_INVALIDFHDR, oss.str(), "jinf", "analyze");
- if (!pfid) // pfid 0 == lid 0 cannot be empty
- throw jexception(jerrno::JERR_JINF_JDATEMPTY, oss.str(), "jinf", "analyze");
- _frot = true;
- done = true;
- }
- else
- {
- assert(pfid == fhdr._pfid);
- if (pfid == 0)
- {
- _initial_owi = fhdr.get_owi();
- early_map.insert(fhdr._lfid, pfid);
- }
- else
- {
- if (_initial_owi == fhdr.get_owi())
- {
- early_map.insert(fhdr._lfid, pfid);
- if (late_latch && (!_ae || _num_jfiles == JRNL_MIN_NUM_FILES))
- throw jexception(jerrno::JERR_JINF_OWIBAD, oss.str(), "jinf", "analyze");
- }
- else
- {
- late_map.insert(fhdr._lfid, pfid);
- late_latch = true;
- }
- }
- }
- jifs.close();
- } // for (pfid)
-
- // If this is not the first rotation, all files should be in either early or late maps
- if (!_frot) assert(early_map.size() + late_map.size() == _num_jfiles);
-
- _pfid_list.clear();
- late_map.get_pfid_list(_pfid_list);
- early_map.get_pfid_list(_pfid_list);
-
- // Check OWI consistency
-// for (u_int16_t lfid=0; lfid<_num_jfiles && !done; lfid++)
-// {
-// throw jexception(jerrno::JERR_JINF_OWIBAD, oss.str(), "jinf", "analyze");
-// }
-
- _analyzed_flag = true;
-}
-
-void
-jinf::write()
-{
- std::ostringstream oss;
- oss << _jdir << "/" << _base_filename << "." << JRNL_INFO_EXTENSION;
- std::ofstream of(oss.str().c_str(), std::ofstream::out | std::ofstream::trunc);
- if (!of.good())
- throw jexception(jerrno::JERR__FILEIO, oss.str(), "jinf", "write");
- of << xml_str();
- of.close();
-}
-
-u_int16_t
-jinf::incr_num_jfiles()
-{
- if (_num_jfiles >= JRNL_MAX_NUM_FILES)
- throw jexception(jerrno::JERR_JINF_TOOMANYFILES, "jinf", "incr_num_jfiles");
- return ++_num_jfiles;
-}
-
-u_int16_t
-jinf::get_first_pfid()
-{
- if (!_analyzed_flag)
- analyze();
- return *_pfid_list.begin();
-}
-
-u_int16_t
-jinf::get_last_pfid()
-{
- if (!_analyzed_flag)
- analyze();
- return *_pfid_list.rbegin();
-}
-
-jinf::pfid_list&
-jinf::get_pfid_list()
-{
- if (!_analyzed_flag)
- analyze();
- return _pfid_list;
-}
-
-void
-jinf::get_normalized_pfid_list(pfid_list& pfid_list)
-{
- if (!_analyzed_flag)
- analyze();
- pfid_list.clear();
- u_int16_t s = _pfid_list.size();
- u_int16_t iz = 0; // index of 0 value
- while (_pfid_list[iz] && iz < s)
- iz++;
- assert(_pfid_list[iz] == 0);
- for (u_int16_t i = iz; i < iz + s; i++)
- pfid_list.push_back(_pfid_list[i % s]);
- assert(pfid_list[0] == 0);
- assert(pfid_list.size() == s);
-}
-
-bool
-jinf::get_initial_owi()
-{
- if (!_analyzed_flag)
- analyze();
- return _initial_owi;
-}
-
-bool
-jinf::get_frot()
-{
- if (!_analyzed_flag)
- analyze();
- return _frot;
-}
-
-std::string
-jinf::to_string() const
-{
- std::ostringstream oss;
- oss << std::setfill('0');
- oss << "Journal ID \"" << _jid << "\" initialized " << (_tm_ptr->tm_year + 1900) << "/";
- oss << std::setw(2) << (_tm_ptr->tm_mon + 1) << "/" << std::setw(2) << _tm_ptr->tm_mday << " ";
- oss << std::setw(2) << _tm_ptr->tm_hour << ":" << std::setw(2) << _tm_ptr->tm_min << ":";
- oss << std::setw(2) << _tm_ptr->tm_sec << "." << std::setw(9) << _ts.tv_nsec << ":" << std::endl;
- oss << " Journal directory: \"" << _jdir << "\"" << std::endl;
- oss << " Journal base filename: \"" << _base_filename << "\"" << std::endl;
- oss << " Journal version: " << (unsigned)_jver << std::endl;
- oss << " Number of journal files: " << _num_jfiles << std::endl;
-// TODO: Uncomment these lines when auto-expand is enabled.
-// oss << " Auto-expand mode: " << (_ae ? "enabled" : "disabled") << std::endl;
-// if (_ae) oss << " Max. number of journal files (in auto-expand mode): " << _ae_max_jfiles << std::endl;
- oss << " Journal file size: " << _jfsize_sblks << " sblks" << std::endl;
- oss << " Softblock size (JRNL_SBLK_SIZE): " << _sblk_size_dblks << " dblks" << std::endl;
- oss << " Datablock size (JRNL_DBLK_SIZE): " << _dblk_size << " bytes" << std::endl;
- oss << " Write page size: " << _wcache_pgsize_sblks << " sblks" << std::endl;
- oss << " Number of write pages: " << _wcache_num_pages << std::endl;
- oss << " Read page size (JRNL_RMGR_PAGE_SIZE): " << _rcache_pgsize_sblks << " sblks" << std::endl;
- oss << " Number of read pages (JRNL_RMGR_PAGES): " << _rcache_num_pages << std::endl;
- return oss.str();
-}
-
-std::string
-jinf::xml_str() const
-{
- // TODO: This is *not* an XML writer, rather for simplicity, it uses literals. I'm sure a more elegant way can be
- // found to do this using the real thing...
-
- std::ostringstream oss;
- oss << std::setfill('0');
- oss << "<?xml version=\"1.0\" ?>" << std::endl;
- oss << "<jrnl>" << std::endl;
- oss << " <journal_version value=\"" << (unsigned)_jver << "\" />" << std::endl;
- oss << " <journal_id>" << std::endl;
- oss << " <id_string value=\"" << _jid << "\" />" << std::endl;
- oss << " <directory value=\"" << _jdir << "\" />" << std::endl;
- oss << " <base_filename value=\"" << _base_filename << "\" />" << std::endl;
- oss << " </journal_id>" << std::endl;
- oss << " <creation_time>" << std::endl;
- oss << " <seconds value=\"" << _ts.tv_sec << "\" />" << std::endl;
- oss << " <nanoseconds value=\"" << _ts.tv_nsec << "\" />" << std::endl;
- oss << " <string value=\"" << (_tm_ptr->tm_year + 1900) << "/";
- oss << std::setw(2) << (_tm_ptr->tm_mon + 1) << "/" << std::setw(2) << _tm_ptr->tm_mday << " ";
- oss << std::setw(2) << _tm_ptr->tm_hour << ":" << std::setw(2) << _tm_ptr->tm_min << ":";
- oss << std::setw(2) << _tm_ptr->tm_sec << "." << std::setw(9) << _ts.tv_nsec;
- oss << "\" />" << std::endl;
- oss << " </creation_time>" << std::endl;
- oss << " <journal_file_geometry>" << std::endl;
- oss << " <number_jrnl_files value=\"" << _num_jfiles << "\" />" << std::endl;
- oss << " <auto_expand value=\"" << (_ae ? "true" : "false") << "\" />" << std::endl;
- if (_ae) oss << " <auto_expand_max_jrnl_files value=\"" << _ae_max_jfiles << "\" />" << std::endl;
- oss << " <jrnl_file_size_sblks value=\"" << _jfsize_sblks << "\" />" << std::endl;
- oss << " <JRNL_SBLK_SIZE value=\"" << _sblk_size_dblks << "\" />" << std::endl;
- oss << " <JRNL_DBLK_SIZE value=\"" << _dblk_size << "\" />" << std::endl;
- oss << " </journal_file_geometry>" << std::endl;
- oss << " <cache_geometry>" << std::endl;
- oss << " <wcache_pgsize_sblks value=\"" << _wcache_pgsize_sblks << "\" />" << std::endl;
- oss << " <wcache_num_pages value=\"" << _wcache_num_pages << "\" />" << std::endl;
- oss << " <JRNL_RMGR_PAGE_SIZE value=\"" << _rcache_pgsize_sblks << "\" />" << std::endl;
- oss << " <JRNL_RMGR_PAGES value=\"" << _rcache_num_pages << "\" />" << std::endl;
- oss << " </cache_geometry>" << std::endl;
- oss << "</jrnl>" << std::endl;
- return oss.str();
-}
-
-void
-jinf::set_filename()
-{
- std::ostringstream oss;
- oss << _jdir << "/" << _base_filename << "." << JRNL_INFO_EXTENSION;
- _filename = oss.str().c_str();
-}
-
-void
-jinf::read(const std::string& jinf_filename)
-{
- // TODO: This is *not* an XML reader, rather for simplicity, it is a brute-force line reader which relies on string
- // recognition. It relies on the format of xml_str() above; it will not handle a XML restructuring.
- // *** Can it be replaced cheaply by a real XML reader? Should it be, or is this sufficient? ***
-
- char buff[1024]; // limit of line input length
- std::ifstream jinfs(jinf_filename.c_str());
- if (!jinfs.good())
- throw jexception(jerrno::JERR__FILEIO, jinf_filename.c_str(), "jinf", "read");
- u_int32_t charcnt = 0;
- while (jinfs.good())
- {
- jinfs.getline(buff, 1023);
- charcnt += std::strlen(buff);
- if (std::strstr(buff, "journal_version"))
- _jver = u_int16_value(buff);
- else if(std::strstr(buff, "id_string"))
- string_value(_jid, buff);
- else if(std::strstr(buff, "directory"))
- string_value(_jdir, buff);
- else if(std::strstr(buff, "base_filename"))
- string_value(_base_filename, buff);
- else if(std::strstr(buff, "number_jrnl_files"))
- _num_jfiles = u_int16_value(buff);
- else if(std::strstr(buff, "auto_expand_max_jrnl_files"))
- _ae_max_jfiles = u_int16_value(buff);
- else if(std::strstr(buff, "auto_expand"))
- _ae = bool_value(buff);
- else if(std::strstr(buff, "jrnl_file_size_sblks"))
- _jfsize_sblks = u_int32_value(buff);
- else if(std::strstr(buff, "JRNL_SBLK_SIZE"))
- _sblk_size_dblks = u_int16_value(buff);
- else if(std::strstr(buff, "JRNL_DBLK_SIZE"))
- _dblk_size = u_int32_value(buff);
- else if(std::strstr(buff, "wcache_pgsize_sblks"))
- _wcache_pgsize_sblks = u_int32_value(buff);
- else if(std::strstr(buff, "wcache_num_pages"))
- _wcache_num_pages = u_int32_value(buff);
- else if(std::strstr(buff, "JRNL_RMGR_PAGE_SIZE"))
- _rcache_pgsize_sblks = u_int32_value(buff);
- else if(std::strstr(buff, "JRNL_RMGR_PAGES"))
- _rcache_num_pages = u_int32_value(buff);
- else if(std::strstr(buff, "nanoseconds"))
- _ts.tv_nsec = u_int32_value(buff);
- else if(std::strstr(buff, "seconds"))
- {
- _ts.tv_sec = u_int32_value(buff);
- _tm_ptr = std::localtime(&_ts.tv_sec);
- }
- }
- jinfs.close();
- if (charcnt == 0)
- throw jexception(jerrno::JERR_JINF_ZEROLENFILE, jinf_filename.c_str(), "jinf", "read");
-}
-
-bool
-jinf::bool_value(char* line) const
-{
- return std::strcmp(find_value(line), "true") == 0;
-}
-
-u_int16_t
-jinf::u_int16_value(char* line) const
-{
- return std::atoi(find_value(line));
-}
-
-u_int32_t
-jinf::u_int32_value(char* line) const
-{
- return std::atol(find_value(line));
-}
-
-std::string&
-jinf::string_value(std::string& str, char* line) const
-{
- str.assign(find_value(line));
- return str;
-}
-
-char*
-jinf::find_value(char* line) const
-{
- const char* target1_str = "value=\"";
- int target2_char = '\"';
- char* t1 = std::strstr(line, target1_str);
- if (t1 == 0)
- {
- std::ostringstream oss;
- oss << "File \"" << _filename << "\": line=" << line;
- throw jexception(jerrno::JERR_JINF_NOVALUESTR, oss.str(), "jinf", "find_value");
- }
- t1 += std::strlen(target1_str);
-
- char* t2 = std::strchr(t1, target2_char);
- if (t2 == 0)
- {
- std::ostringstream oss;
- oss << "File \"" << _filename << "\": line=" << line;
- throw jexception(jerrno::JERR_JINF_BADVALUESTR, oss.str(), "jinf", "find_value");
- }
- *t2 = '\0';
- return t1;
-}
-
-u_int32_t
-jinf::get_filesize(const std::string& file_name) const
-{
- struct stat s;
- if (::stat(file_name.c_str(), &s))
- {
- std::ostringstream oss;
- oss << "stat: file=\"" << file_name << "\"" << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR_JINF_STAT, oss.str(), "jinf", "get_filesize");
- }
- if (!S_ISREG(s.st_mode)) // not a regular file,
- {
- std::ostringstream oss;
- oss << "File \"" << file_name << "\" is not a regular file: mode=0x" << std::hex << s.st_mode;
- throw jexception(jerrno::JERR_JINF_NOTREGFILE, oss.str(), "jinf", "get_filesize");
- }
- return u_int32_t(s.st_size);
-}
-
-} // namespace journal
-} // namespace mrg
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jinf.h b/qpid/cpp/src/qpid/linearstore/jrnl/jinf.h
deleted file mode 100644
index 73f5386a19..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jinf.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file jinf.h
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains the code for the mrg::journal::jinf class.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_JINF_H
-#define QPID_LEGACYSTORE_JRNL_JINF_H
-
-#include <ctime>
-#include <string>
-#include <sys/types.h>
-#include <vector>
-
-namespace mrg
-{
-namespace journal
-{
- /**
- * \class jinf
- * \brief Class to handle the journal information file &lt;basename&gt;.jinf.
- */
- class jinf
- {
- public:
- typedef std::vector<u_int16_t> pfid_list; // pfids
- typedef pfid_list::const_iterator pfidl_citr;
-
- private:
- u_int8_t _jver;
- std::string _jid;
- std::string _jdir;
- std::string _base_filename;
- std::string _filename;
- timespec _ts;
- u_int16_t _num_jfiles;
- bool _ae;
- u_int32_t _ae_max_jfiles;
- u_int32_t _jfsize_sblks;
- u_int16_t _sblk_size_dblks;
- u_int32_t _dblk_size;
- u_int32_t _wcache_pgsize_sblks;
- u_int16_t _wcache_num_pages;
- u_int32_t _rcache_pgsize_sblks;
- u_int16_t _rcache_num_pages;
- std::tm* _tm_ptr;
- bool _valid_flag;
- bool _analyzed_flag;
- pfid_list _pfid_list;
- bool _initial_owi;
- bool _frot;
-
- public:
- // constructor for reading existing jinf file
- jinf(const std::string& jinf_filename, bool validate_flag);
- // constructor for writing jinf file
- jinf(const std::string& jid, const std::string& jdir, const std::string& base_filename,
- const u_int16_t num_jfiles, const bool auto_expand, const u_int16_t ae_max_jfiles,
- const u_int32_t jfsize_sblks, const u_int32_t wcache_pgsize_sblks, const u_int16_t wcache_num_pages,
- const timespec& ts);
- virtual ~jinf();
-
- void validate();
- void analyze();
- void write();
-
- inline u_int8_t jver() const { return _jver; }
- inline const std::string& jid() const { return _jid; }
- inline const std::string& jdir() const { return _jdir; }
- inline void set_jdir(const std::string& jdir) { _jdir = jdir; }
- inline const std::string& base_filename() const { return _base_filename; }
- inline const timespec& ts() const { return _ts; }
- inline u_int16_t num_jfiles() const { return _num_jfiles; }
- u_int16_t incr_num_jfiles();
- inline bool is_ae() const { return _ae; }
- inline u_int16_t ae_max_jfiles() const { return _ae_max_jfiles; }
- inline u_int32_t jfsize_sblks() const { return _jfsize_sblks; }
- inline u_int16_t sblk_size_dblks() const { return _sblk_size_dblks; }
- inline u_int32_t dblk_size() const { return _dblk_size; }
- inline u_int32_t wcache_pgsize_sblks() const { return _wcache_pgsize_sblks; }
- inline u_int16_t wcache_num_pages() const { return _wcache_num_pages; }
- inline u_int32_t rcache_pgsize_sblks() const { return _rcache_pgsize_sblks; }
- inline u_int16_t rcache_num_pages() const { return _rcache_num_pages; }
- u_int16_t get_first_pfid();
- u_int16_t get_last_pfid();
- pfid_list& get_pfid_list();
- void get_normalized_pfid_list(pfid_list& pfid_list);
- bool get_initial_owi();
- bool get_frot();
-
- std::string to_string() const;
- std::string xml_str() const;
-
- private:
- void set_filename();
- void read(const std::string& jinf_filename);
- bool bool_value(char* line) const;
- u_int16_t u_int16_value(char* line) const;
- u_int32_t u_int32_value(char* line) const;
- std::string& string_value(std::string& str, char* line) const;
- char* find_value(char* line) const;
- u_int32_t get_filesize(const std::string& file_name) const;
- };
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_JINF_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jrec.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/jrec.cpp
index 61b9b6cc9b..a4d88cc980 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jrec.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jrec.cpp
@@ -19,22 +19,11 @@
*
*/
-/**
- * \file jrec.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing source code for class mrg::journal::jrec (abstract journal
- * jrecord). See comments in file jrec.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/jrec.h"
+#include "qpid/linearstore/jrnl/jrec.h"
#include <iomanip>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jexception.h"
#include <sstream>
namespace mrg
@@ -46,7 +35,7 @@ jrec::jrec() {}
jrec::~jrec() {}
void
-jrec::chk_hdr(const rec_hdr& hdr)
+jrec::chk_hdr(const rec_hdr_t& hdr)
{
if (hdr._magic == 0)
{
@@ -55,33 +44,33 @@ jrec::chk_hdr(const rec_hdr& hdr)
oss << "enq magic NULL: rid=0x" << hdr._rid;
throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "jrec", "chk_hdr");
}
- if (hdr._version != RHM_JDAT_VERSION)
+ if (hdr._version != QLS_JRNL_VERSION)
{
std::ostringstream oss;
oss << std::hex << std::setfill('0');
oss << "version: rid=0x" << hdr._rid;
- oss << ": expected=0x" << std::setw(2) << (int)RHM_JDAT_VERSION;
+ oss << ": expected=0x" << std::setw(2) << (int)QLS_JRNL_VERSION;
oss << " read=0x" << std::setw(2) << (int)hdr._version;
throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "jrec", "chk_hdr");
}
-#if defined (JRNL_LITTLE_ENDIAN)
- u_int8_t endian_flag = RHM_LENDIAN_FLAG;
-#else
- u_int8_t endian_flag = RHM_BENDIAN_FLAG;
-#endif
- if (hdr._eflag != endian_flag)
- {
- std::ostringstream oss;
- oss << std::hex << std::setfill('0');
- oss << "endian_flag: rid=" << hdr._rid;
- oss << ": expected=0x" << std::setw(2) << (int)endian_flag;
- oss << " read=0x" << std::setw(2) << (int)hdr._eflag;
- throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "jrec", "chk_hdr");
- }
+//#if defined (JRNL_LITTLE_ENDIAN)
+// uint8_t endian_flag = RHM_LENDIAN_FLAG;
+//#else
+// uint8_t endian_flag = RHM_BENDIAN_FLAG;
+//#endif
+// if (hdr._eflag != endian_flag)
+// {
+// std::ostringstream oss;
+// oss << std::hex << std::setfill('0');
+// oss << "endian_flag: rid=" << hdr._rid;
+// oss << ": expected=0x" << std::setw(2) << (int)endian_flag;
+// oss << " read=0x" << std::setw(2) << (int)hdr._eflag;
+// throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "jrec", "chk_hdr");
+// }
}
void
-jrec::chk_rid(const rec_hdr& hdr, const u_int64_t rid)
+jrec::chk_rid(const rec_hdr_t& hdr, const uint64_t rid)
{
if (hdr._rid != rid)
{
@@ -94,7 +83,7 @@ jrec::chk_rid(const rec_hdr& hdr, const u_int64_t rid)
}
void
-jrec::chk_tail(const rec_tail& tail, const rec_hdr& hdr)
+jrec::chk_tail(const rec_tail_t& tail, const rec_hdr_t& hdr)
{
if (tail._xmagic != ~hdr._magic)
{
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/jrec.h b/qpid/cpp/src/qpid/linearstore/jrnl/jrec.h
index 9d0771cabd..42587943e8 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/jrec.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/jrec.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file jrec.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing source code for class mrg::journal::jrec (abstract journal
- * jrecord). See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_JREC_H
#define QPID_LEGACYSTORE_JRNL_JREC_H
@@ -43,10 +32,10 @@ class jrec;
#include <cstddef>
#include <fstream>
-#include "qpid/legacystore/jrnl/rec_hdr.h"
-#include "qpid/legacystore/jrnl/rec_tail.h"
+#include "qpid/linearstore/jrnl/jcfg.h"
+#include "qpid/linearstore/jrnl/utils/rec_hdr.h"
+#include "qpid/linearstore/jrnl/utils/rec_tail.h"
#include <string>
-#include <sys/types.h>
namespace mrg
{
@@ -116,8 +105,8 @@ namespace journal
* \param max_size_dblks Maximum number of data-blocks to write to pointer wptr.
* \returns Number of data-blocks encoded.
*/
- virtual u_int32_t encode(void* wptr, u_int32_t rec_offs_dblks,
- u_int32_t max_size_dblks) = 0;
+ virtual uint32_t encode(void* wptr, uint32_t rec_offs_dblks,
+ uint32_t max_size_dblks) = 0;
/**
* \brief Decode into this instance of jrec from the read buffer at the disk-block-aligned
@@ -149,31 +138,31 @@ namespace journal
* \param max_size_dblks Maximum number of data-blocks to read from pointer rptr.
* \returns Number of data-blocks read (consumed).
*/
- virtual u_int32_t decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks,
- u_int32_t max_size_dblks) = 0;
+ virtual uint32_t decode(rec_hdr_t& h, void* rptr, uint32_t rec_offs_dblks,
+ uint32_t max_size_dblks) = 0;
- virtual bool rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs) = 0;
+ virtual bool rcv_decode(rec_hdr_t h, std::ifstream* ifsp, std::size_t& rec_offs) = 0;
virtual std::string& str(std::string& str) const = 0;
virtual std::size_t data_size() const = 0;
virtual std::size_t xid_size() const = 0;
virtual std::size_t rec_size() const = 0;
- inline virtual u_int32_t rec_size_dblks() const { return size_dblks(rec_size()); }
- static inline u_int32_t size_dblks(const std::size_t size)
+ inline virtual uint32_t rec_size_dblks() const { return size_dblks(rec_size()); }
+ static inline uint32_t size_dblks(const std::size_t size)
{ return size_blks(size, JRNL_DBLK_SIZE); }
- static inline u_int32_t size_sblks(const std::size_t size)
+ static inline uint32_t size_sblks(const std::size_t size)
{ return size_blks(size, JRNL_DBLK_SIZE * JRNL_SBLK_SIZE); }
- static inline u_int32_t size_blks(const std::size_t size, const std::size_t blksize)
+ static inline uint32_t size_blks(const std::size_t size, const std::size_t blksize)
{ return (size + blksize - 1)/blksize; }
- virtual u_int64_t rid() const = 0;
+ virtual uint64_t rid() const = 0;
protected:
virtual void chk_hdr() const = 0;
- virtual void chk_hdr(u_int64_t rid) const = 0;
+ virtual void chk_hdr(uint64_t rid) const = 0;
virtual void chk_tail() const = 0;
- static void chk_hdr(const rec_hdr& hdr);
- static void chk_rid(const rec_hdr& hdr, u_int64_t rid);
- static void chk_tail(const rec_tail& tail, const rec_hdr& hdr);
+ static void chk_hdr(const rec_hdr_t& hdr);
+ static void chk_rid(const rec_hdr_t& hdr, uint64_t rid);
+ static void chk_tail(const rec_tail_t& tail, const rec_hdr_t& hdr);
virtual void clean() = 0;
}; // class jrec
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/lp_map.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/lp_map.cpp
deleted file mode 100644
index 8024ddadd2..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/lp_map.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file lp_map.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::lp_map (logical file map). See
- * comments in file lp_map.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/lp_map.h"
-
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
-#include <sstream>
-
-namespace mrg
-{
-namespace journal
-{
-lp_map::lp_map() : _map() {}
-lp_map::~lp_map() {}
-
-void
-lp_map::insert(u_int16_t lfid, u_int16_t pfid)
-{
- lfpair ip = lfpair(lfid, pfid);
- lfret ret = _map.insert(ip);
- if (ret.second == false)
- {
- std::ostringstream oss;
- oss << std::hex << "lfid=0x" << lfid << " pfid=0x" << pfid;
- throw jexception(jerrno::JERR_MAP_DUPLICATE, oss.str(), "lp_map", "insert");
- }
-}
-
-void
-lp_map::get_pfid_list(std::vector<u_int16_t>& pfid_list)
-{
- for (lp_map_citr_t i = _map.begin(); i != _map.end(); i++)
- pfid_list.push_back(i->second);
-}
-
-// debug aid
-std::string
-lp_map::to_string()
-{
- std::ostringstream oss;
- oss << "{lfid:pfid ";
- for (lp_map_citr_t i=_map.begin(); i!=_map.end(); i++)
- {
- if (i != _map.begin()) oss << ", ";
- oss << (*i).first << ":" << (*i).second;
- }
- oss << "}";
- return oss.str();
-}
-
-} // namespace journal
-} // namespace mrg
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/lp_map.h b/qpid/cpp/src/qpid/linearstore/jrnl/lp_map.h
deleted file mode 100644
index c43cbc0173..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/lp_map.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file lp_map.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::lp_map (logical file map).
- * See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_LP_MAP_H
-#define QPID_LEGACYSTORE_JRNL_LP_MAP_H
-
-#include <map>
-#include <string>
-#include <sys/types.h>
-#include <vector>
-
-namespace mrg
-{
-namespace journal
-{
- /**
- * \class lp_map
- * \brief Maps the logical file id (lfid) to the physical file id (pfid) in the journal.
- *
- * NOTE: NOT THREAD SAFE
- */
- class lp_map
- {
- public:
- typedef std::map<u_int16_t, u_int16_t> lp_map_t;
- typedef lp_map_t::const_iterator lp_map_citr_t;
- typedef lp_map_t::const_reverse_iterator lp_map_critr_t;
-
- private:
- typedef std::pair<u_int16_t, u_int16_t> lfpair;
- typedef std::pair<lp_map_t::iterator, bool> lfret;
- lp_map_t _map;
-
- public:
- lp_map();
- virtual ~lp_map();
-
- void insert(u_int16_t lfid, u_int16_t pfid);
- inline u_int16_t size() const { return u_int16_t(_map.size()); }
- inline bool empty() const { return _map.empty(); }
- inline lp_map_citr_t begin() { return _map.begin(); }
- inline lp_map_citr_t end() { return _map.end(); }
- inline lp_map_critr_t rbegin() { return _map.rbegin(); }
- inline lp_map_critr_t rend() { return _map.rend(); }
- void get_pfid_list(std::vector<u_int16_t>& pfid_list);
-
- // debug aid
- std::string to_string();
- };
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_LP_MAP_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/lpmgr.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/lpmgr.cpp
deleted file mode 100644
index d7b0c9f516..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/lpmgr.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file lpmgr.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::lpmgr (non-logging file
- * handle), used for controlling journal log files. See comments in file
- * lpmgr.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/lpmgr.h"
-
-#include <cassert>
-#include <qpid/legacystore/jrnl/jerrno.h>
-#include <qpid/legacystore/jrnl/jexception.h>
-
-namespace mrg
-{
-namespace journal
-{
-
-lpmgr::lpmgr() : _ae(false), _ae_max_jfiles(0)
-{}
-
-lpmgr::~lpmgr()
-{
- finalize();
-}
-
-void
-lpmgr::initialize(const u_int16_t num_jfiles,
- const bool ae,
- const u_int16_t ae_max_jfiles,
- jcntl* const jcp,
- new_obj_fn_ptr fp)
-{
- assert(jcp != 0);
- finalize();
-
- // Validate params
- if (ae && ae_max_jfiles > 0 && ae_max_jfiles <= num_jfiles)
- {
- std::ostringstream oss;
- oss << "ae_max_jfiles (" << ae_max_jfiles << ") <= num_jfiles (" << num_jfiles << ")";
- throw jexception(jerrno::JERR_LFMGR_BADAEFNUMLIM, oss.str(), "lpmgr", "initialize");
- }
- _ae = ae;
- _ae_max_jfiles = ae_max_jfiles;
-
- const std::size_t num_res_files = ae
- ? (ae_max_jfiles ? ae_max_jfiles : JRNL_MAX_NUM_FILES)
- : num_jfiles;
- _fcntl_arr.reserve(num_res_files);
- append(jcp, fp, num_jfiles);
-}
-
-void
-lpmgr::recover(const rcvdat& rd,
- jcntl* const jcp,
- new_obj_fn_ptr fp)
-{
- assert(jcp != 0);
- finalize();
-
- // Validate rd params
- if (rd._aemjf > 0 && rd._aemjf <= rd._njf)
- {
- std::ostringstream oss;
- oss << "ae_max_jfiles (" << rd._aemjf << ") <= num_jfiles (" << rd._njf << ")";
- throw jexception(jerrno::JERR_LFMGR_BADAEFNUMLIM, oss.str(), "lpmgr", "recover");
- }
- _ae = rd._ae;
- _ae_max_jfiles = rd._aemjf;
-
- const std::size_t num_res_files = rd._ae
- ? (rd._aemjf ? rd._aemjf : JRNL_MAX_NUM_FILES)
- : rd._njf;
- _fcntl_arr.reserve(num_res_files);
- _fcntl_arr.assign(rd._njf, 0);
- std::vector<u_int16_t> lfid_list(rd._fid_list.size(), 0);
- for (std::size_t lid = 0; lid < rd._fid_list.size(); lid++)
- lfid_list[rd._fid_list[lid]] = lid;
- // NOTE: rd._fid_list may be smaller than rd._njf (journal may be empty or not yet file-cycled)
- for (std::size_t pfid = 0; pfid < rd._njf; pfid++)
- if (pfid < rd._fid_list.size())
- _fcntl_arr[lfid_list[pfid]] = fp(jcp, lfid_list[pfid], pfid, &rd);
- else
- _fcntl_arr[pfid] = fp(jcp, pfid, pfid, &rd);
-}
-
-void
-lpmgr::insert(const u_int16_t after_lfid,
- jcntl* const jcp,
- new_obj_fn_ptr fp,
- const u_int16_t num_jfiles)
-{
- assert(jcp != 0);
- assert(after_lfid < _fcntl_arr.size());
- if (!_ae) throw jexception(jerrno::JERR_LFMGR_AEDISABLED, "lpmgr", "insert");
- if (num_jfiles == 0) return;
- std::size_t pfid = _fcntl_arr.size();
- const u_int16_t eff_ae_max_jfiles = _ae_max_jfiles ? _ae_max_jfiles : JRNL_MAX_NUM_FILES;
- if (pfid + num_jfiles > eff_ae_max_jfiles)
- {
- std::ostringstream oss;
- oss << "num_files=" << pfid << " incr=" << num_jfiles << " limit=" << _ae_max_jfiles;
- throw jexception(jerrno::JERR_LFMGR_AEFNUMLIMIT, oss.str(), "lpmgr", "insert");
- }
- for (std::size_t lid = after_lfid + 1; lid <= after_lfid + num_jfiles; lid++, pfid++)
- _fcntl_arr.insert(_fcntl_arr.begin() + lid, fp(jcp, lid, pfid, 0));
- for (std::size_t lid = after_lfid + num_jfiles + 1; lid < _fcntl_arr.size(); lid++)
- {
- fcntl* p = _fcntl_arr[lid];
- assert(p != 0);
- p->set_lfid(p->lfid() + num_jfiles);
- }
-}
-
-void
-lpmgr::finalize()
-{
- for (u_int32_t i = 0; i < _fcntl_arr.size(); i++)
- delete _fcntl_arr[i];
- _fcntl_arr.clear();
- _ae = false;
- _ae_max_jfiles = 0;
-}
-
-void
-lpmgr::set_ae(const bool ae)
-{
- if (ae && _ae_max_jfiles > 0 && _ae_max_jfiles <= _fcntl_arr.size())
- {
- std::ostringstream oss;
- oss << "ae_max_jfiles (" << _ae_max_jfiles << ") <= _fcntl_arr.size (" << _fcntl_arr.size() << ")";
- throw jexception(jerrno::JERR_LFMGR_BADAEFNUMLIM, oss.str(), "lpmgr", "set_ae");
- }
- if (ae && _fcntl_arr.max_size() < _ae_max_jfiles)
- _fcntl_arr.reserve(_ae_max_jfiles ? _ae_max_jfiles : JRNL_MAX_NUM_FILES);
- _ae = ae;
-}
-
-void
-lpmgr::set_ae_max_jfiles(const u_int16_t ae_max_jfiles)
-{
- if (_ae && ae_max_jfiles > 0 && ae_max_jfiles <= _fcntl_arr.size())
- {
- std::ostringstream oss;
- oss << "ae_max_jfiles (" << _ae_max_jfiles << ") <= _fcntl_arr.size() (" << _fcntl_arr.size() << ")";
- throw jexception(jerrno::JERR_LFMGR_BADAEFNUMLIM, oss.str(), "lpmgr", "set_ae_max_jfiles");
- }
- if (_ae && _fcntl_arr.max_size() < ae_max_jfiles)
- _fcntl_arr.reserve(ae_max_jfiles ? ae_max_jfiles : JRNL_MAX_NUM_FILES);
- _ae_max_jfiles = ae_max_jfiles;
-}
-
-u_int16_t
-lpmgr::ae_jfiles_rem() const
-{
- if (_ae_max_jfiles > _fcntl_arr.size()) return _ae_max_jfiles - _fcntl_arr.size();
- if (_ae_max_jfiles == 0) return JRNL_MAX_NUM_FILES - _fcntl_arr.size();
- return 0;
-}
-
-// Testing functions
-
-void
-lpmgr::get_pfid_list(std::vector<u_int16_t>& pfid_list) const
-{
- pfid_list.clear();
- for (std::size_t i = 0; i < _fcntl_arr.size(); i++)
- pfid_list.push_back(_fcntl_arr[i]->pfid());
-}
-
-void
-lpmgr::get_lfid_list(std::vector<u_int16_t>& lfid_list) const
-{
- lfid_list.clear();
- lfid_list.assign(_fcntl_arr.size(), 0);
- for (std::size_t i = 0; i < _fcntl_arr.size(); i++)
- lfid_list[_fcntl_arr[i]->pfid()] = i;
-}
-
-// === protected fns ===
-
-void
-lpmgr::append(jcntl* const jcp,
- new_obj_fn_ptr fp,
- const u_int16_t num_jfiles)
-{
- std::size_t s = _fcntl_arr.size();
- if (_ae_max_jfiles && s + num_jfiles > _ae_max_jfiles)
- {
- std::ostringstream oss;
- oss << "num_files=" << s << " incr=" << num_jfiles << " limit=" << _ae_max_jfiles;
- throw jexception(jerrno::JERR_LFMGR_AEFNUMLIMIT, oss.str(), "lpmgr", "append");
- }
- for (std::size_t i = s; i < s + num_jfiles; i++)
- _fcntl_arr.push_back(fp(jcp, i, i, 0));
-}
-
-} // namespace journal
-} // namespace mrg
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/lpmgr.h b/qpid/cpp/src/qpid/linearstore/jrnl/lpmgr.h
deleted file mode 100644
index be5c4494cc..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/lpmgr.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file lpmgr.h
- *
- * Qpid asynchronous store plugin library
- *
- * Class mrg::journal::lpmgr. See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_LPMGR_H
-#define QPID_LEGACYSTORE_JRNL_LPMGR_H
-
-namespace mrg
-{
-namespace journal
-{
- class jcntl;
- class lpmgr;
-}
-}
-
-#include "qpid/legacystore/jrnl/fcntl.h"
-#include <vector>
-
-namespace mrg
-{
-namespace journal
-{
-
- /**
- * \brief LFID-PFID manager. This class maps the logical file id (lfid) to the physical file id (pfid) so that files
- * may be inserted into the file ring buffer in (nearly) arbitrary logical locations while the physical ids continue
- * to be appended. NOTE: NOT THREAD SAFE.
- *
- * The entire functionality of the LFID-PFID manager is to maintain an array of pointers to fcntl objects which have
- * a one-to-one relationship to the physical %journal files. The logical file id (lfid) is used as an index to the
- * array to read the mapped physical file id (pfid). By altering the order of these pointers within the array, the
- * mapping of logical to physical files may be altered. This can be used to allow for the logical insertion of
- * %journal files into a ring buffer, even though the physical file ids must be appended to those that preceded them.
- *
- * Since the insert() operation uses after-lfid as its position parameter, it is not possible to insert before lfid
- * 0 - i.e. It is only possible to insert after an existing lfid. Consequently, lfid 0 and pfid 0 are always
- * coincident in a %journal. Note, however, that inserting before lfid 0 is logically equivilent to inserting after
- * the last lfid.
- *
- * When one or more files are inserted after a particular lfid, the lfids of the following files are incremented. The
- * pfids of the inserted files follow those of all existing files, thus leading to a lfid-pfid discreppancy (ie no
- * longer a one-to-one mapping):
- *
- * Example: Before insertion, %journal file headers would look as follows:
- * <pre>
- * Logical view (sorted by lfid): Physical view (sorted by pfid):
- * +---+---+---+---+---+---+ +---+---+---+---+---+---+
- * pfid --> | 0 | 1 | 2 | 3 | 4 | 5 | pfid --> | 0 | 1 | 2 | 3 | 4 | 5 |
- * lfid --> | 0 | 1 | 2 | 3 | 4 | 5 | lfid --> | 0 | 1 | 2 | 3 | 4 | 5 |
- * +---+---+---+---+---+---+ +---+---+---+---+---+---+
- * </pre>
- *
- * After insertion of 2 files after lid 2 (marked with *s):
- * <pre>
- * Logical view (sorted by lfid): Physical view (sorted by pfid):
- * +---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+
- * pfid --> | 0 | 1 | 2 |*6*|*7*| 3 | 4 | 5 | pfid --> | 0 | 1 | 2 | 3 | 4 | 5 |*6*|*7*|
- * lfid --> | 0 | 1 | 2 |*3*|*4*| 5 | 6 | 7 | lfid --> | 0 | 1 | 2 | 5 | 6 | 7 |*3*|*4*|
- * +---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+
- * </pre>
- *
- * The insert() function updates the internal map immediately, but the physical files (which have both the pfid and
- * lfid written into the file header) are only updated as they are overwritten in the normal course of enqueueing
- * and dequeueing messages. If the %journal should fail after insertion but before the files following those inserted
- * are overwritten, then duplicate lfids will be present (though no duplicate pfids are possible). The overwrite
- * indicator (owi) flag and the pfid numbers may be used to resolve the ambiguity and determine the logically earlier
- * lfid in this case.
- *
- * Example: Before insertion, the current active write file being lfid/pfid 2 as determined by the owi flag, %journal
- * file headers would look as follows:
- * <pre>
- * Logical view (sorted by lfid): Physical view (sorted by pfid):
- * +---+---+---+---+---+---+ +---+---+---+---+---+---+
- * pfid --> | 0 | 1 | 2 | 3 | 4 | 5 | pfid --> | 0 | 1 | 2 | 3 | 4 | 5 |
- * lfid --> | 0 | 1 | 2 | 3 | 4 | 5 | lfid --> | 0 | 1 | 2 | 3 | 4 | 5 |
- * owi --> | t | t | t | f | f | f | owi --> | t | t | t | f | f | f |
- * +---+---+---+---+---+---+ +---+---+---+---+---+---+
- * </pre>
- *
- * After inserting 2 files after lfid 2 and then 3 (the newly inserted file) - marked with *s:
- * <pre>
- * Logical view (sorted by lfid): Physical view (sorted by pfid):
- * +---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+
- * pfid --> | 0 | 1 | 2 |*6*|*7*| 3 | 4 | 5 | pfid --> | 0 | 1 | 2 | 3 | 4 | 5 |*3*|*4*|
- * lfid --> | 0 | 1 | 2 |*3*|*4*| 3 | 4 | 5 | lfid --> | 0 | 1 | 2 | 3 | 4 | 5 |*3*|*4*|
- * owi --> | t | t | t | t | t | f | f | f | owi --> | t | t | t | f | f | f | t | t |
- * +---+---+---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+
- * </pre>
- *
- * If a broker failure occurs at this point, then there are two independent tests that may be made to resolve
- * duplicate lfids during recovery in such cases:
- * <ol>
- * <li>The correct lfid has owi flag that matches that of pfid/lfid 0</li>
- * <li>The most recently inserted (hence correct) lfid has pfids that are higher than the duplicate that was not
- * overwritten</li>
- * </ol>
- *
- * NOTE: NOT THREAD SAFE. Provide external thread protection if used in multi-threaded environments.
- */
- class lpmgr
- {
- public:
- /**
- * \brief Function pointer to function that will create a new fcntl object and return its pointer.
- *
- * \param jcp Pointer to jcntl instance from which journal file details will be obtained.
- * \param lfid Logical file ID for new fcntl instance.
- * \param pfid Physical file ID for file associated with new fcntl instance.
- * \param rdp Pointer to rcvdat instance which conatins recovery information for new fcntl instance when
- * recovering an existing file, or null if a new file is to be created.
- */
- typedef fcntl* (new_obj_fn_ptr)(jcntl* const jcp,
- const u_int16_t lfid,
- const u_int16_t pfid,
- const rcvdat* const rdp);
-
- private:
- bool _ae; ///< Auto-expand mode
- u_int16_t _ae_max_jfiles; ///< Max file count for auto-expansion; 0 = no limit
- std::vector<fcntl*> _fcntl_arr; ///< Array of pointers to fcntl objects
-
- public:
- lpmgr();
- virtual ~lpmgr();
-
- /**
- * \brief Initialize from scratch for a known number of %journal files. All lfid values are identical to pfid
- * values (which is normal before any inserts have occurred).
- *
- * \param num_jfiles Number of files to be created, and consequently the number of fcntl objects in array
- * _fcntl_arr.
- * \param ae If true, allows auto-expansion; if false, disables auto-expansion.
- * \param ae_max_jfiles The maximum number of files allowed for auto-expansion. Cannot be lower than the current
- * number of files. However, a zero value disables the limit checks, and allows unlimited
- * expansion.
- * \param jcp Pointer to jcntl instance. This is used to find the file path and base filename so that
- * new files may be created.
- * \param fp Pointer to function which creates and returns a pointer to a new fcntl object (and hence
- * causes a new %journal file to be created).
- */
- void initialize(const u_int16_t num_jfiles,
- const bool ae,
- const u_int16_t ae_max_jfiles,
- jcntl* const jcp,
- new_obj_fn_ptr fp);
-
- /**
- * \brief Initialize from a known lfid-pfid map pfid_list (within rcvdat param rd), which is usually obtained
- * from a recover. The index of pfid_list is the logical file id (lfid); the value contained in the vector is
- * the physical file id (pfid).
- *
- * \param rd Ref to rcvdat struct which contains recovery data and the pfid_list.
- * \param jcp Pointer to jcntl instance. This is used to find the file path and base filename so that
- * new files may be created.
- * \param fp Pointer to function which creates and returns a pointer to a new fcntl object (and hence
- * causes a new %journal file to be created).
- */
- void recover(const rcvdat& rd,
- jcntl* const jcp,
- new_obj_fn_ptr fp);
-
- /**
- * \brief Insert num_jfiles files after lfid index after_lfid. This causes all lfids after after_lfid to be
- * increased by num_jfiles.
- *
- * Note that it is not possible to insert <i>before</i> lfid 0, and thus lfid 0 should always point to pfid 0.
- * Inserting before lfid 0 is logically equivilent to inserting after the last lfid in a circular buffer.
- *
- * \param after_lfid Lid index after which to insert file(s).
- * \param jcp Pointer to jcntl instance. This is used to find the file path and base filename so that
- * new files may be created.
- * \param fp Pointer to function which creates and returns a pointer to a new fcntl object (and hence
- * causes a new %journal file to be created).
- * \param num_jfiles The number of files by which to increase.
- */
- void insert(const u_int16_t after_lfid,
- jcntl* const jcp,
- new_obj_fn_ptr fp,
- const u_int16_t num_jfiles = 1);
-
- /**
- * \brief Clears _fcntl_arr and deletes all fcntl instances.
- */
- void finalize();
-
- /**
- * \brief Returns true if initialized; false otherwise. After construction, will return false until initialize()
- * is called; thereafter true until finalize() is called, whereupon it will return false again.
- *
- * \return True if initialized; false otherwise.
- */
- inline bool is_init() const { return _fcntl_arr.size() > 0; }
-
- /**
- * \brief Returns true if auto-expand mode is enabled; false if not.
- *
- * \return True if auto-expand mode is enabled; false if not.
- */
- inline bool is_ae() const { return _ae; }
-
- /**
- * \brief Sets the auto-expand mode to enabled if ae is true, to disabled otherwise. The value of _ae_max_jfiles
- * must be valid to succeed (i.e. _ae_max_jfiles must be greater than the current number of files or be zero).
- *
- * \param ae If true will enable auto-expand mode; if false will disable it.
- */
- void set_ae(const bool ae);
-
- /**
- * \brief Returns the number of %journal files, including any that were appended or inserted since
- * initialization.
- *
- * \return Number of %journal files if initialized; 0 otherwise.
- */
- inline u_int16_t num_jfiles() const { return static_cast<u_int16_t>(_fcntl_arr.size()); }
-
- /**
- * \brief Returns the maximum number of files allowed for auto-expansion.
- *
- * \return Maximum number of files allowed for auto-expansion. A zero value represents a disabled limit
- * - i.e. unlimited expansion.
- */
- inline u_int16_t ae_max_jfiles() const { return _ae_max_jfiles; }
-
- /**
- * \brief Sets the maximum number of files allowed for auto-expansion. A zero value disables the limit.
- *
- * \param ae_max_jfiles The maximum number of files allowed for auto-expansion. Cannot be lower than the current
- * number of files. However, a zero value disables the limit checks, and allows unlimited
- * expansion.
- */
- void set_ae_max_jfiles(const u_int16_t ae_max_jfiles);
-
- /**
- * \brief Calculates the number of future files available for auto-expansion.
- *
- * \return The number of future files available for auto-expansion.
- */
- u_int16_t ae_jfiles_rem() const;
-
- /**
- * \brief Get a pointer to fcntl instance for a given lfid.
- *
- * \return Pointer to fcntl object corresponding to logical file id lfid, or 0 if lfid is out of range
- * (greater than number of files in use).
- */
- inline fcntl* get_fcntlp(const u_int16_t lfid) const
- { if (lfid >= _fcntl_arr.size()) return 0; return _fcntl_arr[lfid]; }
-
- // Testing functions
- void get_pfid_list(std::vector<u_int16_t>& pfid_list) const;
- void get_lfid_list(std::vector<u_int16_t>& lfid_list) const;
-
- protected:
-
- /**
- * \brief Append num_jfiles files to the end of the logical and file id sequence. This is similar to extending
- * the from-scratch initialization.
- *
- * \param jcp Pointer to jcntl instance. This is used to find the file path and base filename so that
- * new files may be created.
- * \param fp Pointer to function which creates and returns a pointer to a new fcntl object (and hence
- * causes a new %journal file to be created).
- * \param num_jfiles The number of files by which to increase.
- */
- void append(jcntl* const jcp,
- new_obj_fn_ptr fp,
- const u_int16_t num_jfiles = 1);
-
- };
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_LPMGR_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/pmgr.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/pmgr.cpp
index 3dc61e2661..e3bd8b2bda 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/pmgr.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/pmgr.cpp
@@ -19,25 +19,14 @@
*
*/
-/**
- * \file pmgr.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::pmgr (page manager). See
- * comments in file pmgr.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/pmgr.h"
+#include "qpid/linearstore/jrnl/pmgr.h"
#include <cerrno>
#include <cstdlib>
#include <cstring>
-#include "qpid/legacystore/jrnl/jcfg.h"
-#include "qpid/legacystore/jrnl/jcntl.h"
-#include "qpid/legacystore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jcfg.h"
+#include "qpid/linearstore/jrnl/jcntl.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
#include <sstream>
@@ -46,14 +35,14 @@ namespace mrg
namespace journal
{
-pmgr::page_cb::page_cb(u_int16_t index):
+pmgr::page_cb::page_cb(uint16_t index):
_index(index),
_state(UNUSED),
_wdblks(0),
_rdblks(0),
_pdtokl(0),
- _wfh(0),
- _rfh(0),
+// _wfh(0),
+// _rfh(0),
_pbuff(0)
{}
@@ -74,7 +63,7 @@ pmgr::page_cb::state_str() const
return "<unknown>";
}
-const u_int32_t pmgr::_sblksize = JRNL_SBLK_SIZE * JRNL_DBLK_SIZE;
+const uint32_t pmgr::_sblksize = JRNL_SBLK_SIZE * JRNL_DBLK_SIZE;
pmgr::pmgr(jcntl* jc, enq_map& emap, txn_map& tmap):
_cache_pgsize_sblks(0),
@@ -104,7 +93,7 @@ pmgr::~pmgr()
}
void
-pmgr::initialize(aio_callback* const cbp, const u_int32_t cache_pgsize_sblks, const u_int16_t cache_num_pages)
+pmgr::initialize(aio_callback* const cbp, const uint32_t cache_pgsize_sblks, const uint16_t cache_num_pages)
{
// As static use of this class keeps old values around, clean up first...
pmgr::clean();
@@ -140,7 +129,7 @@ pmgr::initialize(aio_callback* const cbp, const u_int32_t cache_pgsize_sblks, co
MALLOC_CHK(_aio_cb_arr, "_aio_cb_arr", "pmgr", "initialize");
// 6. Set page pointers in _page_ptr_arr, _page_cb_arr and iocbs to pages within page block
- for (u_int16_t i=0; i<_cache_num_pages; i++)
+ for (uint16_t i=0; i<_cache_num_pages; i++)
{
_page_ptr_arr[i] = (void*)((char*)_page_base_ptr + _cache_pgsize_sblks * _sblksize * i);
_page_cb_arr[i]._index = i;
@@ -152,7 +141,7 @@ pmgr::initialize(aio_callback* const cbp, const u_int32_t cache_pgsize_sblks, co
}
// 7. Allocate io_event array, max one event per cache page plus one for each file
- const u_int16_t max_aio_evts = _cache_num_pages + _jc->num_jfiles();
+ const uint16_t max_aio_evts = _cache_num_pages /*+ _jc->num_jfiles()*/; // TODO find replacement here for linear store
_aio_event_arr = (aio_event*)std::malloc(max_aio_evts * sizeof(aio_event));
MALLOC_CHK(_aio_event_arr, "_aio_event_arr", "pmgr", "initialize");
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/pmgr.h b/qpid/cpp/src/qpid/linearstore/jrnl/pmgr.h
index 64115e225e..17c501d7d0 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/pmgr.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/pmgr.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file pmgr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::pmgr (page manager). See
- * class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_PMGR_H
#define QPID_LEGACYSTORE_JRNL_PMGR_H
@@ -43,15 +32,15 @@ namespace journal
}
#include <deque>
-#include "qpid/legacystore/jrnl/aio.h"
-#include "qpid/legacystore/jrnl/aio_callback.h"
-#include "qpid/legacystore/jrnl/data_tok.h"
-#include "qpid/legacystore/jrnl/deq_rec.h"
-#include "qpid/legacystore/jrnl/enq_map.h"
-#include "qpid/legacystore/jrnl/enq_rec.h"
-#include "qpid/legacystore/jrnl/fcntl.h"
-#include "qpid/legacystore/jrnl/txn_map.h"
-#include "qpid/legacystore/jrnl/txn_rec.h"
+#include "qpid/linearstore/jrnl/aio.h"
+#include "qpid/linearstore/jrnl/aio_callback.h"
+#include "qpid/linearstore/jrnl/data_tok.h"
+#include "qpid/linearstore/jrnl/deq_rec.h"
+#include "qpid/linearstore/jrnl/enq_map.h"
+#include "qpid/linearstore/jrnl/enq_rec.h"
+//#include "qpid/linearstore/jrnl/fcntl.h"
+#include "qpid/linearstore/jrnl/txn_map.h"
+#include "qpid/linearstore/jrnl/txn_rec.h"
namespace mrg
{
@@ -83,23 +72,23 @@ namespace journal
*/
struct page_cb
{
- u_int16_t _index; ///< Index of this page
+ uint16_t _index; ///< Index of this page
page_state _state; ///< Status of page
- u_int64_t _frid; ///< First rid in page (used for fhdr init)
- u_int32_t _wdblks; ///< Total number of dblks in page so far
- u_int32_t _rdblks; ///< Total number of dblks in page
+ uint64_t _frid; ///< First rid in page (used for fhdr init)
+ uint32_t _wdblks; ///< Total number of dblks in page so far
+ uint32_t _rdblks; ///< Total number of dblks in page
std::deque<data_tok*>* _pdtokl; ///< Page message tokens list
- fcntl* _wfh; ///< File handle for incrementing write compl counts
- fcntl* _rfh; ///< File handle for incrementing read compl counts
+ //fcntl* _wfh; ///< File handle for incrementing write compl counts
+ //fcntl* _rfh; ///< File handle for incrementing read compl counts
void* _pbuff; ///< Page buffer
- page_cb(u_int16_t index); ///< Convenience constructor
+ page_cb(uint16_t index); ///< Convenience constructor
const char* state_str() const; ///< Return state as string for this pcb
};
- static const u_int32_t _sblksize; ///< Disk softblock size
- u_int32_t _cache_pgsize_sblks; ///< Size of page cache cache_num_pages
- u_int16_t _cache_num_pages; ///< Number of page cache cache_num_pages
+ static const uint32_t _sblksize; ///< Disk softblock size
+ uint32_t _cache_pgsize_sblks; ///< Size of page cache cache_num_pages
+ uint16_t _cache_num_pages; ///< Number of page cache cache_num_pages
jcntl* _jc; ///< Pointer to journal controller
enq_map& _emap; ///< Ref to enqueue map
txn_map& _tmap; ///< Ref to transaction map
@@ -109,10 +98,10 @@ namespace journal
aio_cb* _aio_cb_arr; ///< Array of iocb structs
aio_event* _aio_event_arr; ///< Array of io_events
io_context_t _ioctx; ///< AIO context for read/write operations
- u_int16_t _pg_index; ///< Index of current page being used
- u_int32_t _pg_cntr; ///< Page counter; determines if file rotation req'd
- u_int32_t _pg_offset_dblks; ///< Page offset (used so far) in data blocks
- u_int32_t _aio_evt_rem; ///< Remaining AIO events
+ uint16_t _pg_index; ///< Index of current page being used
+ uint32_t _pg_cntr; ///< Page counter; determines if file rotation req'd
+ uint32_t _pg_offset_dblks; ///< Page offset (used so far) in data blocks
+ uint32_t _aio_evt_rem; ///< Remaining AIO events
aio_callback* _cbp; ///< Pointer to callback object
enq_rec _enq_rec; ///< Enqueue record used for encoding/decoding
@@ -124,14 +113,14 @@ namespace journal
virtual ~pmgr();
virtual int32_t get_events(page_state state, timespec* const timeout, bool flush = false) = 0;
- inline u_int32_t get_aio_evt_rem() const { return _aio_evt_rem; }
+ inline uint32_t get_aio_evt_rem() const { return _aio_evt_rem; }
static const char* page_state_str(page_state ps);
- inline u_int32_t cache_pgsize_sblks() const { return _cache_pgsize_sblks; }
- inline u_int16_t cache_num_pages() const { return _cache_num_pages; }
+ inline uint32_t cache_pgsize_sblks() const { return _cache_pgsize_sblks; }
+ inline uint16_t cache_num_pages() const { return _cache_num_pages; }
protected:
- virtual void initialize(aio_callback* const cbp, const u_int32_t cache_pgsize_sblks,
- const u_int16_t cache_num_pages);
+ virtual void initialize(aio_callback* const cbp, const uint32_t cache_pgsize_sblks,
+ const uint16_t cache_num_pages);
virtual void rotate_page() = 0;
virtual void clean();
};
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/rcvdat.h b/qpid/cpp/src/qpid/linearstore/jrnl/rcvdat.h
index a7ef2341f0..c74d7f1a83 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/rcvdat.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/rcvdat.h
@@ -19,25 +19,15 @@
*
*/
-/**
- * \file rcvdat.h
- *
- * Qpid asynchronous store plugin library
- *
- * Contains structure for recovery status and offset data.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_RCVDAT_H
#define QPID_LEGACYSTORE_JRNL_RCVDAT_H
#include <cstddef>
#include <iomanip>
#include <map>
-#include "qpid/legacystore/jrnl/jcfg.h"
+#include "qpid/linearstore/jrnl/jcfg.h"
#include <sstream>
-#include <sys/types.h>
+#include <stdint.h>
#include <vector>
namespace mrg
@@ -47,28 +37,28 @@ namespace journal
struct rcvdat
{
- u_int16_t _njf; ///< Number of journal files
- bool _ae; ///< Auto-expand mode
- u_int16_t _aemjf; ///< Auto-expand mode max journal files
- bool _owi; ///< Overwrite indicator
- bool _frot; ///< First rotation flag
+ uint16_t _njf; ///< Number of journal files
+// bool _ae; ///< Auto-expand mode
+// uint16_t _aemjf; ///< Auto-expand mode max journal files
+// bool _owi; ///< Overwrite indicator
+// bool _frot; ///< First rotation flag
bool _jempty; ///< Journal data files empty
- u_int16_t _ffid; ///< First file id
+ uint16_t _ffid; ///< First file id
std::size_t _fro; ///< First record offset in ffid
- u_int16_t _lfid; ///< Last file id
+ uint16_t _lfid; ///< Last file id
std::size_t _eo; ///< End offset (first byte past last record)
- u_int64_t _h_rid; ///< Highest rid found
+ uint64_t _h_rid; ///< Highest rid found
bool _lffull; ///< Last file is full
bool _jfull; ///< Journal is full
- std::vector<u_int16_t> _fid_list; ///< Fid-lid mapping - list of fids in order of lid
- std::vector<u_int32_t> _enq_cnt_list; ///< Number enqueued records found for each file
+// std::vector<uint16_t> _fid_list; ///< Fid-lid mapping - list of fids in order of lid
+ std::vector<uint32_t> _enq_cnt_list; ///< Number enqueued records found for each file
rcvdat():
_njf(0),
- _ae(false),
- _aemjf(0),
- _owi(false),
- _frot(false),
+// _ae(false),
+// _aemjf(0),
+// _owi(false),
+// _frot(false),
_jempty(true),
_ffid(0),
_fro(0),
@@ -77,17 +67,17 @@ namespace journal
_h_rid(0),
_lffull(false),
_jfull(false),
- _fid_list(),
+// _fid_list(),
_enq_cnt_list()
{}
- void reset(const u_int16_t num_jfiles, const bool auto_expand, const u_int16_t ae_max_jfiles)
+ void reset(const uint16_t num_jfiles/*, const bool auto_expand, const uint16_t ae_max_jfiles*/)
{
_njf = num_jfiles;
- _ae = auto_expand;
- _aemjf = ae_max_jfiles;
- _owi = false;
- _frot = false;
+// _ae = auto_expand;
+// _aemjf = ae_max_jfiles;
+// _owi = false;
+// _frot = false;
_jempty = true;
_ffid = 0;
_fro = 0;
@@ -96,15 +86,15 @@ namespace journal
_h_rid = 0;
_lffull = false;
_jfull = false;
- _fid_list.clear();
+// _fid_list.clear();
_enq_cnt_list.clear();
_enq_cnt_list.resize(num_jfiles, 0);
}
// Find first fid with enqueued records
- u_int16_t ffid()
+ uint16_t ffid()
{
- u_int16_t index = _ffid;
+ uint16_t index = _ffid;
while (index != _lfid && _enq_cnt_list[index] == 0)
{
if (++index >= _njf)
@@ -118,10 +108,10 @@ namespace journal
std::ostringstream oss;
oss << "Recover file analysis (jid=\"" << jid << "\"):" << std::endl;
oss << " Number of journal files (_njf) = " << _njf << std::endl;
- oss << " Auto-expand mode (_ae) = " << (_ae ? "TRUE" : "FALSE") << std::endl;
- if (_ae) oss << " Auto-expand mode max journal files (_aemjf) = " << _aemjf << std::endl;
- oss << " Overwrite indicator (_owi) = " << (_owi ? "TRUE" : "FALSE") << std::endl;
- oss << " First rotation (_frot) = " << (_frot ? "TRUE" : "FALSE") << std::endl;
+// oss << " Auto-expand mode (_ae) = " << (_ae ? "TRUE" : "FALSE") << std::endl;
+// if (_ae) oss << " Auto-expand mode max journal files (_aemjf) = " << _aemjf << std::endl;
+// oss << " Overwrite indicator (_owi) = " << (_owi ? "TRUE" : "FALSE") << std::endl;
+// oss << " First rotation (_frot) = " << (_frot ? "TRUE" : "FALSE") << std::endl;
oss << " Journal empty (_jempty) = " << (_jempty ? "TRUE" : "FALSE") << std::endl;
oss << " First (earliest) fid (_ffid) = " << _ffid << std::endl;
oss << " First record offset in first fid (_fro) = 0x" << std::hex << _fro <<
@@ -133,11 +123,11 @@ namespace journal
oss << " Last file full (_lffull) = " << (_lffull ? "TRUE" : "FALSE") << std::endl;
oss << " Journal full (_jfull) = " << (_jfull ? "TRUE" : "FALSE") << std::endl;
oss << " Normalized fid list (_fid_list) = [";
- for (std::vector<u_int16_t>::const_iterator i = _fid_list.begin(); i < _fid_list.end(); i++)
- {
- if (i != _fid_list.begin()) oss << ", ";
- oss << *i;
- }
+// for (std::vector<uint16_t>::const_iterator i = _fid_list.begin(); i < _fid_list.end(); i++)
+// {
+// if (i != _fid_list.begin()) oss << ", ";
+// oss << *i;
+// }
oss << "]" << std::endl;
oss << " Enqueued records (txn & non-txn):" << std::endl;
for (unsigned i=0; i<_enq_cnt_list.size(); i++)
@@ -151,10 +141,10 @@ namespace journal
std::ostringstream oss;
oss << "Recover file analysis (jid=\"" << jid << "\"):";
oss << " njf=" << _njf;
- oss << " ae=" << (_owi ? "T" : "F");
- oss << " aemjf=" << _aemjf;
- oss << " owi=" << (_ae ? "T" : "F");
- oss << " frot=" << (_frot ? "T" : "F");
+// oss << " ae=" << (_owi ? "T" : "F");
+// oss << " aemjf=" << _aemjf;
+// oss << " owi=" << (_ae ? "T" : "F");
+// oss << " frot=" << (_frot ? "T" : "F");
oss << " jempty=" << (_jempty ? "T" : "F");
oss << " ffid=" << _ffid;
oss << " fro=0x" << std::hex << _fro << std::dec << " (" <<
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/rec_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/rec_hdr.h
deleted file mode 100644
index ff6325a760..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/rec_hdr.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file rec_hdr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::rec_hdr (record header),
- * which is a common initial header used for all journal record structures
- * except the record tail (rec_tail).
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_REC_HDR_H
-#define QPID_LEGACYSTORE_JRNL_REC_HDR_H
-
-#include <cstddef>
-#include "qpid/legacystore/jrnl/jcfg.h"
-#include <sys/types.h>
-
-namespace mrg
-{
-namespace journal
-{
-
-#pragma pack(1)
-
- /**
- * \brief Struct for data common to the head of all journal files and records.
- * This includes identification for the file type, the encoding version, endian
- * indicator and a record ID.
- *
- * File header info in binary format (16 bytes):
- * <pre>
- * 0 7
- * +---+---+---+---+---+---+---+---+
- * | magic | v | e | flags |
- * +---+---+---+---+---+---+---+---+
- * | rid |
- * +---+---+---+---+---+---+---+---+
- * v = file version (If the format or encoding of this file changes, then this
- * number should be incremented)
- * e = endian flag, false (0x00) for little endian, true (0x01) for big endian
- * </pre>
- *
- * Note that journal files should be transferable between 32- and 64-bit
- * hardware of the same endianness, but not between hardware of opposite
- * entianness without some sort of binary conversion utility. Thus buffering
- * will be needed for types that change size between 32- and 64-bit compiles.
- */
- struct rec_hdr
- {
- u_int32_t _magic; ///< File type identifier (magic number)
- u_int8_t _version; ///< File encoding version
- u_int8_t _eflag; ///< Flag for determining endianness
- u_int16_t _uflag; ///< User-defined flags
- u_int64_t _rid; ///< Record ID (rotating 64-bit counter)
-
- // Global flags
- static const u_int16_t HDR_OVERWRITE_INDICATOR_MASK = 0x1;
-
- // Convenience constructors and methods
- /**
- * \brief Default constructor, which sets all values to 0.
- */
- inline rec_hdr(): _magic(0), _version(0), _eflag(0), _uflag(0), _rid(0) {}
-
- /**
- * \brief Convenience constructor which initializes values during construction.
- */
- inline rec_hdr(const u_int32_t magic, const u_int8_t version, const u_int64_t rid,
- const bool owi): _magic(magic), _version(version),
-#if defined(JRNL_BIG_ENDIAN)
- _eflag(RHM_BENDIAN_FLAG),
-#else
- _eflag(RHM_LENDIAN_FLAG),
-#endif
- _uflag(owi ? HDR_OVERWRITE_INDICATOR_MASK : 0), _rid(rid) {}
-
- /**
- * \brief Convenience copy method.
- */
- inline void hdr_copy(const rec_hdr& h)
- {
- _magic = h._magic;
- _version = h._version;
- _eflag = h._eflag;
- _uflag = h._uflag;
- _rid =h._rid;
- }
-
- /**
- * \brief Resets all fields to 0
- */
- inline void reset()
- {
- _magic = 0;
- _version = 0;
- _eflag = 0;
- _uflag = 0;
- _rid = 0;
- }
-
- inline bool get_owi() const { return _uflag & HDR_OVERWRITE_INDICATOR_MASK; }
-
- inline void set_owi(const bool owi)
- {
- _uflag = owi ? _uflag | HDR_OVERWRITE_INDICATOR_MASK :
- _uflag & (~HDR_OVERWRITE_INDICATOR_MASK);
- }
-
- /**
- * \brief Returns the size of the header in bytes.
- */
- inline static std::size_t size() { return sizeof(rec_hdr); }
- }; // struct rec_hdr
-
-#pragma pack()
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_REC_HDR_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/rec_tail.h b/qpid/cpp/src/qpid/linearstore/jrnl/rec_tail.h
deleted file mode 100644
index 0c36151927..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/rec_tail.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file rec_tail.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::rec_tail (record tail), used to
- * finalize a persistent record. The presence of a valid tail at the expected
- * position in the journal file indicates that the record write was completed.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_REC_TAIL_H
-#define QPID_LEGACYSTORE_JRNL_REC_TAIL_H
-
-#include <cstddef>
-#include "qpid/legacystore/jrnl/jcfg.h"
-
-namespace mrg
-{
-namespace journal
-{
-
-#pragma pack(1)
-
- /**
- * \brief Struct for data common to the tail of all records. The magic number
- * used here is the binary inverse (1's complement) of the magic used in the
- * record header; this minimizes possible confusion with other headers that may
- * be present during recovery. The tail is used with all records that have either
- * XIDs or data - ie any size-variable content. Currently the only records that
- * do NOT use the tail are non-transactional dequeues and filler records.
- *
- * Record header info in binary format (12 bytes):
- * <pre>
- * 0 7
- * +---+---+---+---+---+---+---+---+
- * | ~(magic) | rid |
- * +---+---+---+---+---+---+---+---+
- * | rid (con't) |
- * +---+---+---+---+
- * </pre>
- */
- struct rec_tail
- {
- u_int32_t _xmagic; ///< Binary inverse (1's complement) of hdr magic number
- u_int64_t _rid; ///< ID (rotating 64-bit counter)
-
-
- /**
- * \brief Default constructor, which sets all values to 0.
- */
- inline rec_tail(): _xmagic(0xffffffff), _rid(0) {}
-
- /**
- * \brief Convenience constructor which initializes values during construction from
- * existing enq_hdr instance.
- */
- inline rec_tail(const rec_hdr& h): _xmagic(~h._magic), _rid(h._rid) {}
-
- /**
- * \brief Convenience constructor which initializes values during construction.
- */
- inline rec_tail(const u_int32_t xmagic, const u_int64_t rid): _xmagic(xmagic), _rid(rid) {}
-
- /**
- * \brief Returns the size of the header in bytes.
- */
- inline static std::size_t size() { return sizeof(rec_tail); }
- };
-
-#pragma pack()
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_REC_TAIL_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/rfc.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/rfc.cpp
deleted file mode 100644
index 9b5ed95e81..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/rfc.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file rfc.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::rfc (rotating
- * file controller). See comments in file rfc.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/rfc.h"
-
-#include <cassert>
-
-namespace mrg
-{
-namespace journal
-{
-
-rfc::rfc(const lpmgr* lpmp): _lpmp(lpmp), _fc_index(0), _curr_fc(0)
-{}
-
-rfc::~rfc()
-{}
-
-void
-rfc::finalize()
-{
- unset_findex();
-}
-
-void
-rfc::set_findex(const u_int16_t fc_index)
-{
- _fc_index = fc_index;
- _curr_fc = _lpmp->get_fcntlp(fc_index);
- _curr_fc->rd_reset();
-}
-
-void
-rfc::unset_findex()
-{
- _fc_index = 0;
- _curr_fc = 0;
-}
-
-std::string
-rfc::status_str() const
-{
- if (!_lpmp->is_init())
- return "state: Uninitialized";
- if (_curr_fc == 0)
- return "state: Inactive";
- std::ostringstream oss;
- oss << "state: Active";
- return oss.str();
-}
-
-} // namespace journal
-} // namespace mrg
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/rfc.h b/qpid/cpp/src/qpid/linearstore/jrnl/rfc.h
deleted file mode 100644
index faa5d566ba..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/rfc.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file rfc.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::rfc (rotating
- * file controller). See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_RFC_H
-#define QPID_LEGACYSTORE_JRNL_RFC_H
-
-namespace mrg
-{
-namespace journal
-{
-class rfc;
-}
-}
-
-#include "qpid/legacystore/jrnl/lpmgr.h"
-#include "qpid/legacystore/jrnl/enums.h"
-
-namespace mrg
-{
-namespace journal
-{
-
- /**
- * \class rfc
- * \brief Rotating File Controller (rfc) - Class to handle the manangement of an array of file controllers (fcntl)
- * objects for use in a circular disk buffer (journal). Each fcntl object corresponds to a file in the journal.
- *
- * The following states exist in this class:
- *
- * <pre>
- * is_init() is_active()
- * +===+ _lpmp.is_init() == false
- * +---------->| | Uninitialized: _curr_fc == 0 F F
- * | +-->+===+ --+
- * | | |
- * | | |
- * | finalize() initialize()
- * | | |
- * | | |
- * | +-- +===+<--+ _lpmp.is_init() == true
- * finalize() | | Inactive: _curr_fc == 0 T F
- * | +-->+===+ --+
- * | | |
- * | | |
- * | unset_findex() set_findex()
- * | | |
- * | | |
- * | +-- +===+<--+ _lpmp.is_init() == true
- * +---------- | | Active: _curr_fc != 0 T T
- * +===+
- * </pre>
- *
- * The Uninitialized state is where the class starts after construction. Once the number of files is known and
- * the array of file controllers allocated, then initialize() is called to set these, causing the state to move
- * to Inactive.
- *
- * The Inactive state has the file controllers allocated and pointing to their respective journal files, but no
- * current file controller has been selected. The pointer to the current file controller _curr_fc is null. Once the
- * index of the active file is known, then calling set_findex() will set the index and internal pointer
- * to the currently active file controller. This moves the state to Active.
- *
- * Note TODO: Comment on sync issues between change in num files in _lpmp and _fc_index/_curr_fc.
- */
- class rfc
- {
- protected:
- const lpmgr* _lpmp; ///< Pointer to jcntl's lpmgr instance containing lfid/pfid map and fcntl objects
- u_int16_t _fc_index; ///< Index of current file controller
- fcntl* _curr_fc; ///< Pointer to current file controller
-
- public:
- rfc(const lpmgr* lpmp);
- virtual ~rfc();
-
- /**
- * \brief Initialize the controller, moving from state Uninitialized to Inactive. The main function of
- * initialize() is to set the number of files and the pointer to the fcntl array.
- */
- virtual inline void initialize() {}
-
- /**
- * \brief Reset the controller to Uninitialized state, usually called when the journal is stopped. Once called,
- * initialize() must be called to reuse an instance.
- */
- virtual void finalize();
-
- /**
- * \brief Check initialization state: true = Not Uninitialized, ie Initialized or Active; false = Uninitialized.
- */
- virtual inline bool is_init() const { return _lpmp->is_init(); }
-
- /**
- * \brief Check active state: true = Initialized and _curr_fc not null; false otherwise.
- */
- virtual inline bool is_active() const { return _lpmp->is_init() && _curr_fc != 0; }
-
- /**
- * \brief Sets the current file index and active fcntl object. Moves to state Active.
- */
- virtual void set_findex(const u_int16_t fc_index);
-
- /**
- * \brief Nulls the current file index and active fcntl pointer, moves to state Inactive.
- */
- virtual void unset_findex();
-
- /**
- * \brief Rotate active file controller to next file in rotating file group.
- * \exception jerrno::JERR__NINIT if called before calling initialize().
- */
- virtual iores rotate() = 0;
-
- /**
- * \brief Returns the index of the currently active file within the rotating file group.
- */
- inline u_int16_t index() const { return _fc_index; }
-
- /**
- * \brief Returns the currently active journal file controller within the rotating file group.
- */
- inline fcntl* file_controller() const { return _curr_fc; }
-
- /**
- * \brief Returns the currently active physical file id (pfid)
- */
- inline u_int16_t pfid() const { return _curr_fc->pfid(); }
-
- // Convenience access methods to current file controller
- // Note: Do not call when not in active state
-
- inline u_int32_t enqcnt() const { return _curr_fc->enqcnt(); }
- inline u_int32_t incr_enqcnt() { return _curr_fc->incr_enqcnt(); }
- inline u_int32_t incr_enqcnt(const u_int16_t fid) { return _lpmp->get_fcntlp(fid)->incr_enqcnt(); }
- inline u_int32_t add_enqcnt(const u_int32_t a) { return _curr_fc->add_enqcnt(a); }
- inline u_int32_t add_enqcnt(const u_int16_t fid, const u_int32_t a)
- { return _lpmp->get_fcntlp(fid)->add_enqcnt(a); }
- inline u_int32_t decr_enqcnt(const u_int16_t fid) { return _lpmp->get_fcntlp(fid)->decr_enqcnt(); }
- inline u_int32_t subtr_enqcnt(const u_int16_t fid, const u_int32_t s)
- { return _lpmp->get_fcntlp(fid)->subtr_enqcnt(s); }
-
- virtual inline u_int32_t subm_cnt_dblks() const = 0;
- virtual inline std::size_t subm_offs() const = 0;
- virtual inline u_int32_t add_subm_cnt_dblks(u_int32_t a) = 0;
-
- virtual inline u_int32_t cmpl_cnt_dblks() const = 0;
- virtual inline std::size_t cmpl_offs() const = 0;
- virtual inline u_int32_t add_cmpl_cnt_dblks(u_int32_t a) = 0;
-
- virtual inline bool is_void() const = 0;
- virtual inline bool is_empty() const = 0;
- virtual inline u_int32_t remaining_dblks() const = 0;
- virtual inline bool is_full() const = 0;
- virtual inline bool is_compl() const = 0;
- virtual inline u_int32_t aio_outstanding_dblks() const = 0;
- virtual inline bool file_rotate() const = 0;
-
- // Debug aid
- virtual std::string status_str() const;
- }; // class rfc
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_RFC_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/rmgr.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/rmgr.cpp
index 3a11817d1e..41201fe64e 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/rmgr.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/rmgr.cpp
@@ -19,24 +19,13 @@
*
*/
-/**
- * \file rmgr.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::rmgr (read manager). See
- * comments in file rmgr.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/rmgr.h"
+#include "qpid/linearstore/jrnl/rmgr.h"
#include <cassert>
#include <cerrno>
#include <cstdlib>
-#include "qpid/legacystore/jrnl/jcntl.h"
-#include "qpid/legacystore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jcntl.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
#include <sstream>
namespace mrg
@@ -44,9 +33,9 @@ namespace mrg
namespace journal
{
-rmgr::rmgr(jcntl* jc, enq_map& emap, txn_map& tmap, rrfc& rrfc):
+rmgr::rmgr(jcntl* jc, enq_map& emap, txn_map& tmap/*, rrfc& rrfc*/):
pmgr(jc, emap, tmap),
- _rrfc(rrfc),
+// _rrfc(rrfc),
_hdr(),
_fhdr_buffer(0),
_fhdr_aio_cb_ptr(0),
@@ -126,14 +115,15 @@ rmgr::read(void** const datapp, std::size_t& dsize, void** const xidpp, std::siz
}
set_params_null(datapp, dsize, xidpp, xidsize);
- _hdr.reset();
+ //_hdr.reset();
+ ::rec_hdr_init(&_hdr, 0, 0, 0, 0);
// Read header, determine next record type
while (true)
{
- if(dblks_rem() == 0 && _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding())
+ if(dblks_rem() == 0 /*&& _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding()*/) // TODO: replace for linear store
{
aio_cycle(); // check if rd AIOs returned; initiate new reads if possible
- if(dblks_rem() == 0 && _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding())
+ if(dblks_rem() == 0 /*&& _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding()*/) // TODO: replace for linear store
{
if (_jc->unflushed_dblks() > 0)
_jc->flush();
@@ -147,10 +137,10 @@ rmgr::read(void** const datapp, std::size_t& dsize, void** const xidpp, std::siz
return RHM_IORES_PAGE_AIOWAIT;
}
void* rptr = (void*)((char*)_page_ptr_arr[_pg_index] + (_pg_offset_dblks * JRNL_DBLK_SIZE));
- std::memcpy(&_hdr, rptr, sizeof(rec_hdr));
+ std::memcpy(&_hdr, rptr, sizeof(rec_hdr_t));
switch (_hdr._magic)
{
- case RHM_JDAT_ENQ_MAGIC:
+ case QLS_ENQ_MAGIC:
{
_enq_rec.reset(); // sets enqueue rec size
// Check if RID of this rec is still enqueued, if so read it, else skip
@@ -211,16 +201,16 @@ rmgr::read(void** const datapp, std::size_t& dsize, void** const xidpp, std::siz
consume_xid_rec(_hdr, rptr, dtokp);
break;
}
- case RHM_JDAT_DEQ_MAGIC:
+ case QLS_DEQ_MAGIC:
consume_xid_rec(_hdr, rptr, dtokp);
break;
- case RHM_JDAT_TXA_MAGIC:
+ case QLS_TXA_MAGIC:
consume_xid_rec(_hdr, rptr, dtokp);
break;
- case RHM_JDAT_TXC_MAGIC:
+ case QLS_TXC_MAGIC:
consume_xid_rec(_hdr, rptr, dtokp);
break;
- case RHM_JDAT_EMPTY_MAGIC:
+ case QLS_EMPTY_MAGIC:
consume_filler();
break;
default:
@@ -230,7 +220,7 @@ rmgr::read(void** const datapp, std::size_t& dsize, void** const xidpp, std::siz
}
int32_t
-rmgr::get_events(page_state state, timespec* const timeout, bool flush)
+rmgr::get_events(page_state /*state*/, timespec* const timeout, bool flush)
{
if (_aio_evt_rem == 0) // no events to get
return 0;
@@ -247,7 +237,7 @@ rmgr::get_events(page_state state, timespec* const timeout, bool flush)
if (ret == 0 && timeout)
return jerrno::AIO_TIMEOUT;
- std::vector<u_int16_t> pil;
+ std::vector<uint16_t> pil;
pil.reserve(ret);
for (int i=0; i<ret; i++) // Index of returned AIOs
{
@@ -274,6 +264,8 @@ rmgr::get_events(page_state state, timespec* const timeout, bool flush)
if (pcbp) // Page reads have pcb
{
+ // TODO: replace for linear store: _rfh
+/*
if (pcbp->_rfh->rd_subm_cnt_dblks() >= JRNL_SBLK_SIZE) // Detects if write reset of this fcntl obj has occurred.
{
// Increment the completed read offset
@@ -284,25 +276,27 @@ rmgr::get_events(page_state state, timespec* const timeout, bool flush)
pcbp->_state = state;
pil[i] = pcbp->_index;
}
+*/
}
else // File header reads have no pcb
{
- std::memcpy(&_fhdr, _fhdr_buffer, sizeof(file_hdr));
- _rrfc.add_cmpl_cnt_dblks(JRNL_SBLK_SIZE);
+ std::memcpy(&_fhdr, _fhdr_buffer, sizeof(file_hdr_t));
+ /*_rrfc.add_cmpl_cnt_dblks(JRNL_SBLK_SIZE);*/ // TODO: replace for linear store: _rrfc
- u_int32_t fro_dblks = (_fhdr._fro / JRNL_DBLK_SIZE) - JRNL_SBLK_SIZE;
+ uint32_t fro_dblks = (_fhdr._fro / JRNL_DBLK_SIZE) - JRNL_SBLK_SIZE;
// Check fro_dblks does not exceed the write pointers which can happen in some corrupted journal recoveries
- if (fro_dblks > _jc->wr_subm_cnt_dblks(_fhdr._pfid) - JRNL_SBLK_SIZE)
- fro_dblks = _jc->wr_subm_cnt_dblks(_fhdr._pfid) - JRNL_SBLK_SIZE;
+ // TODO: replace for linear store: _fhdr._pfid, _rrfc
+// if (fro_dblks > _jc->wr_subm_cnt_dblks(_fhdr._pfid) - JRNL_SBLK_SIZE)
+// fro_dblks = _jc->wr_subm_cnt_dblks(_fhdr._pfid) - JRNL_SBLK_SIZE;
_pg_cntr = fro_dblks / (JRNL_RMGR_PAGE_SIZE * JRNL_SBLK_SIZE);
- u_int32_t tot_pg_offs_dblks = _pg_cntr * JRNL_RMGR_PAGE_SIZE * JRNL_SBLK_SIZE;
+ uint32_t tot_pg_offs_dblks = _pg_cntr * JRNL_RMGR_PAGE_SIZE * JRNL_SBLK_SIZE;
_pg_index = _pg_cntr % JRNL_RMGR_PAGES;
_pg_offset_dblks = fro_dblks - tot_pg_offs_dblks;
- _rrfc.add_subm_cnt_dblks(tot_pg_offs_dblks);
- _rrfc.add_cmpl_cnt_dblks(tot_pg_offs_dblks);
+// _rrfc.add_subm_cnt_dblks(tot_pg_offs_dblks);
+// _rrfc.add_cmpl_cnt_dblks(tot_pg_offs_dblks);
_fhdr_rd_outstanding = false;
- _rrfc.set_valid();
+// _rrfc.set_valid();
}
}
@@ -319,8 +313,9 @@ rmgr::recover_complete()
void
rmgr::invalidate()
{
- if (_rrfc.is_valid())
- _rrfc.set_invalid();
+ // TODO: replace for linear store: _rrfc
+// if (_rrfc.is_valid())
+// _rrfc.set_invalid();
}
void
@@ -339,11 +334,13 @@ rmgr::flush(timespec* timeout)
// Reset all read states and pointers
for (int i=0; i<_cache_num_pages; i++)
_page_cb_arr[i]._state = UNUSED;
- _rrfc.unset_findex();
+ // TODO: replace for linear store: _rrfc
+// _rrfc.unset_findex();
_pg_index = 0;
_pg_offset_dblks = 0;
}
+/*
bool
rmgr::wait_for_validity(timespec* timeout, const bool throw_on_timeout)
{
@@ -356,6 +353,7 @@ rmgr::wait_for_validity(timespec* timeout, const bool throw_on_timeout)
}
return _rrfc.is_valid();
}
+*/
iores
rmgr::pre_read_check(data_tok* dtokp)
@@ -363,17 +361,18 @@ rmgr::pre_read_check(data_tok* dtokp)
if (_aio_evt_rem)
get_events(AIO_COMPLETE, 0);
- if (!_rrfc.is_valid())
- return RHM_IORES_RCINVALID;
+ // TODO: replace for linear store: _rrfc
+// if (!_rrfc.is_valid())
+// return RHM_IORES_RCINVALID;
// block reads until outstanding file header read completes as fro is needed to read
if (_fhdr_rd_outstanding)
return RHM_IORES_PAGE_AIOWAIT;
- if(dblks_rem() == 0 && _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding())
+ if(dblks_rem() == 0 /*&& _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding()*/)// TODO: replace for linear store: _rrfc
{
aio_cycle(); // check if any AIOs have returned
- if(dblks_rem() == 0 && _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding())
+ if(dblks_rem() == 0 /*&& _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding()*/)// TODO: replace for linear store: _rrfc
{
if (_jc->unflushed_dblks() > 0)
_jc->flush();
@@ -400,7 +399,7 @@ rmgr::pre_read_check(data_tok* dtokp)
}
iores
-rmgr::read_enq(rec_hdr& h, void* rptr, data_tok* dtokp)
+rmgr::read_enq(rec_hdr_t& h, void* rptr, data_tok* dtokp)
{
if (_page_cb_arr[_pg_index]._state != AIO_COMPLETE)
{
@@ -409,7 +408,7 @@ rmgr::read_enq(rec_hdr& h, void* rptr, data_tok* dtokp)
}
// Read data from this page, first block will have header and data size.
- u_int32_t dblks_rd = _enq_rec.decode(h, rptr, dtokp->dblocks_read(), dblks_rem());
+ uint32_t dblks_rd = _enq_rec.decode(h, rptr, dtokp->dblocks_read(), dblks_rem());
dtokp->incr_dblocks_read(dblks_rd);
_pg_offset_dblks += dblks_rd;
@@ -442,31 +441,31 @@ rmgr::read_enq(rec_hdr& h, void* rptr, data_tok* dtokp)
}
void
-rmgr::consume_xid_rec(rec_hdr& h, void* rptr, data_tok* dtokp)
+rmgr::consume_xid_rec(rec_hdr_t& h, void* rptr, data_tok* dtokp)
{
- if (h._magic == RHM_JDAT_ENQ_MAGIC)
+ if (h._magic == QLS_ENQ_MAGIC)
{
- enq_hdr ehdr;
- std::memcpy(&ehdr, rptr, sizeof(enq_hdr));
- if (ehdr.is_external())
- dtokp->set_dsize(ehdr._xidsize + sizeof(enq_hdr) + sizeof(rec_tail));
+ enq_hdr_t ehdr;
+ std::memcpy(&ehdr, rptr, sizeof(enq_hdr_t));
+ if (::is_enq_external(&ehdr))
+ dtokp->set_dsize(ehdr._xidsize + sizeof(enq_hdr_t) + sizeof(rec_tail_t));
else
- dtokp->set_dsize(ehdr._xidsize + ehdr._dsize + sizeof(enq_hdr) + sizeof(rec_tail));
+ dtokp->set_dsize(ehdr._xidsize + ehdr._dsize + sizeof(enq_hdr_t) + sizeof(rec_tail_t));
}
- else if (h._magic == RHM_JDAT_DEQ_MAGIC)
+ else if (h._magic == QLS_DEQ_MAGIC)
{
- deq_hdr dhdr;
- std::memcpy(&dhdr, rptr, sizeof(deq_hdr));
+ deq_hdr_t dhdr;
+ std::memcpy(&dhdr, rptr, sizeof(deq_hdr_t));
if (dhdr._xidsize)
- dtokp->set_dsize(dhdr._xidsize + sizeof(deq_hdr) + sizeof(rec_tail));
+ dtokp->set_dsize(dhdr._xidsize + sizeof(deq_hdr_t) + sizeof(rec_tail_t));
else
- dtokp->set_dsize(sizeof(deq_hdr));
+ dtokp->set_dsize(sizeof(deq_hdr_t));
}
- else if (h._magic == RHM_JDAT_TXA_MAGIC || h._magic == RHM_JDAT_TXC_MAGIC)
+ else if (h._magic == QLS_TXA_MAGIC || h._magic == QLS_TXC_MAGIC)
{
- txn_hdr thdr;
- std::memcpy(&thdr, rptr, sizeof(txn_hdr));
- dtokp->set_dsize(thdr._xidsize + sizeof(txn_hdr) + sizeof(rec_tail));
+ txn_hdr_t thdr;
+ std::memcpy(&thdr, rptr, sizeof(txn_hdr_t));
+ dtokp->set_dsize(thdr._xidsize + sizeof(txn_hdr_t) + sizeof(rec_tail_t));
}
else
{
@@ -490,11 +489,11 @@ rmgr::consume_filler()
iores
rmgr::skip(data_tok* dtokp)
{
- u_int32_t dsize_dblks = jrec::size_dblks(dtokp->dsize());
- u_int32_t tot_dblk_cnt = dtokp->dblocks_read();
+ uint32_t dsize_dblks = jrec::size_dblks(dtokp->dsize());
+ uint32_t tot_dblk_cnt = dtokp->dblocks_read();
while (true)
{
- u_int32_t this_dblk_cnt = 0;
+ uint32_t this_dblk_cnt = 0;
if (dsize_dblks - tot_dblk_cnt > dblks_rem())
this_dblk_cnt = dblks_rem();
else
@@ -537,6 +536,8 @@ rmgr::aio_cycle()
// Perform validity checks
if (_fhdr_rd_outstanding) // read of file header still outstanding in aio
return RHM_IORES_SUCCESS;
+ // TODO: replace for linear store: _rrfc
+/*
if (!_rrfc.is_valid())
{
// Flush and reset all read states and pointers
@@ -549,14 +550,15 @@ rmgr::aio_cycle()
init_file_header_read(); // send off AIO read request for file header
return RHM_IORES_SUCCESS;
}
+*/
int16_t first_uninit = -1;
- u_int16_t num_uninit = 0;
- u_int16_t num_compl = 0;
+ uint16_t num_uninit = 0;
+ uint16_t num_compl = 0;
bool outstanding = false;
// Index must start with current buffer and cycle around so that first
// uninitialized buffer is initialized first
- for (u_int16_t i=_pg_index; i<_pg_index+_cache_num_pages; i++)
+ for (uint16_t i=_pg_index; i<_pg_index+_cache_num_pages; i++)
{
int16_t ci = i % _cache_num_pages;
switch (_page_cb_arr[ci]._state)
@@ -588,8 +590,10 @@ rmgr::aio_cycle()
}
iores
-rmgr::init_aio_reads(const int16_t first_uninit, const u_int16_t num_uninit)
+rmgr::init_aio_reads(const int16_t /*first_uninit*/, const uint16_t /*num_uninit*/)
{
+ // TODO: replace for linear store: _rrfc
+/*
for (int16_t i=0; i<num_uninit; i++)
{
if (_rrfc.is_void()) // Nothing to do; this file not yet written to
@@ -604,10 +608,10 @@ rmgr::init_aio_reads(const int16_t first_uninit, const u_int16_t num_uninit)
// TODO: Future perf improvement: Do a single AIO read for all available file
// space into all contiguous empty pages in one AIO operation.
- u_int32_t file_rem_dblks = _rrfc.remaining_dblks();
+ uint32_t file_rem_dblks = _rrfc.remaining_dblks();
file_rem_dblks -= file_rem_dblks % JRNL_SBLK_SIZE; // round down to closest sblk boundary
- u_int32_t pg_size_dblks = JRNL_RMGR_PAGE_SIZE * JRNL_SBLK_SIZE;
- u_int32_t rd_size = file_rem_dblks > pg_size_dblks ? pg_size_dblks : file_rem_dblks;
+ uint32_t pg_size_dblks = JRNL_RMGR_PAGE_SIZE * JRNL_SBLK_SIZE;
+ uint32_t rd_size = file_rem_dblks > pg_size_dblks ? pg_size_dblks : file_rem_dblks;
if (rd_size)
{
int16_t pi = (i + first_uninit) % _cache_num_pages;
@@ -627,6 +631,7 @@ rmgr::init_aio_reads(const int16_t first_uninit, const u_int16_t num_uninit)
if (_rrfc.file_rotate())
_rrfc.rotate();
}
+*/
return RHM_IORES_SUCCESS;
}
@@ -651,7 +656,7 @@ rmgr::rotate_page()
_pg_cntr = 0;
}
-u_int32_t
+uint32_t
rmgr::dblks_rem() const
{
return _page_cb_arr[_pg_index]._rdblks - _pg_offset_dblks;
@@ -669,6 +674,8 @@ rmgr::set_params_null(void** const datapp, std::size_t& dsize, void** const xidp
void
rmgr::init_file_header_read()
{
+ // TODO: replace for linear store: _rrfc
+/*
_jc->fhdr_wr_sync(_rrfc.index()); // wait if the file header write is outstanding
int rfh = _rrfc.fh();
aio::prep_pread_2(_fhdr_aio_cb_ptr, rfh, _fhdr_buffer, _sblksize, 0);
@@ -677,11 +684,12 @@ rmgr::init_file_header_read()
_aio_evt_rem++;
_rrfc.add_subm_cnt_dblks(JRNL_SBLK_SIZE);
_fhdr_rd_outstanding = true;
+*/
}
/* TODO (sometime in the future)
const iores
-rmgr::get(const u_int64_t& rid, const std::size_t& dsize, const std::size_t& dsize_avail,
+rmgr::get(const uint64_t& rid, const std::size_t& dsize, const std::size_t& dsize_avail,
const void** const data, bool auto_discard)
{
return RHM_IORES_SUCCESS;
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/rmgr.h b/qpid/cpp/src/qpid/linearstore/jrnl/rmgr.h
index 47a36ef35c..2b7c948868 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/rmgr.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/rmgr.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file rmgr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::rmgr (read manager). See
- * class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_RMGR_H
#define QPID_LEGACYSTORE_JRNL_RMGR_H
@@ -42,11 +31,12 @@ class rmgr;
}
#include <cstring>
-#include "qpid/legacystore/jrnl/enums.h"
-#include "qpid/legacystore/jrnl/file_hdr.h"
-#include "qpid/legacystore/jrnl/pmgr.h"
-#include "qpid/legacystore/jrnl/rec_hdr.h"
-#include "qpid/legacystore/jrnl/rrfc.h"
+#include "qpid/linearstore/jrnl/enums.h"
+//#include "qpid/linearstore/jrnl/file_hdr.h"
+#include "qpid/linearstore/jrnl/pmgr.h"
+//#include "qpid/linearstore/jrnl/rec_hdr.h"
+//#include "qpid/linearstore/jrnl/rrfc.h"
+#include "qpid/linearstore/jrnl/utils/file_hdr.h"
namespace mrg
{
@@ -62,16 +52,16 @@ namespace journal
class rmgr : public pmgr
{
private:
- rrfc& _rrfc; ///< Ref to read rotating file controller
- rec_hdr _hdr; ///< Header used to determind record type
+ //rrfc& _rrfc; ///< Ref to read rotating file controller
+ rec_hdr_t _hdr; ///< Header used to determind record type
void* _fhdr_buffer; ///< Buffer used for fhdr reads
aio_cb* _fhdr_aio_cb_ptr; ///< iocb pointer for fhdr reads
- file_hdr _fhdr; ///< file header instance for reading file headers
+ file_hdr_t _fhdr; ///< file header instance for reading file headers
bool _fhdr_rd_outstanding; ///< true if a fhdr read is outstanding
public:
- rmgr(jcntl* jc, enq_map& emap, txn_map& tmap, rrfc& rrfc);
+ rmgr(jcntl* jc, enq_map& emap, txn_map& tmap/*, rrfc& rrfc*/);
virtual ~rmgr();
using pmgr::initialize;
@@ -81,12 +71,12 @@ namespace journal
bool ignore_pending_txns);
int32_t get_events(page_state state, timespec* const timeout, bool flush = false);
void recover_complete();
- inline iores synchronize() { if (_rrfc.is_valid()) return RHM_IORES_SUCCESS; return aio_cycle(); }
+ inline iores synchronize() { /*if (_rrfc.is_valid()) return RHM_IORES_SUCCESS;*/ return aio_cycle(); }
void invalidate();
- bool wait_for_validity(timespec* const timeout, const bool throw_on_timeout = false);
+// bool wait_for_validity(timespec* const timeout, const bool throw_on_timeout = false);
/* TODO (if required)
- const iores get(const u_int64_t& rid, const std::size_t& dsize, const std::size_t& dsize_avail,
+ const iores get(const uint64_t& rid, const std::size_t& dsize, const std::size_t& dsize_avail,
const void** const data, bool auto_discard);
const iores discard(data_tok* dtok);
*/
@@ -95,14 +85,14 @@ namespace journal
void clean();
void flush(timespec* timeout);
iores pre_read_check(data_tok* dtokp);
- iores read_enq(rec_hdr& h, void* rptr, data_tok* dtokp);
- void consume_xid_rec(rec_hdr& h, void* rptr, data_tok* dtokp);
+ iores read_enq(rec_hdr_t& h, void* rptr, data_tok* dtokp);
+ void consume_xid_rec(rec_hdr_t& h, void* rptr, data_tok* dtokp);
void consume_filler();
iores skip(data_tok* dtokp);
iores aio_cycle();
- iores init_aio_reads(const int16_t first_uninit, const u_int16_t num_uninit);
+ iores init_aio_reads(const int16_t first_uninit, const uint16_t num_uninit);
void rotate_page();
- u_int32_t dblks_rem() const;
+ uint32_t dblks_rem() const;
void set_params_null(void** const datapp, std::size_t& dsize, void** const xidpp,
std::size_t& xidsize);
void init_file_header_read();
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.cpp
deleted file mode 100644
index fc6f5d427f..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file rrfc.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::rrfc (rotating
- * file controller). See comments in file rrfc.h for details.
- *
- * \author Kim van der Riet
- */
-
-
-#include "qpid/legacystore/jrnl/rrfc.h"
-
-#include <cerrno>
-#include <fcntl.h>
-#include <unistd.h>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
-
-namespace mrg
-{
-namespace journal
-{
-
-rrfc::rrfc(const lpmgr* lpmp): rfc(lpmp), _fh(-1), _valid(false)
-{}
-
-rrfc::~rrfc()
-{
- close_fh();
-}
-
-void
-rrfc::finalize()
-{
- unset_findex();
- rfc::finalize();
-}
-
-void
-rrfc::set_findex(const u_int16_t fc_index)
-{
- rfc::set_findex(fc_index);
- open_fh(_curr_fc->fname());
-}
-
-void
-rrfc::unset_findex()
-{
- set_invalid();
- close_fh();
- rfc::unset_findex();
-}
-
-iores
-rrfc::rotate()
-{
- if (!_lpmp->num_jfiles())
- throw jexception(jerrno::JERR__NINIT, "rrfc", "rotate");
- u_int16_t next_fc_index = _fc_index + 1;
- if (next_fc_index == _lpmp->num_jfiles())
- next_fc_index = 0;
- set_findex(next_fc_index);
- return RHM_IORES_SUCCESS;
-}
-
-std::string
-rrfc::status_str() const
-{
- std::ostringstream oss;
- oss << "rrfc: " << rfc::status_str();
- if (is_active())
- oss << " fcntl[" << _fc_index << "]: " << _curr_fc->status_str();
- return oss.str();
-}
-
-// === protected functions ===
-
-void
-rrfc::open_fh(const std::string& fn)
-{
- close_fh();
- _fh = ::open(fn.c_str(), O_RDONLY | O_DIRECT);
- if (_fh < 0)
- {
- std::ostringstream oss;
- oss << "file=\"" << fn << "\"" << FORMAT_SYSERR(errno);
- throw jexception(jerrno::JERR_RRFC_OPENRD, oss.str(), "rrfc", "open_fh");
- }
-}
-
-void
-rrfc::close_fh()
-{
- if (_fh >= 0)
- {
- ::close(_fh);
- _fh = -1;
- }
-}
-
-} // namespace journal
-} // namespace mrg
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.h b/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.h
deleted file mode 100644
index 5066d6048a..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/rrfc.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file rrfc.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::rrfc (rotating
- * file controller). See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_RRFC_H
-#define QPID_LEGACYSTORE_JRNL_RRFC_H
-
-namespace mrg
-{
-namespace journal
-{
-class rrfc;
-}
-}
-
-#include "qpid/legacystore/jrnl/fcntl.h"
-#include "qpid/legacystore/jrnl/rfc.h"
-
-namespace mrg
-{
-namespace journal
-{
-
- /**
- * \class rrfc
- * \brief Read Rotating File Controller (rrfc) - Subclassed from pure virtual class rfc. Used to control the read
- * pipeline in a rotating file buffer or journal. See class rfc for further details.
- *
- * The states that exist in this class are identical to class rfc from which it inherits, but in addition, the value
- * of the read file handle _fh is also considered. The calls to set_findex also opens the file handle _fh to the
- * active file for reading. Similarly, unset_findex() closes this file handle.
- *
- * <pre>
- * is_init() is_active()
- * +===+ _lpmp.is_init() == false
- * +---------->| | Uninitialized: _curr_fc == 0 F F
- * | +-->+===+ --+ _fh == -1
- * | | |
- * | | |
- * | finalize() initialize()
- * | | |
- * | | |
- * | +-- +===+<--+ _lpmp.is_init() == true
- * finalize() | | Inactive: _curr_fc == 0 T F
- * | +-->+===+ --+ _fh == -1
- * | | |
- * | | |
- * | unset_findex() set_findex()
- * | | |
- * | | |
- * | +-- +===+<--+ _lpmp.is_init() == true
- * +---------- | | Active: _curr_fc != 0 T T
- * +===+ _fh >= 0
- * </pre>
- *
- * In adition to the states above, class rrfc contains a validity flag. This is operated indepenedently of the state
- * machine. This flag (_valid) indicates when the read buffers are valid for reading. This is not strictly a state,
- * but simply a flag used to keep track of the status, and is set/unset with calls to set_valid() and set_invalid()
- * respectively.
- */
- class rrfc : public rfc
- {
- protected:
- int _fh; ///< Read file handle
- bool _valid; ///< Flag is true when read pages contain vailid data
-
- public:
- rrfc(const lpmgr* lpmp);
- virtual ~rrfc();
-
- /**
- * \brief Initialize the controller, moving from state Uninitialized to Initialized. The main function of
- * initialize() is to set the number of files and the pointer to the fcntl array.
- */
- inline void initialize() { rfc::initialize(); _valid = false; }
-
- /**
- * \brief Reset the controller to Uninitialized state, usually called when the journal is stopped. Once called,
- * initialize() must be called to reuse an instance.
- */
- void finalize();
-
- /**
- * \brief Opens the file handle for reading a particular fid. Moves to state open.
- */
- void set_findex(const u_int16_t fc_index);
-
- /**
- * \brief Closes the read file handle and nulls the active fcntl pointer. Moves to state closed.
- */
- void unset_findex();
-
- /**
- * \brief Check the state: true = open; false = closed.
- */
- inline bool is_active() const { return _curr_fc != 0 && _fh >= 0; }
-
- /**
- * \brief Sets the validity flag which indicates that the read buffers contain valid data for reading.
- */
- inline void set_invalid() { _valid = false; }
-
- /**
- * \brief Resets the validity flag wich indicates that the read buffers are no longer synchronized and cannot
- * be read whithout resynchronization.
- */
- inline void set_valid() { _valid = true; }
-
- /**
- * \brief Checks the read buffer validity status: true = valid, can be read; false = invalid, synchronization
- * required.
- */
- inline bool is_valid() const { return _valid; }
-
- /**
- * \brief Rotate active file controller to next file in rotating file group.
- * \exception jerrno::JERR__NINIT if called before calling initialize().
- */
- iores rotate();
-
- inline int fh() const { return _fh; }
-
- inline u_int32_t subm_cnt_dblks() const { return _curr_fc->rd_subm_cnt_dblks(); }
- inline std::size_t subm_offs() const { return _curr_fc->rd_subm_offs(); }
- inline u_int32_t add_subm_cnt_dblks(u_int32_t a) { return _curr_fc->add_rd_subm_cnt_dblks(a); }
-
- inline u_int32_t cmpl_cnt_dblks() const { return _curr_fc->rd_cmpl_cnt_dblks(); }
- inline std::size_t cmpl_offs() const { return _curr_fc->rd_cmpl_offs(); }
- inline u_int32_t add_cmpl_cnt_dblks(u_int32_t a) { return _curr_fc->add_rd_cmpl_cnt_dblks(a); }
-
- inline bool is_void() const { return _curr_fc->rd_void(); }
- inline bool is_empty() const { return _curr_fc->rd_empty(); }
- inline u_int32_t remaining_dblks() const { return _curr_fc->rd_remaining_dblks(); }
- inline bool is_full() const { return _curr_fc->is_rd_full(); }
- inline bool is_compl() const { return _curr_fc->is_rd_compl(); }
- inline u_int32_t aio_outstanding_dblks() const { return _curr_fc->rd_aio_outstanding_dblks(); }
- inline bool file_rotate() const { return _curr_fc->rd_file_rotate(); }
- inline bool is_wr_aio_outstanding() const { return _curr_fc->wr_aio_outstanding_dblks() > 0; }
-
- // Debug aid
- std::string status_str() const;
-
- protected:
- void open_fh(const std::string& fn);
- void close_fh();
- }; // class rrfc
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_RRFC_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/slock.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/slock.cpp
deleted file mode 100644
index 8f26d349ef..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/slock.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file slock.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::slock (scoped lock). See
- * comments in file slock.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/slock.h"
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/slock.h b/qpid/cpp/src/qpid/linearstore/jrnl/slock.h
index c05b5cf336..56aa74f312 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/slock.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/slock.h
@@ -19,22 +19,11 @@
*
*/
-/**
- * \file slock.h
- *
- * Qpid asynchronous store plugin library
- *
- * Messaging journal scoped lock class mrg::journal::slock and scoped try-lock
- * class mrg::journal::stlock.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_SLOCK_H
#define QPID_LEGACYSTORE_JRNL_SLOCK_H
-#include "qpid/legacystore/jrnl/jexception.h"
-#include "qpid/legacystore/jrnl/smutex.h"
+#include "qpid/linearstore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/smutex.h"
#include <pthread.h>
namespace mrg
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/smutex.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/smutex.cpp
deleted file mode 100644
index 6f8991ca5b..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/smutex.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file smutex.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::smutex (scoped mutex). See
- * comments in file smutex.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/smutex.h"
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/smutex.h b/qpid/cpp/src/qpid/linearstore/jrnl/smutex.h
index def0fb70f6..70a5fc9969 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/smutex.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/smutex.h
@@ -19,21 +19,10 @@
*
*/
-/**
- * \file smutex.h
- *
- * Qpid asynchronous store plugin library
- *
- * Messaging journal scoped mutex class mrg::journal::smutex.
- *
- * \author Kim van der Riet
- */
-
-
#ifndef QPID_LEGACYSTORE_JRNL_SMUTEX_H
#define QPID_LEGACYSTORE_JRNL_SMUTEX_H
-#include "qpid/legacystore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/jexception.h"
#include <pthread.h>
namespace mrg
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.cpp
index 976068ef68..e5051c0b13 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.cpp
@@ -19,18 +19,7 @@
*
*/
-/**
- * \file time_ns.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * Messaging journal time struct mrg::journal::time_ns, derived from
- * the timespec struct and provided with helper functions.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/time_ns.h"
+#include "qpid/linearstore/jrnl/time_ns.h"
#include <sstream>
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.h b/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.h
index a9f69e2631..7e4f46b3ce 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/time_ns.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file time_ns.h
- *
- * Qpid asynchronous store plugin library
- *
- * Messaging journal time struct mrg::journal::time_ns, derived from
- * the timespec struct and provided with helper functions.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_TIME_NS_H
#define QPID_LEGACYSTORE_JRNL_TIME_NS_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/txn_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/txn_hdr.h
deleted file mode 100644
index 94b812ccec..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/txn_hdr.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file txn_hdr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::txn_hdr (transaction
- * record header), used to start a transaction (commit or abort) record.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_TXN_HDR_H
-#define QPID_LEGACYSTORE_JRNL_TXN_HDR_H
-
-#include <cstddef>
-#include "qpid/legacystore/jrnl/rec_hdr.h"
-
-namespace mrg
-{
-namespace journal
-{
-
-#pragma pack(1)
-
- /**
- * \brief Struct for transaction commit and abort records.
- *
- * Struct for DTX commit and abort records. Only the magic distinguishes between them. Since
- * this record must be used in the context of a valid XID, the xidsize field must not be zero.
- * Immediately following this record is the XID itself which is xidsize bytes long, followed by
- * a rec_tail.
- *
- * Note that this record had its own rid distinct from the rids of the record(s) making up the
- * transaction it is committing or aborting.
- *
- * Record header info in binary format (24 bytes):
- * <pre>
- * 0 7
- * +---+---+---+---+---+---+---+---+ -+
- * | magic | v | e | flags | |
- * +---+---+---+---+---+---+---+---+ | struct hdr
- * | rid | |
- * +---+---+---+---+---+---+---+---+ -+
- * | xidsize |
- * +---+---+---+---+---+---+---+---+
- * v = file version (If the format or encoding of this file changes, then this
- * number should be incremented)
- * e = endian flag, false (0x00) for little endian, true (0x01) for big endian
- * </pre>
- *
- * Note that journal files should be transferable between 32- and 64-bit
- * hardware of the same endianness, but not between hardware of opposite
- * entianness without some sort of binary conversion utility. Thus buffering
- * will be needed for types that change size between 32- and 64-bit compiles.
- */
- struct txn_hdr : rec_hdr
- {
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler0; ///< Big-endian filler for 32-bit size_t
-#endif
- std::size_t _xidsize; ///< XID size
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- u_int32_t _filler0; ///< Little-endian filler for 32-bit size_t
-#endif
-
- /**
- * \brief Default constructor, which sets all values to 0.
- */
- txn_hdr(): rec_hdr(),
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
- _xidsize(0)
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- , _filler0(0)
-#endif
- {}
-
- /**
- * \brief Convenience constructor which initializes values during construction.
- */
- txn_hdr(const u_int32_t magic, const u_int8_t version, const u_int64_t rid,
- const std::size_t xidsize, const bool owi): rec_hdr(magic, version, rid, owi),
-#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- _filler0(0),
-#endif
- _xidsize(xidsize)
-#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- , _filler0(0)
-#endif
- {}
-
- /**
- * \brief Returns the size of the header in bytes.
- */
- inline static std::size_t size() { return sizeof(txn_hdr); }
- };
-
-#pragma pack()
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_TXN_HDR_H
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.cpp
index c514670601..6be90b67fa 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.cpp
@@ -19,23 +19,12 @@
*
*/
-/**
- * \file txn_map.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::txn_map (transaction map). See
- * comments in file txn_map.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/txn_map.h"
+#include "qpid/linearstore/jrnl/txn_map.h"
#include <iomanip>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
-#include "qpid/legacystore/jrnl/slock.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/slock.h"
#include <sstream>
namespace mrg
@@ -50,7 +39,7 @@ int16_t txn_map::TMAP_OK = 0;
int16_t txn_map::TMAP_NOT_SYNCED = 0;
int16_t txn_map::TMAP_SYNCED = 1;
-txn_data_struct::txn_data_struct(const u_int64_t rid, const u_int64_t drid, const u_int16_t pfid,
+txn_data_struct::txn_data_struct(const uint64_t rid, const uint64_t drid, const uint16_t pfid,
const bool enq_flag, const bool commit_flag):
_rid(rid),
_drid(drid),
@@ -68,13 +57,13 @@ txn_map::txn_map():
txn_map::~txn_map() {}
void
-txn_map::set_num_jfiles(const u_int16_t num_jfiles)
+txn_map::set_num_jfiles(const uint16_t num_jfiles)
{
_pfid_txn_cnt.resize(num_jfiles, 0);
}
-u_int32_t
-txn_map::get_txn_pfid_cnt(const u_int16_t pfid) const
+uint32_t
+txn_map::get_txn_pfid_cnt(const uint16_t pfid) const
{
return _pfid_txn_cnt.at(pfid);
}
@@ -137,23 +126,23 @@ txn_map::in_map(const std::string& xid)
return itr != _map.end();
}
-u_int32_t
+uint32_t
txn_map::enq_cnt()
{
return cnt(true);
}
-u_int32_t
+uint32_t
txn_map::deq_cnt()
{
return cnt(true);
}
-u_int32_t
+uint32_t
txn_map::cnt(const bool enq_flag)
{
slock s(_mutex);
- u_int32_t c = 0;
+ uint32_t c = 0;
for (xmap_itr i = _map.begin(); i != _map.end(); i++)
{
for (tdl_itr j = i->second.begin(); j < i->second.end(); j++)
@@ -185,7 +174,7 @@ txn_map::is_txn_synced(const std::string& xid)
}
int16_t
-txn_map::set_aio_compl(const std::string& xid, const u_int64_t rid)
+txn_map::set_aio_compl(const std::string& xid, const uint64_t rid)
{
slock s(_mutex);
xmap_itr itr = _map.find(xid);
@@ -204,7 +193,7 @@ txn_map::set_aio_compl(const std::string& xid, const u_int64_t rid)
}
bool
-txn_map::data_exists(const std::string& xid, const u_int64_t rid)
+txn_map::data_exists(const std::string& xid, const uint64_t rid)
{
bool found = false;
{
@@ -221,7 +210,7 @@ txn_map::data_exists(const std::string& xid, const u_int64_t rid)
}
bool
-txn_map::is_enq(const u_int64_t rid)
+txn_map::is_enq(const uint64_t rid)
{
bool found = false;
{
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.h b/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.h
index 6b38564e53..0ae322e80c 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/txn_map.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file txn_map.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::txn_map (transaction map).
- * See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_TXN_MAP_H
#define QPID_LEGACYSTORE_JRNL_TXN_MAP_H
@@ -41,11 +30,10 @@ namespace journal
}
}
-#include "qpid/legacystore/jrnl/smutex.h"
+#include "qpid/linearstore/jrnl/smutex.h"
#include <map>
#include <pthread.h>
#include <string>
-#include <sys/types.h>
#include <vector>
namespace mrg
@@ -60,13 +48,13 @@ namespace journal
*/
struct txn_data_struct
{
- u_int64_t _rid; ///< Record id for this operation
- u_int64_t _drid; ///< Dequeue record id for this operation
- u_int16_t _pfid; ///< Physical file id, to be used when transferring to emap on commit
+ uint64_t _rid; ///< Record id for this operation
+ uint64_t _drid; ///< Dequeue record id for this operation
+ uint16_t _pfid; ///< Physical file id, to be used when transferring to emap on commit
bool _enq_flag; ///< If true, enq op, otherwise deq op
bool _commit_flag; ///< (2PC transactions) Records 2PC complete c/a mode
bool _aio_compl; ///< Initially false, set to true when record AIO returns
- txn_data_struct(const u_int64_t rid, const u_int64_t drid, const u_int16_t pfid,
+ txn_data_struct(const uint64_t rid, const uint64_t drid, const uint16_t pfid,
const bool enq_flag, const bool commit_flag = false);
};
typedef txn_data_struct txn_data;
@@ -125,31 +113,31 @@ namespace journal
xmap _map;
smutex _mutex;
- std::vector<u_int32_t> _pfid_txn_cnt;
+ std::vector<uint32_t> _pfid_txn_cnt;
const txn_data_list _empty_data_list;
public:
txn_map();
virtual ~txn_map();
- void set_num_jfiles(const u_int16_t num_jfiles);
- u_int32_t get_txn_pfid_cnt(const u_int16_t pfid) const;
+ void set_num_jfiles(const uint16_t num_jfiles);
+ uint32_t get_txn_pfid_cnt(const uint16_t pfid) const;
bool insert_txn_data(const std::string& xid, const txn_data& td);
const txn_data_list get_tdata_list(const std::string& xid);
const txn_data_list get_remove_tdata_list(const std::string& xid);
bool in_map(const std::string& xid);
- u_int32_t enq_cnt();
- u_int32_t deq_cnt();
+ uint32_t enq_cnt();
+ uint32_t deq_cnt();
int16_t is_txn_synced(const std::string& xid); // -1=xid not found; 0=not synced; 1=synced
- int16_t set_aio_compl(const std::string& xid, const u_int64_t rid); // -2=rid not found; -1=xid not found; 0=done
- bool data_exists(const std::string& xid, const u_int64_t rid);
- bool is_enq(const u_int64_t rid);
+ int16_t set_aio_compl(const std::string& xid, const uint64_t rid); // -2=rid not found; -1=xid not found; 0=done
+ bool data_exists(const std::string& xid, const uint64_t rid);
+ bool is_enq(const uint64_t rid);
inline void clear() { _map.clear(); }
inline bool empty() const { return _map.empty(); }
inline size_t size() const { return _map.size(); }
void xid_list(std::vector<std::string>& xv);
private:
- u_int32_t cnt(const bool enq_flag);
+ uint32_t cnt(const bool enq_flag);
const txn_data_list get_tdata_list_nolock(const std::string& xid);
};
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.cpp
index 918a6ce902..67889cf6e7 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.cpp
@@ -19,26 +19,15 @@
*
*/
-/**
- * \file txn_rec.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains the code for the mrg::journal::txn_rec (journal dequeue
- * record) class. See comments in file txn_rec.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/txn_rec.h"
+#include "qpid/linearstore/jrnl/txn_rec.h"
#include <cassert>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <iomanip>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
+#include "qpid/linearstore/jrnl/jerrno.h"
+#include "qpid/linearstore/jrnl/jexception.h"
#include <sstream>
namespace mrg
@@ -47,21 +36,25 @@ namespace journal
{
txn_rec::txn_rec():
- _txn_hdr(),
+// _txn_hdr(),
_xidp(0),
- _buff(0),
- _txn_tail()
+ _buff(0)
+// _txn_tail()
{
- _txn_hdr._version = RHM_JDAT_VERSION;
+ ::txn_hdr_init(&_txn_hdr, 0, QLS_JRNL_VERSION, 0, 0, 0);
+ ::rec_tail_init(&_txn_tail, 0, 0, 0);
}
-txn_rec::txn_rec(const u_int32_t magic, const u_int64_t rid, const void* const xidp,
- const std::size_t xidlen, const bool owi):
- _txn_hdr(magic, RHM_JDAT_VERSION, rid, xidlen, owi),
+txn_rec::txn_rec(const uint32_t magic, const uint64_t rid, const void* const xidp,
+ const std::size_t xidlen/*, const bool owi*/):
+// _txn_hdr(magic, RHM_JDAT_VERSION, rid, xidlen, owi),
_xidp(xidp),
- _buff(0),
- _txn_tail(_txn_hdr)
-{}
+ _buff(0)
+// _txn_tail(_txn_hdr)
+{
+ ::txn_hdr_init(&_txn_hdr, magic, QLS_JRNL_VERSION, 0, rid, xidlen);
+ ::rec_tail_copy(&_txn_tail, &_txn_hdr._rhdr, 0);
+}
txn_rec::~txn_rec()
{
@@ -69,10 +62,10 @@ txn_rec::~txn_rec()
}
void
-txn_rec::reset(const u_int32_t magic)
+txn_rec::reset(const uint32_t magic)
{
- _txn_hdr._magic = magic;
- _txn_hdr._rid = 0;
+ _txn_hdr._rhdr._magic = magic;
+ _txn_hdr._rhdr._rid = 0;
_txn_hdr._xidsize = 0;
_xidp = 0;
_buff = 0;
@@ -81,12 +74,12 @@ txn_rec::reset(const u_int32_t magic)
}
void
-txn_rec::reset(const u_int32_t magic, const u_int64_t rid, const void* const xidp,
- const std::size_t xidlen, const bool owi)
+txn_rec::reset(const uint32_t magic, const uint64_t rid, const void* const xidp,
+ const std::size_t xidlen/*, const bool owi*/)
{
- _txn_hdr._magic = magic;
- _txn_hdr._rid = rid;
- _txn_hdr.set_owi(owi);
+ _txn_hdr._rhdr._magic = magic;
+ _txn_hdr._rhdr._rid = rid;
+// _txn_hdr.set_owi(owi);
_txn_hdr._xidsize = xidlen;
_xidp = xidp;
_buff = 0;
@@ -94,8 +87,8 @@ txn_rec::reset(const u_int32_t magic, const u_int64_t rid, const void* const xi
_txn_tail._rid = rid;
}
-u_int32_t
-txn_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+uint32_t
+txn_rec::encode(void* wptr, uint32_t rec_offs_dblks, uint32_t max_size_dblks)
{
assert(wptr != 0);
assert(max_size_dblks > 0);
@@ -108,7 +101,7 @@ txn_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
{
if (size_dblks(rec_size()) - rec_offs_dblks > max_size_dblks) // Further split required
{
- rec_offs -= sizeof(_txn_hdr);
+ rec_offs -= sizeof(txn_hdr_t);
std::size_t wsize = _txn_hdr._xidsize > rec_offs ? _txn_hdr._xidsize - rec_offs : 0;
std::size_t wsize2 = wsize;
if (wsize)
@@ -139,7 +132,7 @@ txn_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
}
else // No further split required
{
- rec_offs -= sizeof(_txn_hdr);
+ rec_offs -= sizeof(txn_hdr_t);
std::size_t wsize = _txn_hdr._xidsize > rec_offs ? _txn_hdr._xidsize - rec_offs : 0;
if (wsize)
{
@@ -165,12 +158,12 @@ txn_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
else // Start at beginning of data record
{
// Assumption: the header will always fit into the first dblk
- std::memcpy(wptr, (void*)&_txn_hdr, sizeof(_txn_hdr));
- wr_cnt = sizeof(_txn_hdr);
+ std::memcpy(wptr, (void*)&_txn_hdr, sizeof(txn_hdr_t));
+ wr_cnt = sizeof(txn_hdr_t);
if (size_dblks(rec_size()) > max_size_dblks) // Split required
{
std::size_t wsize;
- rem -= sizeof(_txn_hdr);
+ rem -= sizeof(txn_hdr_t);
if (rem)
{
wsize = rem >= _txn_hdr._xidsize ? _txn_hdr._xidsize : rem;
@@ -202,8 +195,8 @@ txn_rec::encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
return size_dblks(wr_cnt);
}
-u_int32_t
-txn_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks)
+uint32_t
+txn_rec::decode(rec_hdr_t& h, void* rptr, uint32_t rec_offs_dblks, uint32_t max_size_dblks)
{
assert(rptr != 0);
assert(max_size_dblks > 0);
@@ -211,18 +204,17 @@ txn_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
std::size_t rd_cnt = 0;
if (rec_offs_dblks) // Continuation of record on new page
{
- const u_int32_t hdr_xid_dblks = size_dblks(txn_hdr::size() + _txn_hdr._xidsize);
- const u_int32_t hdr_xid_tail_dblks = size_dblks(txn_hdr::size() + _txn_hdr._xidsize +
- rec_tail::size());
+ const uint32_t hdr_xid_dblks = size_dblks(sizeof(txn_hdr_t) + _txn_hdr._xidsize);
+ const uint32_t hdr_xid_tail_dblks = size_dblks(sizeof(txn_hdr_t) + _txn_hdr._xidsize + sizeof(rec_tail_t));
const std::size_t rec_offs = rec_offs_dblks * JRNL_DBLK_SIZE;
if (hdr_xid_tail_dblks - rec_offs_dblks <= max_size_dblks)
{
// Remainder of xid fits within this page
- if (rec_offs - txn_hdr::size() < _txn_hdr._xidsize)
+ if (rec_offs - sizeof(txn_hdr_t) < _txn_hdr._xidsize)
{
// Part of xid still outstanding, copy remainder of xid and tail
- const std::size_t xid_offs = rec_offs - txn_hdr::size();
+ const std::size_t xid_offs = rec_offs - sizeof(txn_hdr_t);
const std::size_t xid_rem = _txn_hdr._xidsize - xid_offs;
std::memcpy((char*)_buff + xid_offs, rptr, xid_rem);
rd_cnt = xid_rem;
@@ -233,8 +225,8 @@ txn_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
else
{
// Tail or part of tail only outstanding, complete tail
- const std::size_t tail_offs = rec_offs - txn_hdr::size() - _txn_hdr._xidsize;
- const std::size_t tail_rem = rec_tail::size() - tail_offs;
+ const std::size_t tail_offs = rec_offs - sizeof(txn_hdr_t) - _txn_hdr._xidsize;
+ const std::size_t tail_rem = sizeof(rec_tail_t) - tail_offs;
std::memcpy((char*)&_txn_tail + tail_offs, rptr, tail_rem);
chk_tail();
rd_cnt = tail_rem;
@@ -243,7 +235,7 @@ txn_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
else if (hdr_xid_dblks - rec_offs_dblks <= max_size_dblks)
{
// Remainder of xid fits within this page, tail split
- const std::size_t xid_offs = rec_offs - txn_hdr::size();
+ const std::size_t xid_offs = rec_offs - sizeof(txn_hdr_t);
const std::size_t xid_rem = _txn_hdr._xidsize - xid_offs;
std::memcpy((char*)_buff + xid_offs, rptr, xid_rem);
rd_cnt += xid_rem;
@@ -258,26 +250,27 @@ txn_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
{
// Remainder of xid split
const std::size_t xid_cp_size = (max_size_dblks * JRNL_DBLK_SIZE);
- std::memcpy((char*)_buff + rec_offs - txn_hdr::size(), rptr, xid_cp_size);
+ std::memcpy((char*)_buff + rec_offs - sizeof(txn_hdr_t), rptr, xid_cp_size);
rd_cnt += xid_cp_size;
}
}
else // Start of record
{
// Get and check header
- _txn_hdr.hdr_copy(h);
- rd_cnt = sizeof(rec_hdr);
+ //_txn_hdr.hdr_copy(h);
+ ::rec_hdr_copy(&_txn_hdr._rhdr, &h);
+ rd_cnt = sizeof(rec_hdr_t);
#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- rd_cnt += sizeof(u_int32_t); // Filler 0
+ rd_cnt += sizeof(uint32_t); // Filler 0
#endif
_txn_hdr._xidsize = *(std::size_t*)((char*)rptr + rd_cnt);
- rd_cnt = _txn_hdr.size();
+ rd_cnt = sizeof(txn_hdr_t);
chk_hdr();
_buff = std::malloc(_txn_hdr._xidsize);
MALLOC_CHK(_buff, "_buff", "txn_rec", "decode");
- const u_int32_t hdr_xid_dblks = size_dblks(txn_hdr::size() + _txn_hdr._xidsize);
- const u_int32_t hdr_xid_tail_dblks = size_dblks(txn_hdr::size() + _txn_hdr._xidsize +
- rec_tail::size());
+ const uint32_t hdr_xid_dblks = size_dblks(sizeof(txn_hdr_t) + _txn_hdr._xidsize);
+ const uint32_t hdr_xid_tail_dblks = size_dblks(sizeof(txn_hdr_t) + _txn_hdr._xidsize +
+ sizeof(rec_tail_t));
// Check if record (header + xid + tail) fits within this page, we can check the
// tail before the expense of copying data to memory
@@ -314,27 +307,28 @@ txn_rec::decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks, u_int32_t max_
}
bool
-txn_rec::rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs)
+txn_rec::rcv_decode(rec_hdr_t h, std::ifstream* ifsp, std::size_t& rec_offs)
{
if (rec_offs == 0)
{
// Read header, allocate for xid
- _txn_hdr.hdr_copy(h);
+ //_txn_hdr.hdr_copy(h);
+ ::rec_hdr_copy(&_txn_hdr._rhdr, &h);
#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
- ifsp->ignore(sizeof(u_int32_t)); // _filler0
+ ifsp->ignore(sizeof(uint32_t)); // _filler0
#endif
ifsp->read((char*)&_txn_hdr._xidsize, sizeof(std::size_t));
#if defined(JRNL_LITTLE_ENDIAN) && defined(JRNL_32_BIT)
- ifsp->ignore(sizeof(u_int32_t)); // _filler0
+ ifsp->ignore(sizeof(uint32_t)); // _filler0
#endif
- rec_offs = sizeof(_txn_hdr);
+ rec_offs = sizeof(txn_hdr_t);
_buff = std::malloc(_txn_hdr._xidsize);
MALLOC_CHK(_buff, "_buff", "txn_rec", "rcv_decode");
}
- if (rec_offs < sizeof(_txn_hdr) + _txn_hdr._xidsize)
+ if (rec_offs < sizeof(txn_hdr_t) + _txn_hdr._xidsize)
{
// Read xid (or continue reading xid)
- std::size_t offs = rec_offs - sizeof(_txn_hdr);
+ std::size_t offs = rec_offs - sizeof(txn_hdr_t);
ifsp->read((char*)_buff + offs, _txn_hdr._xidsize - offs);
std::size_t size_read = ifsp->gcount();
rec_offs += size_read;
@@ -347,14 +341,14 @@ txn_rec::rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs)
return false;
}
}
- if (rec_offs < sizeof(_txn_hdr) + _txn_hdr._xidsize + sizeof(rec_tail))
+ if (rec_offs < sizeof(txn_hdr_t) + _txn_hdr._xidsize + sizeof(rec_tail_t))
{
// Read tail (or continue reading tail)
- std::size_t offs = rec_offs - sizeof(_txn_hdr) - _txn_hdr._xidsize;
- ifsp->read((char*)&_txn_tail + offs, sizeof(rec_tail) - offs);
+ std::size_t offs = rec_offs - sizeof(txn_hdr_t) - _txn_hdr._xidsize;
+ ifsp->read((char*)&_txn_tail + offs, sizeof(rec_tail_t) - offs);
std::size_t size_read = ifsp->gcount();
rec_offs += size_read;
- if (size_read < sizeof(rec_tail) - offs)
+ if (size_read < sizeof(rec_tail_t) - offs)
{
assert(ifsp->eof());
// As we may have read past eof, turn off fail bit
@@ -385,12 +379,12 @@ std::string&
txn_rec::str(std::string& str) const
{
std::ostringstream oss;
- if (_txn_hdr._magic == RHM_JDAT_TXA_MAGIC)
- oss << "dtxa_rec: m=" << _txn_hdr._magic;
+ if (_txn_hdr._rhdr._magic == QLS_TXA_MAGIC)
+ oss << "dtxa_rec: m=" << _txn_hdr._rhdr._magic;
else
- oss << "dtxc_rec: m=" << _txn_hdr._magic;
- oss << " v=" << (int)_txn_hdr._version;
- oss << " rid=" << _txn_hdr._rid;
+ oss << "dtxc_rec: m=" << _txn_hdr._rhdr._magic;
+ oss << " v=" << (int)_txn_hdr._rhdr._version;
+ oss << " rid=" << _txn_hdr._rhdr._rid;
oss << " xid=\"" << _xidp << "\"";
str.append(oss.str());
return str;
@@ -405,36 +399,36 @@ txn_rec::xid_size() const
std::size_t
txn_rec::rec_size() const
{
- return txn_hdr::size() + _txn_hdr._xidsize + rec_tail::size();
+ return sizeof(txn_hdr_t) + _txn_hdr._xidsize + sizeof(rec_tail_t);
}
void
txn_rec::chk_hdr() const
{
- jrec::chk_hdr(_txn_hdr);
- if (_txn_hdr._magic != RHM_JDAT_TXA_MAGIC && _txn_hdr._magic != RHM_JDAT_TXC_MAGIC)
+ jrec::chk_hdr(_txn_hdr._rhdr);
+ if (_txn_hdr._rhdr._magic != QLS_TXA_MAGIC && _txn_hdr._rhdr._magic != QLS_TXC_MAGIC)
{
std::ostringstream oss;
oss << std::hex << std::setfill('0');
- oss << "dtx magic: rid=0x" << std::setw(16) << _txn_hdr._rid;
- oss << ": expected=(0x" << std::setw(8) << RHM_JDAT_TXA_MAGIC;
- oss << " or 0x" << RHM_JDAT_TXC_MAGIC;
- oss << ") read=0x" << std::setw(2) << (int)_txn_hdr._magic;
+ oss << "dtx magic: rid=0x" << std::setw(16) << _txn_hdr._rhdr._rid;
+ oss << ": expected=(0x" << std::setw(8) << QLS_TXA_MAGIC;
+ oss << " or 0x" << QLS_TXC_MAGIC;
+ oss << ") read=0x" << std::setw(2) << (int)_txn_hdr._rhdr._magic;
throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "txn_rec", "chk_hdr");
}
}
void
-txn_rec::chk_hdr(u_int64_t rid) const
+txn_rec::chk_hdr(uint64_t rid) const
{
chk_hdr();
- jrec::chk_rid(_txn_hdr, rid);
+ jrec::chk_rid(_txn_hdr._rhdr, rid);
}
void
txn_rec::chk_tail() const
{
- jrec::chk_tail(_txn_tail, _txn_hdr);
+ jrec::chk_tail(_txn_tail, _txn_hdr._rhdr);
}
void
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.h b/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.h
index 1a49df1c96..68c759eaa9 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/txn_rec.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file txn_rec.h
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains the code for the mrg::journal::txn_rec (journal data
- * record) class. See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_TXN_REC_H
#define QPID_LEGACYSTORE_JRNL_TXN_REC_H
@@ -42,8 +31,8 @@ class txn_rec;
}
#include <cstddef>
-#include "qpid/legacystore/jrnl/jrec.h"
-#include "qpid/legacystore/jrnl/txn_hdr.h"
+#include "qpid/linearstore/jrnl/jrec.h"
+#include "qpid/linearstore/jrnl/utils/txn_hdr.h"
namespace mrg
{
@@ -57,40 +46,40 @@ namespace journal
class txn_rec : public jrec
{
private:
- txn_hdr _txn_hdr; ///< transaction header
+ txn_hdr_t _txn_hdr; ///< transaction header
const void* _xidp; ///< xid pointer for encoding (writing to disk)
void* _buff; ///< Pointer to buffer to receive data read from disk
- rec_tail _txn_tail; ///< Record tail
+ rec_tail_t _txn_tail; ///< Record tail
public:
// constructor used for read operations and xid must have memory allocated
txn_rec();
// constructor used for write operations, where xid already exists
- txn_rec(const u_int32_t magic, const u_int64_t rid, const void* const xidp,
- const std::size_t xidlen, const bool owi);
+ txn_rec(const uint32_t magic, const uint64_t rid, const void* const xidp,
+ const std::size_t xidlen/*, const bool owi*/);
virtual ~txn_rec();
// Prepare instance for use in reading data from journal
- void reset(const u_int32_t magic);
+ void reset(const uint32_t magic);
// Prepare instance for use in writing data to journal
- void reset(const u_int32_t magic, const u_int64_t rid, const void* const xidp,
- const std::size_t xidlen, const bool owi);
- u_int32_t encode(void* wptr, u_int32_t rec_offs_dblks, u_int32_t max_size_dblks);
- u_int32_t decode(rec_hdr& h, void* rptr, u_int32_t rec_offs_dblks,
- u_int32_t max_size_dblks);
+ void reset(const uint32_t magic, const uint64_t rid, const void* const xidp,
+ const std::size_t xidlen/*, const bool owi*/);
+ uint32_t encode(void* wptr, uint32_t rec_offs_dblks, uint32_t max_size_dblks);
+ uint32_t decode(rec_hdr_t& h, void* rptr, uint32_t rec_offs_dblks,
+ uint32_t max_size_dblks);
// Decode used for recover
- bool rcv_decode(rec_hdr h, std::ifstream* ifsp, std::size_t& rec_offs);
+ bool rcv_decode(rec_hdr_t h, std::ifstream* ifsp, std::size_t& rec_offs);
std::size_t get_xid(void** const xidpp);
std::string& str(std::string& str) const;
inline std::size_t data_size() const { return 0; } // This record never carries data
std::size_t xid_size() const;
std::size_t rec_size() const;
- inline u_int64_t rid() const { return _txn_hdr._rid; }
+ inline uint64_t rid() const { return _txn_hdr._rhdr._rid; }
private:
void chk_hdr() const;
- void chk_hdr(u_int64_t rid) const;
+ void chk_hdr(uint64_t rid) const;
void chk_tail() const;
virtual void clean();
}; // class txn_rec
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c b/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c
index dbdb88140c..0cdab3580c 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.c
@@ -21,9 +21,22 @@
#include "deq_hdr.h"
-static const uint16_t DEQ_HDR_TXNCMPLCOMMIT_MASK = 0x10;
+/*static const uint16_t DEQ_HDR_TXNCMPLCOMMIT_MASK = 0x10;*/
-bool is_txn_coml_commit(deq_hdr_t *dh) {
+void deq_hdr_init(deq_hdr_t* dest, const uint32_t magic, const uint16_t version, const uint16_t uflag, const uint64_t
+ rid, const uint64_t deq_rid, const uint64_t xidsize) {
+ rec_hdr_init(&dest->_rhdr, magic, version, uflag, rid);
+ dest->_deq_rid = deq_rid;
+ dest->_xidsize = xidsize;
+}
+
+void deq_hdr_copy(deq_hdr_t* dest, const deq_hdr_t* src) {
+ rec_hdr_copy(&dest->_rhdr, &src->_rhdr);
+ dest->_deq_rid = src->_deq_rid;
+ dest->_xidsize = src->_xidsize;
+}
+
+bool is_txn_coml_commit(const deq_hdr_t *dh) {
return dh->_rhdr._uflag & DEQ_HDR_TXNCMPLCOMMIT_MASK;
}
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h
index 73f99f98f2..f84848a6ad 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/deq_hdr.h
@@ -21,67 +21,53 @@
*
*/
-/**
- * \file deq_hdr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::deq_hdr (dequeue record),
- * used to dequeue a previously enqueued record.
- *
- * \author Kim van der Riet
- */
-
#include <stdbool.h>
#include "rec_hdr.h"
#pragma pack(1)
/**
-* \brief Struct for dequeue record.
-*
-* Struct for dequeue record. If this record has a non-zero xidsize field (i.e., there is a
-* valid XID), then this header is followed by the XID of xidsize bytes and a rec_tail. If,
-* on the other hand, this record has a zero xidsize (i.e., there is no XID), then the rec_tail
-* is absent.
-*
-* Note that this record had its own rid distinct from the rid of the record it is dequeueing.
-* The rid field below is the rid of the dequeue record itself; the deq-rid field is the rid of a
-* previous enqueue record being dequeued by this record.
-*
-* Record header info in binary format (32 bytes):
-* <pre>
-* 0 7
-* +---+---+---+---+---+---+---+---+ -+
-* | magic | v | e | flags | |
-* +---+---+---+---+---+---+---+---+ | struct hdr
-* | rid | |
-* +---+---+---+---+---+---+---+---+ -+
-* | deq-rid |
-* +---+---+---+---+---+---+---+---+
-* | xidsize |
-* +---+---+---+---+---+---+---+---+
-* v = file version (If the format or encoding of this file changes, then this
-* number should be incremented)
-* e = endian flag, false (0x00) for little endian, true (0x01) for big endian
-* </pre>
-*
-* Note that journal files should be transferable between 32- and 64-bit
-* hardware of the same endianness, but not between hardware of opposite
-* entianness without some sort of binary conversion utility. Thus buffering
-* will be needed for types that change size between 32- and 64-bit compiles.
-*/
+ * \brief Struct for dequeue record.
+ *
+ * Struct for dequeue record. If this record has a non-zero xidsize field (i.e., there is a
+ * valid XID), then this header is followed by the XID of xidsize bytes and a rec_tail. If,
+ * on the other hand, this record has a zero xidsize (i.e., there is no XID), then the rec_tail
+ * is absent.
+ *
+ * Note that this record had its own rid distinct from the rid of the record it is dequeueing.
+ * The rid field below is the rid of the dequeue record itself; the deq-rid field is the rid of a
+ * previous enqueue record being dequeued by this record.
+ *
+ * Record header info in binary format (32 bytes):
+ * <pre>
+ * 0 7
+ * +---+---+---+---+---+---+---+---+ -+
+ * | magic | ver | flags | |
+ * +---+---+---+---+---+---+---+---+ | struct rec_hdr_t
+ * | rid | |
+ * +---+---+---+---+---+---+---+---+ -+
+ * | deq-rid |
+ * +---+---+---+---+---+---+---+---+
+ * | xidsize |
+ * +---+---+---+---+---+---+---+---+
+ *
+ * deq-rid = dequeue record ID
+ * </pre>
+ */
typedef struct deq_hdr_t {
- rec_hdr_t _rhdr;
- uint64_t _deq_rid; ///< Record ID of dequeued record
- uint64_t _xidsize; ///< XID size
+ rec_hdr_t _rhdr; /**< Common record header struct */
+ uint64_t _deq_rid; /**< Record ID of record being dequeued */
+ uint64_t _xidsize; /**< XID size */
} deq_hdr_t;
-static const uint16_t DEQ_HDR_TXNCMPLCOMMIT_MASK;
+static const uint16_t DEQ_HDR_TXNCMPLCOMMIT_MASK = 0x10;
-bool is_txn_coml_commit(deq_hdr_t *dh);
+void deq_hdr_init(deq_hdr_t* dest, const uint32_t magic, const uint16_t version, const uint16_t uflag,
+ const uint64_t rid, const uint64_t deq_rid, const uint64_t xidsize);
+void deq_hdr_copy(deq_hdr_t* dest, const deq_hdr_t* src);
+bool is_txn_coml_commit(const deq_hdr_t *dh);
void set_txn_coml_commit(deq_hdr_t *dh, const bool commit);
#pragma pack()
-#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_DEQ_HDR_H
+#endif /* ifndef QPID_LINEARSTORE_JRNL_UTILS_DEQ_HDR_H */
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c b/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c
index 586c37821a..235828ef5a 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.c
@@ -21,23 +21,36 @@
#include "enq_hdr.h"
-static const uint16_t ENQ_HDR_TRANSIENT_MASK = 0x10;
-static const uint16_t ENQ_HDR_EXTERNAL_MASK = 0x20;
+//static const uint16_t ENQ_HDR_TRANSIENT_MASK = 0x10;
+//static const uint16_t ENQ_HDR_EXTERNAL_MASK = 0x20;
-bool is_transient(enq_hdr_t *eh) {
+void enq_hdr_init(enq_hdr_t* dest, const uint32_t magic, const uint16_t version, const uint16_t uflag,
+ const uint64_t rid, const uint64_t xidsize, const uint64_t dsize) {
+ rec_hdr_init(&dest->_rhdr, magic, version, uflag, rid);
+ dest->_xidsize = xidsize;
+ dest->_dsize = dsize;
+}
+
+void enq_hdr_copy(enq_hdr_t* dest, const enq_hdr_t* src) {
+ rec_hdr_copy(&dest->_rhdr, &src->_rhdr);
+ dest->_xidsize = src->_xidsize;
+ dest->_dsize = src->_dsize;
+}
+
+bool is_enq_transient(const enq_hdr_t *eh) {
return eh->_rhdr._uflag & ENQ_HDR_TRANSIENT_MASK;
}
-void set_transient(enq_hdr_t *eh, const bool transient) {
+void set_enq_transient(enq_hdr_t *eh, const bool transient) {
eh->_rhdr._uflag = transient ? eh->_rhdr._uflag | ENQ_HDR_TRANSIENT_MASK :
eh->_rhdr._uflag & (~ENQ_HDR_TRANSIENT_MASK);
}
-bool is_external(enq_hdr_t *eh) {
+bool is_enq_external(const enq_hdr_t *eh) {
return eh->_rhdr._uflag & ENQ_HDR_EXTERNAL_MASK;
}
-void set_external(enq_hdr_t *eh, const bool external) {
+void set_enq_external(enq_hdr_t *eh, const bool external) {
eh->_rhdr._uflag = external ? eh->_rhdr._uflag | ENQ_HDR_EXTERNAL_MASK :
eh->_rhdr._uflag & (~ENQ_HDR_EXTERNAL_MASK);
}
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h
index f0d052c1f3..5cfb6150cf 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/enq_hdr.h
@@ -21,66 +21,52 @@
*
*/
-/**
- * \file enq_hdr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::enq_hdr (enueue header),
- * used to start an enqueue record in the journal.
- *
- * \author Kim van der Riet
- */
-
#include <stdbool.h>
#include "rec_hdr.h"
#pragma pack(1)
- /**
- * \brief Struct for enqueue record.
- *
- * Struct for enqueue record. In addition to the common data, this header includes both the
- * xid and data blob sizes.
- *
- * This header precedes all enqueue data in journal files.
- *
- * Record header info in binary format (32 bytes):
- * <pre>
- * 0 7
- * +---+---+---+---+---+---+---+---+ -+
- * | magic | v | e | flags | |
- * +---+---+---+---+---+---+---+---+ | struct hdr
- * | rid | |
- * +---+---+---+---+---+---+---+---+ -+
- * | xidsize |
- * +---+---+---+---+---+---+---+---+
- * | dsize |
- * +---+---+---+---+---+---+---+---+
- * v = file version (If the format or encoding of this file changes, then this
- * number should be incremented)
- * e = endian flag, false (0x00) for little endian, true (0x01) for big endian
- * </pre>
- *
- * Note that journal files should be transferable between 32- and 64-bit
- * hardware of the same endianness, but not between hardware of opposite
- * entianness without some sort of binary conversion utility. Thus buffering
- * will be needed for types that change size between 32- and 64-bit compiles.
- */
+/**
+ * \brief Struct for enqueue record.
+ *
+ * Struct for enqueue record. In addition to the common data, this header includes both the
+ * xid and data blob sizes.
+ *
+ * This header precedes all enqueue data in journal files.
+ *
+ * Record header info in binary format (32 bytes):
+ * <pre>
+ * 0 7
+ * +---+---+---+---+---+---+---+---+ -+
+ * | magic | ver | flags | |
+ * +---+---+---+---+---+---+---+---+ | struct rec_hdr_t
+ * | rid | |
+ * +---+---+---+---+---+---+---+---+ -+
+ * | xidsize |
+ * +---+---+---+---+---+---+---+---+
+ * | dsize |
+ * +---+---+---+---+---+---+---+---+
+ * v = file version (If the format or encoding of this file changes, then this
+ * number should be incremented)
+ * </pre>
+ */
typedef struct enq_hdr_t {
- rec_hdr_t _rhdr;
- uint64_t _xidsize; ///< XID size
- uint64_t _dsize; ///< Record data size
+ rec_hdr_t _rhdr; /**< Common record header struct */
+ uint64_t _xidsize; /**< XID size in octets */
+ uint64_t _dsize; /**< Record data size in octets */
} enq_hdr_t;
-static const uint16_t ENQ_HDR_TRANSIENT_MASK;
-static const uint16_t ENQ_HDR_EXTERNAL_MASK;
+static const uint16_t ENQ_HDR_TRANSIENT_MASK = 0x10;
+static const uint16_t ENQ_HDR_EXTERNAL_MASK = 0x20;
-bool is_transient(enq_hdr_t *eh);
-void set_transient(enq_hdr_t *eh, const bool transient);
-bool is_external(enq_hdr_t *eh);
-void set_external(enq_hdr_t *eh, const bool external);
+void enq_hdr_init(enq_hdr_t* dest, const uint32_t magic, const uint16_t version, const uint16_t uflag,
+ const uint64_t rid, const uint64_t xidsize, const uint64_t dsize);
+void enq_hdr_copy(enq_hdr_t* dest, const enq_hdr_t* src);
+bool is_enq_transient(const enq_hdr_t *eh);
+void set_enq_transient(enq_hdr_t *eh, const bool transient);
+bool is_enq_external(const enq_hdr_t *eh);
+void set_enq_external(enq_hdr_t *eh, const bool external);
#pragma pack()
-#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_ENQ_HDR_H
+#endif /* ifndef QPID_LINEARSTORE_JRNL_UTILS_ENQ_HDR_H */
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c b/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c
index 2b6bd37c39..c17fe0acec 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.c
@@ -21,12 +21,33 @@
#include "file_hdr.h"
+void file_hdr_init(file_hdr_t* dest, const uint32_t magic, const uint16_t version, const uint16_t uflag,
+ const uint64_t rid, const uint64_t fro, const uint64_t ts_sec, const uint64_t ts_nsec,
+ const uint32_t file_count, const uint64_t file_size, const uint64_t file_number) {
+ rec_hdr_init(&dest->_rhdr, magic, version, uflag, rid);
+ dest->_fro = fro;
+ dest->_ts_sec = ts_sec;
+ dest->_ts_nsec = ts_nsec;
+ dest->_file_count = file_count;
+ dest->_file_size = file_size;
+ dest->_file_number = file_number;
+}
+
+void file_hdr_copy(file_hdr_t* dest, const file_hdr_t* src) {
+ rec_hdr_copy(&dest->_rhdr, &src->_rhdr);
+ dest->_fro = src->_fro;
+ dest->_ts_sec = src->_ts_sec;
+ dest->_ts_nsec = src->_ts_nsec;
+ dest->_file_count = src->_file_count;
+ dest->_file_size = src->_file_size;
+ dest->_file_number = src->_file_number;
+}
+
int set_time_now(file_hdr_t *fh)
{
struct timespec ts;
- int err;
-
- if (err = clock_gettime(CLOCK_REALTIME, &ts))
+ int err = clock_gettime(CLOCK_REALTIME, &ts);
+ if (err)
return err;
fh->_ts_sec = ts.tv_sec;
fh->_ts_nsec = ts.tv_nsec;
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h
index ed3e67cc50..a60dc43636 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/file_hdr.h
@@ -21,18 +21,6 @@
*
*/
-/**
- * \file file_hdr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::file_hdr (file
- * record header), used to start a journal file. It contains some
- * file metadata and information to aid journal recovery.
- *
- * \author Kim van der Riet
- */
-
#include <time.h>
#include "rec_hdr.h"
@@ -47,12 +35,12 @@
* block in the file. The record ID and offset are updated on each overwrite of the
* file.
*
- * File header info in binary format (48 bytes):
+ * File header info in binary format (66 bytes + size of file name in octets):
* <pre>
* 0 7
* +---+---+---+---+---+---+---+---+ -+
- * | magic | v | 0 | flags | |
- * +---+---+---+---+---+---+---+---+ | struct hdr
+ * | magic | ver | flags | |
+ * +---+---+---+---+---+---+---+---+ | struct rec_hdr_t
* | first rid in file | |
* +---+---+---+---+---+---+---+---+ -+
* | fro |
@@ -67,40 +55,36 @@
* +---+---+---+---+---+---+---+---+
* | file-number |
* +---+---+---+---+---+---+---+---+
- * | n-len | File Name... |
+ * | n-len | Queue Name... |
* +-------+ |
* | |
* +---+---+---+---+---+---+---+---+
*
- * v = file version (If the format or encoding of this file changes, then this
- * number should be incremented)
- * fro = First record offset, offset from start of file to first record header
- * file-count = Number of files in use for the journal at the time this header is written
- * file-size = Size of the file in octets
- * file-number = Incrementing serial number indicating file order within a journal
+ * ver = file version (If the format or encoding of this file changes, then this
+ * number should be incremented)
+ * fro = First Record Offset
* n-len = Length of the queue name in octets.
* </pre>
- *
- * Note that journal files should be transferable between 32- and 64-bit
- * hardware of the same endianness, but not between hardware of opposite
- * entianness without some sort of binary conversion utility. Thus buffering
- * will be needed for types that change size between 32- and 64-bit compiles.
*/
typedef struct file_hdr_t {
- rec_hdr_t _rhdr;
- uint64_t _fro;
- uint64_t _ts_sec;
- uint64_t _ts_nsec;
- uint32_t _file_count;
+ rec_hdr_t _rhdr; /**< Common record header struct, but rid field is used for rid of first compete record in file */
+ uint64_t _fro; /**< First Record Offset (FRO) */
+ uint64_t _ts_sec; /**< Time stamp (seconds part) */
+ uint64_t _ts_nsec; /**< Time stamp (nanoseconds part) */
+ uint32_t _file_count; /**< Total number of files in linear sequence at time of writing this file */
uint32_t _reserved;
- uint64_t _file_size;
- uint64_t _file_number;
- uint16_t _name_length;
+ uint64_t _file_size; /**< Size of this file in octets, including header sblk */
+ uint64_t _file_number; /**< The logical number of this file in a monotonically increasing sequence */
+ uint16_t _name_length; /**< Length of the queue name in octets, which follows this struct in the header */
} file_hdr_t;
+void file_hdr_init(file_hdr_t* dest, const uint32_t magic, const uint16_t version, const uint16_t uflag,
+ const uint64_t rid, const uint64_t fro, const uint64_t ts_sec, const uint64_t ts_nsec,
+ const uint32_t file_count, const uint64_t file_size, const uint64_t file_number);
+void file_hdr_copy(file_hdr_t* dest, const file_hdr_t* src);
int set_time_now(file_hdr_t *fh);
void set_time(file_hdr_t *fh, struct timespec *ts);
#pragma pack()
-#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_FILE_HDR_H
+#endif /* ifndef QPID_LINEARSTORE_JRNL_UTILS_FILE_HDR_H */
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.c b/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.c
new file mode 100644
index 0000000000..be56068b9e
--- /dev/null
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.c
@@ -0,0 +1,15 @@
+#include "rec_hdr.h"
+
+void rec_hdr_init(rec_hdr_t* dest, const uint32_t magic, const uint16_t version, const uint16_t uflag, const uint64_t rid) {
+ dest->_magic = magic;
+ dest->_version = version;
+ dest->_uflag = uflag;
+ dest->_rid = rid;
+}
+
+void rec_hdr_copy(rec_hdr_t* dest, const rec_hdr_t* src) {
+ dest->_magic = src->_magic;
+ dest->_version = src->_version;
+ dest->_uflag = src->_uflag;
+ dest->_rid = src->_rid;
+}
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h
index d176bb2301..0a38b191d1 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_hdr.h
@@ -21,21 +21,7 @@
*
*/
-/**
- * \file rec_hdr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::rec_hdr (record header),
- * which is a common initial header used for all journal record structures
- * except the record tail (rec_tail).
- *
- * \author Kim van der Riet
- */
-
#include <stdint.h>
-/*#include "qpid/legacystore/jrnl/jcfg.h"*/
-/*#include <sys/types.h>*/
#pragma pack(1)
@@ -48,28 +34,26 @@
* <pre>
* 0 7
* +---+---+---+---+---+---+---+---+
- * | magic | v | 0 | flags |
+ * | magic | ver | flags |
* +---+---+---+---+---+---+---+---+
* | rid |
* +---+---+---+---+---+---+---+---+
- * v = file version (If the format or encoding of this file changes, then this
- * number should be incremented)
- * 0 = reserved
- * </pre>
*
- * Note that journal files should be transferable between 32- and 64-bit
- * hardware of the same endianness, but not between hardware of opposite
- * entianness without some sort of binary conversion utility. Thus buffering
- * will be needed for types that change size between 32- and 64-bit compiles.
+ * ver = file version (If the format or encoding of this file changes, then this
+ * number should be incremented)
+ * rid = Record ID
+ * </pre>
*/
typedef struct rec_hdr_t {
- uint32_t _magic; ///< File type identifier (magic number)
- uint8_t _version; ///< File encoding version
- uint8_t _zero; ///< Flag for determining endianness
- uint16_t _uflag; ///< User-defined flags
- uint64_t _rid; ///< Record ID (rotating 64-bit counter)
+ uint32_t _magic; /**< File type identifier (magic number) */
+ uint16_t _version; /**< File encoding version */
+ uint16_t _uflag; /**< User-defined flags */
+ uint64_t _rid; /**< Record ID (rotating 64-bit counter) */
} rec_hdr_t;
+void rec_hdr_init(rec_hdr_t* dest, const uint32_t magic, const uint16_t version, const uint16_t uflag, const uint64_t rid);
+void rec_hdr_copy(rec_hdr_t* dest, const rec_hdr_t* src);
+
#pragma pack()
-#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_REC_HDR_H
+#endif /* ifndef QPID_LINEARSTORE_JRNL_UTILS_REC_HDR_H */
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/aio.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_tail.c
index ffbddd887e..2e604eb6c6 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/aio.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_tail.c
@@ -19,23 +19,16 @@
*
*/
-/**
- * \file aio.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::aio (libaio interface
- * encapsulation). See comments in file aio.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/aio.h"
+#include "rec_tail.h"
-namespace mrg
-{
-namespace journal
-{
+void rec_tail_init(rec_tail_t* dest, const uint32_t xmagic, const uint32_t checksum, const uint64_t rid) {
+ dest->_xmagic = xmagic;
+ dest->_checksum = checksum;
+ dest->_rid = rid;
+}
-} // namespace journal
-} // namespace mrg
+void rec_tail_copy(rec_tail_t* dest, const rec_hdr_t* src, const uint32_t checksum) {
+ dest->_xmagic = ~(src->_magic);
+ dest->_checksum = checksum;
+ dest->_rid = src->_rid;
+}
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_tail.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_tail.h
new file mode 100644
index 0000000000..d865f17c6c
--- /dev/null
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/rec_tail.h
@@ -0,0 +1,63 @@
+#ifndef QPID_LEGACYSTORE_JRNL_UTILS_REC_TAIL_H
+#define QPID_LEGACYSTORE_JRNL_UTILS_REC_TAIL_H
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <stdint.h>
+#include "rec_hdr.h"
+
+#pragma pack(1)
+
+/**
+ * \brief Struct for data common to the tail of all records. The magic number
+ * used here is the binary inverse (1's complement) of the magic used in the
+ * record header; this minimizes possible confusion with other headers that may
+ * be present during recovery. The tail is used with all records that have either
+ * XIDs or data - ie any size-variable content. Currently the only records that
+ * do NOT use the tail are non-transactional dequeues and filler records.
+ *
+ * The checksum is used to verify the xid and/or data portion of the record
+ * on recovery, and excludes the header and tail.
+ *
+ * Record header info in binary format (16 bytes):
+ * <pre>
+ * 0 7
+ * +---+---+---+---+---+---+---+---+
+ * | ~(magic) | checksum |
+ * +---+---+---+---+---+---+---+---+
+ * | rid |
+ * +---+---+---+---+---+---+---+---+
+ *
+ * rid = Record ID
+ * </pre>
+ */
+typedef struct rec_tail_t {
+ uint32_t _xmagic; /**< Binary inverse (1's complement) of hdr magic number */
+ uint32_t _checksum; /**< Checksum of xid and data */
+ uint64_t _rid; /**< ID (rotating 64-bit counter) */
+} rec_tail_t;
+
+void rec_tail_init(rec_tail_t* dest, const uint32_t xmagic, const uint32_t checksum, const uint64_t rid);
+void rec_tail_copy(rec_tail_t* dest, const rec_hdr_t* src, const uint32_t checksum);
+
+#pragma pack()
+
+#endif /* ifnedf QPID_LEGACYSTORE_JRNL_UTILS_REC_TAIL_H */
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/cvar.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.c
index e4010bf91f..3b94bf3bb8 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/cvar.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.c
@@ -19,15 +19,15 @@
*
*/
-/**
- * \file cvar.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::cvar (condition variable). See
- * comments in file cvar.h for details.
- *
- * \author Kim van der Riet
- */
+#include "txn_hdr.h"
+
+void txn_hdr_init(txn_hdr_t* dest, const uint32_t magic, const uint16_t version, const uint16_t uflag,
+ const uint64_t rid, const uint64_t xidsize) {
+ rec_hdr_init(&dest->_rhdr, magic, version, uflag, rid);
+ dest->_xidsize = xidsize;
+}
-#include "qpid/legacystore/jrnl/cvar.h"
+void txn_hdr_copy(txn_hdr_t* dest, const txn_hdr_t* src) {
+ rec_hdr_copy(&dest->_rhdr, &src->_rhdr);
+ dest->_xidsize = src->_xidsize;
+}
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h b/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h
index 25acb0a940..9312a2911b 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/utils/txn_hdr.h
@@ -21,57 +21,42 @@
*
*/
-/**
- * \file txn_hdr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::txn_hdr (transaction
- * record header), used to start a transaction (commit or abort) record.
- *
- * \author Kim van der Riet
- */
-
#include "rec_hdr.h"
#pragma pack(1)
/**
-* \brief Struct for transaction commit and abort records.
-*
-* Struct for DTX commit and abort records. Only the magic distinguishes between them. Since
-* this record must be used in the context of a valid XID, the xidsize field must not be zero.
-* Immediately following this record is the XID itself which is xidsize bytes long, followed by
-* a rec_tail.
-*
-* Note that this record had its own rid distinct from the rids of the record(s) making up the
-* transaction it is committing or aborting.
-*
-* Record header info in binary format (24 bytes):
-* <pre>
-* 0 7
-* +---+---+---+---+---+---+---+---+ -+
-* | magic | v | e | flags | |
-* +---+---+---+---+---+---+---+---+ | struct hdr
-* | rid | |
-* +---+---+---+---+---+---+---+---+ -+
-* | xidsize |
-* +---+---+---+---+---+---+---+---+
-* v = file version (If the format or encoding of this file changes, then this
-* number should be incremented)
-* e = endian flag, false (0x00) for little endian, true (0x01) for big endian
-* </pre>
-*
-* Note that journal files should be transferable between 32- and 64-bit
-* hardware of the same endianness, but not between hardware of opposite
-* entianness without some sort of binary conversion utility. Thus buffering
-* will be needed for types that change size between 32- and 64-bit compiles.
-*/
+ * \brief Struct for transaction commit and abort records.
+ *
+ * Struct for local and DTX commit and abort records. Only the magic distinguishes between them.
+ * Since this record must be used in the context of a valid XID, the xidsize field must not be
+ * zero. Immediately following this record is the XID itself which is xidsize bytes long,
+ * followed by a rec_tail.
+ *
+ * Note that this record had its own rid distinct from the rids of the record(s) making up the
+ * transaction it is committing or aborting.
+ *
+ * Record header info in binary format (24 bytes):
+ * <pre>
+ * 0 7
+ * +---+---+---+---+---+---+---+---+ -+
+ * | magic | v | e | flags | |
+ * +---+---+---+---+---+---+---+---+ | struct rec_hdr_t
+ * | rid | |
+ * +---+---+---+---+---+---+---+---+ -+
+ * | xidsize |
+ * +---+---+---+---+---+---+---+---+
+ * </pre>
+ */
typedef struct txn_hdr_t {
- rec_hdr_t _rhdr;
- uint64_t _xidsize; ///< XID size
+ rec_hdr_t _rhdr; /**< Common record header struct */
+ uint64_t _xidsize; /**< XID size */
} txn_hdr_t;
+void txn_hdr_init(txn_hdr_t* dest, const uint32_t magic, const uint16_t version, const uint16_t uflag,
+ const uint64_t rid, const uint64_t xidsize);
+void txn_hdr_copy(txn_hdr_t* dest, const txn_hdr_t* src);
+
#pragma pack()
-#endif // ifndef QPID_LINEARSTORE_JRNL_UTILS_TXN_HDR_H
+#endif /* ifndef QPID_LINEARSTORE_JRNL_UTILS_TXN_HDR_H */
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/wmgr.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/wmgr.cpp
index 4353fcfbca..acb09dc2c3 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/wmgr.cpp
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/wmgr.cpp
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file wmgr.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::wmgr (write manager). See
- * comments in file wmgr.h for details.
- *
- * \author Kim van der Riet
- */
-
#include "qpid/legacystore/jrnl/wmgr.h"
#include <cassert>
@@ -40,6 +29,7 @@
#include "qpid/legacystore/jrnl/jcntl.h"
#include "qpid/legacystore/jrnl/jerrno.h"
#include <sstream>
+#include <stdint.h>
namespace mrg
{
@@ -66,7 +56,7 @@ wmgr::wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc):
{}
wmgr::wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc,
- const u_int32_t max_dtokpp, const u_int32_t max_iowait_us):
+ const uint32_t max_dtokpp, const uint32_t max_iowait_us):
pmgr(jc, emap, tmap /* , dtoklp */),
_wrfc(wrfc),
_max_dtokpp(max_dtokpp),
@@ -91,8 +81,8 @@ wmgr::~wmgr()
}
void
-wmgr::initialize(aio_callback* const cbp, const u_int32_t wcache_pgsize_sblks,
- const u_int16_t wcache_num_pages, const u_int32_t max_dtokpp, const u_int32_t max_iowait_us,
+wmgr::initialize(aio_callback* const cbp, const uint32_t wcache_pgsize_sblks,
+ const uint16_t wcache_num_pages, const uint32_t max_dtokpp, const uint32_t max_iowait_us,
std::size_t eo)
{
_enq_busy = false;
@@ -110,8 +100,8 @@ wmgr::initialize(aio_callback* const cbp, const u_int32_t wcache_pgsize_sblks,
if (eo)
{
- const u_int32_t wr_pg_size_dblks = _cache_pgsize_sblks * JRNL_SBLK_SIZE;
- u_int32_t data_dblks = (eo / JRNL_DBLK_SIZE) - 4; // 4 dblks for file hdr
+ const uint32_t wr_pg_size_dblks = _cache_pgsize_sblks * JRNL_SBLK_SIZE;
+ uint32_t data_dblks = (eo / JRNL_DBLK_SIZE) - 4; // 4 dblks for file hdr
_pg_cntr = data_dblks / wr_pg_size_dblks;
_pg_offset_dblks = data_dblks - (_pg_cntr * wr_pg_size_dblks);
}
@@ -148,7 +138,7 @@ wmgr::enqueue(const void* const data_buff, const std::size_t tot_data_len,
}
}
- u_int64_t rid = (dtokp->external_rid() | cont) ? dtokp->rid() : _wrfc.get_incr_rid();
+ uint64_t rid = (dtokp->external_rid() | cont) ? dtokp->rid() : _wrfc.get_incr_rid();
_enq_rec.reset(rid, data_buff, tot_data_len, xid_ptr, xid_len, _wrfc.owi(), transient,
external);
if (!cont)
@@ -166,8 +156,8 @@ wmgr::enqueue(const void* const data_buff, const std::size_t tot_data_len,
{
assert(_pg_offset_dblks < _cache_pgsize_sblks * JRNL_SBLK_SIZE);
void* wptr = (void*)((char*)_page_ptr_arr[_pg_index] + _pg_offset_dblks * JRNL_DBLK_SIZE);
- u_int32_t data_offs_dblks = dtokp->dblocks_written();
- u_int32_t ret = _enq_rec.encode(wptr, data_offs_dblks,
+ uint32_t data_offs_dblks = dtokp->dblocks_written();
+ uint32_t ret = _enq_rec.encode(wptr, data_offs_dblks,
(_cache_pgsize_sblks * JRNL_SBLK_SIZE) - _pg_offset_dblks);
// Remember fid which contains the record header in case record is split over several files
@@ -247,8 +237,8 @@ wmgr::dequeue(data_tok* dtokp, const void* const xid_ptr, const std::size_t xid_
}
const bool ext_rid = dtokp->external_rid();
- u_int64_t rid = (ext_rid | cont) ? dtokp->rid() : _wrfc.get_incr_rid();
- u_int64_t dequeue_rid = (ext_rid | cont) ? dtokp->dequeue_rid() : dtokp->rid();
+ uint64_t rid = (ext_rid | cont) ? dtokp->rid() : _wrfc.get_incr_rid();
+ uint64_t dequeue_rid = (ext_rid | cont) ? dtokp->dequeue_rid() : dtokp->rid();
_deq_rec.reset(rid, dequeue_rid, xid_ptr, xid_len, _wrfc.owi(), txn_coml_commit);
if (!cont)
{
@@ -270,8 +260,8 @@ wmgr::dequeue(data_tok* dtokp, const void* const xid_ptr, const std::size_t xid_
{
assert(_pg_offset_dblks < _cache_pgsize_sblks * JRNL_SBLK_SIZE);
void* wptr = (void*)((char*)_page_ptr_arr[_pg_index] + _pg_offset_dblks * JRNL_DBLK_SIZE);
- u_int32_t data_offs_dblks = dtokp->dblocks_written();
- u_int32_t ret = _deq_rec.encode(wptr, data_offs_dblks,
+ uint32_t data_offs_dblks = dtokp->dblocks_written();
+ uint32_t ret = _deq_rec.encode(wptr, data_offs_dblks,
(_cache_pgsize_sblks * JRNL_SBLK_SIZE) - _pg_offset_dblks);
// Remember fid which contains the record header in case record is split over several files
@@ -356,7 +346,7 @@ wmgr::abort(data_tok* dtokp, const void* const xid_ptr, const std::size_t xid_le
}
}
- u_int64_t rid = (dtokp->external_rid() | cont) ? dtokp->rid() : _wrfc.get_incr_rid();
+ uint64_t rid = (dtokp->external_rid() | cont) ? dtokp->rid() : _wrfc.get_incr_rid();
_txn_rec.reset(RHM_JDAT_TXA_MAGIC, rid, xid_ptr, xid_len, _wrfc.owi());
if (!cont)
{
@@ -371,8 +361,8 @@ wmgr::abort(data_tok* dtokp, const void* const xid_ptr, const std::size_t xid_le
{
assert(_pg_offset_dblks < _cache_pgsize_sblks * JRNL_SBLK_SIZE);
void* wptr = (void*)((char*)_page_ptr_arr[_pg_index] + _pg_offset_dblks * JRNL_DBLK_SIZE);
- u_int32_t data_offs_dblks = dtokp->dblocks_written();
- u_int32_t ret = _txn_rec.encode(wptr, data_offs_dblks,
+ uint32_t data_offs_dblks = dtokp->dblocks_written();
+ uint32_t ret = _txn_rec.encode(wptr, data_offs_dblks,
(_cache_pgsize_sblks * JRNL_SBLK_SIZE) - _pg_offset_dblks);
// Remember fid which contains the record header in case record is split over several files
@@ -446,7 +436,7 @@ wmgr::commit(data_tok* dtokp, const void* const xid_ptr, const std::size_t xid_l
}
}
- u_int64_t rid = (dtokp->external_rid() | cont) ? dtokp->rid() : _wrfc.get_incr_rid();
+ uint64_t rid = (dtokp->external_rid() | cont) ? dtokp->rid() : _wrfc.get_incr_rid();
_txn_rec.reset(RHM_JDAT_TXC_MAGIC, rid, xid_ptr, xid_len, _wrfc.owi());
if (!cont)
{
@@ -461,8 +451,8 @@ wmgr::commit(data_tok* dtokp, const void* const xid_ptr, const std::size_t xid_l
{
assert(_pg_offset_dblks < _cache_pgsize_sblks * JRNL_SBLK_SIZE);
void* wptr = (void*)((char*)_page_ptr_arr[_pg_index] + _pg_offset_dblks * JRNL_DBLK_SIZE);
- u_int32_t data_offs_dblks = dtokp->dblocks_written();
- u_int32_t ret = _txn_rec.encode(wptr, data_offs_dblks,
+ uint32_t data_offs_dblks = dtokp->dblocks_written();
+ uint32_t ret = _txn_rec.encode(wptr, data_offs_dblks,
(_cache_pgsize_sblks * JRNL_SBLK_SIZE) - _pg_offset_dblks);
// Remember fid which contains the record header in case record is split over several files
@@ -537,7 +527,7 @@ wmgr::commit(data_tok* dtokp, const void* const xid_ptr, const std::size_t xid_l
}
void
-wmgr::file_header_check(const u_int64_t rid, const bool cont, const u_int32_t rec_dblks_rem)
+wmgr::file_header_check(const uint64_t rid, const bool cont, const uint32_t rec_dblks_rem)
{
// Has the file header been written (i.e. write pointers still at 0)?
if (_wrfc.is_void())
@@ -711,10 +701,10 @@ wmgr::get_events(page_state state, timespec* const timeout, bool flush)
}
if (pcbp) // Page writes have pcb
{
- u_int32_t s = pcbp->_pdtokl->size();
+ uint32_t s = pcbp->_pdtokl->size();
std::vector<data_tok*> dtokl;
dtokl.reserve(s);
- for (u_int32_t k=0; k<s; k++)
+ for (uint32_t k=0; k<s; k++)
{
data_tok* dtokp = pcbp->_pdtokl->at(k);
if (dtokp->decr_pg_cnt() == 0)
@@ -804,7 +794,7 @@ wmgr::get_events(page_state state, timespec* const timeout, bool flush)
{
// get lfid from original file header record, update info for that lfid
file_hdr* fhp = (file_hdr*)aiocbp->u.c.buf;
- u_int32_t lfid = fhp->_lfid;
+ uint32_t lfid = fhp->_lfid;
fcntl* fcntlp = _jc->get_fcntlp(lfid);
fcntlp->add_wr_cmpl_cnt_dblks(JRNL_SBLK_SIZE);
fcntlp->decr_aio_cnt();
@@ -827,7 +817,7 @@ wmgr::is_txn_synced(const std::string& xid)
}
void
-wmgr::initialize(aio_callback* const cbp, const u_int32_t wcache_pgsize_sblks, const u_int16_t wcache_num_pages)
+wmgr::initialize(aio_callback* const cbp, const uint32_t wcache_pgsize_sblks, const uint16_t wcache_num_pages)
{
pmgr::initialize(cbp, wcache_pgsize_sblks, wcache_num_pages);
wmgr::clean();
@@ -845,7 +835,7 @@ wmgr::initialize(aio_callback* const cbp, const u_int32_t wcache_pgsize_sblks, c
_fhdr_aio_cb_arr = (aio_cb**)std::malloc(sizeof(aio_cb*) * _num_jfiles);
MALLOC_CHK(_fhdr_aio_cb_arr, "_fhdr_aio_cb_arr", "wmgr", "initialize");
std::memset(_fhdr_aio_cb_arr, 0, sizeof(aio_cb*) * _num_jfiles);
- for (u_int16_t i=0; i<_num_jfiles; i++)
+ for (uint16_t i=0; i<_num_jfiles; i++)
{
_fhdr_ptr_arr[i] = (void*)((char*)_fhdr_base_ptr + _sblksize * i);
_fhdr_aio_cb_arr[i] = new aio_cb;
@@ -890,7 +880,7 @@ wmgr::pre_write_check(const _op_type op, const data_tok* const dtokp,
case WMGR_ENQUEUE:
{
// Check for enqueue reaching cutoff threshold
- u_int32_t size_dblks = jrec::size_dblks(enq_rec::rec_size(xidsize, dsize,
+ uint32_t size_dblks = jrec::size_dblks(enq_rec::rec_size(xidsize, dsize,
external));
if (!_enq_busy && _wrfc.enq_threshold(_cached_offset_dblks + size_dblks))
return RHM_IORES_ENQCAPTHRESH;
@@ -924,7 +914,7 @@ wmgr::pre_write_check(const _op_type op, const data_tok* const dtokp,
}
void
-wmgr::dequeue_check(const std::string& xid, const u_int64_t drid)
+wmgr::dequeue_check(const std::string& xid, const uint64_t drid)
{
// First check emap
bool found = false;
@@ -956,8 +946,8 @@ wmgr::dequeue_check(const std::string& xid, const u_int64_t drid)
void
wmgr::dblk_roundup()
{
- const u_int32_t xmagic = RHM_JDAT_EMPTY_MAGIC;
- u_int32_t wdblks = jrec::size_blks(_cached_offset_dblks, JRNL_SBLK_SIZE) * JRNL_SBLK_SIZE;
+ const uint32_t xmagic = RHM_JDAT_EMPTY_MAGIC;
+ uint32_t wdblks = jrec::size_blks(_cached_offset_dblks, JRNL_SBLK_SIZE) * JRNL_SBLK_SIZE;
while (_cached_offset_dblks < wdblks)
{
void* wptr = (void*)((char*)_page_ptr_arr[_pg_index] + _pg_offset_dblks * JRNL_DBLK_SIZE);
@@ -971,7 +961,7 @@ wmgr::dblk_roundup()
}
void
-wmgr::write_fhdr(u_int64_t rid, u_int16_t fid, u_int16_t lid, std::size_t fro)
+wmgr::write_fhdr(uint64_t rid, uint16_t fid, uint16_t lid, std::size_t fro)
{
file_hdr fhdr(RHM_JDAT_FILE_MAGIC, RHM_JDAT_VERSION, rid, fid, lid, fro, _wrfc.owi(), true);
std::memcpy(_fhdr_ptr_arr[fid], &fhdr, sizeof(fhdr));
@@ -1012,7 +1002,7 @@ wmgr::clean()
if (_fhdr_aio_cb_arr)
{
- for (u_int32_t i=0; i<_num_jfiles; i++)
+ for (uint32_t i=0; i<_num_jfiles; i++)
delete _fhdr_aio_cb_arr[i];
std::free(_fhdr_aio_cb_arr);
_fhdr_aio_cb_arr = 0;
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/wmgr.h b/qpid/cpp/src/qpid/linearstore/jrnl/wmgr.h
index 8347221b1d..39687226a5 100644
--- a/qpid/cpp/src/qpid/linearstore/jrnl/wmgr.h
+++ b/qpid/cpp/src/qpid/linearstore/jrnl/wmgr.h
@@ -19,17 +19,6 @@
*
*/
-/**
- * \file wmgr.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::wmgr (write manager). See
- * class documentation for details.
- *
- * \author Kim van der Riet
- */
-
#ifndef QPID_LEGACYSTORE_JRNL_WMGR_H
#define QPID_LEGACYSTORE_JRNL_WMGR_H
@@ -71,17 +60,17 @@ namespace journal
class wmgr : public pmgr
{
private:
- wrfc& _wrfc; ///< Ref to write rotating file controller
- u_int32_t _max_dtokpp; ///< Max data writes per page
- u_int32_t _max_io_wait_us; ///< Max wait in microseconds till submit
+// wrfc& _wrfc; ///< Ref to write rotating file controller
+ uint32_t _max_dtokpp; ///< Max data writes per page
+ uint32_t _max_io_wait_us; ///< Max wait in microseconds till submit
void* _fhdr_base_ptr; ///< Base pointer to file header memory
void** _fhdr_ptr_arr; ///< Array of pointers to file headers memory
aio_cb** _fhdr_aio_cb_arr; ///< Array of iocb pointers for file header writes
- u_int32_t _cached_offset_dblks; ///< Amount of unwritten data in page (dblocks)
+ uint32_t _cached_offset_dblks; ///< Amount of unwritten data in page (dblocks)
std::deque<data_tok*> _ddtokl; ///< Deferred dequeue data_tok list
- u_int32_t _jfsize_dblks; ///< Journal file size in dblks (NOT sblks!)
- u_int32_t _jfsize_pgs; ///< Journal file size in cache pages
- u_int16_t _num_jfiles; ///< Number of files used in iocb mallocs
+ uint32_t _jfsize_dblks; ///< Journal file size in dblks (NOT sblks!)
+ uint32_t _jfsize_pgs; ///< Journal file size in cache pages
+ uint16_t _num_jfiles; ///< Number of files used in iocb mallocs
// TODO: Convert _enq_busy etc into a proper threadsafe lock
// TODO: Convert to enum? Are these encodes mutually exclusive?
@@ -99,14 +88,14 @@ namespace journal
std::set<std::string> _txn_pending_set; ///< Set containing xids of pending commits/aborts
public:
- wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc);
- wmgr(jcntl* jc, enq_map& emap, txn_map& tmap, wrfc& wrfc, const u_int32_t max_dtokpp,
- const u_int32_t max_iowait_us);
+ wmgr(jcntl* jc, enq_map& emap, txn_map& tmap/*, wrfc& wrfc*/);
+ wmgr(jcntl* jc, enq_map& emap, txn_map& tmap/*, wrfc& wrfc*/, const uint32_t max_dtokpp,
+ const uint32_t max_iowait_us);
virtual ~wmgr();
- void initialize(aio_callback* const cbp, const u_int32_t wcache_pgsize_sblks,
- const u_int16_t wcache_num_pages, const u_int32_t max_dtokpp,
- const u_int32_t max_iowait_us, std::size_t eo = 0);
+ void initialize(aio_callback* const cbp, const uint32_t wcache_pgsize_sblks,
+ const uint16_t wcache_num_pages, const uint32_t max_dtokpp,
+ const uint32_t max_iowait_us, std::size_t eo = 0);
iores enqueue(const void* const data_buff, const std::size_t tot_data_len,
const std::size_t this_data_len, data_tok* dtokp, const void* const xid_ptr,
const std::size_t xid_len, const bool transient, const bool external);
@@ -118,25 +107,25 @@ namespace journal
int32_t get_events(page_state state, timespec* const timeout, bool flush = false);
bool is_txn_synced(const std::string& xid);
inline bool curr_pg_blocked() const { return _page_cb_arr[_pg_index]._state != UNUSED; }
- inline bool curr_file_blocked() const { return _wrfc.aio_cnt() > 0; }
- inline u_int32_t unflushed_dblks() { return _cached_offset_dblks; }
+// inline bool curr_file_blocked() const; { return _wrfc.aio_cnt() > 0; }
+ inline uint32_t unflushed_dblks() { return _cached_offset_dblks; }
// Debug aid
const std::string status_str() const;
private:
- void initialize(aio_callback* const cbp, const u_int32_t wcache_pgsize_sblks,
- const u_int16_t wcache_num_pages);
+ void initialize(aio_callback* const cbp, const uint32_t wcache_pgsize_sblks,
+ const uint16_t wcache_num_pages);
iores pre_write_check(const _op_type op, const data_tok* const dtokp,
const std::size_t xidsize = 0, const std::size_t dsize = 0, const bool external = false)
const;
- void dequeue_check(const std::string& xid, const u_int64_t drid);
- void file_header_check(const u_int64_t rid, const bool cont, const u_int32_t rec_dblks_rem);
+ void dequeue_check(const std::string& xid, const uint64_t drid);
+ void file_header_check(const uint64_t rid, const bool cont, const uint32_t rec_dblks_rem);
void flush_check(iores& res, bool& cont, bool& done);
iores write_flush();
iores rotate_file();
void dblk_roundup();
- void write_fhdr(u_int64_t rid, u_int16_t fid, u_int16_t lid, std::size_t fro);
+ void write_fhdr(uint64_t rid, uint16_t fid, uint16_t lid, std::size_t fro);
void rotate_page();
void clean();
};
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/wrfc.cpp b/qpid/cpp/src/qpid/linearstore/jrnl/wrfc.cpp
deleted file mode 100644
index 43461b66a3..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/wrfc.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file wrfc.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::wrfc (rotating
- * file controller). See comments in file wrfc.h for details.
- *
- * \author Kim van der Riet
- */
-
-#include "qpid/legacystore/jrnl/wrfc.h"
-
-#include <cmath>
-#include "qpid/legacystore/jrnl/jerrno.h"
-#include "qpid/legacystore/jrnl/jexception.h"
-
-namespace mrg
-{
-namespace journal
-{
-
-wrfc::wrfc(const lpmgr* lpmp):
- rfc(lpmp),
- _fsize_sblks(0),
- _fsize_dblks(0),
- _enq_cap_offs_dblks(0),
- _rid(0),
- _reset_ok(false),
- _owi(false),
- _frot(true)
-{}
-
-wrfc::~wrfc()
-{}
-
-void
-wrfc::initialize(const u_int32_t fsize_sblks, rcvdat* rdp)
-{
- if (rdp)
- {
- _fc_index = rdp->_lfid;
- _curr_fc = _lpmp->get_fcntlp(_fc_index);
- _curr_fc->wr_reset(rdp);
- _rid = rdp->_h_rid + 1;
- _reset_ok = true;
- _owi = rdp->_owi;
- _frot = rdp->_frot;
- if (rdp->_lffull)
- rotate();
- }
- else
- {
- rfc::initialize();
- rfc::set_findex(0);
- _rid = 0ULL;
- _reset_ok = false;
- }
- _fsize_sblks = fsize_sblks;
- _fsize_dblks = fsize_sblks * JRNL_SBLK_SIZE;
- _enq_cap_offs_dblks = (u_int32_t)std::ceil(_fsize_dblks * _lpmp->num_jfiles() * (100.0 - JRNL_ENQ_THRESHOLD) / 100);
- // Check the offset is at least one file; if not, make it so
- if (_enq_cap_offs_dblks < _fsize_dblks)
- _enq_cap_offs_dblks = _fsize_dblks;
-}
-
-iores wrfc::rotate()
-{
- if (!_lpmp->num_jfiles())
- throw jexception(jerrno::JERR__NINIT, "wrfc", "rotate");
- _fc_index++;
- if (_fc_index == _lpmp->num_jfiles())
- {
- _fc_index = 0;
- _owi = !_owi;
- _frot = false;
- }
- _curr_fc = _lpmp->get_fcntlp(_fc_index);
- if (_curr_fc->aio_cnt())
- return RHM_IORES_FILE_AIOWAIT;
- if (!wr_reset()) //Checks if file is still in use (ie not fully dequeued yet)
- return RHM_IORES_FULL;
- return RHM_IORES_SUCCESS;
-}
-
-u_int16_t wrfc::earliest_index() const
-{
- if (_frot)
- return 0;
- u_int16_t next_index = _fc_index + 1;
- if (next_index >= _lpmp->num_jfiles())
- next_index = 0;
- return next_index;
-}
-
-bool
-wrfc::enq_threshold(const u_int32_t enq_dsize_dblks) const
-{
- u_int32_t subm_dblks = subm_cnt_dblks(); // includes file hdr if > 0
- // This compensates for new files which don't have their file headers written yet,
- // as file header space cannot be included in this calculation.
- if (subm_dblks != 0)
- subm_dblks -= 4;
- u_int32_t fwd_dblks = subm_dblks + enq_dsize_dblks + _enq_cap_offs_dblks;
- u_int16_t findex = _fc_index;
- fcntl* fcp = _curr_fc;
- bool in_use = false;
- while (fwd_dblks && !(findex != _fc_index && fcp->enqcnt()))
- {
- fwd_dblks -= fwd_dblks > _fsize_dblks ? _fsize_dblks : fwd_dblks;
- if (fwd_dblks)
- {
- if (++findex == _lpmp->num_jfiles())
- findex = 0;
- fcp = _lpmp->get_fcntlp(findex);
- }
- in_use |= fcp->enqcnt() > 0;
- }
- // Return true if threshold exceeded
- return findex != _fc_index && in_use;
-}
-
-bool wrfc::wr_reset()
-{
- _reset_ok = _curr_fc->reset(); // returns false if full (ie file still contains enqueued recs)
- return _reset_ok;
-}
-
-// TODO: update this to reflect all status data
-std::string
-wrfc::status_str() const
-{
- std::ostringstream oss;
- oss << "wrfc: " << rfc::status_str();
- if (is_active())
- oss << " fcntl[" << _fc_index << "]: " << _curr_fc->status_str();
- return oss.str();
-}
-
-} // namespace journal
-} // namespace mrg
diff --git a/qpid/cpp/src/qpid/linearstore/jrnl/wrfc.h b/qpid/cpp/src/qpid/linearstore/jrnl/wrfc.h
deleted file mode 100644
index f0e4e73151..0000000000
--- a/qpid/cpp/src/qpid/linearstore/jrnl/wrfc.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/**
- * \file wrfc.h
- *
- * Qpid asynchronous store plugin library
- *
- * File containing code for class mrg::journal::wrfc (write rotating
- * file controller). See class documentation for details.
- *
- * \author Kim van der Riet
- */
-
-#ifndef QPID_LEGACYSTORE_JRNL_WRFC_H
-#define QPID_LEGACYSTORE_JRNL_WRFC_H
-
-namespace mrg
-{
-namespace journal
-{
-class wrfc;
-}
-}
-
-#include <cstddef>
-#include "qpid/legacystore/jrnl/enums.h"
-#include "qpid/legacystore/jrnl/rrfc.h"
-
-namespace mrg
-{
-namespace journal
-{
-
- /**
- * \class wrfc
- * \brief Class to handle write management of a journal rotating file controller.
- */
- class wrfc : public rfc
- {
- private:
- u_int32_t _fsize_sblks; ///< Size of journal files in sblks
- u_int32_t _fsize_dblks; ///< Size of journal files in dblks
- u_int32_t _enq_cap_offs_dblks; ///< Enqueue capacity offset
- u_int64_t _rid; ///< Master counter for record ID (rid)
- bool _reset_ok; ///< Flag set when reset succeeds
- bool _owi; ///< Overwrite indicator
- bool _frot; ///< Flag is true for first rotation, false otherwise
-
- public:
- wrfc(const lpmgr* lpmp);
- virtual ~wrfc();
-
- /**
- * \brief Initialize the controller.
- * \param fsize_sblks Size of each journal file in sblks.
- * \param rdp Struct carrying restore information. Optional for non-restore use, defaults to 0 (NULL).
- */
- using rfc::initialize;
- void initialize(const u_int32_t fsize_sblks, rcvdat* rdp = 0);
-
- /**
- * \brief Rotate active file controller to next file in rotating file group.
- * \exception jerrno::JERR__NINIT if called before calling initialize().
- */
- iores rotate();
-
- /**
- * \brief Returns the index of the earliest complete file within the rotating
- * file group. Unwritten files are excluded. The currently active file is
- * excluded unless it is the only written file.
- */
- u_int16_t earliest_index() const;
-
- /**
- * \brief Determines if a proposed write would cause the enqueue threshold to be exceeded.
- *
- * The following routine finds whether the next write will take the write pointer to beyond the
- * enqueue limit threshold. The following illustrates how this is achieved.
- * <pre>
- * Current file index: 4 +---+----------+
- * X's mark still-enqueued records |msg| 1-thresh |
- * msg = current msg size + unwritten cache +---+----------+
- * thresh = JRNL_ENQ_THRESHOLD as a fraction ^ V
- * +-------+-------+-------+-------+--+----+-------+-+-----+-------+
- * file num ->| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
- * enq recs ->| X XX |XX XXX |XX XXXX|XXXXXXX|XX | | | X |
- * +-------+-------+-------+-------+--+----+-------+-+-----+-------+
- * ^ ^ ^
- * subm_dblks --+ | |
- * These files must be free of enqueues
- * If not, return true.
- * </pre>
- * \param enq_dsize_dblks Proposed size of write in dblocks
- */
- bool enq_threshold(const u_int32_t enq_dsize_dblks) const;
-
- inline u_int64_t rid() const { return _rid; }
- inline u_int64_t get_incr_rid() { return _rid++; }
- bool wr_reset();
- inline bool is_wr_reset() const { return _reset_ok; }
- inline bool owi() const { return _owi; }
- inline bool frot() const { return _frot; }
-
- // Convenience access methods to current file controller
-
- inline int fh() const { return _curr_fc->wr_fh(); }
-
- inline u_int32_t subm_cnt_dblks() const { return _curr_fc->wr_subm_cnt_dblks(); }
- inline std::size_t subm_offs() const { return _curr_fc->wr_subm_offs(); }
- inline u_int32_t add_subm_cnt_dblks(u_int32_t a) { return _curr_fc->add_wr_subm_cnt_dblks(a); }
-
- inline u_int32_t cmpl_cnt_dblks() const { return _curr_fc->wr_cmpl_cnt_dblks(); }
- inline std::size_t cmpl_offs() const { return _curr_fc->wr_cmpl_offs(); }
- inline u_int32_t add_cmpl_cnt_dblks(u_int32_t a) { return _curr_fc->add_wr_cmpl_cnt_dblks(a); }
-
- inline u_int16_t aio_cnt() const { return _curr_fc->aio_cnt(); }
- inline u_int16_t incr_aio_cnt() { return _curr_fc->incr_aio_cnt(); }
- inline u_int16_t decr_aio_cnt() { return _curr_fc->decr_aio_cnt(); }
-
- inline bool is_void() const { return _curr_fc->wr_void(); }
- inline bool is_empty() const { return _curr_fc->wr_empty(); }
- inline u_int32_t remaining_dblks() const { return _curr_fc->wr_remaining_dblks(); }
- inline bool is_full() const { return _curr_fc->is_wr_full(); };
- inline bool is_compl() const { return _curr_fc->is_wr_compl(); };
- inline u_int32_t aio_outstanding_dblks() const { return _curr_fc->wr_aio_outstanding_dblks(); }
- inline bool file_rotate() const { return _curr_fc->wr_file_rotate(); }
-
- // Debug aid
- std::string status_str() const;
- };
-
-} // namespace journal
-} // namespace mrg
-
-#endif // ifndef QPID_LEGACYSTORE_JRNL_WRFC_H
diff --git a/qpid/tools/src/py/linearstore/efptool.py b/qpid/tools/src/py/linearstore/efptool.py
new file mode 100755
index 0000000000..291a70d34f
--- /dev/null
+++ b/qpid/tools/src/py/linearstore/efptool.py
@@ -0,0 +1,417 @@
+#!/usr/bin/env python
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+"""
+
+import argparse
+import os
+from shutil import rmtree
+from struct import pack
+from uuid import uuid4
+
+# Some "constants"
+DEFAULT_SBLK_SIZE = 4096 # 32 dblks
+DEFAULT_SBLK_SIZE_KB = DEFAULT_SBLK_SIZE / 1024
+DEFAULT_EFP_DIR_NAME = 'efp'
+DEFAULT_JRNL_EXTENTION = '.jrnl'
+
+def get_directory_size(directory_name):
+ ''' Decode the directory name in the format NNNk to a numeric size, where NNN is a number string '''
+ try:
+ if directory_name[-1] == 'k':
+ return int(directory_name[:-1])
+ except ValueError:
+ pass
+ return 0
+
+
+class EfpToolError(StandardError):
+ ''' Parent class for all errors used by efptool '''
+ pass
+
+class InvalidPartitionDirectoryError(EfpToolError):
+ ''' Error class for invalid partition directory '''
+ pass
+
+
+class Header:
+ ''' Abstract class for encoding the initial part of the header struct which is common across all journal headers '''
+ FORMAT = '=4sBBHQ'
+ HDR_VER = 2
+ def __init__(self, magic, hdr_ver, flags, rid):
+ self.magic = magic
+ self.hdr_ver = hdr_ver
+ self.flags = flags
+ self.rid = long(rid)
+ def is_empty(self):
+ ''' Returns TRUE if the header is empty (invalid), tested by looking for a null (all-zero) magic '''
+ return self.magic == r'\0'*4
+ def encode(self):
+ ''' Encode the members of this struct to a binary string for writing to disk '''
+ return pack(Header.FORMAT, self.magic, self.hdr_ver, 0xff, self.flags, self.rid)
+
+
+class FileHeader(Header):
+ ''' Class for encoding journal file headers to disk '''
+ FORMAT = '=3Q2L2QH'
+ def __init__(self, magic, hdr_ver, flags, rid, fro, ts_sec, ts_ns, file_cnt, file_size, file_number, file_name):
+ Header.__init__(self, magic, hdr_ver, flags, rid)
+ self.fro = fro
+ self.ts_sec = ts_sec
+ self.ts_ns = ts_ns
+ self.file_cnt = file_cnt
+ self.file_size = file_size
+ self.file_number = file_number
+ self.file_name = file_name
+ def encode(self):
+ ''' Encode the members of this struct to a binary string for writing to disk '''
+ return Header.encode(self) + pack(FileHeader.FORMAT, self.fro, self.ts_sec, self.ts_ns, self.file_cnt,
+ 0xffffffff, self.file_size, self.file_number,
+ len(self.file_name)) + self.file_name
+
+
+class EfpArgParser(argparse.ArgumentParser):
+ ''' Empty file pool argument parser '''
+ def __init__(self):
+ ''' Constructor '''
+ argparse.ArgumentParser.__init__(self,
+ description='Qpid linear store Empty File Pool (EFP) maintenance tool. '
+ 'Used to view, create, remove and set the sizes and numbers of '
+ 'files in the EFP.',
+ prog='efptool',
+ epilog='NOTE: Pool directories under the efp directory are named as the file '
+ 'size it contains in kb, and followed by the letter \'k\'. (eg a pool '
+ 'containing 160 kb files is named \'160k\'.)')
+ self.add_argument('store_directory', metavar='STORE-DIR',
+ help='Use store directory DIR to create pool (required)')
+ self.add_argument('-a', '--add', action='store_true',
+ help='Add new pool of NF files sized FS in partition PN. Must be used with --partition, '
+ '--size and --num-files')
+ self.add_argument('-r', '--remove', action='store_true',
+ help='Remove existing pool of file sized FS in partition PN. Must be used with --partition '
+ 'and --size')
+ self.add_argument('-f', '--freshen', action='store_true',
+ help='Freshen the file pool of files sized FS in partition PN to NF files. If --partition is '
+ 'used, then in partition PN, otherwise all partitions. If --file-size is used, then for '
+ 'pools of file size FS, otherwise for all pools. Must be used with --num-files')
+ self.add_argument('-l', '--list', action='store_true',
+ help='List the store pools and partitions in store directory STORE-DIR')
+ self.add_argument('-p', '--partition', metavar='PN',
+ help='Name of partition in which pool add, delete or freshen action is to be performed')
+ self.add_argument('-s', '--file-size', metavar='FS',
+ help='Add pool containing file size FS KiB (1024 bytes), must be a multiple of 4 KiB')
+ self.add_argument('-n', '--num-files', metavar='NF',
+ help='Set the number of files for the add or freshen action to NF')
+ self.add_argument('-v', '--version', action='version', version='%(prog)s 0.8')
+ @staticmethod
+ def validate_args(args):
+ ''' Static validation function which checks that required dependent args are present as well as no mutually
+ exclusive args'''
+ valid = True
+ if not os.path.exists(args.store_directory):
+ valid = False
+ print 'ERROR: directory', args.store_directory, 'does not exist'
+ if args.add:
+ if args.partition is None:
+ valid = False
+ print 'ERROR: Must use --partition/-p with --add/-a'
+ if args.file_size is None:
+ valid = False
+ print 'ERROR: Must use --file-size/-s with --add/-a'
+ if args.num_files is None:
+ valid = False
+ print 'ERROR: Must use --num-files/-n with --add/-a'
+ if args.remove:
+ if args.partition is None:
+ valid = False
+ print 'ERROR: Must use --partition/-p with --remove/-r'
+ if args.file_size is None:
+ valid = False
+ print 'ERROR: Must use --file-size/-s with --remove/-r'
+ if args.freshen:
+ if args.num_files is None:
+ valid = False
+ print 'ERROR: Must use --num-files/-n with --freshen/-f'
+ if args.add and args.remove:
+ valid = False
+ print 'ERROR: Cannot use --add/-a and --remove/-r together'
+ if args.add and args.freshen:
+ valid = False
+ print 'ERROR: Cannot use --add/-a and --freshen/-f together'
+ if args.remove and args.freshen:
+ valid = False
+ print 'ERROR: Cannot use --remove/-r and --freshen/-f together'
+ if not args.file_size is None:
+ try:
+ if int(args.file_size) % DEFAULT_SBLK_SIZE_KB != 0:
+ valid = False
+ print 'ERROR: --size/-s: %s is not a multiple of %d' % (args.file_size, DEFAULT_SBLK_SIZE_KB)
+ except ValueError:
+ print 'ERROR: --size/-s: \'%s\' not an integer' % args.file_size
+ valid = False
+ return valid
+
+
+class EmptyFilePool:
+ ''' Class for managing a directory containing empty journal files, known as an empty file pool '''
+ def __init__(self, partition, file_size_kb):
+ self.partition = partition
+ self.file_size_kb = file_size_kb
+ self.size_str = EmptyFilePool.get_dir_name(file_size_kb)
+ self.directory = os.path.join(partition.efp_directory, self.size_str)
+ self.empty_file_names = []
+ self.cum_file_size = 0
+ if not os.path.exists(self.directory):
+ os.mkdir(self.directory)
+ def __str__(self):
+ return 'Pool %s (size: %dk) at %s containing %d files with total size %d' % (self.size_str,
+ self.file_size_kb, self.partition.efp_directory, len(self.empty_file_names), self.cum_file_size)
+ def get_num_files(self):
+ ''' Return the number of empty files currently in this EFP '''
+ return len(self.empty_file_names)
+ def validate_efp_file(self, empty_file_name):
+ ''' Checks that the file name (which is related to the file size it contains) is a valid multiple of 4kb '''
+ file_size = os.path.getsize(empty_file_name)
+ expected_file_size = (self.file_size_kb * 1024) + DEFAULT_SBLK_SIZE
+ if file_size != expected_file_size:
+ print 'WARNING: File %s not of correct size (size=%d, expected=%d): Ignoring' % (empty_file_name, file_size,
+ expected_file_size)
+ return False
+ return True
+ # TODO - read and decode header, verify validity
+ def read(self):
+ ''' Read the directory and parse all empty files found there '''
+ for dir_entry in os.listdir(self.directory):
+ fpn = os.path.join(self.directory, dir_entry)
+ if self.validate_efp_file(fpn):
+ self.add_efp_file(fpn)
+ #print 'Found', os.path.join(self.directory, dir_entry), 'of size', os.path.getsize(fpn)
+ def create_new_efp_files(self, num_files):
+ ''' Create one or more new empty journal files of the prescribed size for this EFP '''
+ cum_file_size = 0
+ for _ in range(num_files):
+ cum_file_size += self.create_new_efp_file()
+ return cum_file_size
+ def create_new_efp_file(self):
+ ''' Create a single new empty journal file of the prescribed size for this EFP '''
+ file_name = str(uuid4()) + DEFAULT_JRNL_EXTENTION
+ file_header = FileHeader(r'\0\0\0\0', 0, 0, 0, 0, 0, 0, 0, self.file_size_kb, 0, file_name)
+ efh = file_header.encode()
+ efh_bytes = len(efh)
+ f = open(os.path.join(self.directory, file_name), 'wb')
+ f.write(efh)
+ f.write('\xff' * (DEFAULT_SBLK_SIZE - efh_bytes))
+ f.write('\x00' * (int(self.file_size_kb) * 1024))
+ f.close()
+ fqfn = os.path.join(self.directory, file_name)
+ self.add_efp_file(fqfn)
+ return os.path.getsize(fqfn)
+ def add_efp_file(self, efp_file_name):
+ ''' Add a single journal file of the appropriate size to this EFP. No file size check is made here. '''
+ self.empty_file_names.append(efp_file_name)
+ self.cum_file_size += os.path.getsize(efp_file_name)
+ @staticmethod
+ def get_dir_name(file_size_kb):
+ ''' Static function to create an EFP directory name from the size of the files it contains '''
+ return '%dk' % file_size_kb
+
+
+class Partition:
+ ''' Class representing a partition, which may contain one or more EFP directories directly under it '''
+ def __init__(self, root_path, partition_num, efp_directory_name):
+ self.root_path = root_path
+ self.efp_directory = os.path.join(root_path, efp_directory_name)
+ self.partition_num = partition_num
+ self.pools = {}
+ self.num_files = 0
+ self.cum_file_size = 0
+ self.validate_efp_directory()
+ def __lt__(self, other):
+ return self.partition_num < other.partition_num
+ def __str__(self):
+ s = ' Partition %d at %s:\n' % (self.partition_num, self.root_path)
+ if len(self.pools) > 0:
+ for pn in self.pools.iterkeys():
+ s += ' %s containing %d files\n' % (pn, self.pools[pn].get_num_files())
+ s += ' [%d files with cumulative size %d]\n' % (self.num_files, self.cum_file_size)
+ else:
+ s += ' <empty partition>\n'
+ return s
+ def validate_efp_directory(self):
+ ''' Check that the partition directory is valid '''
+ # TODO: Add checks for permissions to write and sufficient space
+ if not os.path.exists(self.efp_directory) or not os.path.isdir(self.efp_directory):
+ raise InvalidPartitionDirectoryError
+ def read(self):
+ ''' Read the partition, identifying EFP directories. Read each EFP directory found. '''
+ for dir_entry in os.listdir(self.efp_directory):
+ size_kb = get_directory_size(dir_entry)
+ if size_kb > 0 and size_kb % DEFAULT_SBLK_SIZE_KB == 0:
+ efp = EmptyFilePool(self, size_kb)
+ efp.read()
+ self.num_files += efp.get_num_files()
+ self.cum_file_size += efp.cum_file_size
+ self.pools[dir_entry] = efp
+ def create_new_efp_files(self, file_size_kb, num_files):
+ ''' Create new EFP files in this partition '''
+ dir_name = EmptyFilePool.get_dir_name(file_size_kb)
+ if dir_name in self.pools.keys():
+ efp = self.pools[dir_name]
+ else:
+ efp = EmptyFilePool(self, file_size_kb)
+ cum_file_size = efp.create_new_efp_files(num_files)
+ self.cum_file_size += cum_file_size
+ self.num_files += num_files
+ return cum_file_size
+
+
+class EmptyFilePoolManager:
+ ''' High level class for managing partitions and the empty file pools they contian '''
+ def __init__(self, args_):
+ self.args = args_
+ self.store_directory = os.path.abspath(args_.store_directory)
+ self.partitions = []
+ self.pools = {}
+ self.total_num_files = 0
+ self.total_cum_file_size = 0
+ self.current_partition = None
+ print 'Reading store directory', self.store_directory
+ for dir_entry in os.listdir(self.store_directory):
+ if len(dir_entry) == 4 and dir_entry[0] == 'p':
+ pn = int(dir_entry[1:])
+ try:
+ self.partitions.append(Partition(os.path.join(self.store_directory, dir_entry), pn,
+ DEFAULT_EFP_DIR_NAME))
+ except InvalidPartitionDirectoryError:
+ pass
+ for p in self.partitions:
+ p.read()
+ for efpl in p.pools.iterkeys():
+ if efpl not in self.pools:
+ self.pools[efpl] = []
+ self.pools[efpl].append(p.pools[efpl])
+ self.total_num_files += p.num_files
+ self.total_cum_file_size += p.cum_file_size
+ def __str__(self):
+ s = '\nPartitions (%d):\n' % len(self.partitions)
+ for p in sorted(self.partitions):
+ s += str(p)
+ s += '\nPools (%d):\n' % len(self.pools)
+ for lk in self.pools.iterkeys():
+ l = self.pools[lk]
+ s += ' %s size=%d (%d):\n' % (lk, get_directory_size(lk), len(l))
+ for efp in l:
+ s += ' in partition %d (%s) containing %d files\n' % (efp.partition.partition_num,
+ efp.partition.efp_directory,
+ efp.get_num_files())
+ s += '\nTotal files: %d\nTotal cumulative file size: %d' % (self.total_num_files, self.total_cum_file_size)
+ return s
+ def check_args(self):
+ ''' Value check of args. The names of partitions and pools are validated against the discovered instances '''
+ valid = True
+ self.current_partition = None
+ if not self.args.partition is None:
+ try:
+ if self.args.partition[0] == 'p': # string partition name, eg 'p001'
+ pn = int(self.args.partition[1:])
+ else: # numeric partition, eg '1'
+ pn = int(self.args.partition)
+ found = False
+ for p in self.partitions:
+ if p.partition_num == pn:
+ self.current_partition = p
+ found = True
+ break
+ if not found:
+ print 'ERROR: --partition/-p: Partition %s does not exist' % self.args.partition
+ valid = False
+ except ValueError:
+ print 'ERROR: --partition/-p: Partition %s does not exist' % self.args.partition
+ valid = False
+ if not self.current_partition is None:
+ if self.args.add:
+ if EmptyFilePool.get_dir_name(int(self.args.file_size)) in self.current_partition.pools.keys():
+ n = EmptyFilePool.get_dir_name(int(self.args.file_size))
+ print 'ERROR: --add/-a: Pool directory %s already exists' % n
+ valid = False
+ if self.args.remove:
+ if not EmptyFilePool.get_dir_name(int(self.args.file_size)) in self.current_partition.pools.keys():
+ fs = int(self.args.file_size)
+ print 'ERROR: --remove/-r: Pool %s does not exist' % EmptyFilePool.get_dir_name(fs)
+ valid = False
+ return valid
+ def run(self):
+ ''' Run the command-line args. Entry point for this class '''
+ if self.check_args():
+ if self.args.add:
+ self.add_file_pool(self.current_partition, int(self.args.file_size), int(self.args.num_files))
+ if self.args.remove:
+ self.remove_file_pool(self.current_partition, int(self.args.file_size))
+ if self.args.freshen:
+ self.freshen_file_pool(self.current_partition, self.args.file_size, int(self.args.num_files))
+ if self.args.list:
+ print self
+ def add_file_pool(self, partition, file_size_kb, num_files):
+ ''' Add an EFP in the specified partition of the specified size containing the specified number of files '''
+ dir_name = EmptyFilePool.get_dir_name(file_size_kb)
+ print 'Adding pool \'%s\' to partition %s' % (dir_name, partition.partition_num)
+ self.total_cum_file_size += partition.create_new_efp_files(file_size_kb, num_files)
+ self.total_num_files += num_files
+ def remove_file_pool(self, partition, file_size_kb):
+ ''' Remove an existing EFP from the specified partition and of the specified size '''
+ dir_name = EmptyFilePool.get_dir_name(file_size_kb)
+ print 'Removing pool \'%s\' from partition %s' % (dir_name, partition.partition_num)
+ self.partitions.remove(partition)
+ rmtree(os.path.join(partition.efp_directory, dir_name))
+ def freshen_file_pool(self, partition, file_size_kb_arg, num_files):
+ ''' Freshen an EFP in the specified partition and of the specified size to the specified number of files '''
+ if partition is None:
+ pl = self.partitions
+ a1 = 'all partitions'
+ else:
+ pl = [partition]
+ a1 = 'partition %d' % partition.partition_num
+ if file_size_kb_arg is None:
+ a2 = 'all pools'
+ else:
+ a2 = 'pool \'%s\'' % EmptyFilePool.get_dir_name(int(file_size_kb_arg))
+ print 'Freshening %s in %s to %d files' % (a2, a1, num_files)
+ for p in pl: # Partition objects
+ if file_size_kb_arg is None:
+ fsl = p.pools.keys()
+ else:
+ fsl = ['%sk' % file_size_kb_arg]
+ for fs in fsl:
+ efp = p.pools[fs]
+ num_files_needed = num_files - efp.get_num_files()
+ if num_files_needed > 0:
+ p.create_new_efp_files(get_directory_size(fs), num_files_needed)
+ else:
+ t = (p.pools[fs].size_str, p.partition_num, efp.get_num_files())
+ print ' WARNING: Pool %s in partition %s already contains %d files: no action taken' % t
+
+
+
+# --- main entry point ---
+
+ARGS = EfpArgParser().parse_args()
+if (EfpArgParser.validate_args(ARGS)):
+ EFP = EmptyFilePoolManager(ARGS)
+ EFP.run()
+