diff options
| author | Kim van der Riet <kpvdr@apache.org> | 2013-09-20 18:59:30 +0000 |
|---|---|---|
| committer | Kim van der Riet <kpvdr@apache.org> | 2013-09-20 18:59:30 +0000 |
| commit | c70bf3ea28cdf6bafd8571690d3e5c466a0658a2 (patch) | |
| tree | 68b24940e433f3f9c278b054d9ea1622389bd332 /qpid/cpp | |
| parent | fcdf1723c7b5cdf0772054a93edb6e7d97c4bb1e (diff) | |
| download | qpid-python-c70bf3ea28cdf6bafd8571690d3e5c466a0658a2.tar.gz | |
QPID-4984: WIP - Merge from trunk r.1525056
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/linearstore@1525101 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
577 files changed, 7412 insertions, 43773 deletions
diff --git a/qpid/cpp/BuildInstallSettings.cmake b/qpid/cpp/BuildInstallSettings.cmake index 6b8a3afa6c..6bda220d2b 100644 --- a/qpid/cpp/BuildInstallSettings.cmake +++ b/qpid/cpp/BuildInstallSettings.cmake @@ -93,7 +93,7 @@ if (WIN32) "Directory to install SASL configuration files") set (QPID_INSTALL_DATADIR conf CACHE STRING "Directory to install read-only arch.-independent data root") - set (QPID_INSTALL_EXAMPLESDIR qpid/examples CACHE STRING + set (QPID_INSTALL_EXAMPLESDIR examples CACHE STRING "Directory to install programming examples in") set (QPID_INSTALL_DOCDIR docs CACHE STRING "Directory to install documentation") diff --git a/qpid/cpp/CMakeLists.txt b/qpid/cpp/CMakeLists.txt index 97693b6fe1..ac92e4916e 100644 --- a/qpid/cpp/CMakeLists.txt +++ b/qpid/cpp/CMakeLists.txt @@ -64,8 +64,7 @@ set_absolute_install_path (QPIDC_CONF_FILE ${QPID_INSTALL_CONFDIR}/qpidc.conf) set_absolute_install_path (QPIDD_CONF_FILE ${QPID_INSTALL_CONFDIR}/qpidd.conf) install(FILES LICENSE NOTICE DESTINATION ${QPID_INSTALL_DOCDIR}) -install(FILES include/qmf/qmfengine.i - include/qmf/qmf2.i +install(FILES include/qmf/qmf2.i DESTINATION ${QPID_INSTALL_INCLUDEDIR}/qmf) if (WIN32) diff --git a/qpid/cpp/INSTALL b/qpid/cpp/INSTALL index 8e05026d3e..e65a8654dd 100644 --- a/qpid/cpp/INSTALL +++ b/qpid/cpp/INSTALL @@ -150,10 +150,13 @@ all of the above plus: * doxygen <ftp://ftp.stack.nl/pub/users/dimitri/> (1.5.1) * graphviz <http://www.graphviz.org/> (2.12) * ruby 1.8 <http://www.ruby-lang.org> (1.8.4) - + * python 2.x <http://www.python.org> (2.4.3) NOTE: make sure to install the related '-devel' packages also!!!! +NOTE: Python 3.x is know to NOT work - please use 2.7 or earlier. +Ruby should be prior to version 2. + To build the QMF (Qpid Management Framework) bindings for Ruby and Python, the following must also be installed: diff --git a/qpid/cpp/INSTALL-AUTOTOOLS b/qpid/cpp/INSTALL-AUTOTOOLS deleted file mode 100644 index 8a35d7bedc..0000000000 --- a/qpid/cpp/INSTALL-AUTOTOOLS +++ /dev/null @@ -1,281 +0,0 @@ - - - ============================== DEPRECATED ============================== - - This file describes how to use the autotools build system to build Qpid. - The autotools build system is *deprecated* and will be removed in a - future release. Use the cmake build system instead as described in the - INSTALL file. - - You can continue using the autoconf build system until you switch to - cmake. Run configure with --enable-deprecated=yes to enable it. - - ======================================================================== - - Installing Qpid/C++ - =================== - -Table of Contents -================= -1. Introduction - -2. Prerequisites - 2.1. What to Install - 2.2. How to Install - 2.2.1. Using Package Management Tools - 2.2.2. From Source - 2.2.2.1. boost - 2.2.2.2. autotools - 2.3. Important Environment Variable Settings - -3. Building from a Source Distribution -4. Building a Repository Working Copy -5. Tests - - -1. Introduction -=============== -Note that the daemon and client API can be installed separately. - -This document describes how to build the Qpid/C++ broker and client, either -from a checkout of the source or from a source distribution, on Linux/UNIX. -Please see INSTALL-WINDOWS for information on building on Windows. - -This also explains how to install the required prerequisites for Qpid/C++. - - -2. Prerequisites -================ -We prefer to avoid spending time accommodating older versions of these -packages, so please make sure that you have the latest stable versions. -Known version numbers for a succesfull build are given in brackets, take -these as a recommended minimum version. - - -2.1. What to Install -==================== -The following libraries and header files must be installed to build -a source distribution: - * boost <http://www.boost.org> (1.35)(*) - * libuuid <http://kernel.org/~kzak/util-linux/> (2.19) - * pkgconfig <http://pkgconfig.freedesktop.org/wiki/> (0.21) - -(*) earlier versions of boost e.g. 1.33 also work and there is a patch -to get 1.32 working in the svn tree though that is only recommended as -a last resort. - -Optional XML exchange requires: - * xqilla <http://xqilla.sourceforge.net/HomePage> (2.0.0) - * xerces-c <http://xerces.apache.org/xerces-c/> (2.7.0) - -Optional SSL support requires: -* nss <http://www.mozilla.org/projects/security/pki/nss/> -* nspr <http://www.mozilla.org/projects/nspr/> - -Optional binding support for ruby requires: -* ruby and ruby devel <http://www.ruby-lang.org/en/> -* swig <http://www.swig.org/> - -Qpid has been built using the GNU C++ compiler: - * gcc <http://gcc.gnu.org/> (3.4.6) - -If you want to build directly from the SVN repository you will need -all of the above plus: - - * GNU make <http://www.gnu.org/software/make/> (3.8.0) - * autoconf <http://www.gnu.org/software/autoconf/> (2.61) - * automake <http://www.gnu.org/software/automake/> (1.9.6) - * help2man <http://www.gnu.org/software/help2man/> (1.36.4) - * libtool <http://www.gnu.org/software/libtool/> (1.5.22) - * doxygen <ftp://ftp.stack.nl/pub/users/dimitri/> (1.5.1) - * graphviz <http://www.graphviz.org/> (2.12) - * ruby 1.8 <http://www.ruby-lang.org> (1.8.4) - - -NOTE: make sure to install the related '-devel' packages also! - -To build the QMF (Qpid Management Framework) bindings for Ruby and Python, -the following must also be installed: - - * ruby-devel - * python-devel - * swig <http://www.swig.org> (1.3.35) - -UUID problems: -In some earlier Linux releases (such as Fedora 11), the uuid/uuid.h -file is located in the e2fsprogs-devel package instead of -libuuid-devel. If you are using an older Linux release and run into a -problem during configure in which uuid.h cannot be found, install the -e2fsprogs-devel package. - -2.2. How to Install -=================== - -2.2.1. Using Package Management Tools -===================================== - -On linux most packages can be installed using your distribution's -package management tool. For example on Fedora: - - # yum install boost-devel libuuid-devel pkgconfig gcc-c++ make autoconf automake ruby libtool help2man doxygen graphviz - -For SASL and SSL, include - # yum install cyrus-sasl-devel nss-devel nspr-devel - -For the XML Exchange, include: - - # yum install xqilla-devel xerces-c-devel - -Optional ruby binding support include: - # yum install ruby ruby-devel swig - -Optional legacystore store module. -# yum install libdb-cxx-devel libaio-devel - -Follow the manual installation instruction below for any packages not -available through your distributions packaging tool. - -2.2.2. From Source -================== -Required dependencies can be installed and built from source distributions. -It is recommended that you create a directory to install them to, for example, -~/qpid-tools. - - To build and install the dependency pakcages: - - 1. Unzip and untar them and cd to the untared directory. - 2. do: - # ./configure --prefix=~/qpid-tools - # make install - -The exception is boost. - -2.2.2.1. boost -============== - 1. Unpack boost-jam. - 2. Add bjam in the unpacked directory to your path. - 3. Unpack boost and cd to the boost untarred directory. - 4. do: - - # bjam toolset=gcc variant=release threading=single link=shared \ - --layout=system --prefix=~/qpid-tools install - -2.2.2.2. autotools -================== -If you don't have sufficiently up-to-date autotools you can get the -latest by running the script qpid-autotools-install. - -1. Decide where you would like to install the tools. It should be in a - local directory so that you do not need root privileges. (Suggest - $HOME/qpid-tools.) Create an empty directory. -2. Modify your environment variable PATH to ensure that the bin directory - within this directory comes first in the PATH string: - PATH=$HOME/qpid-tools/bin:$PATH -3. Set PKG_CONFIG_PATH=$HOME/qpid-tools/lib/pkgconfig:/usr/lib/pkgconfig - (or if it already exists, make sure that the above path to your - qpid-tools directory is first). -4. Run the install utility from the cpp directory: - ./qpid-autotools-install --prefix=$HOME/qpid-tools --skip-check - (Note that --prefix will only accept an absolute path, so don't use - ~/qpid-tools.) The utility will download, compile and install the - required tools into the qpid-tools directory (this may take a little - time). Watch for any notices about paths at the end of the install - - this means that your environment is not correct - see steps 2 and 3 - above. - NOTE: If you omit the --skip-check option, the check of the build - can add up to an hour to what is normally a few minutes of install - time. -5. Perform a check: from the command-line run "which automake" and - ensure that it finds the automake in your qpid-tools directory. If not, - check that the build completed normally and your environment. -6. (Optional) If having the build artifacts lying around bothers you, delete - the (hidden) build directory cpp/.build-auto-tools. - -To see help, run ./qpid-autotools-install --help. - - -2.3. Important Environment Variable Settings -============================================ -Ensure that all the build tools are available on your path, when they are -manually installed to non-standard locations. For example: - - # export PATH=~/qpid-tools/bin:$PATH - -Ensure that pkg-config is set up correctly. For example: - - # export PKG_CONFIG_PATH=~/qpid-tools/lib/pkgconfig:/usr/local/pkgconfig - # export PKG_CONFIG=~/qpid-tools/bin/pkg-config - -Ensure that the boost libraries are made available on the gcc library path. -For example: - - # export CXXFLAGS=-I~/qpid-tools/include/boost-1_33_1 - - -3. Building from a Source Distribution -====================================== -In the distribution directory - -Build and install with: - - # ./configure --prefix=<install_location> - # make all - # make install - -To build and test everything: - - # make - # make check - -This builds in the source tree. You can have multiple builds in the -same working copy with different configuration. For example you can do -the following to build twice, once for debug, the other with -optimization: - - # make distclean - # mkdir .build-dbg .build-opt - # (cd .build-opt ../configure --prefix=/tmp/x && make && make check) - # (cd .build-dbg ../configure CXXFLAGS=-g --prefix=/tmp/x \ - && make && make check) - - -4. Building a Repository Working Copy -===================================== -To get the source code from the subversion repository (trunk) do: - - # svn checkout http://svn.apache.org/repos/asf/qpid/trunk/qpid/. - -To build a fresh checkout: - -Cd to qpid/cpp subdirectory. Before running make on a fresh checkout do: - - # ./bootstrap - -This generates config, makefiles and the like - check the script for -details. You only need to do this once, "make" will keep everything up -to date thereafter (including re-generating configuration & Makefiles -if the automake templates change etc.) - -If you are developing code yourself, or if you want to help -us keep the code as tight and robust as possible, consider enabling -the use of valgrind. If you configure like this: - - # ./configure --enable-valgrind - -That will arrange (assuming you have valgrind installed) for "make check" -to run tests via valgrind. That makes the tests run more slowly, but -helps detect certain types of bugs, as well as memory leaks. If you run -"make check" and valgrind detects a leak that is not listed as being -"ignorable-for-now", the test script in question will fail. However, -recording whether a leak is ignorable is not easy, when the stack -signature, libraries, compiler, O/S, architecture, etc., may all vary, -so if you see a new leak, try to figure out if it's one you can fix -before adding it to the list. - -Now follow instruction for building from a source distribution in step (3). - - -5. Tests -======== -See src/tests/README.txt for details. - diff --git a/qpid/cpp/INSTALL-WINDOWS b/qpid/cpp/INSTALL-WINDOWS index 75fa69079e..c3578a3dba 100644 --- a/qpid/cpp/INSTALL-WINDOWS +++ b/qpid/cpp/INSTALL-WINDOWS @@ -41,9 +41,7 @@ Take these as a recommended minimum version. The following libraries and header files must be installed to build
from either a source checkout or a source distribution:
- * boost <http://www.boost.org> (1.35)(*)
-
-earlier versions of boost e.g. 1.33 also work
+ * boost <http://www.boost.org> (1.35)
To build from a source repository (SVN) checkout you will need boost plus:
@@ -51,6 +49,9 @@ To build from a source repository (SVN) checkout you will need boost plus: * python <http://www.python.org> (2.5.2)
* ruby <http://www.ruby-lang.org> (1.8.4)
+NOTE: Python 3.x is known to NOT work - please use 2.7 or earlier.
+Ruby should be prior to version 2.
+
Regardless of which type of build you perform, if you wish to run the full
test suite, you will need to have python, listed above, installed.
diff --git a/qpid/cpp/Makefile.am b/qpid/cpp/Makefile.am deleted file mode 100644 index c9c316cd92..0000000000 --- a/qpid/cpp/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS=libTest include exampleProgram diff --git a/qpid/cpp/README-HA.txt b/qpid/cpp/README-HA.txt index ae9bec5182..4e95ea1041 100644 --- a/qpid/cpp/README-HA.txt +++ b/qpid/cpp/README-HA.txt @@ -136,4 +136,4 @@ The queue state replication mechanism implemented by the modules `replicating_li [ha-virtual-ip]: http://qpid.apache.org/books/0.22/AMQP-Messaging-Broker-CPP-Book/html/chapter-ha.html#ha-virtual-ip [ha-replicate-values]: http://qpid.apache.org/books/0.22/AMQP-Messaging-Broker-CPP-Book/html/chapter-ha.html#ha-replicate-values [ha-rm-config]: http://qpid.apache.org/books/0.22/AMQP-Messaging-Broker-CPP-Book/html/chapter-ha.html#ha-rm-config -[ha-queue-replication]: http://qpid.apache.org/books/0.22/AMQP-Messaging-Broker-CPP-Book/html/chapter-ha.html#ha-queue-replication +[ha-queue-replication]: http://qpid.apache.org/releases/qpid-0.22/cpp-broker/book/ha-queue-replication.html diff --git a/qpid/cpp/README-winsdk.txt b/qpid/cpp/README-winsdk.txt index 7bcd21687a..3e4899f8e6 100644 --- a/qpid/cpp/README-winsdk.txt +++ b/qpid/cpp/README-winsdk.txt @@ -82,7 +82,7 @@ The kit directories hold the content described here. A python scripting code set for generating QMF data structures.
For more information on Qpid QMF go to:
- https://cwiki.apache.org/qpid/qpid-management-framework.html
+ http://qpid.apache.org/components/qmf/index.html
The architectural relationships of the components in this SDK are
illustrated here.
diff --git a/qpid/cpp/SSL b/qpid/cpp/SSL index b810d4ef10..06aa0db267 100644 --- a/qpid/cpp/SSL +++ b/qpid/cpp/SSL @@ -7,15 +7,11 @@ on Windows. Linux ===== -SSL support for Qpid-C++, based on Mozilla's Network Security Services -library, is provided as two loadable modules: one for the client -(sslconnector.so), one for the broker (ssl.so). Either these libraries -should be present in the relevant module directory or the -'load-module' option (or QPID_LOAD_MODULE environment variable) is -used to ensure they are loaded. +SSL support for Qpid-C++ is based on Mozilla's Network Security Services +library. SSL support will be built automatically providing this library +and include files are found at build time. -Broker side SSL Settings (note you can get these by qpidd --help -providing the ssl.so module is loaded): +Broker side SSL Settings (note you can get these by qpidd --help) SSL Settings: --ssl-use-export-policy Use NSS export policy @@ -57,14 +53,13 @@ for accessing the created db. The daemon can then be started with something like the following: -./src/qpidd --auth no --load-module src/.libs/ssl.so \ +./src/qpidd --auth no \ --ssl-cert-db ./test_cert_db \ --ssl-cert-password-file ./cert.password \ --ssl-cert-name myhost.mydomain then for client set: -QPID_LOAD_MODULE=./src/.libs/sslconnector.so QPID_SSL_CERT_DB=./test_cert_db and run e.g. diff --git a/qpid/cpp/bindings/CMakeLists.txt b/qpid/cpp/bindings/CMakeLists.txt index 14e30ed6ca..883eef286f 100644 --- a/qpid/cpp/bindings/CMakeLists.txt +++ b/qpid/cpp/bindings/CMakeLists.txt @@ -73,7 +73,7 @@ if (SWIG_FOUND) set(CMAKE_SWIG_FLAGS "-w361,362,401,467,503") if (PYTHONLIBS_FOUND) - message("Building Python bindings") + message(STATUS "Building Python bindings") execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True, prefix='${CMAKE_INSTALL_PREFIX}')" OUTPUT_VARIABLE PYTHON_SITEARCH_PACKAGES @@ -81,11 +81,10 @@ if (SWIG_FOUND) add_subdirectory(qpid/python) add_subdirectory(qmf2/python) - add_subdirectory(qmf/python) endif (PYTHONLIBS_FOUND) if (RUBY_FOUND) - message("Building Ruby bindings") + message(STATUS "Building Ruby bindings") execute_process(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "puts RbConfig::CONFIG['prefix']" OUTPUT_VARIABLE RUBY_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -93,11 +92,10 @@ if (SWIG_FOUND) # string(REPLACE ${RUBY_PREFIX} ${CMAKE_INSTALL_PREFIX} RUBY_PFX_ARCH_DIR ${RUBY_ARCH_DIR}) add_subdirectory(qpid/ruby) add_subdirectory(qmf2/ruby) - add_subdirectory(qmf/ruby) endif (RUBY_FOUND) if (PERLLIBS_FOUND) - message("Building Perl bindings") + message(STATUS "Building Perl bindings") execute_process(COMMAND ${PERL_EXECUTABLE} "-V::prefix:" OUTPUT_VARIABLE QPERL_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/qpid/cpp/bindings/qmf/Makefile.am b/qpid/cpp/bindings/qmf/Makefile.am deleted file mode 100644 index ee4ff1d3c1..0000000000 --- a/qpid/cpp/bindings/qmf/Makefile.am +++ /dev/null @@ -1,32 +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. -# - -if HAVE_SWIG - -SUBDIRS = tests - -if HAVE_RUBY_DEVEL -SUBDIRS += ruby -endif - -if HAVE_PYTHON_DEVEL -SUBDIRS += python -endif - -endif diff --git a/qpid/cpp/bindings/qmf/python/CMakeLists.txt b/qpid/cpp/bindings/qmf/python/CMakeLists.txt deleted file mode 100644 index 14ba888c78..0000000000 --- a/qpid/cpp/bindings/qmf/python/CMakeLists.txt +++ /dev/null @@ -1,66 +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. -# - -##------------------------------------------------------ -## Use Swig to generate a literal binding to the C++ API -##------------------------------------------------------ -set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/python.i PROPERTIES CPLUSPLUS ON) -set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/python.i PROPERTIES SWIG_FLAGS "-I${qpid-cpp_SOURCE_DIR}/include;-I${qpid-cpp_SOURCE_DIR}/bindings") - -swig_add_module(qmfengine_python python ${CMAKE_CURRENT_SOURCE_DIR}/python.i) -swig_link_libraries(qmfengine_python qmf qmfconsole ${PYTHON_LIBRARIES}) - -set_source_files_properties(${swig_generated_file_fullname} PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing -I${PYTHON_INCLUDE_PATH} -I${qpid-cpp_SOURCE_DIR}/include") - -##------------------------------------ -## Install the complete Python binding -##------------------------------------ - -# Copy py source to binary dir so pyc/pyo will be generated in binary dir. -# NOTE: not using the file(COPY) command as it is not available in cmake 2.6 -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/qmf.py" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY) - -# Python compile the modules -install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m py_compile qmfengine.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") - -install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile qmfengine.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") -install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m py_compile qmf.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") -install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile qmf.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") - -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/qmfengine.py - ${CMAKE_CURRENT_BINARY_DIR}/qmfengine.pyc - ${CMAKE_CURRENT_BINARY_DIR}/qmfengine.pyo - ${CMAKE_CURRENT_SOURCE_DIR}/qmf.py - ${CMAKE_CURRENT_BINARY_DIR}/qmf.pyc - ${CMAKE_CURRENT_BINARY_DIR}/qmf.pyo - DESTINATION ${PYTHON_SITEARCH_PACKAGES} - COMPONENT ${QPID_COMPONENT_CLIENT} - ) - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/_qmfengine_python.so - RENAME _qmfengine.so - DESTINATION ${PYTHON_SITEARCH_PACKAGES} - COMPONENT ${QPID_COMPONENT_CLIENT} - ) - diff --git a/qpid/cpp/bindings/qmf/python/Makefile.am b/qpid/cpp/bindings/qmf/python/Makefile.am deleted file mode 100644 index f787d3955f..0000000000 --- a/qpid/cpp/bindings/qmf/python/Makefile.am +++ /dev/null @@ -1,51 +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. -# - -if HAVE_PYTHON_DEVEL - -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src/qmf -I$(top_srcdir)/src -I$(top_builddir)/src - -generated_file_list = \ - qmfengine.cpp \ - qmfengine.py - -EXTRA_DIST = CMakeLists.txt python.i qmfengine.py -BUILT_SOURCES = $(generated_file_list) -SWIG_FLAGS = -w362,401 - -$(generated_file_list): $(srcdir)/python.i - $(SWIG) -c++ -python $(SWIG_FLAGS) $(INCLUDES) $(QPID_CXXFLAGS) -I$(top_srcdir)/src/qmf -I/usr/include -o qmfengine.cpp $(srcdir)/python.i - -pylibdir = $(pyexecdir) - -pylib_LTLIBRARIES = _qmfengine.la -qenginedir = $(pythondir) -qengine_PYTHON = qmfengine.py qmf.py - -#_qmfengine_la_LDFLAGS = -avoid-version -module -shrext "$(PYTHON_SO)" -#_qmfengine_la_LDFLAGS = -avoid-version -module -shrext ".so" -_qmfengine_la_LDFLAGS = -avoid-version -module -shared -_qmfengine_la_LIBADD = $(PYTHON_LIBS) -L$(top_builddir)/src/.libs -lqpidclient $(top_builddir)/src/libqmf.la -_qmfengine_la_CXXFLAGS = $(INCLUDES) -I$(srcdir)/qmf $(PYTHON_CFLAGS) -fno-strict-aliasing -nodist__qmfengine_la_SOURCES = qmfengine.cpp - -CLEANFILES = $(generated_file_list) - -endif # HAVE_PYTHON_DEVEL - diff --git a/qpid/cpp/bindings/qmf/python/python.i b/qpid/cpp/bindings/qmf/python/python.i deleted file mode 100644 index 118d0d3dbd..0000000000 --- a/qpid/cpp/bindings/qmf/python/python.i +++ /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. - */ - -%module qmfengine - - -/* unsigned32 Convert from Python --> C */ -%typemap(in) uint32_t { - if (PyInt_Check($input)) { - $1 = (uint32_t) PyInt_AsUnsignedLongMask($input); - } else if (PyLong_Check($input)) { - $1 = (uint32_t) PyLong_AsUnsignedLong($input); - } else { - SWIG_exception_fail(SWIG_ValueError, "unknown integer type"); - } -} - -/* unsinged32 Convert from C --> Python */ -%typemap(out) uint32_t { - $result = PyInt_FromLong((long)$1); -} - - -/* unsigned16 Convert from Python --> C */ -%typemap(in) uint16_t { - if (PyInt_Check($input)) { - $1 = (uint16_t) PyInt_AsUnsignedLongMask($input); - } else if (PyLong_Check($input)) { - $1 = (uint16_t) PyLong_AsUnsignedLong($input); - } else { - SWIG_exception_fail(SWIG_ValueError, "unknown integer type"); - } -} - -/* unsigned16 Convert from C --> Python */ -%typemap(out) uint16_t { - $result = PyInt_FromLong((long)$1); -} - - -/* signed32 Convert from Python --> C */ -%typemap(in) int32_t { - if (PyInt_Check($input)) { - $1 = (int32_t) PyInt_AsLong($input); - } else if (PyLong_Check($input)) { - $1 = (int32_t) PyLong_AsLong($input); - } else { - SWIG_exception_fail(SWIG_ValueError, "unknown integer type"); - } -} - -/* signed32 Convert from C --> Python */ -%typemap(out) int32_t { - $result = PyInt_FromLong((long)$1); -} - - -/* unsigned64 Convert from Python --> C */ -%typemap(in) uint64_t { -%#ifdef HAVE_LONG_LONG - if (PyLong_Check($input)) { - $1 = (uint64_t)PyLong_AsUnsignedLongLong($input); - } else if (PyInt_Check($input)) { - $1 = (uint64_t)PyInt_AsUnsignedLongLongMask($input); - } else -%#endif - { - SWIG_exception_fail(SWIG_ValueError, "unsupported integer size - uint64_t input too large"); - } -} - -/* unsigned64 Convert from C --> Python */ -%typemap(out) uint64_t { -%#ifdef HAVE_LONG_LONG - $result = PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)$1); -%#else - SWIG_exception_fail(SWIG_ValueError, "unsupported integer size - uint64_t output too large"); -%#endif -} - -/* signed64 Convert from Python --> C */ -%typemap(in) int64_t { -%#ifdef HAVE_LONG_LONG - if (PyLong_Check($input)) { - $1 = (int64_t)PyLong_AsLongLong($input); - } else if (PyInt_Check($input)) { - $1 = (int64_t)PyInt_AsLong($input); - } else -%#endif - { - SWIG_exception_fail(SWIG_ValueError, "unsupported integer size - int64_t input too large"); - } -} - -/* signed64 Convert from C --> Python */ -%typemap(out) int64_t { -%#ifdef HAVE_LONG_LONG - $result = PyLong_FromLongLong((PY_LONG_LONG)$1); -%#else - SWIG_exception_fail(SWIG_ValueError, "unsupported integer size - int64_t output too large"); -%#endif -} - - -/* Convert from Python --> C */ -%typemap(in) void * { - $1 = (void *)$input; -} - -/* Convert from C --> Python */ -%typemap(out) void * { - $result = (PyObject *) $1; - Py_INCREF($result); -} - -%typemap (typecheck, precedence=SWIG_TYPECHECK_UINT64) uint64_t { - $1 = PyLong_Check($input) ? 1 : 0; -} - -%typemap (typecheck, precedence=SWIG_TYPECHECK_UINT32) uint32_t { - $1 = PyInt_Check($input) ? 1 : 0; -} - - - -%include "qmf/qmfengine.i" - diff --git a/qpid/cpp/bindings/qmf/python/qmf.py b/qpid/cpp/bindings/qmf/python/qmf.py deleted file mode 100644 index 06d3070841..0000000000 --- a/qpid/cpp/bindings/qmf/python/qmf.py +++ /dev/null @@ -1,1680 +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. -# -import sys -import socket -import os -import logging -from threading import Thread -from threading import RLock -from threading import Condition -import qmfengine -from qmfengine import (ACCESS_READ_CREATE, ACCESS_READ_ONLY, ACCESS_READ_WRITE) -from qmfengine import (CLASS_EVENT, CLASS_OBJECT) -from qmfengine import (DIR_IN, DIR_IN_OUT, DIR_OUT) -from qmfengine import (TYPE_ABSTIME, TYPE_ARRAY, TYPE_BOOL, TYPE_DELTATIME, - TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT16, TYPE_INT32, TYPE_INT64, - TYPE_INT8, TYPE_LIST, TYPE_LSTR, TYPE_MAP, TYPE_OBJECT, - TYPE_REF, TYPE_SSTR, TYPE_UINT16, TYPE_UINT32, TYPE_UINT64, - TYPE_UINT8, TYPE_UUID) -from qmfengine import (O_EQ, O_NE, O_LT, O_LE, O_GT, O_GE, O_RE_MATCH, O_RE_NOMATCH, - E_NOT, E_AND, E_OR, E_XOR) -from qmfengine import (SEV_EMERG, SEV_ALERT, SEV_CRIT, SEV_ERROR, SEV_WARN, SEV_NOTICE, - SEV_INFORM, SEV_DEBUG) - - -def qmf_to_native(val): - typecode = val.getType() - if typecode == TYPE_UINT8: return val.asUint() - elif typecode == TYPE_UINT16: return val.asUint() - elif typecode == TYPE_UINT32: return val.asUint() - elif typecode == TYPE_UINT64: return val.asUint64() - elif typecode == TYPE_SSTR: return val.asString() - elif typecode == TYPE_LSTR: return val.asString() - elif typecode == TYPE_ABSTIME: return val.asInt64() - elif typecode == TYPE_DELTATIME: return val.asUint64() - elif typecode == TYPE_REF: return ObjectId(val.asObjectId()) - elif typecode == TYPE_BOOL: return val.asBool() - elif typecode == TYPE_FLOAT: return val.asFloat() - elif typecode == TYPE_DOUBLE: return val.asDouble() - elif typecode == TYPE_UUID: return val.asUuid() - elif typecode == TYPE_INT8: return val.asInt() - elif typecode == TYPE_INT16: return val.asInt() - elif typecode == TYPE_INT32: return val.asInt() - elif typecode == TYPE_INT64: return val.asInt64() - elif typecode == TYPE_MAP: return value_to_dict(val) - elif typecode == TYPE_LIST: return value_to_list(val) - else: - # when TYPE_OBJECT - logging.error( "Unsupported type for get_attr? '%s'" % str(val.getType()) ) - return None - - -def native_to_qmf(target, value): - val = None - typecode = None - if target.__class__ == qmfengine.Value: - val = target - typecode = val.getType() - else: - typecode = target - val = qmfengine.Value(typecode) - - if typecode == TYPE_UINT8: val.setUint(value) - elif typecode == TYPE_UINT16: val.setUint(value) - elif typecode == TYPE_UINT32: val.setUint(value) - elif typecode == TYPE_UINT64: val.setUint64(value) - elif typecode == TYPE_SSTR: - if value: val.setString(value) - else: val.setString('') - elif typecode == TYPE_LSTR: - if value: val.setString(value) - else: val.setString('') - elif typecode == TYPE_ABSTIME: val.setInt64(value) - elif typecode == TYPE_DELTATIME: val.setUint64(value) - elif typecode == TYPE_REF: val.setObjectId(value.impl) - elif typecode == TYPE_BOOL: val.setBool(value) - elif typecode == TYPE_FLOAT: val.setFloat(value) - elif typecode == TYPE_DOUBLE: val.setDouble(value) - elif typecode == TYPE_UUID: val.setUuid(value) - elif typecode == TYPE_INT8: val.setInt(value) - elif typecode == TYPE_INT16: val.setInt(value) - elif typecode == TYPE_INT32: val.setInt(value) - elif typecode == TYPE_INT64: val.setInt64(value) - elif typecode == TYPE_MAP: dict_to_value(val, value) - elif typecode == TYPE_LIST: list_to_value(val, value) - else: - # when TYPE_OBJECT - logging.error("Unsupported type for get_attr? '%s'" % str(val.getType())) - return None - return val - - -def pick_qmf_type(value): - if value.__class__ == int: - if value >= 0: - if value < 0x100000000: return TYPE_UINT32 - return TYPE_UINT64 - else: - if value > -0xffffffff: return TYPE_INT32 - return TYPE_INT64 - - if value.__class__ == long: - if value >= 0: return TYPE_UINT64 - return TYPE_INT64 - - if value.__class__ == str: - if len(value) < 256: return TYPE_SSTR - return TYPE_LSTR - - if value.__class__ == float: return TYPE_DOUBLE - if value.__class__ == bool: return TYPE_BOOL - if value == None: return TYPE_BOOL - if value.__class__ == dict: return TYPE_MAP - if value.__class__ == list: return TYPE_LIST - - raise "QMF type not known for native type %s" % value.__class__ - - -def value_to_dict(val): - if not val.isMap(): raise "value_to_dict must be given a map value" - mymap = {} - for i in range(val.keyCount()): - key = val.key(i) - mymap[key] = qmf_to_native(val.byKey(key)) - return mymap - - -def dict_to_value(val, mymap): - for key, value in mymap.items(): - if key.__class__ != str: raise "QMF map key must be a string" - typecode = pick_qmf_type(value) - val.insert(key, native_to_qmf(typecode, value)) - - -def value_to_list(val): - mylist = [] - if val.isList(): - for i in range(val.listItemCount()): - mylist.append(qmf_to_native(val.listItem(i))) - return mylist - #if val.isArray(): - # for i in range(val.arrayItemCount()): - # mylist.append(qmf_to_native(val.arrayItem(i))) - # return mylist - - raise "value_to_list must be given a list value" - - -def list_to_value(val, mylist): - for item in mylist: - typecode = pick_qmf_type(item) - val.appendToList(native_to_qmf(typecode, item)) - - - ##============================================================================== - ## CONNECTION - ##============================================================================== - -class ConnectionSettings(object): - #attr_reader :impl - def __init__(self, url=None): - if url: - self.impl = qmfengine.ConnectionSettings(url) - else: - self.impl = qmfengine.ConnectionSettings() - - - def set_attr(self, key, val): - if type(val) == str: - _v = qmfengine.Value(TYPE_LSTR) - _v.setString(val) - elif type(val) == int: - _v = qmfengine.Value(TYPE_UINT32) - _v.setUint(val) - elif type(val) == bool: - _v = qmfengine.Value(TYPE_BOOL) - _v.setBool(val) - else: - raise Exception("Argument error: value for attribute '%s' has unsupported type: %s" % ( key, type(val))) - - good = self.impl.setAttr(key, _v) - if not good: - raise Exception("Argument error: unsupported attribute '%s'" % key ) - - - def get_attr(self, key): - _v = self.impl.getAttr(key) - if _v.isString(): - return _v.asString() - elif _v.isUint(): - return _v.asUint() - elif _v.isBool(): - return _v.asBool() - else: - raise Exception("Argument error: value for attribute '%s' has unsupported type: %s" % ( key, str(_v.getType()))) - - - def __getattr__(self, name): - return self.get_attr(name) - - - def __setattr__(self, name, value): - if name == "impl": - return super.__setattr__(self, name, value) - return self.set_attr(name, value) - - - -class ConnectionHandler: - def conn_event_connected(self): None - def conn_event_disconnected(self, error): None - def conn_event_visit(self): None - def sess_event_session_closed(self, context, error): None - def sess_event_recv(self, context, message): None - - - -class Connection(Thread): - def __init__(self, settings): - Thread.__init__(self) - self._lock = RLock() - self.impl = qmfengine.ResilientConnection(settings.impl) - self._sockEngine, self._sock = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) - self.impl.setNotifyFd(self._sockEngine.fileno()) - self._new_conn_handlers = [] - self._conn_handlers_to_delete = [] - self._conn_handlers = [] - self._connected = False - self._operational = True - self.start() - - - def destroy(self, timeout=None): - logging.debug("Destroying Connection...") - self._operational = False - self.kick() - self.join(timeout) - logging.debug("... Conn Destroyed!" ) - if self.isAlive(): - logging.error("Error: Connection thread '%s' is hung..." % self.getName()) - - - def connected(self): - return self._connected - - - def kick(self): - self.impl.notify() - - - def add_conn_handler(self, handler): - self._lock.acquire() - try: - self._new_conn_handlers.append(handler) - finally: - self._lock.release() - self.kick() - - - def del_conn_handler(self, handler): - self._lock.acquire() - try: - self._conn_handlers_to_delete.append(handler) - finally: - self._lock.release() - self.kick() - - - def run(self): - eventImpl = qmfengine.ResilientConnectionEvent() - new_handlers = [] - del_handlers = [] - bt_count = 0 - - while self._operational: - logging.debug("Connection thread waiting for socket data...") - self._sock.recv(1) - - self._lock.acquire() - try: - new_handlers = self._new_conn_handlers - del_handlers = self._conn_handlers_to_delete - self._new_conn_handlers = [] - self._conn_handlers_to_delete = [] - finally: - self._lock.release() - - for nh in new_handlers: - self._conn_handlers.append(nh) - if self._connected: - nh.conn_event_connected() - new_handlers = [] - - for dh in del_handlers: - if dh in self._conn_handlers: - self._conn_handlers.remove(dh) - del_handlers = [] - - valid = self.impl.getEvent(eventImpl) - while valid: - try: - if eventImpl.kind == qmfengine.ResilientConnectionEvent.CONNECTED: - logging.debug("Connection thread: CONNECTED event received.") - self._connected = True - for h in self._conn_handlers: - h.conn_event_connected() - - elif eventImpl.kind == qmfengine.ResilientConnectionEvent.DISCONNECTED: - logging.debug("Connection thread: DISCONNECTED event received.") - self._connected = False - for h in self._conn_handlers: - h.conn_event_disconnected(eventImpl.errorText) - - elif eventImpl.kind == qmfengine.ResilientConnectionEvent.SESSION_CLOSED: - logging.debug("Connection thread: SESSION_CLOSED event received.") - eventImpl.sessionContext.handler.sess_event_session_closed(eventImpl.sessionContext, eventImpl.errorText) - - elif eventImpl.kind == qmfengine.ResilientConnectionEvent.RECV: - logging.debug("Connection thread: RECV event received.") - eventImpl.sessionContext.handler.sess_event_recv(eventImpl.sessionContext, eventImpl.message) - else: - logging.debug("Connection thread received unknown event: '%s'" % str(eventImpl.kind)) - - except: - import traceback - logging.error( "Exception occurred during Connection event processing:" ) - logging.error( str(sys.exc_info()) ) - if bt_count < 2: - traceback.print_exc() - traceback.print_stack() - bt_count += 1 - - self.impl.popEvent() - valid = self.impl.getEvent(eventImpl) - - for h in self._conn_handlers: - h.conn_event_visit() - - logging.debug("Shutting down Connection thread") - - - -class Session: - def __init__(self, conn, label, handler): - self._conn = conn - self._label = label - self.handler = handler - self.handle = qmfengine.SessionHandle() - result = self._conn.impl.createSession(label, self, self.handle) - - - def destroy(self): - self._conn.impl.destroySession(self.handle) - - - - ##============================================================================== - ## OBJECTS and EVENTS - ##============================================================================== - -class QmfEvent(object): - # attr_reader :impl, :event_class - def __init__(self, cls, kwargs={}): - self._allow_sets = True - if kwargs.has_key("broker"): - self._broker = kwargs["broker"] - else: - self._broker = None - if cls: - self.event_class = cls - self.impl = qmfengine.Event(self.event_class.impl) - elif kwargs.has_key("impl"): - self.impl = qmfengine.Event(kwargs["impl"]) - self.event_class = SchemaEventClass(None, None, 0, - {"impl":self.impl.getClass()}) - else: - raise Exception("Argument error: required parameter ('impl') not supplied") - - - def arguments(self): - list = [] - for arg in self.event_class.arguments: - list.append([arg, self.get_attr(arg.name())]) - return list - - - def get_attr(self, name): - val = self._value(name) - return qmf_to_native(val) - - - def set_attr(self, name, v): - val = self._value(name) - native_to_qmf(val, v) - - - def __getitem__(self, name): - return self.get_attr(name) - - - def __setitem__(self, name, value): - self.set_attr(name, value) - - - def __setattr__(self, name, value): - # - # Ignore the internal attributes, set them normally... - # - if (name[0] == '_' or - name == 'impl' or - name == 'event_class'): - return super.__setattr__(self, name, value) - - if not self._allow_sets: - raise Exception("'Set' operations not permitted on this object") - - # - # If the name matches an argument name, set the value of the argument. - # - # print "set name=%s" % str(name) - for arg in self.event_class.arguments: - if arg.name() == name: - return self.set_attr(name, value) - - # unrecognized name? should I raise an exception? - super.__setattr__(self, name, value) - - - def __getattr__(self, name, *args): - # - # If the name matches an argument name, return the value of the argument. - # - for arg in self.event_class.arguments: - if arg.name() == name: - return self.get_attr(name) - - # - # This name means nothing to us, pass it up the line to the parent - # class's handler. - # - # print "__getattr__=%s" % str(name) - super.__getattr__(self, name) - - - def _value(self, name): - val = self.impl.getValue(name) - if not val: - raise Exception("Argument error: attribute named '%s' not defined for package %s, class %s" % - (name, - self.event_class.impl.getClassKey().getPackageName(), - self.event_class.impl.getClassKey().getClassName())) - return val - - -class QmfObject(object): - # attr_reader :impl, :object_class - def __init__(self, cls, kwargs={}): - self._cv = Condition() - self._sync_count = 0 - self._sync_result = None - self._allow_sets = False - if kwargs.has_key("broker"): - self._broker = kwargs["broker"] - else: - self._broker = None - if cls: - self.object_class = cls - self.impl = qmfengine.Object(self.object_class.impl) - elif kwargs.has_key("impl"): - self.impl = qmfengine.Object(kwargs["impl"]) - self.object_class = SchemaObjectClass(None, - None, - {"impl":self.impl.getClass()}) - else: - raise Exception("Argument error: required parameter ('impl') not supplied") - - - def destroy(self): - self.impl.destroy() - - - def object_id(self): - return ObjectId(self.impl.getObjectId()) - - - def set_object_id(self, oid): - self.impl.setObjectId(oid.impl) - - - def properties(self): - list = [] - for prop in self.object_class.properties: - list.append([prop, self.get_attr(prop.name())]) - return list - - - def statistics(self): - list = [] - for stat in self.object_class.statistics: - list.append([stat, self.get_attr(stat.name())]) - return list - - - def get_attr(self, name): - val = self._value(name) - return qmf_to_native(val) - - - def set_attr(self, name, v): - val = self._value(name) - native_to_qmf(val, v) - - - def __getitem__(self, name): - return self.get_attr(name) - - - def __setitem__(self, name, value): - self.set_attr(name, value) - - - def inc_attr(self, name, by=1): - self.set_attr(name, self.get_attr(name) + by) - - - def dec_attr(self, name, by=1): - self.set_attr(name, self.get_attr(name) - by) - - - def __setattr__(self, name, value): - # - # Ignore the internal attributes, set them normally... - # - if (name[0] == '_' or - name == 'impl' or - name == 'object_class'): - return super.__setattr__(self, name, value) - - if not self._allow_sets: - raise Exception("'Set' operations not permitted on this object") - # - # If the name matches a property name, set the value of the property. - # - # print "set name=%s" % str(name) - for prop in self.object_class.properties: - if prop.name() == name: - return self.set_attr(name, value) - # - # otherwise, check for a statistic set... - # - for stat in self.object_class.statistics: - if stat.name() == name: - return self.set_attr(name, value) - - # unrecognized name? should I raise an exception? - super.__setattr__(self, name, value) - - - def __getattr__(self, name, *args): - # - # If the name matches a property name, return the value of the property. - # - for prop in self.object_class.properties: - if prop.name() == name: - return self.get_attr(name) - # - # Do the same for statistics - # - for stat in self.object_class.statistics: - if stat.name() == name: - return self.get_attr(name) - # - # If we still haven't found a match for the name, check to see if - # it matches a method name. If so, marshall up the arguments into - # a map, and invoke the method. - # - for method in self.object_class.methods: - if method.name() == name: - argMap = self._marshall(method, args) - return lambda name, argMap : self._invokeMethod(name, argMap) - - # - # This name means nothing to us, pass it up the line to the parent - # class's handler. - # - # print "__getattr__=%s" % str(name) - super.__getattr__(self, name) - - - def _invokeMethod(self, name, argMap): - """ - Private: Helper function that invokes an object's method, and waits for the result. - """ - self._cv.acquire() - try: - timeout = 30 - self._sync_count = 1 - self.impl.invokeMethod(name, argMap, self) - if self._broker: - self._broker.conn.kick() - self._cv.wait(timeout) - if self._sync_count == 1: - raise Exception("Timed out: waiting for response to method call.") - finally: - self._cv.release() - - return self._sync_result - - - def _method_result(self, result): - """ - Called to return the result of a method call on an object - """ - self._cv.acquire(); - try: - self._sync_result = result - self._sync_count -= 1 - self._cv.notify() - finally: - self._cv.release() - - - def _marshall(schema, args): - ''' - Private: Convert a list of arguments (positional) into a Value object of type "map". - Used to create the argument parameter for an object's method invokation. - ''' - # Build a map of the method's arguments - map = qmfengine.Value(TYPE_MAP) - for arg in schema.arguments: - if arg.direction == DIR_IN or arg.direction == DIR_IN_OUT: - map.insert(arg.name, qmfengine.Value(arg.typecode)) - - # install each argument's value into the map - marshalled = Arguments(map) - idx = 0 - for arg in schema.arguments: - if arg.direction == DIR_IN or arg.direction == DIR_IN_OUT: - if args[idx]: - marshalled[arg.name] = args[idx] - idx += 1 - - return marshalled.map - - - def _value(self, name): - val = self.impl.getValue(name) - if not val: - raise Exception("Argument error: attribute named '%s' not defined for package %s, class %s" % - (name, - self.object_class.impl.getClassKey().getPackageName(), - self.object_class.impl.getClassKey().getClassName())) - return val - - - -class AgentObject(QmfObject): - def __init__(self, cls, kwargs={}): - QmfObject.__init__(self, cls, kwargs) - self._allow_sets = True - - - def destroy(self): - self.impl.destroy() - - - def set_object_id(self, oid): - self.impl.setObjectId(oid.impl) - - - -class ConsoleObject(QmfObject): - # attr_reader :current_time, :create_time, :delete_time - def __init__(self, cls, kwargs={}): - QmfObject.__init__(self, cls, kwargs) - - - def update(self): - if not self._broker: - raise Exception("No linkage to broker") - newer = self._broker.console.objects(Query({"object_id":object_id})) - if newer.size != 1: - raise Exception("Expected exactly one update for this object, %d present" % int(newer.size)) - self.merge_update(newer[0]) - - - def merge_update(self, newObject): - self.impl.merge(new_object.impl) - - - def is_deleted(self): - return self.impl.isDeleted() - - - def key(self): pass - - - -class ObjectId: - def __init__(self, impl=None): - if impl: - self.impl = impl - else: - self.impl = qmfengine.ObjectId() - self.agent_key = "%d.%d" % (self.impl.getBrokerBank(), self.impl.getAgentBank()) - - - def object_num_high(self): - return self.impl.getObjectNumHi() - - - def object_num_low(self): - return self.impl.getObjectNumLo() - - - def agent_key(self): - self.agent_key - - def __eq__(self, other): - if not isinstance(other, self.__class__): return False - return self.impl == other.impl - - def __ne__(self, other): - return not self.__eq__(other) - - def __repr__(self): - return self.impl.str() - - - -class Arguments(object): - def __init__(self, map): - self.map = map - self._by_hash = {} - key_count = self.map.keyCount() - a = 0 - while a < key_count: - key = self.map.key(a) - self._by_hash[key] = qmf_to_native(self.map.byKey(key)) - a += 1 - - - def __getitem__(self, key): - return self._by_hash[key] - - - def __setitem__(self, key, value): - self._by_hash[key] = value - self.set(key, value) - - - def __iter__(self): - return self._by_hash.__iter__ - - - def __getattr__(self, name): - if name in self._by_hash: - return self._by_hash[name] - return super.__getattr__(self, name) - - - def __setattr__(self, name, value): - # - # ignore local data members - # - if (name[0] == '_' or - name == 'map'): - return super.__setattr__(self, name, value) - - if name in self._by_hash: - self._by_hash[name] = value - return self.set(name, value) - - return super.__setattr__(self, name, value) - - - def set(self, key, value): - val = self.map.byKey(key) - native_to_qmf(val, value) - - - -class MethodResponse(object): - def __init__(self, impl): - self.impl = qmfengine.MethodResponse(impl) - - - def status(self): - return self.impl.getStatus() - - - def exception(self): - return self.impl.getException() - - - def text(self): - return exception().asString() - - - def args(self): - return Arguments(self.impl.getArgs()) - - - def __getattr__(self, name): - myArgs = self.args() - return myArgs.__getattr__(name) - - - def __setattr__(self, name, value): - if name == 'impl': - return super.__setattr__(self, name, value) - - myArgs = self.args() - return myArgs.__setattr__(name, value) - - - - ##============================================================================== - ## QUERY - ##============================================================================== - - -class Query: - def __init__(self, kwargs={}): - if "impl" in kwargs: - self.impl = kwargs["impl"] - else: - package = '' - if "key" in kwargs: - # construct using SchemaClassKey: - self.impl = qmfengine.Query(kwargs["key"]) - elif "object_id" in kwargs: - self.impl = qmfengine.Query(kwargs["object_id"].impl) - else: - if "package" in kwargs: - package = kwargs["package"] - if "class" in kwargs: - self.impl = qmfengine.Query(kwargs["class"], package) - else: - raise Exception("Argument error: invalid arguments, use 'key', 'object_id' or 'class'[,'package']") - - - def package_name(self): return self.impl.getPackage() - def class_name(self): return self.impl.getClass() - def object_id(self): - _objid = self.impl.getObjectId() - if _objid: - return ObjectId(_objid) - else: - return None - - - ##============================================================================== - ## SCHEMA - ##============================================================================== - - - -class SchemaArgument: - #attr_reader :impl - def __init__(self, name, typecode, kwargs={}): - if "impl" in kwargs: - self.impl = kwargs["impl"] - else: - self.impl = qmfengine.SchemaArgument(name, typecode) - if kwargs.has_key("dir"): self.impl.setDirection(kwargs["dir"]) - if kwargs.has_key("unit"): self.impl.setUnit(kwargs["unit"]) - if kwargs.has_key("desc"): self.impl.setDesc(kwargs["desc"]) - - - def name(self): - return self.impl.getName() - - - def direction(self): - return self.impl.getDirection() - - - def typecode(self): - return self.impl.getType() - - - def __repr__(self): - return self.name() - - - -class SchemaMethod: - # attr_reader :impl, arguments - def __init__(self, name, kwargs={}): - self.arguments = [] - if "impl" in kwargs: - self.impl = kwargs["impl"] - for i in range(self.impl.getArgumentCount()): - self.arguments.append(SchemaArgument(None,None,{"impl":self.impl.getArgument(i)})) - else: - self.impl = qmfengine.SchemaMethod(name) - if kwargs.has_key("desc"): self.impl.setDesc(kwargs["desc"]) - - - def add_argument(self, arg): - self.arguments.append(arg) - self.impl.addArgument(arg.impl) - - def name(self): - return self.impl.getName() - - def __repr__(self): - return self.name() - - - -class SchemaProperty: - #attr_reader :impl - def __init__(self, name, typecode, kwargs={}): - if "impl" in kwargs: - self.impl = kwargs["impl"] - else: - self.impl = qmfengine.SchemaProperty(name, typecode) - if kwargs.has_key("access"): self.impl.setAccess(kwargs["access"]) - if kwargs.has_key("index"): self.impl.setIndex(kwargs["index"]) - if kwargs.has_key("optional"): self.impl.setOptional(kwargs["optional"]) - if kwargs.has_key("unit"): self.impl.setUnit(kwargs["unit"]) - if kwargs.has_key("desc"): self.impl.setDesc(kwargs["desc"]) - - - def name(self): - return self.impl.getName() - - def __repr__(self): - return self.name() - - - -class SchemaStatistic: - # attr_reader :impl - def __init__(self, name, typecode, kwargs={}): - if "impl" in kwargs: - self.impl = kwargs["impl"] - else: - self.impl = qmfengine.SchemaStatistic(name, typecode) - if kwargs.has_key("unit"): self.impl.setUnit(kwargs["unit"]) - if kwargs.has_key("desc"): self.impl.setDesc(kwargs["desc"]) - - - def name(self): - return self.impl.getName() - - def __repr__(self): - return self.name() - - - -class SchemaClassKey: - #attr_reader :impl - def __init__(self, i): - self.impl = i - - - def package_name(self): - return self.impl.getPackageName() - - - def class_name(self): - return self.impl.getClassName() - - def __repr__(self): - return self.impl.asString() - - - -class SchemaObjectClass: - # attr_reader :impl, :properties, :statistics, :methods - def __init__(self, package, name, kwargs={}): - self.properties = [] - self.statistics = [] - self.methods = [] - if "impl" in kwargs: - self.impl = kwargs["impl"] - - for i in range(self.impl.getPropertyCount()): - self.properties.append(SchemaProperty(None, None, {"impl":self.impl.getProperty(i)})) - - for i in range(self.impl.getStatisticCount()): - self.statistics.append(SchemaStatistic(None, None, {"impl":self.impl.getStatistic(i)})) - - for i in range(self.impl.getMethodCount()): - self.methods.append(SchemaMethod(None, {"impl":self.impl.getMethod(i)})) - else: - self.impl = qmfengine.SchemaObjectClass(package, name) - - - def add_property(self, prop): - self.properties.append(prop) - self.impl.addProperty(prop.impl) - - - def add_statistic(self, stat): - self.statistics.append(stat) - self.impl.addStatistic(stat.impl) - - - def add_method(self, meth): - self.methods.append(meth) - self.impl.addMethod(meth.impl) - - - def class_key(self): - return SchemaClassKey(self.impl.getClassKey()) - - - def package_name(self): - return self.impl.getClassKey().getPackageName() - - - def class_name(self): - return self.impl.getClassKey().getClassName() - - - -class SchemaEventClass: - # attr_reader :impl :arguments - def __init__(self, package, name, sev, kwargs={}): - self.arguments = [] - if "impl" in kwargs: - self.impl = kwargs["impl"] - for i in range(self.impl.getArgumentCount()): - self.arguments.append(SchemaArgument(nil, nil, {"impl":self.impl.getArgument(i)})) - else: - self.impl = qmfengine.SchemaEventClass(package, name, sev) - if kwargs.has_key("desc"): self.impl.setDesc(kwargs["desc"]) - - - def add_argument(self, arg): - self.arguments.append(arg) - self.impl.addArgument(arg.impl) - - - def name(self): - return self.impl.getClassKey().getClassName() - - def class_key(self): - return SchemaClassKey(self.impl.getClassKey()) - - - def package_name(self): - return self.impl.getClassKey().getPackageName() - - - def class_name(self): - return self.impl.getClassKey().getClassName() - - - ##============================================================================== - ## CONSOLE - ##============================================================================== - - - -class ConsoleHandler: - def agent_added(self, agent): pass - def agent_deleted(self, agent): pass - def new_package(self, package): pass - def new_class(self, class_key): pass - def object_update(self, obj, hasProps, hasStats): pass - def event_received(self, event): pass - def agent_heartbeat(self, agent, timestamp): pass - def method_response(self, resp): pass - def broker_info(self, broker): pass - - - -class Console(Thread): - # attr_reader :impl - def __init__(self, handler=None, kwargs={}): - Thread.__init__(self) - self._handler = handler - self.impl = qmfengine.Console() - self._event = qmfengine.ConsoleEvent() - self._broker_list = [] - self._cv = Condition() - self._sync_count = 0 - self._sync_result = None - self._select = {} - self._cb_cond = Condition() - self._operational = True - self.start() - - - def destroy(self, timeout=None): - logging.debug("Destroying Console...") - self._operational = False - self.start_console_events() # wake thread up - self.join(timeout) - logging.debug("... Console Destroyed!") - if self.isAlive(): - logging.error( "Console thread '%s' is hung..." % self.getName() ) - - - def add_connection(self, conn): - broker = Broker(self, conn) - self._cv.acquire() - try: - self._broker_list.append(broker) - finally: - self._cv.release() - return broker - - - def del_connection(self, broker): - logging.debug("shutting down broker...") - broker.shutdown() - logging.debug("...broker down.") - self._cv.acquire() - try: - self._broker_list.remove(broker) - finally: - self._cv.release() - logging.debug("del_connection() finished") - - - def packages(self): - plist = [] - for i in range(self.impl.packageCount()): - plist.append(self.impl.getPackageName(i)) - return plist - - - def classes(self, package, kind=CLASS_OBJECT): - clist = [] - for i in range(self.impl.classCount(package)): - key = self.impl.getClass(package, i) - class_kind = self.impl.getClassKind(key) - if class_kind == kind: - if kind == CLASS_OBJECT: - clist.append(SchemaObjectClass(None, None, {"impl":self.impl.getObjectClass(key)})) - elif kind == CLASS_EVENT: - clist.append(SchemaEventClass(None, None, 0, {"impl":self.impl.getEventClass(key)})) - return clist - - - def bind_package(self, package): - return self.impl.bindPackage(package) - - - def bind_class(self, kwargs = {}): - if "key" in kwargs: - self.impl.bindClass(kwargs["key"]) - elif "package" in kwargs: - package = kwargs["package"] - if "class" in kwargs: - self.impl.bindClass(package, kwargs["class"]) - else: - self.impl.bindClass(package, "*") - else: - raise Exception("Argument error: invalid arguments, use 'key' or 'package'[,'class']") - - - def bind_event(self, kwargs = {}): - if "key" in kwargs: - self.impl.bindEvent(kwargs["key"]) - elif "package" in kwargs: - package = kwargs["package"] - if "event" in kwargs: - self.impl.bindEvent(package, kwargs["event"]) - else: - self.impl.bindEvent(package, "*") - else: - raise Exception("Argument error: invalid arguments, use 'key' or 'package'[,'event']") - - - def agents(self, broker=None): - blist = [] - if broker: - blist.append(broker) - else: - self._cv.acquire() - try: - # copy while holding lock - blist = self._broker_list[:] - finally: - self._cv.release() - - agents = [] - for b in blist: - for idx in range(b.impl.agentCount()): - agents.append(AgentProxy(b.impl.getAgent(idx), b)) - - return agents - - - def objects(self, query, kwargs = {}): - timeout = 30 - agent = None - temp_args = kwargs.copy() - if type(query) == type({}): - temp_args.update(query) - - if "_timeout" in temp_args: - timeout = temp_args["_timeout"] - temp_args.pop("_timeout") - - if "_agent" in temp_args: - agent = temp_args["_agent"] - temp_args.pop("_agent") - - if type(query) == type({}): - query = Query(temp_args) - - self._select = {} - for k in temp_args.iterkeys(): - if type(k) == str: - self._select[k] = temp_args[k] - - self._cv.acquire() - try: - self._sync_count = 1 - self._sync_result = [] - broker = self._broker_list[0] - broker.send_query(query.impl, None, agent) - self._cv.wait(timeout) - if self._sync_count == 1: - raise Exception("Timed out: waiting for query response") - finally: - self._cv.release() - - return self._sync_result - - - def object(self, query, kwargs = {}): - ''' - Return one and only one object or None. - ''' - objs = objects(query, kwargs) - if len(objs) == 1: - return objs[0] - else: - return None - - - def first_object(self, query, kwargs = {}): - ''' - Return the first of potentially many objects. - ''' - objs = objects(query, kwargs) - if objs: - return objs[0] - else: - return None - - - # Check the object against select to check for a match - def _select_match(self, object): - schema_props = object.properties() - for key in self._select.iterkeys(): - for prop in schema_props: - if key == p[0].name() and self._select[key] != p[1]: - return False - return True - - - def _get_result(self, list, context): - ''' - Called by Broker proxy to return the result of a query. - ''' - self._cv.acquire() - try: - for item in list: - if self._select_match(item): - self._sync_result.append(item) - self._sync_count -= 1 - self._cv.notify() - finally: - self._cv.release() - - - def start_sync(self, query): pass - - - def touch_sync(self, sync): pass - - - def end_sync(self, sync): pass - - - def run(self): - while self._operational: - self._cb_cond.acquire() - try: - self._cb_cond.wait(1) - while self._do_console_events(): - pass - finally: - self._cb_cond.release() - logging.debug("Shutting down Console thread") - - - def start_console_events(self): - self._cb_cond.acquire() - try: - self._cb_cond.notify() - finally: - self._cb_cond.release() - - - def _do_console_events(self): - ''' - Called by the Console thread to poll for events. Passes the events - onto the ConsoleHandler associated with this Console. Is called - periodically, but can also be kicked by Console.start_console_events(). - ''' - count = 0 - valid = self.impl.getEvent(self._event) - while valid: - count += 1 - try: - if self._event.kind == qmfengine.ConsoleEvent.AGENT_ADDED: - logging.debug("Console Event AGENT_ADDED received") - if self._handler: - self._handler.agent_added(AgentProxy(self._event.agent, None)) - elif self._event.kind == qmfengine.ConsoleEvent.AGENT_DELETED: - logging.debug("Console Event AGENT_DELETED received") - if self._handler: - self._handler.agent_deleted(AgentProxy(self._event.agent, None)) - elif self._event.kind == qmfengine.ConsoleEvent.NEW_PACKAGE: - logging.debug("Console Event NEW_PACKAGE received") - if self._handler: - self._handler.new_package(self._event.name) - elif self._event.kind == qmfengine.ConsoleEvent.NEW_CLASS: - logging.debug("Console Event NEW_CLASS received") - if self._handler: - self._handler.new_class(SchemaClassKey(self._event.classKey)) - elif self._event.kind == qmfengine.ConsoleEvent.OBJECT_UPDATE: - logging.debug("Console Event OBJECT_UPDATE received") - if self._handler: - self._handler.object_update(ConsoleObject(None, {"impl":self._event.object}), - self._event.hasProps, self._event.hasStats) - elif self._event.kind == qmfengine.ConsoleEvent.EVENT_RECEIVED: - logging.debug("Console Event EVENT_RECEIVED received") - elif self._event.kind == qmfengine.ConsoleEvent.AGENT_HEARTBEAT: - logging.debug("Console Event AGENT_HEARTBEAT received") - if self._handler: - self._handler.agent_heartbeat(AgentProxy(self._event.agent, None), self._event.timestamp) - elif self._event.kind == qmfengine.ConsoleEvent.METHOD_RESPONSE: - logging.debug("Console Event METHOD_RESPONSE received") - else: - logging.debug("Console thread received unknown event: '%s'" % str(self._event.kind)) - except e: - print "Exception caught in callback thread:", e - self.impl.popEvent() - valid = self.impl.getEvent(self._event) - return count - - - -class AgentProxy: - # attr_reader :broker - def __init__(self, impl, broker): - self.impl = impl - self.broker = broker - self.key = "%d.%d" % (self.impl.getBrokerBank(), self.impl.getAgentBank()) - - - def label(self): - return self.impl.getLabel() - - - def key(self): - return self.key - - -class Broker(ConnectionHandler): - # attr_reader :impl :conn, :console, :broker_bank - def __init__(self, console, conn): - self.broker_bank = 1 - self.console = console - self.conn = conn - self._session = None - self._cv = Condition() - self._stable = None - self._event = qmfengine.BrokerEvent() - self._xmtMessage = qmfengine.Message() - self.impl = qmfengine.BrokerProxy(self.console.impl) - self.console.impl.addConnection(self.impl, self) - self.conn.add_conn_handler(self) - self._operational = True - - - def shutdown(self): - logging.debug("broker.shutdown() called.") - self.console.impl.delConnection(self.impl) - self.conn.del_conn_handler(self) - if self._session: - self.impl.sessionClosed() - logging.debug("broker.shutdown() sessionClosed done.") - self._session.destroy() - logging.debug("broker.shutdown() session destroy done.") - self._session = None - self._operational = False - logging.debug("broker.shutdown() done.") - - - def wait_for_stable(self, timeout = None): - self._cv.acquire() - try: - if self._stable: - return - if timeout: - self._cv.wait(timeout) - if not self._stable: - raise Exception("Timed out: waiting for broker connection to become stable") - else: - while not self._stable: - self._cv.wait() - finally: - self._cv.release() - - - def send_query(self, query, ctx, agent): - agent_impl = None - if agent: - agent_impl = agent.impl - self.impl.sendQuery(query, ctx, agent_impl) - self.conn.kick() - - - def _do_broker_events(self): - count = 0 - valid = self.impl.getEvent(self._event) - while valid: - count += 1 - if self._event.kind == qmfengine.BrokerEvent.BROKER_INFO: - logging.debug("Broker Event BROKER_INFO received"); - elif self._event.kind == qmfengine.BrokerEvent.DECLARE_QUEUE: - logging.debug("Broker Event DECLARE_QUEUE received"); - self.conn.impl.declareQueue(self._session.handle, self._event.name) - elif self._event.kind == qmfengine.BrokerEvent.DELETE_QUEUE: - logging.debug("Broker Event DELETE_QUEUE received"); - self.conn.impl.deleteQueue(self._session.handle, self._event.name) - elif self._event.kind == qmfengine.BrokerEvent.BIND: - logging.debug("Broker Event BIND received"); - self.conn.impl.bind(self._session.handle, self._event.exchange, self._event.name, self._event.bindingKey) - elif self._event.kind == qmfengine.BrokerEvent.UNBIND: - logging.debug("Broker Event UNBIND received"); - self.conn.impl.unbind(self._session.handle, self._event.exchange, self._event.name, self._event.bindingKey) - elif self._event.kind == qmfengine.BrokerEvent.SETUP_COMPLETE: - logging.debug("Broker Event SETUP_COMPLETE received"); - self.impl.startProtocol() - elif self._event.kind == qmfengine.BrokerEvent.STABLE: - logging.debug("Broker Event STABLE received"); - self._cv.acquire() - try: - self._stable = True - self._cv.notify() - finally: - self._cv.release() - elif self._event.kind == qmfengine.BrokerEvent.QUERY_COMPLETE: - result = [] - for idx in range(self._event.queryResponse.getObjectCount()): - result.append(ConsoleObject(None, {"impl":self._event.queryResponse.getObject(idx), "broker":self})) - self.console._get_result(result, self._event.context) - elif self._event.kind == qmfengine.BrokerEvent.METHOD_RESPONSE: - obj = self._event.context - obj._method_result(MethodResponse(self._event.methodResponse())) - - self.impl.popEvent() - valid = self.impl.getEvent(self._event) - - return count - - - def _do_broker_messages(self): - count = 0 - valid = self.impl.getXmtMessage(self._xmtMessage) - while valid: - count += 1 - logging.debug("Broker: sending msg on connection") - self.conn.impl.sendMessage(self._session.handle, self._xmtMessage) - self.impl.popXmt() - valid = self.impl.getXmtMessage(self._xmtMessage) - - return count - - - def _do_events(self): - while True: - self.console.start_console_events() - bcnt = self._do_broker_events() - mcnt = self._do_broker_messages() - if bcnt == 0 and mcnt == 0: - break; - - - def conn_event_connected(self): - logging.debug("Broker: Connection event CONNECTED") - self._session = Session(self.conn, "qmfc-%s.%d" % (socket.gethostname(), os.getpid()), self) - self.impl.sessionOpened(self._session.handle) - self._do_events() - - - def conn_event_disconnected(self, error): - logging.debug("Broker: Connection event DISCONNECTED") - pass - - - def conn_event_visit(self): - self._do_events() - - - def sess_event_session_closed(self, context, error): - logging.debug("Broker: Session event CLOSED") - self.impl.sessionClosed() - - - def sess_event_recv(self, context, message): - logging.debug("Broker: Session event MSG_RECV") - if not self._operational: - logging.warning("Unexpected session event message received by Broker proxy: context='%s'" % str(context)) - self.impl.handleRcvMessage(message) - self._do_events() - - - - ##============================================================================== - ## AGENT - ##============================================================================== - - - -class AgentHandler: - def get_query(self, context, query, userId): None - def method_call(self, context, name, object_id, args, userId): None - - - -class Agent(ConnectionHandler): - def __init__(self, handler, label=""): - if label == "": - self._agentLabel = "rb-%s.%d" % (socket.gethostname(), os.getpid()) - else: - self._agentLabel = label - self._conn = None - self._handler = handler - self.impl = qmfengine.Agent(self._agentLabel) - self._event = qmfengine.AgentEvent() - self._xmtMessage = qmfengine.Message() - - - def set_connection(self, conn): - self._conn = conn - self._conn.add_conn_handler(self) - - - def register_class(self, cls): - self.impl.registerClass(cls.impl) - - - def alloc_object_id(self, low = 0, high = 0): - return ObjectId(self.impl.allocObjectId(low, high)) - - - def raise_event(self, event): - self.impl.raiseEvent(event.impl) - - def query_response(self, context, obj): - self.impl.queryResponse(context, obj.impl) - - - def query_complete(self, context): - self.impl.queryComplete(context) - - - def method_response(self, context, status, text, arguments): - self.impl.methodResponse(context, status, text, arguments.map) - - - def do_agent_events(self): - count = 0 - valid = self.impl.getEvent(self._event) - while valid: - count += 1 - if self._event.kind == qmfengine.AgentEvent.GET_QUERY: - self._handler.get_query(self._event.sequence, - Query({"impl":self._event.query}), - self._event.authUserId) - - elif self._event.kind == qmfengine.AgentEvent.START_SYNC: - pass - elif self._event.kind == qmfengine.AgentEvent.END_SYNC: - pass - elif self._event.kind == qmfengine.AgentEvent.METHOD_CALL: - args = Arguments(self._event.arguments) - self._handler.method_call(self._event.sequence, self._event.name, - ObjectId(self._event.objectId), - args, self._event.authUserId) - - elif self._event.kind == qmfengine.AgentEvent.DECLARE_QUEUE: - self._conn.impl.declareQueue(self._session.handle, self._event.name) - - elif self._event.kind == qmfengine.AgentEvent.DELETE_QUEUE: - self._conn.impl.deleteQueue(self._session.handle, self._event.name) - - elif self._event.kind == qmfengine.AgentEvent.BIND: - self._conn.impl.bind(self._session.handle, self._event.exchange, - self._event.name, self._event.bindingKey) - - elif self._event.kind == qmfengine.AgentEvent.UNBIND: - self._conn.impl.unbind(self._session.handle, self._event.exchange, - self._event.name, self._event.bindingKey) - - elif self._event.kind == qmfengine.AgentEvent.SETUP_COMPLETE: - self.impl.startProtocol() - - self.impl.popEvent() - valid = self.impl.getEvent(self._event) - return count - - - def do_agent_messages(self): - count = 0 - valid = self.impl.getXmtMessage(self._xmtMessage) - while valid: - count += 1 - self._conn.impl.sendMessage(self._session.handle, self._xmtMessage) - self.impl.popXmt() - valid = self.impl.getXmtMessage(self._xmtMessage) - return count - - - def do_events(self): - while True: - ecnt = self.do_agent_events() - mcnt = self.do_agent_messages() - if ecnt == 0 and mcnt == 0: - break - - - def conn_event_connected(self): - logging.debug("Agent Connection Established...") - self._session = Session(self._conn, - "qmfa-%s.%d" % (socket.gethostname(), os.getpid()), - self) - self.impl.newSession() - self.do_events() - - - def conn_event_disconnected(self, error): - logging.debug("Agent Connection Lost") - pass - - - def conn_event_visit(self): - self.do_events() - - - def sess_event_session_closed(self, context, error): - logging.debug("Agent Session Lost") - pass - - - def sess_event_recv(self, context, message): - self.impl.handleRcvMessage(message) - self.do_events() - - diff --git a/qpid/cpp/bindings/qmf/ruby/CMakeLists.txt b/qpid/cpp/bindings/qmf/ruby/CMakeLists.txt deleted file mode 100644 index 37ce73293f..0000000000 --- a/qpid/cpp/bindings/qmf/ruby/CMakeLists.txt +++ /dev/null @@ -1,51 +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. -# - -##------------------------------------------------------ -## Use Swig to generate a literal binding to the C++ API -##------------------------------------------------------ -set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/ruby.i PROPERTIES CPLUSPLUS ON) - -if ((${CMAKE_MAJOR_VERSION} EQUAL 2) AND (${CMAKE_MINOR_VERSION} LESS 8)) - set (RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_PATH}) -endif ((${CMAKE_MAJOR_VERSION} EQUAL 2) AND (${CMAKE_MINOR_VERSION} LESS 8)) - -include_directories(${RUBY_INCLUDE_DIRS} - ${qpid-cpp_SOURCE_DIR}/include - ${qpid-cpp_SOURCE_DIR}/bindings) - -swig_add_module(qmfengine_ruby ruby ${CMAKE_CURRENT_SOURCE_DIR}/ruby.i) -swig_link_libraries(qmfengine_ruby qmf qmfconsole ${RUBY_LIBRARY}) - -##---------------------------------- -## Install the complete Ruby binding -##---------------------------------- -if ((${CMAKE_MAJOR_VERSION} EQUAL 2) AND (${CMAKE_MINOR_VERSION} LESS 8)) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmfengine_ruby.so - RENAME qmfengine.so - DESTINATION ${RUBY_PFX_ARCH_DIR} - COMPONENT ${QPID_COMPONENT_CLIENT} - ) -else() - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libqmfengine_ruby.so - RENAME qmfengine.so - DESTINATION ${RUBY_PFX_ARCH_DIR} - COMPONENT ${QPID_COMPONENT_CLIENT} - ) -endif ((${CMAKE_MAJOR_VERSION} EQUAL 2) AND (${CMAKE_MINOR_VERSION} LESS 8)) diff --git a/qpid/cpp/bindings/qmf/ruby/Makefile.am b/qpid/cpp/bindings/qmf/ruby/Makefile.am deleted file mode 100644 index 488d5550c5..0000000000 --- a/qpid/cpp/bindings/qmf/ruby/Makefile.am +++ /dev/null @@ -1,45 +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. -# - -if HAVE_RUBY_DEVEL - -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_builddir)/src - -EXTRA_DIST = $(srcdir)/CMakeLists.txt $(srcdir)/ruby.i -BUILT_SOURCES = qmfengine.cpp -SWIG_FLAGS = -w362,401 - -rubylibdir = $(RUBY_LIB) - -dist_rubylib_DATA = qmf.rb - -qmfengine.cpp: $(srcdir)/ruby.i - $(SWIG) -ruby -c++ $(SWIG_FLAGS) $(INCLUDES) $(QPID_CXXFLAGS) -I/usr/include -o qmfengine.cpp $(srcdir)/ruby.i - -rubylibarchdir = $(RUBY_LIB_ARCH) -rubylibarch_LTLIBRARIES = qmfengine.la - -qmfengine_la_LDFLAGS = -avoid-version -module -shared -shrext ".$(RUBY_DLEXT)" -qmfengine_la_LIBADD = $(RUBY_LIBS) -L$(top_builddir)/src/.libs -lqpidclient $(top_builddir)/src/libqmfengine.la -qmfengine_la_CXXFLAGS = $(INCLUDES) -I$(RUBY_INC) -I$(RUBY_INC_ARCH) -fno-strict-aliasing -nodist_qmfengine_la_SOURCES = qmfengine.cpp - -CLEANFILES = qmfengine.cpp - -endif # HAVE_RUBY_DEVEL diff --git a/qpid/cpp/bindings/qmf/ruby/qmf.rb b/qpid/cpp/bindings/qmf/ruby/qmf.rb deleted file mode 100644 index d05127db4b..0000000000 --- a/qpid/cpp/bindings/qmf/ruby/qmf.rb +++ /dev/null @@ -1,1528 +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. -# - -require 'qmfengine' -require 'thread' -require 'socket' -require 'monitor' - -module Qmf - - # Pull all the TYPE_* constants into Qmf namespace. Maybe there's an easier way? - Qmfengine.constants.each do |c| - c = c.to_s - if c.index('TYPE_') == 0 or c.index('ACCESS_') == 0 or c.index('DIR_') == 0 or - c.index('CLASS_') == 0 or c.index('SEV_') == 0 - const_set(c, Qmfengine.const_get(c)) - end - end - - module StringHelpers - def ensure_encoding(str) - enc = (Encoding.default_external.name || "UTF-8" rescue "UTF-8") - str.respond_to?(:force_encoding) ? str.force_encoding(enc) : str - end - end - - class Util - include StringHelpers - - def qmf_to_native(val) - case val.getType - when TYPE_UINT8, TYPE_UINT16, TYPE_UINT32 then val.asUint - when TYPE_UINT64 then val.asUint64 - when TYPE_SSTR, TYPE_LSTR then ensure_encoding(val.asString) - when TYPE_ABSTIME then val.asInt64 - when TYPE_DELTATIME then val.asUint64 - when TYPE_REF then ObjectId.new(val.asObjectId) - when TYPE_BOOL then val.asBool - when TYPE_FLOAT then val.asFloat - when TYPE_DOUBLE then val.asDouble - when TYPE_UUID then val.asUuid - when TYPE_INT8, TYPE_INT16, TYPE_INT32 then val.asInt - when TYPE_INT64 then val.asInt64 - when TYPE_MAP then value_to_dict(val) - when TYPE_LIST then value_to_list(val) - when TYPE_OBJECT - when TYPE_ARRAY - end - end - - def native_to_qmf(target, value) - if target.class == Qmfengine::Value - val = target - typecode = val.getType - else - typecode = target - val = Qmfengine::Value.new(typecode) - end - - case typecode - when TYPE_UINT8, TYPE_UINT16, TYPE_UINT32 then val.setUint(value) - when TYPE_UINT64 then val.setUint64(value) - when TYPE_SSTR, TYPE_LSTR then value ? val.setString(value) : val.setString('') - when TYPE_ABSTIME then val.setInt64(value) - when TYPE_DELTATIME then val.setUint64(value) - when TYPE_REF then val.setObjectId(value.impl) - when TYPE_BOOL then value ? val.setBool(value) : val.setBool(0) - when TYPE_FLOAT then val.setFloat(value) - when TYPE_DOUBLE then val.setDouble(value) - when TYPE_UUID then val.setUuid(value) - when TYPE_INT8, TYPE_INT16, TYPE_INT32 then val.setInt(value) - when TYPE_INT64 then val.setInt64(value) - when TYPE_MAP then dict_to_value(val, value) - when TYPE_LIST then list_to_value(val, value) - when TYPE_OBJECT - when TYPE_ARRAY - end - return val - end - - def pick_qmf_type(value) - if value.class == Fixnum - if value >= 0 - return TYPE_UINT32 if value < 0x100000000 - return TYPE_UINT64 - else - return TYPE_INT32 if value > -0xffffffff - return TYPE_INT64 - end - end - - if value.class == Bignum - return TYPE_UINT64 if value >= 0 - return TYPE_INT64 - end - - if value.class == String - return TYPE_SSTR if value.length < 256 - return TYPE_LSTR - end - - return TYPE_DOUBLE if value.class == Float - - return TYPE_BOOL if value.class == TrueClass - return TYPE_BOOL if value.class == FalseClass - return TYPE_BOOL if value.class == NilClass - - return TYPE_MAP if value.class == Hash - return TYPE_LIST if value.class == Array - - raise ArgumentError, "QMF type not known for native type #{value.class}" - end - - def value_to_dict(val) - # Assume val is of type Qmfengine::Value - raise ArgumentError, "value_to_dict must be given a map value" if !val.isMap - map = {} - for i in 0...val.keyCount - key = val.key(i) - map[key] = qmf_to_native(val.byKey(key)) - end - return map - end - - def dict_to_value(val, map) - map.each do |key, value| - raise ArgumentError, "QMF map key must be a string" if key.class != String - typecode = pick_qmf_type(value) - val.insert(key, native_to_qmf(typecode, value)) - end - end - - def value_to_list(val) - # Assume val is of type Qmfengine::Value - raise ArgumentError, "value_to_dict must be given a map value" if !val.isList - list = [] - for i in 0...val.listItemCount - list.push(qmf_to_native(val.listItem(i))) - end - return list - end - - def list_to_value(val, list) - list.each do |value| - typecode = pick_qmf_type(value) - val.appendToList(native_to_qmf(typecode, value)) - end - end - end - - $util = Util.new - - ##============================================================================== - ## CONNECTION - ##============================================================================== - - class ConnectionSettings - include StringHelpers - attr_reader :impl - - def initialize(url = nil) - if url - @impl = Qmfengine::ConnectionSettings.new(url) - else - @impl = Qmfengine::ConnectionSettings.new() - end - end - - def set_attr(key, val) - if val.class == String - v = Qmfengine::Value.new(TYPE_LSTR) - v.setString(val) - elsif val.class == TrueClass or val.class == FalseClass - v = Qmfengine::Value.new(TYPE_BOOL) - v.setBool(val) - elsif val.class == Fixnum - v = Qmfengine::Value.new(TYPE_UINT32) - v.setUint(val) - else - raise ArgumentError, "Value for attribute '#{key}' has unsupported type: #{val.class}" - end - - good = @impl.setAttr(key, v) - raise "Invalid attribute '#{key}'" unless good - end - - def get_attr(key) - _v = @impl.getAttr(key) - if _v.isString() - return ensure_encoding(_v.asString()) - elsif _v.isUint() - return _v.asUint() - elsif _v.isBool() - return _v.asBool() - else - raise Exception("Argument error: value for attribute '#{key}' has unsupported type: #{_v.getType()}") - end - end - - - def method_missing(name_in, *args) - name = name_in.to_s - if name[name.length - 1] == 61 - attr = name[0..name.length - 2] - set_attr(attr, args[0]) - return - else - return get_attr(name) - end - end - end - - class ConnectionHandler - def conn_event_connected(); end - def conn_event_disconnected(error); end - def conn_event_visit(); end - def sess_event_session_closed(context, error); end - def sess_event_recv(context, message); end - end - - class Connection - include MonitorMixin - - attr_reader :impl - - def initialize(settings) - super() - @impl = Qmfengine::ResilientConnection.new(settings.impl) - @sockEngine, @sock = Socket::socketpair(Socket::PF_UNIX, Socket::SOCK_STREAM, 0) - @impl.setNotifyFd(@sockEngine.fileno) - @new_conn_handlers = [] - @conn_handlers_to_delete = [] - @conn_handlers = [] - @connected = nil - - @thread = Thread.new do - run - end - end - - def connected? - @connected - end - - def kick - @impl.notify - end - - def add_conn_handler(handler) - synchronize do - @new_conn_handlers << handler - end - kick - end - - def del_conn_handler(handler) - synchronize do - @conn_handlers_to_delete << handler - end - kick - end - - def run() - eventImpl = Qmfengine::ResilientConnectionEvent.new - new_handlers = nil - del_handlers = nil - bt_count = 0 - - while :true - @sock.read(1) - - synchronize do - new_handlers = @new_conn_handlers - del_handlers = @conn_handlers_to_delete - @new_conn_handlers = [] - @conn_handlers_to_delete = [] - end - - new_handlers.each do |nh| - @conn_handlers << nh - nh.conn_event_connected() if @connected - end - new_handlers = nil - - del_handlers.each do |dh| - d = @conn_handlers.delete(dh) - end - del_handlers = nil - - valid = @impl.getEvent(eventImpl) - while valid - begin - case eventImpl.kind - when Qmfengine::ResilientConnectionEvent::CONNECTED - @connected = :true - @conn_handlers.each { |h| h.conn_event_connected() } - when Qmfengine::ResilientConnectionEvent::DISCONNECTED - @connected = nil - @conn_handlers.each { |h| h.conn_event_disconnected(eventImpl.errorText) } - when Qmfengine::ResilientConnectionEvent::SESSION_CLOSED - eventImpl.sessionContext.handler.sess_event_session_closed(eventImpl.sessionContext, eventImpl.errorText) - when Qmfengine::ResilientConnectionEvent::RECV - eventImpl.sessionContext.handler.sess_event_recv(eventImpl.sessionContext, eventImpl.message) - end - rescue Exception => ex - if bt_count < 2 - bt_count += 1 - end - end - @impl.popEvent - valid = @impl.getEvent(eventImpl) - end - @conn_handlers.each { |h| h.conn_event_visit } - end - end - end - - class Session - attr_reader :handle, :handler - - def initialize(conn, label, handler) - @conn = conn - @label = label - @handler = handler - @handle = Qmfengine::SessionHandle.new - result = @conn.impl.createSession(label, self, @handle) - end - - def destroy() - @conn.impl.destroySession(@handle) - end - end - - ##============================================================================== - ## OBJECTS and EVENTS - ##============================================================================== - - class QmfEvent - attr_reader :impl, :event_class - def initialize(cls, kwargs={}) - @broker = kwargs[:broker] if kwargs.include?(:broker) - @allow_sets = :true - - if cls - @event_class = cls - @impl = Qmfengine::Event.new(@event_class.impl) - elsif kwargs.include?(:impl) - @impl = Qmfengine::Event.new(kwargs[:impl]) - @event_class = SchemaEventClass.new(nil, nil, nil, :impl => @impl.getClass) - end - end - - def arguments - list = [] - @event_class.arguments.each do |arg| - list << [arg, get_attr(arg.name)] - end - return list - end - - def get_attr(name) - val = value(name) - $util.qmf_to_native(val) - end - - def set_attr(name, v) - val = value(name) - $util.native_to_qmf(val, v) - end - - def [](name) - get_attr(name) - end - - def []=(name, value) - set_attr(name, value) - end - - def method_missing(name_in, *args) - # - # Convert the name to a string and determine if it represents an - # attribute assignment (i.e. "attr=") - # - name = name_in.to_s - attr_set = (name[name.length - 1] == 61) - name = name[0..name.length - 2] if attr_set - raise "Sets not permitted on this object" if attr_set && !@allow_sets - - # - # If the name matches an argument name, set or return the value of the argument. - # - @event_class.arguments.each do |arg| - if arg.name == name - if attr_set - return set_attr(name, args[0]) - else - return get_attr(name) - end - end - end - - # - # This name means nothing to us, pass it up the line to the parent - # class's handler. - # - super.method_missing(name_in, args) - end - - private - def value(name) - val = @impl.getValue(name.to_s) - if val.nil? - raise ArgumentError, "Attribute '#{name}' not defined for event #{@event_class.impl.getClassKey.getPackageName}:#{@object_class.impl.getClassKey.getClassName}" - end - return val - end - end - - class QmfObject - include MonitorMixin - attr_reader :impl, :object_class - def initialize(cls, kwargs={}) - super() - @cv = new_cond - @sync_count = 0 - @sync_result = nil - @allow_sets = :false - @broker = kwargs[:broker] if kwargs.include?(:broker) - - if cls - @object_class = cls - @impl = Qmfengine::Object.new(@object_class.impl) - elsif kwargs.include?(:impl) - @impl = Qmfengine::Object.new(kwargs[:impl]) - @object_class = SchemaObjectClass.new(nil, nil, :impl => @impl.getClass) - end - end - - def object_id - return ObjectId.new(@impl.getObjectId) - end - - def properties - list = [] - @object_class.properties.each do |prop| - list << [prop, get_attr(prop.name)] - end - return list - end - - def statistics - list = [] - @object_class.statistics.each do |stat| - list << [stat, get_attr(stat.name)] - end - return list - end - - def get_attr(name) - val = value(name) - $util.qmf_to_native(val) - end - - def set_attr(name, v) - val = value(name) - $util.native_to_qmf(val, v) - end - - def [](name) - get_attr(name) - end - - def []=(name, value) - set_attr(name, value) - end - - def inc_attr(name, by=1) - set_attr(name, get_attr(name) + by) - end - - def dec_attr(name, by=1) - set_attr(name, get_attr(name) - by) - end - - def method_missing(name_in, *args) - # - # Convert the name to a string and determine if it represents an - # attribute assignment (i.e. "attr=") - # - name = name_in.to_s - attr_set = (name[name.length - 1] == 61) - name = name[0..name.length - 2] if attr_set - raise "Sets not permitted on this object" if attr_set && !@allow_sets - - # - # If the name matches a property name, set or return the value of the property. - # - @object_class.properties.each do |prop| - if prop.name == name - if attr_set - return set_attr(name, args[0]) - else - return get_attr(name) - end - end - end - - # - # Do the same for statistics - # - @object_class.statistics.each do |stat| - if stat.name == name - if attr_set - return set_attr(name, args[0]) - else - return get_attr(name) - end - end - end - - # - # If we still haven't found a match for the name, check to see if - # it matches a method name. If so, marshall the arguments and invoke - # the method. - # - @object_class.methods.each do |method| - if method.name == name - raise "Sets not permitted on methods" if attr_set - timeout = 30 - synchronize do - @sync_count = 1 - @impl.invokeMethod(name, _marshall(method, args), self) - @broker.conn.kick if @broker - unless @cv.wait(timeout) { @sync_count == 0 } - raise "Timed out waiting for response" - end - end - - return @sync_result - end - end - - # - # This name means nothing to us, pass it up the line to the parent - # class's handler. - # - super.method_missing(name_in, args) - end - - def _method_result(result) - synchronize do - @sync_result = result - @sync_count -= 1 - @cv.signal - end - end - - # - # Convert a Ruby array of arguments (positional) into a Value object of type "map". - # - private - def _marshall(schema, args) - map = Qmfengine::Value.new(TYPE_MAP) - schema.arguments.each do |arg| - if arg.direction == DIR_IN || arg.direction == DIR_IN_OUT - map.insert(arg.name, Qmfengine::Value.new(arg.typecode)) - end - end - - marshalled = Arguments.new(map) - idx = 0 - schema.arguments.each do |arg| - if arg.direction == DIR_IN || arg.direction == DIR_IN_OUT - marshalled[arg.name] = args[idx] unless args[idx] == nil - idx += 1 - end - end - - return marshalled.map - end - - private - def value(name) - val = @impl.getValue(name.to_s) - if val.nil? - raise ArgumentError, "Attribute '#{name}' not defined for class #{@object_class.impl.getClassKey.getPackageName}:#{@object_class.impl.getClassKey.getClassName}" - end - return val - end - end - - class AgentObject < QmfObject - def initialize(cls, kwargs={}) - super(cls, kwargs) - @allow_sets = :true - end - - def destroy - @impl.destroy - end - - def set_object_id(oid) - @impl.setObjectId(oid.impl) - end - end - - class ConsoleObject < QmfObject - attr_reader :current_time, :create_time, :delete_time - - def initialize(cls, kwargs={}) - super(cls, kwargs) - end - - def update() - raise "No linkage to broker" unless @broker - newer = @broker.console.objects(Query.new(:object_id => object_id)) - raise "Expected exactly one update for this object" unless newer.size == 1 - merge_update(newer[0]) - end - - def merge_update(new_object) - @impl.merge(new_object.impl) - end - - def deleted?() - @impl.isDeleted - end - - def key() - end - end - - class ObjectId - attr_reader :impl, :agent_key - def initialize(impl=nil) - if impl - @impl = Qmfengine::ObjectId.new(impl) - else - @impl = Qmfengine::ObjectId.new - end - @agent_key = "#{@impl.getBrokerBank}.#{@impl.getAgentBank}" - end - - def object_num_high - @impl.getObjectNumHi - end - - def object_num_low - @impl.getObjectNumLo - end - - def ==(other) - return @impl == other.impl - end - - def to_s - @impl.str - end - end - - class Arguments - attr_reader :map - def initialize(map) - @map = map - @by_hash = {} - key_count = @map.keyCount - a = 0 - while a < key_count - key = @map.key(a) - @by_hash[key] = $util.qmf_to_native(@map.byKey(key)) - a += 1 - end - end - - def [] (key) - return @by_hash[key] - end - - def []= (key, value) - @by_hash[key] = value - set(key, value) - end - - def each - @by_hash.each { |k, v| yield(k, v) } - end - - def method_missing(name, *args) - if @by_hash.include?(name.to_s) - return @by_hash[name.to_s] - end - - super.method_missing(name, args) - end - - def set(key, value) - val = @map.byKey(key) - $util.native_to_qmf(val, value) - end - end - - class MethodResponse - include StringHelpers - - def initialize(impl) - @impl = Qmfengine::MethodResponse.new(impl) - end - - def status - @impl.getStatus - end - - def exception - @impl.getException - end - - def text - ensure_encoding(exception.asString) - end - - def args - Arguments.new(@impl.getArgs) - end - - def method_missing(name, *extra_args) - args.__send__(name, extra_args) - end - end - - ##============================================================================== - ## QUERY - ##============================================================================== - - class Query - attr_reader :impl - def initialize(kwargs = {}) - if kwargs.include?(:impl) - @impl = Qmfengine::Query.new(kwargs[:impl]) - else - package = '' - if kwargs.include?(:key) - @impl = Qmfengine::Query.new(kwargs[:key]) - elsif kwargs.include?(:object_id) - @impl = Qmfengine::Query.new(kwargs[:object_id].impl) - else - package = kwargs[:package] if kwargs.include?(:package) - if kwargs.include?(:class) - @impl = Qmfengine::Query.new(kwargs[:class], package) - else - raise ArgumentError, "Invalid arguments, use :key, :object_id or :class[,:package]" - end - end - end - end - - def package_name - @impl.getPackage - end - - def class_name - @impl.getClass - end - - def object_id - objid = @impl.getObjectId - if objid.class == NilClass - return nil - end - return ObjectId.new(objid) - end - end - - ##============================================================================== - ## SCHEMA - ##============================================================================== - - class SchemaArgument - attr_reader :impl - def initialize(name, typecode, kwargs={}) - if kwargs.include?(:impl) - @impl = kwargs[:impl] - else - @impl = Qmfengine::SchemaArgument.new(name, typecode) - @impl.setDirection(kwargs[:dir]) if kwargs.include?(:dir) - @impl.setUnit(kwargs[:unit]) if kwargs.include?(:unit) - @impl.setDesc(kwargs[:desc]) if kwargs.include?(:desc) - end - end - - def name - @impl.getName - end - - def direction - @impl.getDirection - end - - def typecode - @impl.getType - end - - def to_s - name - end - end - - class SchemaMethod - attr_reader :impl, :arguments - def initialize(name, kwargs={}) - @arguments = [] - if kwargs.include?(:impl) - @impl = kwargs[:impl] - arg_count = @impl.getArgumentCount - for i in 0...arg_count - @arguments << SchemaArgument.new(nil, nil, :impl => @impl.getArgument(i)) - end - else - @impl = Qmfengine::SchemaMethod.new(name) - @impl.setDesc(kwargs[:desc]) if kwargs.include?(:desc) - end - end - - def add_argument(arg) - @arguments << arg - @impl.addArgument(arg.impl) - end - - def name - @impl.getName - end - - def to_s - name - end - end - - class SchemaProperty - attr_reader :impl - def initialize(name, typecode, kwargs={}) - if kwargs.include?(:impl) - @impl = kwargs[:impl] - else - @impl = Qmfengine::SchemaProperty.new(name, typecode) - @impl.setAccess(kwargs[:access]) if kwargs.include?(:access) - @impl.setIndex(kwargs[:index]) if kwargs.include?(:index) - @impl.setOptional(kwargs[:optional]) if kwargs.include?(:optional) - @impl.setUnit(kwargs[:unit]) if kwargs.include?(:unit) - @impl.setDesc(kwargs[:desc]) if kwargs.include?(:desc) - end - end - - def name - @impl.getName - end - - def to_s - name - end - end - - class SchemaStatistic - attr_reader :impl - def initialize(name, typecode, kwargs={}) - if kwargs.include?(:impl) - @impl = kwargs[:impl] - else - @impl = Qmfengine::SchemaStatistic.new(name, typecode) - @impl.setUnit(kwargs[:unit]) if kwargs.include?(:unit) - @impl.setDesc(kwargs[:desc]) if kwargs.include?(:desc) - end - end - - def name - @impl.getName - end - - def to_s - name - end - end - - class SchemaClassKey - include StringHelpers - attr_reader :impl - def initialize(i) - @impl = Qmfengine::SchemaClassKey.new(i) - end - - def package_name - @impl.getPackageName - end - - def class_name - @impl.getClassName - end - - def to_s - ensure_encoding(@impl.asString) - end - end - - class SchemaObjectClass - attr_reader :impl, :properties, :statistics, :methods - def initialize(package, name, kwargs={}) - @properties = [] - @statistics = [] - @methods = [] - if kwargs.include?(:impl) - @impl = kwargs[:impl] - - @impl.getPropertyCount.times do |i| - @properties << SchemaProperty.new(nil, nil, :impl => @impl.getProperty(i)) - end - - @impl.getStatisticCount.times do |i| - @statistics << SchemaStatistic.new(nil, nil, :impl => @impl.getStatistic(i)) - end - - @impl.getMethodCount.times do |i| - @methods << SchemaMethod.new(nil, :impl => @impl.getMethod(i)) - end - else - @impl = Qmfengine::SchemaObjectClass.new(package, name) - end - end - - def add_property(prop) - @properties << prop - @impl.addProperty(prop.impl) - end - - def add_statistic(stat) - @statistics << stat - @impl.addStatistic(stat.impl) - end - - def add_method(meth) - @methods << meth - @impl.addMethod(meth.impl) - end - - def class_key - SchemaClassKey.new(@impl.getClassKey) - end - - def package_name - @impl.getClassKey.getPackageName - end - - def class_name - @impl.getClassKey.getClassName - end - end - - class SchemaEventClass - attr_reader :impl, :arguments - def initialize(package, name, sev, kwargs={}) - @arguments = [] - if kwargs.include?(:impl) - @impl = kwargs[:impl] - @impl.getArgumentCount.times do |i| - @arguments << SchemaArgument.new(nil, nil, :impl => @impl.getArgument(i)) - end - else - @impl = Qmfengine::SchemaEventClass.new(package, name, sev) - @impl.setDesc(kwargs[:desc]) if kwargs.include?(:desc) - end - end - - def add_argument(arg) - @arguments << arg - @impl.addArgument(arg.impl) - end - - def name - @impl.getClassKey.getClassName - end - - def class_key - SchemaClassKey.new(@impl.getClassKey) - end - - def package_name - @impl.getClassKey.getPackageName - end - - def class_name - @impl.getClassKey.getClassName - end - end - - ##============================================================================== - ## CONSOLE - ##============================================================================== - - class ConsoleHandler - def agent_added(agent); end - def agent_deleted(agent); end - def new_package(package); end - def new_class(class_key); end - def object_update(object, hasProps, hasStats); end - def event_received(event); end - def agent_heartbeat(agent, timestamp); end - def method_response(resp); end - def broker_info(broker); end - end - - class Console - include MonitorMixin - attr_reader :impl - - def initialize(handler = nil, kwargs={}) - super() - @handler = handler - @impl = Qmfengine::Console.new - @event = Qmfengine::ConsoleEvent.new - @broker_list = [] - @cv = new_cond - @sync_count = nil - @sync_result = nil - @select = [] - @bt_count = 0 - @cb_cond = new_cond - @cb_thread = Thread.new do - run_cb_thread - end - end - - def add_connection(conn) - broker = Broker.new(self, conn) - synchronize { @broker_list << broker } - return broker - end - - def del_connection(broker) - broker.shutdown - synchronize { @broker_list.delete(broker) } - end - - def packages() - plist = [] - count = @impl.packageCount - for i in 0...count - plist << @impl.getPackageName(i) - end - return plist - end - - def classes(package, kind=CLASS_OBJECT) - clist = [] - count = @impl.classCount(package) - for i in 0...count - key = @impl.getClass(package, i) - class_kind = @impl.getClassKind(key) - if class_kind == kind - if kind == CLASS_OBJECT - clist << SchemaObjectClass.new(nil, nil, :impl => @impl.getObjectClass(key)) - elsif kind == CLASS_EVENT - clist << SchemaEventClass.new(nil, nil, nil, :impl => @impl.getEventClass(key)) - end - end - end - - return clist - end - - def bind_package(package) - @impl.bindPackage(package) - end - - def bind_class(kwargs = {}) - if kwargs.include?(:key) - @impl.bindClass(kwargs[:key]) - elsif kwargs.include?(:package) - package = kwargs[:package] - if kwargs.include?(:class) - @impl.bindClass(package, kwargs[:class]) - else - @impl.bindClass(package) - end - else - raise ArgumentError, "Invalid arguments, use :key or :package[,:class]" - end - end - - def bind_event(kwargs = {}) - if kwargs.include?(:key) - @impl.bindEvent(kwargs[:key]) - elsif kwargs.include?(:package) - package = kwargs[:package] - if kwargs.include?(:event) - @impl.bindEvent(package, kwargs[:event]) - else - @impl.bindEvent(package, "*") - end - else - raise ArgumentError, "Invalid arguments, use :key or :package[,:event]" - end - end - - def agents(broker = nil) - blist = [] - if broker - blist << broker - else - synchronize { blist = @broker_list } - end - - agents = [] - blist.each do |b| - count = b.impl.agentCount - for idx in 0...count - agents << AgentProxy.new(b.impl.getAgent(idx), b) - end - end - - return agents - end - - def objects(query, kwargs = {}) - timeout = 30 - agent = nil - kwargs.merge!(query) if query.class == Hash - - if kwargs.include?(:timeout) - timeout = kwargs[:timeout] - kwargs.delete(:timeout) - end - - if kwargs.include?(:agent) - agent = kwargs[:agent] - kwargs.delete(:agent) - end - - query = Query.new(kwargs) if query.class == Hash - - @select = [] - kwargs.each do |k,v| - @select << [k, v] if k.is_a?(String) - end - - synchronize do - @sync_count = 1 - @sync_result = [] - broker = nil - synchronize { broker = @broker_list[0] } - broker.send_query(query.impl, nil, agent) - unless @cv.wait(timeout) { @sync_count == 0 } - raise "Timed out waiting for response" - end - - return @sync_result - end - end - - # Return one and only one object or nil. - def object(query, kwargs = {}) - objs = objects(query, kwargs) - return objs.length == 1 ? objs[0] : nil - end - - # Return the first of potentially many objects. - def first_object(query, kwargs = {}) - objs = objects(query, kwargs) - return objs.length > 0 ? objs[0] : nil - end - - # Check the object against select to check for a match - def select_match(object) - @select.each do |key, value| - object.properties.each do |prop, propval| - if key == prop.name && value != propval - return nil - end - end - end - return :true - end - - def _get_result(list, context) - synchronize do - list.each do |item| - @sync_result << item if select_match(item) - end - @sync_count -= 1 - @cv.signal - end - end - - def start_sync(query) - end - - def touch_sync(sync) - end - - def end_sync(sync) - end - - def run_cb_thread - while :true - synchronize { @cb_cond.wait(1) } - begin - count = do_console_events - end until count == 0 - end - end - - def start_console_events - synchronize { @cb_cond.signal } - end - - def do_console_events - count = 0 - valid = @impl.getEvent(@event) - while valid - count += 1 - begin - case @event.kind - when Qmfengine::ConsoleEvent::AGENT_ADDED - @handler.agent_added(AgentProxy.new(@event.agent, nil)) if @handler - when Qmfengine::ConsoleEvent::AGENT_DELETED - @handler.agent_deleted(AgentProxy.new(@event.agent, nil)) if @handler - when Qmfengine::ConsoleEvent::NEW_PACKAGE - @handler.new_package(@event.name) if @handler - when Qmfengine::ConsoleEvent::NEW_CLASS - @handler.new_class(SchemaClassKey.new(@event.classKey)) if @handler - when Qmfengine::ConsoleEvent::OBJECT_UPDATE - @handler.object_update(ConsoleObject.new(nil, :impl => @event.object), @event.hasProps, @event.hasStats) if @handler - when Qmfengine::ConsoleEvent::EVENT_RECEIVED - @handler.event_received(QmfEvent.new(nil, :impl => @event.event)) if @handler - when Qmfengine::ConsoleEvent::AGENT_HEARTBEAT - @handler.agent_heartbeat(AgentProxy.new(@event.agent, nil), @event.timestamp) if @handler - when Qmfengine::ConsoleEvent::METHOD_RESPONSE - end - rescue Exception => ex - if @bt_count < 2 - @bt_count += 1 - end - end - @impl.popEvent - valid = @impl.getEvent(@event) - end - return count - end - end - - class AgentProxy - attr_reader :impl, :broker, :label, :key - - def initialize(impl, broker) - @impl = Qmfengine::AgentProxy.new(impl) - @broker = broker - @label = @impl.getLabel - @key = "#{@impl.getBrokerBank}.#{@impl.getAgentBank}" - end - end - - class Broker < ConnectionHandler - include MonitorMixin - attr_reader :impl, :conn, :console, :broker_bank - - def initialize(console, conn) - super() - @broker_bank = 1 - @console = console - @conn = conn - @session = nil - @cv = new_cond - @stable = nil - @event = Qmfengine::BrokerEvent.new - @xmtMessage = Qmfengine::Message.new - @impl = Qmfengine::BrokerProxy.new(@console.impl) - @console.impl.addConnection(@impl, self) - @conn.add_conn_handler(self) - @operational = :true - end - - def shutdown() - @console.impl.delConnection(@impl) - @conn.del_conn_handler(self) - @operational = :false - end - - def wait_for_stable(timeout = nil) - synchronize do - return if @stable - if timeout - unless @cv.wait(timeout) { @stable } - raise "Timed out waiting for broker connection to become stable" - end - else - while not @stable - @cv.wait - end - end - end - end - - def send_query(query, ctx, agent) - agent_impl = agent.impl if agent - @impl.sendQuery(query, ctx, agent_impl) - @conn.kick - end - - def do_broker_events() - count = 0 - valid = @impl.getEvent(@event) - while valid - count += 1 - case @event.kind - when Qmfengine::BrokerEvent::BROKER_INFO - when Qmfengine::BrokerEvent::DECLARE_QUEUE - @conn.impl.declareQueue(@session.handle, @event.name) - when Qmfengine::BrokerEvent::DELETE_QUEUE - @conn.impl.deleteQueue(@session.handle, @event.name) - when Qmfengine::BrokerEvent::BIND - @conn.impl.bind(@session.handle, @event.exchange, @event.name, @event.bindingKey) - when Qmfengine::BrokerEvent::UNBIND - @conn.impl.unbind(@session.handle, @event.exchange, @event.name, @event.bindingKey) - when Qmfengine::BrokerEvent::SETUP_COMPLETE - @impl.startProtocol - when Qmfengine::BrokerEvent::STABLE - synchronize do - @stable = :true - @cv.signal - end - when Qmfengine::BrokerEvent::QUERY_COMPLETE - result = [] - for idx in 0...@event.queryResponse.getObjectCount - result << ConsoleObject.new(nil, :impl => @event.queryResponse.getObject(idx), :broker => self) - end - @console._get_result(result, @event.context) - when Qmfengine::BrokerEvent::METHOD_RESPONSE - obj = @event.context - obj._method_result(MethodResponse.new(@event.methodResponse)) - end - @impl.popEvent - valid = @impl.getEvent(@event) - end - return count - end - - def do_broker_messages() - count = 0 - valid = @impl.getXmtMessage(@xmtMessage) - while valid - count += 1 - @conn.impl.sendMessage(@session.handle, @xmtMessage) - @impl.popXmt - valid = @impl.getXmtMessage(@xmtMessage) - end - return count - end - - def do_events() - begin - @console.start_console_events - bcnt = do_broker_events - mcnt = do_broker_messages - end until bcnt == 0 and mcnt == 0 - end - - def conn_event_connected() - @session = Session.new(@conn, "qmfc-%s.%d" % [Socket.gethostname, Process::pid], self) - @impl.sessionOpened(@session.handle) - do_events - end - - def conn_event_disconnected(error) - - end - - def conn_event_visit - do_events - end - - def sess_event_session_closed(context, error) - @impl.sessionClosed() - end - - def sess_event_recv(context, message) - @impl.handleRcvMessage(message) - do_events - end - end - - ##============================================================================== - ## AGENT - ##============================================================================== - - class AgentHandler - def get_query(context, query, userId); end - def method_call(context, name, object_id, args, userId); end - end - - class Agent < ConnectionHandler - def initialize(handler, label="") - if label == "" - @agentLabel = "rb-%s.%d" % [Socket.gethostname, Process::pid] - else - @agentLabel = label - end - @conn = nil - @handler = handler - @impl = Qmfengine::Agent.new(@agentLabel) - @event = Qmfengine::AgentEvent.new - @xmtMessage = Qmfengine::Message.new - end - - def set_connection(conn) - @conn = conn - @conn.add_conn_handler(self) - end - - def register_class(cls) - @impl.registerClass(cls.impl) - end - - def alloc_object_id(low = 0, high = 0) - ObjectId.new(@impl.allocObjectId(low, high)) - end - - def raise_event(event) - @impl.raiseEvent(event.impl) - end - - def query_response(context, object) - @impl.queryResponse(context, object.impl) - end - - def query_complete(context) - @impl.queryComplete(context) - end - - def method_response(context, status, text, arguments) - @impl.methodResponse(context, status, text, arguments.map) - end - - def do_agent_events() - count = 0 - valid = @impl.getEvent(@event) - while valid - count += 1 - case @event.kind - when Qmfengine::AgentEvent::GET_QUERY - @handler.get_query(@event.sequence, Query.new(:impl => @event.query), @event.authUserId) - when Qmfengine::AgentEvent::START_SYNC - when Qmfengine::AgentEvent::END_SYNC - when Qmfengine::AgentEvent::METHOD_CALL - args = Arguments.new(@event.arguments) - @handler.method_call(@event.sequence, @event.name, ObjectId.new(@event.objectId), - args, @event.authUserId) - when Qmfengine::AgentEvent::DECLARE_QUEUE - @conn.impl.declareQueue(@session.handle, @event.name) - when Qmfengine::AgentEvent::DELETE_QUEUE - @conn.impl.deleteQueue(@session.handle, @event.name) - when Qmfengine::AgentEvent::BIND - @conn.impl.bind(@session.handle, @event.exchange, @event.name, @event.bindingKey) - when Qmfengine::AgentEvent::UNBIND - @conn.impl.unbind(@session.handle, @event.exchange, @event.name, @event.bindingKey) - when Qmfengine::AgentEvent::SETUP_COMPLETE - @impl.startProtocol() - end - @impl.popEvent - valid = @impl.getEvent(@event) - end - return count - end - - def do_agent_messages() - count = 0 - valid = @impl.getXmtMessage(@xmtMessage) - while valid - count += 1 - @conn.impl.sendMessage(@session.handle, @xmtMessage) - @impl.popXmt - valid = @impl.getXmtMessage(@xmtMessage) - end - return count - end - - def do_events() - begin - ecnt = do_agent_events - mcnt = do_agent_messages - end until ecnt == 0 and mcnt == 0 - end - - def conn_event_connected() - @session = Session.new(@conn, "qmfa-%s.%d" % [Socket.gethostname, Process::pid], self) - @impl.newSession - do_events - end - - def conn_event_disconnected(error) - - end - - def conn_event_visit - do_events - end - - def sess_event_session_closed(context, error) - - end - - def sess_event_recv(context, message) - @impl.handleRcvMessage(message) - do_events - end - end -end diff --git a/qpid/cpp/bindings/qmf/ruby/ruby.i b/qpid/cpp/bindings/qmf/ruby/ruby.i deleted file mode 100644 index 2854aa0c7e..0000000000 --- a/qpid/cpp/bindings/qmf/ruby/ruby.i +++ /dev/null @@ -1,106 +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. - */ - -%include stl.i - -%module qmfengine - -%typemap (in) void * -{ - $1 = (void *) $input; -} - -%typemap (out) void * -{ - $result = (VALUE) $1; -} - -%typemap (in) uint16_t -{ - $1 = NUM2UINT ($input); -} - -%typemap (out) uint16_t -{ - $result = UINT2NUM((uint16_t) $1); -} - -%typemap (in) uint32_t -{ - if (TYPE($input) == T_BIGNUM) - $1 = NUM2UINT($input); - else - $1 = FIX2UINT($input); -} - -%typemap (out) uint32_t -{ - $result = UINT2NUM((uint32_t) $1); -} - -%typemap (in) int32_t -{ - if (TYPE($input) == T_BIGNUM) - $1 = NUM2INT($input); - else - $1 = FIX2INT($input); -} - -%typemap (out) int32_t -{ - $result = INT2NUM((int32_t) $1); -} - -%typemap (typecheck, precedence=SWIG_TYPECHECK_INTEGER) uint32_t { - $1 = FIXNUM_P($input); -} - -%typemap (in) uint64_t -{ - if (TYPE($input) == T_BIGNUM) - $1 = NUM2ULL($input); - else - $1 = (uint64_t) FIX2ULONG($input); -} - -%typemap (out) uint64_t -{ - $result = ULL2NUM((uint64_t) $1); -} - -%typemap (in) int64_t -{ - if (TYPE($input) == T_BIGNUM) - $1 = NUM2LL($input); - else - $1 = (int64_t) FIX2LONG($input); -} - -%typemap (out) int64_t -{ - $result = LL2NUM((int64_t) $1); -} - -%typemap (typecheck, precedence=SWIG_TYPECHECK_INTEGER) uint64_t { - $1 = FIXNUM_P($input); -} - - -%include "qmf/qmfengine.i" - diff --git a/qpid/cpp/bindings/qmf/tests/Makefile.am b/qpid/cpp/bindings/qmf/tests/Makefile.am deleted file mode 100644 index 182771e16b..0000000000 --- a/qpid/cpp/bindings/qmf/tests/Makefile.am +++ /dev/null @@ -1,27 +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. -# - -TESTS = run_interop_tests - -EXTRA_DIST = \ - agent_ruby.rb \ - python_agent.py \ - python_console.py \ - ruby_console.rb \ - run_interop_tests diff --git a/qpid/cpp/bindings/qmf/tests/agent_ruby.rb b/qpid/cpp/bindings/qmf/tests/agent_ruby.rb deleted file mode 100755 index 5ee5e371d3..0000000000 --- a/qpid/cpp/bindings/qmf/tests/agent_ruby.rb +++ /dev/null @@ -1,279 +0,0 @@ -#!/usr/bin/ruby - -# -# 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. -# - -require 'qmf' -require 'socket' - -class Model - attr_reader :parent_class, :child_class, :event_class - - def initialize - @parent_class = Qmf::SchemaObjectClass.new("org.apache.qpid.qmf", "parent") - @parent_class.add_property(Qmf::SchemaProperty.new("name", Qmf::TYPE_SSTR, :index => true)) - @parent_class.add_property(Qmf::SchemaProperty.new("state", Qmf::TYPE_SSTR)) - - @parent_class.add_property(Qmf::SchemaProperty.new("uint64val", Qmf::TYPE_UINT64)) - @parent_class.add_property(Qmf::SchemaProperty.new("uint32val", Qmf::TYPE_UINT32)) - @parent_class.add_property(Qmf::SchemaProperty.new("uint16val", Qmf::TYPE_UINT16)) - @parent_class.add_property(Qmf::SchemaProperty.new("uint8val", Qmf::TYPE_UINT8)) - - @parent_class.add_property(Qmf::SchemaProperty.new("int64val", Qmf::TYPE_INT64)) - @parent_class.add_property(Qmf::SchemaProperty.new("int32val", Qmf::TYPE_INT32)) - @parent_class.add_property(Qmf::SchemaProperty.new("int16val", Qmf::TYPE_INT16)) - @parent_class.add_property(Qmf::SchemaProperty.new("int8val", Qmf::TYPE_INT8)) - - @parent_class.add_property(Qmf::SchemaProperty.new("sstrval", Qmf::TYPE_SSTR)) - @parent_class.add_property(Qmf::SchemaProperty.new("lstrval", Qmf::TYPE_LSTR)) - - @parent_class.add_property(Qmf::SchemaProperty.new("mapval", Qmf::TYPE_MAP)) - @parent_class.add_property(Qmf::SchemaProperty.new("listval", Qmf::TYPE_LIST)) - - @parent_class.add_statistic(Qmf::SchemaStatistic.new("queryCount", Qmf::TYPE_UINT32, :unit => "query", :desc => "Query count")) - - method = Qmf::SchemaMethod.new("echo", :desc => "Check responsiveness of the agent object") - method.add_argument(Qmf::SchemaArgument.new("sequence", Qmf::TYPE_UINT32, :dir => Qmf::DIR_IN_OUT)) - @parent_class.add_method(method) - - method = Qmf::SchemaMethod.new("set_numerics", :desc => "Set the numeric values in the object") - method.add_argument(Qmf::SchemaArgument.new("test", Qmf::TYPE_SSTR, :dir => Qmf::DIR_IN)) - @parent_class.add_method(method) - - method = Qmf::SchemaMethod.new("test_map_list", :desc => "A method call that accepts map and list arguments.") - method.add_argument(Qmf::SchemaArgument.new("inMap", Qmf::TYPE_MAP, :dir => Qmf::DIR_IN)) - method.add_argument(Qmf::SchemaArgument.new("inList", Qmf::TYPE_LIST, :dir => Qmf::DIR_IN)) - method.add_argument(Qmf::SchemaArgument.new("outMap", Qmf::TYPE_MAP, :dir => Qmf::DIR_OUT)) - method.add_argument(Qmf::SchemaArgument.new("outList", Qmf::TYPE_LIST, :dir => Qmf::DIR_OUT)) - @parent_class.add_method(method) - - method = Qmf::SchemaMethod.new("set_short_string", :desc => "Set the short string value in the object") - method.add_argument(Qmf::SchemaArgument.new("value", Qmf::TYPE_SSTR, :dir => Qmf::DIR_IN_OUT)) - @parent_class.add_method(method) - - method = Qmf::SchemaMethod.new("set_long_string", :desc => "Set the long string value in the object") - method.add_argument(Qmf::SchemaArgument.new("value", Qmf::TYPE_LSTR, :dir => Qmf::DIR_IN_OUT)) - @parent_class.add_method(method) - - method = Qmf::SchemaMethod.new("create_child", :desc => "Create a new child object") - method.add_argument(Qmf::SchemaArgument.new("child_name", Qmf::TYPE_LSTR, :dir => Qmf::DIR_IN)) - method.add_argument(Qmf::SchemaArgument.new("child_ref", Qmf::TYPE_REF, :dir => Qmf::DIR_OUT)) - @parent_class.add_method(method) - - method = Qmf::SchemaMethod.new("probe_userid", :desc => "Return the user-id for this method call") - method.add_argument(Qmf::SchemaArgument.new("userid", Qmf::TYPE_SSTR, :dir => Qmf::DIR_OUT)) - @parent_class.add_method(method) - - @child_class = Qmf::SchemaObjectClass.new("org.apache.qpid.qmf", "child") - @child_class.add_property(Qmf::SchemaProperty.new("name", Qmf::TYPE_SSTR, :index => true)) - - @event_class = Qmf::SchemaEventClass.new("org.apache.qpid.qmf", "test_event", Qmf::SEV_INFORM) - @event_class.add_argument(Qmf::SchemaArgument.new("uint32val", Qmf::TYPE_UINT32)) - @event_class.add_argument(Qmf::SchemaArgument.new("strval", Qmf::TYPE_LSTR)) - @event_class.add_argument(Qmf::SchemaArgument.new("mapval", Qmf::TYPE_MAP)) - @event_class.add_argument(Qmf::SchemaArgument.new("listval", Qmf::TYPE_LIST)) - end - - def register(agent) - agent.register_class(@parent_class) - agent.register_class(@child_class) - agent.register_class(@event_class) - end -end - - -class App < Qmf::AgentHandler - def get_query(context, query, userId) -# puts "Query: user=#{userId} context=#{context} class=#{query.class_name} object_num=#{query.object_id if query.object_id}" - if query.class_name == 'parent' - @agent.query_response(context, @parent) - elsif query.object_id == @parent_oid - @agent.query_response(context, @parent) - end - @agent.query_complete(context) - end - - def method_call(context, name, object_id, args, userId) -# puts "Method: user=#{userId} context=#{context} method=#{name} object_num=#{object_id if object_id} args=#{args}" - - retCode = 0 - retText = "OK" - - if name == "echo" - @agent.method_response(context, 0, "OK", args) - - elsif name == "test_map_list" - # build the output map from the input map, accessing each key, - # value to ensure they are encoded/decoded - outMap = {} - args['inMap'].each do |k,v| - outMap[k] = v - end - - # same deal for the output list - outList = [] - args['inList'].each do |v| - outList << v - end - - args['outMap'] = outMap - args['outList'] = outList - - elsif name == "set_numerics" - - if args['test'] == "big" - @parent.uint64val = 0x9494949449494949 - @parent.uint32val = 0xa5a55a5a - @parent.uint16val = 0xb66b - @parent.uint8val = 0xc7 - - @parent.int64val = 1000000000000000000 - @parent.int32val = 1000000000 - @parent.int16val = 10000 - @parent.int8val = 100 - - event = Qmf::QmfEvent.new(@model.event_class) - event.uint32val = @parent.uint32val - event.strval = "Unused" - event.mapval = @parent.mapval - event.listval = @parent.listval - @agent.raise_event(event) - - elsif args['test'] == "small" - @parent.uint64val = 4 - @parent.uint32val = 5 - @parent.uint16val = 6 - @parent.uint8val = 7 - - @parent.int64val = 8 - @parent.int32val = 9 - @parent.int16val = 10 - @parent.int8val = 11 - - event = Qmf::QmfEvent.new(@model.event_class) - event.uint32val = @parent.uint32val - event.strval = "Unused" - @agent.raise_event(event) - - elsif args['test'] == "negative" - @parent.uint64val = 0 - @parent.uint32val = 0 - @parent.uint16val = 0 - @parent.uint8val = 0 - - @parent.int64val = -10000000000 - @parent.int32val = -100000 - @parent.int16val = -1000 - @parent.int8val = -100 - - event = Qmf::QmfEvent.new(@model.event_class) - event.uint32val = @parent.uint32val - event.strval = "Unused" - @agent.raise_event(event) - - else - retCode = 1 - retText = "Invalid argument value for test" - end - - elsif name == "set_short_string" - @parent.sstrval = args['value'] - - event = Qmf::QmfEvent.new(@model.event_class) - event.uint32val = 0 - event.strval = @parent.sstrval - @agent.raise_event(event) - - elsif name == "set_long_string" - @parent.lstrval = args['value'] - - event = Qmf::QmfEvent.new(@model.event_class) - event.uint32val = 0 - event.strval = @parent.lstrval - @agent.raise_event(event) - - elsif name == "create_child" - oid = @agent.alloc_object_id(2) - args['child_ref'] = oid - @child = Qmf::AgentObject.new(@model.child_class) - @child.name = args.by_key("child_name") - @child.set_object_id(oid) - - elsif name == "probe_userid" - args['userid'] = userId - - else - retCode = 1 - retText = "Unimplemented Method: #{name}" - end - - @agent.method_response(context, retCode, retText, args) - end - - def main - @settings = Qmf::ConnectionSettings.new - @settings.set_attr("host", ARGV[0]) if ARGV.size > 0 - @settings.set_attr("port", ARGV[1].to_i) if ARGV.size > 1 - @connection = Qmf::Connection.new(@settings) - @agent = Qmf::Agent.new(self, "agent_test_label") - - @model = Model.new - @model.register(@agent) - - @agent.set_connection(@connection) - - @parent = Qmf::AgentObject.new(@model.parent_class) - @parent.name = "Parent One" - @parent.state = "OPERATIONAL" - - @parent.uint64val = 0 - @parent.uint32val = 0 - @parent.uint16val = 0 - @parent.uint8val = 0 - - @parent.int64val = 0 - @parent.int32val = 0 - @parent.int16val = 0 - @parent.int8val = 0 - - # a list containing a list that contains a map (so there!) - @parent.listval = ['a', 1, 'b', -2, - ['c', true, 3.1415, - {"hi" => 10, "lo" => 5, "neg" => -3}]] - - # a default map - @parent.mapval = {'aLong' => 9999999999, - 'aInt' => 54321, - 'aSigned' => -666, - 'aString' => "A String", - 'aFloat'=> 3.1415, - 'aMap' => {"first" => 1, "second" => 2}, - 'aList' => ['x', -1, 'y', 2]} - - @parent_oid = @agent.alloc_object_id(1) - @parent.set_object_id(@parent_oid) - - sleep - end -end - -app = App.new -app.main - - diff --git a/qpid/cpp/bindings/qmf/tests/python_agent.py b/qpid/cpp/bindings/qmf/tests/python_agent.py deleted file mode 100644 index 28ba47e1bb..0000000000 --- a/qpid/cpp/bindings/qmf/tests/python_agent.py +++ /dev/null @@ -1,326 +0,0 @@ -#!/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 qmf -import sys -import time - - -class Model: - # attr_reader :parent_class, :child_class - def __init__(self): - self.parent_class = qmf.SchemaObjectClass("org.apache.qpid.qmf", "parent") - self.parent_class.add_property(qmf.SchemaProperty("name", qmf.TYPE_SSTR, {"index":True})) - self.parent_class.add_property(qmf.SchemaProperty("state", qmf.TYPE_SSTR)) - - self.parent_class.add_property(qmf.SchemaProperty("uint64val", qmf.TYPE_UINT64)) - self.parent_class.add_property(qmf.SchemaProperty("uint32val", qmf.TYPE_UINT32)) - self.parent_class.add_property(qmf.SchemaProperty("uint16val", qmf.TYPE_UINT16)) - self.parent_class.add_property(qmf.SchemaProperty("uint8val", qmf.TYPE_UINT8)) - - self.parent_class.add_property(qmf.SchemaProperty("int64val", qmf.TYPE_INT64)) - self.parent_class.add_property(qmf.SchemaProperty("int32val", qmf.TYPE_INT32)) - self.parent_class.add_property(qmf.SchemaProperty("int16val", qmf.TYPE_INT16)) - self.parent_class.add_property(qmf.SchemaProperty("int8val", qmf.TYPE_INT8)) - - self.parent_class.add_property(qmf.SchemaProperty("sstrval", qmf.TYPE_SSTR)) - self.parent_class.add_property(qmf.SchemaProperty("lstrval", qmf.TYPE_LSTR)) - - self.parent_class.add_property(qmf.SchemaProperty("mapval", qmf.TYPE_MAP)) - self.parent_class.add_property(qmf.SchemaProperty("listval", qmf.TYPE_LIST)) - - - self.parent_class.add_statistic(qmf.SchemaStatistic("queryCount", qmf.TYPE_UINT32, {"unit":"query", "desc":"Query count"})) - - _method = qmf.SchemaMethod("echo", {"desc":"Check responsiveness of the agent object"}) - _method.add_argument(qmf.SchemaArgument("sequence", qmf.TYPE_UINT32, {"dir":qmf.DIR_IN_OUT})) - self.parent_class.add_method(_method) - - _method = qmf.SchemaMethod("set_numerics", {"desc":"Set the numeric values in the object"}) - _method.add_argument(qmf.SchemaArgument("test", qmf.TYPE_SSTR, {"dir":qmf.DIR_IN})) - self.parent_class.add_method(_method) - - _method = qmf.SchemaMethod("test_map_list", {"desc":"A method call that accepts map and list arguments."}) - _method.add_argument(qmf.SchemaArgument("inMap", qmf.TYPE_MAP, {"dir":qmf.DIR_IN})) - _method.add_argument(qmf.SchemaArgument("inList", qmf.TYPE_LIST, {"dir":qmf.DIR_IN})) - _method.add_argument(qmf.SchemaArgument("outMap", qmf.TYPE_MAP, {"dir":qmf.DIR_OUT})) - _method.add_argument(qmf.SchemaArgument("outList", qmf.TYPE_LIST, {"dir":qmf.DIR_OUT})) - self.parent_class.add_method(_method) - - _method = qmf.SchemaMethod("set_short_string", {"desc":"Set the short string value in the object"}) - _method.add_argument(qmf.SchemaArgument("value", qmf.TYPE_SSTR, {"dir":qmf.DIR_IN_OUT})) - self.parent_class.add_method(_method) - - _method = qmf.SchemaMethod("set_long_string", {"desc":"Set the long string value in the object"}) - _method.add_argument(qmf.SchemaArgument("value", qmf.TYPE_LSTR, {"dir":qmf.DIR_IN_OUT})) - self.parent_class.add_method(_method) - - _method = qmf.SchemaMethod("create_child", {"desc":"Create a new child object"}) - _method.add_argument(qmf.SchemaArgument("child_name", qmf.TYPE_LSTR, {"dir":qmf.DIR_IN})) - _method.add_argument(qmf.SchemaArgument("child_ref", qmf.TYPE_REF, {"dir":qmf.DIR_OUT})) - self.parent_class.add_method(_method) - - _method = qmf.SchemaMethod("probe_userid", {"desc":"Return the user-id for this method call"}) - _method.add_argument(qmf.SchemaArgument("userid", qmf.TYPE_SSTR, {"dir":qmf.DIR_OUT})) - self.parent_class.add_method(_method) - - self.child_class = qmf.SchemaObjectClass("org.apache.qpid.qmf", "child") - self.child_class.add_property(qmf.SchemaProperty("name", qmf.TYPE_SSTR, {"index":True})) - - self.event_class = qmf.SchemaEventClass("org.apache.qpid.qmf", "test_event", qmf.SEV_NOTICE) - self.event_class.add_argument(qmf.SchemaArgument("uint32val", qmf.TYPE_UINT32)) - self.event_class.add_argument(qmf.SchemaArgument("strval", qmf.TYPE_LSTR)) - self.event_class.add_argument(qmf.SchemaArgument("mapval", qmf.TYPE_MAP)) - self.event_class.add_argument(qmf.SchemaArgument("listval", qmf.TYPE_LIST)) - - def register(self, agent): - agent.register_class(self.parent_class) - agent.register_class(self.child_class) - agent.register_class(self.event_class) - - - -class App(qmf.AgentHandler): - ''' - Object that handles events received by the Agent. - ''' - def get_query(self, context, query, userId): - ''' - Respond to a Query request from a console. - ''' - #print "Query: user=%s context=%d class=%s" % (userId, context, query.class_name()) - #if query.object_id(): - # print query.object_id().object_num_low() - self._parent.inc_attr("queryCount") - if query.class_name() == 'parent': - self._agent.query_response(context, self._parent) - elif query.object_id() == self._parent_oid: - self._agent.query_response(context, self._parent) - self._agent.query_complete(context) - - - def method_call(self, context, name, object_id, args, userId): - ''' - Invoke a method call requested by the console. - ''' - #print "Method: name=%s user=%s context=%d object_id=%s args=%s" % (name, userId, context, object_id, args) - if name == "echo": - self._agent.method_response(context, 0, "OK", args) - - elif name == "test_map_list": - # build the output map from the input map, accessing each key, - # value to ensure they are encoded/decoded - outMap = {} - for key,value in args['inMap'].items(): - outMap[key] = value - - # same deal for the output list - outList = [] - for value in args['inList']: - outList.append(value) - - args['outMap'] = outMap - args['outList'] = outList - self._agent.method_response(context, 0, "OK", args) - - elif name == "set_numerics": - _retCode = 0 - _retText = "OK" - - if args['test'] == "big": - # - # note the alternate forms for setting object attributes: - # - self._parent.set_attr("uint64val", 0x9494949449494949) - self._parent.uint32val = 0xa5a55a5a - self._parent.set_attr("uint16val", 0xb66b) - self._parent["uint8val"] = 0xc7 - - self._parent.int64val = 1000000000000000000 - self._parent.set_attr("int32val", 1000000000) - self._parent["int16val"] = 10000 - self._parent.set_attr("int8val", 100) - - event = qmf.QmfEvent(self._model.event_class) - event.uint32val = self._parent.get_attr("uint32val") - event.strval = "Unused" - event.mapval = self._parent.get_attr("mapval") - event.listval = self._parent["listval"] - - self._agent.raise_event(event) - - ## Test the __getattr__ implementation: - ## @todo: remove once python_client implements this - ## form of property access - assert self._parent["uint8val"] == 0xc7 - assert self._parent.uint64val == 0x9494949449494949 - - # note the alternative argument access syntax: - elif args.test == "small": - self._parent.set_attr("uint64val", 4) - self._parent.set_attr("uint32val", 5) - self._parent.set_attr("uint16val", 6) - self._parent.set_attr("uint8val", 7) - - self._parent.set_attr("int64val", 8) - self._parent.set_attr("int32val", 9) - self._parent.set_attr("int16val", 10) - self._parent.set_attr("int8val", 11) - - event = qmf.QmfEvent(self._model.event_class) - event.uint32val = self._parent.uint32val - event.strval = "Unused" - self._agent.raise_event(event) - - elif args['test'] == "negative": - self._parent.set_attr("uint64val", 0) - self._parent.set_attr("uint32val", 0) - self._parent.set_attr("uint16val", 0) - self._parent.set_attr("uint8val", 0) - - self._parent.set_attr("int64val", -10000000000) - self._parent.set_attr("int32val", -100000) - self._parent.set_attr("int16val", -1000) - self._parent.set_attr("int8val", -100) - - event = qmf.QmfEvent(self._model.event_class) - event.uint32val = self._parent.uint32val - event.strval = "Unused" - self._agent.raise_event(event) - - else: - _retCode = 1 - _retText = "Invalid argument value for test" - - self._agent.method_response(context, _retCode, _retText, args) - - elif name == "set_short_string": - self._parent.set_attr('sstrval', args['value']) - event = qmf.QmfEvent(self._model.event_class) - event.uint32val = 0 - event.strval = self._parent.sstrval - self._agent.raise_event(event) - - self._agent.method_response(context, 0, "OK", args) - - elif name == "set_long_string": - self._parent.set_attr('lstrval', args['value']) - event = qmf.QmfEvent(self._model.event_class) - event.uint32val = 0 - event.strval = self._parent.lstrval - self._agent.raise_event(event) - - self._agent.method_response(context, 0, "OK", args) - - elif name == "create_child": - # - # Instantiate an object based on the Child Schema Class - # - _oid = self._agent.alloc_object_id(2) - args['child_ref'] = _oid - self._child = qmf.AgentObject(self._model.child_class) - self._child.set_attr("name", args["child_name"]) - self._child.set_object_id(_oid) - self._agent.method_response(context, 0, "OK", args) - - elif name == "probe_userid": - args['userid'] = userId - self._agent.method_response(context, 0, "OK", args) - - else: - self._agent.method_response(context, 1, "Unimplemented Method: %s" % name, args) - - - def main(self): - ''' - Agent application's main processing loop. - ''' - # Connect to the broker - self._settings = qmf.ConnectionSettings() - self._settings.sendUserId = True - if len(sys.argv) > 1: - self._settings.host = str(sys.argv[1]) - if len(sys.argv) > 2: - self._settings.port = int(sys.argv[2]) - self._connection = qmf.Connection(self._settings) - - # Instantiate an Agent to serve me queries and method calls - self._agent = qmf.Agent(self, "agent_test_label") - - # Dynamically define the parent and child schemas, then - # register them with the agent - self._model = Model() - self._model.register(self._agent) - - # Tell the agent about our connection to the broker - self._agent.set_connection(self._connection) - - # Instantiate and populate an instance of the Parent - # Schema Object - self._parent = qmf.AgentObject(self._model.parent_class) - - ## @todo how do we force a test failure? - # verify the properties() and statistics() object methods: - assert len(self._parent.properties()) == 14 - assert len(self._parent.statistics()) == 1 - - self._parent.set_attr("name", "Parent One") - self._parent.set_attr("state", "OPERATIONAL") - - self._parent.set_attr("uint64val", 0) - self._parent.set_attr("uint32val", 0) - self._parent.set_attr("uint16val", 0) - self._parent.set_attr("uint8val", 0) - - self._parent.set_attr("int64val", 0) - self._parent.set_attr("int32val", 0) - self._parent.set_attr("int16val", 0) - self._parent.set_attr("int8val", 0) - - # a list containing a list that contains a map (so there!) - self._parent.set_attr("listval", ['a', 1, 'b', -2, - ['c', True, 3.1415, - {"hi": 10, "lo": 5, "neg": -3}]]) - # a default map - self._parent.set_attr("mapval", {'aLong' : long(9999999999), - 'aInt' : int(54321), - 'aSigned' : -666, - 'aString' : "A String", - 'aFloat' : 3.1415, - 'aMap' : {'first' : 1, - 'second': 2}, - 'aList' : ['x', -1, 'y', 2]}) - - - - self._parent_oid = self._agent.alloc_object_id(1) - self._parent.set_object_id(self._parent_oid) - - # Now wait for events arriving on the connection - # to the broker... - while True: - time.sleep(1000) - - - -app = App() -app.main() - diff --git a/qpid/cpp/bindings/qmf/tests/python_console.py b/qpid/cpp/bindings/qmf/tests/python_console.py deleted file mode 100755 index 1cef824fb5..0000000000 --- a/qpid/cpp/bindings/qmf/tests/python_console.py +++ /dev/null @@ -1,311 +0,0 @@ -#!/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 sys -from qpid.testlib import TestBase010 -from qpid.datatypes import Message -from qpid.queue import Empty -from time import sleep -import qmf.console - -class QmfInteropTests(TestBase010): - - def test_A_agent_presence(self): - self.startQmf(); - qmf = self.qmf - - agents = [] - count = 0 - while len(agents) == 0: - agents = qmf.getObjects(_class="agent") - sleep(1) - count += 1 - if count > 10: - self.fail("Timed out waiting for remote agent") - - def test_B_basic_method_invocation(self): - self.startQmf(); - qmf = self.qmf - - parents = qmf.getObjects(_class="parent") - self.assertEqual(len(parents), 1) - parent = parents[0] - for seq in range(10): - result = parent.echo(seq, _timeout=5) - self.assertEqual(result.status, 0) - self.assertEqual(result.text, "OK") - self.assertEqual(result.sequence, seq) - - result = parent.set_numerics("bogus") - self.assertEqual(result.status, 1) - self.assertEqual(result.text, "Invalid argument value for test") - - def test_C_basic_types_numeric_big(self): - self.startQmf(); - qmf = self.qmf - - parents = qmf.getObjects(_class="parent") - self.assertEqual(len(parents), 1) - parent = parents[0] - - result = parent.set_numerics("big") - self.assertEqual(result.status, 0) - self.assertEqual(result.text, "OK") - - parent.update() - - self.assertEqual(parent.uint64val, 0x9494949449494949) - self.assertEqual(parent.uint32val, 0xA5A55A5A) - self.assertEqual(parent.uint16val, 0xB66B) - self.assertEqual(parent.uint8val, 0xC7) - - self.assertEqual(parent.int64val, 1000000000000000000) - self.assertEqual(parent.int32val, 1000000000) - self.assertEqual(parent.int16val, 10000) - self.assertEqual(parent.int8val, 100) - - def test_C_basic_types_numeric_small(self): - self.startQmf(); - qmf = self.qmf - - parents = qmf.getObjects(_class="parent") - self.assertEqual(len(parents), 1) - parent = parents[0] - - result = parent.set_numerics("small") - self.assertEqual(result.status, 0) - self.assertEqual(result.text, "OK") - - parent.update() - - self.assertEqual(parent.uint64val, 4) - self.assertEqual(parent.uint32val, 5) - self.assertEqual(parent.uint16val, 6) - self.assertEqual(parent.uint8val, 7) - - self.assertEqual(parent.int64val, 8) - self.assertEqual(parent.int32val, 9) - self.assertEqual(parent.int16val, 10) - self.assertEqual(parent.int8val, 11) - - def test_C_basic_types_numeric_negative(self): - self.startQmf(); - qmf = self.qmf - - parents = qmf.getObjects(_class="parent") - self.assertEqual(len(parents), 1) - parent = parents[0] - - result = parent.set_numerics("negative") - self.assertEqual(result.status, 0) - self.assertEqual(result.text, "OK") - - parent.update() - - self.assertEqual(parent.uint64val, 0) - self.assertEqual(parent.uint32val, 0) - self.assertEqual(parent.uint16val, 0) - self.assertEqual(parent.uint8val, 0) - - self.assertEqual(parent.int64val, -10000000000) - self.assertEqual(parent.int32val, -100000) - self.assertEqual(parent.int16val, -1000) - self.assertEqual(parent.int8val, -100) - - def disabled_test_D_userid_for_method(self): - self.startQmf(); - qmf = self.qmf - - parents = qmf.getObjects(_class="parent") - self.assertEqual(len(parents), 1) - parent = parents[0] - - result = parent.probe_userid() - self.assertEqual(result.status, 0) - self.assertEqual(result.userid, "guest") - - def test_D_get_by_object_id(self): - self.startQmf() - qmf = self.qmf - - parents = qmf.getObjects(_class="parent") - self.assertEqual(len(parents), 1) - parent = parents[0] - - newList = qmf.getObjects(_objectId=parent.getObjectId()) - self.assertEqual(len(newList), 1) - - def test_E_filter_by_object_id(self): - self.startQmf() - qmf = self.qmf - - list = qmf.getObjects(_class="exchange", name="qpid.management") - self.assertEqual(len(list), 1, "No Management Exchange") - mgmt_exchange = list[0] - - bindings = qmf.getObjects(_class="binding", exchangeRef=mgmt_exchange.getObjectId()) - if len(bindings) == 0: - self.fail("No bindings found on management exchange") - - for binding in bindings: - self.assertEqual(binding.exchangeRef, mgmt_exchange.getObjectId()) - - def test_F_events(self): - class Handler(qmf.console.Console): - def __init__(self): - self.queue = [] - - def event(self, broker, event): - if event.getClassKey().getClassName() == "test_event": - self.queue.append(event) - - handler = Handler() - self.startQmf(handler) - - parents = self.qmf.getObjects(_class="parent") - self.assertEqual(len(parents), 1) - parent = parents[0] - - parent.set_numerics("big") - parent.set_numerics("small") - parent.set_numerics("negative") - parent.set_short_string("TEST") - parent.set_long_string("LONG_TEST") - parent.probe_userid() - - queue = handler.queue - self.assertEqual(len(queue), 5) - self.assertEqual(queue[0].arguments["uint32val"], 0xA5A55A5A) - self.assertEqual(queue[0].arguments["strval"], "Unused") - - # verify map and list event content. - # see agent for structure of listval and mapval - listval = queue[0].arguments["listval"] - self.assertTrue(isinstance(listval, list)) - self.assertEqual(len(listval), 5) - self.assertTrue(isinstance(listval[4], list)) - self.assertEqual(len(listval[4]), 4) - self.assertTrue(isinstance(listval[4][3], dict)) - self.assertEqual(listval[4][3]["hi"], 10) - self.assertEqual(listval[4][3]["lo"], 5) - self.assertEqual(listval[4][3]["neg"], -3) - - mapval = queue[0].arguments["mapval"] - self.assertTrue(isinstance(mapval, dict)) - self.assertEqual(len(mapval), 7) - self.assertEqual(mapval['aLong'], 9999999999) - self.assertEqual(mapval['aInt'], 54321) - self.assertEqual(mapval['aSigned'], -666) - self.assertEqual(mapval['aString'], "A String"), - self.assertEqual(mapval['aFloat'], 3.1415), - self.assertTrue(isinstance(mapval['aMap'], dict)) - self.assertEqual(len(mapval['aMap']), 2) - self.assertEqual(mapval['aMap']['second'], 2) - self.assertTrue(isinstance(mapval['aList'], list)) - self.assertEqual(len(mapval['aList']), 4) - self.assertEqual(mapval['aList'][1], -1) - - self.assertEqual(queue[1].arguments["uint32val"], 5) - self.assertEqual(queue[1].arguments["strval"], "Unused") - self.assertEqual(queue[2].arguments["uint32val"], 0) - self.assertEqual(queue[2].arguments["strval"], "Unused") - self.assertEqual(queue[3].arguments["uint32val"], 0) - self.assertEqual(queue[3].arguments["strval"], "TEST") - self.assertEqual(queue[4].arguments["uint32val"], 0) - self.assertEqual(queue[4].arguments["strval"], "LONG_TEST") - - - - def test_G_basic_map_list_data(self): - self.startQmf(); - qmf = self.qmf - - parents = qmf.getObjects(_class="parent") - self.assertEqual(len(parents), 1) - parent = parents[0] - - # see agent for structure of listval - - self.assertTrue(isinstance(parent.listval, list)) - self.assertEqual(len(parent.listval), 5) - self.assertTrue(isinstance(parent.listval[4], list)) - self.assertEqual(len(parent.listval[4]), 4) - self.assertTrue(isinstance(parent.listval[4][3], dict)) - self.assertEqual(parent.listval[4][3]["hi"], 10) - self.assertEqual(parent.listval[4][3]["lo"], 5) - self.assertEqual(parent.listval[4][3]["neg"], -3) - - # see agent for structure of mapval - - self.assertTrue(isinstance(parent.mapval, dict)) - self.assertEqual(len(parent.mapval), 7) - self.assertEqual(parent.mapval['aLong'], 9999999999) - self.assertEqual(parent.mapval['aInt'], 54321) - self.assertEqual(parent.mapval['aSigned'], -666) - self.assertEqual(parent.mapval['aString'], "A String"), - self.assertEqual(parent.mapval['aFloat'], 3.1415), - self.assertTrue(isinstance(parent.mapval['aMap'], dict)) - self.assertEqual(len(parent.mapval['aMap']), 2) - self.assertEqual(parent.mapval['aMap']['second'], 2) - self.assertTrue(isinstance(parent.mapval['aList'], list)) - self.assertEqual(len(parent.mapval['aList']), 4) - self.assertEqual(parent.mapval['aList'][1], -1) - - def test_H_map_list_method_call(self): - self.startQmf(); - qmf = self.qmf - - parents = qmf.getObjects(_class="parent") - self.assertEqual(len(parents), 1) - parent = parents[0] - - inMap = {'aLong' : long(9999999999), - 'aInt' : int(54321), - 'aSigned' : -666, - 'aString' : "A String", - 'aFloat' : 3.1415, - 'aList' : ['x', -1, 'y', 2], - 'abool' : False} - inList = ['aString', long(1), -1, 2.7182, {'aMap': -8}, True] - - result = parent.test_map_list(inMap, inList) - self.assertEqual(result.status, 0) - self.assertEqual(result.text, "OK") - - # verify returned values - self.assertEqual(len(inMap), len(result.outArgs['outMap'])) - for key,value in result.outArgs['outMap'].items(): - self.assertEqual(inMap[key], value) - - self.assertEqual(len(inList), len(result.outArgs['outList'])) - for idx in range(len(inList)): - self.assertEqual(inList[idx], result.outArgs['outList'][idx]) - - - def getProperty(self, msg, name): - for h in msg.headers: - if hasattr(h, name): return getattr(h, name) - return None - - def getAppHeader(self, msg, name): - headers = self.getProperty(msg, "application_headers") - if headers: - return headers[name] - return None diff --git a/qpid/cpp/bindings/qmf/tests/ruby_console.rb b/qpid/cpp/bindings/qmf/tests/ruby_console.rb deleted file mode 100755 index 31670312d6..0000000000 --- a/qpid/cpp/bindings/qmf/tests/ruby_console.rb +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/ruby - -# -# 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. -# - -require 'qmf' -require 'socket' - -class App < Qmf::ConsoleHandler - - def agent_added(agent) - puts "AgentAdded: label=#{agent.label} key=#{agent.key}" - end - - def agent_deleted(agent) - puts "AgentDeleted: #{agent.label}" - end - - def new_package(package) - puts "NewPackage: #{package}" - end - - def new_class(class_key) - puts "NewClass: #{class_key}" - end - - def object_update(object, hasProps, hasStats) - puts "ObjectUpdate: #{object.object_class.class_name} props=#{hasProps} stats=#{hasStats}" - puts " agent-key=#{object.object_id.agent_key}" - puts " package=#{object.object_class.package_name}" - end - - def event_received(event); end - - def agent_heartbeat(agent, timestamp) - puts "AgentHeartbeat: #{agent.label} time=#{timestamp/1000000000}" - end - - def method_response(resp); end - def broker_info(broker); end - - - def dump_schema - packages = @qmfc.packages - puts "----- Packages -----" - packages.each do |p| - puts p - puts " ----- Object Classes -----" - classes = @qmfc.classes(p) - classes.each do |c| - puts " #{c.name}" - - puts " ---- Properties ----" - props = c.properties - props.each do |prop| - puts " #{prop.name}" - end - - puts " ---- Statistics ----" - stats = c.statistics - stats.each do |stat| - puts " #{stat.name}" - end - - puts " ---- Methods ----" - methods = c.methods - methods.each do |method| - puts " #{method.name}" - puts " ---- Args ----" - args = method.arguments - args.each do |arg| - puts " #{arg.name}" - end - end - end - - puts " ----- Event Classes -----" - classes = @qmfc.classes(p, Qmf::CLASS_EVENT) - classes.each do |c| - puts " #{c.name}" - puts " ---- Args ----" - args = c.arguments - args.each do |arg| - puts " #{arg.name}" - end - end - end - puts "-----" - end - - def main - @settings = Qmf::ConnectionSettings.new - @settings.host = ARGV[0] if ARGV.size > 0 - @settings.port = ARGV[1].to_i if ARGV.size > 1 - @connection = Qmf::Connection.new(@settings) - @qmfc = Qmf::Console.new(self) - - @broker = @qmfc.add_connection(@connection) - @broker.wait_for_stable - - ##dump_schema - - agents = @qmfc.agents() - puts "---- Agents ----" - agents.each do |a| - puts " => #{a.label}" - end - puts "----" - - for idx in 0...20 - blist = @qmfc.objects(Qmf::Query.new(:class => "broker")) - puts "---- Brokers ----" - blist.each do |b| - puts " ---- Broker ----" - puts " systemRef: #{b.systemRef}" - puts " port : #{b.port}" - puts " uptime : #{b.uptime / 1000000000}" - puts " properties : #{b.properties}" - puts " statistics : #{b.statistics}" - - for rep in 0...1 - puts " Pinging..." - ret = b.echo(45, 'text string') - puts " status=#{ret.status} text=#{ret.exception.asString} seq=#{ret.args.sequence} body=#{ret.args.body}" - end - end - puts "----" - - elist = @qmfc.objects(:package => "org.apache.qpid.broker", :class => "exchange", 'durable' => true) - puts "---- Durable Exchanges ----" - elist.each do |e| - puts "Exchange: #{e.name}" - end - puts "----" - - qlist = @qmfc.objects(Qmf::Query.new(:package => "org.apache.qpid.broker", - :class => "queue")) - puts "---- Queues ----" - qlist.each do |q| - puts " ---- Queue ----" - puts " name : #{q.name}" - end - puts "----" - sleep(5) - end - - sleep(5) - puts "Deleting connection..." - @qmfc.del_connection(@broker) - puts " done" - sleep - end -end - -app = App.new -app.main - - diff --git a/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb b/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb deleted file mode 100755 index 972d5977b8..0000000000 --- a/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb +++ /dev/null @@ -1,397 +0,0 @@ -#!/usr/bin/ruby - -# -# 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. -# - -require 'test_base' - -class ConsoleTest < ConsoleTestBase - - def test_A_agent_presence - assert(@connection.connected?, "Connection not connected") - - agents = [] - count = 0 - while agents.size == 0 - agents = @qmfc.objects(Qmf::Query.new(:class => "agent")) - sleep(1) - count += 1 - fail("Timed out waiting for remote agent") if count > 10 - end - - agentList = @qmfc.agents - assert_equal(agentList.size, 2, "Number of agents reported by Console") - end - - def test_A_connection_settings - begin - @settings.bogusAttribute = 25 - fail("Connection settings accepted bogus attribute") - rescue - end - end - - def test_B_basic_method_invocation - parent = @qmfc.object(:class => "parent") - assert(parent, "Number of 'parent' objects") - for seq in 0...10 - result = parent.echo(seq) - assert_equal(result.status, 0, "Method Response Status") - assert_equal(result.text, "OK", "Method Response Text") - assert_equal(result.args.sequence, seq, "Echo Response Sequence") - end - - result = parent.set_numerics("bogus") - assert_equal(result.status, 1) - assert_equal(result.text, "Invalid argument value for test") - end - - def test_C_basic_types_numeric_big - parent = @qmfc.object(:class =>"parent") - assert(parent, "Number of parent objects") - - result = parent.set_numerics("big") - assert_equal(result.status, 0, "Method Response Status") - assert_equal(result.text, "OK", "Method Response Text") - - parent.update - - assert_equal(parent.uint64val, 0x9494949449494949) - assert_equal(parent.uint32val, 0xA5A55A5A) - assert_equal(parent.uint16val, 0xB66B) - assert_equal(parent.uint8val, 0xC7) - - assert_equal(parent.int64val, 1000000000000000000) - assert_equal(parent.int32val, 1000000000) - assert_equal(parent.int16val, 10000) - assert_equal(parent.int8val, 100) - end - - def test_C_basic_types_numeric_small - parent = @qmfc.object(:class =>"parent") - assert(parent, "Number of parent objects") - - result = parent.set_numerics("small") - assert_equal(result.status, 0, "Method Response Status") - assert_equal(result.text, "OK", "Method Response Text") - - parent.update - - assert_equal(parent.uint64val, 4) - assert_equal(parent.uint32val, 5) - assert_equal(parent.uint16val, 6) - assert_equal(parent.uint8val, 7) - - assert_equal(parent.int64val, 8) - assert_equal(parent.int32val, 9) - assert_equal(parent.int16val, 10) - assert_equal(parent.int8val, 11) - end - - def test_C_basic_types_numeric_negative - parent = @qmfc.object(:class =>"parent") - assert(parent, "Number of parent objects") - - result = parent.set_numerics("negative") - assert_equal(result.status, 0, "Method Response Status") - assert_equal(result.text, "OK", "Method Response Text") - - parent.update - - assert_equal(parent.uint64val, 0) - assert_equal(parent.uint32val, 0) - assert_equal(parent.uint16val, 0) - assert_equal(parent.uint8val, 0) - - assert_equal(parent.int64val, -10000000000) - assert_equal(parent.int32val, -100000) - assert_equal(parent.int16val, -1000) - assert_equal(parent.int8val, -100) - end - - def test_C_basic_types_string_short - parent = @qmfc.object(:class =>"parent") - assert(parent, "Number of parent objects") - - strings = [] - strings << "" - strings << "A" - strings << "BC" - strings << "DEF" - strings << "GHIJKLMNOPQRSTUVWXYZ" - big = "a" - for i in 0...254 - big << "X" - end - strings << big - - strings.each do |str| - result = parent.set_short_string(str) - assert_equal(result.status, 0, "Method Response Status") - compare = str - compare = compare[0..254] if compare.size > 255 - assert_equal(result.args.value, compare, "Value returned by method") - parent.update - assert_equal(parent.sstrval, compare, "Value stored in the object") - end - end - - def test_C_basic_types_string_long - parent = @qmfc.object(:class =>"parent") - assert(parent, "Number of parent objects") - - strings = [] - strings << "" - strings << "A" - strings << "BC" - strings << "DEF" - strings << "GHIJKLMNOPQRSTUVWXYZ" - big = "a" - for i in 0...270 - big << "X" - end - strings << big - - strings.each do |str| - result = parent.set_long_string(str) - assert_equal(result.status, 0, "Method Response Status") - assert_equal(result.args.value, str, "Value returned by method") - parent.update - assert_equal(parent.lstrval, str, "Value stored in the object") - end - end - - def test_D_userid_for_method - parent = @qmfc.object(:class => "parent") - assert(parent, "Number of parent objects") - - result = parent.probe_userid - assert_equal(result.status, 0, "Method Response Status") - assert_equal(result.args.userid, "anonymous") - end - - def test_D_get_by_object_id - parent = @qmfc.object(:class => "parent") - assert(parent, "Number of parent objects") - - list = @qmfc.objects(:object_id => parent.object_id) - assert_equal(list.size, 1) - - bad_oid = Qmf::ObjectId.new - list = @qmfc.objects(:object_id => bad_oid) - assert_equal(list.size, 0) - - # TODO: test a bad_oid that has an agent-bank that is not associated with an attached agent. - - end - - def test_D_get_with_agent - agents = @qmfc.agents - agents.each do |agent| - if agent.label == "agent_test_label" - parent = @qmfc.object(:class => "parent", :agent => agent) - assert(parent, "Number of parent objects") - return - end - end - - fail("Didn't find a non-broker agent") - end - - def test_E_filter_by_object_id - mgmt_exchange = @qmfc.object(:class => "exchange", 'name' => "qpid.management") - assert(mgmt_exchange, "No Management Exchange") - - bindings = @qmfc.objects(:class => "binding", 'exchangeRef' => mgmt_exchange.object_id) - if bindings.size == 0 - fail("No bindings found on management exchange") - end - - bindings.each do |binding| - assert_equal(binding.exchangeRef, mgmt_exchange.object_id) - end - end - - - def test_F_events - - @event_list.clear - @store_events = :true - - parent = @qmfc.object(:class =>"parent") - assert(parent, "Number of parent objects") - - parent.set_numerics("big") - parent.set_numerics("small") - parent.set_numerics("negative") - parent.set_short_string("TEST") - parent.set_long_string("LONG_TEST") - parent.probe_userid() - - @store_events = :false - - assert_equal(@event_list.length, 5) - - assert_equal(@event_list[0].get_attr("uint32val"), 0xA5A55A5A) - assert_equal(@event_list[0].get_attr("strval"), "Unused") - - # verify map and list event content. - # see agent for structure of listval and mapval - - listval = @event_list[0].listval - assert(listval.class == Array) - assert_equal(listval.length, 5) - assert(listval[4].class == Array) - assert_equal(listval[4].length, 4) - assert(listval[4][3].class == Hash) - assert_equal(listval[4][3]["hi"], 10) - assert_equal(listval[4][3]["lo"], 5) - assert_equal(listval[4][3]["neg"], -3) - - mapval = @event_list[0].mapval - assert(mapval.class == Hash) - assert_equal(mapval.length, 7) - assert_equal(mapval['aLong'], 9999999999) - assert_equal(mapval['aInt'], 54321) - assert_equal(mapval['aSigned'], -666) - assert_equal(mapval['aString'], "A String") - assert_equal(mapval['aFloat'], 3.1415) - assert(mapval['aMap'].class == Hash) - assert_equal(mapval['aMap'].length, 2) - assert_equal(mapval['aMap']['second'], 2) - assert(mapval['aList'].class == Array) - assert_equal(mapval['aList'].length, 4) - assert_equal(mapval['aList'][1], -1) - - assert_equal(@event_list[1]["uint32val"], 5) - assert_equal(@event_list[1].get_attr("strval"), "Unused") - assert_equal(@event_list[2].get_attr("uint32val"), 0) - assert_equal(@event_list[2].get_attr("strval"), "Unused") - assert_equal(@event_list[3].get_attr("uint32val"), 0) - assert_equal(@event_list[3].get_attr("strval"), "TEST") - assert_equal(@event_list[4].get_attr("uint32val"), 0) - assert_equal(@event_list[4].get_attr("strval"), "LONG_TEST") - - @event_list.clear - - end - - def test_G_basic_map_list_data - parent = @qmfc.object(:class => "parent") - assert(parent, "Number of 'parent' objects") - - # see agent for structure of listval - - assert(parent.listval.class == Array) - assert_equal(parent.listval.length, 5) - assert(parent.listval[4].class == Array) - assert_equal(parent.listval[4].length, 4) - assert(parent.listval[4][3].class == Hash) - assert_equal(parent.listval[4][3]["hi"], 10) - assert_equal(parent.listval[4][3]["lo"], 5) - assert_equal(parent.listval[4][3]["neg"], -3) - - # see agent for structure of mapval - - assert(parent.mapval.class == Hash) - assert_equal(parent.mapval.length, 7) - assert_equal(parent.mapval['aLong'], 9999999999) - assert_equal(parent.mapval['aInt'], 54321) - assert_equal(parent.mapval['aSigned'], -666) - assert_equal(parent.mapval['aString'], "A String") - assert_equal(parent.mapval['aFloat'], 3.1415) - assert(parent.mapval['aMap'].class == Hash) - assert_equal(parent.mapval['aMap'].length, 2) - assert_equal(parent.mapval['aMap']['second'], 2) - assert(parent.mapval['aList'].class == Array) - assert_equal(parent.mapval['aList'].length, 4) - assert_equal(parent.mapval['aList'][1], -1) - end - - def test_H_map_list_method_call - parent = @qmfc.object(:class => "parent") - assert(parent, "Number of 'parent' objects") - - inMap = {'aLong' => 9999999999, - 'aInt' => 54321, - 'aSigned' => -666, - 'aString' => "A String", - 'aFloat' => 3.1415, - 'aList' => ['x', -1, 'y', 2], - 'abool' => false} - - inList = ['aString', 1, -1, 2.7182, {'aMap'=> -8}, true] - - result = parent.test_map_list(inMap, inList) - assert_equal(result.status, 0) - assert_equal(result.text, "OK") - - # verify returned values - assert_equal(inMap.length, result.args['outMap'].length) - result.args['outMap'].each do |k,v| - assert_equal(inMap[k], v) - end - - assert_equal(inList.length, result.args['outList'].length) - for idx in 0...inList.length - assert_equal(inList[idx], result.args['outList'][idx]) - end - end - - def test_H_map_list_method_call_big - parent = @qmfc.object(:class => "parent") - assert(parent, "Number of 'parent' objects") - - big_string = "" - segment = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - for idx in 1...1500 - big_string = big_string + segment - end - - inMap = {'aLong' => 9999999999, - 'aInt' => 54321, - 'aSigned' => -666, - 'aString' => big_string, - 'another' => big_string, - 'aFloat' => 3.1415, - 'aList' => ['x', -1, 'y', 2], - 'abool' => false} - - inList = ['aString', 1, -1, 2.7182, {'aMap'=> -8}, true] - - result = parent.test_map_list(inMap, inList) - assert_equal(result.status, 0) - assert_equal(result.text, "OK") - - # verify returned values - assert_equal(inMap.length, result.args['outMap'].length) - result.args['outMap'].each do |k,v| - assert_equal(inMap[k], v) - end - - assert_equal(inList.length, result.args['outList'].length) - for idx in 0...inList.length - assert_equal(inList[idx], result.args['outList'][idx]) - end - end - -end - -app = ConsoleTest.new - diff --git a/qpid/cpp/bindings/qmf/tests/run_interop_tests b/qpid/cpp/bindings/qmf/tests/run_interop_tests deleted file mode 100755 index c370f211af..0000000000 --- a/qpid/cpp/bindings/qmf/tests/run_interop_tests +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/sh - -# -# 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. -# - -# Run the qmf interoperability tests. -MY_DIR=`dirname \`which $0\`` -QPID_DIR=${MY_DIR}/../../../.. -BUILD_DIR=../../.. -PYTHON_DIR=${QPID_DIR}/python -TOOLS_PY_DIR=${QPID_DIR}/tools/src/py -QMF_DIR=${QPID_DIR}/extras/qmf -QMF_DIR_PY=${QMF_DIR}/src/py -BROKER_DIR=${BUILD_DIR}/src -API_DIR=${BUILD_DIR}/bindings/qmf -SPEC_DIR=${QPID_DIR}/specs - -RUBY_LIB_DIR=${API_DIR}/ruby/.libs -PYTHON_LIB_DIR=${API_DIR}/python/.libs - -trap stop_broker INT TERM QUIT - -start_broker() { - ${BROKER_DIR}/qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no > _qpidd.port - BROKER_PORT=`cat _qpidd.port` -} - -stop_broker() { - ${BROKER_DIR}/qpidd -q --port $BROKER_PORT - echo "Broker stopped" -} - -start_ruby_agent() { - ruby -I${MY_DIR}/../ruby -I${RUBY_LIB_DIR} ${MY_DIR}/agent_ruby.rb localhost $BROKER_PORT & - AGENT_PID=$! -} - -stop_ruby_agent() { - kill $AGENT_PID -} - -start_python_agent() { - PYTHONPATH="${MY_DIR}/../python:${API_DIR}/python:${PYTHON_LIB_DIR}" python ${MY_DIR}/python_agent.py localhost $BROKER_PORT & - PY_AGENT_PID=$! -} - -stop_python_agent() { - kill $PY_AGENT_PID -} - -TESTS_FAILED=0 - -if test -d ${PYTHON_DIR} ; then - start_broker - echo "Running qmf interop tests using broker on port $BROKER_PORT" - PYTHONPATH=${PYTHON_DIR}:${QMF_DIR_PY}:${MY_DIR}:${TOOLS_PY_DIR} - export PYTHONPATH - - if test -d ${PYTHON_LIB_DIR} ; then - echo " Python Agent (external storage) vs. Pure-Python Console" - start_python_agent - echo " Python agent started at pid $PY_AGENT_PID" - ${PYTHON_DIR}/qpid-python-test -m python_console -b localhost:$BROKER_PORT $@ - RETCODE=$? - stop_python_agent - if test x$RETCODE != x0; then - echo "FAIL qmf interop tests (Python Agent)"; - TESTS_FAILED=1 - fi - fi - - if test -d ${RUBY_LIB_DIR} ; then - echo " Ruby Agent (external storage) vs. Pure-Python Console" - start_ruby_agent - echo " Ruby agent started at pid $AGENT_PID" - ${PYTHON_DIR}/qpid-python-test -m python_console -b localhost:$BROKER_PORT $@ - RETCODE=$? - if test x$RETCODE != x0; then - echo "FAIL qmf interop tests (Ruby Agent)"; - TESTS_FAILED=1 - fi - - echo " Ruby Agent (external storage) vs. Ruby Console" - ruby -I${MY_DIR} -I${MY_DIR}/../ruby -I${RUBY_LIB_DIR} ${MY_DIR}/ruby_console_test.rb localhost $BROKER_PORT $@ - RETCODE=$? - stop_ruby_agent - if test x$RETCODE != x0; then - echo "FAIL qmf interop tests (Ruby Console/Ruby Agent)"; - TESTS_FAILED=1 - fi - - if test -d ${PYTHON_LIB_DIR} ; then - echo " Python Agent (external storage) vs. Ruby Console" - start_python_agent - ruby -I${MY_DIR} -I${MY_DIR}/../ruby -I${RUBY_LIB_DIR} ${MY_DIR}/ruby_console_test.rb localhost $BROKER_PORT $@ - RETCODE=$? - stop_python_agent - if test x$RETCODE != x0; then - echo "FAIL qmf interop tests (Ruby Console/Python Agent)"; - TESTS_FAILED=1 - fi - fi - fi - - # Also against the Pure-Python console: - # Ruby agent (internal storage) - # Python agent (external and internal) - # C++ agent (external and internal) - # - # Other consoles against the same set of agents: - # Wrapped Python console - # Ruby console - # C++ console - - stop_broker - if test x$TESTS_FAILED != x0; then - echo "TEST FAILED!" - exit 1 - fi -fi diff --git a/qpid/cpp/bindings/qmf/tests/test_base.rb b/qpid/cpp/bindings/qmf/tests/test_base.rb deleted file mode 100644 index 7d4609097c..0000000000 --- a/qpid/cpp/bindings/qmf/tests/test_base.rb +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/ruby - -# -# 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. -# - -require 'qmf' -require 'socket' - -class ConsoleTestBase < Qmf::ConsoleHandler - def initialize - sleep(2) - @settings = Qmf::ConnectionSettings.new - @settings.host = ARGV[0] if ARGV.size > 0 - @settings.port = ARGV[1].to_i if ARGV.size > 1 - @connection = Qmf::Connection.new(@settings) - @qmfc = Qmf::Console.new(self) - - @broker = @qmfc.add_connection(@connection) - @broker.wait_for_stable - - @store_events = :false - @event_list = [] - - tests = [] - methods.each do |m| - name = m.to_s - tests << name if name[0..4] == "test_" - end - - failures = 0 - - tests.sort.each do |t| - begin - print "#{t}..." - $stdout.flush - send(t) - puts " Pass" - rescue - puts " Fail: #{$!}" - failures += 1 - end - end - - @qmfc.del_connection(@broker) - exit(1) if failures > 0 - end - - def assert_equal(left, right, in_text=nil) - text = " (#{in_text})" if in_text - raise "Assertion failed: #{left} != #{right}#{text}" unless left == right - end - - def assert(condition, in_text=nil) - text = " (#{in_text})" if in_text - raise "Assertion failed: #{condition} #{text}" unless condition - end - - def fail(text) - raise text - end - - def event_received(event) - @event_list << event if @store_events - end - -end diff --git a/qpid/cpp/bindings/qmf2/Makefile.am b/qpid/cpp/bindings/qmf2/Makefile.am deleted file mode 100644 index 0f50e757a2..0000000000 --- a/qpid/cpp/bindings/qmf2/Makefile.am +++ /dev/null @@ -1,32 +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. -# - -if HAVE_SWIG - -SUBDIRS = examples/cpp - -if HAVE_RUBY_DEVEL -SUBDIRS += ruby -endif - -if HAVE_PYTHON_DEVEL -SUBDIRS += python -endif - -endif diff --git a/qpid/cpp/bindings/qmf2/examples/cpp/CMakeLists.txt b/qpid/cpp/bindings/qmf2/examples/cpp/CMakeLists.txt index 6621137ba9..0e1e00d34e 100644 --- a/qpid/cpp/bindings/qmf2/examples/cpp/CMakeLists.txt +++ b/qpid/cpp/bindings/qmf2/examples/cpp/CMakeLists.txt @@ -57,10 +57,10 @@ macro(add_example subdir example) add_executable(${subdir}_${example} ${example}.cpp) set_target_properties(${subdir}_${example} PROPERTIES OUTPUT_NAME ${example}) if (${ARGC} GREATER 2) - target_link_libraries(${subdir}_${example} ${ARGN} qpidclient + target_link_libraries(${subdir}_${example} ${ARGN} qpidmessaging qpidtypes ${_boost_libs_needed}) else (${ARGC} GREATER 2) - target_link_libraries(${subdir}_${example} qpidclient + target_link_libraries(${subdir}_${example} qpidmessaging qpidtypes ${_boost_libs_needed}) endif (${ARGC} GREATER 2) endmacro(add_example) @@ -73,22 +73,11 @@ macro(add_installed_example subdir example) install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${example}.cpp DESTINATION ${QPID_INSTALL_EXAMPLESDIR}/${subdir} COMPONENT ${QPID_COMPONENT_EXAMPLES}) - if (MSVC) - install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}_${example}.vcproj - DESTINATION ${QPID_INSTALL_EXAMPLESDIR}/${subdir} - COMPONENT ${QPID_COMPONENT_EXAMPLES}) - endif (MSVC) - endmacro(add_installed_example) install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.txt DESTINATION ${QPID_INSTALL_EXAMPLESDIR} COMPONENT ${QPID_COMPONENT_EXAMPLES}) -if (MSVC) - install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples.sln - DESTINATION ${QPID_INSTALL_EXAMPLESDIR} - COMPONENT ${QPID_COMPONENT_EXAMPLES}) -endif (MSVC) add_installed_example(qmf2 agent qmf2) if (NOT WIN32) diff --git a/qpid/cpp/bindings/qmf2/examples/cpp/Makefile.am b/qpid/cpp/bindings/qmf2/examples/cpp/Makefile.am deleted file mode 100644 index 8bf56ead91..0000000000 --- a/qpid/cpp/bindings/qmf2/examples/cpp/Makefile.am +++ /dev/null @@ -1,39 +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. -# - -INCLUDE = -I$(top_srcdir)/include - -AM_CPPFLAGS = $(INCLUDE) - -TYPES_LIB=$(top_builddir)/src/libqpidtypes.la -MESSAGING_LIB=$(top_builddir)/src/libqpidmessaging.la - -noinst_PROGRAMS=agent event_driven_list_agents list_agents print_events - -agent_SOURCES=agent.cpp -agent_LDADD=$(top_builddir)/src/libqmf2.la $(TYPES_LIB) $(MESSAGING_LIB) - -list_agents_SOURCES=list_agents.cpp -list_agents_LDADD=$(top_builddir)/src/libqmf2.la $(MESSAGING_LIB) - -event_driven_list_agents_SOURCES=event_driven_list_agents.cpp -event_driven_list_agents_LDADD=$(top_builddir)/src/libqmf2.la $(MESSAGING_LIB) - -print_events_SOURCES=print_events.cpp -print_events_LDADD=$(top_builddir)/src/libqmf2.la $(TYPES_LIB) $(MESSAGING_LIB) diff --git a/qpid/cpp/bindings/qmf2/python/Makefile.am b/qpid/cpp/bindings/qmf2/python/Makefile.am deleted file mode 100644 index 309e8f8dad..0000000000 --- a/qpid/cpp/bindings/qmf2/python/Makefile.am +++ /dev/null @@ -1,49 +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. -# - -if HAVE_PYTHON_DEVEL - -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/bindings -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_builddir)/src $(QMF_INCLUDES) - -generated_file_list = \ - cqmf2.cpp \ - cqmf2.py - -EXTRA_DIST = CMakeLists.txt python.i -BUILT_SOURCES = $(generated_file_list) -SWIG_FLAGS = -w362,401 - -$(generated_file_list): $(srcdir)/python.i - $(SWIG) -c++ -python $(SWIG_FLAGS) $(INCLUDES) $(QPID_CXXFLAGS) -I/usr/include -o cqmf2.cpp $(srcdir)/python.i - -pylibdir = $(pyexecdir) - -pylib_LTLIBRARIES = _cqmf2.la -cqpiddir = $(pythondir) -cqpid_PYTHON = qmf2.py cqmf2.py - -_cqmf2_la_LDFLAGS = -avoid-version -module -shared -_cqmf2_la_LIBADD = $(PYTHON_LIBS) -L$(top_builddir)/src/.libs $(top_builddir)/src/libqmf2.la -_cqmf2_la_CXXFLAGS = $(INCLUDES) -I$(srcdir)/qmf $(PYTHON_CFLAGS) -fno-strict-aliasing -nodist__cqmf2_la_SOURCES = cqmf2.cpp - -CLEANFILES = $(generated_file_list) - -endif # HAVE_PYTHON_DEVEL - diff --git a/qpid/cpp/bindings/qmf2/ruby/Makefile.am b/qpid/cpp/bindings/qmf2/ruby/Makefile.am deleted file mode 100644 index 9952edb972..0000000000 --- a/qpid/cpp/bindings/qmf2/ruby/Makefile.am +++ /dev/null @@ -1,44 +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. -# - -if HAVE_RUBY_DEVEL - -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/bindings -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_builddir)/src $(QMF_INCLUDES) - -EXTRA_DIST = CMakeLists.txt ruby.i -BUILT_SOURCES = cqmf2.cpp -SWIG_FLAGS = -w362,401 - -rubylibdir = $(RUBY_LIB) - -cqmf2.cpp: $(srcdir)/ruby.i - $(SWIG) -ruby -c++ $(SWIG_FLAGS) $(INCLUDES) $(QPID_CXXFLAGS) -I/usr/include -o cqmf2.cpp $(srcdir)/ruby.i - -rubylibarchdir = $(RUBY_LIB_ARCH) -rubylibarch_LTLIBRARIES = cqmf2.la -dist_rubylib_DATA = qmf2.rb - -cqmf2_la_LDFLAGS = -avoid-version -module -shared -shrext ".$(RUBY_DLEXT)" -cqmf2_la_LIBADD = $(RUBY_LIBS) -L$(top_builddir)/src/.libs -lqmf2 $(top_builddir)/src/libqmf2.la -cqmf2_la_CXXFLAGS = $(INCLUDES) -I$(RUBY_INC) -I$(RUBY_INC_ARCH) -fno-strict-aliasing -nodist_cqmf2_la_SOURCES = cqmf2.cpp - -CLEANFILES = cqmf2.cpp - -endif # HAVE_RUBY_DEVEL diff --git a/qpid/cpp/bindings/qpid/Makefile.am b/qpid/cpp/bindings/qpid/Makefile.am deleted file mode 100644 index 5f47ee9b0a..0000000000 --- a/qpid/cpp/bindings/qpid/Makefile.am +++ /dev/null @@ -1,79 +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. -# - -SUBDIRS = dotnet - -if HAVE_SWIG - -if HAVE_RUBY_DEVEL -SUBDIRS += ruby -endif - -if HAVE_PYTHON_DEVEL -SUBDIRS += python -endif - -if HAVE_PERL_DEVEL - -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/bindings -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_builddir)/src -I$(PERL_INC) - -EXTRA_DIST = perl/perl.i perl/CMakeLists.txt perl/Makefile.PL perl/lib/qpid.pm perl/lib -BUILT_SOURCES = perl/cqpid_perl.cpp -SWIG_FLAGS = -w362,401 - -perl/cqpid_perl.cpp: $(srcdir)/perl/perl.i - mkdir -p perl - $(SWIG) -perl -c++ $(SWIG_FLAGS) $(INCLUDES) $(QPID_CXXFLAGS) -I/usr/include -o perl/cqpid_perl.cpp $(srcdir)/perl/perl.i - -perl/Makefile: perl/cqpid_perl.cpp - mkdir -p perl - cd perl; \ - $(PERL) Makefile.PL PREFIX=$(prefix) ; \ - cd .. - -all-local: perl/Makefile - cd perl; \ - $(MAKE) OPTIMIZE="$(CXXFLAGS)" ; \ - cd .. - -install-exec-local: - cd perl ; \ - $(MAKE) pure_install ; \ - cd .. - -clean-local: - cd perl ; \ - $(MAKE) clean ; \ - cd .. - -distclean-local: - cd perl ; \ - $(MAKE) distclean ; \ - cd .. - -maintainer-clean-local: - cd perl ; \ - $(PERL) maintainer-clean ; \ - cd .. - -CLEANFILES = perl/cqpid_perl.cpp perl/Makefile.old perl/cqpid_perl.pm - -endif - -endif diff --git a/qpid/cpp/bindings/qpid/dotnet/Makefile.am b/qpid/cpp/bindings/qpid/dotnet/Makefile.am deleted file mode 100644 index 82ae315578..0000000000 --- a/qpid/cpp/bindings/qpid/dotnet/Makefile.am +++ /dev/null @@ -1,159 +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. -# - -EXTRA_DIST = configure-windows.ps1 \ - examples/csharp.direct.receiver/csharp.direct.receiver.cs \ - examples/csharp.direct.receiver/Properties/AssemblyInfo.cs \ - examples/csharp.direct.sender/csharp.direct.sender.cs \ - examples/csharp.direct.sender/Properties/AssemblyInfo.cs \ - examples/csharp.example.client/csharp.example.client.cs \ - examples/csharp.example.client/Properties/AssemblyInfo.cs \ - examples/csharp.example.declare_queues/csharp.example.declare_queues.cs \ - examples/csharp.example.declare_queues/Properties/AssemblyInfo.cs \ - examples/csharp.example.drain/csharp.example.drain.cs \ - examples/csharp.example.drain/Options.cs \ - examples/csharp.example.drain/Properties/AssemblyInfo.cs \ - examples/csharp.example.helloworld/csharp.example.helloworld.cs \ - examples/csharp.example.helloworld/Properties/AssemblyInfo.cs \ - examples/csharp.example.server/csharp.example.server.cs \ - examples/csharp.example.server/Properties/AssemblyInfo.cs \ - examples/csharp.example.spout/csharp.example.spout.cs \ - examples/csharp.example.spout/Options.cs \ - examples/csharp.example.spout/Properties/AssemblyInfo.cs \ - examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs \ - examples/csharp.map.callback.receiver/Properties/AssemblyInfo.cs \ - examples/csharp.map.callback.sender/csharp.map.callback.sender.cs \ - examples/csharp.map.callback.sender/Properties/AssemblyInfo.cs \ - examples/csharp.map.receiver/csharp.map.receiver.cs \ - examples/csharp.map.receiver/Properties/AssemblyInfo.cs \ - examples/csharp.map.sender/csharp.map.sender.cs \ - examples/csharp.map.sender/Properties/AssemblyInfo.cs \ - examples/msvc10/csharp.direct.receiver/app.config \ - examples/msvc10/csharp.direct.receiver/csharp.direct.receiver.csproj \ - examples/msvc10/csharp.direct.sender/app.config \ - examples/msvc10/csharp.direct.sender/csharp.direct.sender.csproj \ - examples/msvc10/csharp.example.client/app.config \ - examples/msvc10/csharp.example.client/csharp.example.client.csproj \ - examples/msvc10/csharp.example.declare_queues/app.config \ - examples/msvc10/csharp.example.declare_queues/csharp.example.declare_queues.csproj \ - examples/msvc10/csharp.example.drain/app.config \ - examples/msvc10/csharp.example.drain/csharp.example.drain.csproj \ - examples/msvc10/csharp.example.helloworld/app.config \ - examples/msvc10/csharp.example.helloworld/csharp.example.helloworld.csproj \ - examples/msvc10/csharp.example.server/app.config \ - examples/msvc10/csharp.example.server/csharp.example.server.csproj \ - examples/msvc10/csharp.example.spout/app.config \ - examples/msvc10/csharp.example.spout/csharp.example.spout.csproj \ - examples/msvc10/csharp.map.callback.receiver/app.config \ - examples/msvc10/csharp.map.callback.receiver/csharp.map.callback.receiver.csproj \ - examples/msvc10/csharp.map.callback.sender/app.config \ - examples/msvc10/csharp.map.callback.sender/csharp.map.callback.sender.csproj \ - examples/msvc10/csharp.map.receiver/app.config \ - examples/msvc10/csharp.map.receiver/csharp.map.receiver.csproj \ - examples/msvc10/csharp.map.sender/app.config \ - examples/msvc10/csharp.map.sender/csharp.map.sender.csproj \ - examples/msvc9/csharp.direct.receiver/csharp.direct.receiver.csproj \ - examples/msvc9/csharp.direct.sender/csharp.direct.sender.csproj \ - examples/msvc9/csharp.example.client/csharp.example.client.csproj \ - examples/msvc9/csharp.example.declare_queues/csharp.example.declare_queues.csproj \ - examples/msvc9/csharp.example.drain/csharp.example.drain.csproj \ - examples/msvc9/csharp.example.helloworld/csharp.example.helloworld.csproj \ - examples/msvc9/csharp.example.server/csharp.example.server.csproj \ - examples/msvc9/csharp.example.spout/csharp.example.spout.csproj \ - examples/msvc9/csharp.map.callback.receiver/csharp.map.callback.receiver.csproj \ - examples/msvc9/csharp.map.callback.sender/csharp.map.callback.sender.csproj \ - examples/msvc9/csharp.map.receiver/csharp.map.receiver.csproj \ - examples/msvc9/csharp.map.sender/csharp.map.sender.csproj \ - Makefile.am \ - msvc10/org.apache.qpid.messaging.sessionreceiver.sln \ - msvc10/org.apache.qpid.messaging.sln \ - msvc9/org.apache.qpid.messaging.sessionreceiver.sln \ - msvc9/org.apache.qpid.messaging.sln \ - ReadMe.txt \ - src/Address.cpp \ - src/Address.h \ - src/app.rc \ - src/AssemblyInfo.cpp \ - src/Connection.cpp \ - src/Connection.h \ - src/Duration.h \ - src/FailoverUpdates.cpp \ - src/FailoverUpdates.h \ - src/Message.cpp \ - src/Message.h \ - src/msvc10/org.apache.qpid.messaging.vcxproj \ - src/msvc10/org.apache.qpid.messaging.vcxproj.filters \ - src/msvc9/org.apache.qpid.messaging.vcproj \ - src/org.apache.qpid.messaging.template.rc \ - src/qpid.snk \ - src/QpidException.h \ - src/QpidMarshal.h \ - src/QpidTypeCheck.h \ - src/ReadMe.txt \ - src/Receiver.cpp \ - src/Receiver.h \ - src/resource1.h \ - src/Sender.cpp \ - src/Sender.h \ - src/Session.cpp \ - src/Session.h \ - src/sessionreceiver/msvc10/org.apache.qpid.messaging.sessionreceiver.csproj \ - src/sessionreceiver/msvc9/org.apache.qpid.messaging.sessionreceiver.csproj \ - src/sessionreceiver/Properties/sessionreceiver-AssemblyInfo-template.cs \ - src/sessionreceiver/qpid.snk \ - src/sessionreceiver/sessionreceiver.cs \ - src/TypeTranslator.cpp \ - src/TypeTranslator.h \ - test/messaging.test/messaging.test.address.cs \ - test/messaging.test/messaging.test.connection.cs \ - test/messaging.test/messaging.test.cs \ - test/messaging.test/messaging.test.duration.cs \ - test/messaging.test/messaging.test.message.cs \ - test/messaging.test/msvc10/messaging.test.csproj \ - test/messaging.test/msvc9/messaging.test.csproj \ - test/messaging.test/Properties/AssemblyInfo.cs \ - winsdk_sources/msvc10/examples/csharp.direct.receiver/csharp.direct.receiver.csproj \ - winsdk_sources/msvc10/examples/csharp.direct.sender/csharp.direct.sender.csproj \ - winsdk_sources/msvc10/examples/csharp.example.client/csharp.example.client.csproj \ - winsdk_sources/msvc10/examples/csharp.example.declare_queues/csharp.example.declare_queues.csproj \ - winsdk_sources/msvc10/examples/csharp.example.drain/csharp.example.drain.csproj \ - winsdk_sources/msvc10/examples/csharp.example.helloworld/csharp.example.helloworld.csproj \ - winsdk_sources/msvc10/examples/csharp.example.server/csharp.example.server.csproj \ - winsdk_sources/msvc10/examples/csharp.example.spout/csharp.example.spout.csproj \ - winsdk_sources/msvc10/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.csproj \ - winsdk_sources/msvc10/examples/csharp.map.callback.sender/csharp.map.callback.sender.csproj \ - winsdk_sources/msvc10/examples/csharp.map.receiver/csharp.map.receiver.csproj \ - winsdk_sources/msvc10/examples/csharp.map.sender/csharp.map.sender.csproj \ - winsdk_sources/msvc10/winsdk_dotnet_examples.sln \ - winsdk_sources/msvc9/examples/csharp.direct.receiver/csharp.direct.receiver.csproj \ - winsdk_sources/msvc9/examples/csharp.direct.sender/csharp.direct.sender.csproj \ - winsdk_sources/msvc9/examples/csharp.example.client/csharp.example.client.csproj \ - winsdk_sources/msvc9/examples/csharp.example.declare_queues/csharp.example.declare_queues.csproj \ - winsdk_sources/msvc9/examples/csharp.example.drain/csharp.example.drain.csproj \ - winsdk_sources/msvc9/examples/csharp.example.helloworld/csharp.example.helloworld.csproj \ - winsdk_sources/msvc9/examples/csharp.example.server/csharp.example.server.csproj \ - winsdk_sources/msvc9/examples/csharp.example.spout/csharp.example.spout.csproj \ - winsdk_sources/msvc9/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.csproj \ - winsdk_sources/msvc9/examples/csharp.map.callback.sender/csharp.map.callback.sender.csproj \ - winsdk_sources/msvc9/examples/csharp.map.receiver/csharp.map.receiver.csproj \ - winsdk_sources/msvc9/examples/csharp.map.sender/csharp.map.sender.csproj \ - winsdk_sources/msvc9/winsdk_dotnet_examples.sln \ - ../../../src/windows/resources/qpid-icon.ico \ - ../../../src/windows/resources/template-resource.rc \ - ../../../src/windows/resources/version-resource.h diff --git a/qpid/cpp/bindings/qpid/examples/perl/spout.pl b/qpid/cpp/bindings/qpid/examples/perl/spout.pl index 74e589b617..7468a25a3a 100755 --- a/qpid/cpp/bindings/qpid/examples/perl/spout.pl +++ b/qpid/cpp/bindings/qpid/examples/perl/spout.pl @@ -28,6 +28,7 @@ use Time::Local; my $url = "127.0.0.1"; my $timeout = 0; my $count = 1; +my $durable = 0; my $id = ""; my $replyto = ""; my @properties; @@ -41,6 +42,7 @@ my $result = GetOptions( "broker|b=s" => \$url, "timeout|t=i" => \$timeout, "count|c=i" => \$count, + "durable|d" => \$durable, "id|i=s" => \$id, "replyto=s" => \$replyto, "property|p=s@" => \@properties, @@ -96,6 +98,9 @@ eval { $message->set_content_type("text/plain"); } + # set durable flag + $message->set_durable($durable); + # if a reply-to address was supplied, then create a receiver from the # session and wait for a response to be sent my $receiver; diff --git a/qpid/cpp/bindings/qpid/examples/python/console b/qpid/cpp/bindings/qpid/examples/python/console new file mode 100755 index 0000000000..2facc368c3 --- /dev/null +++ b/qpid/cpp/bindings/qpid/examples/python/console @@ -0,0 +1,99 @@ +#!/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 optparse, sys, traceback + +try: + from qpid_messaging import * +except: + from qpid.messaging import * + +parser = optparse.OptionParser(usage="usage: %prog [options] ADDRESS ...", + description="handle requests from the supplied address.") +parser.add_option("-b", "--broker", default="localhost", + help="connect to specified BROKER (default %default)") +parser.add_option("-r", "--reconnect", action="store_true", + help="enable auto reconnect") +parser.add_option("-i", "--reconnect-interval", type="float", default=3, + help="interval between reconnect attempts") +parser.add_option("-l", "--reconnect-limit", type="int", default=10, + help="maximum number of reconnect attempts") +parser.add_option("-v", dest="verbose", action="store_true", + help="enable logging") + +opts, args = parser.parse_args() + +if args: + addr = args.pop(0) +else: + parser.error("address is required") + +conn = Connection(opts.broker, + reconnect=opts.reconnect, + reconnect_interval=opts.reconnect_interval, + reconnect_limit=opts.reconnect_limit) + +try: + conn.open() + session = conn.session() + sender = session.sender(addr) + response_queue = "response-queue;{create:always}" + receiver = session.receiver(response_queue) + receiver.capacity = 10 + + while True: + cmdtype = None + data = None + input = raw_input("Type (eval/shell/exit, ENTER=shell):") + if input != "exit": + if input == "eval": + cmdtype = input + data = raw_input("Text to evaluate: ") + elif input == "shell" or input == "": + cmdtype = "shell" + data = raw_input("Shell cmd: ") + + if cmdtype != None and data != "": + msg = Message() + msg.properties["type"] = cmdtype + # TODO: fix this + # msg.setProperty("type", cmdtype) + msg.content = data + msg.reply_to = response_queue + try: + sender.send(msg) + response = receiver.fetch() + print "Response:" + print "%s" % response.content + session.acknowledge(response) + except SendError, e: + print e + else: + break + if sender is not None: + sender.close() + if receiver is not None: + receiver.close() +except ReceiverError, e: + print e +except KeyboardInterrupt: + pass + +conn.close() diff --git a/qpid/cpp/bindings/qpid/examples/python/drain b/qpid/cpp/bindings/qpid/examples/python/drain new file mode 100755 index 0000000000..2b15a50500 --- /dev/null +++ b/qpid/cpp/bindings/qpid/examples/python/drain @@ -0,0 +1,102 @@ +#!/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 optparse + +try: + from qpid_messaging import * +except: + from qpid.messaging import * + +from qpid.util import URL +from qpid.log import enable, DEBUG, WARN + +parser = optparse.OptionParser(usage="usage: %prog [options] ADDRESS ...", + description="Drain messages from the supplied address.") +parser.add_option("-b", "--broker", default="localhost", + help="connect to specified BROKER (default %default)") +parser.add_option("-c", "--count", type="int", + help="number of messages to drain") +parser.add_option("-f", "--forever", action="store_true", + help="ignore timeout and wait forever") +parser.add_option("-r", "--reconnect", action="store_true", + help="enable auto reconnect") +parser.add_option("-i", "--reconnect-interval", type="float", default=3, + help="interval between reconnect attempts") +parser.add_option("-l", "--reconnect-limit", type="int", + help="maximum number of reconnect attempts") +parser.add_option("-t", "--timeout", type="float", default=0, + help="timeout in seconds to wait before exiting (default %default)") +parser.add_option("-p", "--print", dest="format", default="%(M)s", + help="format string for printing messages (default %default)") +parser.add_option("-v", dest="verbose", action="store_true", + help="enable logging") + +opts, args = parser.parse_args() + +if opts.verbose: + enable("qpid", DEBUG) +else: + enable("qpid", WARN) + +if args: + addr = args.pop(0) +else: + parser.error("address is required") +if opts.forever: + timeout = None +else: + timeout = opts.timeout + +class Formatter: + + def __init__(self, message): + self.message = message + self.environ = {"M": self.message, + "P": self.message.properties, + "C": self.message.content} + + def __getitem__(self, st): + return eval(st, self.environ) + +conn = Connection(opts.broker, + reconnect=opts.reconnect, + reconnect_interval=opts.reconnect_interval, + reconnect_limit=opts.reconnect_limit) +try: + conn.open() + ssn = conn.session() + rcv = ssn.receiver(addr) + + count = 0 + while not opts.count or count < opts.count: + try: + msg = rcv.fetch(timeout=timeout) + print opts.format % Formatter(msg) + count += 1 + ssn.acknowledge() + except Empty: + break +except ReceiverError, e: + print e +except KeyboardInterrupt: + pass + +conn.close() diff --git a/qpid/cpp/docs/api/Makefile.am b/qpid/cpp/bindings/qpid/examples/python/hello index 3dd78ae7ad..52ea955093 100644..100755 --- a/qpid/cpp/docs/api/Makefile.am +++ b/qpid/cpp/bindings/qpid/examples/python/hello @@ -1,3 +1,4 @@ +#!/usr/bin/env python # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -16,25 +17,40 @@ # specific language governing permissions and limitations # under the License. # -# -# Run doxygen to generate HTML doc. -# Generate dependency files so its rebuilt only when needed. -# -if HAVE_DOXYGEN +import sys + +try: + from qpid_messaging import * +except: + from qpid.messaging import * + +if len(sys.argv)<2: + broker = "localhost:5672" +else: + broker = sys.argv[1] + +if len(sys.argv)<3: + address = "amq.topic" +else: + address = sys.argv[2] + +connection = Connection(broker) -EXTRA_DIST = html user.doxygen developer.doxygen html.timestamp CMakeLists.txt \ - header.html footer.html +try: + connection.open() + session = connection.session() -html: html.timestamp + sender = session.sender(address) + receiver = session.receiver(address) + sender.send(Message("Hello world!")); -html.timestamp: - test $(srcdir) = . || cp $(srcdir)/header.html $(srcdir)/footer.html . - doxygen user.doxygen - touch $@ + message = receiver.fetch() + print message.content + session.acknowledge() -clean-local: - rm -rf html html-dev html.timestamp +except MessagingError,m: + print m -endif +connection.close() diff --git a/qpid/cpp/bindings/qpid/examples/python/hello_xml b/qpid/cpp/bindings/qpid/examples/python/hello_xml new file mode 100755 index 0000000000..05fa5cc7ba --- /dev/null +++ b/qpid/cpp/bindings/qpid/examples/python/hello_xml @@ -0,0 +1,81 @@ +#!/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 sys + +try: + from qpid_messaging import * +except: + from qpid.messaging import * + +broker = "localhost:5672" +connection = Connection(broker) + +try: + connection.open() + session = connection.session() + +# Set up the receiver + query = """ + let $w := ./weather + return $w/station = 'Raleigh-Durham International Airport (KRDU)' + and $w/temperature_f > 50 + and $w/temperature_f - $w/dewpoint > 5 + and $w/wind_speed_mph > 7 + and $w/wind_speed_mph < 20 """ + +# query="./weather" + + address = """ + xml; { + create: always, + node:{ type: queue }, + link: { + x-bindings: [{ exchange: xml, key: weather, arguments: { xquery: %r} }] + } + } + """ % query + + receiver = session.receiver(address) + +# Send an observation + + observations = """ + <weather> + <station>Raleigh-Durham International Airport (KRDU)</station> + <wind_speed_mph>16</wind_speed_mph> + <temperature_f>70</temperature_f> + <dewpoint>35</dewpoint> + </weather> """ + + message = Message(subject="weather", content=observations) + sender = session.sender("xml") + sender.send(message) + +# Retrieve matching message from the receiver and print it + + message = receiver.fetch(timeout=1) + print message.content + session.acknowledge() + +except MessagingError,m: + print m + +connection.close() diff --git a/qpid/cpp/bindings/qpid/examples/python/server b/qpid/cpp/bindings/qpid/examples/python/server new file mode 100755 index 0000000000..fb87951bad --- /dev/null +++ b/qpid/cpp/bindings/qpid/examples/python/server @@ -0,0 +1,100 @@ +#!/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 optparse, sys, traceback + +try: + from qpid_messaging import * +except: + from qpid.messaging import * + +from qpid.util import URL +from subprocess import Popen, STDOUT, PIPE +from qpid.log import enable, DEBUG, WARN + +parser = optparse.OptionParser(usage="usage: %prog [options] ADDRESS ...", + description="handle requests from the supplied address.") +parser.add_option("-b", "--broker", default="localhost", + help="connect to specified BROKER (default %default)") +parser.add_option("-r", "--reconnect", action="store_true", + help="enable auto reconnect") +parser.add_option("-i", "--reconnect-interval", type="float", default=3, + help="interval between reconnect attempts") +parser.add_option("-l", "--reconnect-limit", type="int", + help="maximum number of reconnect attempts") +parser.add_option("-v", dest="verbose", action="store_true", + help="enable logging") + +opts, args = parser.parse_args() + +if opts.verbose: + enable("qpid", DEBUG) +else: + enable("qpid", WARN) + +if args: + addr = args.pop(0) +else: + parser.error("address is required") + +conn = Connection(opts.broker, + reconnect=opts.reconnect, + reconnect_interval=opts.reconnect_interval, + reconnect_limit=opts.reconnect_limit) +def dispatch(msg): + msg_type = msg.properties.get("type") + if msg_type == "shell": + proc = Popen(msg.content, shell=True, stderr=STDOUT, stdin=PIPE, stdout=PIPE) + output, _ = proc.communicate() + result = Message(output) + result.properties["exit"] = proc.returncode + elif msg_type == "eval": + try: + content = str(eval(msg.content)) + except: + content = traceback.format_exc() + result = Message(content = content) + else: + result = Message("unrecognized message type: %s" % msg_type) + return result + +try: + conn.open() + ssn = conn.session() + rcv = ssn.receiver(addr) + + while True: + msg = rcv.fetch() + response = dispatch(msg) + snd = None + try: + snd = ssn.sender(msg.reply_to) + snd.send(response) + except SendError, e: + print e + if snd is not None: + snd.close() + ssn.acknowledge() +except ReceiverError, e: + print e +except KeyboardInterrupt: + pass + +conn.close() diff --git a/qpid/cpp/bindings/qpid/examples/python/spout b/qpid/cpp/bindings/qpid/examples/python/spout new file mode 100755 index 0000000000..48921d4387 --- /dev/null +++ b/qpid/cpp/bindings/qpid/examples/python/spout @@ -0,0 +1,139 @@ +#!/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 optparse, time + +try: + from qpid_messaging import * + from uuid import uuid4 +except: + from qpid.messaging import * + +from qpid.util import URL +from qpid.log import enable, DEBUG, WARN + +def nameval(st): + idx = st.find("=") + if idx >= 0: + name = st[0:idx] + value = st[idx+1:] + else: + name = st + value = None + return name, value + +parser = optparse.OptionParser(usage="usage: %prog [options] ADDRESS [ CONTENT ... ]", + description="Send messages to the supplied address.") +parser.add_option("-b", "--broker", default="localhost", + help="connect to specified BROKER (default %default)") +parser.add_option("-r", "--reconnect", action="store_true", + help="enable auto reconnect") +parser.add_option("-i", "--reconnect-interval", type="float", default=3, + help="interval between reconnect attempts") +parser.add_option("-l", "--reconnect-limit", type="int", + help="maximum number of reconnect attempts") +parser.add_option("-c", "--count", type="int", default=1, + help="stop after count messages have been sent, zero disables (default %default)") +parser.add_option("-d", "--durable", action="store_true", + help="make the message persistent") +parser.add_option("-t", "--timeout", type="float", default=None, + help="exit after the specified time") +parser.add_option("-I", "--id", help="use the supplied id instead of generating one") +parser.add_option("-S", "--subject", help="specify a subject") +parser.add_option("-R", "--reply-to", help="specify reply-to address") +parser.add_option("-P", "--property", dest="properties", action="append", default=[], + metavar="NAME=VALUE", help="specify message property") +parser.add_option("-M", "--map", dest="entries", action="append", default=[], + metavar="KEY=VALUE", + help="specify map entry for message body") +parser.add_option("-v", dest="verbose", action="store_true", + help="enable logging") + +opts, args = parser.parse_args() + +if opts.verbose: + enable("qpid", DEBUG) +else: + enable("qpid", WARN) + +if opts.id is None: + spout_id = str(uuid4()) +else: + spout_id = opts.id +if args: + addr = args.pop(0) +else: + parser.error("address is required") + +content = None +content_type = None + +if args: + text = " ".join(args) +else: + text = None + +if opts.entries: + content = {} + if text: + content["text"] = text + for e in opts.entries: + name, val = nameval(e) + content[name] = val +else: + content = text + # no entries were supplied, so assume text/plain for + # compatibility with java (and other) clients + content_type = "text/plain" + +conn = Connection(opts.broker, + reconnect=opts.reconnect, + reconnect_interval=opts.reconnect_interval, + reconnect_limit=opts.reconnect_limit) +try: + conn.open() + ssn = conn.session() + snd = ssn.sender(addr) + + count = 0 + start = time.time() + while (opts.count == 0 or count < opts.count) and \ + (opts.timeout is None or time.time() - start < opts.timeout): + msg = Message(subject=opts.subject, + reply_to=opts.reply_to, + content=content) + if opts.durable: + msg.durable = True + if content_type is not None: + msg.content_type = content_type + msg.properties["spout-id"] = "%s:%s" % (spout_id, count) + for p in opts.properties: + name, val = nameval(p) + msg.properties[name] = val + + snd.send(msg) + count += 1 + print msg +except SendError, e: + print e +except KeyboardInterrupt: + pass + +conn.close() diff --git a/qpid/cpp/bindings/qpid/examples/python/statistics.py b/qpid/cpp/bindings/qpid/examples/python/statistics.py new file mode 100644 index 0000000000..089b81b740 --- /dev/null +++ b/qpid/cpp/bindings/qpid/examples/python/statistics.py @@ -0,0 +1,139 @@ +#!/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 time + +TS = "ts" +TIME_SEC = 1000000000 +MILLISECOND = 1000 + +class Statistic: + def message(self, msg): + return + def report(self): + return "" + def header(self): + return "" + + +class Throughput(Statistic): + def __init__(self): + self.messages = 0 + self.started = False + + def message(self, m): + self.messages += 1 + if not self.started: + self.start = time.time() + self.started = True + + def header(self): + return "tp(m/s)" + + def report(self): + if self.started: + elapsed = time.time() - self.start + return str(int(self.messages/elapsed)) + else: + return "0" + + +class ThroughputAndLatency(Throughput): + def __init__(self): + Throughput.__init__(self) + self.total = 0.0 + self.min = float('inf') + self.max = -float('inf') + self.samples = 0 + + def message(self, m): + Throughput.message(self, m) + if TS in m.properties: + self.samples+=1 + latency = MILLISECOND * (time.time() - float(m.properties[TS])/TIME_SEC) + if latency > 0: + self.total += latency + if latency < self.min: + self.min = latency + if latency > self.max: + self.max = latency + + def header(self): +# Throughput.header(self) + return "%s\tl-min\tl-max\tl-avg" % Throughput.header(self) + + def report(self): + output = Throughput.report(self) + if (self.samples > 0): + output += "\t%.2f\t%.2f\t%.2f" %(self.min, self.max, self.total/self.samples) + return output + + +# Report batch and overall statistics +class ReporterBase: + def __init__(self, batch, wantHeader): + self.batchSize = batch + self.batchCount = 0 + self.headerPrinted = not wantHeader + self.overall = None + self.batch = None + + def create(self): + return + + # Count message in the statistics + def message(self, m): + if self.overall == None: + self.overall = self.create() + self.overall.message(m) + if self.batchSize: + if self.batch == None: + self.batch = self.create() + self.batch.message(m) + self.batchCount+=1 + if self.batchCount == self.batchSize: + self.header() + print self.batch.report() + self.create() + self.batchCount = 0 + + # Print overall report. + def report(self): + if self.overall == None: + self.overall = self.create() + self.header() + print self.overall.report() + + def header(self): + if not self.headerPrinted: + if self.overall == None: + self.overall = self.create() + print self.overall.header() + self.headerPrinted = True + + +class Reporter(ReporterBase): + def __init__(self, batchSize, wantHeader, Stats): + ReporterBase.__init__(self, batchSize, wantHeader) + self.__stats = Stats + + def create(self): + ClassName = self.__stats.__class__ + return ClassName() diff --git a/qpid/cpp/bindings/qpid/perl/CMakeLists.txt b/qpid/cpp/bindings/qpid/perl/CMakeLists.txt index c8257b74aa..540c0da2de 100644 --- a/qpid/cpp/bindings/qpid/perl/CMakeLists.txt +++ b/qpid/cpp/bindings/qpid/perl/CMakeLists.txt @@ -24,6 +24,10 @@ set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/perl.i PROPERTIES CPLUSP set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/perl.i PROPERTIES SWIG_FLAGS "-I${qpid-cpp_SOURCE_DIR}/include;-I${qpid-cpp_SOURCE_DIR}/include;-I${qpid-cpp_SOURCE_DIR}/bindings") +list(APPEND SWIG_MODULE_cqpid_perl_EXTRA_DEPS + ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/qpid/qpid.i + ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/qpid/swig_perl_typemaps.i +) swig_add_module(cqpid_perl perl ${CMAKE_CURRENT_SOURCE_DIR}/perl.i) swig_link_libraries(cqpid_perl qpidmessaging qpidtypes qmf2 ${PERL_LIBRARY}) diff --git a/qpid/cpp/bindings/qpid/python/CMakeLists.txt b/qpid/cpp/bindings/qpid/python/CMakeLists.txt index 2693475dea..15f9bbb9f7 100644 --- a/qpid/cpp/bindings/qpid/python/CMakeLists.txt +++ b/qpid/cpp/bindings/qpid/python/CMakeLists.txt @@ -24,8 +24,12 @@ set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/python.i PROPERTIES CPLU set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/python.i PROPERTIES SWIG_FLAGS "-I${qpid-cpp_SOURCE_DIR}/include;-I${qpid-cpp_SOURCE_DIR}/bindings") -swig_add_module(cqpid_python python ${CMAKE_CURRENT_SOURCE_DIR}/python.i) -swig_link_libraries(cqpid_python qpidmessaging qpidtypes qmf2 ${PYTHON_LIBRARIES}) +list(APPEND SWIG_MODULE_qpid_messaging_python_EXTRA_DEPS + ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/qpid/qpid.i + ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/qpid/swig_python_typemaps.i +) +swig_add_module(qpid_messaging python ${CMAKE_CURRENT_SOURCE_DIR}/python.i) +swig_link_libraries(qpid_messaging qpidmessaging qpidtypes ${PYTHON_LIBRARIES}) set_source_files_properties(${swig_generated_file_fullname} PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing") include_directories(${PYTHON_INCLUDE_PATH} @@ -35,18 +39,17 @@ include_directories(${PYTHON_INCLUDE_PATH} ##------------------------------------ ## Install the complete Python binding ##------------------------------------ -install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m py_compile cqpid.py +install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m py_compile qpid_messaging.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") -install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile cqpid.py +install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile qpid_messaging.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cqpid.py - ${CMAKE_CURRENT_BINARY_DIR}/cqpid.pyc - ${CMAKE_CURRENT_BINARY_DIR}/cqpid.pyo +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qpid_messaging.py + ${CMAKE_CURRENT_BINARY_DIR}/qpid_messaging.pyc + ${CMAKE_CURRENT_BINARY_DIR}/qpid_messaging.pyo DESTINATION ${PYTHON_SITEARCH_PACKAGES} COMPONENT ${QPID_COMPONENT_CLIENT} ) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/_cqpid_python.so - RENAME _cqpid.so +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/_qpid_messaging.so DESTINATION ${PYTHON_SITEARCH_PACKAGES} COMPONENT ${QPID_COMPONENT_CLIENT} ) diff --git a/qpid/cpp/bindings/qpid/python/ChangeLog b/qpid/cpp/bindings/qpid/python/ChangeLog index 2c1e689f06..ff6704cdd6 100644 --- a/qpid/cpp/bindings/qpid/python/ChangeLog +++ b/qpid/cpp/bindings/qpid/python/ChangeLog @@ -1 +1,5 @@ -Version 0.24: +Version 0.26: + * QPID-4952: Changed the module name to qpid_messaging. + * QPID-5140: Added get/set method to MessageProperties. + * QPID-4924: Added examples from pure Python libraries. + * QPID-4924: Added the console example to interact with server. diff --git a/qpid/cpp/bindings/qpid/python/Makefile.am b/qpid/cpp/bindings/qpid/python/Makefile.am deleted file mode 100644 index d27cc8b3a2..0000000000 --- a/qpid/cpp/bindings/qpid/python/Makefile.am +++ /dev/null @@ -1,49 +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. -# - -if HAVE_PYTHON_DEVEL - -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/bindings -I$(top_builddir)/include -I$(top_srcdir)/src/qmf -I$(top_srcdir)/src -I$(top_builddir)/src - -generated_file_list = \ - cqpid.cpp \ - cqpid.py - -EXTRA_DIST = CMakeLists.txt python.i -BUILT_SOURCES = $(generated_file_list) -SWIG_FLAGS = -w362,401 - -$(generated_file_list): $(srcdir)/python.i - $(SWIG) -c++ -python $(SWIG_FLAGS) $(INCLUDES) $(QPID_CXXFLAGS) -I$(top_srcdir)/src/qmf -I/usr/include -o cqpid.cpp $(srcdir)/python.i - -pylibdir = $(pyexecdir) - -pylib_LTLIBRARIES = _cqpid.la -cqpiddir = $(pythondir) -cqpid_PYTHON = cqpid.py - -_cqpid_la_LDFLAGS = -avoid-version -module -shared -_cqpid_la_LIBADD = $(PYTHON_LIBS) -L$(top_builddir)/src/.libs -lqpidmessaging -lqpidtypes $(top_builddir)/src/libqpidmessaging.la $(top_builddir)/src/libqpidtypes.la -_cqpid_la_CXXFLAGS = $(INCLUDES) $(PYTHON_CFLAGS) -fno-strict-aliasing -nodist__cqpid_la_SOURCES = cqpid.cpp - -CLEANFILES = $(generated_file_list) - -endif # HAVE_PYTHON_DEVEL - diff --git a/qpid/cpp/bindings/qpid/python/extra_dist/CMakeLists.txt b/qpid/cpp/bindings/qpid/python/extra_dist/CMakeLists.txt index dbb0102db1..8ddd7869ae 100644 --- a/qpid/cpp/bindings/qpid/python/extra_dist/CMakeLists.txt +++ b/qpid/cpp/bindings/qpid/python/extra_dist/CMakeLists.txt @@ -49,10 +49,10 @@ SET_SOURCE_FILES_PROPERTIES (${CMAKE_CURRENT_SOURCE_DIR}/python.i SET_SOURCE_FILES_PROPERTIES (${CMAKE_CURRENT_SOURCE_DIR}/python.i PROPERTIES SWIG_FLAGS "-I${QPID_INCLUDE_DIR}") -SWIG_ADD_MODULE (cqpid_python python +SWIG_ADD_MODULE (qpid_messaging_python python ${CMAKE_CURRENT_SOURCE_DIR}/python.i) -SWIG_LINK_LIBRARIES (cqpid_python +SWIG_LINK_LIBRARIES (qpid_messaging_python qpidmessaging qpidtypes ${PYTHON_LIBRARIES}) @@ -61,9 +61,9 @@ SWIG_LINK_LIBRARIES (cqpid_python ## Install the bindings ## -------------------- -INSTALL (CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -m py_compile cqpid.py +INSTALL (CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -m py_compile qpid_messaging.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") -INSTALL (CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile cqpid.py +INSTALL (CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile qpid_messaging.py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})") SET_SOURCE_FILES_PROPERTIES (${swig_generated_file_fullname} @@ -75,12 +75,12 @@ INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_SOURCE_DIR} ) -INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/cqpid.py - ${CMAKE_CURRENT_BINARY_DIR}/cqpid.pyc - ${CMAKE_CURRENT_BINARY_DIR}/cqpid.pyo +INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/qpid_messaging.py + ${CMAKE_CURRENT_BINARY_DIR}/qpid_messaging.pyc + ${CMAKE_CURRENT_BINARY_DIR}/qpid_messaging.pyo DESTINATION ${PYTHON_SITEARCH_PACKAGES}) -INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/_cqpid_python.so - RENAME _cqpid.so +INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/_qpid_messaging_python.so + RENAME _qpid_messaging.so DESTINATION ${PYTHON_SITEARCH_PACKAGES}) diff --git a/qpid/cpp/bindings/qpid/python/python.i b/qpid/cpp/bindings/qpid/python/python.i index 148cad5e63..624cee35bc 100644 --- a/qpid/cpp/bindings/qpid/python/python.i +++ b/qpid/cpp/bindings/qpid/python/python.i @@ -17,7 +17,8 @@ * under the License. */ -%module cqpid +%module qpid_messaging + %include "std_string.i" %include "qpid/swig_python_typemaps.i" @@ -29,7 +30,7 @@ /* * Exceptions * - * The convention below is that exceptions in _cqpid.so have the same + * The convention below is that exceptions in _qpid_messaging.so have the same * names as in the C++ library. They get renamed to their Python * equivalents when brought into the Python wrapping */ @@ -39,12 +40,12 @@ static PyObject* exception; %} %init %{ exception = PyErr_NewException( - (char *) ("_cqpid." #exception), parent, NULL); + (char *) ("_qpid_messaging." #exception), parent, NULL); Py_INCREF(exception); PyModule_AddObject(m, #exception, exception); %} %pythoncode %{ - exception = _cqpid. ## exception + exception = _qpid_messaging. ## exception %} %enddef @@ -139,8 +140,9 @@ QPID_EXCEPTION(UnauthorizedAccess, SessionError) /* This only renames the non-const version (I believe). Then again, I * don't even know why there is a non-const version of the method. */ %rename(opened) qpid::messaging::Connection::isOpen(); +%rename(_close) qpid::messaging::Connection::close(); %rename(receiver) qpid::messaging::Session::createReceiver; -%rename(sender) qpid::messaging::Session::createSender; +%rename(_sender) qpid::messaging::Session::createSender; %rename(_acknowledge_all) qpid::messaging::Session::acknowledge(bool); %rename(_acknowledge_msg) qpid::messaging::Session::acknowledge( Message &, bool); @@ -163,26 +165,28 @@ QPID_EXCEPTION(UnauthorizedAccess, SessionError) %extend qpid::messaging::Connection { %pythoncode %{ - # Handle the different options by converting underscores to hyphens. - # Also, the sasl_mechanisms option in Python has no direct - # equivalent in C++, so we will translate them to sasl_mechanism - # when possible. def __init__(self, url=None, **options): if url: - args = [url] + args = [str(url)] else: args = [] - if options : - if "sasl_mechanisms" in options : - if ' ' in options.get("sasl_mechanisms",'') : - raise Exception( - "C++ Connection objects are unable to handle " - "multiple sasl-mechanisms") - options["sasl_mechanism"] = options.pop("sasl_mechanisms") - args.append(options) - this = _cqpid.new_Connection(*args) + if options: + # remove null valued options + clean_opts = {} + for k, v in options.iteritems(): + if v: + clean_opts[k] = v + args.append(clean_opts) + this = _qpid_messaging.new_Connection(*args) try: self.this.append(this) except: self.this = this + + def attached(self): + return self.opened() + + def close(self, timeout=None): + #timeout not supported in c++ + self._close() %} /* Return a pre-existing session with the given name, if one @@ -236,18 +240,29 @@ QPID_EXCEPTION(UnauthorizedAccess, SessionError) __swig_getmethods__["connection"] = getConnection if _newclass: connection = property(getConnection) + + def sender(self, target, **options) : + s = self._sender(target) + s._setDurable(options.get("durable")) + return s %} } %extend qpid::messaging::Receiver { %pythoncode %{ + def _get_source(self): + return self.getAddress().str() + __swig_getmethods__["capacity"] = getCapacity __swig_setmethods__["capacity"] = setCapacity if _newclass: capacity = property(getCapacity, setCapacity) __swig_getmethods__["session"] = getSession if _newclass: session = property(getSession) + + __swig_getmethods__["source"] = _get_source + if _newclass: source = property(_get_source) %} %pythoncode %{ @@ -263,25 +278,68 @@ QPID_EXCEPTION(UnauthorizedAccess, SessionError) %extend qpid::messaging::Sender { %pythoncode %{ + def _get_target(self): + return self.getAddress().str() + + def _setDurable(self, d): + self.durable = d + def send(self, object, sync=True) : if isinstance(object, Message): message = object else: message = Message(object) + if self.durable and message.durable is None: + message.durable = self.durable return self._send(message, sync) - + __swig_getmethods__["capacity"] = getCapacity __swig_setmethods__["capacity"] = setCapacity if _newclass: capacity = property(getCapacity, setCapacity) __swig_getmethods__["session"] = getSession if _newclass: session = property(getSession) + + __swig_getmethods__["target"] = _get_target + if _newclass: source = property(_get_target) + %} } %extend qpid::messaging::Message { %pythoncode %{ + class MessageProperties: + def __init__(self, msg): + self.msg = msg + self.properties = self.msg.getProperties() + + def __len__(self): + return self.properties.__len__() + + def __getitem__(self, key): + return self.properties[key]; + + def get(self, key): + return self.__getitem__(key) + + def __setitem__(self, key, value): + self.properties[key] = value + self.msg.setProperty(key, value) + + def set(self, key, value): + self.__setitem__(key, value) + + def __delitem__(self, key): + del self.properties[key] + self.msg.setProperties(self.properties) + + def __iter__(self): + return self.properties.iteritems() + + def __repr__(self): + return str(self.properties) + # UNSPECIFIED was module level before, but I do not # know how to insert python code at the top of the module. # (A bare "%pythoncode" inserts at the end. @@ -290,10 +348,10 @@ QPID_EXCEPTION(UnauthorizedAccess, SessionError) subject=None, user_id=None, reply_to=None, correlation_id=None, durable=None, priority=None, ttl=None, properties=None): - this = _cqpid.new_Message('') + this = _qpid_messaging.new_Message('') try: self.this.append(this) except: self.this = this - if content : + if not content is None: self.content = content if content_type != UNSPECIFIED : self.content_type = content_type @@ -314,34 +372,46 @@ QPID_EXCEPTION(UnauthorizedAccess, SessionError) if ttl is not None : self.ttl = ttl if properties is not None : - # Can't set properties via (inst).getProperties, because - # the typemaps make a copy of the underlying properties. - # Instead, set via setProperty for the time-being - for k, v in properties.iteritems() : - self.setProperty(k, v) + self.setProperties(properties) + + def _get_msg_props(self): + try: + return self._msg_props + except AttributeError: + self._msg_props = Message.MessageProperties(self) + return self._msg_props def _get_content(self) : + obj = self.getContentObject() + if obj: + return obj if self.content_type == "amqp/list" : return decodeList(self) if self.content_type == "amqp/map" : return decodeMap(self) return self.getContent() def _set_content(self, content) : - if isinstance(content, basestring) : + if isinstance(content, str) : self.setContent(content) + elif isinstance(content, unicode) : + if not self.content_type: self.content_type = "text/plain" + self.setContent(str(content)) elif isinstance(content, list) or isinstance(content, dict) : encode(content, self) else : - # Not a type we can handle. Try setting it anyway, - # although this will probably lead to a swig error - self.setContent(content) + self.setContentObject(content) __swig_getmethods__["content"] = _get_content __swig_setmethods__["content"] = _set_content if _newclass: content = property(_get_content, _set_content) - __swig_getmethods__["content_type"] = getContentType + def _get_content_type(self) : + ct = self.getContentType() + if ct == "": return None + else: return ct + + __swig_getmethods__["content_type"] = _get_content_type __swig_setmethods__["content_type"] = setContentType - if _newclass: content_type = property(getContentType, setContentType) + if _newclass: content_type = property(_get_content_type, setContentType) __swig_getmethods__["id"] = getMessageId __swig_setmethods__["id"] = setMessageId @@ -379,8 +449,8 @@ QPID_EXCEPTION(UnauthorizedAccess, SessionError) __swig_setmethods__["durable"] = setDurable if _newclass: durable = property(getDurable, setDurable) - __swig_getmethods__["properties"] = getProperties - if _newclass: properties = property(getProperties) + __swig_getmethods__["properties"] = _get_msg_props + if _newclass: properties = property(_get_msg_props) def getReplyTo(self) : return self._getReplyTo().str() @@ -389,7 +459,7 @@ QPID_EXCEPTION(UnauthorizedAccess, SessionError) __swig_getmethods__["reply_to"] = getReplyTo __swig_setmethods__["reply_to"] = setReplyTo if _newclass: reply_to = property(getReplyTo, setReplyTo) - + def __repr__(self): args = [] for name in ["id", "subject", "user_id", "reply_to", diff --git a/qpid/cpp/bindings/qpid/ruby/CMakeLists.txt b/qpid/cpp/bindings/qpid/ruby/CMakeLists.txt index a56fac7c8a..60c60445b7 100644 --- a/qpid/cpp/bindings/qpid/ruby/CMakeLists.txt +++ b/qpid/cpp/bindings/qpid/ruby/CMakeLists.txt @@ -39,6 +39,10 @@ include_directories(${RUBY_INCLUDE_DIRS} ${qpid-cpp_SOURCE_DIR}/include ${qpid-cpp_SOURCE_DIR}/bindings) +list(APPEND SWIG_MODULE_cqpid_ruby_EXTRA_DEPS + ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/qpid/qpid.i + ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/qpid/swig_ruby_typemaps.i +) swig_add_module(cqpid_ruby ruby ${CMAKE_CURRENT_SOURCE_DIR}/ruby.i) swig_link_libraries(cqpid_ruby qpidmessaging qpidtypes qmf2 ${RUBY_LIBRARY}) diff --git a/qpid/cpp/bindings/qpid/ruby/ChangeLog b/qpid/cpp/bindings/qpid/ruby/ChangeLog index 03813053d2..f9906c2d51 100644 --- a/qpid/cpp/bindings/qpid/ruby/ChangeLog +++ b/qpid/cpp/bindings/qpid/ruby/ChangeLog @@ -1,4 +1,10 @@ -Verison 0.22: +Version 0.26: + * QPID-4834: Ruby client examples incorrectly handles '--connection-options' option + +Version 0.24: + * No language-specific changes. + +Version 0.22: * Qpid::Messaging::Address can use an address string on creation. * Qpid::Messaging::Message can use an address string for reply_to. * Removed errors.rb and the KeyError and SessionNameException errors. diff --git a/qpid/cpp/bindings/qpid/ruby/Makefile.am b/qpid/cpp/bindings/qpid/ruby/Makefile.am deleted file mode 100644 index 398449c7ed..0000000000 --- a/qpid/cpp/bindings/qpid/ruby/Makefile.am +++ /dev/null @@ -1,44 +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. -# - -if HAVE_RUBY_DEVEL - -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/bindings -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_builddir)/src - -EXTRA_DIST = CMakeLists.txt ruby.i -BUILT_SOURCES = cqpid.cpp -SWIG_FLAGS = -w362,401 - -rubylibdir = $(RUBY_LIB) - -cqpid.cpp: $(srcdir)/ruby.i - $(SWIG) -ruby -c++ $(SWIG_FLAGS) $(INCLUDES) $(QPID_CXXFLAGS) -I/usr/include -o cqpid.cpp $(srcdir)/ruby.i - -rubylibarchdir = $(RUBY_LIB_ARCH) -rubylibarch_LTLIBRARIES = cqpid.la - -cqpid_la_LDFLAGS = -avoid-version -module -shared -shrext ".$(RUBY_DLEXT)" -cqpid_la_LIBADD = $(RUBY_LIBS) -L$(top_builddir)/src/.libs -lqpidmessaging -lqpidtypes \ - $(top_builddir)/src/libqpidmessaging.la $(top_builddir)/src/libqpidtypes.la -cqpid_la_CXXFLAGS = $(INCLUDES) -I$(RUBY_INC) -I$(RUBY_INC_ARCH) -fno-strict-aliasing -nodist_cqpid_la_SOURCES = cqpid.cpp - -CLEANFILES = cqpid.cpp - -endif # HAVE_RUBY_DEVEL diff --git a/qpid/cpp/bindings/qpid/ruby/examples/spout.rb b/qpid/cpp/bindings/qpid/ruby/examples/spout.rb index f7170f146b..6a0751e682 100644 --- a/qpid/cpp/bindings/qpid/ruby/examples/spout.rb +++ b/qpid/cpp/bindings/qpid/ruby/examples/spout.rb @@ -26,6 +26,7 @@ options = { :broker => "127.0.0.1", :address => "", :timeout => 0, + :durable => false, :count => 1, :properties => {}, :content => nil, @@ -51,6 +52,11 @@ opts = OptionParser.new do |opts| options[:timeout] = Qpid::Messaging::Duration.new timeout * 1000 end + opts.on("-d", "--durable", + "make the message durable (def. #{options[:durable]})") do + options[:durable] = true + end + opts.on("-c", "--count VALUE", Integer, "stop after count messages have been sent, zero disables") do |count| options[:count] = count @@ -85,8 +91,9 @@ opts = OptionParser.new do |opts| options[:content] = content end - opts.on(nil, "--connection-options VALUE", + opts.on("--connection-options VALUE", "connection options string in the form {name1:value1, name2:value2}") do |conopts| + options[:connection_options] = conopts end end @@ -100,7 +107,27 @@ end # now get the non-arg options options[:address] = ARGV[0] unless ARGV[0].nil? -connection = Qpid::Messaging::Connection.new :url => options[:broker], :options => options[:connection_options] +# process the connection options +unless options[:connection_options].nil? + fields = options[:connection_options].gsub(/^{(.*)}$/, '\1') + # remove any surrounding braces + if /{.*}/ =~ fields + fields = fields[1..-2] + end + # break up the options separated by commas + keysvalues = {} + fields.split(",").each do |field| + if /.+:.+/ =~ field + (key, value) = field.split(":") + keysvalues[key] = value + end + end + # now store the options + options[:connection_options] = keysvalues +end + +connection = Qpid::Messaging::Connection.new(:url => options[:broker], + :options => options[:connection_options]) connection.open session = connection.create_session sender = session.create_sender options[:address] @@ -114,6 +141,7 @@ options[:properties].each_key {|key| message[key] = options[:properties][key]} elsif options[:content] message.content = options[:content] end + message.durable = options[:durable] message.content = options[:content] unless options[:content].nil? message.properties["spout-id"] = "#{count}" message.reply_to = options[:replyto] unless options[:replyto].nil? || options[:replyto].empty? diff --git a/qpid/cpp/bld-winsdk.ps1 b/qpid/cpp/bld-winsdk.ps1 index eac771f707..42e6e636a4 100644 --- a/qpid/cpp/bld-winsdk.ps1 +++ b/qpid/cpp/bld-winsdk.ps1 @@ -218,19 +218,17 @@ function BuildAPlatform ('bin/msvc*.dll', 'bin/Release') , ('bin/*d.dll', 'bin/Debug'), ('bin/*.dll', 'bin/Release'), - ('bin/*test.exe', 'bin/Release') + ('bin/*test.exe', 'bin/Release'), + ('bin/qpid-send.exe', 'bin/Release'), + ('bin/qpid-receive.exe', 'bin/Release') ) $preserve=( - 'include/qpid/agent', - 'include/qpid/amqp_0_10', - 'include/qpid/management', 'include/qpid/messaging', 'include/qpid/sys/IntegerTypes.h', 'include/qpid/sys/windows/IntegerTypes.h', 'include/qpid/sys/posix/IntegerTypes.h', 'include/qpid/types', - 'include/qpid/CommonImportExport.h', 'include/qpid/ImportExport.h') $remove=( @@ -244,8 +242,10 @@ function BuildAPlatform 'bin/*PDB/qpidxarm*.*', 'bin/boost_regex*.*', 'bin/boost', + 'bin/*.exe', + 'bin/qmf-gen', + 'bin/qpidt', 'conf', - 'examples/qmf-console', 'examples/*.sln', 'examples/*.vcproj', 'examples/messaging/*.vcproj', @@ -287,8 +287,8 @@ function BuildAPlatform # Set top level info files to DOS line endings
Unix2Dos "$install_dir/README-winsdk.txt"
- Unix2Dos "$install_dir/LICENSE"
- Unix2Dos "$install_dir/NOTICE" + Unix2Dos "$install_dir/docs/LICENSE"
+ Unix2Dos "$install_dir/docs/NOTICE" Unix2Dos "$install_dir/examples/README.txt"
# Install the .NET binding example source code diff --git a/qpid/cpp/bootstrap b/qpid/cpp/bootstrap deleted file mode 100755 index d6ff19765b..0000000000 --- a/qpid/cpp/bootstrap +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# -# 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. -# - -# Copy the global QPID_VERSION.txt file into the source tree. -cp ../QPID_VERSION.txt . - -aclocal -I m4 -autoheader -libtoolize --automake - -# Create initial Makefile fragments that will force make to generate -# the real ones. -cat > src/rubygen.mk <<EOF -\$(srcdir)/rubygen.mk: force - \$(rgen_cmd) \$(srcdir)/rubygen.mk -EOF -cat > src/managementgen.mk <<EOF -\$(srcdir)/managementgen.mk: force - \$(mgen_cmd) -EOF - -automake --add-missing -autoconf - -# Optionally do the build as well. -if [ "$1" = "-build" -o "$1" = "--build" ] ; then - shift - ./configure "$@" - make - make check -fi diff --git a/qpid/cpp/build-aux/.gitignore b/qpid/cpp/build-aux/.gitignore deleted file mode 100644 index 6bab38bdf9..0000000000 --- a/qpid/cpp/build-aux/.gitignore +++ /dev/null @@ -1,20 +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. -# - -/py-compile diff --git a/qpid/cpp/build-aux/compile b/qpid/cpp/build-aux/compile deleted file mode 100755 index 1b1d232169..0000000000 --- a/qpid/cpp/build-aux/compile +++ /dev/null @@ -1,142 +0,0 @@ -#! /bin/sh -# Wrapper for compilers which do not understand `-c -o'. - -scriptversion=2005-05-14.22 - -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. -# Written by Tom Tromey <tromey@cygnus.com>. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to <bug-automake@gnu.org> or send patches to -# <automake-patches@gnu.org>. - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: compile [--help] [--version] PROGRAM [ARGS] - -Wrapper for compilers which do not understand `-c -o'. -Remove `-o dest.o' from ARGS, run PROGRAM with the remaining -arguments, and rename the output as expected. - -If you are trying to build a whole package this is not the -right script to run: please start by reading the file `INSTALL'. - -Report bugs to <bug-automake@gnu.org>. -EOF - exit $? - ;; - -v | --v*) - echo "compile $scriptversion" - exit $? - ;; -esac - -ofile= -cfile= -eat= - -for arg -do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as `compile cc -o foo foo.c'. - # So we strip `-o arg' only if arg is an object. - eat=1 - case $2 in - *.o | *.obj) - ofile=$2 - ;; - *) - set x "$@" -o "$2" - shift - ;; - esac - ;; - *.c) - cfile=$1 - set x "$@" "$1" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift -done - -if test -z "$ofile" || test -z "$cfile"; then - # If no `-o' option was seen then we might have been invoked from a - # pattern rule where we don't need one. That is ok -- this is a - # normal compilation that the losing compiler can handle. If no - # `.c' file was seen then we are probably linking. That is also - # ok. - exec "$@" -fi - -# Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` - -# Create the lock directory. -# Note: use `[/.-]' here to ensure that we don't use the same name -# that we are using for the .o file. Also, base the name on the expected -# object file name, since that is what matters with a parallel build. -lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d -while true; do - if mkdir "$lockdir" >/dev/null 2>&1; then - break - fi - sleep 1 -done -# FIXME: race condition here if user kills between mkdir and trap. -trap "rmdir '$lockdir'; exit 1" 1 2 15 - -# Run the compile. -"$@" -ret=$? - -if test -f "$cofile"; then - mv "$cofile" "$ofile" -elif test -f "${cofile}bj"; then - mv "${cofile}bj" "$ofile" -fi - -rmdir "$lockdir" -exit $ret - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/qpid/cpp/build-aux/config.guess b/qpid/cpp/build-aux/config.guess deleted file mode 100755 index c93201a4d2..0000000000 --- a/qpid/cpp/build-aux/config.guess +++ /dev/null @@ -1,1501 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, -# Inc. - -timestamp='2006-11-08' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner <per@bothner.com>. -# Please send patches to <config-patches@gnu.org>. Submit a context -# diff and a properly formatted ChangeLog entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to <config-patches@gnu.org>." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE="alpha" ;; - "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; - "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; - "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; - "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; - "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; - "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; - "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; - "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; - "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; - "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; - "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; - "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include <stdio.h> /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include <sys/systemcfg.h> - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include <stdlib.h> - #include <unistd.h> - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = "hppa2.0w" ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null - then - HP_ARCH="hppa2.0w" - else - HP_ARCH="hppa64" - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include <unistd.h> - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - x86:Interix*:[3456]*) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - EM64T:Interix*:[3456]* | authenticamd:Interix*:[3456]*) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit ;; - crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu - exit ;; - frv:Linux:*:*) - echo frv-unknown-linux-gnu - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - or32:Linux:*:*) - echo or32-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu - exit ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include <features.h> - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^LIBC/{ - s: ::g - p - }'`" - test x"${LIBC}" != x && { - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit - } - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo ${UNAME_MACHINE}-pc-isc$UNAME_REL - elif /bin/uname -X 2>/dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says <Richard.M.Bartel@ccMail.Census.GOV> - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes <hewes@openmarket.com>. - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c <<EOF -#ifdef _SEQUENT_ -# include <sys/types.h> -# include <sys/utsname.h> -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include <sys/param.h> - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include <sys/param.h> -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi - -cat >&2 <<EOF -$0: unable to guess system type - -This script, last modified $timestamp, has failed to recognize -the operating system you are using. It is advised that you -download the most up to date version of the config scripts from - - http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess -and - http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub - -If the version you run ($0) is already up to date, please -send the following data and any information you think might be -pertinent to <config-patches@gnu.org> in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/qpid/cpp/build-aux/config.rpath b/qpid/cpp/build-aux/config.rpath deleted file mode 100755 index c492a93b66..0000000000 --- a/qpid/cpp/build-aux/config.rpath +++ /dev/null @@ -1,614 +0,0 @@ -#! /bin/sh -# Output a system dependent set of variables, describing how to set the -# run time search path of shared libraries in an executable. -# -# Copyright 1996-2006 Free Software Foundation, Inc. -# Taken from GNU libtool, 2001 -# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# The first argument passed to this file is the canonical host specification, -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld -# should be set by the caller. -# -# The set of defined variables is at the end of this script. - -# Known limitations: -# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer -# than 256 bytes, otherwise the compiler driver will dump core. The only -# known workaround is to choose shorter directory names for the build -# directory and/or the installation directory. - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a -shrext=.so - -host="$1" -host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - -# Code taken from libtool.m4's _LT_CC_BASENAME. - -for cc_temp in $CC""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` - -# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. - -wl= -if test "$GCC" = yes; then - wl='-Wl,' -else - case "$host_os" in - aix*) - wl='-Wl,' - ;; - darwin*) - case $cc_basename in - xlc*) - wl='-Wl,' - ;; - esac - ;; - mingw* | pw32* | os2*) - ;; - hpux9* | hpux10* | hpux11*) - wl='-Wl,' - ;; - irix5* | irix6* | nonstopux*) - wl='-Wl,' - ;; - newsos6) - ;; - linux*) - case $cc_basename in - icc* | ecc*) - wl='-Wl,' - ;; - pgcc | pgf77 | pgf90) - wl='-Wl,' - ;; - ccc*) - wl='-Wl,' - ;; - como) - wl='-lopt=' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - wl='-Wl,' - ;; - esac - ;; - esac - ;; - osf3* | osf4* | osf5*) - wl='-Wl,' - ;; - sco3.2v5*) - ;; - solaris*) - wl='-Wl,' - ;; - sunos4*) - wl='-Qoption ld ' - ;; - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - wl='-Wl,' - ;; - sysv4*MP*) - ;; - unicos*) - wl='-Wl,' - ;; - uts4*) - ;; - esac -fi - -# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. - -hardcode_libdir_flag_spec= -hardcode_libdir_separator= -hardcode_direct=no -hardcode_minus_L=no - -case "$host_os" in - cygwin* | mingw* | pw32*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; -esac - -ld_shlibs=yes -if test "$with_gnu_ld" = yes; then - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - # Unlike libtool, we use -rpath here, not --rpath, since the documented - # option of GNU ld is called -rpath, not --rpath. - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - case "$host_os" in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs=no - fi - ;; - amigaos*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we cannot use - # them. - ld_shlibs=no - ;; - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - cygwin* | mingw* | pw32*) - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - interix3*) - hardcode_direct=no - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - linux*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - netbsd*) - ;; - solaris*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) - ld_shlibs=no - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' - else - ld_shlibs=no - fi - ;; - esac - ;; - sunos4*) - hardcode_direct=yes - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - : - else - ld_shlibs=no - fi - ;; - esac - if test "$ld_shlibs" = no; then - hardcode_libdir_flag_spec= - fi -else - case "$host_os" in - aix3*) - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - else - aix_use_runtimelinking=no - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix5*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - fi - hardcode_direct=yes - hardcode_libdir_separator=':' - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - hardcode_direct=yes - else - # We have old collect2 - hardcode_direct=unsupported - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - ;; - esac - fi - # Begin _LT_AC_SYS_LIBPATH_AIX. - echo 'int main () { return 0; }' > conftest.c - ${CC} ${LDFLAGS} conftest.c -o conftest - aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` - if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` - fi - if test -z "$aix_libpath"; then - aix_libpath="/usr/lib:/lib" - fi - rm -f conftest.c conftest - # End _LT_AC_SYS_LIBPATH_AIX. - if test "$aix_use_runtimelinking" = yes; then - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - else - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - fi - fi - ;; - amigaos*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # see comment about different semantics on the GNU ld section - ld_shlibs=no - ;; - bsdi[45]*) - ;; - cygwin* | mingw* | pw32*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - libext=lib - ;; - darwin* | rhapsody*) - hardcode_direct=no - if test "$GCC" = yes ; then - : - else - case $cc_basename in - xlc*) - ;; - *) - ld_shlibs=no - ;; - esac - fi - ;; - dgux*) - hardcode_libdir_flag_spec='-L$libdir' - ;; - freebsd1*) - ld_shlibs=no - ;; - freebsd2.2*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - freebsd2*) - hardcode_direct=yes - hardcode_minus_L=yes - ;; - freebsd* | kfreebsd*-gnu | dragonfly*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - hpux9*) - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - hpux10*) - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - fi - ;; - hpux11*) - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - case $host_cpu in - hppa*64*|ia64*) - hardcode_direct=no - ;; - *) - hardcode_direct=yes - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - esac - fi - ;; - irix5* | irix6* | nonstopux*) - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - netbsd*) - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - ;; - newsos6) - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - openbsd*) - hardcode_direct=yes - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - else - case "$host_os" in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - osf3*) - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - osf4* | osf5*) - if test "$GCC" = yes; then - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - # Both cc and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - hardcode_libdir_separator=: - ;; - solaris*) - hardcode_libdir_flag_spec='-R$libdir' - ;; - sunos4*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - ;; - sysv4) - case $host_vendor in - sni) - hardcode_direct=yes # is this really true??? - ;; - siemens) - hardcode_direct=no - ;; - motorola) - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - ;; - esac - ;; - sysv4.3*) - ;; - sysv4*MP*) - if test -d /usr/nec; then - ld_shlibs=yes - fi - ;; - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) - ;; - sysv5* | sco3.2v5* | sco5v6*) - hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - hardcode_libdir_separator=':' - ;; - uts4*) - hardcode_libdir_flag_spec='-L$libdir' - ;; - *) - ld_shlibs=no - ;; - esac -fi - -# Check dynamic linker characteristics -# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. -libname_spec='lib$name' -case "$host_os" in - aix3*) - ;; - aix4* | aix5*) - ;; - amigaos*) - ;; - beos*) - ;; - bsdi[45]*) - ;; - cygwin* | mingw* | pw32*) - shrext=.dll - ;; - darwin* | rhapsody*) - shrext=.dylib - ;; - dgux*) - ;; - freebsd1*) - ;; - kfreebsd*-gnu) - ;; - freebsd* | dragonfly*) - ;; - gnu*) - ;; - hpux9* | hpux10* | hpux11*) - case $host_cpu in - ia64*) - shrext=.so - ;; - hppa*64*) - shrext=.sl - ;; - *) - shrext=.sl - ;; - esac - ;; - interix3*) - ;; - irix5* | irix6* | nonstopux*) - case "$host_os" in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; - *) libsuff= shlibsuff= ;; - esac - ;; - esac - ;; - linux*oldld* | linux*aout* | linux*coff*) - ;; - linux*) - ;; - knetbsd*-gnu) - ;; - netbsd*) - ;; - newsos6) - ;; - nto-qnx*) - ;; - openbsd*) - ;; - os2*) - libname_spec='$name' - shrext=.dll - ;; - osf3* | osf4* | osf5*) - ;; - solaris*) - ;; - sunos4*) - ;; - sysv4 | sysv4.3*) - ;; - sysv4*MP*) - ;; - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - ;; - uts4*) - ;; -esac - -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' -escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` -shlibext=`echo "$shrext" | sed -e 's,^\.,,'` -escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` - -LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF - -# How to pass a linker flag through the compiler. -wl="$escaped_wl" - -# Static library suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally "so"). -shlibext="$shlibext" - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec" - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator="$hardcode_libdir_separator" - -# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the -# resulting binary. -hardcode_direct="$hardcode_direct" - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L="$hardcode_minus_L" - -EOF diff --git a/qpid/cpp/build-aux/config.sub b/qpid/cpp/build-aux/config.sub deleted file mode 100755 index 7ccee73057..0000000000 --- a/qpid/cpp/build-aux/config.sub +++ /dev/null @@ -1,1619 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, -# Inc. - -timestamp='2006-11-07' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Please send patches to <config-patches@gnu.org>. Submit a context -# diff and a properly formatted ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to <config-patches@gnu.org>." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ - | bfin \ - | c4x | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | mt \ - | msp430 \ - | nios | nios2 \ - | ns16k | ns32k \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | score \ - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nios-* | nios2-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ - | xstormy16-* | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16c) - basic_machine=cr16c-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; - -zvmoe) - os=-zvmoe - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/qpid/cpp/build-aux/depcomp b/qpid/cpp/build-aux/depcomp deleted file mode 100755 index ca5ea4e1ef..0000000000 --- a/qpid/cpp/build-aux/depcomp +++ /dev/null @@ -1,584 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2006-10-15.18 - -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software -# Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: depcomp [--help] [--version] PROGRAM [ARGS] - -Run PROGRAMS ARGS to compile a file, generating dependencies -as side-effects. - -Environment variables: - depmode Dependency tracking mode. - source Source file read by `PROGRAMS ARGS'. - object Object file output by `PROGRAMS ARGS'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputing dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to <bug-automake@gnu.org>. -EOF - exit $? - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit $? - ;; -esac - -if test -z "$depmode" || test -z "$source" || test -z "$object"; then - echo "depcomp: Variables source, object and depmode must be set" 1>&2 - exit 1 -fi - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Some modes work just like other modes, but use different flags. We -# parameterize here, but still list the modes in the big case below, -# to make depend.m4 easier to write. Note that we *cannot* use a case -# here, because this file can only contain one case statement. -if test "$depmode" = hp; then - # HP compiler uses -M and no extra arg. - gccflag=-M - depmode=gcc -fi - -if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout -fi - -case "$depmode" in -gcc3) -## gcc 3 implements dependency tracking that does exactly what -## we want. Yay! Note: for some reason libtool 1.4 doesn't like -## it if -MD -MP comes after the -MF stuff. Hmm. -## Unfortunately, FreeBSD c89 acceptance of flags depends upon -## the command line argument order; so add the flags where they -## appear in depend2.am. Note that the slowdown incurred here -## affects only configure: in makefiles, %FASTDEP% shortcuts this. - for arg - do - case $arg in - -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; - *) set fnord "$@" "$arg" ;; - esac - shift # fnord - shift # $arg - done - "$@" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - if test -z "$gccflag"; then - gccflag=-MD, - fi - "$@" -Wp,"$gccflag$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the - # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> $depfile - echo >> $depfile - - # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> $depfile - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts `$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` - tmpdepfile="$stripped.u" - if test "$libtool" = yes; then - "$@" -Wc,-M - else - "$@" -M - fi - stat=$? - - if test -f "$tmpdepfile"; then : - else - stripped=`echo "$stripped" | sed 's,^.*/,,'` - tmpdepfile="$stripped.u" - fi - - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - - if test -f "$tmpdepfile"; then - outname="$stripped.o" - # Each line is of the form `foo.o: dependent.h'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" - sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -icc) - # Intel's C compiler understands `-MD -MF file'. However on - # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # ICC 7.0 will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want: - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - # ICC 7.1 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using \ : - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h', - # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. - # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | - sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp2) - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 - # compilers, which have integrated preprocessors. The correct option - # to use with these is +Maked; it writes dependencies to a file named - # 'foo.d', which lands next to the object file, wherever that - # happens to be. - # Much of this is similar to the tru64 case; see comments there. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir.libs/$base.d - "$@" -Wc,+Maked - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - "$@" +Maked - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" - # Add `dependent.h:' lines. - sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" "$tmpdepfile2" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - # With Tru64 cc, shared objects can also be used to make a - # static library. This mechanism is used in libtool 1.4 series to - # handle both shared and static libraries in a single compilation. - # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. - # - # With libtool 1.5 this exception was removed, and libtool now - # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 - tmpdepfile2=$dir$base.o.d # libtool 1.5 - tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 - tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.o.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - tmpdepfile4=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for `:' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. - "$@" $dashmflag | - sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no - for arg in "$@"; do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix="`echo $object | sed 's/^.*\././'`" - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test $1 != '--mode=compile'; do - shift - done - shift - fi - - # Remove `-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o, - # because we must use -o when running libtool. - "$@" || exit $? - IFS=" " - for arg - do - case "$arg" in - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" - . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/qpid/cpp/build-aux/install-sh b/qpid/cpp/build-aux/install-sh deleted file mode 100755 index 4fbbae7b7f..0000000000 --- a/qpid/cpp/build-aux/install-sh +++ /dev/null @@ -1,507 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2006-10-14.15 - -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. - -nl=' -' -IFS=" "" $nl" - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi - -# Put in absolute file names if you don't have them in your path; -# or use environment vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -posix_glob= -posix_mkdir= - -# Desired mode of installed file. -mode=0755 - -chmodcmd=$chmodprog -chowncmd= -chgrpcmd= -stripcmd= -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src= -dst= -dir_arg= -dstarg= -no_target_directory= - -usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE - or: $0 [OPTION]... SRCFILES... DIRECTORY - or: $0 [OPTION]... -t DIRECTORY SRCFILES... - or: $0 [OPTION]... -d DIRECTORIES... - -In the 1st form, copy SRCFILE to DSTFILE. -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. -In the 4th, create DIRECTORIES. - -Options: --c (ignored) --d create directories instead of installing files. --g GROUP $chgrpprog installed files to GROUP. --m MODE $chmodprog installed files to MODE. --o USER $chownprog installed files to USER. --s $stripprog installed files. --t DIRECTORY install into DIRECTORY. --T report an error if DSTFILE is a directory. ---help display this help and exit. ---version display version info and exit. - -Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG -" - -while test $# -ne 0; do - case $1 in - -c) shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - --help) echo "$usage"; exit $?;; - - -m) mode=$2 - shift - shift - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -s) stripcmd=$stripprog - shift - continue;; - - -t) dstarg=$2 - shift - shift - continue;; - - -T) no_target_directory=true - shift - continue;; - - --version) echo "$0 $scriptversion"; exit $?;; - - --) shift - break;; - - -*) echo "$0: invalid option: $1" >&2 - exit 1;; - - *) break;; - esac -done - -if test $# -ne 0 && test -z "$dir_arg$dstarg"; then - # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dstarg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dstarg" - shift # fnord - fi - shift # arg - dstarg=$arg - done -fi - -if test $# -eq 0; then - if test -z "$dir_arg"; then - echo "$0: no input file specified." >&2 - exit 1 - fi - # It's OK to call `install-sh -d' without argument. - # This can happen when creating conditional directories. - exit 0 -fi - -if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 - - # Set umask so as not to create temps with too-generous modes. - # However, 'strip' requires both read and write access to temps. - case $mode in - # Optimize common cases. - *644) cp_umask=133;; - *755) cp_umask=22;; - - *[0-7]) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw='% 200' - fi - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; - *) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw=,u+rw - fi - cp_umask=$mode$u_plus_rw;; - esac -fi - -for src -do - # Protect names starting with `-'. - case $src in - -*) src=./$src ;; - esac - - if test -n "$dir_arg"; then - dst=$src - dstdir=$dst - test -d "$dstdir" - dstdir_status=$? - else - - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command - # might cause directories to be created, which would be especially bad - # if $src (and thus $dsttmp) contains '*'. - if test ! -f "$src" && test ! -d "$src"; then - echo "$0: $src does not exist." >&2 - exit 1 - fi - - if test -z "$dstarg"; then - echo "$0: no destination specified." >&2 - exit 1 - fi - - dst=$dstarg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst ;; - esac - - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. - if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dstarg: Is a directory" >&2 - exit 1 - fi - dstdir=$dst - dst=$dstdir/`basename "$src"` - dstdir_status=0 - else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - - test -d "$dstdir" - dstdir_status=$? - fi - fi - - obsolete_mkdir_used=false - - if test $dstdir_status != 0; then - case $posix_mkdir in - '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; - esac - - if - $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" - ) - then : - else - - # The umask is ridiculous, or mkdir does not conform to POSIX, - # or it failed possibly due to a race condition. Create the - # directory the slow way, step by step, checking for races as we go. - - case $dstdir in - /*) prefix=/ ;; - -*) prefix=./ ;; - *) prefix= ;; - esac - - case $posix_glob in - '') - if (set -f) 2>/dev/null; then - posix_glob=true - else - posix_glob=false - fi ;; - esac - - oIFS=$IFS - IFS=/ - $posix_glob && set -f - set fnord $dstdir - shift - $posix_glob && set +f - IFS=$oIFS - - prefixes= - - for d - do - test -z "$d" && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ - done - - if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true - fi - fi - fi - - if test -n "$dir_arg"; then - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 - else - - # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ - - # Trap to clean up those temp files at exit. - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - - # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && - - # and set any options; do chmod last to preserve setuid bits. - # - # If any of these fail, we abort the whole thing. If we want to - # ignore errors from any of these, just make sure not to ignore - # errors from the above "$doit $cpprog $src $dsttmp" command. - # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ - && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ - && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ - && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && - - # Now rename the file to the real destination. - { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \ - || { - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - if test -f "$dst"; then - $doit $rmcmd -f "$dst" 2>/dev/null \ - || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \ - && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\ - || { - echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - else - : - fi - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" - } - } || exit 1 - - trap '' 0 - fi -done - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/qpid/cpp/build-aux/mdate-sh b/qpid/cpp/build-aux/mdate-sh deleted file mode 100755 index cd916c0a34..0000000000 --- a/qpid/cpp/build-aux/mdate-sh +++ /dev/null @@ -1,201 +0,0 @@ -#!/bin/sh -# Get modification time of a file or directory and pretty-print it. - -scriptversion=2005-06-29.22 - -# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005 Free Software -# Foundation, Inc. -# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to <bug-automake@gnu.org> or send patches to -# <automake-patches@gnu.org>. - -case $1 in - '') - echo "$0: No file. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: mdate-sh [--help] [--version] FILE - -Pretty-print the modification time of FILE. - -Report bugs to <bug-automake@gnu.org>. -EOF - exit $? - ;; - -v | --v*) - echo "mdate-sh $scriptversion" - exit $? - ;; -esac - -# Prevent date giving response in another language. -LANG=C -export LANG -LC_ALL=C -export LC_ALL -LC_TIME=C -export LC_TIME - -# GNU ls changes its time format in response to the TIME_STYLE -# variable. Since we cannot assume `unset' works, revert this -# variable to its documented default. -if test "${TIME_STYLE+set}" = set; then - TIME_STYLE=posix-long-iso - export TIME_STYLE -fi - -save_arg1=$1 - -# Find out how to get the extended ls output of a file or directory. -if ls -L /dev/null 1>/dev/null 2>&1; then - ls_command='ls -L -l -d' -else - ls_command='ls -l -d' -fi - -# A `ls -l' line looks as follows on OS/2. -# drwxrwx--- 0 Aug 11 2001 foo -# This differs from Unix, which adds ownership information. -# drwxrwx--- 2 root root 4096 Aug 11 2001 foo -# -# To find the date, we split the line on spaces and iterate on words -# until we find a month. This cannot work with files whose owner is a -# user named `Jan', or `Feb', etc. However, it's unlikely that `/' -# will be owned by a user whose name is a month. So we first look at -# the extended ls output of the root directory to decide how many -# words should be skipped to get the date. - -# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below. -set x`ls -l -d /` - -# Find which argument is the month. -month= -command= -until test $month -do - shift - # Add another shift to the command. - command="$command shift;" - case $1 in - Jan) month=January; nummonth=1;; - Feb) month=February; nummonth=2;; - Mar) month=March; nummonth=3;; - Apr) month=April; nummonth=4;; - May) month=May; nummonth=5;; - Jun) month=June; nummonth=6;; - Jul) month=July; nummonth=7;; - Aug) month=August; nummonth=8;; - Sep) month=September; nummonth=9;; - Oct) month=October; nummonth=10;; - Nov) month=November; nummonth=11;; - Dec) month=December; nummonth=12;; - esac -done - -# Get the extended ls output of the file or directory. -set dummy x`eval "$ls_command \"\$save_arg1\""` - -# Remove all preceding arguments -eval $command - -# Because of the dummy argument above, month is in $2. -# -# On a POSIX system, we should have -# -# $# = 5 -# $1 = file size -# $2 = month -# $3 = day -# $4 = year or time -# $5 = filename -# -# On Darwin 7.7.0 and 7.6.0, we have -# -# $# = 4 -# $1 = day -# $2 = month -# $3 = year or time -# $4 = filename - -# Get the month. -case $2 in - Jan) month=January; nummonth=1;; - Feb) month=February; nummonth=2;; - Mar) month=March; nummonth=3;; - Apr) month=April; nummonth=4;; - May) month=May; nummonth=5;; - Jun) month=June; nummonth=6;; - Jul) month=July; nummonth=7;; - Aug) month=August; nummonth=8;; - Sep) month=September; nummonth=9;; - Oct) month=October; nummonth=10;; - Nov) month=November; nummonth=11;; - Dec) month=December; nummonth=12;; -esac - -case $3 in - ???*) day=$1;; - *) day=$3; shift;; -esac - -# Here we have to deal with the problem that the ls output gives either -# the time of day or the year. -case $3 in - *:*) set `date`; eval year=\$$# - case $2 in - Jan) nummonthtod=1;; - Feb) nummonthtod=2;; - Mar) nummonthtod=3;; - Apr) nummonthtod=4;; - May) nummonthtod=5;; - Jun) nummonthtod=6;; - Jul) nummonthtod=7;; - Aug) nummonthtod=8;; - Sep) nummonthtod=9;; - Oct) nummonthtod=10;; - Nov) nummonthtod=11;; - Dec) nummonthtod=12;; - esac - # For the first six month of the year the time notation can also - # be used for files modified in the last year. - if (expr $nummonth \> $nummonthtod) > /dev/null; - then - year=`expr $year - 1` - fi;; - *) year=$3;; -esac - -# The result. -echo $day $month $year - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/qpid/cpp/build-aux/missing b/qpid/cpp/build-aux/missing deleted file mode 100755 index 1c8ff7049d..0000000000 --- a/qpid/cpp/build-aux/missing +++ /dev/null @@ -1,367 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. - -scriptversion=2006-05-10.23 - -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 -# Free Software Foundation, Inc. -# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" - -case $1 in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch] - -Send bug reports to <bug-automake@gnu.org>." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - -esac - -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). -case $1 in - lex|yacc) - # Not GNU programs, they don't have --version. - ;; - - tar) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; - - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case $1 in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case $f in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if test ! -f y.tab.h; then - echo >y.tab.h - fi - if test ! -f y.tab.c; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if test $# -ne 1; then - eval LASTARG="\${$#}" - case $LASTARG in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if test ! -f lex.yy.c; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - tar) - shift - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case $firstarg in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case $firstarg in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/qpid/cpp/configure.ac b/qpid/cpp/configure.ac deleted file mode 100644 index 2ca4592d81..0000000000 --- a/qpid/cpp/configure.ac +++ /dev/null @@ -1,26 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59) -AC_INIT(linearstore, 1.0) -AC_PROG_CC - -AC_CANONICAL_SYSTEM - -dnl Initialize automake -AM_INIT_AUTOMAKE - -dnl this allows us specify individual liking flags for each target -AM_PROG_CC_C_O - -dnl Initialize Libtool -LT_INIT - -dnl Check if Libtool is present -dnl Libtool is used for building share libraries -AC_PROG_LIBTOOL - -AC_CONFIG_FILES(Makefile - exampleProgram/Makefile - libTest/Makefile - include/Makefile) -AC_OUTPUT
\ No newline at end of file diff --git a/qpid/cpp/design_docs/new-cluster-design.txt b/qpid/cpp/design_docs/new-cluster-design.txt deleted file mode 100644 index d29ecce445..0000000000 --- a/qpid/cpp/design_docs/new-cluster-design.txt +++ /dev/null @@ -1,298 +0,0 @@ --*-org-*- -# 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. - -* A new design for Qpid clustering. - -** Issues with old cluster design - -See [[./old-cluster-issues.txt]] - -** A new cluster design. - -1. Clearly defined interface between broker code and cluster plug-in. - -2. Replicate queue events rather than client data. - - Only requires consistent enqueue order. - - Events only need be serialized per-queue, allows concurrency between queues - - Allows for replicated and non-replicated queues. - -3. Use a lock protocol to agree order of dequeues: only the broker - holding the lock can acqiure & dequeue. No longer relies on - identical state and lock-step behavior to cause identical dequeues - on each broker. - -4. Use multiple CPG groups to process different queues in - parallel. Use a fixed set of groups and hash queue names to choose - the group for each queue. - -*** Requirements - -The cluster must provide these delivery guarantees: - -- client sends transfer: message must be replicated and not lost even if the local broker crashes. -- client acquires a message: message must not be delivered on another broker while acquired. -- client accepts message: message is forgotten, will never be delivered or re-queued by any broker. -- client releases message: message must be re-queued on cluster and not lost. -- client rejects message: message must be dead-lettered or discarded and forgotten. -- client disconnects/broker crashes: acquired but not accepted messages must be re-queued on cluster. - -Each guarantee takes effect when the client receives a *completion* -for the associated command (transfer, acquire, reject, accept) - -*** Broker receiving messages - -On recieving a message transfer, in the connection thread we: -- multicast a message-received event. -- enqueue and complete the transfer when it is self-delivered. - -Other brokers enqueue the message when they recieve the message-received event. - -Enqueues are queued up with other queue operations to be executed in the -thread context associated with the queue. - -*** Broker sending messages: moving queue ownership - -Each queue is *owned* by at most one cluster broker at a time. Only -that broker may acquire or dequeue messages. The owner multicasts -notification of messages it acquires/dequeues to the cluster. -Periodically the owner hands over ownership to another interested -broker, providing time-shared access to the queue among all interested -brokers. - -We assume the same IO-driven dequeuing algorithm as the standalone -broker with one modification: queues can be "locked". A locked queue -is not available for dequeuing messages and will be skipped by the -output algorithm. - -At any given time only those queues owned by the local broker will be -unlocked. - -As messages are acquired/dequeued from unlocked queues by the IO threads -the broker multicasts acquire/dequeue events to the cluster. - -When an unlocked queue has no more consumers with credit, or when a -time limit expires, the broker relinquishes ownership by multicasting -a release-queue event, allowing another interested broker to take -ownership. - -*** Asynchronous completion of accept - -In acknowledged mode a message is not forgotten until it is accepted, -to allow for requeue on rejection or crash. The accept should not be -completed till the message has been forgotten. - -On receiving an accept the broker: -- dequeues the message from the local queue -- multicasts an "accept" event -- completes the accept asynchronously when the dequeue event is self delivered. - -NOTE: The message store does not currently implement asynchronous -completions of accept, this is a bug. - -*** Multiple CPG groups. - -The old cluster was bottlenecked by processing everything in a single -CPG deliver thread. - -The new cluster uses a set of CPG groups, one per core. Queue names -are hashed to give group indexes, so statistically queues are likely -to be spread over the set of groups. - -Operations on a given queue always use the same group, so we have -order within each queue, but operations on different queues can use -different groups giving greater throughput sending to CPG and multiple -handler threads to process CPG messages. - -** Inconsistent errors. - -An inconsistent error means that after multicasting an enqueue, accept -or dequeue, some brokers succeed in processing it and others fail. - -The new design eliminates most sources of inconsistent errors in the -old broker: connections, sessions, security, management etc. Only -store journal errors remain. - -The new inconsistent error protocol is similar to the old one with one -major improvement: brokers do not have to stall processing while an -error is being resolved. - -** Updating new members - -When a new member (the updatee) joins a cluster it needs to be brought -up to date with the rest of the cluster. An existing member (the -updater) sends an "update". - -In the old cluster design the update is a snapshot of the entire -broker state. To ensure consistency of the snapshot both the updatee -and the updater "stall" at the start of the update, i.e. they stop -processing multicast events and queue them up for processing when the -update is complete. This creates a back-log of work to get through, -which leaves them lagging behind the rest of the cluster till they -catch up (which is not guaranteed to happen in a bounded time.) - -With the new cluster design only exchanges, queues, bindings and -messages need to be replicated. - -We update individual objects (queues and exchanges) independently. -- create queues first, then update all queues and exchanges in parallel. -- multiple updater threads, per queue/exchange. - -Queue updater: -- marks the queue position at the sync point -- sends messages starting from the sync point working towards the head of the queue. -- send "done" message. - -Queue updatee: -- enqueues received from CPG: add to back of queue as normal. -- dequeues received from CPG: apply if found, else save to check at end of update. -- messages from updater: add to the *front* of the queue. -- update complete: apply any saved dequeues. - -Exchange updater: -- updater: send snapshot of exchange as it was at the sync point. - -Exchange updatee: -- queue exchange operations after the sync point. -- when snapshot is received: apply saved operations. - -Note: -- Updater is active throughout, no stalling. -- Consuming clients actually reduce the size of the update. -- Updatee stalls clients until the update completes. - (Note: May be possible to avoid updatee stall as well, needs thought) - -** Internal cluster interface - -The new cluster interface is similar to the MessageStore interface, but -provides more detail (message positions) and some additional call -points (e.g. acquire) - -The cluster interface captures these events: -- wiring changes: queue/exchange declare/bind -- message enqueued/acquired/released/rejected/dequeued. -- transactional events. - -** Maintainability - -This design gives us more robust code with a clear and explicit interfaces. - -The cluster depends on specific events clearly defined by an explicit -interface. Provided the semantics of this interface are not violated, -the cluster will not be broken by changes to broker code. - -The cluster no longer requires identical processing of the entire -broker stack on each broker. It is not affected by the details of how -the broker allocates messages. It is independent of the -protocol-specific state of connections and sessions and so is -protected from future protocol changes (e.g. AMQP 1.0) - -A number of specific ways the code will be simplified: -- drop code to replicate management model. -- drop timer workarounds for TTL, management, heartbeats. -- drop "cluster-safe assertions" in broker code. -- drop connections, sessions, management from cluster update. -- drop security workarounds: cluster code now operates after message decoding. -- drop connection tracking in cluster code. -- simper inconsistent-error handling code, no need to stall. - -** Performance - -The standalone broker processes _connections_ concurrently, so CPU -usage increases as you add more connections. - -The new cluster processes _queues_ concurrently, so CPU usage increases as you -add more queues. - -In both cases, CPU usage peaks when the number of "units of - concurrency" (connections or queues) goes above the number of cores. - -When all consumers on a queue are connected to the same broker the new -cluster uses the same messagea allocation threading/logic as a -standalone broker, with a little extra asynchronous book-keeping. - -If a queue has multiple consumers connected to multiple brokers, the -new cluster time-shares the queue which is less efficient than having -all consumers on a queue connected to the same broker. - -** Flow control -New design does not queue up CPG delivered messages, they are -processed immediately in the CPG deliver thread. This means that CPG's -flow control is sufficient for qpid. - -** Live upgrades - -Live upgrades refers to the ability to upgrade a cluster while it is -running, with no downtime. Each brokers in the cluster is shut down, -and then re-started with a new version of the broker code. - -To achieve this -- Cluster protocl XML file has a new element <version number=N> attached - to each method. This is the version at which the method was added. -- New versions can only add methods, existing methods cannot be changed. -- The cluster handshake for new members includes the protocol version - at each member. -- Each cpg message starts with header: version,size. Allows new encodings later. -- Brokers ignore messages of higher version. - -- The cluster's version is the lowest version among its members. -- A newer broker can join and older cluster. When it does, it must restrict - itself to speaking the older version protocol. -- When the cluster version increases (because the lowest version member has left) - the remaining members may move up to the new version. - - -* Design debates -** Active/active vs. active passive - -An active-active cluster can be used in an active-passive mode. In -this mode we would like the cluster to be as efficient as a strictly -active-passive implementation. - -An active/passive implementation allows some simplifications over active/active: -- drop Queue ownership and locking -- don't need to replicate message acquisition. -- can do immediate local enqueue and still guarantee order. - -Active/passive introduces a few extra requirements: -- Exactly one broker has to take over if primary fails. -- Passive members must refuse client connections. -- On failover, clients must re-try all known addresses till they find the active member. - -Active/active benefits: -- A broker failure only affects the subset of clients connected to that broker. -- Clients can switch to any other broker on failover -- Backup brokers are immediately available on failover. -- As long as a client can connect to any broker in the cluster, it can be served. - -Active/passive benefits: -- Don't need to replicate message allocation, can feed consumers at top speed. - -Active/passive drawbacks: -- All clients on one node so a failure affects every client in the - system. -- After a failure there is a "reconnect storm" as every client - reconnects to the new active node. -- After a failure there is a period where no broker is active, until - the other brokers realize the primary is gone and agree on the new - primary. -- Clients must find the single active node, may involve multiple - connect attempts. -- No service if a partition separates a client from the active broker, - even if the client can see other brokers. - - diff --git a/qpid/cpp/design_docs/new-cluster-plan.txt b/qpid/cpp/design_docs/new-cluster-plan.txt deleted file mode 100644 index 042e03f177..0000000000 --- a/qpid/cpp/design_docs/new-cluster-plan.txt +++ /dev/null @@ -1,340 +0,0 @@ --*-org-*- - -# 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. - -* Status of impementation - -Meaning of priorities: -[#A] Essential for basic functioning. -[#B] Required for first release. -[#C] Can be addressed in a later release. - -The existig prototype is bare bones to do performance benchmarks: -- Implements publish and consumer locking protocol. -- Defered delivery and asynchronous completion of message. -- Optimize the case all consumers are on the same node. -- No new member updates, no failover updates, no transactions, no persistence etc. - -Prototype code is on branch qpid-2920-active, in cpp/src/qpid/cluster/exp/ - -** Similarities to existing cluster. - -/Active-active/: the new cluster can be a drop-in replacement for the -old, existing tests & customer deployment configurations are still -valid. - -/Virtual synchrony/: Uses corosync to co-ordinate activity of members. - -/XML controls/: Uses XML to define the primitives multicast to the -cluster. - -** Differences with existing cluster. - -/Report rather than predict consumption/: brokers explicitly tell each -other which messages have been acquired or dequeued. This removes the -major cause of bugs in the existing cluster. - -/Queue consumer locking/: to avoid duplicates only one broker can acquire or -dequeue messages at a time - while has the consume-lock on the -queue. If multiple brokers are consuming from the same queue the lock -is passed around to time-share access to the queue. - -/Per-queue concurrency/: uses a fixed-size set of CPG groups (reflecting -the concurrency of the host) to allow concurrent processing on -different queues. Queues are hashed onto the groups. - -* Completed tasks -** DONE [#A] Minimal POC: publish/acquire/dequeue protocol. - CLOSED: [2011-10-05 Wed 16:03] - -Defines broker::Cluster interface and call points. -Initial interface commite - -Main classes -Core: central object holding cluster classes together (replaces cluster::Cluster) -BrokerContext: implements broker::Cluster interface. -QueueContext: Attached to a broker::Queue, holds cluster status. -MessageHolder:holds local messages while they are being enqueued. - -Implements multiple CPG groups for better concurrency. - -** DONE [#A] Large message replication. - CLOSED: [2011-10-05 Wed 17:22] -Multicast using fixed-size (64k) buffers, allow fragmetation of messages across buffers (frame by frame) - -* Design Questions -** [[Queue sequence numbers vs. independant message IDs]] - -Current prototype uses queue+sequence number to identify message. This -is tricky for updating new members as the sequence numbers are only -known on delivery. - -Independent message IDs that can be generated and sent as part of the -message simplify this and potentially allow performance benefits by -relaxing total ordering. However they require additional map lookups -that hurt performance. - -- [X] Prototype independent message IDs, check performance. -Throughput worse by 30% in contented case, 10% in uncontended. - -* Tasks to match existing cluster -** TODO [#A] Review old cluster code for more tasks. 1 -** TODO [#A] Put cluster enqueue after all policy & other checks. - -gsim: we do policy check after multicasting enqueue so -could have inconsistent outcome. - -aconway: Multicast should be after enqueue and any other code that may -decide to send/not send the message. - -gsime: while later is better, is moving it that late the right thing? -That will mean for example that any dequeues triggered by the enqueue -(e.g. ring queue or lvq) will happen before the enqueue is broadcast. - -** TODO [#A] Defer and async completion of wiring commands. 5 -Testing requirement: Many tests assume wiring changes are visible -across the cluster once the wiring commad completes. - -Name clashes: avoid race if same name queue/exchange declared on 2 -brokers simultaneously. - -Ken async accept, never merged: http://svn.apache.org/viewvc/qpid/branches/qpid-3079/ - -Clashes with non-replicated: see [[Allow non-replicated]] below. - -** TODO [#A] defer & async completion for explicit accept. - -Explicit accept currently ignores the consume lock. Defer and complete -it when the lock is acquired. - -** TODO [#A] Update to new members joining. 10. - -Need to resolve [[Queue sequence numbers vs. independant message IDs]] -first. -- implicit sequence numbers are more tricky to replicate to new member. - -Update individual objects (queues and exchanges) independently. -- create queues first, then update all queues and exchanges in parallel. -- multiple updater threads, per queue/exchange. -- updater sends messages to special exchange(s) (not using extended AMQP controls) - -Queue updater: -- marks the queue position at the sync point -- sends messages starting from the sync point working towards the head of the queue. -- send "done" message. -Note: updater remains active throughout, consuming clients actually reduce the -size of the update. - -Queue updatee: -- enqueues received from CPG: add to back of queue as normal. -- dequeues received from CPG: apply if found, else save to check at end of update. -- messages from updater: add to the *front* of the queue. -- update complete: apply any saved dequeues. - -Exchange updater: -- updater: send snapshot of exchange as it was at the sync point. - -Exchange updatee: -- queue exchange operations after the sync point. -- when snapshot is received: apply saved operations. - -Updater remains active throughout. -Updatee stalls clients until the update completes. - -Updating queue/exchange/binding objects is via the same encode/decode -that is used by the store. Updatee to use recovery interfaces to -recover? - -** TODO [#A] Failover updates to client. 2 -Implement the amq.failover exchange to notify clients of membership. -** TODO [#A] Passing all existing cluster tests. 5 - -The new cluster should be a drop-in replacement for the old, so it -should be able to pass all the existing tests. - -** TODO [#B] Initial status protocol. 3 -Handshake to give status of each broker member to new members joining. -Status includes -- cluster protocol version. -- persistent store state (clean, dirty) -- make it extensible, so additional state can be added in new protocols - -Clean store if last man standing or clean shutdown. -Need to add multicast controls for shutdown. - -** TODO [#B] Persistent cluster startup. 4 - -Based on existing code: -- Exchange dirty/clean exchanged in initial status. -- Only one broker recovers from store, others update. -** TODO [#B] Replace boost::hash with our own hash function. 1 -The hash function is effectively part of the interface so -we need to be sure it doesn't change underneath us. - -** TODO [#B] Management model. 3 -Alerts for inconsistent message loss. - -** TODO [#B] Management methods that modify queues. 5 - -Replicate management methods that modify queues - e.g. move, purge. -Target broker may not have all messages on other brokers for purge/destroy. -- Queue::purge() - wait for lock, purge local, mcast dequeues. -- Queue::move() - wait for lock, move msgs (mcasts enqueues), mcast dequeues. -- Queue::destroy() - messages to alternate exchange on all brokers. -- Queue::get() - ??? -Need to add callpoints & mcast messages to replicate these? -** TODO [#B] TX transaction support. 5 -Extend broker::Cluster interface to capture transaction context and completion. -Running brokers exchange TX information. -New broker update includes TX information. - - // FIXME aconway 2010-10-18: As things stand the cluster is not - // compatible with transactions - // - enqueues occur after routing is complete - // - no call to Cluster::enqueue, should be in Queue::process? - // - no transaction context associated with messages in the Cluster interface. - // - no call to Cluster::accept in Queue::dequeueCommitted - -Injecting holes into a queue: -- Multicast a 'non-message' that just consumes one queue position. -- Used to reserve a message ID (position) for a non-commited message. -- Also could allow non-replicated messages on a replicated queue if required. - -** TODO [#B] DTX transaction support. 5 -Extend broker::Cluster interface to capture transaction context and completion. -Running brokers exchange DTX information. -New broker update includes DTX information. - -** TODO [#B] Replicate message groups? -Message groups may require additional state to be replicated. -** TODO [#B] Replicate state for Fairshare? -gsim: fairshare would need explicit code to keep it in sync across -nodes; that may not be required however. -** TODO [#B] Timed auto-delete queues? -gsim: may need specific attention? -** TODO [#B] Async completion of accept. 4 -When this is fixed in the standalone broker, it should be fixed for cluster. - -** TODO [#B] Network partitions and quorum. 2 -Re-use existing implementation. - -** TODO [#B] Review error handling, put in a consitent model. 4. -- [ ] Review all asserts, for possible throw. -- [ ] Decide on fatal vs. non-fatal errors. - -** TODO [#B] Implement inconsistent error handling policy. 5 -What to do if a message is enqueued sucessfully on some broker(s), -but fails on other(s) - e.g. due to store limits? -- fail on local broker = possible message loss. -- fail on non-local broker = possible duplication. - -We have more flexibility now, we don't *have* to crash -- but we've lost some of our redundancy guarantee, how to inform user? - -Options to respond to inconsistent error: -- stop broker -- reset broker (exec a new qpidd) -- reset queue -- log critical -- send management event - -Most important is to inform of the risk of message loss. -Current favourite: reset queue+log critical+ management event. -Configurable choices? - -** TODO [#C] Allow non-replicated exchanges, queues. 5 - -3 levels set in declare arguments: -- qpid.replicate=no - nothing is replicated. -- qpid.replicate=wiring - queues/exchanges are replicated but not messages. -- qpid.replicate=yes - queues exchanges and messages are replicated. - -Wiring use case: it's OK to lose some messages (up to the max depth of -the queue) but the queue/exchange structure must be highly available -so clients can resume communication after fail over. - -Configurable default? Default same as old cluster? - -Need to -- save replicated status to stored (in arguments). -- support in management tools. - -Avoid name clashes between replicated/non-replicated: multicast -local-only names as well, all brokers keep a map and refuse to create -clashes. - -** TODO [#C] Handling immediate messages in a cluster. 2 -Include remote consumers in descision to deliver an immediate message. -* Improvements over existing cluster -** TODO [#C] Remove old cluster hacks and workarounds. -The old cluster has workarounds in the broker code that can be removed. -- [ ] drop code to replicate management model. -- [ ] drop timer workarounds for TTL, management, heartbeats. -- [ ] drop "cluster-safe assertions" in broker code. -- [ ] drop connections, sessions, management from cluster update. -- [ ] drop security workarounds: cluster code now operates after message decoding. -- [ ] drop connection tracking in cluster code. -- [ ] simpler inconsistent-error handling code, no need to stall. - -** TODO [#C] Support for live upgrades. - -Allow brokers in a running cluster to be replaced one-by-one with a new version. -(see new-cluster-design for design notes.) - -The old cluster protocol was unstable because any changes in broker -state caused changes to the cluster protocol.The new design should be -much more stable. - -Points to implement in anticipation of live upgrade: -- Prefix each CPG message with a version number and length. - Version number determines how to decode the message. -- Brokers ignore messages that have a higher version number than they understand. -- Protocol version XML element in cluster.xml, on each control. -- Initial status protocol to include protocol version number. - -New member udpates: use the store encode/decode for updates, use the -same backward compatibility strategy as the store. This allows for -adding new elements to the end of structures but not changing or -removing new elements. - -NOTE: Any change to the association of CPG group names and queues will -break compatibility. How to work around this? - -** TODO [#C] Refactoring of common concerns. - -There are a bunch of things that act as "Queue observers" with intercept -points in similar places. -- QueuePolicy -- QueuedEvents (async replication) -- MessageStore -- Cluster - -Look for ways to capitalize on the similarity & simplify the code. - -In particular QueuedEvents (async replication) strongly resembles -cluster replication, but over TCP rather than multicast. - -** TODO [#C] Support for AMQP 1.0. - -* Testing -** TODO [#A] Pass all existing cluster tests. -Requires [[Defer and async completion of wiring commands.]] -** TODO [#A] New cluster tests. -Stress tests & performance benchmarks focused on changes in new cluster: -- concurrency by queues rather than connections. -- different handling shared queues when consuemrs are on different brokers. diff --git a/qpid/cpp/docs/man/Makefile.am b/qpid/cpp/docs/man/Makefile.am deleted file mode 100644 index 50b5630992..0000000000 --- a/qpid/cpp/docs/man/Makefile.am +++ /dev/null @@ -1,66 +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. -# - -# Generate makefile from qpidd --help -# -# Note: qiddd.1 is normally a _checked in_ pre-generated file, so that -# make dist does not have to build the entire source just for the man page. -# -# To update the checked-in file (e.g. for a new release) do the following: -# -# - start with a completely clean checkout. -# - make sure there are no modules installed in your configured prefix, -# we don't want to pick up configuration from optional modules -# - do bootstrap; configure -# - in build-dir: cd src; make # build the broker -# - in source-dir: cd docs/man; rm qpidd.1 # remove checked-in man page. -# - in build-dir: cd docs/man; make # make new man page -# - edit qpidd.1 to remove all default values referring to file/directory locations. -# these values will differ between builds depending on configuration. -# - if source-dir != build-dir: copy qpidd.1 from build-dir/docs/man to source-dir/docs/man - -dist_man_MANS = qpidd.1 - -man_aux = $(dist_man_MANS:.1=.x) -EXTRA_DIST = $(man_aux) CMakeLists.txt generate_manpage groffify_options.sed groffify_template.sed -DISTCLEANFILES = $(dist_man_MANS) -CLEANFILES=qpidd.1 - -dist-hook: $(man_aux) - -# Depend on configure.ac to get version number changes. -$(dist_man_MANS): $(top_srcdir)/configure.ac - -if HAVE_HELP2MAN - -SUFFIXES = .x .1 -qpidd.1: $(srcdir)/qpidd.x $(top_builddir)/src/qpidd -.x.1: - @rm -f $@ - @echo "Updating man page $@" - $(HELP2MAN) --no-info --include=$(srcdir)/$*.x --output=$@-t --help-option="--help --no-module-dir" --version-option="--version --no-module-dir" ../../src/$* - @chmod a-w $@-t - @mv $@-t $@ -else -qpidd.1: - @echo "Warning: help2man not available, using sed script instead." - $(srcdir)/generate_manpage $(srcdir)/qpidd.x $(top_builddir)/src/qpidd $@ -endif - - diff --git a/qpid/cpp/etc/Makefile.am b/qpid/cpp/etc/Makefile.am deleted file mode 100644 index 5d0059c536..0000000000 --- a/qpid/cpp/etc/Makefile.am +++ /dev/null @@ -1,55 +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. -# -SASL_CONF = sasl2/qpidd.conf - -EXTRA_DIST = \ - $(SASL_CONF) \ - qpidd.in qpidd-primary.in qpidd.conf qpidc.conf CMakeLists.txt \ - cluster.conf-example.xml.in - -confdir = $(sysconfdir)/qpid -nobase_conf_DATA=\ - qpidc.conf - -nobase_sysconf_DATA = \ - qpidd.conf - -if HAVE_SASL -nobase_sysconf_DATA += \ - $(SASL_CONF) -endif - -# Substitute values for directories in init scripts. -# -# We can't use autoconf substitution directly because it leaves -# ${prefix} and ${exec_prefix} unexpanded. Substitute with sed -# scripts. -SUBST="s|@sysconfdir[@]|${sysconfdir}|;s|@sbindir[@]|${sbindir}|;s|@bindir[@]|${bindir}|" -qpidd: qpidd.in - sed $(SUBST) $< > $@ -qpidd-primary: qpidd-primary.in - sed $(SUBST) $< > $@ -cluster.conf-example.xml: cluster.conf-example.xml.in - sed $(SUBST) $< > $@ - -CLEANFILES = qpidd qpidd-primary cluster.conf-example.xml - -initddir = $(sysconfdir)/init.d -nobase_initd_SCRIPTS = qpidd qpidd-primary - diff --git a/qpid/cpp/etc/qpidd.in b/qpid/cpp/etc/qpidd.in index 91448add02..b53ea40a1f 100755 --- a/qpid/cpp/etc/qpidd.in +++ b/qpid/cpp/etc/qpidd.in @@ -63,9 +63,8 @@ if [ $RETVAL = 4 ]; then fi start() { - [[ $QPID_DATA_DIR ]] || QPID_DATA_DIR=/var/lib/qpidd echo -n $"Starting Qpid AMQP daemon: " - daemon --pidfile $pidfile --check $prog --user qpidd @sbindir@/$prog --data-dir $QPID_DATA_DIR --daemon $QPIDD_OPTIONS + daemon --pidfile $pidfile --check $prog --user qpidd @sbindir@/$prog ${QPID_DATA_DIR:+--data-dir $QPID_DATA_DIR} --daemon $QPIDD_OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch $lockfile diff --git a/qpid/cpp/etc/selinux/Makefile b/qpid/cpp/etc/selinux/Makefile deleted file mode 100644 index 1ab6337114..0000000000 --- a/qpid/cpp/etc/selinux/Makefile +++ /dev/null @@ -1,34 +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. -# -# Makefile to build and install the selinux policies in this directory. -# Needs to be run as root. - -POLICIES = qpidd.pp qpiddevel.pp -SOURCES = $(POLICIES:.pp=.te) - -all: $(POLICIES) - -$(POLICIES): $(SOURCES) - make -f /usr/share/selinux/devel/Makefile - -install: $(POLICIES) - for p in $(POLICIES); do /usr/sbin/semodule -i $$p; done - -clean: - rm -rf *~ *.pp *.fc *.if tmp diff --git a/qpid/cpp/examples/CMakeLists.txt b/qpid/cpp/examples/CMakeLists.txt index 728ab0e4c6..3c4b4039d4 100644 --- a/qpid/cpp/examples/CMakeLists.txt +++ b/qpid/cpp/examples/CMakeLists.txt @@ -90,6 +90,5 @@ if (MSVC) COMPONENT ${QPID_COMPONENT_EXAMPLES}) endif (MSVC) -add_subdirectory(qmf-console) add_subdirectory(messaging) -add_subdirectory(old_api) + diff --git a/qpid/cpp/examples/Makefile.am b/qpid/cpp/examples/Makefile.am deleted file mode 100644 index 6b2bb73587..0000000000 --- a/qpid/cpp/examples/Makefile.am +++ /dev/null @@ -1,37 +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. -# -SUBDIRS = qmf-console messaging old_api - -MAKEDIST=.libs/Makefile - -$(MAKEDIST): Makefile - mkdir -p .libs - @(echo 'all clean:' ; \ - echo ' for d in $(SUBDIRS) ; do $$(MAKE) -C $$$$d $$@ ; done' ; \ - ) > $(MAKEDIST) - -examplesdir=$(pkgdatadir)/examples -dist_examples_DATA = README.txt $(MAKEDIST) - -EXTRA_DIST = examples.sln CMakeLists.txt - -# For older versions of automake -abs_top_srcdir = @abs_top_srcdir@ -abs_top_builddir = @abs_top_builddir@ - diff --git a/qpid/cpp/examples/makedist.mk b/qpid/cpp/examples/makedist.mk deleted file mode 100644 index 9a1568d427..0000000000 --- a/qpid/cpp/examples/makedist.mk +++ /dev/null @@ -1,42 +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. -# -# Settings to build the examples in automake -AM_CXXFLAGS = $(WARNING_CFLAGS) -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -CLIENT_LIB=$(top_builddir)/src/libqpidclient.la -COMMON_LIB=$(top_builddir)/src/libqpidcommon.la -CONSOLE_LIB=$(top_builddir)/src/libqmfconsole.la -CLIENTFLAGS=-lqpidclient -CONSOLEFLAGS=-lqmfconsole - -# Generate a simple non-automake Makefile for distribution. -MAKEDIST=.libs/Makefile - -$(MAKEDIST): Makefile - mkdir -p .libs - @(echo CXX=$(CXX) ; \ - echo CXXFLAGS=$(CXXFLAGS) ; \ - echo LDFLAGS=$(MAKELDFLAGS) ; \ - echo ; \ - echo all: $(noinst_PROGRAMS) ; \ - echo ; \ - echo clean: ; \ - echo " rm -f $(noinst_PROGRAMS)" ; \ - ) > $(MAKEDIST) - diff --git a/qpid/cpp/examples/messaging/CMakeLists.txt b/qpid/cpp/examples/messaging/CMakeLists.txt index 25651e525b..5481f2f0bf 100644 --- a/qpid/cpp/examples/messaging/CMakeLists.txt +++ b/qpid/cpp/examples/messaging/CMakeLists.txt @@ -23,7 +23,7 @@ macro(add_messaging_example example) add_executable(${example} ${example}.cpp OptionParser.cpp) set_target_properties(${example} PROPERTIES OUTPUT_NAME ${example}) - target_link_libraries(${example} qpidmessaging ${_boost_libs_needed}) + target_link_libraries(${example} qpidmessaging qpidtypes ${_boost_libs_needed}) # For installs, don't install the built example; that would be pointless. # Install the things a user needs to build the example on-site. install (FILES @@ -49,6 +49,7 @@ add_messaging_example(map_sender) add_messaging_example(client) add_messaging_example(server) +add_messaging_example(server_reconnect) # These don't need Boost or OptionParser add_executable(hello_world hello_world.cpp) @@ -74,6 +75,7 @@ install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/map_sender.cpp ${CMAKE_CURRENT_SOURCE_DIR}/client.cpp ${CMAKE_CURRENT_SOURCE_DIR}/server.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/server_reconnect.cpp DESTINATION ${QPID_INSTALL_EXAMPLESDIR}/messaging COMPONENT ${QPID_COMPONENT_EXAMPLES}) diff --git a/qpid/cpp/examples/messaging/Makefile.am b/qpid/cpp/examples/messaging/Makefile.am deleted file mode 100644 index 5fefb37f8a..0000000000 --- a/qpid/cpp/examples/messaging/Makefile.am +++ /dev/null @@ -1,75 +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. -# -examplesdir=$(pkgdatadir)/examples/messaging - -# Settings to build the examples in automake -AM_CXXFLAGS = $(WARNING_CFLAGS) -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -CLIENT_LIB=$(top_builddir)/src/libqpidmessaging.la -TYPES_LIB=$(top_builddir)/src/libqpidtypes.la -CLIENTFLAGS=-lqpidmessaging - -noinst_PROGRAMS=drain spout client server map_sender map_receiver hello_world hello_xml - -hello_world_SOURCES=hello_world.cpp -hello_world_LDADD=$(CLIENT_LIB) - -hello_xml_SOURCES=hello_xml.cpp -hello_xml_LDADD=$(CLIENT_LIB) - -drain_SOURCES=drain.cpp OptionParser.h OptionParser.cpp -drain_LDADD=$(CLIENT_LIB) $(TYPES_LIB) - -spout_SOURCES=spout.cpp OptionParser.h OptionParser.cpp -spout_LDADD=$(CLIENT_LIB) $(TYPES_LIB) - -client_SOURCES=client.cpp -client_LDADD=$(CLIENT_LIB) - -server_SOURCES=server.cpp -server_LDADD=$(CLIENT_LIB) - -map_sender_SOURCES=map_sender.cpp -map_sender_LDADD=$(CLIENT_LIB) $(TYPES_LIB) - -map_receiver_SOURCES=map_receiver.cpp -map_receiver_LDADD=$(CLIENT_LIB) $(TYPES_LIB) - -examples_DATA= \ - hello_world.cpp \ - hello_xml.cpp \ - drain.cpp \ - spout.cpp \ - OptionParser.cpp \ - OptionParser.h \ - client.cpp \ - server.cpp \ - map_sender.cpp \ - map_receiver.cpp \ - extra_dist/CMakeLists.txt - -EXTRA_DIST= \ - $(examples_DATA) \ - CMakeLists.txt \ - messaging_client.vcproj \ - messaging_drain.vcproj \ - messaging_map_receiver.vcproj \ - messaging_map_sender.vcproj \ - messaging_server.vcproj \ - messaging_spout.vcproj diff --git a/qpid/cpp/examples/messaging/drain.cpp b/qpid/cpp/examples/messaging/drain.cpp index 563e5e5060..6ac1d3a236 100644 --- a/qpid/cpp/examples/messaging/drain.cpp +++ b/qpid/cpp/examples/messaging/drain.cpp @@ -90,15 +90,17 @@ int main(int argc, char** argv) int count = options.getCount(); Message message; int i = 0; - + while (receiver.fetch(message, timeout)) { - std::cout << "Message(properties=" << message.getProperties() << ", content='" ; + std::cout << "Message(properties=" << message.getProperties(); + if (!message.getSubject().empty()) { + std::cout << ", subject='" << message.getSubject() << "'"; + } + std::cout << ", content='"; if (message.getContentType() == "amqp/map") { - Variant::Map map; - decode(message, map); - std::cout << map; + std::cout << message.getContentObject().asMap(); } else { - std::cout << message.getContent(); + std::cout << message.getContentObject(); } std::cout << "')" << std::endl; session.acknowledge(); @@ -106,7 +108,7 @@ int main(int argc, char** argv) break; } receiver.close(); - session.close(); + session.close(); connection.close(); return 0; } catch(const std::exception& error) { @@ -114,5 +116,5 @@ int main(int argc, char** argv) connection.close(); } } - return 1; + return 1; } diff --git a/qpid/cpp/examples/messaging/map_receiver.cpp b/qpid/cpp/examples/messaging/map_receiver.cpp index 081f7394a8..96bc76b821 100644 --- a/qpid/cpp/examples/messaging/map_receiver.cpp +++ b/qpid/cpp/examples/messaging/map_receiver.cpp @@ -39,15 +39,13 @@ int main(int argc, char** argv) { const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; const char* address = argc>2 ? argv[2] : "message_queue; {create: always}"; std::string connectionOptions = argc > 3 ? argv[3] : ""; - + Connection connection(url, connectionOptions); try { connection.open(); Session session = connection.createSession(); Receiver receiver = session.createReceiver(address); - Variant::Map content; - decode(receiver.fetch(), content); - std::cout << content << std::endl; + std::cout << receiver.fetch().getContentObject() << std::endl; session.acknowledge(); receiver.close(); connection.close(); @@ -56,5 +54,5 @@ int main(int argc, char** argv) { std::cout << error.what() << std::endl; connection.close(); } - return 1; + return 1; } diff --git a/qpid/cpp/examples/messaging/map_sender.cpp b/qpid/cpp/examples/messaging/map_sender.cpp index 8ce3e1d8ec..81ac7320d8 100644 --- a/qpid/cpp/examples/messaging/map_sender.cpp +++ b/qpid/cpp/examples/messaging/map_sender.cpp @@ -39,7 +39,7 @@ int main(int argc, char** argv) { const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; const char* address = argc>2 ? argv[2] : "message_queue; {create: always}"; std::string connectionOptions = argc > 3 ? argv[3] : ""; - + Connection connection(url, connectionOptions); try { connection.open(); @@ -57,8 +57,8 @@ int main(int argc, char** argv) { colours.push_back(Variant("white")); content["colours"] = colours; content["uuid"] = Uuid(true); - encode(content, message); - + message.setContentObject(content); + sender.send(message, true); connection.close(); diff --git a/qpid/cpp/examples/qmf-console/qmf-console_ping.vcproj b/qpid/cpp/examples/messaging/messaging_server_reconnect.vcproj index b193f8cf28..dfde201178 100644 --- a/qpid/cpp/examples/qmf-console/qmf-console_ping.vcproj +++ b/qpid/cpp/examples/messaging/messaging_server_reconnect.vcproj @@ -22,9 +22,9 @@ <VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
- Name="qmf_console_ping"
- ProjectGUID="{C1FFDE95-3442-49AE-9985-7EEE3D45B4A3}"
- RootNamespace="qmf_console_ping"
+ Name="messaging_server_reconnect"
+ ProjectGUID="{AF862399-FECA-1BAD-1FEE-AE349A6B75AA}"
+ RootNamespace="messaging_server_reconnect"
Keyword="Win32Proj"
TargetFrameworkVersion="0"
>
@@ -42,7 +42,7 @@ <Configuration
Name="Debug|Win32"
OutputDirectory="."
- IntermediateDirectory="Debug\qmf_console_ping\I386"
+ IntermediateDirectory="Debug\messaging_server_reconnect\I386"
ConfigurationType="1"
CharacterSet="0"
>
@@ -70,8 +70,8 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
+ AdditionalIncludeDirectories=""$(QPID_ROOT)\include";..\..\include"
+ PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
MinimalRebuild="false"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -79,14 +79,13 @@ WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
+ PreprocessorDefinitions="_DEBUG;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
Culture="1033"
AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
/>
@@ -95,11 +94,11 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib qmfconsoled.lib"
- OutputFile="$(OutDir)\ping.exe"
+ AdditionalDependencies="qpidmessagingd.lib qpidcommond.lib qpidtypesd.lib"
+ OutputFile="$(OutDir)\server_reconnect.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
+ AdditionalLibraryDirectories="$(QPID_ROOT)\bin;..\..\lib"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
@@ -127,9 +126,9 @@ />
</Configuration>
<Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\qmf_console_ping\AMD64"
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release\messaging_server_reconnect\I386"
ConfigurationType="1"
CharacterSet="0"
>
@@ -156,24 +155,20 @@ />
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
+ Optimization="2"
+ AdditionalIncludeDirectories=""$(QPID_ROOT)\include";..\..\include"
+ PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
+ RuntimeLibrary="2"
RuntimeTypeInfo="true"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
+ PreprocessorDefinitions="NDEBUG;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
Culture="1033"
AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
/>
@@ -182,15 +177,16 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib qmfconsoled.lib"
- OutputFile="$(OutDir)\ping.exe"
- LinkIncremental="2"
+ AdditionalDependencies="qpidmessaging.lib qpidcommon.lib qpidtypes.lib"
+ OutputFile="$(OutDir)\server_reconnect.exe"
+ LinkIncremental="1"
SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
+ AdditionalLibraryDirectories="$(QPID_ROOT)\bin;..\..\lib"
GenerateDebugInformation="true"
SubSystem="1"
- TargetMachine="17"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@@ -215,9 +211,9 @@ />
</Configuration>
<Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\qmf_console_ping\I386"
+ Name="Debug|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="0"
>
@@ -237,6 +233,7 @@ Name="VCMIDLTool"
AdditionalOptions=""
AdditionalIncludeDirectories=""
+ TargetEnvironment="3"
TypeLibraryName="$(InputName).tlb"
HeaderFileName="$(InputName).h"
InterfaceIdentifierFileName="$(InputName)_i.c"
@@ -244,21 +241,23 @@ />
<Tool
Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(QPID_ROOT)\include";..\..\include"
+ PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
+ MinimalRebuild="false"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
RuntimeTypeInfo="true"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
+ DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
+ PreprocessorDefinitions="_DEBUG;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
Culture="1033"
AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
/>
@@ -267,16 +266,14 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib qmfconsole.lib"
- OutputFile="$(OutDir)\ping.exe"
- LinkIncremental="1"
+ AdditionalDependencies="qpidmessagingd.lib qpidcommond.lib qpidtypesd.lib"
+ OutputFile="$(OutDir)\server_reconnect.exe"
+ LinkIncremental="2"
SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
+ AdditionalLibraryDirectories="$(QPID_ROOT)\bin;..\..\lib"
GenerateDebugInformation="true"
SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
@@ -302,8 +299,8 @@ </Configuration>
<Configuration
Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\qmf_console_ping\AMD64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="0"
>
@@ -323,6 +320,7 @@ Name="VCMIDLTool"
AdditionalOptions=""
AdditionalIncludeDirectories=""
+ TargetEnvironment="3"
TypeLibraryName="$(InputName).tlb"
HeaderFileName="$(InputName).h"
InterfaceIdentifierFileName="$(InputName)_i.c"
@@ -331,20 +329,19 @@ <Tool
Name="VCCLCompilerTool"
Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
+ AdditionalIncludeDirectories=""$(QPID_ROOT)\include";..\..\include"
+ PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
RuntimeLibrary="2"
RuntimeTypeInfo="true"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
+ PreprocessorDefinitions="NDEBUG;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
Culture="1033"
AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
/>
@@ -353,12 +350,11 @@ />
<Tool
Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib qmfconsole.lib"
- OutputFile="$(OutDir)\ping.exe"
+ AdditionalDependencies="qpidmessaging.lib qpidcommon.lib qpidtypes.lib"
+ OutputFile="$(OutDir)\server_reconnect.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
+ AdditionalLibraryDirectories="$(QPID_ROOT)\bin;..\..\lib"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
@@ -393,24 +389,51 @@ <Files>
<Filter
Name="Source Files"
- Filter="cpp;cxx;cc;C;c"
+ Filter="cpp;cxx;cc;c;C"
>
<File
- RelativePath="ping.cpp"
+ RelativePath="server_reconnect.cpp"
>
</File>
</Filter>
<Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh"
+ Name="Documentation"
>
<File
- RelativePath="ConnectionOptions.h"
- >
- </File>
- <File
- RelativePath="TestOptions.h"
+ RelativePath="CMakeLists.txt"
>
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
</File>
</Filter>
</Files>
diff --git a/qpid/cpp/examples/messaging/server_reconnect.cpp b/qpid/cpp/examples/messaging/server_reconnect.cpp new file mode 100644 index 0000000000..ab7147760f --- /dev/null +++ b/qpid/cpp/examples/messaging/server_reconnect.cpp @@ -0,0 +1,97 @@ +/* + * + * 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 <qpid/messaging/Address.h> +#include <qpid/messaging/Connection.h> +#include <qpid/messaging/exceptions.h> +#include <qpid/messaging/Message.h> +#include <qpid/messaging/Receiver.h> +#include <qpid/messaging/Sender.h> +#include <qpid/messaging/Session.h> + +#include <algorithm> +#include <cstdlib> +#include <iostream> +#include <memory> +#include <sstream> + +using namespace qpid::messaging; + +using std::stringstream; +using std::string; + +int main(int argc, char** argv) { + std::string url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; + std::string connectionOptions = argc > 2 ? argv[2] : ""; + + Connection connection(url, connectionOptions); + try { + connection.open(); + Session session = connection.createSession(); + Receiver receiver = session.createReceiver("service_queue; {create: always}"); + + while (true) { + try { + if (!connection.isOpen()) { + // This demonstrates use of application controlled + // reconnect; the reconnect connection option may + // also be used to automatcially handle + // reconnection + if (url.empty()) { + connection.reconnect(); + } else { + connection.reconnect(url); + } + std::cout << "Reconnected to " << connection.getUrl() << std::endl; + } + Message request = receiver.fetch(); + const Address& address = request.getReplyTo(); + if (address) { + Sender sender = session.createSender(address); + std::string s = request.getContent(); + std::transform(s.begin(), s.end(), s.begin(), toupper); + Message response(s); + sender.send(response); + std::cout << "Processed request: " + << request.getContent() + << " -> " + << response.getContent() << std::endl; + session.acknowledge(); + sender.close(); + } else { + std::cerr << "Error: no reply address specified for request: " << request.getContent() << std::endl; + session.reject(request); + } + } catch (const TransportFailure&) { + std::cout << "Connection to broker was lost, please enter URL to reconnect to (or hit return to use original url):" << std::endl; + if (!std::getline(std::cin, url)) { + return 1; + } + } + } + connection.close(); + return 0; + } catch(const std::exception& error) { + std::cout << error.what() << std::endl; + connection.close(); + } + return 1; +} diff --git a/qpid/cpp/examples/messaging/spout.cpp b/qpid/cpp/examples/messaging/spout.cpp index 72fcdc7c65..d3451c084b 100644 --- a/qpid/cpp/examples/messaging/spout.cpp +++ b/qpid/cpp/examples/messaging/spout.cpp @@ -43,6 +43,7 @@ struct Options : OptionParser std::string url; std::string address; int timeout; + bool durable; int count; std::string id; std::string replyto; @@ -55,10 +56,12 @@ struct Options : OptionParser : OptionParser("Usage: spout [OPTIONS] ADDRESS", "Send messages to the specified address"), url("127.0.0.1"), timeout(0), - count(1) + count(1), + durable(false) { add("broker,b", url, "url of broker to connect to"); add("timeout,t", timeout, "exit after the specified time"); + add("durable,d", durable, "make the message durable (def. transient)"); add("count,c", count, "stop after count messages have been sent, zero disables"); add("id,i", id, "use the supplied id instead of generating one"); add("reply-to", replyto, "specify reply-to address"); @@ -127,6 +130,11 @@ struct Options : OptionParser return true; } } + + bool isDurable() const + { + return durable; + } }; @@ -141,14 +149,16 @@ int main(int argc, char** argv) Sender sender = session.createSender(options.address); Message message; + message.setDurable(options.isDurable()); options.setProperties(message); + Variant& obj = message.getContentObject(); if (options.entries.size()) { Variant::Map content; options.setEntries(content); - encode(content, message); + obj = content; } else if (options.content.size()) { - message.setContent(options.content); - message.setContentType("text/plain"); + obj = options.content; + obj.setEncoding("utf8"); } std::time_t start = std::time(0); for (int count = 0; diff --git a/qpid/cpp/examples/old_api/CMakeLists.txt b/qpid/cpp/examples/old_api/CMakeLists.txt deleted file mode 100644 index 701f9be860..0000000000 --- a/qpid/cpp/examples/old_api/CMakeLists.txt +++ /dev/null @@ -1,25 +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. -# -add_subdirectory(direct) -add_subdirectory(failover) -add_subdirectory(fanout) -add_subdirectory(pub-sub) -add_subdirectory(request-response) -add_subdirectory(tradedemo) -add_subdirectory(xml-exchange) diff --git a/qpid/cpp/examples/old_api/Makefile.am b/qpid/cpp/examples/old_api/Makefile.am deleted file mode 100644 index 04216ffa97..0000000000 --- a/qpid/cpp/examples/old_api/Makefile.am +++ /dev/null @@ -1,48 +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. -# -SUBDIRS = direct pub-sub fanout request-response failover tradedemo -if HAVE_XML - SUBDIRS += xml-exchange - broker_args = "--no-module-dir --data-dir \"\" --auth no --load-module $(top_builddir)/src/.libs/xml.so" -endif -if !HAVE_XML - exclude_examples_regexp="xml" # Exclude XML examples. - broker_args = "--no-module-dir --data-dir \"\" --auth no" -endif - -MAKEDIST=.libs/Makefile - -$(MAKEDIST): Makefile - mkdir -p .libs - @(echo 'all clean:' ; \ - echo ' for d in $(SUBDIRS) ; do $$(MAKE) -C $$$$d $$@ ; done' ; \ - ) > $(MAKEDIST) - -examplesdir=$(pkgdatadir)/examples/old_api -dist_examples_DATA = $(MAKEDIST) -EXTRA_DIST = README.verify verify verify_all CMakeLists.txt - -# For older versions of automake -abs_top_srcdir = @abs_top_srcdir@ -abs_top_builddir = @abs_top_builddir@ - -# Verify the examples in the buid tree. -check-local: - $(srcdir)/verify_all $(abs_top_srcdir)/.. $(abs_top_builddir) $(broker_args) $(exclude_examples_regexp) - diff --git a/qpid/cpp/examples/old_api/README.verify b/qpid/cpp/examples/old_api/README.verify deleted file mode 100644 index e1370764c9..0000000000 --- a/qpid/cpp/examples/old_api/README.verify +++ /dev/null @@ -1,42 +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. -# -= Qpid C++ Examples = - -For more information read examples/README. - -== The Verify All Script == - -The verify_all script will run each C++ example and compare its output -against what is expected. - -=== Arguments === - -The verify_all script expects the path to Qpid trunk as an argument. - -== The Verify Script == - -The verify script is capable of running one or many scripts designed to verify -the success of Qpid examples. The verify script is utilized by the verify_all -scripts. - -=== Verifying an individual example === - -This will require you using the verify script, and providing the necessary sub -script(s) it will utilize in the process. Please note that it is your -responsibility to setup the necessary environment for the verification process diff --git a/qpid/cpp/examples/old_api/direct/CMakeLists.txt b/qpid/cpp/examples/old_api/direct/CMakeLists.txt deleted file mode 100644 index 2ec1b2b813..0000000000 --- a/qpid/cpp/examples/old_api/direct/CMakeLists.txt +++ /dev/null @@ -1,22 +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. -# - -add_example(direct declare_queues) -add_example(direct direct_producer) -add_example(direct listener) diff --git a/qpid/cpp/examples/old_api/direct/Makefile.am b/qpid/cpp/examples/old_api/direct/Makefile.am deleted file mode 100644 index 18957c84f4..0000000000 --- a/qpid/cpp/examples/old_api/direct/Makefile.am +++ /dev/null @@ -1,47 +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. -# -examplesdir=$(pkgdatadir)/examples/old_api/direct - -MAKELDFLAGS=$(CLIENTFLAGS) -include $(top_srcdir)/examples/makedist.mk - -noinst_PROGRAMS=direct_producer listener declare_queues -direct_producer_SOURCES=direct_producer.cpp -direct_producer_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -listener_SOURCES=listener.cpp -listener_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -declare_queues_SOURCES=declare_queues.cpp -declare_queues_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -examples_DATA= \ - direct_producer.cpp \ - listener.cpp \ - declare_queues.cpp \ - $(MAKEDIST) - -EXTRA_DIST= \ - $(examples_DATA) \ - CMakeLists.txt \ - verify \ - verify.in \ - direct_declare_queues.vcproj \ - direct_direct_producer.vcproj \ - direct_listener.vcproj diff --git a/qpid/cpp/examples/old_api/direct/declare_queues.cpp b/qpid/cpp/examples/old_api/direct/declare_queues.cpp deleted file mode 100644 index 9a51d1982b..0000000000 --- a/qpid/cpp/examples/old_api/direct/declare_queues.cpp +++ /dev/null @@ -1,85 +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. - * - */ - - -/** - * declare_queues.cpp - * - * This program is one of three programs designed to be used - * together. - * - * declare_queues.cpp: (this program): - * - * Creates a queue named "message_queue" on a broker, binding the - * queue to the "amq.direct" exchange, using the routing key - * "routing_key". - * - * direct_producer.cpp - * - * Publishes to the "amq.direct" exchange, specifying the routing - * key "routing_key" - * - * listener.cpp - * - * Reads from the "message_queue" queue on the broker using a - * message listener. - * - */ - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> - - -using namespace qpid::client; -using namespace qpid::framing; - - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - Connection connection; - - try { - connection.open(host, port); - Session session = connection.newSession(); - - - //--------- Main body of program -------------------------------------------- - - // Create a queue named "message_queue", and route all messages whose - // routing key is "routing_key" to this newly created queue. - - session.queueDeclare(arg::queue="message_queue"); - session.exchangeBind(arg::exchange="amq.direct", arg::queue="message_queue", arg::bindingKey="routing_key"); - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; - -} - - - diff --git a/qpid/cpp/examples/old_api/direct/direct_declare_queues.vcproj b/qpid/cpp/examples/old_api/direct/direct_declare_queues.vcproj deleted file mode 100644 index 083474b9ef..0000000000 --- a/qpid/cpp/examples/old_api/direct/direct_declare_queues.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="direct_declare_queues"
- ProjectGUID="{18165D4D-FECA-1BAD-4346-8C4DF2536AA5}"
- RootNamespace="direct_declare_queues"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\direct_declare_queues\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\direct_declare_queues\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\direct_declare_queues\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\direct_declare_queues\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="declare_queues.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/direct/direct_direct_producer.vcproj b/qpid/cpp/examples/old_api/direct/direct_direct_producer.vcproj deleted file mode 100644 index f091fbf291..0000000000 --- a/qpid/cpp/examples/old_api/direct/direct_direct_producer.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="direct_direct_producer"
- ProjectGUID="{9701E0BD-FECA-1BAD-4346-8C4DF2536AA5}"
- RootNamespace="direct_direct_producer"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\direct_direct_producer\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\direct_producer.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\direct_direct_producer\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\direct_producer.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\direct_direct_producer\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\direct_producer.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\direct_direct_producer\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\direct_producer.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="direct_producer.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/direct/direct_listener.vcproj b/qpid/cpp/examples/old_api/direct/direct_listener.vcproj deleted file mode 100644 index dce1d3ec28..0000000000 --- a/qpid/cpp/examples/old_api/direct/direct_listener.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="direct_listener"
- ProjectGUID="{95CE1459-FECA-1BAD-4346-8C4DF2536AA5}"
- RootNamespace="direct_listener"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\direct_listener\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\listener.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\direct_listener\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\listener.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\direct_listener\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\listener.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\direct_listener\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\listener.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="listener.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/direct/direct_producer.cpp b/qpid/cpp/examples/old_api/direct/direct_producer.cpp deleted file mode 100644 index ecc9675189..0000000000 --- a/qpid/cpp/examples/old_api/direct/direct_producer.cpp +++ /dev/null @@ -1,109 +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. - * - */ - -/** - * direct_producer.cpp: - * - * This program is one of three programs designed to be used - * together. - * - * create_queues.cpp: - * - * Creates a queue named "message_queue" on a broker, binding the - * queue to the "amq.direct" exchange, using the routing key - * "routing_key". - * - * direct_producer.cpp (this program): - * - * Publishes to the "amq.direct" exchange, specifying the routing - * key "routing_key" - * - * listener.cpp - * - * Reads from the "message_queue" queue on the broker using a - * message listener. - * - */ - - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/AsyncSession.h> -#include <qpid/client/Message.h> - - -#include <cstdlib> -#include <iostream> - -#include <sstream> - -using namespace qpid::client; -using namespace qpid::framing; - -using std::stringstream; -using std::string; - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - int count = argc>3 ? atoi(argv[3]) : 10; - - Connection connection; - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - // The routing key is a message property. We will use the same - // routing key for each message, so we'll set this property - // just once. (In most simple cases, there is no need to set - // other message properties.) - - Message message; - message.getDeliveryProperties().setRoutingKey("routing_key"); - - // Now send some messages ... - - for (int i=0; i<count; i++) { - stringstream message_data; - message_data << "Message " << i; - - message.setData(message_data.str()); - session.messageTransfer(arg::content=message, arg::destination="amq.direct"); - } - - // And send a final message to indicate termination. - - message.setData("That's all, folks!"); - session.messageTransfer(arg::content=message, arg::destination="amq.direct"); - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/direct/listener.cpp b/qpid/cpp/examples/old_api/direct/listener.cpp deleted file mode 100644 index 38bf24ec41..0000000000 --- a/qpid/cpp/examples/old_api/direct/listener.cpp +++ /dev/null @@ -1,109 +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. - * - */ - -/** - * listener.cpp: - * - * This program is one of three programs designed to be used - * together. - * - * create_queues.cpp: - * - * Creates a queue named "message_queue" on a broker, binding the - * queue to the "amq.direct" exchange, using the routing key - * "routing_key". - * - * direct_producer.cpp - * - * Publishes to the "amq.direct" exchange, specifying the routing - * key "routing_key" - * - * listener.cpp (this program): - * - * Reads from the "message_queue" queue on the broker using a - * message listener. - */ - - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/Message.h> -#include <qpid/client/MessageListener.h> -#include <qpid/client/SubscriptionManager.h> - -#include <cstdlib> -#include <iostream> - -using namespace qpid::client; -using namespace qpid::framing; - - -class Listener : public MessageListener{ - private: - SubscriptionManager& subscriptions; - public: - Listener(SubscriptionManager& subscriptions); - virtual void received(Message& message); -}; - -Listener::Listener(SubscriptionManager& subs) : subscriptions(subs) -{} - -void Listener::received(Message& message) { - std::cout << "Message: " << message.getData() << std::endl; - if (message.getData() == "That's all, folks!") { - std::cout << "Shutting down listener for " << message.getDestination() - << std::endl; - subscriptions.cancel(message.getDestination()); - } -} - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - - Connection connection; - - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - SubscriptionManager subscriptions(session); - // Create a listener and subscribe it to the queue named "message_queue" - Listener listener(subscriptions); - subscriptions.subscribe(listener, "message_queue"); - // Receive messages until the subscription is cancelled - // by Listener::received() - subscriptions.run(); - - //--------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/direct/verify b/qpid/cpp/examples/old_api/direct/verify deleted file mode 100644 index f598bacc1f..0000000000 --- a/qpid/cpp/examples/old_api/direct/verify +++ /dev/null @@ -1,23 +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. -# - - -# See https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/bin/verify -clients ./declare_queues ./direct_producer ./listener -outputs ./declare_queues.out ./direct_producer.out ./listener.out diff --git a/qpid/cpp/examples/old_api/direct/verify.in b/qpid/cpp/examples/old_api/direct/verify.in deleted file mode 100644 index d1e95f1151..0000000000 --- a/qpid/cpp/examples/old_api/direct/verify.in +++ /dev/null @@ -1,15 +0,0 @@ -==== declare_queues.out -==== direct_producer.out -==== listener.out -Message: Message 0 -Message: Message 1 -Message: Message 2 -Message: Message 3 -Message: Message 4 -Message: Message 5 -Message: Message 6 -Message: Message 7 -Message: Message 8 -Message: Message 9 -Message: That's all, folks! -Shutting down listener for message_queue diff --git a/qpid/cpp/examples/old_api/failover/CMakeLists.txt b/qpid/cpp/examples/old_api/failover/CMakeLists.txt deleted file mode 100644 index 05db8fad51..0000000000 --- a/qpid/cpp/examples/old_api/failover/CMakeLists.txt +++ /dev/null @@ -1,22 +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. -# - -add_example(failover declare_queues) -add_example(failover resuming_receiver) -add_example(failover replaying_sender) diff --git a/qpid/cpp/examples/old_api/failover/Makefile.am b/qpid/cpp/examples/old_api/failover/Makefile.am deleted file mode 100644 index 60e99b9ed6..0000000000 --- a/qpid/cpp/examples/old_api/failover/Makefile.am +++ /dev/null @@ -1,47 +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. -# -examplesdir=$(pkgdatadir)/examples/old_api/failover - -MAKELDFLAGS=$(CLIENTFLAGS) -include $(top_srcdir)/examples/makedist.mk - -noinst_PROGRAMS=declare_queues resuming_receiver replaying_sender - -declare_queues_SOURCES=declare_queues.cpp -declare_queues_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -resuming_receiver_SOURCES=resuming_receiver.cpp -resuming_receiver_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -replaying_sender_SOURCES=replaying_sender.cpp -replaying_sender_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -examples_DATA= \ - declare_queues.cpp \ - resuming_receiver.cpp \ - replaying_sender.cpp \ - $(MAKEDIST) - -# FIXME aconway 2008-10-10: add verify scripts. - -EXTRA_DIST= \ - CMakeLists.txt \ - failover_declare_queues.vcproj \ - failover_replaying_sender.vcproj \ - failover_resuming_receiver.vcproj diff --git a/qpid/cpp/examples/old_api/failover/declare_queues.cpp b/qpid/cpp/examples/old_api/failover/declare_queues.cpp deleted file mode 100644 index a677870c53..0000000000 --- a/qpid/cpp/examples/old_api/failover/declare_queues.cpp +++ /dev/null @@ -1,61 +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. - * - */ - -#include <qpid/client/FailoverManager.h> -#include <qpid/client/Session.h> -#include <qpid/Exception.h> - -#include <cstdlib> -#include <iostream> - -using namespace qpid::client; - -using namespace std; - -int main(int argc, char ** argv) -{ - ConnectionSettings settings; - if (argc > 1) settings.host = argv[1]; - if (argc > 2) settings.port = atoi(argv[2]); - - FailoverManager connection(settings); - try { - bool complete = false; - while (!complete) { - Session session = connection.connect().newSession(); - try { - session.queueDeclare(arg::queue="message_queue"); - complete = true; - } catch (const qpid::TransportFailure&) {} - } - connection.close(); - return 0; - } catch (const std::exception& error) { - std::cout << "Failed:" << error.what() << std::endl; - return 1; - } - -} - - - - - diff --git a/qpid/cpp/examples/old_api/failover/failover_declare_queues.vcproj b/qpid/cpp/examples/old_api/failover/failover_declare_queues.vcproj deleted file mode 100644 index c87c72affd..0000000000 --- a/qpid/cpp/examples/old_api/failover/failover_declare_queues.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="failover_declare_queues"
- ProjectGUID="{7817898E-FECA-1BAD-8026-8D997AD361D0}"
- RootNamespace="failover_declare_queues"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\failover_declare_queues\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\failover_declare_queues\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\failover_declare_queues\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\failover_declare_queues\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="declare_queues.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/failover/failover_replaying_sender.vcproj b/qpid/cpp/examples/old_api/failover/failover_replaying_sender.vcproj deleted file mode 100644 index 6d22fa6770..0000000000 --- a/qpid/cpp/examples/old_api/failover/failover_replaying_sender.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="failover_replaying_sender"
- ProjectGUID="{085D6A66-FECA-1BAD-8026-8D997AD361D0}"
- RootNamespace="failover_replaying_sender"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\failover_replaying_sender\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\replaying_sender.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\failover_replaying_sender\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\replaying_sender.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\failover_replaying_sender\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\replaying_sender.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\failover_replaying_sender\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\replaying_sender.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="replaying_sender.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/failover/failover_resuming_receiver.vcproj b/qpid/cpp/examples/old_api/failover/failover_resuming_receiver.vcproj deleted file mode 100644 index ba5061e248..0000000000 --- a/qpid/cpp/examples/old_api/failover/failover_resuming_receiver.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="failover_resuming_receiver"
- ProjectGUID="{B0DAF702-FECA-1BAD-8026-8D997AD361D0}"
- RootNamespace="failover_resuming_receiver"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\failover_resuming_receiver\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\resuming_receiver.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\failover_resuming_receiver\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\resuming_receiver.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\failover_resuming_receiver\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\resuming_receiver.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\failover_resuming_receiver\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\resuming_receiver.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="resuming_receiver.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/failover/replaying_sender.cpp b/qpid/cpp/examples/old_api/failover/replaying_sender.cpp deleted file mode 100644 index 22a7e1ebd3..0000000000 --- a/qpid/cpp/examples/old_api/failover/replaying_sender.cpp +++ /dev/null @@ -1,97 +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. - * - */ - -#include <qpid/client/FailoverManager.h> -#include <qpid/client/Session.h> -#include <qpid/client/AsyncSession.h> -#include <qpid/client/Message.h> -#include <qpid/client/MessageReplayTracker.h> -#include <qpid/Exception.h> - -#include <iostream> -#include <sstream> - -using namespace qpid; -using namespace qpid::client; -using namespace qpid::framing; - -using namespace std; - -class Sender : public FailoverManager::Command -{ - public: - Sender(const std::string& queue, uint count); - void execute(AsyncSession& session, bool isRetry); - uint getSent(); - private: - MessageReplayTracker sender; - const uint count; - uint sent; - Message message; - -}; - -Sender::Sender(const std::string& queue, uint count_) : sender(10), count(count_), sent(0) -{ - message.getDeliveryProperties().setRoutingKey(queue); -} - -void Sender::execute(AsyncSession& session, bool isRetry) -{ - if (isRetry) sender.replay(session); - else sender.init(session); - while (sent < count) { - stringstream message_data; - message_data << ++sent; - message.setData(message_data.str()); - message.getHeaders().setInt("sn", sent); - sender.send(message); - if (count > 1000 && !(sent % 1000)) { - std::cout << "sent " << sent << " of " << count << std::endl; - } - } - message.setData("That's all, folks!"); - sender.send(message); -} - -uint Sender::getSent() -{ - return sent; -} - -int main(int argc, char ** argv) -{ - ConnectionSettings settings; - if (argc > 1) settings.host = argv[1]; - if (argc > 2) settings.port = atoi(argv[2]); - - FailoverManager connection(settings); - Sender sender("message_queue", argc > 3 ? atoi(argv[3]) : 1000); - try { - connection.execute(sender); - std::cout << "Sent " << sender.getSent() << " messages." << std::endl; - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << "Failed: " << error.what() << std::endl; - } - return 1; -} diff --git a/qpid/cpp/examples/old_api/failover/resuming_receiver.cpp b/qpid/cpp/examples/old_api/failover/resuming_receiver.cpp deleted file mode 100644 index d1886ce861..0000000000 --- a/qpid/cpp/examples/old_api/failover/resuming_receiver.cpp +++ /dev/null @@ -1,127 +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. - * - */ - -#include <qpid/client/FailoverManager.h> -#include <qpid/client/Session.h> -#include <qpid/client/Message.h> -#include <qpid/client/SubscriptionManager.h> - -#include <iostream> -#include <fstream> - - -using namespace qpid; -using namespace qpid::client; -using namespace qpid::framing; - -using namespace std; - - -class Listener : public MessageListener, - public FailoverManager::Command, - public FailoverManager::ReconnectionStrategy -{ - public: - Listener(); - void received(Message& message); - void execute(AsyncSession& session, bool isRetry); - void check(); - void editUrlList(std::vector<Url>& urls); - private: - Subscription subscription; - uint count; - uint skipped; - uint lastSn; - bool gaps; -}; - -Listener::Listener() : count(0), skipped(0), lastSn(0), gaps(false) {} - -void Listener::received(Message & message) -{ - if (message.getData() == "That's all, folks!") { - std::cout << "Shutting down listener for " << message.getDestination() - << std::endl; - - std::cout << "Listener received " << count << " messages (" << skipped << " skipped)" << std::endl; - subscription.cancel(); - } else { - uint sn = message.getHeaders().getAsInt("sn"); - if (lastSn < sn) { - if (sn - lastSn > 1) { - std::cout << "Error: gap in sequence between " << lastSn << " and " << sn << std::endl; - gaps = true; - } - lastSn = sn; - ++count; - } else { - ++skipped; - } - } -} - -void Listener::check() -{ - if (gaps) throw Exception("Detected gaps in sequence; messages appear to have been lost."); -} - -void Listener::execute(AsyncSession& session, bool isRetry) -{ - if (isRetry) { - std::cout << "Resuming from " << count << std::endl; - } - SubscriptionManager subs(session); - subscription = subs.subscribe(*this, "message_queue"); - subs.run(); -} - -void Listener::editUrlList(std::vector<Url>& urls) -{ - /** - * A more realistic algorithm would be to search through the list - * for prefered hosts and ensure they come first in the list. - */ - if (urls.size() > 1) std::rotate(urls.begin(), urls.begin() + 1, urls.end()); -} - -int main(int argc, char ** argv) -{ - ConnectionSettings settings; - if (argc > 1) settings.host = argv[1]; - if (argc > 2) settings.port = atoi(argv[2]); - - Listener listener; - FailoverManager connection(settings, &listener); - - try { - connection.execute(listener); - connection.close(); - listener.check(); - std::cout << "Completed without error." << std::endl; - return 0; - } catch(const std::exception& error) { - std::cout << "Failure: " << error.what() << std::endl; - } - return 1; -} - - - diff --git a/qpid/cpp/examples/old_api/fanout/CMakeLists.txt b/qpid/cpp/examples/old_api/fanout/CMakeLists.txt deleted file mode 100644 index 3f89d67650..0000000000 --- a/qpid/cpp/examples/old_api/fanout/CMakeLists.txt +++ /dev/null @@ -1,21 +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. -# - -add_example(fanout fanout_producer) -add_example(fanout listener) diff --git a/qpid/cpp/examples/old_api/fanout/Makefile.am b/qpid/cpp/examples/old_api/fanout/Makefile.am deleted file mode 100644 index 06e84b47b6..0000000000 --- a/qpid/cpp/examples/old_api/fanout/Makefile.am +++ /dev/null @@ -1,42 +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. -# -examplesdir=$(pkgdatadir)/examples/old_api/fanout - -MAKELDFLAGS=$(CLIENTFLAGS) -include $(top_srcdir)/examples/makedist.mk - -noinst_PROGRAMS=fanout_producer listener -fanout_producer_SOURCES=fanout_producer.cpp -fanout_producer_LDADD=$(CLIENT_LIB) - -listener_SOURCES=listener.cpp -listener_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -examples_DATA= \ - fanout_producer.cpp \ - listener.cpp \ - $(MAKEDIST) - -EXTRA_DIST= \ - $(examples_DATA) \ - CMakeLists.txt \ - verify \ - verify.in \ - fanout_fanout_producer.vcproj \ - fanout_listener.vcproj diff --git a/qpid/cpp/examples/old_api/fanout/fanout_fanout_producer.vcproj b/qpid/cpp/examples/old_api/fanout/fanout_fanout_producer.vcproj deleted file mode 100644 index daff5f3cf0..0000000000 --- a/qpid/cpp/examples/old_api/fanout/fanout_fanout_producer.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="fanout_fanout_producer"
- ProjectGUID="{972AB76B-FECA-1BAD-8826-8C64F27AA1C5}"
- RootNamespace="fanout_fanout_producer"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\fanout_fanout_producer\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\fanout_producer.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\fanout_fanout_producer\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\fanout_producer.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\fanout_fanout_producer\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\fanout_producer.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\fanout_fanout_producer\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\fanout_producer.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="fanout_producer.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/fanout/fanout_listener.vcproj b/qpid/cpp/examples/old_api/fanout/fanout_listener.vcproj deleted file mode 100644 index f0e91b7dc6..0000000000 --- a/qpid/cpp/examples/old_api/fanout/fanout_listener.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="fanout_listener"
- ProjectGUID="{95E7DF39-FECA-1BAD-8826-8C64F27AA1C5}"
- RootNamespace="fanout_listener"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\fanout_listener\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\listener.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\fanout_listener\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\listener.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\fanout_listener\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\listener.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\fanout_listener\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\listener.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="listener.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/fanout/fanout_producer.cpp b/qpid/cpp/examples/old_api/fanout/fanout_producer.cpp deleted file mode 100644 index decd4d314d..0000000000 --- a/qpid/cpp/examples/old_api/fanout/fanout_producer.cpp +++ /dev/null @@ -1,105 +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. - * - */ - - -/** - * fanout_producer.cpp: - * - * This program is one of two programs designed to be used - * together. - * - * fanout_producer.cpp (this program): - * - * Publishes messages to the "amq.fanout" exchange. - * - * listener.cpp - * - * Creates a private queue, binds it to the "amq.fanout" - * exchange, and reads messages from its queue as they - * arrive. Messages sent before the listener binds the queue are - * not received. - * - * Multiple listeners can run at the same time. - * - */ - - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/AsyncSession.h> -#include <qpid/client/Message.h> - - -#include <cstdlib> -#include <iostream> - -#include <sstream> - -using namespace qpid::client; -using namespace qpid::framing; - -using std::stringstream; -using std::string; - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - - Connection connection; - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - // Unlike topic exchanges and direct exchanges, a fanout - // exchange need not set a routing key. - - Message message; - - // Now send some messages ... - - for (int i=0; i<10; i++) { - stringstream message_data; - message_data << "Message " << i; - - message.setData(message_data.str()); - // Asynchronous transfer sends messages as quickly as - // possible without waiting for confirmation. - async(session).messageTransfer(arg::content=message, arg::destination="amq.fanout"); - } - - // And send a final message to indicate termination. - - message.setData("That's all, folks!"); - session.messageTransfer(arg::content=message, arg::destination="amq.fanout"); - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/fanout/listener.cpp b/qpid/cpp/examples/old_api/fanout/listener.cpp deleted file mode 100644 index cd3071c29a..0000000000 --- a/qpid/cpp/examples/old_api/fanout/listener.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. - * - */ - - -/** - * listener.cpp - * - * This program is one of two programs designed to be used - * together. - * - * fanout_producer.cpp - * - * Publishes messages to the "amq.fanout" exchange. - * - * listener.cpp (this program) - * - * Creates a private queue, binds it to the "amq.fanout" - * exchange, and reads messages from its queue as they - * arrive. Messages sent before the listener binds the queue are - * not received. - * - * Multiple listeners can run at the same time. - * - */ - - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/Message.h> -#include <qpid/client/MessageListener.h> -#include <qpid/client/SubscriptionManager.h> - -#include <cstdlib> -#include <iostream> - -using namespace qpid::client; -using namespace qpid::framing; - - -class Listener : public MessageListener{ - private: - SubscriptionManager& subscriptions; - public: - Listener(SubscriptionManager& subscriptions); - virtual void received(Message& message); -}; - -Listener::Listener(SubscriptionManager& subs) : subscriptions(subs) -{} - -void Listener::received(Message& message) { - std::cout << "Message: " << message.getData() << std::endl; - if (message.getData() == "That's all, folks!") { - std::cout << "Shutting down listener for " << message.getDestination() - << std::endl; - subscriptions.cancel(message.getDestination()); - } -} - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - - Connection connection; - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - // Each client creates its own private queue, using the - // session id to guarantee a unique name. It then routes - // all messages from the fanout exchange to its own queue - // by binding to the queue. - // - // The binding specifies a binding key, but for a fanout - // exchange, the binding key is optional and is not used - // for routing decisions. It can be useful for tracking - // messages and routing in logs. - - std::string myQueue=session.getId().getName(); - session.queueDeclare(arg::queue=myQueue, arg::exclusive=true, - arg::autoDelete=true); - - session.exchangeBind(arg::exchange="amq.fanout", arg::queue=myQueue, arg::bindingKey="my-key"); - - // Create a listener and subscribe it to my queue. - SubscriptionManager subscriptions(session); - Listener listener(subscriptions); - subscriptions.subscribe(listener, myQueue); - - // Receive messages until the subscription is cancelled - // by Listener::received() - std::cout << "Listening" << std::endl; - subscriptions.run(); - - //--------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/fanout/verify b/qpid/cpp/examples/old_api/fanout/verify deleted file mode 100644 index 2eaadff56b..0000000000 --- a/qpid/cpp/examples/old_api/fanout/verify +++ /dev/null @@ -1,25 +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. -# - -# See https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/bin/verify -background "Listening" ./listener -background "Listening" ./listener -background "Listening" ./listener -clients ./fanout_producer -outputs ./fanout_producer.out "./listener.out | remove_uuid" "./listenerX.out | remove_uuid" "./listenerXX.out | remove_uuid" diff --git a/qpid/cpp/examples/old_api/fanout/verify.in b/qpid/cpp/examples/old_api/fanout/verify.in deleted file mode 100644 index 8f8612ce67..0000000000 --- a/qpid/cpp/examples/old_api/fanout/verify.in +++ /dev/null @@ -1,43 +0,0 @@ -==== fanout_producer.out -==== listener.out | remove_uuid -Listening -Message: Message 0 -Message: Message 1 -Message: Message 2 -Message: Message 3 -Message: Message 4 -Message: Message 5 -Message: Message 6 -Message: Message 7 -Message: Message 8 -Message: Message 9 -Message: That's all, folks! -Shutting down listener for -==== listenerX.out | remove_uuid -Listening -Message: Message 0 -Message: Message 1 -Message: Message 2 -Message: Message 3 -Message: Message 4 -Message: Message 5 -Message: Message 6 -Message: Message 7 -Message: Message 8 -Message: Message 9 -Message: That's all, folks! -Shutting down listener for -==== listenerXX.out | remove_uuid -Listening -Message: Message 0 -Message: Message 1 -Message: Message 2 -Message: Message 3 -Message: Message 4 -Message: Message 5 -Message: Message 6 -Message: Message 7 -Message: Message 8 -Message: Message 9 -Message: That's all, folks! -Shutting down listener for diff --git a/qpid/cpp/examples/old_api/old-examples.sln b/qpid/cpp/examples/old_api/old-examples.sln deleted file mode 100644 index e6ec9a0d66..0000000000 --- a/qpid/cpp/examples/old_api/old-examples.sln +++ /dev/null @@ -1,123 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-#
-#
-# 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
-#
-#
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "direct_declare_queues", "direct\direct_declare_queues.vcproj", "{18165D4D-FECA-1BAD-4346-8C4DF2536AA5}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "direct_direct_producer", "direct\direct_direct_producer.vcproj", "{9701E0BD-FECA-1BAD-4346-8C4DF2536AA5}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "direct_listener", "direct\direct_listener.vcproj", "{95CE1459-FECA-1BAD-4346-8C4DF2536AA5}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "failover_declare_queues", "failover\failover_declare_queues.vcproj", "{7817898E-FECA-1BAD-8026-8D997AD361D0}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "failover_replaying_sender", "failover\failover_replaying_sender.vcproj", "{085D6A66-FECA-1BAD-8026-8D997AD361D0}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "failover_resuming_receiver", "failover\failover_resuming_receiver.vcproj", "{B0DAF702-FECA-1BAD-8026-8D997AD361D0}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fanout_fanout_producer", "fanout\fanout_fanout_producer.vcproj", "{972AB76B-FECA-1BAD-8826-8C64F27AA1C5}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fanout_listener", "fanout\fanout_listener.vcproj", "{95E7DF39-FECA-1BAD-8826-8C64F27AA1C5}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pub_sub_topic_listener", "pub-sub\pub-sub_topic_listener.vcproj", "{A415E66A-FECA-1BAD-A430-FD5330E23A2D}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pub_sub_topic_publisher", "pub-sub\pub-sub_topic_publisher.vcproj", "{05158653-FECA-1BAD-A430-FD5330E23A2D}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "request_response_client", "request-response\request-response_client.vcproj", "{2691FE1E-FECA-1BAD-BD3A-8A467D0C5CCC}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "request_response_server", "request-response\request-response_server.vcproj", "{46817425-FECA-1BAD-BD3A-8A467D0C5CCC}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tradedemo_declare_queues", "tradedemo\tradedemo_declare_queues.vcproj", "{9057502D-FECA-1BAD-23CE-CD4095BD3C8B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tradedemo_topic_listener", "tradedemo\tradedemo_topic_listener.vcproj", "{5A25F2CD-FECA-1BAD-23CE-CD4095BD3C8B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tradedemo_topic_publisher", "tradedemo\tradedemo_topic_publisher.vcproj", "{E614CC2C-FECA-1BAD-23CE-CD4095BD3C8B}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {18165D4D-FECA-1BAD-4346-8C4DF2536AA5}.Debug|Win32.ActiveCfg = Debug|Win32
- {18165D4D-FECA-1BAD-4346-8C4DF2536AA5}.Debug|Win32.Build.0 = Debug|Win32
- {18165D4D-FECA-1BAD-4346-8C4DF2536AA5}.Release|Win32.ActiveCfg = Release|Win32
- {18165D4D-FECA-1BAD-4346-8C4DF2536AA5}.Release|Win32.Build.0 = Release|Win32
- {9701E0BD-FECA-1BAD-4346-8C4DF2536AA5}.Debug|Win32.ActiveCfg = Debug|Win32
- {9701E0BD-FECA-1BAD-4346-8C4DF2536AA5}.Debug|Win32.Build.0 = Debug|Win32
- {9701E0BD-FECA-1BAD-4346-8C4DF2536AA5}.Release|Win32.ActiveCfg = Release|Win32
- {9701E0BD-FECA-1BAD-4346-8C4DF2536AA5}.Release|Win32.Build.0 = Release|Win32
- {95CE1459-FECA-1BAD-4346-8C4DF2536AA5}.Debug|Win32.ActiveCfg = Debug|Win32
- {95CE1459-FECA-1BAD-4346-8C4DF2536AA5}.Debug|Win32.Build.0 = Debug|Win32
- {95CE1459-FECA-1BAD-4346-8C4DF2536AA5}.Release|Win32.ActiveCfg = Release|Win32
- {95CE1459-FECA-1BAD-4346-8C4DF2536AA5}.Release|Win32.Build.0 = Release|Win32
- {7817898E-FECA-1BAD-8026-8D997AD361D0}.Debug|Win32.ActiveCfg = Debug|Win32
- {7817898E-FECA-1BAD-8026-8D997AD361D0}.Debug|Win32.Build.0 = Debug|Win32
- {7817898E-FECA-1BAD-8026-8D997AD361D0}.Release|Win32.ActiveCfg = Release|Win32
- {7817898E-FECA-1BAD-8026-8D997AD361D0}.Release|Win32.Build.0 = Release|Win32
- {085D6A66-FECA-1BAD-8026-8D997AD361D0}.Debug|Win32.ActiveCfg = Debug|Win32
- {085D6A66-FECA-1BAD-8026-8D997AD361D0}.Debug|Win32.Build.0 = Debug|Win32
- {085D6A66-FECA-1BAD-8026-8D997AD361D0}.Release|Win32.ActiveCfg = Release|Win32
- {085D6A66-FECA-1BAD-8026-8D997AD361D0}.Release|Win32.Build.0 = Release|Win32
- {B0DAF702-FECA-1BAD-8026-8D997AD361D0}.Debug|Win32.ActiveCfg = Debug|Win32
- {B0DAF702-FECA-1BAD-8026-8D997AD361D0}.Debug|Win32.Build.0 = Debug|Win32
- {B0DAF702-FECA-1BAD-8026-8D997AD361D0}.Release|Win32.ActiveCfg = Release|Win32
- {B0DAF702-FECA-1BAD-8026-8D997AD361D0}.Release|Win32.Build.0 = Release|Win32
- {972AB76B-FECA-1BAD-8826-8C64F27AA1C5}.Debug|Win32.ActiveCfg = Debug|Win32
- {972AB76B-FECA-1BAD-8826-8C64F27AA1C5}.Debug|Win32.Build.0 = Debug|Win32
- {972AB76B-FECA-1BAD-8826-8C64F27AA1C5}.Release|Win32.ActiveCfg = Release|Win32
- {972AB76B-FECA-1BAD-8826-8C64F27AA1C5}.Release|Win32.Build.0 = Release|Win32
- {95E7DF39-FECA-1BAD-8826-8C64F27AA1C5}.Debug|Win32.ActiveCfg = Debug|Win32
- {95E7DF39-FECA-1BAD-8826-8C64F27AA1C5}.Debug|Win32.Build.0 = Debug|Win32
- {95E7DF39-FECA-1BAD-8826-8C64F27AA1C5}.Release|Win32.ActiveCfg = Release|Win32
- {95E7DF39-FECA-1BAD-8826-8C64F27AA1C5}.Release|Win32.Build.0 = Release|Win32
- {A415E66A-FECA-1BAD-A430-FD5330E23A2D}.Debug|Win32.ActiveCfg = Debug|Win32
- {A415E66A-FECA-1BAD-A430-FD5330E23A2D}.Debug|Win32.Build.0 = Debug|Win32
- {A415E66A-FECA-1BAD-A430-FD5330E23A2D}.Release|Win32.ActiveCfg = Release|Win32
- {A415E66A-FECA-1BAD-A430-FD5330E23A2D}.Release|Win32.Build.0 = Release|Win32
- {05158653-FECA-1BAD-A430-FD5330E23A2D}.Debug|Win32.ActiveCfg = Debug|Win32
- {05158653-FECA-1BAD-A430-FD5330E23A2D}.Debug|Win32.Build.0 = Debug|Win32
- {05158653-FECA-1BAD-A430-FD5330E23A2D}.Release|Win32.ActiveCfg = Release|Win32
- {05158653-FECA-1BAD-A430-FD5330E23A2D}.Release|Win32.Build.0 = Release|Win32
- {2691FE1E-FECA-1BAD-BD3A-8A467D0C5CCC}.Debug|Win32.ActiveCfg = Debug|Win32
- {2691FE1E-FECA-1BAD-BD3A-8A467D0C5CCC}.Debug|Win32.Build.0 = Debug|Win32
- {2691FE1E-FECA-1BAD-BD3A-8A467D0C5CCC}.Release|Win32.ActiveCfg = Release|Win32
- {2691FE1E-FECA-1BAD-BD3A-8A467D0C5CCC}.Release|Win32.Build.0 = Release|Win32
- {46817425-FECA-1BAD-BD3A-8A467D0C5CCC}.Debug|Win32.ActiveCfg = Debug|Win32
- {46817425-FECA-1BAD-BD3A-8A467D0C5CCC}.Debug|Win32.Build.0 = Debug|Win32
- {46817425-FECA-1BAD-BD3A-8A467D0C5CCC}.Release|Win32.ActiveCfg = Release|Win32
- {46817425-FECA-1BAD-BD3A-8A467D0C5CCC}.Release|Win32.Build.0 = Release|Win32
- {9057502D-FECA-1BAD-23CE-CD4095BD3C8B}.Debug|Win32.ActiveCfg = Debug|Win32
- {9057502D-FECA-1BAD-23CE-CD4095BD3C8B}.Debug|Win32.Build.0 = Debug|Win32
- {9057502D-FECA-1BAD-23CE-CD4095BD3C8B}.Release|Win32.ActiveCfg = Release|Win32
- {9057502D-FECA-1BAD-23CE-CD4095BD3C8B}.Release|Win32.Build.0 = Release|Win32
- {5A25F2CD-FECA-1BAD-23CE-CD4095BD3C8B}.Debug|Win32.ActiveCfg = Debug|Win32
- {5A25F2CD-FECA-1BAD-23CE-CD4095BD3C8B}.Debug|Win32.Build.0 = Debug|Win32
- {5A25F2CD-FECA-1BAD-23CE-CD4095BD3C8B}.Release|Win32.ActiveCfg = Release|Win32
- {5A25F2CD-FECA-1BAD-23CE-CD4095BD3C8B}.Release|Win32.Build.0 = Release|Win32
- {E614CC2C-FECA-1BAD-23CE-CD4095BD3C8B}.Debug|Win32.ActiveCfg = Debug|Win32
- {E614CC2C-FECA-1BAD-23CE-CD4095BD3C8B}.Debug|Win32.Build.0 = Debug|Win32
- {E614CC2C-FECA-1BAD-23CE-CD4095BD3C8B}.Release|Win32.ActiveCfg = Release|Win32
- {E614CC2C-FECA-1BAD-23CE-CD4095BD3C8B}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/qpid/cpp/examples/old_api/pub-sub/CMakeLists.txt b/qpid/cpp/examples/old_api/pub-sub/CMakeLists.txt deleted file mode 100644 index 961de06d5a..0000000000 --- a/qpid/cpp/examples/old_api/pub-sub/CMakeLists.txt +++ /dev/null @@ -1,21 +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. -# - -add_example(pub-sub topic_listener) -add_example(pub-sub topic_publisher) diff --git a/qpid/cpp/examples/old_api/pub-sub/Makefile.am b/qpid/cpp/examples/old_api/pub-sub/Makefile.am deleted file mode 100644 index e8e19e4c32..0000000000 --- a/qpid/cpp/examples/old_api/pub-sub/Makefile.am +++ /dev/null @@ -1,43 +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. -# -examplesdir=$(pkgdatadir)/examples/old_api/pub-sub - -MAKELDFLAGS=$(CLIENTFLAGS) -include $(top_srcdir)/examples/makedist.mk - -noinst_PROGRAMS=topic_listener topic_publisher - -topic_listener_SOURCES=topic_listener.cpp -topic_listener_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -topic_publisher_SOURCES=topic_publisher.cpp -topic_publisher_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -examples_DATA= \ - topic_listener.cpp \ - topic_publisher.cpp \ - $(MAKEDIST) - -EXTRA_DIST= \ - $(examples_DATA) \ - CMakeLists.txt \ - verify \ - verify.in \ - pub-sub_topic_listener.vcproj \ - pub-sub_topic_publisher.vcproj diff --git a/qpid/cpp/examples/old_api/pub-sub/pub-sub_topic_listener.vcproj b/qpid/cpp/examples/old_api/pub-sub/pub-sub_topic_listener.vcproj deleted file mode 100644 index aa0b3bcaa3..0000000000 --- a/qpid/cpp/examples/old_api/pub-sub/pub-sub_topic_listener.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="pub_sub_topic_listener"
- ProjectGUID="{A415E66A-FECA-1BAD-A430-FD5330E23A2D}"
- RootNamespace="pub_sub_topic_listener"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\pub_sub_topic_listener\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\topic_listener.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\pub_sub_topic_listener\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\topic_listener.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\pub_sub_topic_listener\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\topic_listener.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\pub_sub_topic_listener\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\topic_listener.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="topic_listener.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/pub-sub/pub-sub_topic_publisher.vcproj b/qpid/cpp/examples/old_api/pub-sub/pub-sub_topic_publisher.vcproj deleted file mode 100644 index 76e51df4df..0000000000 --- a/qpid/cpp/examples/old_api/pub-sub/pub-sub_topic_publisher.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="pub_sub_topic_publisher"
- ProjectGUID="{05158653-FECA-1BAD-A430-FD5330E23A2D}"
- RootNamespace="pub_sub_topic_publisher"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\pub_sub_topic_publisher\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\topic_publisher.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\pub_sub_topic_publisher\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\topic_publisher.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\pub_sub_topic_publisher\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\topic_publisher.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\pub_sub_topic_publisher\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\topic_publisher.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="topic_publisher.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/pub-sub/topic_listener.cpp b/qpid/cpp/examples/old_api/pub-sub/topic_listener.cpp deleted file mode 100644 index d38a806303..0000000000 --- a/qpid/cpp/examples/old_api/pub-sub/topic_listener.cpp +++ /dev/null @@ -1,173 +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. - * - */ - -/** - * topic_listener.cpp: - * - * This program is one of two programs designed to be used - * together. These programs implement a publish-subscribe example - * using the "amq.topic" exchange. - * - * topic_publisher.cpp - * - * Sends messages to the "amq.topic" exchange, using the - * multipart routing keys "usa.news", "usa.weather", - * "europe.news", and "europe.weather". - * - * topic_listener.cpp (this program) - * - * Creates private queues for "news", "weather", "usa", and - * "europe", binding them to the amq.topic exchange using - * bindings that match the corresponding parts of the multipart - * routing keys. - * - * Multiple listeners can be run at the same time. - * - */ - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/Message.h> -#include <qpid/client/MessageListener.h> -#include <qpid/client/SubscriptionManager.h> - -#include <cstdlib> -#include <iostream> - -using namespace qpid::client; -using namespace qpid::framing; - - -class Listener : public MessageListener { - private: - Session& session; - SubscriptionManager subscriptions; - public: - Listener(Session& session); - virtual void prepareQueue(std::string queue, std::string exchange, std::string routing_key); - virtual void received(Message& message); - virtual void listen(); - ~Listener() { }; -}; - - -/* - * Listener::Listener - * - * Subscribe to the queue, route it to a client destination for the - * listener. (The destination name merely identifies the destination - * in the listener, you can use any name as long as you use the same - * name for the listener). - */ - -Listener::Listener(Session& session) : - session(session), - subscriptions(session) -{ -} - - -void Listener::prepareQueue(std::string queue, std::string exchange, std::string routing_key) { - - /* Create a unique queue name for this consumer by concatenating - * the queue name parameter with the Session ID. - */ - - queue += session.getId().getName(); - std::cout << "Declaring queue: " << queue << std::endl; - - /* Declare an exclusive queue on the broker - */ - - session.queueDeclare(arg::queue=queue, arg::exclusive=true, arg::autoDelete=true); - - /* Route messages to the new queue if they match the routing key. - * - * Also route any messages to with the "control" routing key to - * this queue so we know when it's time to stop. A publisher sends - * a message with the content "That's all, Folks!", using the - * "control" routing key, when it is finished. - */ - - session.exchangeBind(arg::exchange=exchange, arg::queue=queue, arg::bindingKey=routing_key); - session.exchangeBind(arg::exchange=exchange, arg::queue=queue, arg::bindingKey="control"); - - /* - * subscribe to the queue using the subscription manager. - */ - - std::cout << "Subscribing to queue " << queue << std::endl; - subscriptions.subscribe(*this, queue); -} - -void Listener::received(Message& message) { - std::cout << "Message: " << message.getData() << " from " << message.getDestination() << std::endl; - - if (message.getData() == "That's all, folks!") { - std::cout << "Shutting down listener for " << message.getDestination() << std::endl; - subscriptions.cancel(message.getDestination()); - } -} - -void Listener::listen() { - // Receive messages - subscriptions.run(); -} - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - std::string exchange = argc>3 ? argv[3] : "amq.topic"; - Connection connection; - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - // Create a listener for the session - - Listener listener(session); - - // Subscribe to messages on the queues we are interested in - - listener.prepareQueue("usa", exchange, "usa.#"); - listener.prepareQueue("europe", exchange, "europe.#"); - listener.prepareQueue("news", exchange, "#.news"); - listener.prepareQueue("weather", exchange, "#.weather"); - - std::cout << "Listening for messages ..." << std::endl; - - // Give up control and receive messages - listener.listen(); - - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/pub-sub/topic_publisher.cpp b/qpid/cpp/examples/old_api/pub-sub/topic_publisher.cpp deleted file mode 100644 index aed5f8f033..0000000000 --- a/qpid/cpp/examples/old_api/pub-sub/topic_publisher.cpp +++ /dev/null @@ -1,129 +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. - * - */ - -/** - * topic_publisher.cpp: - * - * This program is one of two programs designed to be used - * together. These programs implement a publish-subscribe example - * using the "amq.topic" exchange. - * - * topic_publisher.cpp (this program) - * - * Sends messages to the "amq.topic" exchange, using the - * multipart routing keys "usa.news", "usa.weather", - * "europe.news", and "europe.weather". - * - * topic_listener.cpp - * - * Creates private queues for "news", "weather", "usa", and - * "europe", binding them to the amq.topic exchange using - * bindings that match the corresponding parts of the multipart - * routing keys. - * - * Multiple listeners can be run at the same time. - * - */ - - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/AsyncSession.h> -#include <qpid/client/Message.h> - - -#include <cstdlib> -#include <iostream> - -#include <sstream> - -using namespace qpid::client; -using namespace qpid::framing; - -using std::stringstream; -using std::string; - -void publish_messages(Session& session, string routing_key) -{ - Message message; - - // Set the routing key once, we'll use the same routing key for all - // messages. - - message.getDeliveryProperties().setRoutingKey(routing_key); - for (int i=0; i<5; i++) { - stringstream message_data; - message_data << "Message " << i; - - message.setData(message_data.str()); - // Asynchronous transfer sends messages as quickly as - // possible without waiting for confirmation. - async(session).messageTransfer(arg::content=message, arg::destination="amq.topic"); - } - -} - -/* - * no_more_messages() - * - * Send a message to indicate that no more messages are coming. - * Use the 'control' routing key (see comments in topic_config_queues.cpp). - * - */ - -void no_more_messages(Session& session) -{ - Message message; - - message.getDeliveryProperties().setRoutingKey("control"); - message.setData("That's all, folks!"); - session.messageTransfer(arg::content=message, arg::destination="amq.topic"); -} - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - - Connection connection; - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - publish_messages(session, "usa.news"); - publish_messages(session, "usa.weather"); - publish_messages(session, "europe.news"); - publish_messages(session, "europe.weather"); - - no_more_messages(session); - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/pub-sub/verify b/qpid/cpp/examples/old_api/pub-sub/verify deleted file mode 100644 index 528d2f401e..0000000000 --- a/qpid/cpp/examples/old_api/pub-sub/verify +++ /dev/null @@ -1,23 +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. -# - -# See https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/bin/verify -background "Listening" ./topic_listener -clients ./topic_publisher -outputs ./topic_publisher.out "topic_listener.out | remove_uuid | sort" diff --git a/qpid/cpp/examples/old_api/pub-sub/verify.in b/qpid/cpp/examples/old_api/pub-sub/verify.in deleted file mode 100644 index 6413c5c788..0000000000 --- a/qpid/cpp/examples/old_api/pub-sub/verify.in +++ /dev/null @@ -1,59 +0,0 @@ -==== topic_publisher.out -==== topic_listener.out | remove_uuid | sort -Declaring queue: europe -Declaring queue: news -Declaring queue: usa -Declaring queue: weather -Listening for messages ... -Message: Message 0 from europe -Message: Message 0 from europe -Message: Message 0 from news -Message: Message 0 from news -Message: Message 0 from usa -Message: Message 0 from usa -Message: Message 0 from weather -Message: Message 0 from weather -Message: Message 1 from europe -Message: Message 1 from europe -Message: Message 1 from news -Message: Message 1 from news -Message: Message 1 from usa -Message: Message 1 from usa -Message: Message 1 from weather -Message: Message 1 from weather -Message: Message 2 from europe -Message: Message 2 from europe -Message: Message 2 from news -Message: Message 2 from news -Message: Message 2 from usa -Message: Message 2 from usa -Message: Message 2 from weather -Message: Message 2 from weather -Message: Message 3 from europe -Message: Message 3 from europe -Message: Message 3 from news -Message: Message 3 from news -Message: Message 3 from usa -Message: Message 3 from usa -Message: Message 3 from weather -Message: Message 3 from weather -Message: Message 4 from europe -Message: Message 4 from europe -Message: Message 4 from news -Message: Message 4 from news -Message: Message 4 from usa -Message: Message 4 from usa -Message: Message 4 from weather -Message: Message 4 from weather -Message: That's all, folks! from europe -Message: That's all, folks! from news -Message: That's all, folks! from usa -Message: That's all, folks! from weather -Shutting down listener for europe -Shutting down listener for news -Shutting down listener for usa -Shutting down listener for weather -Subscribing to queue europe -Subscribing to queue news -Subscribing to queue usa -Subscribing to queue weather diff --git a/qpid/cpp/examples/old_api/request-response/CMakeLists.txt b/qpid/cpp/examples/old_api/request-response/CMakeLists.txt deleted file mode 100644 index 873a0cfa86..0000000000 --- a/qpid/cpp/examples/old_api/request-response/CMakeLists.txt +++ /dev/null @@ -1,21 +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. -# - -add_example(request-response client) -add_example(request-response server) diff --git a/qpid/cpp/examples/old_api/request-response/Makefile.am b/qpid/cpp/examples/old_api/request-response/Makefile.am deleted file mode 100644 index cf10ae81db..0000000000 --- a/qpid/cpp/examples/old_api/request-response/Makefile.am +++ /dev/null @@ -1,43 +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. -# -examplesdir=$(pkgdatadir)/examples/old_api/request-response - -MAKELDFLAGS=$(CLIENTFLAGS) -include $(top_srcdir)/examples/makedist.mk - -noinst_PROGRAMS=client server - -client_SOURCES=client.cpp -client_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -server_SOURCES=server.cpp -server_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -examples_DATA= \ - server.cpp \ - client.cpp \ - $(MAKEDIST) - -EXTRA_DIST= \ - $(examples_DATA) \ - CMakeLists.txt \ - verify \ - verify.in \ - request-response_client.vcproj \ - request-response_server.vcproj diff --git a/qpid/cpp/examples/old_api/request-response/client.cpp b/qpid/cpp/examples/old_api/request-response/client.cpp deleted file mode 100644 index 679d1c5fc2..0000000000 --- a/qpid/cpp/examples/old_api/request-response/client.cpp +++ /dev/null @@ -1,163 +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. - * - */ - - -/** - * client.cpp - * - * This program is one of two programs that illustrate the - * request/response pattern. - * - * - * client.cpp (this program) - * - * A client application that sends messages to the "amq.direct" - * exchange, using the routing key "request" to route messages to - * the server. - * - * Each instance of the client creates its own private response - * queue, binding it to the "amq.direct" exchange using it's - * session identifier as the routing key, and places its session - * identifier in the "reply-to" property of each message it sends. - * - * - * server.cpp - * - * A service that accepts messages from a request queue, converts - * their content to upper case, and sends the result to the - * original sender. - * - * This program creates a request queue, binds it to "amq.direct" - * using the routing key "request", then receives messages from - * the request queue. Each incoming message is converted to upper - * case, then sent to the "amq.direct" exchange using the - * request's reply-to property as the routing key for the - * response. - * - * - */ - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/Message.h> -#include <qpid/client/MessageListener.h> -#include <qpid/client/SubscriptionManager.h> - -#include <cstdlib> -#include <iostream> - -#include <sstream> - -using namespace qpid::client; -using namespace qpid::framing; - -using std::stringstream; -using std::string; - -class Listener : public MessageListener{ - private: - SubscriptionManager& subscriptions; - int counter; - public: - Listener(SubscriptionManager& subscriptions); - virtual void received(Message& message); -}; - -Listener::Listener(SubscriptionManager& subs) : subscriptions(subs), counter(0) -{} - -void Listener::received(Message& message) { - std::cout << "Response: " << message.getData() << std::endl; - - ++ counter; - if (counter > 3) { - std::cout << "Shutting down listener for " << message.getDestination() << std::endl; - subscriptions.cancel(message.getDestination()); - } -} - - - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - Connection connection; - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - // Create a response queue so the server can send us responses - // to our requests. Use the client's session ID as the name - // of the response queue. - - stringstream response_queue; - response_queue << "client" << session.getId().getName(); - - // Use the name of the response queue as the routing key - - session.queueDeclare(arg::queue=response_queue.str()); - session.exchangeBind(arg::exchange="amq.direct", arg::queue=response_queue.str(), arg::bindingKey=response_queue.str()); - - // Each client sends the name of their own response queue so - // the service knows where to route messages. - - Message request; - request.getDeliveryProperties().setRoutingKey("request"); - request.getMessageProperties().setReplyTo(ReplyTo("amq.direct", response_queue.str())); - - // Create a listener for the response queue and listen for response messages. - std::cout << "Activating response queue listener for: " << response_queue.str() << std::endl; - SubscriptionManager subscriptions(session); - Listener listener(subscriptions); - subscriptions.subscribe(listener, response_queue.str()); - - // Now send some requests ... - - string s[] = { - "Twas brillig, and the slithy toves", - "Did gire and gymble in the wabe.", - "All mimsy were the borogroves,", - "And the mome raths outgrabe." - }; - - - for (int i=0; i<4; i++) { - request.setData(s[i]); - session.messageTransfer(arg::content=request, arg::destination="amq.direct"); - std::cout << "Request: " << s[i] << std::endl; - } - - std::cout << "Waiting for all responses to arrive ..." << std::endl; - subscriptions.run(); - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/request-response/request-response_client.vcproj b/qpid/cpp/examples/old_api/request-response/request-response_client.vcproj deleted file mode 100644 index 5f9eadde36..0000000000 --- a/qpid/cpp/examples/old_api/request-response/request-response_client.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="request_response_client"
- ProjectGUID="{2691FE1E-FECA-1BAD-BD3A-8A467D0C5CCC}"
- RootNamespace="request_response_client"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\request_response_client\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\client.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\request_response_client\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\client.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\request_response_client\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\client.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\request_response_client\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\client.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="client.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/request-response/request-response_server.vcproj b/qpid/cpp/examples/old_api/request-response/request-response_server.vcproj deleted file mode 100644 index 54352b9f46..0000000000 --- a/qpid/cpp/examples/old_api/request-response/request-response_server.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="request_response_server"
- ProjectGUID="{46817425-FECA-1BAD-BD3A-8A467D0C5CCC}"
- RootNamespace="request_response_server"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\request_response_server\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\server.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\request_response_server\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\server.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\request_response_server\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\server.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\request_response_server\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\server.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="server.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/request-response/server.cpp b/qpid/cpp/examples/old_api/request-response/server.cpp deleted file mode 100644 index 65a4717b35..0000000000 --- a/qpid/cpp/examples/old_api/request-response/server.cpp +++ /dev/null @@ -1,161 +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. - * - */ - - -/** - * server.cpp - * - * This program is one of two programs that illustrate the - * request/response pattern. - * - * - * client.cpp - * - * A client application that sends messages to the "amq.direct" - * exchange, using the routing key "request" to route messages to - * the server. - * - * Each instance of the client creates its own private response - * queue, binding it to the "amq.direct" exchange using it's - * session identifier as the routing key, and places its session - * identifier in the "reply-to" property of each message it sends. - * - * - * server.cpp (this program) - * - * A service that accepts messages from a request queue, converts - * their content to upper case, and sends the result to the - * original sender. - * - * This program creates a request queue, binds it to "amq.direct" - * using the routing key "request", then receives messages from - * the request queue. Each incoming message is converted to upper - * case, then sent to the "amq.direct" exchange using the - * request's reply-to property as the routing key for the - * response. - * - * - */ - - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> - -#include <qpid/client/AsyncSession.h> -#include <qpid/client/Message.h> -#include <qpid/client/MessageListener.h> -#include <qpid/client/SubscriptionManager.h> - -#include <cstdlib> -#include <iostream> - -#include <sstream> -#include <string> - -using namespace qpid::client; -using namespace qpid::framing; -using std::stringstream; -using std::string; - -class Listener : public MessageListener{ - private: - SubscriptionManager& subscriptions; - AsyncSession asyncSession; - public: - Listener(SubscriptionManager& subscriptions, Session& session); - virtual void received(Message& message); -}; - -Listener::Listener(SubscriptionManager& subs, Session& session) - : subscriptions(subs), asyncSession(session) -{} - -void Listener::received(Message& request) { - Message response; - - // Get routing key for response from the request's replyTo property - string routingKey; - - if (request.getMessageProperties().hasReplyTo()) { - routingKey = request.getMessageProperties().getReplyTo().getRoutingKey(); - } else { - std::cout << "Error: " << "No routing key for request (" << request.getData() << ")" << std::endl; - return; - } - - std::cout << "Request: " << request.getData() << " (" <<routingKey << ")" << std::endl; - - // Transform message content to upper case - std::string s = request.getData(); - std::transform (s.begin(), s.end(), s.begin(), toupper); - response.setData(s); - - // Send it back to the user - response.getDeliveryProperties().setRoutingKey(routingKey); - - // Asynchronous transfer sends messages as quickly as - // possible without waiting for confirmation. - asyncSession.messageTransfer(arg::content=response, arg::destination="amq.direct"); -} - - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - Connection connection; - - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - - // Create a request queue for clients to use when making - // requests. - string request_queue = "request"; - - // Use the name of the request queue as the routing key - session.queueDeclare(arg::queue=request_queue); - session.exchangeBind(arg::exchange="amq.direct", arg::queue=request_queue, arg::bindingKey=request_queue); - - // Create a listener and subscribe it to the request_queue - std::cout << "Activating request queue listener for: " << request_queue << std::endl; - SubscriptionManager subscriptions(session); - Listener listener(subscriptions, session); - subscriptions.subscribe(listener, request_queue); - // Deliver messages until the subscription is cancelled - // by Listener::received() - - std::cout << "Waiting for requests" << std::endl; - subscriptions.run(); - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/request-response/verify b/qpid/cpp/examples/old_api/request-response/verify deleted file mode 100644 index dee82413e7..0000000000 --- a/qpid/cpp/examples/old_api/request-response/verify +++ /dev/null @@ -1,24 +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. -# - -# See https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/bin/verify -background "Waiting" ./server -clients ./client -kill %% # Must kill the server. -outputs "./client.out | remove_uuid" "server.out | remove_uuid" diff --git a/qpid/cpp/examples/old_api/request-response/verify.in b/qpid/cpp/examples/old_api/request-response/verify.in deleted file mode 100644 index 7925dc5671..0000000000 --- a/qpid/cpp/examples/old_api/request-response/verify.in +++ /dev/null @@ -1,19 +0,0 @@ -==== client.out | remove_uuid -Activating response queue listener for: client -Request: Twas brillig, and the slithy toves -Request: Did gire and gymble in the wabe. -Request: All mimsy were the borogroves, -Request: And the mome raths outgrabe. -Waiting for all responses to arrive ... -Response: TWAS BRILLIG, AND THE SLITHY TOVES -Response: DID GIRE AND GYMBLE IN THE WABE. -Response: ALL MIMSY WERE THE BOROGROVES, -Response: AND THE MOME RATHS OUTGRABE. -Shutting down listener for client -==== server.out | remove_uuid -Activating request queue listener for: request -Waiting for requests -Request: Twas brillig, and the slithy toves (client) -Request: Did gire and gymble in the wabe. (client) -Request: All mimsy were the borogroves, (client) -Request: And the mome raths outgrabe. (client) diff --git a/qpid/cpp/examples/old_api/tradedemo/CMakeLists.txt b/qpid/cpp/examples/old_api/tradedemo/CMakeLists.txt deleted file mode 100644 index e61fc1467d..0000000000 --- a/qpid/cpp/examples/old_api/tradedemo/CMakeLists.txt +++ /dev/null @@ -1,22 +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. -# - -add_example(tradedemo topic_listener) -add_example(tradedemo topic_publisher) -add_example(tradedemo declare_queues) diff --git a/qpid/cpp/examples/old_api/tradedemo/Makefile.am b/qpid/cpp/examples/old_api/tradedemo/Makefile.am deleted file mode 100644 index 9932d87a6b..0000000000 --- a/qpid/cpp/examples/old_api/tradedemo/Makefile.am +++ /dev/null @@ -1,46 +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. -# -examplesdir=$(pkgdatadir)/examples/old_api/tradedemo - -MAKELDFLAGS=$(CLIENTFLAGS) -include $(top_srcdir)/examples/makedist.mk - -noinst_PROGRAMS=topic_listener topic_publisher declare_queues - -topic_listener_SOURCES=topic_listener.cpp -topic_listener_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -topic_publisher_SOURCES=topic_publisher.cpp -topic_publisher_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -declare_queues_SOURCES=declare_queues.cpp -declare_queues_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - - -examples_DATA= \ - topic_listener.cpp \ - topic_publisher.cpp \ - declare_queues.cpp \ - $(MAKEDIST) - -EXTRA_DIST= \ - CMakeLists.txt \ - tradedemo_declare_queues.vcproj \ - tradedemo_topic_listener.vcproj \ - tradedemo_topic_publisher.vcproj diff --git a/qpid/cpp/examples/old_api/tradedemo/declare_queues.cpp b/qpid/cpp/examples/old_api/tradedemo/declare_queues.cpp deleted file mode 100644 index b1f2cc3510..0000000000 --- a/qpid/cpp/examples/old_api/tradedemo/declare_queues.cpp +++ /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. - * - */ - - -/** - * topic_publisher.cpp: - * - * This program is one of three programs designed to be used - * together. These programs implement a publish-subscribe example - * using the "amq.topic" exchange. In the example multiple listeners - * can subscribe to the same queues for TTL messages. - * The TTL messages are all ticker price data. Messages are - * browsed and therefore shared among the multiple listeners. - * Messages timeout using TTL so that they don't stay in the queue - * for too long and fill it up. - * Local exclusive LVQ are also declared for market data. - * - * declare_queues.cpp - * - * Declares several non-exclusive queues bound to the amq:topic exchange - * - * topic_publisher.cpp - * - * Sends messages to the "amq.topic" exchange, using the - * multipart routing keys for ticker price and market data - * Ticker messages are sent using a TTL value. - * - * topic_listener.cpp (this program) - * - * Subscribes to non-exclusive queues in NOT_ACQUIRE mode for - * ticker price data and declares two LVQs for market data. - * - * Multiple listeners can be run at the same time. - * - */ - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> - - -using namespace qpid::client; -using namespace qpid::framing; - - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - Connection connection; - - try { - connection.open(host, port); - Session session = connection.newSession(); - - - //--------- Main body of program -------------------------------------------- - - // Create a queue named "message_queue", and route all messages whose - // routing key is "routing_key" to this newly created queue. - - session.queueDeclare(arg::queue="TICKER.NYSE", arg::exclusive=false); - session.exchangeBind(arg::exchange="amq.topic", arg::queue="TICKER.NYSE", arg::bindingKey="TICKER.NYSE.#"); - std::cout << "Declared queue Ticker NYSE non-exclusive with amq:topic binding TICKER.NYSE.#" << std::endl; - session.queueDeclare(arg::queue="TICKER.NASDAQ", arg::exclusive=false); - session.exchangeBind(arg::exchange="amq.topic", arg::queue="TICKER.NASDAQ", arg::bindingKey="TICKER.NASDAQ.#"); - std::cout << "Declared queue Ticker NASDAQ non-exclusive with amq:topic binding TICKER.NASDAQ.#" << std::endl; - - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; - -} - - - diff --git a/qpid/cpp/examples/old_api/tradedemo/topic_listener.cpp b/qpid/cpp/examples/old_api/tradedemo/topic_listener.cpp deleted file mode 100644 index c488e7fb69..0000000000 --- a/qpid/cpp/examples/old_api/tradedemo/topic_listener.cpp +++ /dev/null @@ -1,183 +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. - * - */ - -/** - * topic_publisher.cpp: - * - * This program is one of three programs designed to be used - * together. These programs implement a publish-subscribe example - * using the "amq.topic" exchange. In the example multiple listeners - * can subscribe to the same queues for TTL messages. - * The TTL messages are all ticker price data. Messages are - * browsed and therefore shared among the multiple listeners. - * Messages timeout using TTL so that they don't stay in the queue - * for too long and fill it up. - * Local exclusive LVQ are also declared for market data. - * - * declare_queues.cpp - * - * Declares several non-exclusive queues bound to the amq:topic exchange - * - * topic_publisher.cpp - * - * Sends messages to the "amq.topic" exchange, using the - * multipart routing keys for ticker price and market data - * Ticker messages are sent using a TTL value. - * - * topic_listener.cpp (this program) - * - * Subscribes to non-exclusive queues in NOT_ACQUIRE mode for - * ticker price data and declares two LVQs for market data. - * - * Multiple listeners can be run at the same time. - * - */ - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/Message.h> -#include <qpid/client/MessageListener.h> -#include <qpid/client/SubscriptionManager.h> -#include "qpid/client/QueueOptions.h" - -#include <cstdlib> -#include <iostream> - -using namespace qpid::client; -using namespace qpid::framing; - - -class Listener : public MessageListener { - private: - Session& session; - SubscriptionManager subscriptions; - public: - Listener(Session& session); - virtual void subscribeTTLQueue(std::string queue); - virtual void subscribeLVQQueue(std::string queue); - virtual void received(Message& message); - virtual void listen(); - ~Listener() { }; -}; - - -/* - * Listener::Listener - * - * Subscribe to the queue, route it to a client destination for the - * listener. (The destination name merely identifies the destination - * in the listener, you can use any name as long as you use the same - * name for the listener). - */ - -Listener::Listener(Session& session) : - session(session), - subscriptions(session) -{ -} - - -void Listener::subscribeTTLQueue(std::string queue) { - - /* - * Subscribe to the queue using the subscription manager. - * The queues were declared elsewhere alog with their bindings. - */ - - std::cout << "Subscribing to queue " << queue << std::endl; - subscriptions.subscribe(*this, queue); - // Will not acquire messages but instead browse them. - subscriptions.setAcquireMode(message::ACQUIRE_MODE_NOT_ACQUIRED); -} - -void Listener::subscribeLVQQueue(std::string queue) { - - /* - * Declare and subscribe to the queue using the subscription manager. - */ - - QueueOptions qo; - qo.setOrdering(LVQ); - std::string binding = queue + ".#"; - queue += session.getId().getName(); - session.queueDeclare(arg::queue=queue, arg::exclusive=true, arg::arguments=qo); - session.exchangeBind(arg::exchange="amq.topic", arg::queue=queue, arg::bindingKey=binding); - std::cout << "Declared queue " << queue << " non-exclusive with amq:topic binding " << binding << std::endl; - std::cout << "Subscribing to queue " << queue << std::endl; - subscriptions.subscribe(*this, queue, SubscriptionSettings(FlowControl::unlimited(), ACCEPT_MODE_NONE)); - -} - -void Listener::received(Message& message) { - // If you want to see the destination you can swap the following lines. - // std::cout << message.getDestination() << "\t" << message.getData() << std::endl; - std::cout << message.getData() << std::endl; - -} - -void Listener::listen() { - // Receive messages - subscriptions.run(); -} - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - - Connection connection; - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - - - // Create a listener for the session - - Listener listener(session); - - // Subscribe to messages on the queues we are interested in - - listener.subscribeTTLQueue("TICKER.NASDAQ"); - listener.subscribeTTLQueue("TICKER.NYSE"); - - listener.subscribeLVQQueue("MRKT.NASDAQ"); - listener.subscribeLVQQueue("MRKT.NYSE"); - - std::cout << "Starting Listener <Ctrl>-C to exit." << std::endl; - std::cout << "Listening for messages ..." << std::endl; - - // Give up control and receive messages - listener.listen(); - - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/tradedemo/topic_publisher.cpp b/qpid/cpp/examples/old_api/tradedemo/topic_publisher.cpp deleted file mode 100644 index e22c185bc7..0000000000 --- a/qpid/cpp/examples/old_api/tradedemo/topic_publisher.cpp +++ /dev/null @@ -1,271 +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. - * - */ - -/** - * topic_publisher.cpp: - * - * This program is one of three programs designed to be used - * together. These programs implement a publish-subscribe example - * using the "amq.topic" exchange. In the example multiple listeners - * can subscribe to the same queues for TTL messages. - * The TTL messages are all ticker price data. Messages are - * browsed and therefore shared among the multiple listeners. - * Messages timeout using TTL so that they don't stay in the queue - * for too long and fill it up. - * Local exclusive LVQ are also declared for market data. - * - * declare_queues.cpp - * - * Declares several non-exclusive queues bound to the amq:topic exchange - * - * topic_publisher.cpp - * - * Sends messages to the "amq.topic" exchange, using the - * multipart routing keys for ticker price and market data - * Ticker messages are sent using a TTL value. - * - * topic_listener.cpp (this program) - * - * Subscribes to non-exclusive queues in NOT_ACQUIRE mode for - * ticker price data and declares two LVQs for market data. - * - * Multiple listeners can be run at the same time. - * - */ - - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/AsyncSession.h> -#include <qpid/client/Message.h> -#include "qpid/client/QueueOptions.h" - - -#include <stdlib.h> -#include <cstdlib> -#include <iostream> -#include <set> -#include <sstream> - -using namespace qpid::client; -using namespace qpid::framing; - -using std::stringstream; -using std::string; - -class Publisher { - private: - Session& session; - int ttl_time; - unsigned long seq; - - unsigned short high_[6]; - unsigned short low_[6]; - unsigned long shares_[6]; - unsigned long volume_[6]; - QueueOptions args; - - public: - Publisher( Session& session, - const int ttl_time, - const unsigned long shares[6]); - - virtual void publish_ticker(const std::string queue, unsigned short& curr_price); - virtual void publish_market(const std::string queue, unsigned short& curr_price, int i); - virtual ~Publisher() { }; -}; - -Publisher::Publisher(Session& session, int ttl_time, const unsigned long shares[6]) : - session(session), - ttl_time(ttl_time), - seq(0) -{ - for (unsigned short i=0; i < 6; i++) { - high_[i] = 0; - low_[i] = 9999; - volume_[i] = 0; - shares_[i] = shares[i]; - } -} - - -void Publisher::publish_ticker(const std::string symbol, unsigned short& curr_price) -{ - Message message; - - // Set the routing key once, we'll use the same routing key for all - // messages. - - std::string routing_key = "TICKER." + symbol; - std::cout << "Setting routing key:" << routing_key << std::endl; - message.getDeliveryProperties().setRoutingKey(routing_key); - - // Randomally generate some price flucuations - bool mvmnt; - unsigned short change = rand() % 3; - if (rand() % 2 == 0) - { - mvmnt = true; - curr_price += change; - } - else - { - mvmnt = false; - curr_price = (curr_price - change)>0 ? (curr_price - change) : 0; - } - - // Was there change in price or no change ? - std::string movement; - if (!change) - { - movement = "] [--]"; - } else - { - movement = (mvmnt ? "] [UP]" : "] [DOWN]"); - } - - stringstream ticker_data; - // Build up the ticker info - ticker_data << "[TICKER] " << "Symbol:" << symbol << " \tPrice[" << curr_price << "] \t[" - << change << movement; - - message.setData(ticker_data.str()); - // Set TTL value so that message will timeout after a period and be purged from queues - message.getDeliveryProperties().setTtl(ttl_time); - // Asynchronous transfer sends messages as quickly as - // possible without waiting for confirmation. - async(session).messageTransfer(arg::content=message, arg::destination="amq.topic"); - -} - -void Publisher::publish_market(const std::string symbol, unsigned short& curr_price, int i) -{ - Message message; - - // Set the routing key - std::string routing_key = "MRKT." + symbol; - std::cout << "Setting routing key:" << routing_key << std::endl; - message.getDeliveryProperties().setRoutingKey(routing_key); - - // Calculate the market data low/hi change, vol, market cap etc. - if (curr_price < low_[i] || low_[i] == 0) - { - low_[i] = curr_price; - } - else if (curr_price > high_[i] || high_[i] == 9999) - { - high_[i] = curr_price; - } - - volume_[i] += rand() % 1000; // increase the daily volume tracker - int mkt_cap = shares_[i] * curr_price; // calculate new market cap based on current price - - stringstream market_data; - // Build up the ticker info - market_data << "[MARKET] " << "Symbol:" << symbol << "\tVolume: " << volume_[i] - << "\tHi:" << high_[i] << "\tLo:" << low_[i] << "\tMktCap:" - << mkt_cap <<"M\tSEQ[" << seq << "]"; - - message.setData(market_data.str()); - - std::string key; - args.getLVQKey(key); - message.getHeaders().setString(key, symbol); - - // Asynchronous transfer sends messages as quickly as - // possible without waiting for confirmation. - async(session).messageTransfer(arg::content=message, arg::destination="amq.topic"); - seq++; // This sequence number is really just to demonstrate the LVQ nature of the queue. - // You will notice some messages don't show because they are overwritten by last value. - -} - - -int main(int argc, char** argv) { - unsigned int pub_cycles = argc>1 ? atoi(argv[1]) : 100; - unsigned int ttl_time = argc>2 ? atoi(argv[2]) : 4000; - const char* host = argc>3 ? argv[3] : "127.0.0.1"; - int port = argc>4 ? atoi(argv[4]) : 5672; - std::cout <<"Usage: topic_publisher <pub cycles> <TTL-timeout> <host name/IP> <port>" << std::endl; - std::cout <<"\tparameters are optional but must be in this order when used." << std::endl; - - // Set up the stocks symbols and their prices - std::string symbol[6]; - unsigned short price[6]; - symbol[0] = "NYSE.RHT"; // Red Hat - symbol[1] = "NYSE.IBM"; // IBM Corp. - symbol[2] = "NASDAQ.MSFT"; // Microsoft - symbol[3] = "NASDAQ.CSCO"; // Cisco Systems - symbol[4] = "NASDAQ.YHOO"; // Yahoo - symbol[5] = "NASDAQ.GOOG"; // Google - - // Rough starting values. - price[0] = rand() % 30 +1; - price[1] = rand() % 120 +1; - price[2] = rand() % 20 +1; - price[3] = rand() % 75 +1; - price[4] = rand() % 10 +1; - price[5] = rand() % 323 +1; - - // Shares oustanding in millions. - unsigned long shares[6] = {190,1340,8890, 5860, 1390, 314}; - - - Connection connection; - try { - connection.open(host, port); - Session session = connection.newSession(); - - Publisher theFeed(session,ttl_time, shares); - - //--------- Main body of program -------------------------------------------- - - // Print the opening values for each symbol - std::cout << std::endl << "Opening values:" << std::endl; - for (int i=0; i < 6; i++) - { - std::cout << symbol[i] << ":" << price[i] << std::endl; - } - - // For the duration of the publishing cycles publish - // ticker and market data for each symbol - for (unsigned int j=0; j<pub_cycles; j++) - { - for (unsigned int i=0; i < 6; i++) - { - // for each symbol publish the ticker and the market data - theFeed.publish_ticker(symbol[i], price[i]); - theFeed.publish_market(symbol[i], price[i], i); - } - } - - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/tradedemo/tradedemo_declare_queues.vcproj b/qpid/cpp/examples/old_api/tradedemo/tradedemo_declare_queues.vcproj deleted file mode 100644 index 34b5cb3b2b..0000000000 --- a/qpid/cpp/examples/old_api/tradedemo/tradedemo_declare_queues.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="tradedemo_declare_queues"
- ProjectGUID="{9057502D-FECA-1BAD-23CE-CD4095BD3C8B}"
- RootNamespace="tradedemo_declare_queues"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\tradedemo_declare_queues\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\tradedemo_declare_queues\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\tradedemo_declare_queues\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\tradedemo_declare_queues\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\declare_queues.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="declare_queues.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/tradedemo/tradedemo_topic_listener.vcproj b/qpid/cpp/examples/old_api/tradedemo/tradedemo_topic_listener.vcproj deleted file mode 100644 index 965be2e88b..0000000000 --- a/qpid/cpp/examples/old_api/tradedemo/tradedemo_topic_listener.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="tradedemo_topic_listener"
- ProjectGUID="{5A25F2CD-FECA-1BAD-23CE-CD4095BD3C8B}"
- RootNamespace="tradedemo_topic_listener"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\tradedemo_topic_listener\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\topic_listener.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\tradedemo_topic_listener\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\topic_listener.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\tradedemo_topic_listener\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\topic_listener.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\tradedemo_topic_listener\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\topic_listener.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="topic_listener.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/tradedemo/tradedemo_topic_publisher.vcproj b/qpid/cpp/examples/old_api/tradedemo/tradedemo_topic_publisher.vcproj deleted file mode 100644 index 77fd511e15..0000000000 --- a/qpid/cpp/examples/old_api/tradedemo/tradedemo_topic_publisher.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="tradedemo_topic_publisher"
- ProjectGUID="{E614CC2C-FECA-1BAD-23CE-CD4095BD3C8B}"
- RootNamespace="tradedemo_topic_publisher"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\tradedemo_topic_publisher\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\topic_publisher.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\tradedemo_topic_publisher\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\topic_publisher.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\tradedemo_topic_publisher\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib"
- OutputFile="$(OutDir)\topic_publisher.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\tradedemo_topic_publisher\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib"
- OutputFile="$(OutDir)\topic_publisher.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="topic_publisher.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/old_api/verify b/qpid/cpp/examples/old_api/verify deleted file mode 100755 index 1ee21f6b03..0000000000 --- a/qpid/cpp/examples/old_api/verify +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash - -# -# 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. -# - -export LC_ALL=C - -# Driver script to verify installed examples (also used for build tests.) -# -# Usage: verify example_dir [ example_dir ...] -# Where each example_dir must contain a verify sub-script to include. -# -# If $QPIDD is set, run a private QPIDD and use it. -# If $QPID_HOST or $QPID_PORT are set, use them to connect. -# - -QPID_NO_MODULE_DIR=1 -QPID_DATA_DIR= - -# Use temporary directory if $HOME does not exist -if [ ! -e "$HOME" ]; then - QPID_DATA_DIR=/tmp/qpid - QPID_PID_DIR=/tmp/qpid -fi - -export QPID_DATA_DIR QPID_NO_MODULE_DIR QPID_PID_DIR - -cleanup() { - test -n "$QPIDD" && $QPIDD -q # Private broker - kill %% > /dev/null 2>&1 # Leftover background jobs -} - -trap cleanup EXIT - -ARGS="${QPID_HOST:-localhost} $QPID_PORT" - -outfile() { - file=$1 - while [ -f $file.out ]; do file="${file}X"; done - echo $file.out - } - -fail() { test -n "$*" && echo $* 1>&2 ; FAIL=1; return 1; } - -client() { "$@" $ARGS > `outfile $*` || fail; } - -clients() { for cmd in "$@"; do client $cmd; done; } - -waitfor() { until grep -a -l "$2" $1 >/dev/null 2>&1 ; do sleep 1 ; done ; } - -background() { - pattern=$1; shift - out=`outfile $*` - eval "$* $ARGS > $out &" || { fail; return 1; } - waitfor $out "$pattern" -} - -name() { - for x in $*; do name="$name `basename $x`"; done - echo $name; -} - -outputs() { - wait 2> /dev/null # Wait for all backgroud processes to complete - rm -f $script.out - for f in "$@"; do - { echo "==== `name $f`"; eval "cat $f"; } >> $script.out || fail - done -} - -normalize() { echo `cd $1 && pwd`; } - -verify() { - FAIL= - arg=$1 - srcdir=$(normalize $2) - builddir=$(normalize $3) - if [ -d $arg ]; then dir=$(normalize $arg); script=verify; - else dir=$(normalize `dirname $arg`); script=`basename $arg`; fi - - # if the example is in the "cpp" area, make sure we run from the build directory, not the source dir. - rundir=${dir/$srcdir\/cpp/$builddir/} - cd $rundir || return 1 - rm -f *.out - { source $dir/$script && diff -ac $script.out $dir/$script.in ; } || fail - test -z "$FAIL" && rm -f *.out - return $FAIL -} - -HEX="[a-fA-F0-9]" -remove_uuid() { - sed "s/$HEX\{8\}-$HEX\{4\}-$HEX\{4\}-$HEX\{4\}-$HEX\{12\}//g" $* -} -remove_uuid64() { - sed 's/[-A-Za-z0-9_]\{22\}==//g' $* -} - -# Start private broker if QPIDD is set. -if [ -n "$QPIDD" ] ; then - export QPID_PORT=`$QPIDD -dp0` || { echo "Cannot start $QPIDD" ; exit 1; } - trap "$QPIDD -q" EXIT -fi - -topsrcdir=$1 -topbuilddir=$2 -shift 2 - -for example in "$@"; do - echo "== $example" - if ( verify $example $topsrcdir $topbuilddir; ) then echo "PASS"; else echo "FAIL"; RET=1; fi - done -exit $RET diff --git a/qpid/cpp/examples/old_api/verify_all b/qpid/cpp/examples/old_api/verify_all deleted file mode 100755 index e71479d6be..0000000000 --- a/qpid/cpp/examples/old_api/verify_all +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# -# 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. -# - -# Verify all examples - -verify=`dirname $0`/verify -topsrcdir=$1 -topbuilddir=$2 -qpidd=$topbuilddir/src/qpidd -broker_args=$3 -exclude_regexp=$4 - -# Use temporary directory if $HOME does not exist -if ! test -e "$HOME"; then - export QPID_DATA_DIR=/tmp/qpid - export QPID_PID_DIR=/tmp/qpid -fi - -trap "$qpidd -q" exit -QPID_PORT=`$qpidd -dp0 $broker_args` || { echo "Can't run qpidd" ; exit 1; } -export QPID_PORT - -find="find $topsrcdir/cpp/examples/old_api" -find="$find -mindepth 2 -name verify" -all_examples=`$find` - -if test -z "$exclude_regexp"; then - run_examples=$all_examples -else - for f in $all_examples; do - { echo $f | grep $exclude_regexp > /dev/null ; } || run_examples="$run_examples $f" - done -fi -$verify $topsrcdir $topbuilddir $run_examples diff --git a/qpid/cpp/examples/old_api/xml-exchange/CMakeLists.txt b/qpid/cpp/examples/old_api/xml-exchange/CMakeLists.txt deleted file mode 100644 index 3fea47a208..0000000000 --- a/qpid/cpp/examples/old_api/xml-exchange/CMakeLists.txt +++ /dev/null @@ -1,24 +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. -# - -if (BUILD_XML) -add_example(xml-exchange declare_queues) -add_example(xml-exchange xml_producer) -add_example(xml-exchange listener) -endif (BUILD_XML) diff --git a/qpid/cpp/examples/old_api/xml-exchange/Makefile.am b/qpid/cpp/examples/old_api/xml-exchange/Makefile.am deleted file mode 100644 index d4bc6ba233..0000000000 --- a/qpid/cpp/examples/old_api/xml-exchange/Makefile.am +++ /dev/null @@ -1,49 +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. -# -examplesdir=$(pkgdatadir)/examples/old_api/xml-exchange - -MAKELDFLAGS=$(CLIENTFLAGS) -include $(top_srcdir)/examples/makedist.mk - -noinst_PROGRAMS=declare_queues xml_producer listener - -declare_queues_SOURCES=declare_queues.cpp -declare_queues_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -xml_producer_SOURCES=xml_producer.cpp -xml_producer_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -listener_SOURCES=listener.cpp -listener_LDADD=$(CLIENT_LIB) $(COMMON_LIB) - -EXTRA_DIST= \ - README.txt \ - CMakeLists.txt - -examples_DATA= \ - $(EXTRA_DIST) \ - declare_queues.cpp \ - listener.cpp \ - xml_producer.cpp \ - $(MAKEDIST) - - - - - diff --git a/qpid/cpp/examples/old_api/xml-exchange/README.txt b/qpid/cpp/examples/old_api/xml-exchange/README.txt deleted file mode 100644 index 85caebe352..0000000000 --- a/qpid/cpp/examples/old_api/xml-exchange/README.txt +++ /dev/null @@ -1,53 +0,0 @@ -This example shows how to program a simple application -using the XML Exchange. - -[Note: The XML Exchange is not a standard AMQP exchange type. To run -this example you need to have a broker that has support for the xml -exchange. If you are compiling the broker from source please refer to -the INSTALL notes from qpid.] - -To run the example, execute the programs in the -following order: - -1 ./declare_queues -2 ./listener -3 ./message_producer (in a separate window) - -The XML Exchange must be explicitly declared. Bindings -are established using queries in XQuery. These queries -can reference message content, message application -properties (which are declared as external variables -in the XQuery), or both. - -Once this is done, message producers publish to the -exchange using the exchange name and a routing key, -just as for other exchange types. Message consumers -read from the queues to which messages are routed. -If a message does not have XML content, or is -missing message application properties needed by -the query, the query is not routed. - -Queries can use message application headers to -provide functionality similar to JMS selectors. -If a query does not use the content of a message, -the message content is not parsed, and need not -be XML. - -The XQuery processor, XQilla, does path-based -document projection, so once the portion of -a document needed to evaluate a query has -been read, it stops parsing the document. -Suppose a long document has a header section. -You can indicate in the query that only -one header section needs to be queried, -and there is no need to parse the entire -document to see if there are further header -sections, using a path like this: - -./message/header[1]/date - -If you used a path like this, all children -of the message element would be read to -see if there are further headers: - -./message/header/date diff --git a/qpid/cpp/examples/old_api/xml-exchange/declare_queues.cpp b/qpid/cpp/examples/old_api/xml-exchange/declare_queues.cpp deleted file mode 100644 index ad08642019..0000000000 --- a/qpid/cpp/examples/old_api/xml-exchange/declare_queues.cpp +++ /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. - * - */ - - -/** - * - * declare_queues.cpp - * - * This is one of three programs used to implement XML-based content - * routing in C++. - * - * declare_queues.cpp (this program) - * - * Creates a queue named "message_qaueue" on the broker, - * declares an XML Exchange, subscribes the queue to the XML - * Exchange using an XQuery in the binding, then exits. - * - * xml_producer.cpp - * - * Publishes messages to the XML Exchange. - * - * listener.cpp - * - * Reads messages from the "message_queue" queue. - */ - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> - -#include <cstdlib> -#include <iostream> - -using namespace qpid::client; -using namespace qpid::framing; - -using std::string; - - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - Connection connection; - - try { - connection.open(host, port); - Session session = connection.newSession(); - - - //--------- Main body of program -------------------------------------------- - - // Set up queues, bind them with queries. Note that the XML exchange - // is not in the AMQP specification, so it is called "xml", not "amq.xml". - // Note that the XML exchange is not predeclared in Qpid, it must - // be declared by the application. - - session.queueDeclare(arg::queue="message_queue"); - session.exchangeDeclare(arg::exchange="xml", arg::type="xml"); - - // Application message properties are mapped to external variables - // in the XQuery. An XML Exchange can query message properties much - // like JMS, query the XML content of the message, or both. - - FieldTable binding; - binding.setString("xquery", "declare variable $control external;" - "./message/id mod 2 = 1 or $control = 'end'"); - session.exchangeBind(arg::exchange="xml", arg::queue="message_queue", arg::bindingKey="content_feed", arg::arguments=binding); - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; - -} - - - diff --git a/qpid/cpp/examples/old_api/xml-exchange/listener.cpp b/qpid/cpp/examples/old_api/xml-exchange/listener.cpp deleted file mode 100644 index 11bcb9f669..0000000000 --- a/qpid/cpp/examples/old_api/xml-exchange/listener.cpp +++ /dev/null @@ -1,107 +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. - * - */ - - -/** - * - * listener.cpp - * - * This is one of three programs used to implement XML-based content - * routing in C++. - * - * declare_queues.cpp - * - * Creates a queue named "message_qaueue" on the broker, - * declares an XML Exchange, subscribes the queue to the XML - * Exchange using an XQuery in the binding, then exits. - * - * xml_producer.cpp - * - * Publishes messages to the XML Exchange. - * - * listener.cpp (this program) - * - * Reads messages from the "message_queue" queue. - */ - - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/Message.h> -#include <qpid/client/SubscriptionManager.h> - -#include <cstdlib> -#include <iostream> - -using namespace qpid::client; -using namespace qpid::framing; - - -class Listener : public MessageListener{ - private: - SubscriptionManager& subscriptions; - public: - Listener(SubscriptionManager& subscriptions); - virtual void received(Message& message); -}; - -Listener::Listener(SubscriptionManager& subs) : subscriptions(subs) -{} - -void Listener::received(Message& message) { - std::cout << "Message: " << message.getData() << std::endl; - if (message.getHeaders().getAsString("control") == "end") { - std::cout << "Shutting down listener for " << message.getDestination() - << std::endl; - subscriptions.cancel(message.getDestination()); - } -} - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - - Connection connection; - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - SubscriptionManager subscriptions(session); - // Create a listener and subscribe it to the queue named "message_queue" - Listener listener(subscriptions); - subscriptions.subscribe(listener, "message_queue"); - // Receive messages until the subscription is cancelled - // by Listener::received() - subscriptions.run(); - - //--------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/old_api/xml-exchange/xml_producer.cpp b/qpid/cpp/examples/old_api/xml-exchange/xml_producer.cpp deleted file mode 100644 index af1a7e60c7..0000000000 --- a/qpid/cpp/examples/old_api/xml-exchange/xml_producer.cpp +++ /dev/null @@ -1,113 +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. - * - */ - - -/** - * - * xml_producer.cpp - * - * This is one of three programs used to implement XML-based content - * routing in C++. - * - * declare_queues.cpp - * - * Creates a queue named "message_qaueue" on the broker, - * declares an XML Exchange, subscribes the queue to the XML - * Exchange using an XQuery in the binding, then exits. - * - * xml_producer.cpp (this program) - * - * Publishes messages to the XML Exchange. - * - * listener.cpp - * - * Reads messages from the "message_queue" queue. - */ - - -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/AsyncSession.h> -#include <qpid/client/Message.h> - - -#include <cstdlib> -#include <iostream> - -#include <sstream> - -using namespace qpid::client; -using namespace qpid::framing; - -using std::stringstream; -using std::string; - -int main(int argc, char** argv) { - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - Connection connection; - Message message; - try { - connection.open(host, port); - Session session = connection.newSession(); - - //--------- Main body of program -------------------------------------------- - - // Publish some XML messages. Use the control property to - // indicate when we are finished. - // - // In the XML exchange, the routing key and the name of - // the query match. - - message.getDeliveryProperties().setRoutingKey("content_feed"); - message.getHeaders().setString("control","continue"); - - // Now send some messages ... - - for (int i=0; i<10; i++) { - stringstream message_data; - message_data << "<message><id>" << i << "</id></message>"; - - std::cout << "Message data: " << message_data.str() << std::endl; - - message.setData(message_data.str()); - // Asynchronous transfer sends messages as quickly as - // possible without waiting for confirmation. - async(session).messageTransfer(arg::content=message, arg::destination="xml"); - } - - // And send a final message to indicate termination. - - message.getHeaders().setString("control","end"); - message.setData("<end>That's all, folks!</end>"); - session.messageTransfer(arg::content=message, arg::destination="xml"); - - //----------------------------------------------------------------------------- - - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << error.what() << std::endl; - } - return 1; -} - - diff --git a/qpid/cpp/examples/qmf-agent/Makefile b/qpid/cpp/examples/qmf-agent/Makefile deleted file mode 100644 index 5b1afc4b01..0000000000 --- a/qpid/cpp/examples/qmf-agent/Makefile +++ /dev/null @@ -1,85 +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. -# - -SRC_DIR = . -QPID_DIR = ../../.. -SCHEMA_FILE = $(SRC_DIR)/schema.xml -GEN_DIR = $(SRC_DIR)/gen -OUT_FILE = $(SRC_DIR)/qmf-agent - -CC = gcc -LIB_DIR = $(QPID_DIR)/cpp/src/.libs -CC_INCLUDES = -I$(SRC_DIR) -I$(QPID_DIR)/cpp/include -I$(GEN_DIR) -CC_FLAGS = -g -O3 -LD_FLAGS = -lqmf -L$(LIB_DIR) -SPEC_DIR = $(QPID_DIR)/specs -MGEN_DIR = $(QPID_DIR)/cpp/managementgen -MGEN = $(MGEN_DIR)/qmf-gen - -vpath %.cpp $(SRC_DIR):$(GEN_DIR) -vpath %.d $(OBJ_DIR) -vpath %.o $(OBJ_DIR) - -cpps = $(wildcard $(SRC_DIR)/*.cpp) -cpps += $(wildcard $(GEN_DIR)/qmf/org/apache/qpid/agent/example/*.cpp) -deps = $(addsuffix .d, $(basename $(cpps))) -objects = $(addsuffix .o, $(basename $(cpps))) - -.PHONY: all clean gen - -#========================================================== -# Pass 0: generate source files from schema -ifeq ($(MAKELEVEL), 0) - -all: gen - @$(MAKE) - -gen: - $(MGEN) -o $(GEN_DIR)/qmf $(SCHEMA_FILE) - -clean: - rm -rf $(GEN_DIR) $(OUT_FILE) *.d *.o - - -#========================================================== -# Pass 1: generate dependencies -else ifeq ($(MAKELEVEL), 1) - -all: $(deps) - @$(MAKE) - -%.d : %.cpp - $(CC) -M $(CC_FLAGS) $(CC_INCLUDES) $< > $@ - - -#========================================================== -# Pass 2: build project -else ifeq ($(MAKELEVEL), 2) - -$(OUT_FILE) : $(objects) - $(CC) -o $(OUT_FILE) $(CC_FLAGS) $(LD_FLAGS) $(objects) - -include $(deps) - -%.o : %.cpp - $(CC) -c $(CC_FLAGS) $(CC_INCLUDES) -o $@ $< - -endif - - diff --git a/qpid/cpp/examples/qmf-console/CMakeLists.txt b/qpid/cpp/examples/qmf-console/CMakeLists.txt deleted file mode 100644 index 3b74338221..0000000000 --- a/qpid/cpp/examples/qmf-console/CMakeLists.txt +++ /dev/null @@ -1,23 +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. -# - -add_installed_example(qmf-console console qmfconsole) -add_installed_example(qmf-console printevents qmfconsole) -add_installed_example(qmf-console ping qmfconsole) -add_installed_example(qmf-console queuestats qmfconsole) diff --git a/qpid/cpp/examples/qmf-console/Makefile.am b/qpid/cpp/examples/qmf-console/Makefile.am deleted file mode 100644 index 060147e9a4..0000000000 --- a/qpid/cpp/examples/qmf-console/Makefile.am +++ /dev/null @@ -1,56 +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. -# - -examplesdir=$(pkgdatadir)/examples/qmf-console - -MAKELDFLAGS=$(CONSOLEFLAGS) -include $(top_srcdir)/examples/makedist.mk - -noinst_PROGRAMS=console printevents ping queuestats cluster-qmon - -console_SOURCES=console.cpp -console_LDADD=$(CONSOLE_LIB) -lqpidcommon -lqpidclient - -printevents_SOURCES=printevents.cpp -printevents_LDADD=$(CONSOLE_LIB) -lqpidcommon -lqpidclient - -ping_SOURCES=ping.cpp -ping_LDADD=$(CONSOLE_LIB) -lqpidcommon -lqpidclient - -queuestats_SOURCES=queuestats.cpp -queuestats_LDADD=$(CONSOLE_LIB) -lqpidcommon -lqpidclient - -cluster_qmon_SOURCES=cluster-qmon.cpp -cluster_qmon_LDADD=$(CONSOLE_LIB) -lqpidcommon -lqpidclient - -examples_DATA= \ - console.cpp \ - printevents.cpp \ - ping.cpp \ - queuestats.cpp \ - cluster-qmon.cpp \ - $(MAKEDIST) - -EXTRA_DIST= \ - README.txt \ - CMakeLists.txt \ - qmf-console_console.vcproj \ - qmf-console_ping.vcproj \ - qmf-console_printevents.vcproj \ - qmf-console_queuestats.vcproj diff --git a/qpid/cpp/examples/qmf-console/README.txt b/qpid/cpp/examples/qmf-console/README.txt deleted file mode 100644 index 2ee784cbc2..0000000000 --- a/qpid/cpp/examples/qmf-console/README.txt +++ /dev/null @@ -1,39 +0,0 @@ -The QMF console library provides an interface infrastructure for -broker management. This directory contains example applications that -use the QMF console library to interact with the broker. - -cluster-qmon.cpp: -This example maintains connections to a number of brokers (assumed to -be running on localhost and at ports listed in the command line -arguments). The program then periodically polls queue information -from a single operational broker. This is a useful illustration of -how one might monitor statistics on a cluster of brokers. - -console.cpp: -A simple application that attaches to a broker (assumed to be -available as "localhost:5672"), and extracts: - * Management Schema (packages and classes) - * Management state for all active Exchanges - * Management state for all active Queues -It then invokes the broker's "echo" test method before detaching from -the broker. - -ping.cpp: -Connects to a broker (assumed to be available as "localhost:5672"), -and invokes the "echo" test method five times. - -printevents.cpp: -An example of a passive broker monitor. This application connects to -a broker (assumed to be available as "localhost:5672"), and registers -a callback listener. The listener's callbacks are invoked when -various management events are signalled by the broker. - -queuestats.cpp: -An example of a passive broker monitor. This application connects to -a broker (assumed to be available as "localhost:5672"), and registers -a callback listener for status updates only for Queue objects. The -listener's callback is invoked whenever the status of a Queue -changes. - - - diff --git a/qpid/cpp/examples/qmf-console/cluster-qmon.cpp b/qpid/cpp/examples/qmf-console/cluster-qmon.cpp deleted file mode 100644 index fe92f8a8ae..0000000000 --- a/qpid/cpp/examples/qmf-console/cluster-qmon.cpp +++ /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. - * - */ - -#include "qpid/console/ConsoleListener.h" -#include "qpid/console/SessionManager.h" -#include "qpid/sys/Time.h" -#include "qpid/sys/Mutex.h" -#include <signal.h> -#include <map> - -using namespace std; -using namespace qpid::console; -using qpid::sys::Mutex; - -// -// This example maintains connections to a number of brokers (assumed -// to be running on localhost and at ports listed in the command line -// arguments). -// -// The program then periodically polls queue information from a -// single operational broker. This is a useful illustration of how -// one might monitor statistics on a cluster of brokers. -// - -//============================================================== -// Main program -//============================================================== - -// -// The Main class extends ConsoleListener so it can receive broker connected/disconnected -// notifications. -// -class Main : public ConsoleListener { - bool stopping; // Used to tell the program to exit - Mutex lock; // Mutex to protect the broker-map - map<Broker*, bool> brokerMap; // Map of broker-pointers to boolean "operational" status - -public: - Main() : stopping(false) {} - - /** Invoked when a connection is established to a broker - */ - void brokerConnected(const Broker& broker) - { - Mutex::ScopedLock l(lock); - brokerMap[const_cast<Broker*>(&broker)] = true; - } - - /** Invoked when the connection to a broker is lost - */ - void brokerDisconnected(const Broker& broker) - { - Mutex::ScopedLock l(lock); - brokerMap[const_cast<Broker*>(&broker)] = false; - } - - int run(int argc, char** argv) - { - // - // Tune the settings for this application: We will operate synchronously only, we don't - // wish to use the bandwidth needed to aysnchronously receive objects or events. - // - SessionManager::Settings sessionSettings; - sessionSettings.rcvObjects = false; - sessionSettings.rcvEvents = false; - sessionSettings.rcvHeartbeats = false; - - SessionManager sm(this, sessionSettings); - - // - // Connect to the brokers. - // - for (int idx = 1; idx < argc; idx++) { - qpid::client::ConnectionSettings connSettings; - connSettings.host = "localhost"; - connSettings.port = atoi(argv[idx]); - Broker* broker = sm.addBroker(connSettings); - - Mutex::ScopedLock l(lock); - brokerMap[broker] = false; // initially assume broker is disconnected - } - - // - // Periodically poll the first connected broker. - // - while (!stopping) { - // - // Find an operational broker - // - Broker* operationalBroker = 0; - { - Mutex::ScopedLock l(lock); - for (map<Broker*, bool>::iterator iter = brokerMap.begin(); - iter != brokerMap.end(); iter++) { - if (iter->second) { - operationalBroker = iter->first; - break; - } - } - } - - if (operationalBroker != 0) { - Object::Vector list; - sm.getObjects(list, "queue", operationalBroker); - for (Object::Vector::iterator i = list.begin(); i != list.end(); i++) { - cout << "queue: " << i->attrString("name"); - cout << " bindingCount=" << i->attrUint64("bindingCount") << endl; - } - } else { - cout << "No operational brokers" << endl; - } - - qpid::sys::sleep(10); - if (stopping) - break; - } - - { - // - // The following code structure uses the mutex to protect the broker map while - // ensuring that sm.delBroker is called without the mutex held (which leads to - // a deadlock). - // - Mutex::ScopedLock l(lock); - map<Broker*, bool>::iterator iter = brokerMap.begin(); - while (iter != brokerMap.end()) { - Broker* broker = iter->first; - brokerMap.erase(iter); - { - Mutex::ScopedUnlock ul(lock); - sm.delBroker(broker); - } - iter = brokerMap.begin(); - } - } - - return 0; - } - - void stop() { - stopping = true; - } -}; - -Main main_program; - -void signal_handler(int) -{ - main_program.stop(); -} - -int main(int argc, char** argv) -{ - signal(SIGINT, signal_handler); - try { - return main_program.run(argc, argv); - } catch(std::exception& e) { - cout << "Top Level Exception: " << e.what() << endl; - } -} - diff --git a/qpid/cpp/examples/qmf-console/console.cpp b/qpid/cpp/examples/qmf-console/console.cpp deleted file mode 100644 index b5375b673f..0000000000 --- a/qpid/cpp/examples/qmf-console/console.cpp +++ /dev/null @@ -1,151 +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. - * - */ - -#include "qpid/console/ConsoleListener.h" -#include "qpid/console/SessionManager.h" - -using namespace std; -using namespace qpid::console; - -class Listener : public ConsoleListener { -public: - ~Listener() {} - - void brokerConnected(const Broker& broker) { - cout << "brokerConnected: " << broker << endl; - } - - void brokerDisconnected(const Broker& broker) { - cout << "brokerDisconnected: " << broker << endl; - } - - void newPackage(const std::string& name) { - cout << "newPackage: " << name << endl; - } - - void newClass(const ClassKey& classKey) { - cout << "newClass: key=" << classKey << endl; - } - - void newAgent(const Agent& agent) { - cout << "newAgent: " << agent << endl; - } - - void delAgent(const Agent& agent) { - cout << "delAgent: " << agent << endl; - } - - void objectProps(Broker& broker, Object& object) { - cout << "objectProps: broker=" << broker << " object=" << object << endl; - } - - void objectStats(Broker& broker, Object& object) { - cout << "objectStats: broker=" << broker << " object=" << object << endl; - } - - void event(Event& event) { - cout << "event: " << event << endl; - } -}; - - -//============================================================== -// Main program -//============================================================== -int main_int(int /*argc*/, char** /*argv*/) -{ - //Listener listener; - qpid::client::ConnectionSettings settings; - - cout << "Creating SessionManager" << endl; - SessionManager sm; - cout << "Adding broker" << endl; - Broker* broker; - - broker = sm.addBroker(settings); - broker->waitForStable(); - - cout << "Package List:" << endl; - vector<string> packages; - sm.getPackages(packages); - for (vector<string>::iterator iter = packages.begin(); iter != packages.end(); iter++) { - cout << " " << *iter << endl; - SessionManager::KeyVector classKeys; - sm.getClasses(classKeys, *iter); - for (SessionManager::KeyVector::iterator cIter = classKeys.begin(); - cIter != classKeys.end(); cIter++) - cout << " " << *cIter << endl; - } - - Object::Vector list; - cout << "getting exchanges..." << endl; - sm.getObjects(list, "exchange"); - cout << " returned " << list.size() << " elements" << endl; - - for (Object::Vector::iterator i = list.begin(); i != list.end(); i++) { - cout << "exchange: " << *i << endl; - } - - list.clear(); - cout << "getting queues..." << endl; - sm.getObjects(list, "queue"); - cout << " returned " << list.size() << " elements" << endl; - - for (Object::Vector::iterator i = list.begin(); i != list.end(); i++) { - cout << "queue: " << *i << endl; - cout << " bindingCount=" << i->attrUint("bindingCount") << endl; - cout << " arguments=" << i->attrMap("arguments") << endl; - } - - list.clear(); - sm.getObjects(list, "broker"); - if (list.size() == 1) { - Object& broker = *list.begin(); - - cout << "Broker: " << broker << endl; - - Object::AttributeMap args; - MethodResponse result; - args.addUint("sequence", 1); - args.addString("body", "Testing..."); - - cout << "Call echo method..." << endl; - broker.invokeMethod("echo", args, result); - cout << "Result: code=" << result.code << " text=" << result.text << endl; - for (Object::AttributeMap::iterator aIter = result.arguments.begin(); - aIter != result.arguments.end(); aIter++) { - cout << " Output Arg: " << aIter->first << " => " << aIter->second->str() << endl; - } - } - - sm.delBroker(broker); - return 0; -} - -int main(int argc, char** argv) -{ - try { - return main_int(argc, argv); - } catch(std::exception& e) { - cout << "Top Level Exception: " << e.what() << endl; - } -} - diff --git a/qpid/cpp/examples/qmf-console/ping.cpp b/qpid/cpp/examples/qmf-console/ping.cpp deleted file mode 100644 index e6d6d138d5..0000000000 --- a/qpid/cpp/examples/qmf-console/ping.cpp +++ /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. - * - */ - -#include "qpid/console/SessionManager.h" -#include "qpid/sys/Time.h" - -using namespace std; -using namespace qpid::console; - -//============================================================== -// Main program -//============================================================== -int main_int(int /*argc*/, char** /*argv*/) -{ - // - // Declare connection settings for the messaging broker. - // - qpid::client::ConnectionSettings connSettings; - - // - // Declare the (optional) session manager settings. Override the default timeout - // for methods calls to be 2 seconds. - // - SessionManager::Settings smSettings; - smSettings.methodTimeout = 2; - smSettings.getTimeout = 2; - - // - // Declare the console session manager. With a null listener argument, it defaults to - // synchronous-only access mode. - // - SessionManager sm(0, smSettings); - - // - // Add a broker connection to the session manager. - // - Broker* broker = sm.addBroker(connSettings); - broker->waitForStable(); - - uint32_t count = 5; // The number of echo requests we will send to the broker. - Object::Vector list; // A container for holding objects retrieved from the broker. - - for (uint32_t iter = 0; iter < count; iter++) { - cout << "Ping Broker: " << broker->getUrl() << "... "; - cout.flush(); - - // - // Query for a list of 'broker' objects from the Management Database - // - sm.getObjects(list, "broker"); - - // - // We expect one object (since we are connected to only one broker) - // - if (list.size() == 1) { - Object& brokerObject = *(list.begin()); - - // - // Declare a container for arguments to be sent with the "echo" method - // that we will invoke on the remote "broker" object. - // - Object::AttributeMap args; - - // - // Declare a container for the result of the method invocation. - // - MethodResponse result; - - // - // Set the values of the input arguments. - // - args.addUint("sequence", iter); - args.addString("body", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - - // - // Invoke the method. This is a synchronous operation that will block until - // the method completes and returns a result. - // - brokerObject.invokeMethod("echo", args, result); - - // - // result.code is the return code (0 => Success) - // result.text is the return text - // result.arguments is a container (of type Object::AttributeMap) that holds - // the output arguments (if any) from the method. - // - cout << "Result: code=" << result.code << " text=" << result.text; - if (result.code == 0) - cout << " seq=" << result.arguments["sequence"]->asUint(); - cout << endl; - - if (result.code == 0 && iter < count - 1) - qpid::sys::sleep(1); - } else { - cout << "Disconnected..." << endl; - qpid::sys::sleep(1); - } - } - - // - // Disconnect the broker from the session manager. - // - sm.delBroker(broker); - return 0; -} - -int main(int argc, char** argv) -{ - try { - return main_int(argc, argv); - } catch(std::exception& e) { - cout << "Top Level Exception: " << e.what() << endl; - } -} - diff --git a/qpid/cpp/examples/qmf-console/printevents.cpp b/qpid/cpp/examples/qmf-console/printevents.cpp deleted file mode 100644 index ac3e449a2c..0000000000 --- a/qpid/cpp/examples/qmf-console/printevents.cpp +++ /dev/null @@ -1,123 +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. - * - */ - -#include "qpid/console/ConsoleListener.h" -#include "qpid/console/SessionManager.h" -#include "qpid/sys/Time.h" -#include <signal.h> - -using namespace std; -using namespace qpid::console; - -// -// Define a listener class to receive asynchronous events. -// -class Listener : public ConsoleListener { -public: - void brokerConnected(const Broker& broker) { - cout << qpid::sys::now() << " NOTIC qpid-printevents:brokerConnected broker=" << - broker.getUrl() << endl; - } - - void brokerDisconnected(const Broker& broker) { - cout << qpid::sys::now() << " NOTIC qpid-printevents:brokerDisconnected broker=" << - broker.getUrl() << endl; - } - - void event(Event& event) { - cout << event << endl; - } -}; - - -//============================================================== -// Main program -//============================================================== -struct Main { - bool stopping; - - Main() : stopping(false) {} - - int run(int /*argc*/, char** /*argv*/) - { - // - // Declare an instance of our listener. - // - Listener listener; - - // - // Declare connection settings for the messaging broker. - // - qpid::client::ConnectionSettings connSettings; - - // - // Declare the (optional) session manager settings. Disable the reception of - // object updates and heartbeats. Note that by disabling the reception of things - // we don't need, we don't unnecessarily use network bandwidth. - // - SessionManager::Settings smSettings; - smSettings.rcvObjects = false; - smSettings.rcvHeartbeats = false; - - // - // Declare the console session manager. - // - SessionManager sm(&listener, smSettings); - - // - // Add a broker connection to the session manager. If desired, multiple brokers may - // be connected. - // - Broker* broker = sm.addBroker(connSettings); - - // - // Sleep indefinitely while asynchronous events are handled by the listener. - // - while (!stopping) - qpid::sys::sleep(1); - - sm.delBroker(broker); - return 0; - } - - void stop() - { - stopping = true; - } -}; - -Main main_program; - -void signal_handler(int) -{ - main_program.stop(); -} - -int main(int argc, char** argv) -{ - signal(SIGINT, signal_handler); - try { - return main_program.run(argc, argv); - } catch(std::exception& e) { - cout << "Top Level Exception: " << e.what() << endl; - } -} - diff --git a/qpid/cpp/examples/qmf-console/qmf-console_console.vcproj b/qpid/cpp/examples/qmf-console/qmf-console_console.vcproj deleted file mode 100644 index eea535b85d..0000000000 --- a/qpid/cpp/examples/qmf-console/qmf-console_console.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="qmf_console_console"
- ProjectGUID="{490473E1-FECA-1BAD-2E13-3FFA2B8669C3}"
- RootNamespace="qmf_console_console"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\qmf_console_console\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib qmfconsoled.lib"
- OutputFile="$(OutDir)\console.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\qmf_console_console\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib qmfconsole.lib"
- OutputFile="$(OutDir)\console.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\qmf_console_console\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib qmfconsoled.lib"
- OutputFile="$(OutDir)\console.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\qmf_console_console\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib qmfconsole.lib"
- OutputFile="$(OutDir)\console.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="console.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/qmf-console/qmf-console_printevents.vcproj b/qpid/cpp/examples/qmf-console/qmf-console_printevents.vcproj deleted file mode 100644 index 221d922212..0000000000 --- a/qpid/cpp/examples/qmf-console/qmf-console_printevents.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="qmf_console_printevents"
- ProjectGUID="{72C74624-FECA-1BAD-2E13-3FFA2B8669C3}"
- RootNamespace="qmf_console_printevents"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\qmf_console_printevents\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib qmfconsoled.lib"
- OutputFile="$(OutDir)\printevents.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\qmf_console_printevents\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib qmfconsole.lib"
- OutputFile="$(OutDir)\printevents.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\qmf_console_printevents\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib qmfconsoled.lib"
- OutputFile="$(OutDir)\printevents.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\qmf_console_printevents\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib qmfconsole.lib"
- OutputFile="$(OutDir)\printevents.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="printevents.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/qmf-console/qmf-console_queuestats.vcproj b/qpid/cpp/examples/qmf-console/qmf-console_queuestats.vcproj deleted file mode 100644 index d89650b335..0000000000 --- a/qpid/cpp/examples/qmf-console/qmf-console_queuestats.vcproj +++ /dev/null @@ -1,394 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<!--
- -
- - 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.
- -
- -->
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="qmf_console_queuestats"
- ProjectGUID="{B21825EA-FECA-1BAD-2E13-3FFA2B8669C3}"
- RootNamespace="qmf_console_queuestats"
- Keyword="Win32Proj"
- SignManifests="true"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="."
- IntermediateDirectory="Debug\qmf_console_queuestats\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib qmfconsoled.lib"
- OutputFile="$(OutDir)\queuestats.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release\qmf_console_queuestats\I386"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib qmfconsole.lib"
- OutputFile="$(OutDir)\queuestats.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="."
- IntermediateDirectory="Debug\qmf_console_queuestats\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- MinimalRebuild="false"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommond.lib qpidclientd.lib qmfconsoled.lib"
- OutputFile="$(OutDir)\queuestats.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="Release"
- IntermediateDirectory="Release\qmf_console_queuestats\AMD64"
- ConfigurationType="1"
- CharacterSet="0"
-
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- AdditionalOptions=""
- AdditionalIncludeDirectories=""
- TypeLibraryName="$(InputName).tlb"
- HeaderFileName="$(InputName).h"
- InterfaceIdentifierFileName="$(InputName)_i.c"
- ProxyFileName="$(InputName)_p.c"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;_CRT_NONSTDC_NO_WARNINGS;_AMD64_;_WIN64;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;BOOST_ALL_DYN_LINK"
- RuntimeLibrary="2"
- RuntimeTypeInfo="true"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DisableSpecificWarnings="4244;4800"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG;NOMINMAX;WIN32_LEAN_AND_MEAN;_SCL_SECURE_NO_WARNINGS;_WIN64"
- Culture="1033"
- AdditionalIncludeDirectories="$(BOOST_ROOT)\include\$(BOOST_VERSION),$(BOOST_ROOT)\.,$(QPID_ROOT)\include,..\..\include"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/machine:AMD64"
- AdditionalDependencies="qpidcommon.lib qpidclient.lib qmfconsole.lib"
- OutputFile="$(OutDir)\queuestats.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories=".;$(BOOST_ROOT)\lib;$(QPID_ROOT)\bin,..\..\bin"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;cxx;cc;C;c">
- <File
- RelativePath="queuestats.cpp">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hh">
- <File
- RelativePath="ConnectionOptions.h">
- </File>
- <File
- RelativePath="TestOptions.h">
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/qpid/cpp/examples/qmf-console/queuestats.cpp b/qpid/cpp/examples/qmf-console/queuestats.cpp deleted file mode 100644 index 2c38777ad8..0000000000 --- a/qpid/cpp/examples/qmf-console/queuestats.cpp +++ /dev/null @@ -1,142 +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. - * - */ - -#include "qpid/console/ConsoleListener.h" -#include "qpid/console/SessionManager.h" -#include "qpid/sys/Time.h" - -using namespace std; -using namespace qpid::console; - -// -// Declare a subclass of ConsoleListener to receive asynchronous data. -// -class Listener : public ConsoleListener { - - // - // Declare a map from ObjectId to string to store queue names by their object IDs. - // - typedef map<ObjectId, string> QueueMap; - QueueMap queueMap; -public: - ~Listener() {} - - // - // Receive property updates from the agent. - // - void objectProps(Broker& /*broker*/, Object& object) { - string name = object.attrString("name"); - ObjectId oid = object.getObjectId(); - QueueMap::iterator iter = queueMap.find(oid); - - if (iter == queueMap.end()) { - // - // Object is not in the map. Learn it. - // - cout << "New Queue: " << name << endl; - queueMap[oid] = name; - } - } - - // - // Receive statistic updates from the agent. - // - void objectStats(Broker& /*broker*/, Object& object) { - ObjectId oid = object.getObjectId(); - QueueMap::iterator iter = queueMap.find(oid); - if (iter == queueMap.end()) - // - // Object id is not in the map. We are not interested in this update. - // - return; - - cout << "Stats for: " << iter->second << endl; - cout << " msgTotalEnqueues = " << object.attrUint64("msgTotalEnqueues") << endl; - cout << " msgTotalDequeues = " << object.attrUint64("msgTotalDequeues") << endl; - cout << " msgDepth = " << object.attrUint("msgDepth") << endl; - - if (object.isDeleted()) { - // - // Object was deleted and is in the map. Remove it. - // - cout << "Queue Deleted: " << iter->second << endl; - queueMap.erase(oid); - } - - // - // Note that the object-delete logic is done after processing statistics. - // This allows us to get the "final" statistics for a deleted object. It also - // assures that very short-lived objects are accounted for (i.e. created, used, - // and destroyed all within a single reporting interval). - // - } -}; - -//============================================================== -// Main program -//============================================================== -int main_int(int /*argc*/, char** /*argv*/) -{ - Listener listener; - - // - // Tune the settings for this application: We wish to receive objects but not events. - // By using "userBindings", we can restrict which objects we receive updates for. - // - SessionManager::Settings sessionSettings; - sessionSettings.rcvObjects = true; - sessionSettings.rcvEvents = false; - sessionSettings.rcvHeartbeats = false; - sessionSettings.userBindings = true; - - SessionManager sm(&listener, sessionSettings); - - // - // We want to receive updates only for the broker queue object. - // - sm.bindClass("org.apache.qpid.broker", "queue"); - - // - // Connect to the broker. - // - qpid::client::ConnectionSettings connSettings; - Broker* broker = sm.addBroker(connSettings); - - // - // Sleep while the listener does all the work asynchronously. - // - for (;;) { - qpid::sys::sleep(1); - } - - sm.delBroker(broker); - return 0; -} - -int main(int argc, char** argv) -{ - try { - return main_int(argc, argv); - } catch(std::exception& e) { - cout << "Top Level Exception: " << e.what() << endl; - } -} - diff --git a/qpid/cpp/include/qmf/engine/Agent.h b/qpid/cpp/include/qmf/engine/Agent.h deleted file mode 100644 index 71abf82254..0000000000 --- a/qpid/cpp/include/qmf/engine/Agent.h +++ /dev/null @@ -1,209 +0,0 @@ -#ifndef _QmfEngineAgent_ -#define _QmfEngineAgent_ - -/* - * 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 <qmf/engine/Schema.h> -#include <qmf/engine/ObjectId.h> -#include <qmf/engine/Object.h> -#include <qmf/engine/Event.h> -#include <qmf/engine/Query.h> -#include <qmf/engine/Value.h> -#include <qmf/engine/Message.h> - -namespace qmf { -namespace engine { - - /** - * AgentEvent - * - * This structure represents a QMF event coming from the agent to - * the application. - */ - struct AgentEvent { - enum EventKind { - GET_QUERY = 1, - START_SYNC = 2, - END_SYNC = 3, - METHOD_CALL = 4, - DECLARE_QUEUE = 5, - DELETE_QUEUE = 6, - BIND = 7, - UNBIND = 8, - SETUP_COMPLETE = 9 - }; - - EventKind kind; - uint32_t sequence; // Protocol sequence (for all kinds) - char* authUserId; // Authenticated user ID (for all kinds) - char* authToken; // Authentication token if issued (for all kinds) - char* name; // Name of the method/sync query - // (METHOD_CALL, START_SYNC, END_SYNC, DECLARE_QUEUE, BIND, UNBIND) - Object* object; // Object involved in method call (METHOD_CALL) - ObjectId* objectId; // ObjectId for method call (METHOD_CALL) - Query* query; // Query parameters (GET_QUERY, START_SYNC) - Value* arguments; // Method parameters (METHOD_CALL) - char* exchange; // Exchange for bind (BIND, UNBIND) - char* bindingKey; // Key for bind (BIND, UNBIND) - const SchemaObjectClass* objectClass; // (METHOD_CALL) - }; - - class AgentImpl; - - /** - * Agent - Protocol engine for the QMF agent - */ - class Agent { - public: - Agent(char* label, bool internalStore=true); - ~Agent(); - - /** - * Configure the directory path for storing persistent data. - *@param path Null-terminated string containing a directory path where files can be - * created, written, and read. If NULL, no persistent storage will be - * attempted. - */ - void setStoreDir(const char* path); - - /** - * Configure the directory path for files transferred over QMF. - *@param path Null-terminated string containing a directory path where files can be - * created, deleted, written, and read. If NULL, file transfers shall not - * be permitted. - */ - void setTransferDir(const char* path); - - /** - * Pass messages received from the AMQP session to the Agent engine. - *@param message AMQP messages received on the agent session. - */ - void handleRcvMessage(Message& message); - - /** - * Get the next message to be sent to the AMQP network. - *@param item The Message structure describing the message to be produced. - *@return true if the Message is valid, false if there are no messages to send. - */ - bool getXmtMessage(Message& item) const; - - /** - * Remove and discard one message from the head of the transmit queue. - */ - void popXmt(); - - /** - * Get the next application event from the agent engine. - *@param event The event iff the return value is true - *@return true if event is valid, false if there are no events to process - */ - bool getEvent(AgentEvent& event) const; - - /** - * Remove and discard one event from the head of the event queue. - */ - void popEvent(); - - /** - * A new AMQP session has been established for Agent communication. - */ - void newSession(); - - /** - * Start the QMF Agent protocol. This should be invoked after a SETUP_COMPLETE event - * is received from the Agent engine. - */ - void startProtocol(); - - /** - * This method is called periodically so the agent can supply a heartbeat. - */ - void heartbeat(); - - /** - * Respond to a method request. - *@param sequence The sequence number from the method request event. - *@param status The method's completion status. - *@param text Status text ("OK" or an error message) - *@param arguments The list of output arguments from the method call. - */ - void methodResponse(uint32_t sequence, uint32_t status, char* text, const Value& arguments); - - /** - * Send a content indication to the QMF bus. This is only needed for objects that are - * managed by the application. This is *NOT* needed for objects managed by the Agent - * (inserted using addObject). - *@param sequence The sequence number of the GET request or the SYNC_START request. - *@param object The object (annotated with "changed" flags) for publication. - *@param prop If true, changed object properties are transmitted. - *@param stat If true, changed object statistics are transmitted. - */ - void queryResponse(uint32_t sequence, Object& object, bool prop = true, bool stat = true); - - /** - * Indicate the completion of a query. This is not used for SYNC_START requests. - *@param sequence The sequence number of the GET request. - */ - void queryComplete(uint32_t sequence); - - /** - * Register a schema class with the Agent. - *@param cls A SchemaObejctClass object that defines data managed by the agent. - */ - void registerClass(SchemaObjectClass* cls); - - /** - * Register a schema class with the Agent. - *@param cls A SchemaEventClass object that defines events sent by the agent. - */ - void registerClass(SchemaEventClass* cls); - - /** - * Give an object to the Agent for storage and management. Once added, the agent takes - * responsibility for the life cycle of the object. - *@param obj The object to be managed by the Agent. - *@param persistId A unique non-zero value if the object-id is to be persistent. - *@return The objectId of the managed object. - */ - const ObjectId* addObject(Object& obj, uint64_t persistId); - // const ObjectId* addObject(Object& obj, uint32_t persistIdLo, uint32_t persistIdHi); - - /** - * Allocate an object-id for an object that will be managed by the application. - *@param persistId A unique non-zero value if the object-id is to be persistent. - *@return The objectId structure for the allocated ID. - */ - const ObjectId* allocObjectId(uint64_t persistId); - const ObjectId* allocObjectId(uint32_t persistIdLo, uint32_t persistIdHi); - - /** - * Raise an event into the QMF network.. - *@param event The event object for the event to be raised. - */ - void raiseEvent(Event& event); - - private: - AgentImpl* impl; - }; -} -} - -#endif - diff --git a/qpid/cpp/include/qmf/engine/ConnectionSettings.h b/qpid/cpp/include/qmf/engine/ConnectionSettings.h deleted file mode 100644 index 36312400b1..0000000000 --- a/qpid/cpp/include/qmf/engine/ConnectionSettings.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef _QmfEngineConnectionSettings_ -#define _QmfEngineConnectionSettings_ - -/* - * 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 "qmf/engine/QmfEngineImportExport.h" -#include "qpid/sys/IntegerTypes.h" - -namespace qmf { -namespace engine { - - class ConnectionSettingsImpl; - class Value; - - /** - * Settings for AMQP connections to the broker. - * - * \ingroup qmfapi - */ - class ConnectionSettings { - public: - - /** - * Create a set of default connection settings. - * - * If no further attributes are set, the settings will cause a connection to be made to - * the default broker (on localhost or at a host/port supplied by service discovery) and - * authentication will be the best-available (GSSAPI/Kerberos, Anonymous, Plain with prompts - * for username and password). - */ - QMFE_EXTERN ConnectionSettings(); - - /** - * Create a set of connection settings by URL. - * - * @param url Universal resource locator describing the broker address and additional attributes. - * - * The URL is of the form: - * amqp[s]://host[:port][?key=value[&key=value]*] - * - * For example: - * amqp://localhost - * amqp://broker?transport=rdma&authmech=GSSAPI&authservice=qpidd - * amqps://broker?authmech=PLAIN&authuser=guest&authpass=guest - */ - QMFE_EXTERN ConnectionSettings(const char* url); - - /** - * Copy Constructor. - */ - ConnectionSettings(const ConnectionSettings& from); - - /** - * Destroy the connection settings object. - */ - QMFE_EXTERN ~ConnectionSettings(); - - /** - * Set an attribute to control connection setup. - * - * @param key A null-terminated string that is an attribute name. - * - * @param value Reference to a value to be stored as the attribute. The type of the value - * is specific to the key. - * - * @return True if success, False if invalid attribute - */ - QMFE_EXTERN bool setAttr(const char* key, const Value& value); - - /** - * Get the value of an attribute. - * - * @param key A null-terminated attribute name. - * - * @return The value associated with the attribute name. - */ - QMFE_EXTERN Value getAttr(const char* key) const; - - /** - * Get the attribute string (the portion of the URL following the '?') for the settings. - * - * @return A pointer to the attribute string. If the content of this string needs to be - * available beyond the scope of the calling function, it should be copied. The - * returned pointer may become invalid if the set of attributes is changed. - */ - QMFE_EXTERN const char* getAttrString() const; - - /** - * Shortcuts for setting the transport for the connection. - * - * @param port The port value for the connection address. - */ - QMFE_EXTERN void transportTcp(uint16_t port = 5672); - QMFE_EXTERN void transportSsl(uint16_t port = 5671); - QMFE_EXTERN void transportRdma(uint16_t port = 5672); - - /** - * Shortcuts for setting authentication mechanisms. - * - * @param username Null-terminated authentication user name. - * - * @param password Null-terminated authentication password. - * - * @param serviceName Null-terminated GSSAPI service name (Kerberos service principal) - * - * @param minSsf Minimum security factor for connections. 0 = encryption not required. - * - * @param maxSsf Maximum security factor for connections. 0 = encryption not permitted. - */ - QMFE_EXTERN void authAnonymous(const char* username = 0); - QMFE_EXTERN void authPlain(const char* username = 0, const char* password = 0); - QMFE_EXTERN void authGssapi(const char* serviceName, uint32_t minSsf = 0, uint32_t maxSsf = 256); - - /** - * Shortcut for setting connection retry attributes. - * - * @param delayMin Minimum delay (in seconds) between connection attempts. - * - * @param delaxMax Maximum delay (in seconds) between connection attempts. - * - * @param delayFactor Factor to multiply the delay by between failed connection attempts. - */ - QMFE_EXTERN void setRetry(int delayMin = 1, int delayMax = 128, int delayFactor = 2); - - private: - friend class ResilientConnectionImpl; - ConnectionSettingsImpl* impl; - }; - -} -} - -#endif diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h deleted file mode 100644 index bd40c63c6c..0000000000 --- a/qpid/cpp/include/qmf/engine/Console.h +++ /dev/null @@ -1,239 +0,0 @@ -#ifndef _QmfEngineConsole_ -#define _QmfEngineConsole_ - -/* - * 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 <qmf/engine/ResilientConnection.h> -#include <qmf/engine/Schema.h> -#include <qmf/engine/ObjectId.h> -#include <qmf/engine/Object.h> -#include <qmf/engine/Event.h> -#include <qmf/engine/Query.h> -#include <qmf/engine/Value.h> -#include <qmf/engine/Message.h> - -namespace qmf { -namespace engine { - - class Console; - class ConsoleImpl; - class BrokerProxyImpl; - class AgentProxy; - struct AgentProxyImpl; - struct MethodResponseImpl; - struct QueryResponseImpl; - struct QueryContext; - - /** - * - */ - class MethodResponse { - public: - MethodResponse(const MethodResponse& from); - ~MethodResponse(); - uint32_t getStatus() const; - const Value* getException() const; - const Value* getArgs() const; - - private: - friend struct MethodResponseImpl; - friend class ConsoleImpl; - MethodResponse(MethodResponseImpl* impl); - MethodResponseImpl* impl; - }; - - /** - * - */ - class QueryResponse { - public: - ~QueryResponse(); - uint32_t getStatus() const; - const Value* getException() const; - uint32_t getObjectCount() const; - const Object* getObject(uint32_t idx) const; - - private: - friend struct QueryResponseImpl; - friend struct QueryContext; - QueryResponse(QueryResponseImpl* impl); - QueryResponseImpl *impl; - }; - - /** - * - */ - struct ConsoleEvent { - enum EventKind { - AGENT_ADDED = 1, - AGENT_DELETED = 2, - NEW_PACKAGE = 3, - NEW_CLASS = 4, - OBJECT_UPDATE = 5, - EVENT_RECEIVED = 7, - AGENT_HEARTBEAT = 8 - }; - - EventKind kind; - AgentProxy* agent; // (AGENT_[ADDED|DELETED|HEARTBEAT]) - char* name; // (NEW_PACKAGE) - const SchemaClassKey* classKey; // (NEW_CLASS) - Object* object; // (OBJECT_UPDATE) - void* context; // (OBJECT_UPDATE) - Event* event; // (EVENT_RECEIVED) - uint64_t timestamp; // (AGENT_HEARTBEAT) - QueryResponse* queryResponse; // (QUERY_COMPLETE) - bool hasProps; - bool hasStats; - }; - - /** - * - */ - struct BrokerEvent { - enum EventKind { - BROKER_INFO = 10, - DECLARE_QUEUE = 11, - DELETE_QUEUE = 12, - BIND = 13, - UNBIND = 14, - SETUP_COMPLETE = 15, - STABLE = 16, - QUERY_COMPLETE = 17, - METHOD_RESPONSE = 18 - }; - - EventKind kind; - char* name; // ([DECLARE|DELETE]_QUEUE, [UN]BIND) - char* exchange; // ([UN]BIND) - char* bindingKey; // ([UN]BIND) - void* context; // (QUERY_COMPLETE, METHOD_RESPONSE) - QueryResponse* queryResponse; // (QUERY_COMPLETE) - MethodResponse* methodResponse; // (METHOD_RESPONSE) - }; - - /** - * - */ - class AgentProxy { - public: - AgentProxy(const AgentProxy& from); - ~AgentProxy(); - const char* getLabel() const; - uint32_t getBrokerBank() const; - uint32_t getAgentBank() const; - - private: - friend struct StaticContext; - friend struct QueryContext; - friend struct AgentProxyImpl; - friend class BrokerProxyImpl; - AgentProxy(AgentProxyImpl* impl); - AgentProxyImpl* impl; - }; - - /** - * - */ - class BrokerProxy { - public: - BrokerProxy(Console& console); - ~BrokerProxy(); - - void sessionOpened(SessionHandle& sh); - void sessionClosed(); - void startProtocol(); - - void handleRcvMessage(Message& message); - bool getXmtMessage(Message& item) const; - void popXmt(); - - bool getEvent(BrokerEvent& event) const; - void popEvent(); - - uint32_t agentCount() const; - const AgentProxy* getAgent(uint32_t idx) const; - void sendQuery(const Query& query, void* context, const AgentProxy* agent = 0); - - private: - friend class ConsoleImpl; - friend struct StaticContext; - BrokerProxyImpl* impl; - }; - - // TODO - move this to a public header - struct ConsoleSettings { - bool rcvObjects; - bool rcvEvents; - bool rcvHeartbeats; - bool userBindings; - - ConsoleSettings() : - rcvObjects(true), - rcvEvents(true), - rcvHeartbeats(true), - userBindings(false) {} - }; - - class Console { - public: - Console(const ConsoleSettings& settings = ConsoleSettings()); - ~Console(); - - bool getEvent(ConsoleEvent& event) const; - void popEvent(); - - void addConnection(BrokerProxy& broker, void* context); - void delConnection(BrokerProxy& broker); - - uint32_t packageCount() const; - const char* getPackageName(uint32_t idx) const; - - uint32_t classCount(const char* packageName) const; - const SchemaClassKey* getClass(const char* packageName, uint32_t idx) const; - - ClassKind getClassKind(const SchemaClassKey* key) const; - const SchemaObjectClass* getObjectClass(const SchemaClassKey* key) const; - const SchemaEventClass* getEventClass(const SchemaClassKey* key) const; - - void bindPackage(const char* packageName); - void bindClass(const SchemaClassKey* key); - void bindClass(const char* packageName, const char* className); - - void bindEvent(const SchemaClassKey *key); - void bindEvent(const char* packageName, const char* eventName); - - /* - void startSync(const Query& query, void* context, SyncQuery& sync); - void touchSync(SyncQuery& sync); - void endSync(SyncQuery& sync); - */ - - private: - friend class BrokerProxyImpl; - friend struct AgentProxyImpl; - friend struct StaticContext; - ConsoleImpl* impl; - }; -} -} - -#endif - diff --git a/qpid/cpp/include/qmf/engine/Event.h b/qpid/cpp/include/qmf/engine/Event.h deleted file mode 100644 index 647b88dbf8..0000000000 --- a/qpid/cpp/include/qmf/engine/Event.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _QmfEngineEvent_ -#define _QmfEngineEvent_ - -/* - * 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. - */ - -namespace qmf { -namespace engine { - - class SchemaEventClass; - class Value; - struct EventImpl; - - class Event { - public: - Event(const SchemaEventClass* type); - Event(const Event& from); - ~Event(); - - const SchemaEventClass* getClass() const; - Value* getValue(const char* key) const; - - private: - friend struct EventImpl; - friend class AgentImpl; - Event(EventImpl* impl); - EventImpl* impl; - }; -} -} - -#endif - diff --git a/qpid/cpp/include/qmf/engine/Message.h b/qpid/cpp/include/qmf/engine/Message.h deleted file mode 100644 index 1e95cc6afe..0000000000 --- a/qpid/cpp/include/qmf/engine/Message.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _QmfEngineMessage_ -#define _QmfEngineMessage_ - -/* - * 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 "qpid/sys/IntegerTypes.h" - -namespace qmf { -namespace engine { - - struct Message { - char* body; - uint32_t length; - char* destination; - char* routingKey; - char* replyExchange; - char* replyKey; - char* userId; - }; - -} -} - -#endif diff --git a/qpid/cpp/include/qmf/engine/Object.h b/qpid/cpp/include/qmf/engine/Object.h deleted file mode 100644 index ad67cfdb95..0000000000 --- a/qpid/cpp/include/qmf/engine/Object.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _QmfEngineObject_ -#define _QmfEngineObject_ - -/* - * 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 <qmf/engine/Schema.h> -#include <qmf/engine/ObjectId.h> -#include <qmf/engine/Value.h> - -namespace qmf { -namespace engine { - - struct ObjectImpl; - class Object { - public: - Object(const SchemaObjectClass* type); - Object(const Object& from); - virtual ~Object(); - - void destroy(); - const ObjectId* getObjectId() const; - void setObjectId(ObjectId* oid); - const SchemaObjectClass* getClass() const; - Value* getValue(const char* key) const; - void invokeMethod(const char* methodName, const Value* inArgs, void* context) const; - bool isDeleted() const; - void merge(const Object& from); - - private: - friend struct ObjectImpl; - friend class AgentImpl; - Object(ObjectImpl* impl); - ObjectImpl* impl; - }; -} -} - -#endif - diff --git a/qpid/cpp/include/qmf/engine/ObjectId.h b/qpid/cpp/include/qmf/engine/ObjectId.h deleted file mode 100644 index 51eb2bc9e7..0000000000 --- a/qpid/cpp/include/qmf/engine/ObjectId.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _QmfEngineObjectId_ -#define _QmfEngineObjectId_ - -/* - * 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 <qpid/sys/IntegerTypes.h> - -namespace qmf { -namespace engine { - - // TODO: Add to/from string and << operator - - struct ObjectIdImpl; - class ObjectId { - public: - ObjectId(); - ObjectId(const ObjectId& from); - ~ObjectId(); - - uint64_t getObjectNum() const; - uint32_t getObjectNumHi() const; - uint32_t getObjectNumLo() const; - bool isDurable() const; - const char* str() const; - uint8_t getFlags() const; - uint16_t getSequence() const; - uint32_t getBrokerBank() const; - uint32_t getAgentBank() const; - - bool operator==(const ObjectId& other) const; - bool operator<(const ObjectId& other) const; - bool operator>(const ObjectId& other) const; - bool operator<=(const ObjectId& other) const; - bool operator>=(const ObjectId& other) const; - ObjectId& operator=(const ObjectId &other); - - private: - friend struct ObjectIdImpl; - friend struct ObjectImpl; - friend class BrokerProxyImpl; - friend struct QueryImpl; - friend struct ValueImpl; - friend class AgentImpl; - ObjectId(ObjectIdImpl* impl); - ObjectIdImpl* impl; - }; -} -} - -#endif - diff --git a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h deleted file mode 100644 index cf8fffdb17..0000000000 --- a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef QMF_ENGINE_IMPORT_EXPORT_H -#define QMF_ENGINE_IMPORT_EXPORT_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. - */ - -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -# if defined(QMF_EXPORT) || defined (qmfengine_EXPORTS) -# define QMFE_EXTERN __declspec(dllexport) -# else -# define QMFE_EXTERN __declspec(dllimport) -# endif -# ifdef _MSC_VER -# define QMFE_CLASS_EXTERN -# define QMFE_INLINE_EXTERN QMFE_EXTERN -# else -# define QMFE_CLASS_EXTERN QMFE_EXTERN -# define QMFE_INLINE_EXTERN -# endif -#else -# define QMFE_EXTERN -# define QMFE_CLASS_EXTERN -# define QMFE_INLINE_EXTERN -#endif - -#endif diff --git a/qpid/cpp/include/qmf/engine/Query.h b/qpid/cpp/include/qmf/engine/Query.h deleted file mode 100644 index 3ed08c5d8e..0000000000 --- a/qpid/cpp/include/qmf/engine/Query.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef _QmfEngineQuery_ -#define _QmfEngineQuery_ - -/* - * 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 <qmf/engine/ObjectId.h> -#include <qmf/engine/Value.h> - -namespace qmf { -namespace engine { - - class Object; - struct QueryElementImpl; - struct QueryImpl; - struct QueryExpressionImpl; - class SchemaClassKey; - - enum ValueOper { - O_EQ = 1, - O_NE = 2, - O_LT = 3, - O_LE = 4, - O_GT = 5, - O_GE = 6, - O_RE_MATCH = 7, - O_RE_NOMATCH = 8, - O_PRESENT = 9, - O_NOT_PRESENT = 10 - }; - - struct QueryOperand { - virtual ~QueryOperand() {} - virtual bool evaluate(const Object* object) const = 0; - }; - - struct QueryElement : public QueryOperand { - QueryElement(const char* attrName, const Value* value, ValueOper oper); - QueryElement(QueryElementImpl* impl); - virtual ~QueryElement(); - bool evaluate(const Object* object) const; - - QueryElementImpl* impl; - }; - - enum ExprOper { - E_NOT = 1, - E_AND = 2, - E_OR = 3, - E_XOR = 4 - }; - - struct QueryExpression : public QueryOperand { - QueryExpression(ExprOper oper, const QueryOperand* operand1, const QueryOperand* operand2); - QueryExpression(QueryExpressionImpl* impl); - virtual ~QueryExpression(); - bool evaluate(const Object* object) const; - - QueryExpressionImpl* impl; - }; - - class Query { - public: - Query(const char* className, const char* packageName); - Query(const SchemaClassKey* key); - Query(const ObjectId* oid); - Query(const Query& from); - ~Query(); - - void setSelect(const QueryOperand* criterion); - void setLimit(uint32_t maxResults); - void setOrderBy(const char* attrName, bool decreasing); - - const char* getPackage() const; - const char* getClass() const; - const ObjectId* getObjectId() const; - - bool haveSelect() const; - bool haveLimit() const; - bool haveOrderBy() const; - const QueryOperand* getSelect() const; - uint32_t getLimit() const; - const char* getOrderBy() const; - bool getDecreasing() const; - - private: - friend struct QueryImpl; - friend class BrokerProxyImpl; - Query(QueryImpl* impl); - QueryImpl* impl; - }; -} -} - -#endif - diff --git a/qpid/cpp/include/qmf/engine/ResilientConnection.h b/qpid/cpp/include/qmf/engine/ResilientConnection.h deleted file mode 100644 index c03d08cb96..0000000000 --- a/qpid/cpp/include/qmf/engine/ResilientConnection.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef _QmfEngineResilientConnection_ -#define _QmfEngineResilientConnection_ - -/* - * 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 <qmf/engine/Message.h> -#include <qmf/engine/ConnectionSettings.h> -#include <string> - -namespace qmf { -namespace engine { - - class ResilientConnectionImpl; - - /** - * Represents events that occur, unsolicited, from ResilientConnection. - */ - struct ResilientConnectionEvent { - enum EventKind { - CONNECTED = 1, - DISCONNECTED = 2, - SESSION_CLOSED = 3, - RECV = 4 - }; - - EventKind kind; - void* sessionContext; // SESSION_CLOSED, RECV - char* errorText; // DISCONNECTED, SESSION_CLOSED - Message message; // RECV - }; - - class SessionHandle { - friend class ResilientConnectionImpl; - void* impl; - }; - - /** - * ResilientConnection represents a Qpid connection that is resilient. - * - * Upon creation, ResilientConnection attempts to establish a connection to the - * messaging broker. If it fails, it will continue to retry at an interval that - * increases over time (to a maximum interval). If an extablished connection is - * dropped, a reconnect will be attempted. - */ - class ResilientConnection { - public: - - /** - * Create a new resilient connection. - *@param settings Settings that define how the connection is to be made. - *@param delayMin Minimum delay (in seconds) between retries. - *@param delayMax Maximum delay (in seconds) between retries. - *@param delayFactor Factor to multiply retry delay by after each failure. - */ - ResilientConnection(const ConnectionSettings& settings); - ~ResilientConnection(); - - /** - * Get the connected status of the resilient connection. - *@return true iff the connection is established. - */ - bool isConnected() const; - - /** - * Get the next event (if present) from the connection. - *@param event Returned event if one is available. - *@return true if event is valid, false if there are no more events to handle. - */ - bool getEvent(ResilientConnectionEvent& event); - - /** - * Discard the event on the front of the queue. This should be invoked after processing - * the event from getEvent. - */ - void popEvent(); - - /** - * Create a new AMQP session. - *@param name Unique name for the session. - *@param sessionContext Optional user-context value that will be provided in events - * pertaining to this session. - *@param handle Output handle to be stored and used in subsequent calls pertaining to - * this session. - *@return true iff the session was successfully created. - */ - bool createSession(const char* name, void* sessionContext, SessionHandle& handle); - - /** - * Destroy a created session. - *@param handle SessionHandle returned by createSession. - */ - void destroySession(SessionHandle handle); - - /** - * Send a message into the AMQP broker via a session. - *@param handle The session handle of the session to transmit through. - *@param message The QMF message to transmit. - */ - void sendMessage(SessionHandle handle, Message& message); - - /** - * Declare an exclusive, auto-delete queue for a session. - *@param handle The session handle for the owner of the queue. - *@param queue The name of the queue. - */ - void declareQueue(SessionHandle handle, char* queue); - - /** - * Delete a queue. - *@param handle The session handle for the owner of the queue. - *@param queue The name of the queue. - */ - void deleteQueue(SessionHandle handle, char* queue); - - /** - * Bind a queue to an exchange. - *@param handle The session handle of the session to use for binding. - *@param exchange The name of the exchange for binding. - *@param queue The name of the queue for binding. - *@param key The binding key. - */ - void bind(SessionHandle handle, char* exchange, char* queue, char* key); - - /** - * Remove a binding. - *@param handle The session handle of the session to use for un-binding. - *@param exchange The name of the exchange. - *@param queue The name of the queue. - *@param key The binding key. - */ - void unbind(SessionHandle handle, char* exchange, char* queue, char* key); - - /** - * Establish a file descriptor for event notification. - *@param fd A file descriptor into which the connection shall write a character each - * time an event is enqueued. This fd may be in a pair, the other fd of which - * is used in a select loop to control execution. - */ - void setNotifyFd(int fd); - - /** - * Send a byte into the notify file descriptor. - * - * This can be used to wake up the event processing portion of the engine from either the - * wrapped implementation or the engine itself. - */ - void notify(); - - private: - ResilientConnectionImpl* impl; - }; -} -} - -#endif - diff --git a/qpid/cpp/include/qmf/engine/Schema.h b/qpid/cpp/include/qmf/engine/Schema.h deleted file mode 100644 index f53e84324a..0000000000 --- a/qpid/cpp/include/qmf/engine/Schema.h +++ /dev/null @@ -1,212 +0,0 @@ -#ifndef _QmfEngineSchema_ -#define _QmfEngineSchema_ - -/* - * 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 <qmf/engine/Typecode.h> -#include <qpid/sys/IntegerTypes.h> - -namespace qmf { -namespace engine { - - enum Access { ACCESS_READ_CREATE = 1, ACCESS_READ_WRITE = 2, ACCESS_READ_ONLY = 3 }; - enum Direction { DIR_IN = 1, DIR_OUT = 2, DIR_IN_OUT = 3 }; - enum ClassKind { CLASS_OBJECT = 1, CLASS_EVENT = 2 }; - enum Severity { SEV_EMERG = 0, SEV_ALERT = 1, SEV_CRIT = 2, SEV_ERROR = 3, SEV_WARN = 4, SEV_NOTICE = 5, SEV_INFORM = 6, SEV_DEBUG = 7 }; - - struct SchemaArgumentImpl; - struct SchemaMethodImpl; - struct SchemaPropertyImpl; - struct SchemaStatisticImpl; - struct SchemaObjectClassImpl; - struct SchemaEventClassImpl; - struct SchemaClassKeyImpl; - - /** - */ - class SchemaArgument { - public: - SchemaArgument(const char* name, Typecode typecode); - SchemaArgument(const SchemaArgument& from); - ~SchemaArgument(); - void setDirection(Direction dir); - void setUnit(const char* val); - void setDesc(const char* desc); - const char* getName() const; - Typecode getType() const; - Direction getDirection() const; - const char* getUnit() const; - const char* getDesc() const; - - private: - friend struct SchemaArgumentImpl; - friend struct SchemaMethodImpl; - friend struct SchemaEventClassImpl; - SchemaArgument(SchemaArgumentImpl* impl); - SchemaArgumentImpl* impl; - }; - - /** - */ - class SchemaMethod { - public: - SchemaMethod(const char* name); - SchemaMethod(const SchemaMethod& from); - ~SchemaMethod(); - void addArgument(const SchemaArgument* argument); - void setDesc(const char* desc); - const char* getName() const; - const char* getDesc() const; - int getArgumentCount() const; - const SchemaArgument* getArgument(int idx) const; - - private: - friend struct SchemaMethodImpl; - friend struct SchemaObjectClassImpl; - friend class AgentImpl; - SchemaMethod(SchemaMethodImpl* impl); - SchemaMethodImpl* impl; - }; - - /** - */ - class SchemaProperty { - public: - SchemaProperty(const char* name, Typecode typecode); - SchemaProperty(const SchemaProperty& from); - ~SchemaProperty(); - void setAccess(Access access); - void setIndex(bool val); - void setOptional(bool val); - void setUnit(const char* val); - void setDesc(const char* desc); - const char* getName() const; - Typecode getType() const; - Access getAccess() const; - bool isIndex() const; - bool isOptional() const; - const char* getUnit() const; - const char* getDesc() const; - - private: - friend struct SchemaPropertyImpl; - friend struct SchemaObjectClassImpl; - SchemaProperty(SchemaPropertyImpl* impl); - SchemaPropertyImpl* impl; - }; - - /** - */ - class SchemaStatistic { - public: - SchemaStatistic(const char* name, Typecode typecode); - SchemaStatistic(const SchemaStatistic& from); - ~SchemaStatistic(); - void setUnit(const char* val); - void setDesc(const char* desc); - const char* getName() const; - Typecode getType() const; - const char* getUnit() const; - const char* getDesc() const; - - private: - friend struct SchemaStatisticImpl; - friend struct SchemaObjectClassImpl; - SchemaStatistic(SchemaStatisticImpl* impl); - SchemaStatisticImpl* impl; - }; - - /** - */ - class SchemaClassKey { - public: - SchemaClassKey(const SchemaClassKey& from); - ~SchemaClassKey(); - - const char* getPackageName() const; - const char* getClassName() const; - const uint8_t* getHash() const; - const char* asString() const; - - bool operator==(const SchemaClassKey& other) const; - bool operator<(const SchemaClassKey& other) const; - - private: - friend struct SchemaClassKeyImpl; - friend class BrokerProxyImpl; - friend class ConsoleImpl; - SchemaClassKey(SchemaClassKeyImpl* impl); - SchemaClassKeyImpl* impl; - }; - - /** - */ - class SchemaObjectClass { - public: - SchemaObjectClass(const char* package, const char* name); - SchemaObjectClass(const SchemaObjectClass& from); - ~SchemaObjectClass(); - void addProperty(const SchemaProperty* property); - void addStatistic(const SchemaStatistic* statistic); - void addMethod(const SchemaMethod* method); - - const SchemaClassKey* getClassKey() const; - int getPropertyCount() const; - int getStatisticCount() const; - int getMethodCount() const; - const SchemaProperty* getProperty(int idx) const; - const SchemaStatistic* getStatistic(int idx) const; - const SchemaMethod* getMethod(int idx) const; - - private: - friend struct SchemaObjectClassImpl; - friend class BrokerProxyImpl; - friend class AgentImpl; - SchemaObjectClass(SchemaObjectClassImpl* impl); - SchemaObjectClassImpl* impl; - }; - - /** - */ - class SchemaEventClass { - public: - SchemaEventClass(const char* package, const char* name, Severity severity); - SchemaEventClass(const SchemaEventClass& from); - ~SchemaEventClass(); - void addArgument(const SchemaArgument* argument); - void setDesc(const char* desc); - - const SchemaClassKey* getClassKey() const; - Severity getSeverity() const; - int getArgumentCount() const; - const SchemaArgument* getArgument(int idx) const; - - private: - friend struct SchemaEventClassImpl; - friend class BrokerProxyImpl; - friend class AgentImpl; - SchemaEventClass(SchemaEventClassImpl* impl); - SchemaEventClassImpl* impl; - }; -} -} - -#endif - diff --git a/qpid/cpp/include/qmf/engine/Typecode.h b/qpid/cpp/include/qmf/engine/Typecode.h deleted file mode 100644 index 613f96a483..0000000000 --- a/qpid/cpp/include/qmf/engine/Typecode.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _QmfEngineTypecode_ -#define _QmfEngineTypecode_ - -/* - * 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. - */ - -namespace qmf { -namespace engine { - - enum Typecode { - TYPE_UINT8 = 1, - TYPE_UINT16 = 2, - TYPE_UINT32 = 3, - TYPE_UINT64 = 4, - TYPE_SSTR = 6, - TYPE_LSTR = 7, - TYPE_ABSTIME = 8, - TYPE_DELTATIME = 9, - TYPE_REF = 10, - TYPE_BOOL = 11, - TYPE_FLOAT = 12, - TYPE_DOUBLE = 13, - TYPE_UUID = 14, - TYPE_MAP = 15, - TYPE_INT8 = 16, - TYPE_INT16 = 17, - TYPE_INT32 = 18, - TYPE_INT64 = 19, - TYPE_OBJECT = 20, - TYPE_LIST = 21, - TYPE_ARRAY = 22 - }; -} -} - -#endif - diff --git a/qpid/cpp/include/qmf/engine/Value.h b/qpid/cpp/include/qmf/engine/Value.h deleted file mode 100644 index 5b45061b78..0000000000 --- a/qpid/cpp/include/qmf/engine/Value.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef _QmfEngineValue_ -#define _QmfEngineValue_ - -/* - * 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 <qmf/engine/ObjectId.h> -#include <qmf/engine/Typecode.h> - -namespace qmf { -namespace engine { - - class Object; - struct ValueImpl; - - class Value { - public: - // Value(); - Value(const Value& from); - Value(Typecode t, Typecode arrayType = TYPE_UINT8); - ~Value(); - - Typecode getType() const; - bool isNull() const; - void setNull(); - - bool isObjectId() const; - const ObjectId& asObjectId() const; - void setObjectId(const ObjectId& oid); - - bool isUint() const; - uint32_t asUint() const; - void setUint(uint32_t val); - - bool isInt() const; - int32_t asInt() const; - void setInt(int32_t val); - - bool isUint64() const; - uint64_t asUint64() const; - void setUint64(uint64_t val); - - bool isInt64() const; - int64_t asInt64() const; - void setInt64(int64_t val); - - bool isString() const; - const char* asString() const; - void setString(const char* val); - - bool isBool() const; - bool asBool() const; - void setBool(bool val); - - bool isFloat() const; - float asFloat() const; - void setFloat(float val); - - bool isDouble() const; - double asDouble() const; - void setDouble(double val); - - bool isUuid() const; - const uint8_t* asUuid() const; - void setUuid(const uint8_t* val); - - bool isObject() const; - const Object* asObject() const; - void setObject(Object* val); - - bool isMap() const; - bool keyInMap(const char* key) const; - Value* byKey(const char* key); - const Value* byKey(const char* key) const; - void deleteKey(const char* key); - void insert(const char* key, Value* val); - uint32_t keyCount() const; - const char* key(uint32_t idx) const; - - bool isList() const; - uint32_t listItemCount() const; - Value* listItem(uint32_t idx); - void appendToList(Value* val); - void deleteListItem(uint32_t idx); - - bool isArray() const; - Typecode arrayType() const; - uint32_t arrayItemCount() const; - Value* arrayItem(uint32_t idx); - void appendToArray(Value* val); - void deleteArrayItem(uint32_t idx); - - private: - friend struct ValueImpl; - friend class BrokerProxyImpl; - friend struct ObjectImpl; - friend struct EventImpl; - friend class AgentImpl; - Value(ValueImpl* impl); - ValueImpl* impl; - }; -} -} - -#endif - diff --git a/qpid/cpp/include/qmf/qmfengine.i b/qpid/cpp/include/qmf/qmfengine.i deleted file mode 100644 index eb350115a3..0000000000 --- a/qpid/cpp/include/qmf/qmfengine.i +++ /dev/null @@ -1,59 +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. - */ - -%{ - -#include "qmf/engine/Agent.h" -#include "qmf/engine/Console.h" -#include "qmf/engine/ResilientConnection.h" - -%} - -%include <qmf/engine/QmfEngineImportExport.h> -%include <qmf/engine/Query.h> -%include <qmf/engine/Message.h> -%include <qmf/engine/Agent.h> -%include <qmf/engine/Console.h> -%include <qmf/engine/ConnectionSettings.h> -%include <qmf/engine/ResilientConnection.h> -%include <qmf/engine/Typecode.h> -%include <qmf/engine/Schema.h> -%include <qmf/engine/Value.h> -%include <qmf/engine/ObjectId.h> -%include <qmf/engine/Object.h> -%include <qmf/engine/Event.h> - - -%inline { - -using namespace std; -using namespace qmf::engine; - -namespace qmf { -namespace engine { - -} -} -} - - -%{ - -%}; - diff --git a/qpid/cpp/include/qpid/ImportExport.h b/qpid/cpp/include/qpid/ImportExport.h index e62399faf7..eecc9503bc 100644 --- a/qpid/cpp/include/qpid/ImportExport.h +++ b/qpid/cpp/include/qpid/ImportExport.h @@ -60,12 +60,16 @@ // // Non-Windows (Linux, etc.) definitions: // +#if __GNUC__ >= 4 +# define QPID_EXPORT __attribute ((visibility ("default"))) +#else # define QPID_EXPORT +#endif # define QPID_IMPORT -# define QPID_CLASS_EXPORT -# define QPID_CLASS_IMPORT -# define QPID_INLINE_EXPORT -# define QPID_INLINE_IMPORT +# define QPID_CLASS_EXPORT QPID_EXPORT +# define QPID_CLASS_IMPORT QPID_IMPORT +# define QPID_INLINE_EXPORT QPID_EXPORT +# define QPID_INLINE_IMPORT QPID_IMPORT #endif #endif /*!QPID_IMPORTEXPORT_H*/ diff --git a/qpid/cpp/include/qpid/agent/ManagementAgent.h b/qpid/cpp/include/qpid/agent/ManagementAgent.h deleted file mode 100644 index 10bc6527a9..0000000000 --- a/qpid/cpp/include/qpid/agent/ManagementAgent.h +++ /dev/null @@ -1,205 +0,0 @@ -#ifndef _qpid_agent_ManagementAgent_ -#define _qpid_agent_ManagementAgent_ - -// -// 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 "qpid/agent/QmfAgentImportExport.h" -#include "qpid/management/ManagementObject.h" -#include "qpid/management/ManagementEvent.h" -#include "qpid/management/Manageable.h" -#include "qpid/management/ConnectionSettings.h" - -namespace qpid { -namespace management { - -class Notifyable { -public: - virtual ~Notifyable() {} - virtual void notify() = 0; -}; - -class ManagementAgent -{ - public: - - class Singleton { - public: - QMF_AGENT_EXTERN Singleton(bool disableManagement = false); - QMF_AGENT_EXTERN ~Singleton(); - QMF_AGENT_EXTERN static ManagementAgent* getInstance(); - }; - - typedef enum { - SEV_EMERG = 0, - SEV_ALERT = 1, - SEV_CRIT = 2, - SEV_ERROR = 3, - SEV_WARN = 4, - SEV_NOTE = 5, - SEV_INFO = 6, - SEV_DEBUG = 7, - SEV_DEFAULT = 8 - } severity_t; - - ManagementAgent() {} - virtual ~ManagementAgent() {} - - virtual int getMaxThreads() = 0; - - // Set the name of the agent - // - // vendor - Vendor name or domain (i.e. "apache.org") - // product - Product name (i.e. "qpid") - // instance - A unique identifier for this instance of the agent. - // If empty, the agent will create a GUID for the instance. - // Note: the ":" character is reserved - do no use it in the vendor or product name. - // - virtual void setName(const std::string& vendor, - const std::string& product, - const std::string& instance="") = 0; - - // Retrieve the name of the agent as assigned by setName() - // - virtual void getName(std::string& vendor, - std::string& product, - std::string& instance) = 0; - - // Obtain the fully qualified name of the agent - // - virtual const std::string& getAddress() = 0; - - // Connect to a management broker - // - // brokerHost - Hostname or IP address (dotted-quad) of broker. - // - // brokerPort - TCP port of broker. - // - // intervalSeconds - The interval (in seconds) that this agent shall use - // between broadcast updates to the broker. - // - // useExternalThread - If true, the thread of control used for callbacks - // must be supplied by the user of the object (via the - // pollCallbacks method). - // - // If false, callbacks shall be invoked on the management - // agent's thread. In this case, the callback implementations - // MUST be thread safe. - // - // storeFile - File where this process has read and write access. This - // file shall be used to store persistent state. - // - virtual void init(const std::string& brokerHost = "localhost", - uint16_t brokerPort = 5672, - uint16_t intervalSeconds = 10, - bool useExternalThread = false, - const std::string& storeFile = "", - const std::string& uid = "", - const std::string& pwd = "", - const std::string& mech = "PLAIN", - const std::string& proto = "tcp") = 0; - - virtual void init(const management::ConnectionSettings& settings, - uint16_t intervalSeconds = 10, - bool useExternalThread = false, - const std::string& storeFile = "") = 0; - - - // Register a schema with the management agent. This is normally called by the - // package initializer generated by the management code generator. - // - virtual void - registerClass(const std::string& packageName, - const std::string& className, - uint8_t* md5Sum, - management::ManagementObject::writeSchemaCall_t schemaCall) = 0; - - virtual void - registerEvent(const std::string& packageName, - const std::string& eventName, - uint8_t* md5Sum, - management::ManagementEvent::writeSchemaCall_t schemaCall) = 0; - - // Add a management object to the agent. Once added, this object shall be visible - // in the greater management context. - // - // Please note that ManagementObject instances are not explicitly deleted from - // the management agent. When the core object represented by a management object - // is deleted, the "resourceDestroy" method on the management object must be called. - // It will then be reclaimed in due course by the management agent. - // - // Once a ManagementObject instance is added to the agent, the agent then owns the - // instance. The caller MUST NOT free the resources of the instance at any time. - // When it is no longer needed, invoke its "resourceDestroy" method and discard the - // pointer. This allows the management agent to report the deletion of the object - // in an orderly way. - // - virtual ObjectId addObject(ManagementObject* objectPtr, uint64_t persistId = 0) = 0; - virtual ObjectId addObject(ManagementObject* objectPtr, - const std::string& key, - bool persistent = true) = 0; - - // - // - virtual void raiseEvent(const ManagementEvent& event, - severity_t severity = SEV_DEFAULT) = 0; - - // If "useExternalThread" was set to true in init, this method must - // be called to provide a thread for any pending method calls that have arrived. - // The method calls for ManagementObject instances shall be invoked synchronously - // during the execution of this method. - // - // callLimit may optionally be used to limit the number of callbacks invoked. - // if 0, no limit is imposed. - // - // The return value is the number of callbacks that remain queued after this - // call is complete. It can be used to determine whether or not further calls - // to pollCallbacks are necessary to clear the backlog. If callLimit is zero, - // the return value will also be zero. - // - virtual uint32_t pollCallbacks(uint32_t callLimit = 0) = 0; - - // In the "useExternalThread" scenario, there are three ways that an application can - // use to be notified that there is work to do. Of course the application may periodically - // call pollCallbacks if it wishes, but this will cause long latencies in the responses - // to method calls. - // - // The notification methods are: - // - // 1) Register a C-style callback by providing a pointer to a function - // 2) Register a C++-style callback by providing an object of a class that is derived - // from Notifyable - // 3) Call getSignalFd() to get a file descriptor that can be used in a select - // call. The file descriptor shall become readable when the agent has work to - // do. Note that this mechanism is specific to Posix-based operating environments. - // getSignalFd will probably not function correctly on Windows. - // - // If a callback is registered, the callback function will be called on the agent's - // thread. The callback function must perform no work other than to signal the application - // thread to call pollCallbacks. - // - typedef void (*cb_t)(void*); - virtual void setSignalCallback(cb_t callback, void* context) = 0; - virtual void setSignalCallback(Notifyable& notifyable) = 0; - virtual int getSignalFd() = 0; -}; - -}} - -#endif /*!_qpid_agent_ManagementAgent_*/ diff --git a/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h b/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h deleted file mode 100644 index 3f923ac4b2..0000000000 --- a/qpid/cpp/include/qpid/agent/QmfAgentImportExport.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef QMF_AGENT_IMPORT_EXPORT_H -#define QMF_AGENT_IMPORT_EXPORT_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 "qpid/ImportExport.h" - -#if defined(QMF_EXPORT) || defined (qmf_EXPORTS) -# define QMF_AGENT_EXTERN QPID_EXPORT -# define QMF_AGENT_CLASS_EXTERN QPID_CLASS_EXPORT -# define QMF_AGENT_INLINE_EXTERN QPID_INLINE_EXPORT -#else -# define QMF_AGENT_EXTERN QPID_IMPORT -# define QMF_AGENT_CLASS_EXTERN QPID_CLASS_IMPORT -# define QMF_AGENT_INLINE_EXTERN QPID_INLINE_IMPORT -#endif - -#endif diff --git a/qpid/cpp/include/qpid/console/Agent.h b/qpid/cpp/include/qpid/console/Agent.h deleted file mode 100644 index 629dd71dee..0000000000 --- a/qpid/cpp/include/qpid/console/Agent.h +++ /dev/null @@ -1,58 +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. - * - */ -#ifndef _QPID_CONSOLE_AGENT_H_ -#define _QPID_CONSOLE_AGENT_H_ - -#include "qpid/console/Broker.h" -#include "qpid/console/ConsoleImportExport.h" - -namespace qpid { -namespace console { - - /** - * - * \ingroup qmfconsoleapi - */ - class QPID_CONSOLE_CLASS_EXTERN Agent { - public: - typedef std::vector<Agent*> Vector; - - QPID_CONSOLE_INLINE_EXTERN Agent(Broker* _broker, uint32_t _bank, const std::string& _label) : - broker(_broker), brokerBank(broker->getBrokerBank()), - agentBank(_bank), label(_label) {} - QPID_CONSOLE_INLINE_EXTERN Broker* getBroker() const { return broker; } - QPID_CONSOLE_INLINE_EXTERN uint32_t getBrokerBank() const { return brokerBank; } - QPID_CONSOLE_INLINE_EXTERN uint32_t getAgentBank() const { return agentBank; } - QPID_CONSOLE_INLINE_EXTERN const std::string& getLabel() const { return label; } - - private: - Broker* broker; - const uint32_t brokerBank; - const uint32_t agentBank; - const std::string label; - }; - - std::ostream& operator<<(std::ostream& o, const Agent& agent); -} -} - - -#endif diff --git a/qpid/cpp/include/qpid/console/Broker.h b/qpid/cpp/include/qpid/console/Broker.h deleted file mode 100644 index c2ba8ac81f..0000000000 --- a/qpid/cpp/include/qpid/console/Broker.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. - * - */ -#ifndef _QPID_CONSOLE_BROKER_H_ -#define _QPID_CONSOLE_BROKER_H_ - -#include "qpid/console/ConsoleImportExport.h" -#include "qpid/client/Connection.h" -#include "qpid/client/ConnectionSettings.h" -#include "qpid/client/SubscriptionManager.h" -#include "qpid/client/Session.h" -#include "qpid/client/AsyncSession.h" -#include "qpid/client/Message.h" -#include "qpid/client/MessageListener.h" -#include "qpid/sys/Thread.h" -#include "qpid/sys/Runnable.h" -#include "qpid/sys/Mutex.h" -#include "qpid/sys/Condition.h" -#include "qpid/Url.h" -#include "qpid/framing/Buffer.h" -#include "qpid/framing/Uuid.h" -#include <string> -#include <iostream> - -namespace qpid { -namespace console { - class SessionManager; - class Agent; - class Object; - - /** - * - * \ingroup qpidconsoleapi - */ - class Broker : public client::MessageListener { - public: - QPID_CONSOLE_EXTERN Broker(SessionManager& sm, - client::ConnectionSettings& settings); - QPID_CONSOLE_EXTERN ~Broker(); - - QPID_CONSOLE_INLINE_EXTERN bool isConnected() const { return connected; } - QPID_CONSOLE_INLINE_EXTERN const std::string& getError() const { return error; } - QPID_CONSOLE_INLINE_EXTERN const std::string& getSessionId() const { return amqpSessionId; } - QPID_CONSOLE_INLINE_EXTERN const framing::Uuid& getBrokerId() const { return brokerId; } - QPID_CONSOLE_INLINE_EXTERN uint32_t getBrokerBank() const { return 1; } - QPID_CONSOLE_INLINE_EXTERN void addBinding(const std::string& key) { - connThreadBody.bindExchange("qpid.management", key); - } - QPID_CONSOLE_EXTERN std::string getUrl() const; - QPID_CONSOLE_EXTERN void waitForStable(); - - private: - friend class SessionManager; - friend class Object; - typedef std::map<uint64_t,Agent*> AgentMap; - static const int SYNC_TIME = 60; - - SessionManager& sessionManager; - AgentMap agents; - bool connected; - std::string error; - std::string amqpSessionId; - client::ConnectionSettings connectionSettings; - sys::Mutex lock; - sys::Condition cond; - framing::Uuid brokerId; - uint32_t reqsOutstanding; - bool syncInFlight; - bool topicBound; - Object* methodObject; - - friend class ConnectionThread; - class ConnectionThread : public sys::Runnable { - bool operational; - bool shuttingDown; - Broker& broker; - framing::Uuid sessionId; - client::Connection connection; - client::Session session; - client::SubscriptionManager* subscriptions; - std::stringstream queueName; - sys::Mutex connLock; - void run(); - public: - ConnectionThread(Broker& _broker) : - operational(false), shuttingDown(false), broker(_broker), subscriptions(0) {} - ~ConnectionThread(); - void sendBuffer(qpid::framing::Buffer& buf, - uint32_t length, - const std::string& exchange = "qpid.management", - const std::string& routingKey = "broker"); - void bindExchange(const std::string& exchange, const std::string& key); - void shutdown(); - }; - - ConnectionThread connThreadBody; - sys::Thread connThread; - - void encodeHeader(framing::Buffer& buf, uint8_t opcode, uint32_t seq = 0) const; - bool checkHeader(framing::Buffer& buf, uint8_t *opcode, uint32_t *seq) const; - void received(client::Message& msg); - void resetAgents(); - void updateAgent(const Object& object); - void incOutstanding(); - void decOutstanding(); - void setBrokerId(const framing::Uuid& id) { brokerId = id; } - void appendAgents(std::vector<Agent*>& agents) const; - - friend std::ostream& operator<<(std::ostream& o, const Broker& k); - }; - - std::ostream& operator<<(std::ostream& o, const Broker& k); -} -} - -#endif diff --git a/qpid/cpp/include/qpid/console/ClassKey.h b/qpid/cpp/include/qpid/console/ClassKey.h deleted file mode 100644 index 5f7c50351a..0000000000 --- a/qpid/cpp/include/qpid/console/ClassKey.h +++ /dev/null @@ -1,66 +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. - * - */ -#ifndef _QPID_CONSOLE_CLASSKEY_H_ -#define _QPID_CONSOLE_CLASSKEY_H_ - -#include <string> -#include "qpid/console/ConsoleImportExport.h" -#include "qpid/console/Package.h" -#include "qpid/framing/Buffer.h" - -namespace qpid { -namespace console { - - /** - * - * \ingroup qmfconsoleapi - */ - class QPID_CONSOLE_CLASS_EXTERN ClassKey { - public: - QPID_CONSOLE_EXTERN static const int HASH_SIZE = 16; - - QPID_CONSOLE_EXTERN ClassKey(const std::string& package, const std::string& name, const uint8_t* hash); - - const QPID_CONSOLE_EXTERN std::string& getPackageName() const { return package; } - const QPID_CONSOLE_EXTERN std::string& getClassName() const { return name; } - const QPID_CONSOLE_EXTERN uint8_t* getHash() const { return hash; } - QPID_CONSOLE_EXTERN std::string getHashString() const; - QPID_CONSOLE_EXTERN std::string str() const; - QPID_CONSOLE_EXTERN bool operator==(const ClassKey& other) const; - QPID_CONSOLE_EXTERN bool operator!=(const ClassKey& other) const; - QPID_CONSOLE_EXTERN bool operator<(const ClassKey& other) const; - QPID_CONSOLE_EXTERN bool operator>(const ClassKey& other) const; - QPID_CONSOLE_EXTERN bool operator<=(const ClassKey& other) const; - QPID_CONSOLE_EXTERN bool operator>=(const ClassKey& other) const; - QPID_CONSOLE_EXTERN void encode(framing::Buffer& buffer) const; - - private: - std::string package; - std::string name; - uint8_t hash[HASH_SIZE]; - }; - - QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const ClassKey& k); -} -} - - -#endif diff --git a/qpid/cpp/include/qpid/console/ConsoleImportExport.h b/qpid/cpp/include/qpid/console/ConsoleImportExport.h deleted file mode 100644 index aac30858f7..0000000000 --- a/qpid/cpp/include/qpid/console/ConsoleImportExport.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef QPID_CONSOLE_IMPORT_EXPORT_H -#define QPID_CONSOLE_IMPORT_EXPORT_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 "qpid/ImportExport.h" - -#if defined(CONSOLE_EXPORT) || defined (qmfconsole_EXPORTS) -# define QPID_CONSOLE_EXTERN QPID_EXPORT -# define QPID_CONSOLE_CLASS_EXTERN QPID_CLASS_EXPORT -# define QPID_CONSOLE_INLINE_EXTERN QPID_INLINE_EXPORT -#else -# define QPID_CONSOLE_EXTERN QPID_IMPORT -# define QPID_CONSOLE_CLASS_EXTERN QPID_CLASS_IMPORT -# define QPID_CONSOLE_INLINE_EXTERN QPID_INLINE_IMPORT -#endif - -#endif diff --git a/qpid/cpp/include/qpid/console/ConsoleListener.h b/qpid/cpp/include/qpid/console/ConsoleListener.h deleted file mode 100644 index 7a649da657..0000000000 --- a/qpid/cpp/include/qpid/console/ConsoleListener.h +++ /dev/null @@ -1,97 +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. - * - */ -#ifndef _QPID_CONSOLE_CONSOLE_LISTENER_H_ -#define _QPID_CONSOLE_CONSOLE_LISTENER_H_ - -#include <string> -#include "qpid/console/ConsoleImportExport.h" -#include "qpid/console/Broker.h" -#include "qpid/console/ClassKey.h" -#include "qpid/console/Object.h" -#include "qpid/console/Event.h" - -namespace qpid { -namespace console { - - /** - * Implement a subclass of ConsoleListener and subscribe it using - * the SessionManager to receive indications. - * - * \ingroup qmfconsoleapi - */ - class QPID_CONSOLE_EXTERN ConsoleListener{ - public: - virtual ~ConsoleListener() {}; - - /** Invoked when a connection is established to a broker - */ - virtual void brokerConnected(const Broker&) {} - - /** Invoked when the connection to a broker is lost - */ - virtual void brokerDisconnected(const Broker&) {} - - /** Invoked when a QMF package is discovered. - */ - virtual void newPackage(const std::string&) {} - - /** Invoked when a new class is discovered. Session.getSchema can be - * used to obtain details about the class. - */ - virtual void newClass(const ClassKey&) {} - - /** Invoked when a QMF agent is discovered. - */ - virtual void newAgent(const Agent&) {} - - /** Invoked when a QMF agent disconects. - */ - virtual void delAgent(const Agent&) {} - - /** Invoked when an object is updated. - */ - virtual void objectProps(Broker&, Object&) {} - - /** Invoked when an object is updated. - */ - virtual void objectStats(Broker&, Object&) {} - - /** Invoked when an event is raised. - */ - virtual void event(Event&) {} - - /** - */ - //virtual void heartbeat(Agent&, uint64_t) {} - - /** - */ - virtual void brokerInfo(Broker&) {} - - /** - */ - //virtual void methodResponse(Broker&, uint32_t seq, MethodResponse&) {} - }; -} -} - - -#endif diff --git a/qpid/cpp/include/qpid/console/Event.h b/qpid/cpp/include/qpid/console/Event.h deleted file mode 100644 index ef4ecc791c..0000000000 --- a/qpid/cpp/include/qpid/console/Event.h +++ /dev/null @@ -1,86 +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. - * - */ -#ifndef _QPID_CONSOLE_EVENT_H_ -#define _QPID_CONSOLE_EVENT_H_ - -#include "qpid/console/ConsoleImportExport.h" -#include "qpid/console/Object.h" -#include "qpid/framing/Uuid.h" -#include "qpid/framing/FieldTable.h" - -namespace qpid { -namespace framing { - class Buffer; -} -namespace console { - - class Broker; - struct SchemaClass; - class ClassKey; - - /** - * - * \ingroup qmfconsoleapi - */ - class Event { - public: - typedef enum { - SEV_EMERGENCY = 0, SEV_ALERT = 1, SEV_CRITICAL = 2, SEV_ERROR = 3, - SEV_WARNING = 4, SEV_NOTICE = 5, SEV_INFO = 6, SEV_DEBUG = 7 - } Severity; - - QPID_CONSOLE_EXTERN Event(Broker* broker, - SchemaClass* schemaClass, - framing::Buffer& buffer); - Broker* getBroker() const { return broker; } - QPID_CONSOLE_EXTERN const ClassKey& getClassKey() const; - SchemaClass* getSchema() const { return schema; } - const Object::AttributeMap& getAttributes() const { return attributes; } - uint64_t getTimestamp() const { return timestamp; } - uint8_t getSeverity() const { return severity; } - QPID_CONSOLE_EXTERN std::string getSeverityString() const; - - QPID_CONSOLE_EXTERN ObjectId attrRef(const std::string& key) const; - QPID_CONSOLE_EXTERN uint32_t attrUint(const std::string& key) const; - QPID_CONSOLE_EXTERN int32_t attrInt(const std::string& key) const; - QPID_CONSOLE_EXTERN uint64_t attrUint64(const std::string& key) const; - QPID_CONSOLE_EXTERN int64_t attrInt64(const std::string& key) const; - QPID_CONSOLE_EXTERN std::string attrString(const std::string& key) const; - QPID_CONSOLE_EXTERN bool attrBool(const std::string& key) const; - QPID_CONSOLE_EXTERN float attrFloat(const std::string& key) const; - QPID_CONSOLE_EXTERN double attrDouble(const std::string& key) const; - QPID_CONSOLE_EXTERN framing::Uuid attrUuid(const std::string& key) const; - QPID_CONSOLE_EXTERN framing::FieldTable attrMap(const std::string& key) const; - - private: - Broker* broker; - SchemaClass* schema; - uint64_t timestamp; - Severity severity; - Object::AttributeMap attributes; - }; - - QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Event& event); -} -} - - -#endif diff --git a/qpid/cpp/include/qpid/console/Object.h b/qpid/cpp/include/qpid/console/Object.h deleted file mode 100644 index 5a29fdf792..0000000000 --- a/qpid/cpp/include/qpid/console/Object.h +++ /dev/null @@ -1,123 +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. - * - */ -#ifndef _QPID_CONSOLE_OBJECT_H_ -#define _QPID_CONSOLE_OBJECT_H_ - -#include "qpid/console/ConsoleImportExport.h" -#include "qpid/console/ObjectId.h" -#include "qpid/framing/Uuid.h" -#include "qpid/framing/FieldTable.h" -#include <boost/shared_ptr.hpp> -#include <map> -#include <set> -#include <vector> - -namespace qpid { -namespace framing { - class Buffer; -} -namespace console { - - class Broker; - struct SchemaClass; - struct SchemaMethod; - class ObjectId; - class ClassKey; - class Value; - - /** - * \ingroup qmfconsoleapi - */ - struct MethodResponse { - uint32_t code; - std::string text; - std::map<std::string, boost::shared_ptr<Value> > arguments; - }; - - class Object { - public: - typedef std::vector<Object> Vector; - struct AttributeMap : public std::map<std::string, boost::shared_ptr<Value> > { - QPID_CONSOLE_EXTERN void addRef(const std::string& key, const ObjectId& val); - QPID_CONSOLE_EXTERN void addUint(const std::string& key, uint32_t val); - QPID_CONSOLE_EXTERN void addInt(const std::string& key, int32_t val); - QPID_CONSOLE_EXTERN void addUint64(const std::string& key, uint64_t val); - QPID_CONSOLE_EXTERN void addInt64(const std::string& key, int64_t val); - QPID_CONSOLE_EXTERN void addString(const std::string& key, const std::string& val); - QPID_CONSOLE_EXTERN void addBool(const std::string& key, bool val); - QPID_CONSOLE_EXTERN void addFloat(const std::string& key, float val); - QPID_CONSOLE_EXTERN void addDouble(const std::string& key, double val); - QPID_CONSOLE_EXTERN void addUuid(const std::string& key, const framing::Uuid& val); - QPID_CONSOLE_EXTERN void addMap(const std::string& key, const framing::FieldTable& val); - }; - - QPID_CONSOLE_EXTERN Object(Broker* broker, SchemaClass* schemaClass, framing::Buffer& buffer, bool prop, bool stat); - QPID_CONSOLE_EXTERN ~Object(); - - Broker* getBroker() const { return broker; } - const ObjectId& getObjectId() const { return objectId; } - QPID_CONSOLE_EXTERN const ClassKey& getClassKey() const; - SchemaClass* getSchema() const { return schema; } - uint64_t getCurrentTime() const { return currentTime; } - uint64_t getCreateTime() const { return createTime; } - uint64_t getDeleteTime() const { return deleteTime; } - bool isDeleted() const { return deleteTime != 0; } - QPID_CONSOLE_EXTERN std::string getIndex() const; - QPID_CONSOLE_EXTERN void mergeUpdate(const Object& updated); - const AttributeMap& getAttributes() const { return attributes; } - QPID_CONSOLE_EXTERN void invokeMethod(const std::string name, - const AttributeMap& args, - MethodResponse& result); - QPID_CONSOLE_EXTERN void handleMethodResp(framing::Buffer& buffer, - uint32_t sequence); - - QPID_CONSOLE_EXTERN ObjectId attrRef(const std::string& key) const; - QPID_CONSOLE_EXTERN uint32_t attrUint(const std::string& key) const; - QPID_CONSOLE_EXTERN int32_t attrInt(const std::string& key) const; - QPID_CONSOLE_EXTERN uint64_t attrUint64(const std::string& key) const; - QPID_CONSOLE_EXTERN int64_t attrInt64(const std::string& key) const; - QPID_CONSOLE_EXTERN std::string attrString(const std::string& key) const; - QPID_CONSOLE_EXTERN bool attrBool(const std::string& key) const; - QPID_CONSOLE_EXTERN float attrFloat(const std::string& key) const; - QPID_CONSOLE_EXTERN double attrDouble(const std::string& key) const; - QPID_CONSOLE_EXTERN framing::Uuid attrUuid(const std::string& key) const; - QPID_CONSOLE_EXTERN framing::FieldTable attrMap(const std::string& key) const; - - private: - Broker* broker; - SchemaClass* schema; - ObjectId objectId; - uint64_t currentTime; - uint64_t createTime; - uint64_t deleteTime; - AttributeMap attributes; - SchemaMethod* pendingMethod; - MethodResponse methodResponse; - - void parsePresenceMasks(framing::Buffer& buffer, std::set<std::string>& excludeList); - }; - - QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Object& object); -} -} - - -#endif diff --git a/qpid/cpp/include/qpid/console/ObjectId.h b/qpid/cpp/include/qpid/console/ObjectId.h deleted file mode 100644 index 0722eaebeb..0000000000 --- a/qpid/cpp/include/qpid/console/ObjectId.h +++ /dev/null @@ -1,69 +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. - * - */ -#ifndef _QPID_CONSOLE_OBJECTID_H -#define _QPID_CONSOLE_OBJECTID_H - -#include <iostream> -#include "qpid/console/ConsoleImportExport.h" -#include "qpid/sys/IntegerTypes.h" - -namespace qpid { -namespace framing { - class Buffer; -} -namespace console { - - /** - * - * \ingroup qmfconsoleapi - */ - class QPID_CONSOLE_EXTERN ObjectId { - public: - ObjectId() : first(0), second(0) {} - ObjectId(framing::Buffer& buffer); - - uint8_t getFlags() const { return (uint8_t)((first & 0xF000000000000000LL) >> 60); } - uint16_t getSequence() const { return (uint16_t)((first & 0x0FFF000000000000LL) >> 48); } - uint32_t getBrokerBank() const { return (uint32_t)((first & 0x0000FFFFF0000000LL) >> 28); } - uint32_t getAgentBank() const { return (uint32_t) (first & 0x000000000FFFFFFFLL); } - uint64_t getObject() const { return second; } - bool isDurable() const { return getSequence() == 0; } - void decode(framing::Buffer& buffer); - void encode(framing::Buffer& buffer); - void setValue(uint64_t f, uint64_t s) { first = f; second = s; } - - bool operator==(const ObjectId& other) const; - bool operator!=(const ObjectId& other) const; - bool operator<(const ObjectId& other) const; - bool operator>(const ObjectId& other) const; - bool operator<=(const ObjectId& other) const; - bool operator>=(const ObjectId& other) const; - - private: - uint64_t first; - uint64_t second; - }; - - QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const ObjectId& id); -} -} - -#endif diff --git a/qpid/cpp/include/qpid/console/Package.h b/qpid/cpp/include/qpid/console/Package.h deleted file mode 100644 index 3b59e366ff..0000000000 --- a/qpid/cpp/include/qpid/console/Package.h +++ /dev/null @@ -1,78 +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. - * - */ -#ifndef _QPID_CONSOLE_PACKAGE_H_ -#define _QPID_CONSOLE_PACKAGE_H_ - -#include <string> -#include <map> -#include "qpid/console/ConsoleImportExport.h" -#include "qpid/sys/IntegerTypes.h" - -namespace qpid { -namespace console { - struct SchemaClass; - - /** - * - * \ingroup qmfconsoleapi - */ - class Package { - public: - Package(const std::string& n) : name(n) {} - const std::string& getName() const { return name; } - - private: - friend class SessionManager; - struct NameHash { - std::string name; - uint8_t hash[16]; - NameHash(const std::string& n, const uint8_t* h) : name(n) { - for (int i = 0; i < 16; i++) - hash[i] = h[i]; - } - }; - - struct NameHashComp { - bool operator() (const NameHash& lhs, const NameHash& rhs) const - { - if (lhs.name != rhs.name) - return lhs.name < rhs.name; - else - for (int i = 0; i < 16; i++) - if (lhs.hash[i] != rhs.hash[i]) - return lhs.hash[i] < rhs.hash[i]; - return false; - } - }; - - typedef std::map<NameHash, SchemaClass*, NameHashComp> ClassMap; - - const std::string name; - ClassMap classes; - - SchemaClass* getClass(const std::string& className, uint8_t* hash); - void addClass(const std::string& className, uint8_t* hash, - SchemaClass* schemaClass); - }; -} -} - -#endif diff --git a/qpid/cpp/include/qpid/console/Schema.h b/qpid/cpp/include/qpid/console/Schema.h deleted file mode 100644 index 6d4e41ab3e..0000000000 --- a/qpid/cpp/include/qpid/console/Schema.h +++ /dev/null @@ -1,105 +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. - * - */ -#ifndef _QPID_CONSOLE_SCHEMA_H_ -#define _QPID_CONSOLE_SCHEMA_H_ - -#include "qpid/console/ClassKey.h" -#include <boost/shared_ptr.hpp> -#include <vector> - -namespace qpid { -namespace framing { - class Buffer; -} -namespace console { - class Value; - - struct SchemaArgument { - SchemaArgument(framing::Buffer& buffer, bool forMethod = false); - boost::shared_ptr<Value> decodeValue(framing::Buffer& buffer); - - std::string name; - uint8_t typeCode; - bool dirInput; - bool dirOutput; - std::string unit; - int min; - int max; - int maxLen; - std::string desc; - std::string defaultVal; - }; - - struct SchemaProperty { - SchemaProperty(framing::Buffer& buffer); - boost::shared_ptr<Value> decodeValue(framing::Buffer& buffer); - - std::string name; - uint8_t typeCode; - uint8_t accessCode; - bool isIndex; - bool isOptional; - std::string unit; - int min; - int max; - int maxLen; - std::string desc; - }; - - struct SchemaStatistic { - SchemaStatistic(framing::Buffer& buffer); - boost::shared_ptr<Value> decodeValue(framing::Buffer& buffer); - - std::string name; - uint8_t typeCode; - std::string unit; - std::string desc; - }; - - struct SchemaMethod { - SchemaMethod(framing::Buffer& buffer); - ~SchemaMethod(); - - std::string name; - std::string desc; - std::vector<SchemaArgument*> arguments; - }; - - struct SchemaClass { - static const uint8_t KIND_TABLE = 1; - static const uint8_t KIND_EVENT = 2; - - SchemaClass(const uint8_t kind, const ClassKey& key, framing::Buffer& buffer); - ~SchemaClass(); - const ClassKey& getClassKey() const { return key; } - - const uint8_t kind; - const ClassKey key; - std::vector<SchemaProperty*> properties; - std::vector<SchemaStatistic*> statistics; - std::vector<SchemaMethod*> methods; - std::vector<SchemaArgument*> arguments; - }; -} -} - - -#endif diff --git a/qpid/cpp/include/qpid/console/SessionManager.h b/qpid/cpp/include/qpid/console/SessionManager.h deleted file mode 100644 index b46af549ff..0000000000 --- a/qpid/cpp/include/qpid/console/SessionManager.h +++ /dev/null @@ -1,219 +0,0 @@ -#ifndef _QPID_CONSOLE_SESSION_MANAGER_H -#define _QPID_CONSOLE_SESSION_MANAGER_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 "qpid/console/ConsoleImportExport.h" -#include "qpid/console/Broker.h" -#include "qpid/console/Package.h" -#include "qpid/console/SequenceManager.h" -#include "qpid/console/ClassKey.h" -#include "qpid/console/Schema.h" -#include "qpid/console/Agent.h" -#include "qpid/console/Object.h" -#include "qpid/console/ObjectId.h" -#include "qpid/console/Value.h" -#include "qpid/sys/Mutex.h" -#include "qpid/sys/Condition.h" -#include "qpid/client/ConnectionSettings.h" -#include <string> -#include <vector> - -namespace qpid { -namespace console { - -class ConsoleListener; - -/** - * - * \ingroup qmfconsoleapi - */ -class SessionManager -{ - public: - typedef std::vector<std::string> NameVector; - typedef std::vector<ClassKey> KeyVector; - QPID_CONSOLE_EXTERN ~SessionManager(); - - struct Settings { - bool rcvObjects; - bool rcvEvents; - bool rcvHeartbeats; - bool userBindings; - uint32_t methodTimeout; - uint32_t getTimeout; - - Settings() : rcvObjects(true), rcvEvents(true), rcvHeartbeats(true), - userBindings(false), methodTimeout(20), getTimeout(20) - {} - }; - - /** Create a new SessionManager - * - * Provide your own subclass of ConsoleListener to receive updates and indications - * asynchronously or leave it as its default and use only synchronous methods. - * - *@param listener Listener object to receive asynchronous indications. - *@param settings.rcvObjects Listener wishes to receive managed object data. - *@param settings.rcvEvents Listener wishes to receive events. - *@param settings.rcvHeartbeats Listener wishes to receive agent heartbeats. - *@param settings.userBindings If rcvObjects is true, userBindings allows the - * console client to control which object classes are received. See the bindPackage - * and bindClass methods. If userBindings is false, the listener will receive - * updates for all object classes. - */ - QPID_CONSOLE_EXTERN SessionManager(ConsoleListener* listener = 0, - Settings settings = Settings()); - - /** Connect a broker to the console session - * - *@param settings Connection settings for client access - *@return broker object if operation is successful - * an exception shall be thrown. - */ - QPID_CONSOLE_EXTERN Broker* addBroker(client::ConnectionSettings& settings); - - /** Disconnect a broker from the console session - * - *@param broker The broker object returned from an earlier call to addBroker. - */ - QPID_CONSOLE_EXTERN void delBroker(Broker* broker); - - /** Get a list of known management packages - * - *@param packages Vector of package names returned by the session manager. - */ - QPID_CONSOLE_EXTERN void getPackages(NameVector& packages); - - /** Get a list of class keys associated with a package - * - *@param classKeys List of class keys returned by the session manager. - *@param packageName Name of package being queried. - */ - QPID_CONSOLE_EXTERN void getClasses(KeyVector& classKeys, - const std::string& packageName); - - /** Get the schema of a class given its class key - * - *@param classKey Class key of the desired schema. - */ - QPID_CONSOLE_EXTERN SchemaClass& getSchema(const ClassKey& classKey); - - /** Request that updates be received for all classes within a package - * - * Note that this method is only meaningful if a ConsoleListener was provided at session - * creation and if the 'userBindings' flag was set to true. - * - *@param packageName Name of the package to which to bind. - */ - QPID_CONSOLE_EXTERN void bindPackage(const std::string& packageName); - - /** Request update to be received for a particular class - * - * Note that this method is only meaningful if a ConsoleListener was provided at session - * creation and if the 'userBindings' flag was set to true. - * - *@param classKey Class key of class to which to bind. - */ - QPID_CONSOLE_EXTERN void bindClass(const ClassKey& classKey); - QPID_CONSOLE_EXTERN void bindClass(const std::string& packageName, - const std::string& className); - - /** Request events from a particular package. - * - * Note that this method is only meaningful if a ConsoleListener was provided at session - * creation and if the 'userBindings' flag was set to true. - * - * @param classKey Class key of event of interest - * @param packageName Name of package of event of interest. - * @param eventName Name of event of interest. Default=All events defined by package. - */ - QPID_CONSOLE_EXTERN void bindEvent(const ClassKey& classKey); - QPID_CONSOLE_EXTERN void bindEvent(const std::string& packageName, - const std::string& eventName=""); - - - /** Get a list of qmf agents known to the session manager. - * - *@param agents Vector of Agent objects returned by the session manager. - *@param broker Return agents registered with this broker only. If NULL, return agents - * from all connected brokers. - */ - QPID_CONSOLE_EXTERN void getAgents(Agent::Vector& agents, - Broker* broker = 0); - - /** Get objects from agents. There are four variants of this method with different ways of - * specifying from which class objects are being queried. - * - *@param objects List of objects received. - *@param classKey ClassKey object identifying class to be queried. - *@param className Class name identifying class to be queried. - *@param objectId Object Id of the single object to be queried. - *@param broker Restrict the query to this broker, or all brokers if NULL. - *@param agent Restrict the query to this agent, or all agents if NULL. - */ - QPID_CONSOLE_EXTERN void getObjects(Object::Vector& objects, - const std::string& className, - Broker* broker = 0, - Agent* agent = 0); - //void getObjects(Object::Vector& objects, const ClassKey& classKey, - // Broker* broker = 0, Agent* agent = 0); - //void getObjects(Object::Vector& objects, const ObjectId& objectId, - // Broker* broker = 0, Agent* agent = 0); - -private: - friend class Broker; - friend class Broker::ConnectionThread; - friend class Object; - sys::Mutex lock; - sys::Mutex brokerListLock; - ConsoleListener* listener; - std::vector<Broker*> brokers; - std::map<std::string, Package*> packages; - SequenceManager sequenceManager; - sys::Condition cv; - SequenceManager::set syncSequenceList; - Object::Vector getResult; - std::string error; - Settings settings; - NameVector bindingKeyList; - - void bindingKeys(); - void allBrokersStable(); - void startProtocol(Broker* broker); - void handleBrokerResp(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); - void handlePackageInd(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); - void handleCommandComplete(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); - void handleClassInd(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); - void handleMethodResp(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); - void handleHeartbeatInd(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); - void handleEventInd(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); - void handleSchemaResp(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence); - void handleContentInd(Broker* broker, framing::Buffer& inBuffer, uint32_t sequence, bool prop, bool stat); - void handleBrokerConnect(Broker* broker); - void handleBrokerDisconnect(Broker* broker); - -}; - -}} // namespace qpid::console - -#endif /*!_QPID_CONSOLE_SESSION_MANAGER_H*/ diff --git a/qpid/cpp/include/qpid/console/Value.h b/qpid/cpp/include/qpid/console/Value.h deleted file mode 100644 index d9eb65053b..0000000000 --- a/qpid/cpp/include/qpid/console/Value.h +++ /dev/null @@ -1,213 +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. - * - */ -#ifndef _QPID_CONSOLE_VALUE_H_ -#define _QPID_CONSOLE_VALUE_H_ - -#include "qpid/Exception.h" -#include "qpid/framing/Uuid.h" -#include "qpid/framing/FieldTable.h" -#include "qpid/console/ObjectId.h" -#include <boost/shared_ptr.hpp> - -namespace qpid { -namespace framing { - class Buffer; -} -namespace console { - - /** - * \ingroup qmfconsoleapi - */ - class Value { - - public: - typedef boost::shared_ptr<Value> Ptr; - virtual ~Value() {} - virtual std::string str() const = 0; - - virtual bool isNull() const { return false; } - virtual bool isObjectId() const { return false; } - virtual bool isUint() const { return false; } - virtual bool isInt() const { return false; } - virtual bool isUint64() const { return false; } - virtual bool isInt64() const { return false; } - virtual bool isString() const { return false; } - virtual bool isBool() const { return false; } - virtual bool isFloat() const { return false; } - virtual bool isDouble() const { return false; } - virtual bool isUuid() const { return false; } - virtual bool isMap() const { return false; } - - virtual ObjectId asObjectId() const { incompatible(); return ObjectId(); } - virtual uint32_t asUint() const { incompatible(); return 0; } - virtual int32_t asInt() const { incompatible(); return 0; } - virtual uint64_t asUint64() const { incompatible(); return 0; } - virtual int64_t asInt64() const { incompatible(); return 0; } - virtual std::string asString() const { incompatible(); return std::string(); } - virtual bool asBool() const { incompatible(); return false; } - virtual float asFloat() const { incompatible(); return 0.0; } - virtual double asDouble() const { incompatible(); return 0.0; } - virtual framing::Uuid asUuid() const { incompatible(); return framing::Uuid(); } - virtual framing::FieldTable asMap() const { incompatible(); return framing::FieldTable(); } - - private: - void incompatible() const { - throw Exception("Incompatible Type"); - } - }; - - class NullValue : public Value { - public: - NullValue() {} - std::string str() const; - bool isNull() const { return true; } - }; - - class RefValue : public Value { - public: - RefValue(ObjectId v) : value(v) {} - RefValue(framing::Buffer& buffer); - std::string str() const; - bool isObjectId() const { return true; } - ObjectId asObjectId() const { return value; } - private: - ObjectId value; - }; - - class UintValue : public Value { - public: - UintValue(uint32_t v) : value(v) {} - std::string str() const; - bool isUint() const { return true; } - uint32_t asUint() const { return value; } - bool isUint64() const { return true; } - uint64_t asUint64() const { return (uint64_t) value; } - private: - uint32_t value; - }; - - class IntValue : public Value { - public: - IntValue(int32_t v) : value(v) {} - std::string str() const; - bool isInt() const { return true; } - int32_t asInt() const { return value; } - bool isInt64() const { return true; } - int64_t asInt64() const { return (int64_t) value; } - private: - int32_t value; - }; - - class Uint64Value : public Value { - public: - Uint64Value(uint64_t v) : value(v) {} - std::string str() const; - bool isUint64() const { return true; } - uint64_t asUint64() const { return value; } - private: - uint64_t value; - }; - - class Int64Value : public Value { - public: - Int64Value(int64_t v) : value(v) {} - std::string str() const; - bool isInt64() const { return true; } - int64_t asInt64() const { return value; } - private: - int64_t value; - }; - - class StringValue : public Value { - public: - StringValue(const std::string& v) : value(v) {} - StringValue(framing::Buffer& buffer, int tc); - std::string str() const { return value; } - bool isString() const { return true; } - std::string asString() const { return value; } - private: - std::string value; - }; - - class BoolValue : public Value { - public: - BoolValue(bool v) : value(v) {} - BoolValue(uint8_t v) : value(v != 0) {} - std::string str() const; - bool isBool() const { return true; } - bool asBool() const { return value; } - private: - bool value; - }; - - class FloatValue : public Value { - public: - FloatValue(float v) : value(v) {} - std::string str() const; - bool isFloat() const { return true; } - float asFloat() const { return value; } - bool isDouble() const { return true; } - double asDouble() const { return (double) value; } - private: - float value; - }; - - class DoubleValue : public Value { - public: - DoubleValue(double v) : value(v) {} - std::string str() const; - bool isDouble() const { return true; } - double asDouble() const { return value; } - private: - double value; - }; - - class UuidValue : public Value { - public: - UuidValue(const framing::Uuid& v) : value(v) {} - UuidValue(framing::Buffer& buffer); - std::string str() const { return value.str(); } - bool isUuid() const { return true; } - framing::Uuid asUuid() const { return value; } - private: - framing::Uuid value; - }; - - class MapValue : public Value { - public: - MapValue(const framing::FieldTable& v) : value(v) {} - MapValue(framing::Buffer& buffer); - std::string str() const; - bool isMap() const { return true; } - framing::FieldTable asMap() const { return value; } - private: - framing::FieldTable value; - }; - - class ValueFactory { - public: - static Value::Ptr newValue(int typeCode, framing::Buffer& buffer); - static void encodeValue(int typeCode, Value::Ptr value, framing::Buffer& buffer); - }; -} -} - -#endif diff --git a/qpid/cpp/include/qpid/framing/BufferTypes.h b/qpid/cpp/include/qpid/framing/BufferTypes.h new file mode 100644 index 0000000000..4199755852 --- /dev/null +++ b/qpid/cpp/include/qpid/framing/BufferTypes.h @@ -0,0 +1,106 @@ +#ifndef QPID_FRAMING_BUFFERTYPES_H +#define QPID_FRAMING_BUFFERTYPES_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. + * + */ + +/**@file + * Using templates with framing::Buffer is difficultg becase of the many + * different put/get function names. Here we define a set of types + * corresponding the basic types of Buffer but presenting a uniform + * encode/decode/encodedSize interface. + * + * It also provides some convenience templates for the common case of + * encoding a single encodable value as a string, e.g. + * + * LongString ls("hello"); + * std::string encoded = encodeStr(ls); + * LongString ls2 = decodeStr<LongString>(encoded); + * LongString ls3; + * decodeStr(encoded, ls3); + */ + +namespace qpid { +namespace framing { + +// Templates to help define types +template <class ValueType> struct BufferTypeTraits { + typedef void (Buffer::*Put)(const ValueType&); + typedef void (Buffer::*Get)(ValueType&); +}; + +template <class ValueType, + typename BufferTypeTraits<ValueType>::Put PutFn, + typename BufferTypeTraits<ValueType>::Get GetFn> +struct EncodeDecodeTemplate { + EncodeDecodeTemplate(const ValueType& s) : value(s) {} + operator ValueType() const { return value; } + + ValueType value; + void encode(framing::Buffer& buf) const { (buf.*PutFn)(value); } + void decode(framing::Buffer& buf) { (buf.*GetFn)(value); } +}; + +template <size_t Size, + typename BufferTypeTraits<std::string>::Put PutFn, + typename BufferTypeTraits<std::string>::Get GetFn + > +struct StringTypeTemplate : public EncodeDecodeTemplate<std::string, PutFn, GetFn> { + typedef EncodeDecodeTemplate<std::string, PutFn, GetFn> Base; + StringTypeTemplate(const std::string& s) : Base(s) {} + size_t encodedSize() const { return Size + Base::value.size(); } +}; + + +// Convenience tempates for encoding/decoding values to/from a std::string. + +/** Encode value as a string. */ +template <class T> std::string encodeStr(const T& value) { + std::string encoded(value.encodedSize(), '\0'); + framing::Buffer buffer(&encoded[0], encoded.size()); + value.encode(buffer); + return encoded; +} + +/** Decode value from a string. */ +template <class T> void decodeStr(const std::string& encoded, T& value) { + framing::Buffer b(const_cast<char*>(&encoded[0]), encoded.size()); + value.decode(b); +} + +/** Decode value from a string. */ +template <class T> T decodeStr(const std::string& encoded) { + T value; + decodeStr(encoded, value); + return value; +} + +// The types + +typedef StringTypeTemplate<4, &Buffer::putLongString, &Buffer::getLongString> LongString; +typedef StringTypeTemplate<2, &Buffer::putMediumString, &Buffer::getMediumString> MediumString; +typedef StringTypeTemplate<1, &Buffer::putShortString, &Buffer::getShortString> ShortString; + +// TODO aconway 2013-07-26: Add integer types. + +}} // namespace qpid::framing + +#endif /*!QPID_FRAMING_BUFFERTYPES_H*/ diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h index 58e61c4655..bb83685731 100644 --- a/qpid/cpp/include/qpid/messaging/Connection.h +++ b/qpid/cpp/include/qpid/messaging/Connection.h @@ -98,6 +98,33 @@ class QPID_MESSAGING_CLASS_EXTERN Connection : public qpid::messaging::Handle<Co QPID_MESSAGING_EXTERN void open(); QPID_MESSAGING_EXTERN bool isOpen(); QPID_MESSAGING_EXTERN bool isOpen() const; + + /** + * Attempts to reconnect to the specified url, re-establish + * existing sessions, senders and receivers and resend any indoubt + * messages. + * + * This can be used to directly control reconnect behaviour rather + * than using the reconnect option for automatically handling + * that. + */ + QPID_MESSAGING_EXTERN void reconnect(const std::string& url); + /** + * Attempts to reconnect to the original url, including any + * specified reconnect_urls, re-establish existing sessions, + * senders and receivers and resend any indoubt messages. + * + * This can be used to directly control reconnect behaviour rather + * than using the reconnect option for automatically handling + * that. + */ + QPID_MESSAGING_EXTERN void reconnect(); + /** + * returns a url reprsenting the broker the client is currently + * connected to (or an e,pty string if it is not connected). + */ + QPID_MESSAGING_EXTERN std::string getUrl() const; + /** * Closes a connection and all sessions associated with it. An * opened connection must be closed before the last handle is diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h index 5b14c7cf27..6315d3e86f 100644 --- a/qpid/cpp/include/qpid/messaging/Message.h +++ b/qpid/cpp/include/qpid/messaging/Message.h @@ -42,6 +42,7 @@ class MessageImpl; class QPID_MESSAGING_CLASS_EXTERN Message { public: + QPID_MESSAGING_EXTERN Message(qpid::types::Variant&); QPID_MESSAGING_EXTERN Message(const std::string& bytes = std::string()); QPID_MESSAGING_EXTERN Message(const char*, size_t); QPID_MESSAGING_EXTERN Message(const Message&); @@ -148,6 +149,7 @@ class QPID_MESSAGING_CLASS_EXTERN Message */ QPID_MESSAGING_EXTERN const qpid::types::Variant::Map& getProperties() const; QPID_MESSAGING_EXTERN qpid::types::Variant::Map& getProperties(); + QPID_MESSAGING_EXTERN void setProperties(const qpid::types::Variant::Map&); /** * Set the content to the data held in the string parameter. Note: @@ -164,6 +166,27 @@ class QPID_MESSAGING_CLASS_EXTERN Message /** Get the content as a std::string */ QPID_MESSAGING_EXTERN std::string getContent() const; + /** Get the content as raw bytes (an alias for getContent() */ + QPID_MESSAGING_EXTERN std::string getContentBytes() const; + /** Set the content as raw bytes (an alias for setContent() */ + QPID_MESSAGING_EXTERN void setContentBytes(const std::string&); + /** + * Get the content as a Variant, which can represent an object of + * different types. This can be used for content representing a + * map or a list for example. + */ + QPID_MESSAGING_EXTERN qpid::types::Variant& getContentObject(); + /** + * Get the content as a Variant, which can represent an object of + * different types. This can be used for content representing a + * map or a list for example. + */ + QPID_MESSAGING_EXTERN const qpid::types::Variant& getContentObject() const; + /** + * Set the content using a Variant, which can represent an object + * of different types. + */ + QPID_MESSAGING_EXTERN void setContentObject(const qpid::types::Variant&); /** * Get a const pointer to the start of the content data. The * memory pointed to is owned by the message. The getContentSize() diff --git a/qpid/cpp/include/qpid/messaging/exceptions.h b/qpid/cpp/include/qpid/messaging/exceptions.h index 31e2488d91..a9fa8e2506 100644 --- a/qpid/cpp/include/qpid/messaging/exceptions.h +++ b/qpid/cpp/include/qpid/messaging/exceptions.h @@ -40,9 +40,6 @@ struct QPID_MESSAGING_CLASS_EXTERN MessagingException : public qpid::types::Exce { QPID_MESSAGING_EXTERN MessagingException(const std::string& msg); QPID_MESSAGING_EXTERN virtual ~MessagingException() throw(); - - qpid::types::Variant::Map detail; - //TODO: override what() to include detail if present }; /** diff --git a/qpid/cpp/include/qpid/swig_python_typemaps.i b/qpid/cpp/include/qpid/swig_python_typemaps.i index 25a4e46b18..9d44a1e1ef 100644 --- a/qpid/cpp/include/qpid/swig_python_typemaps.i +++ b/qpid/cpp/include/qpid/swig_python_typemaps.i @@ -61,6 +61,11 @@ typedef int Py_ssize_t; if (PyInt_Check(value)) return qpid::types::Variant(int64_t(PyInt_AS_LONG(value))); if (PyLong_Check(value)) return qpid::types::Variant(int64_t(PyLong_AsLongLong(value))); if (PyString_Check(value)) return qpid::types::Variant(std::string(PyString_AS_STRING(value))); + if (PyUnicode_Check(value)) { + qpid::types::Variant v(std::string(PyUnicode_AS_DATA(value))); + v.setEncoding("utf8"); + return v; + } if (PyDict_Check(value)) { qpid::types::Variant::Map map; PyToMap(value, &map); @@ -116,7 +121,10 @@ typedef int Py_ssize_t; } case qpid::types::VAR_STRING : { const std::string val(v->asString()); - result = PyString_FromStringAndSize(val.c_str(), val.size()); + if (v->getEncoding() == "utf8") + result = PyUnicode_DecodeUTF8(val.c_str(), val.size(), NULL); + else + result = PyString_FromStringAndSize(val.c_str(), val.size()); break; } case qpid::types::VAR_MAP : { diff --git a/qpid/cpp/include/qpid/types/Uuid.h b/qpid/cpp/include/qpid/types/Uuid.h index 43ec160ab3..6384103f43 100644 --- a/qpid/cpp/include/qpid/types/Uuid.h +++ b/qpid/cpp/include/qpid/types/Uuid.h @@ -32,7 +32,7 @@ namespace types { class QPID_TYPES_CLASS_EXTERN Uuid { public: - static const size_t SIZE; + QPID_TYPES_EXTERN static const size_t SIZE; /** * If unique is true, this will generate a new unique uuid, if not * it will construct a null uuid. @@ -42,6 +42,7 @@ class QPID_TYPES_CLASS_EXTERN Uuid QPID_TYPES_EXTERN Uuid& operator=(const Uuid&); /** Copy the UUID from data16, which must point to a 16-byte UUID */ QPID_TYPES_EXTERN Uuid(const unsigned char* data16); + QPID_TYPES_EXTERN Uuid(const char* data16); /** Set to a new unique identifier. */ QPID_TYPES_EXTERN void generate(); @@ -81,6 +82,9 @@ class QPID_TYPES_CLASS_EXTERN Uuid unsigned char bytes[16]; }; +/** Hash value function for use with boots::hash or std::hash */ +inline size_t hash_value(const Uuid& uuid) { return uuid.hash(); } + /** Returns true if the uuids are equal, false otherwise. **/ QPID_TYPES_EXTERN bool operator==(const Uuid&, const Uuid&); /** Returns true if the uuids are NOT equal, false if they are. **/ diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h index e6bfd6bc0a..faba5fe9a4 100644 --- a/qpid/cpp/include/qpid/types/Variant.h +++ b/qpid/cpp/include/qpid/types/Variant.h @@ -38,7 +38,8 @@ namespace types { */ struct QPID_TYPES_CLASS_EXTERN InvalidConversion : public Exception { - InvalidConversion(const std::string& msg); + QPID_TYPES_EXTERN InvalidConversion(const std::string& msg); + QPID_TYPES_EXTERN ~InvalidConversion() throw(); }; enum VariantType { diff --git a/qpid/cpp/m4/ac_pkg_swig.m4 b/qpid/cpp/m4/ac_pkg_swig.m4 deleted file mode 100644 index 6e385c067c..0000000000 --- a/qpid/cpp/m4/ac_pkg_swig.m4 +++ /dev/null @@ -1,120 +0,0 @@ -# =========================================================================== -# http://www.nongnu.org/autoconf-archive/ac_pkg_swig.html -# =========================================================================== -# -# SYNOPSIS -# -# AC_PROG_SWIG([major.minor.micro]) -# -# DESCRIPTION -# -# This macro searches for a SWIG installation on your system. If found you -# should call SWIG via $(SWIG). You can use the optional first argument to -# check if the version of the available SWIG is greater than or equal to -# the value of the argument. It should have the format: N[.N[.N]] (N is a -# number between 0 and 999. Only the first N is mandatory.) -# -# If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks that -# the swig package is this version number or higher. -# -# In configure.in, use as: -# -# AC_PROG_SWIG(1.3.17) -# SWIG_ENABLE_CXX -# SWIG_MULTI_MODULE_SUPPORT -# SWIG_PYTHON -# -# LICENSE -# -# Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de> -# Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca> -# Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net> -# Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za> -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see <http://www.gnu.org/licenses/>. -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. -# -# Fixed by Sandro Santilli to consider 2.0.0 > 1.3.37 (2010-06-15) - -AC_DEFUN([AC_PROG_SWIG],[ - AC_PATH_PROG([SWIG],[swig]) - if test -z "$SWIG" ; then - AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org]) - SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false' - elif test -n "$1" ; then - AC_MSG_CHECKING([for SWIG version]) - [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] - AC_MSG_RESULT([$swig_version]) - if test -n "$swig_version" ; then - # Calculate the required version number components - [required=$1] - [required_major=`echo $required | sed 's/[^0-9].*//'`] - if test -z "$required_major" ; then - [required_major=0] - fi - [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] - [required_minor=`echo $required | sed 's/[^0-9].*//'`] - if test -z "$required_minor" ; then - [required_minor=0] - fi - [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] - [required_patch=`echo $required | sed 's/[^0-9].*//'`] - if test -z "$required_patch" ; then - [required_patch=0] - fi - # Calculate the available version number components - [available=$swig_version] - [available_major=`echo $available | sed 's/[^0-9].*//'`] - if test -z "$available_major" ; then - [available_major=0] - fi - [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] - [available_minor=`echo $available | sed 's/[^0-9].*//'`] - if test -z "$available_minor" ; then - [available_minor=0] - fi - [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] - [available_patch=`echo $available | sed 's/[^0-9].*//'`] - if test -z "$available_patch" ; then - [available_patch=0] - fi - [required_full=`printf %2.2d%2.2d%2.2d%2.2d $required_major $required_minor $required_patch]` - [available_full=`printf %2.2d%2.2d%2.2d%2.2d $available_major $available_minor $available_patch]` - if test $available_full -lt $required_full; then - AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version. You should look at http://www.swig.org]) - SWIG='echo "Error: SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false' - else - AC_MSG_NOTICE([SWIG executable is '$SWIG']) - SWIG_LIB=`$SWIG -swiglib` - AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB']) - fi - else - AC_MSG_WARN([cannot determine SWIG version]) - SWIG='echo "Error: Cannot determine SWIG version. You should look at http://www.swig.org" ; false' - fi - fi - AC_SUBST([SWIG_LIB]) -]) diff --git a/qpid/cpp/m4/clock_time.m4 b/qpid/cpp/m4/clock_time.m4 deleted file mode 100644 index 227a5978e5..0000000000 --- a/qpid/cpp/m4/clock_time.m4 +++ /dev/null @@ -1,30 +0,0 @@ -# clock_time.m4 serial 8 -dnl Copyright (C) 2002-2006 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# Check for clock_gettime and clock_settime, and set LIB_CLOCK_GETTIME. -# For a program named, say foo, you should add a line like the following -# in the corresponding Makefile.am file: -# foo_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) - -AC_DEFUN([gl_CLOCK_TIME], -[ - dnl Persuade glibc and Solaris <time.h> to declare these functions. - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - - # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function. - # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. - - # Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all* - # programs in the package would end up linked with that potentially-shared - # library, inducing unnecessary run-time overhead. - gl_saved_libs=$LIBS - AC_SEARCH_LIBS(clock_gettime, [rt posix4], - [test "$ac_cv_search_clock_gettime" = "none required" || - LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime]) - AC_SUBST([LIB_CLOCK_GETTIME]) - AC_CHECK_FUNCS(clock_gettime clock_settime) - LIBS=$gl_saved_libs -]) diff --git a/qpid/cpp/m4/compiler-flags.m4 b/qpid/cpp/m4/compiler-flags.m4 deleted file mode 100644 index 01cb728f02..0000000000 --- a/qpid/cpp/m4/compiler-flags.m4 +++ /dev/null @@ -1,23 +0,0 @@ -# serial 3 -# Find valid warning flags for the C Compiler. -*-Autoconf-*- -dnl Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl Written by Jesse Thilo. - -AC_DEFUN([gl_COMPILER_FLAGS], - [AC_MSG_CHECKING(whether compiler accepts $1) - AC_SUBST(COMPILER_FLAGS) - ac_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $1" - ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS $1" - AC_TRY_COMPILE(, - [int x;], - COMPILER_FLAGS="$COMPILER_FLAGS $1" - AC_MSG_RESULT(yes), - AC_MSG_RESULT(no)) - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - ]) diff --git a/qpid/cpp/m4/cppunit.m4 b/qpid/cpp/m4/cppunit.m4 deleted file mode 100644 index f009086f9d..0000000000 --- a/qpid/cpp/m4/cppunit.m4 +++ /dev/null @@ -1,89 +0,0 @@ -dnl -dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl -AC_DEFUN([AM_PATH_CPPUNIT], -[ - -AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)], - cppunit_config_prefix="$withval", cppunit_config_prefix="") -AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)], - cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="") - - if test x$cppunit_config_exec_prefix != x ; then - cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix" - if test x${CPPUNIT_CONFIG+set} != xset ; then - CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config - fi - fi - if test x$cppunit_config_prefix != x ; then - cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix" - if test x${CPPUNIT_CONFIG+set} != xset ; then - CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config - fi - fi - - AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no) - cppunit_version_min=$1 - - AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min) - no_cppunit="" - if test "$CPPUNIT_CONFIG" = "no" ; then - AC_MSG_RESULT(no) - no_cppunit=yes - else - CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags` - CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs` - cppunit_version=`$CPPUNIT_CONFIG --version` - - cppunit_major_version=`echo $cppunit_version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - cppunit_minor_version=`echo $cppunit_version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - cppunit_micro_version=`echo $cppunit_version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` - - cppunit_major_min=`echo $cppunit_version_min | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - if test "x${cppunit_major_min}" = "x" ; then - cppunit_major_min=0 - fi - - cppunit_minor_min=`echo $cppunit_version_min | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - if test "x${cppunit_minor_min}" = "x" ; then - cppunit_minor_min=0 - fi - - cppunit_micro_min=`echo $cppunit_version_min | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` - if test "x${cppunit_micro_min}" = "x" ; then - cppunit_micro_min=0 - fi - - cppunit_version_proper=`expr \ - $cppunit_major_version \> $cppunit_major_min \| \ - $cppunit_major_version \= $cppunit_major_min \& \ - $cppunit_minor_version \> $cppunit_minor_min \| \ - $cppunit_major_version \= $cppunit_major_min \& \ - $cppunit_minor_version \= $cppunit_minor_min \& \ - $cppunit_micro_version \>= $cppunit_micro_min ` - - if test "$cppunit_version_proper" = "1" ; then - AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version]) - else - AC_MSG_RESULT(no) - no_cppunit=yes - fi - fi - - if test "x$no_cppunit" = x ; then - ifelse([$2], , :, [$2]) - else - CPPUNIT_CFLAGS="" - CPPUNIT_LIBS="" - ifelse([$3], , :, [$3]) - fi - - AC_SUBST(CPPUNIT_CFLAGS) - AC_SUBST(CPPUNIT_LIBS) -]) diff --git a/qpid/cpp/m4/extensions.m4 b/qpid/cpp/m4/extensions.m4 deleted file mode 100644 index fe7398b046..0000000000 --- a/qpid/cpp/m4/extensions.m4 +++ /dev/null @@ -1,59 +0,0 @@ -# serial 5 -*- Autoconf -*- -# Enable extensions on systems that normally disable them. - -# Copyright (C) 2003, 2006, 2008 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS -# Autoconf. Perhaps we can remove this once we can assume Autoconf -# 2.61 or later everywhere, but since CVS Autoconf mutates rapidly -# enough in this area it's likely we'll need to redefine -# AC_USE_SYSTEM_EXTENSIONS for quite some time. - -# AC_USE_SYSTEM_EXTENSIONS -# ------------------------ -# Enable extensions on systems that normally disable them, -# typically due to standards-conformance issues. -m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], [], [ -AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], -[ - AC_BEFORE([$0], [AC_COMPILE_IFELSE]) - AC_BEFORE([$0], [AC_RUN_IFELSE]) - - AC_REQUIRE([AC_GNU_SOURCE]) - AC_REQUIRE([AC_AIX]) - AC_REQUIRE([AC_MINIX]) - - AH_VERBATIM([__EXTENSIONS__], -[/* Enable extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# undef __EXTENSIONS__ -#endif -#ifndef _POSIX_PTHREAD_SEMANTICS -# undef _POSIX_PTHREAD_SEMANTICS -#endif -#ifndef _TANDEM_SOURCE -# undef _TANDEM_SOURCE -#endif]) - AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], - [ac_cv_safe_to_define___extensions__], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([ -# define __EXTENSIONS__ 1 - AC_INCLUDES_DEFAULT])], - [ac_cv_safe_to_define___extensions__=yes], - [ac_cv_safe_to_define___extensions__=no])]) - test $ac_cv_safe_to_define___extensions__ = yes && - AC_DEFINE([__EXTENSIONS__]) - AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) - AC_DEFINE([_TANDEM_SOURCE]) -])]) - -# gl_USE_SYSTEM_EXTENSIONS -# ------------------------ -# Enable extensions on systems that normally disable them, -# typically due to standards-conformance issues. -AC_DEFUN([gl_USE_SYSTEM_EXTENSIONS], - [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])]) diff --git a/qpid/cpp/m4/python.m4 b/qpid/cpp/m4/python.m4 deleted file mode 100644 index 229fd5547b..0000000000 --- a/qpid/cpp/m4/python.m4 +++ /dev/null @@ -1,168 +0,0 @@ -## ------------------------ -*- Autoconf -*- -## Python file handling -## From Andrew Dalke -## Updated by James Henstridge -## ------------------------ -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# --------------------------------------------------------------------------- -# Adds support for distributing Python modules and packages. To -# install modules, copy them to $(pythondir), using the python_PYTHON -# automake variable. To install a package with the same name as the -# automake package, install to $(pkgpythondir), or use the -# pkgpython_PYTHON automake variable. -# -# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as -# locations to install python extension modules (shared libraries). -# Another macro is required to find the appropriate flags to compile -# extension modules. -# -# If your package is configured with a different prefix to python, -# users will have to add the install directory to the PYTHONPATH -# environment variable, or create a .pth file (see the python -# documentation for details). -# -# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will -# cause an error if the version of python installed on the system -# doesn't meet the requirement. MINIMUM-VERSION should consist of -# numbers and dots only. -AC_DEFUN([AM_PATH_PYTHON], - [ - dnl Find a Python interpreter. Python versions prior to 1.5 are not - dnl supported because the default installation locations changed from - dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages - dnl in 1.5. - m4_define_default([_AM_PYTHON_INTERPRETER_LIST], - [python python2 python2.5 python2.4 python2.3 python2.2 dnl -python2.1 python2.0 python1.6 python1.5]) - - m4_if([$1],[],[ - dnl No version check is needed. - # Find any Python interpreter. - if test -z "$PYTHON"; then - AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :) - fi - am_display_PYTHON=python - ], [ - dnl A version check is needed. - if test -n "$PYTHON"; then - # If the user set $PYTHON, use it and don't search something else. - AC_MSG_CHECKING([whether $PYTHON version >= $1]) - AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], - [AC_MSG_RESULT(yes)], - [AC_MSG_ERROR(too old)]) - am_display_PYTHON=$PYTHON - else - # Otherwise, try each interpreter until we find one that satisfies - # VERSION. - AC_CACHE_CHECK([for a Python interpreter with version >= $1], - [am_cv_pathless_PYTHON],[ - for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do - test "$am_cv_pathless_PYTHON" = none && break - AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) - done]) - # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. - if test "$am_cv_pathless_PYTHON" = none; then - PYTHON=: - else - AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON]) - fi - am_display_PYTHON=$am_cv_pathless_PYTHON - fi - ]) - - if test "$PYTHON" = :; then - dnl Run any user-specified action, or abort. - m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])]) - else - - dnl Query Python for its version number. Getting [:3] seems to be - dnl the best way to do this; it's what "site.py" does in the standard - dnl library. - - AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version], - [am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`]) - AC_SUBST([PYTHON_VERSION], [$am_cv_python_version]) - - dnl Use the values of $prefix and $exec_prefix for the corresponding - dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made - dnl distinct variables so they can be overridden if need be. However, - dnl general consensus is that you shouldn't need this ability. - - AC_SUBST([PYTHON_PREFIX], ['${prefix}']) - AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}']) - - dnl At times (like when building shared libraries) you may want - dnl to know which OS platform Python thinks this is. - - AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform], - [am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`]) - AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform]) - - - dnl Set up 4 directories: - - dnl pythondir -- where to install python scripts. This is the - dnl site-packages directory, not the python standard library - dnl directory like in previous automake betas. This behavior - dnl is more consistent with lispdir.m4 for example. - dnl Query distutils for this directory. distutils does not exist in - dnl Python 1.5, so we fall back to the hardcoded directory if it - dnl doesn't work. - AC_CACHE_CHECK([for $am_display_PYTHON script directory], - [am_cv_python_pythondir], - [am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null || - echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`]) - AC_SUBST([pythondir], [$am_cv_python_pythondir]) - - dnl pkgpythondir -- $PACKAGE directory under pythondir. Was - dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is - dnl more consistent with the rest of automake. - - AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE]) - - dnl pyexecdir -- directory for installing python extension modules - dnl (shared libraries) - dnl Query distutils for this directory. distutils does not exist in - dnl Python 1.5, so we fall back to the hardcoded directory if it - dnl doesn't work. - AC_CACHE_CHECK([for $am_display_PYTHON extension module directory], - [am_cv_python_pyexecdir], - [am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null || - echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`]) - AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir]) - - dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE) - - AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE]) - - dnl Run any user-specified action. - $2 - fi - -]) - - -# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) -# --------------------------------------------------------------------------- -# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. -# Run ACTION-IF-FALSE otherwise. -# This test uses sys.hexversion instead of the string equivalent (first -# word of sys.version), in order to cope with versions such as 2.2c1. -# hexversion has been introduced in Python 1.5.2; it's probably not -# worth to support older versions (1.5.1 was released on October 31, 1998). -AC_DEFUN([AM_PYTHON_CHECK_VERSION], - [prog="import sys, string -# split strings by '.' and convert to numeric. Append some zeros -# because we need at least 4 digits for the hex conversion. -minver = map(int, string.split('$2', '.')) + [[0, 0, 0]] -minverhex = 0 -for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]] -sys.exit(sys.hexversion < minverhex)" - AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) diff --git a/qpid/cpp/make-dist b/qpid/cpp/make-dist deleted file mode 100755 index a0c02402e5..0000000000 --- a/qpid/cpp/make-dist +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash - -# -# -# 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. -# - - -# -# Temporary hack for producing a binary dev distribution. -# Includes regular stuff from 'make install' + examples and headers. -# -# TODO: Also include debug libraries. -# - -Usage() { - echo "usage: $0 [release-version] - release-version e.g. 1.0M1 (defaults to the svn revision)" >&2 - exit 2 -} - -if [[ $# -eq 1 ]]; then - [[ $1 == "-?" ]] && Usage - version=$1 -elif [[ $# -ne 0 ]]; then - Usage -else - # Default the version to the svn revision - if which svn >/dev/null 2>&1; then - svnRevision=$(svn info | grep ^Revision: | awk '{print $2}') - version=r${svnRevision} - else - echo "You need to have svn in your PATH or specify a release-version" - exit 2 - fi -fi - -releaseName=qpid-cpp-dev-${version}-$(uname -s)-$(uname -p) -releaseDir=release/$releaseName - -if [[ -d $releaseDir ]]; then - echo "$releaseDir already exists" - exit 2 -fi - -# Copy bin. -mkdir -p $releaseDir/bin -cp -r src/.libs/* ${releaseDir}/bin - -# Copy libs. -mkdir -p $releaseDir/lib -cp lib/broker/.libs/lib* lib/common/.libs/lib* lib/client/.libs/lib* \ - $releaseDir/lib - -# Copy gen include files. -find gen -name \*.h | while read file; do - destFile=${releaseDir}/include/$file - baseDir=$(dirname $destFile) - mkdir -p $baseDir - cp $file $destFile -done - -# Copy in lib include files. -( - cd lib; find . -name \*.h | while read file; do - destFile=../${releaseDir}/include/$file - baseDir=$(dirname $destFile) - mkdir -p $baseDir - cp $file $destFile - done -) - -# Copy non-cppunit tests as examples. -mkdir -p $releaseDir/examples -for file in tests/*.cpp; do - if grep CppUnit $file >/dev/null; then - echo Skipping cppunit file $file - else - cp $file $releaseDir/examples - fi -done - -# Copy Makefile and README for examples. -cp tests/examples.Makefile $releaseDir/examples/Makefile -cp tests/examples.README $releaseDir/examples/README - -cd release -tar=$releaseName.tar -tar cvf $tar $releaseName -bzip2 $tar diff --git a/qpid/cpp/managementgen/Makefile.am b/qpid/cpp/managementgen/Makefile.am deleted file mode 100644 index e7a9d87eab..0000000000 --- a/qpid/cpp/managementgen/Makefile.am +++ /dev/null @@ -1,44 +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. -# -qmfpythondir = $(pythondir) -dist_bin_SCRIPTS = \ - qmf-gen - -pkgpyexec_qmfgendir = $(pythondir)/qmfgen -pkgpyexec_qmfgen_PYTHON = \ - qmfgen/__init__.py \ - qmfgen/generate.py \ - qmfgen/schema.py \ - qmfgen/management-types.xml - -pkgpyexec_qmfgentmpldir = $(pythondir)/qmfgen/templates -pkgpyexec_qmfgentmpl_PYTHON = \ - qmfgen/templates/Args.h \ - qmfgen/templates/Class.cpp \ - qmfgen/templates/Class.h \ - qmfgen/templates/CMakeLists.cmake \ - qmfgen/templates/Event.cpp \ - qmfgen/templates/Event.h \ - qmfgen/templates/Makefile.mk \ - qmfgen/templates/Package.cpp \ - qmfgen/templates/Package.h \ - qmfgen/templates/V2Package.cpp \ - qmfgen/templates/V2Package.h - -EXTRA_DIST = $(nobase_qmfpython_DATA) CMakeLists.txt diff --git a/qpid/cpp/managementgen/qmfgen/templates/Class.cpp b/qpid/cpp/managementgen/qmfgen/templates/Class.cpp index d3033db7e1..bb7bd66fc6 100644 --- a/qpid/cpp/managementgen/qmfgen/templates/Class.cpp +++ b/qpid/cpp/managementgen/qmfgen/templates/Class.cpp @@ -70,6 +70,16 @@ uint8_t /*MGEN:Class.NameCap*/::md5Sum[MD5_LEN] = /*MGEN:Class.NameCap*/::~/*MGEN:Class.NameCap*/ () { +/*MGEN:IF(Class.ExistPerThreadStats)*/ + for (int idx = 0; idx < maxThreads; idx++) + if (perThreadStatsArray[idx] != 0) + delete perThreadStatsArray[idx]; + delete[] perThreadStatsArray; +/*MGEN:ENDIF*/ +} + +void /*MGEN:Class.NameCap*/::debugStats (const std::string& comment) +{ /*MGEN:IF(Root.GenLogs)*/ bool logEnabled; QPID_LOG_TEST_CAT(trace, model, logEnabled); @@ -77,19 +87,14 @@ uint8_t /*MGEN:Class.NameCap*/::md5Sum[MD5_LEN] = { ::qpid::types::Variant::Map map; mapEncodeValues(map, false, true); - QPID_LOG_CAT(trace, model, "Mgmt delete " << className + QPID_LOG_CAT(trace, model, "Mgmt " << comment << ((comment!="")?(" "):("")) << className << ". id:" << getKey() << " Statistics: " << map); } /*MGEN:ENDIF*/ -/*MGEN:IF(Class.ExistPerThreadStats)*/ - for (int idx = 0; idx < maxThreads; idx++) - if (perThreadStatsArray[idx] != 0) - delete perThreadStatsArray[idx]; - delete[] perThreadStatsArray; -/*MGEN:ENDIF*/ } + namespace { const string NAME("name"); const string TYPE("type"); diff --git a/qpid/cpp/managementgen/qmfgen/templates/Class.h b/qpid/cpp/managementgen/qmfgen/templates/Class.h index cd43cef7f4..84fe3df5da 100644 --- a/qpid/cpp/managementgen/qmfgen/templates/Class.h +++ b/qpid/cpp/managementgen/qmfgen/templates/Class.h @@ -118,6 +118,8 @@ namespace qmf { /*MGEN:Root.ExternMethod*/ ~/*MGEN:Class.NameCap*/(); + void debugStats (const std::string& comment); + /*MGEN:Class.SetGeneralReferenceDeclaration*/ /*MGEN:Root.ExternMethod*/ static void registerSelf( diff --git a/qpid/cpp/managementgen/qmfgen/templates/Makefile.mk b/qpid/cpp/managementgen/qmfgen/templates/Makefile.mk deleted file mode 100644 index b9adb4a2d2..0000000000 --- a/qpid/cpp/managementgen/qmfgen/templates/Makefile.mk +++ /dev/null @@ -1,40 +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. -# -/*MGEN:commentPrefix=#*/ -/*MGEN:Root.Disclaimer*/ -/*MGEN:IF(Makefile.QpidBroker)*/ -/*MGEN:mgenDir=$(mgen_dir)*/ -/*MGEN:specDir=$(top_srcdir)/../specs*/ - -mgen_generator=/*MGEN:Makefile.GenSources*/ - -mgen_broker_cpp=/*MGEN:Makefile.GenCppFiles*/ - -# Header file install rules. -/*MGEN:Makefile.HeaderInstalls*/ -if GENERATE -$(srcdir)/managementgen.mk: $(mgen_generator) - $(mgen_cmd) - -$(mgen_generator): -endif -/*MGEN:ENDIF*/ - -qmfgen_sources=/*MGEN:Makefile.GeneratedFiles*/ - diff --git a/qpid/cpp/packaging/NSIS/Makefile.am b/qpid/cpp/packaging/NSIS/Makefile.am deleted file mode 100644 index 0ef6b1c7c7..0000000000 --- a/qpid/cpp/packaging/NSIS/Makefile.am +++ /dev/null @@ -1,21 +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. -# - -EXTRA_DIST = \ - qpid-icon.ico qpid-icon.png qpid-install-banner.bmp qpid-install-banner.png diff --git a/qpid/cpp/qpid-autotools-install b/qpid/cpp/qpid-autotools-install deleted file mode 100755 index dcd1c93902..0000000000 --- a/qpid/cpp/qpid-autotools-install +++ /dev/null @@ -1,224 +0,0 @@ -#!/bin/sh -# -# 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. -# - -# Written by Jim Meyering - -VERSION='2007-07-10 09:09' # UTC - -prog_name=`basename $0` -die () { echo "$prog_name: $*" >&2; exit 1; } - -tarballs=' - http://pkgconfig.freedesktop.org/releases/pkg-config-0.21.tar.gz - ftp://ftp.gnu.org/gnu/m4/m4-1.4.10.tar.gz - ftp://ftp.gnu.org/gnu/automake/automake-1.10.tar.gz - ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz - ftp://ftp.gnu.org/gnu/libtool/libtool-1.5.24.tar.gz -' - -usage() { - echo >&2 "\ -Usage: $0 [OPTION]... -Download, build, and install some tools. - -Options: - --prefix=PREFIX install tools under specified directory - --skip-check do not run "make check" (this can save 50+ min) - --help display this help and exit - -For example, to install programs into \$HOME/qpid-tools/bin, run this command: - - $prog_name --prefix=\$HOME/qpid-tools - -If you've already verified that your system/environment can build working -versions of these tools, you can make this script complete in just a -minute or two (rather than about an hour if you let all "make check" -tests run) by invoking it like this: - - $prog_name --prefix=\$HOME/qpid-tools --skip-check - -" -} - -# Get the listed tarballs into the current directory. -get_sources() -{ - case `wget --help` in - *'--no-cache'*) - WGET_COMMAND='wget -nv --no-cache';; - *'--cache=on/off'*) - WGET_COMMAND='wget -nv --cache=off';; - *'--non-verbose'*) - WGET_COMMAND='wget -nv';; - *) - die 'no wget program found; please install it and try again';; - esac - - # Download the each tar-ball along with its signature, if there is one. - pkgs= - for t in $(echo $tarballs); do - base=$(basename $t) - pkgs="$pkgs $base" - test -f $base || $WGET_COMMAND $t - - # pkg-config has no .sig file. - case $base in pkg-config*) continue;; esac - - test -f $base.sig || $WGET_COMMAND $t.sig - # Verify each signature. - gpg --quiet --verify --trust-model=always \ - --trusted-key=32419B785D0CDCFC \ - --trusted-key=3859C03B2E236E47 \ - --trusted-key=B93F60C6B5C4CE13 \ - --trusted-key=F382AE19F4850180 \ - $base.sig > /dev/null 2>&1 \ - || echo "info: not verifying GPG signature for $base" 1>&2 - done - - printf 'verifying package SHA1 checksums...' 1>&2 - sha1sum -c --warn --status <<EOF || die "checksum mismatch" -69f37c509a4757d747b6f4c091d209ab3984d62f autoconf-2.61.tar.gz -69dc02b083b9a609b28fc4db129fef6a83ed2339 automake-1.10.tar.gz -b4c994f1bf4a76d2b0c1d0a6f54d16598c15f3db libtool-1.5.24.tar.gz -26d47c893722d683308f5d9fc172a11d5b2ad8a9 m4-1.4.10.tar.gz -b2508ba8404cad46ec42f6f58cbca43ae59d715f pkg-config-0.21.tar.gz -EOF - printf 'ok\n' 1>&2 - echo $pkgs -} - -################################################################# -set -e - -# Parse options. - -make_check=yes -prefix= - -for option -do - case $option in - --help) usage; exit;; - --skip-check) make_check=no;; - --prefix=*) prefix=`expr "$option" : '--prefix=\(.*\)'`;; - *) die "$option: unknown option";; - esac -done - -test -n "$prefix" \ - || die "you must specify a --prefix" - -case $prefix in - /*) ;; - *) die 'invalid prefix: '"$prefix"': it must be an absolute name';; -esac - -# Don't run as root. -# Make sure id -u succeeds. -my_uid=`id -u` -test $? = 0 || { - echo "$0: cannot run \`id -u'" 1>&2 - (exit 1); exit 1 -} -test $my_uid = 0 && die "please don't run this program as root" - -# Ensure that prefix is not /usr/bin or /bin, /sbin, etc. -case $prefix in - /bin|/sbin|/usr/bin|/usr/sbin) - die "don't set PREFIX to a system directory";; - *) ;; -esac - -# Create a build directory, then cd into it for the rest.... -tmpdir=.build-auto-tools -mkdir -p $tmpdir -cd $tmpdir - -pkgs=$(get_sources) - -for pkg in $pkgs; do - echo building/installing $pkg... - dir=$(basename $pkg .tar.gz) - rm -rf dir - gzip -dc $pkg|tar xf - - cd $dir - ./configure CFLAGS=-O2 LDFLAGS=-s --prefix=$prefix > makerr-config 2>&1 - make -j1 > makerr-build 2>&1 - if test "$make_check" = yes; then - case $pkg in - automake*) expected_duration_minutes=40;; - autoconf*) expected_duration_minutes=15;; - # libtool*) expected_duration_minutes=3;; - *);; - esac - test -n "$expected_duration_minutes" \ - && echo "running 'make check' for $pkg; NB: this can take over" \ - "$expected_duration_minutes minutes" - case $pkg in - # In this package, the check-requires-private test fails. - # Change the Makefile so it skips that test. - pkg-config-0.21.tar.gz) - perl -pi.bak -e 's/check-requires-private //' check/Makefile;; - - esac - make -j1 check > makerr-check 2>&1 - fi - make -j1 install > makerr-install 2>&1 - echo done at $(date +%Y-%m-%d.%T) - cd .. -done - -# Without checks (and with existing tarballs), it takes just one minute. -# Including all checks, it takes nearly an hour on an AMD64/3400+ - -case $PKG_CONFIG_PATH in - $prefix/lib/pkgconfig:/usr/lib/pkgconfig) - echo 'Good! your PKG_CONFIG_PATH envvar is already set';; - *) cat <<EOF;; -************************************************************************** -Be sure that PKG_CONFIG_PATH is set in your environment, e.g., -PKG_CONFIG_PATH=$prefix/lib/pkgconfig:/usr/lib/pkgconfig -************************************************************************** -EOF -esac - -case $PATH in - "$prefix/bin:"*) echo 'Good! your PATH is fine';; - *) cat <<EOF;; -************************************************************************** -Be sure that "$prefix/bin" is earlier in your PATH than /bin, /usr/bin, etc. -************************************************************************** -EOF -esac - -cat <<EOF -************************************************************************** -You may want to remove the tool build directory: -rm -rf $tmpdir -************************************************************************** -EOF - -## Local Variables: -## eval: (add-hook 'write-file-hooks 'time-stamp) -## time-stamp-start: "VERSION='" -## time-stamp-format: "%:y-%02m-%02d %02H:%02M" -## time-stamp-time-zone: "UTC" -## time-stamp-end: "' # UTC" -## End: diff --git a/qpid/cpp/src/CMakeLists.txt b/qpid/cpp/src/CMakeLists.txt index dcbb17d1e0..e7cf72e745 100644 --- a/qpid/cpp/src/CMakeLists.txt +++ b/qpid/cpp/src/CMakeLists.txt @@ -26,6 +26,16 @@ foreach (r ${REQUIRE}) message(STATUS "Forcing ${r} to ${${r}_force}") endforeach(r) +# Capture specified C++ compiler (if any) +if (NOT ENV_CXX) + if (NOT "$ENV{CXX}" STREQUAL "") + set(CXX $ENV{CXX}) + else(NOT "$ENV{CXX}" STREQUAL "") + set(CXX ${CMAKE_CXX_COMPILER}) + endif(NOT "$ENV{CXX}" STREQUAL "") + set(ENV_CXX ${CXX} CACHE INTERNAL "C++ compiler specified in cmake environment") +endif (NOT ENV_CXX) + include(CheckFunctionExists) include(CheckIncludeFileCXX) include(CheckIncludeFiles) @@ -145,6 +155,13 @@ MACRO (add_msvc_version verProject verProjectType verProjectFileExt) endif (MSVC) ENDMACRO (add_msvc_version) +# Add a test to check the exported library API against expected API symbols +MACRO (add_api_test libname) + if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) + add_test(api_check_${libname} ${CMAKE_CURRENT_SOURCE_DIR}/check-abi "${ENV_CXX}" ${CMAKE_CURRENT_BINARY_DIR}/lib${libname}.so ${CMAKE_CURRENT_SOURCE_DIR}/lib${libname}-api-symbols.txt) + endif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) +ENDMACRO (add_api_test libname) + # # Install optional windows version settings. Override variables are specified in a file. @@ -263,6 +280,9 @@ if (ENABLE_VALGRIND AND NOT VALGRIND) message(STATUS "Can't locate the valgrind command; no run-time error detection") endif (ENABLE_VALGRIND AND NOT VALGRIND) +# Do not keep on linking against transitive library dependencies +set (CMAKE_LINK_INTERFACE_LIBRARIES "") + if (CMAKE_COMPILER_IS_GNUCXX) # Warnings: Enable as many as possible, keep the code clean. Please # do not disable warnings or remove -Werror without discussing on @@ -279,18 +299,24 @@ if (CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_SYSTEM_NAME STREQUAL SunOS) set (CATCH_UNDEFINED "") endif (CMAKE_SYSTEM_NAME STREQUAL SunOS) - set (COMPILER_FLAGS "-fvisibility-inlines-hidden") + set (COMPILER_FLAGS "-fvisibility-inlines-hidden -Wl,--as-needed") # gcc 4.1.2 on RHEL 5 needs -Wno-attributes to avoid an error that's fixed # in later gcc versions. execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) if (GCC_VERSION VERSION_EQUAL 4.1.2) + set (COMPILER_FLAGS "-Wl,--as-needed") message (STATUS "Cannot use -fvisibility=hidden on gcc 4.1.2") else (GCC_VERSION VERSION_EQUAL 4.1.2) - set (HIDE_SYMBOL_FLAGS "-fvisibility=hidden") + set (HIDE_SYMBOL_FLAGS "-fno-visibility-inlines-hidden -fvisibility=hidden") endif (GCC_VERSION VERSION_EQUAL 4.1.2) endif (CMAKE_COMPILER_IS_GNUCXX) +if (CMAKE_SYSTEM_NAME STREQUAL Linux) + set (QPID_LINKMAP ${CMAKE_CURRENT_SOURCE_DIR}/qpid.linkmap) + set (LINK_VERSION_SCRIPT_FLAG "-Wl,--version-script=${QPID_LINKMAP}") +endif (CMAKE_SYSTEM_NAME STREQUAL Linux) + if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro) set (COMPILER_FLAGS "-library=stlport4 -mt") set (WARNING_FLAGS "+w") @@ -301,9 +327,9 @@ endif (CMAKE_CXX_COMPILER_ID STREQUAL SunPro) if (CMAKE_SYSTEM_NAME STREQUAL Windows) # Allow MSVC user to select 'WinXP-SP3/Windows Server 2003' as build target version set (win32_winnt_default OFF) - if (MSVC) - set (win32_winnt_default ON) - endif (MSVC) + if (MSVC) + set (win32_winnt_default ON) + endif (MSVC) option(SET_WIN32_WINNT "In Windows-MSVC build: define _WIN32_WINNT=0x0502 to select target version: Windows XP with SP3" ${win32_winnt_default}) endif (CMAKE_SYSTEM_NAME STREQUAL Windows) @@ -356,7 +382,7 @@ endif (CMAKE_SYSTEM_NAME STREQUAL Windows) # where Boost 1.45 is supported, or we can just accept some versions using # the Additional_versions variable. if (NOT DEFINED Boost_ADDITIONAL_VERSIONS) - set (Boost_ADDITIONAL_VERSIONS + set (Boost_ADDITIONAL_VERSIONS "1.45" "1.45.0" "1.46" "1.46.0" "1.47" "1.47.0" "1.48" "1.48.0" "1.49" "1.49.0" "1.50" "1.50.0" "1.51" "1.51.0" "1.52" "1.52.0" "1.53" "1.53.0") @@ -513,44 +539,49 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/../include ) link_directories( ${Boost_LIBRARY_DIRS} ) -CHECK_LIBRARY_EXISTS (rt clock_gettime "" CLOCK_GETTIME_IN_RT) -if (NOT CLOCK_GETTIME_IN_RT) - CHECK_FUNCTION_EXISTS (clock_gettime QPID_HAS_CLOCK_GETTIME) -else (NOT CLOCK_GETTIME_IN_RT) - set(CMAKE_REQUIRED_LIBS ${CMAKE_REQUIRED_LIBS} rt) - set(QPID_HAS_CLOCK_GETTIME YES CACHE BOOL "Platform has clock_gettime") -endif (NOT CLOCK_GETTIME_IN_RT) - -# Check for header file for dtrace static probes -check_include_files(sys/sdt.h HAVE_SYS_SDT_H) -if (HAVE_SYS_SDT_H) - set(probes_default ON) -endif (HAVE_SYS_SDT_H) -option(BUILD_PROBES "Build with DTrace/systemtap static probes" ${probes_default}) -if (NOT BUILD_PROBES) - set (HAVE_SYS_SDT_H 0) -endif (NOT BUILD_PROBES) - -# Check for poll/epoll header files -check_include_files(sys/poll.h HAVE_POLL) -check_include_files(sys/epoll.h HAVE_EPOLL) - -# Set default poller implementation (check from general to specific to allow overriding) -if (HAVE_POLL) - set(poller_default poll) -endif (HAVE_POLL) -if (HAVE_EPOLL) - set(poller_default epoll) -endif (HAVE_EPOLL) -set(POLLER ${poller_default} CACHE STRING "Poller implementation (poll/epoll)") - -# If not windows ensure that we have uuid library +# These dependencies aren't found on windows if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) + # Ensure we have clock_gettime + CHECK_FUNCTION_EXISTS (clock_gettime CLOCK_GETTIME_IN_LIBC) + if (NOT CLOCK_GETTIME_IN_LIBC) + CHECK_LIBRARY_EXISTS (rt clock_gettime "" CLOCK_GETTIME_IN_RT) + if (CLOCK_GETTIME_IN_RT) + set(clock_gettime_LIB "rt") + else () + message(FATAL_ERROR "Cannot find clock_gettime()") + endif (CLOCK_GETTIME_IN_RT) + endif (NOT CLOCK_GETTIME_IN_LIBC) + + # Ensure we have uuid library CHECK_LIBRARY_EXISTS (uuid uuid_compare "" HAVE_UUID) CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) if (NOT HAVE_UUID AND NOT HAVE_UUID_H) message(FATAL_ERROR "Uuid library and/or header file not found") endif (NOT HAVE_UUID AND NOT HAVE_UUID_H) + set (uuid_LIB "uuid") + + # Check for header file for dtrace static probes + check_include_files(sys/sdt.h HAVE_SYS_SDT_H) + if (HAVE_SYS_SDT_H) + set(probes_default ON) + endif (HAVE_SYS_SDT_H) + option(BUILD_PROBES "Build with DTrace/systemtap static probes" ${probes_default}) + if (NOT BUILD_PROBES) + set (HAVE_SYS_SDT_H 0) + endif (NOT BUILD_PROBES) + + # Check for poll/epoll header files + check_include_files(sys/poll.h HAVE_POLL) + check_include_files(sys/epoll.h HAVE_EPOLL) + + # Set default poller implementation (check from general to specific to allow overriding) + if (HAVE_POLL) + set(poller_default poll) + endif (HAVE_POLL) + if (HAVE_EPOLL) + set(poller_default epoll) + endif (HAVE_EPOLL) + set(POLLER ${poller_default} CACHE STRING "Poller implementation (poll/epoll)") endif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) # See if Cyrus SASL is desired and available @@ -578,7 +609,10 @@ if (BUILD_SASL) qpid/sys/cyrus/CyrusSecurityLayer.h qpid/sys/cyrus/CyrusSecurityLayer.cpp ) - set(qpidcommon_sasl_lib sasl2) + set(sasl_LIB sasl2) +else (BUILD_SASL) + set(HAVE_SASL OFF) + set(BROKER_SASL_NAME "qpidd" CACHE STRING "SASL app name for the qpid broker") endif (BUILD_SASL) # Optional SSL/TLS support. Requires Netscape Portable Runtime on Linux. @@ -604,27 +638,23 @@ if (BUILD_SSL) set (sslcommon_SOURCES qpid/sys/windows/SslAsynchIO.cpp ) + set (ssl_SOURCES qpid/broker/windows/SslProtocolFactory.cpp ) + set (sslconnector_SOURCES qpid/client/windows/SslConnector.cpp ) - set (windows_ssl_libs Secur32.lib) - set (windows_ssl_server_libs Crypt32.lib) + set (ssl_INCLUDES "") + set (ssl_LIBDIRS "") + set (ssl_LIBS Secur32.lib) + set (ssl_server_LIBS Crypt32.lib Secur32.lib) else (CMAKE_SYSTEM_NAME STREQUAL Windows) if (NOT NSS_FOUND) message(FATAL_ERROR "nss/nspr not found, required for ssl support") endif (NOT NSS_FOUND) - foreach(f ${NSS_CFLAGS}) - set (NSS_COMPILE_FLAGS "${NSS_COMPILE_FLAGS} ${f}") - endforeach(f) - - foreach(f ${NSS_LDFLAGS}) - set (NSS_LINK_FLAGS "${NSS_LINK_FLAGS} ${f}") - endforeach(f) - set (sslcommon_SOURCES qpid/sys/ssl/check.h qpid/sys/ssl/check.cpp @@ -643,14 +673,17 @@ if (BUILD_SSL) qpid/messaging/amqp/SslTransport.cpp ) - set_source_files_properties ( - ${sslcommon_SOURCES} - ${ssl_SOURCES} - ${sslconnector_SOURCES} - PROPERTIES - COMPILE_FLAGS "${NSS_COMPILE_FLAGS}" - ) + set (ssl_INCLUDES "${NSS_INCLUDE_DIRS}") + set (ssl_LIBDIRS "${NSS_LIBRARY_DIRS}") + set (ssl_LIBS "${NSS_LIBRARIES}") + set (ssl_server_LIBS "${NSS_LIBRARIES}") endif (CMAKE_SYSTEM_NAME STREQUAL Windows) + + # Add include directories and link directories for NSS + # unfortunately this doesn't get done automatically for + # libraries detected by FindPkgConfig + include_directories(${ssl_INCLUDES}) + link_directories(${ssl_LIBDIRS}) endif (BUILD_SSL) # See if XML Exchange is desired and prerequisites are available @@ -690,7 +723,7 @@ if (BUILD_XML) qpid/xml/XmlExchange.cpp qpid/xml/XmlExchange.h qpid/xml/XmlExchangePlugin.cpp) - target_link_libraries (xml xerces-c xqilla qpidbroker pthread) + target_link_libraries (xml xerces-c xqilla qpidbroker qpidcommon) set_target_properties (xml PROPERTIES PREFIX "" COMPILE_DEFINITIONS _IN_QPID_BROKER @@ -744,16 +777,15 @@ if (BUILD_HA) qpid/ha/BrokerReplicator.h qpid/ha/ConnectionObserver.cpp qpid/ha/ConnectionObserver.h + qpid/ha/Event.cpp + qpid/ha/Event.h qpid/ha/FailoverExchange.cpp qpid/ha/FailoverExchange.h qpid/ha/HaBroker.cpp qpid/ha/HaBroker.h qpid/ha/HaPlugin.cpp - qpid/ha/hash.h qpid/ha/IdSetter.h qpid/ha/QueueSnapshot.h - qpid/ha/makeMessage.cpp - qpid/ha/makeMessage.h qpid/ha/Membership.cpp qpid/ha/Membership.h qpid/ha/Primary.cpp @@ -773,18 +805,22 @@ if (BUILD_HA) qpid/ha/StandAlone.h qpid/ha/StatusCheck.cpp qpid/ha/StatusCheck.h + qpid/ha/PrimaryTxObserver.cpp + qpid/ha/PrimaryTxObserver.h qpid/ha/types.cpp + qpid/ha/TxReplicator.cpp + qpid/ha/TxReplicator.h qpid/ha/types.h ) add_library (ha MODULE ${ha_SOURCES}) - set_target_properties (ha PROPERTIES PREFIX "" COMPILE_DEFINITIONS _IN_QPID_BROKER) - target_link_libraries (ha qpidtypes qpidcommon qpidbroker qpidmessaging) - if (CMAKE_COMPILER_IS_GNUCXX) - set_target_properties (ha PROPERTIES - PREFIX "" - LINK_FLAGS -Wl,--no-undefined) - endif (CMAKE_COMPILER_IS_GNUCXX) + target_link_libraries (ha + qpidtypes qpidcommon qpidbroker qpidmessaging + "${Boost_PROGRAM_OPTIONS_LIBRARY}") + set_target_properties (ha PROPERTIES + PREFIX "" + COMPILE_DEFINITIONS _IN_QPID_BROKER + LINK_FLAGS "${CATCH_UNDEFINED}") install (TARGETS ha DESTINATION ${QPIDD_MODULE_DIR} COMPONENT ${QPID_COMPONENT_BROKER}) @@ -799,7 +835,7 @@ include (amqp.cmake) # Check for syslog capabilities not present on all systems check_symbol_exists (LOG_AUTHPRIV "sys/syslog.h" HAVE_LOG_AUTHPRIV) check_symbol_exists (LOG_FTP "sys/syslog.h" HAVE_LOG_FTP) - + # Set default Memory Status module (Null implementation) set (qpid_memstat_module qpid/sys/MemStat.cpp @@ -834,20 +870,20 @@ if (CMAKE_SYSTEM_NAME STREQUAL Windows) ) set (qpidcommon_platform_LIBS - ${Boost_THREAD_LIBRARY} ${windows_ssl_libs} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_SYSTEM_LIBRARY} ws2_32 ) + ${Boost_THREAD_LIBRARY} + ${Boost_DATE_TIME_LIBRARY} + ${Boost_SYSTEM_LIBRARY} + ws2_32 + ) + set (qpidbroker_platform_SOURCES qpid/broker/windows/BrokerDefaults.cpp qpid/broker/windows/SaslAuthenticator.cpp ) - set (qpidbroker_platform_LIBS - ${windows_ssl_libs} ${windows_ssl_server_libs} - ) + set (qpidclient_platform_SOURCES qpid/client/windows/ClientDllMain.cpp ) - set (qpidclient_platform_LIBS - ${windows_ssl_libs} - ) set (qpidd_platform_SOURCES windows/QpiddBroker.cpp @@ -885,7 +921,7 @@ else (CMAKE_SYSTEM_NAME STREQUAL Windows) # On Linux override memory status module set (qpid_memstat_module qpid/sys/posix/MemStat.cpp - ) + ) endif (CMAKE_SYSTEM_NAME STREQUAL Linux) if (CMAKE_SYSTEM_NAME STREQUAL SunOS) @@ -908,8 +944,7 @@ else (CMAKE_SYSTEM_NAME STREQUAL Windows) set (qpidtypes_platform_SOURCES) set (qpidtypes_platform_LIBS - uuid - ${Boost_SYSTEM_LIBRARY} + "${uuid_LIB}" ) set (qpidcommon_platform_SOURCES @@ -934,9 +969,11 @@ else (CMAKE_SYSTEM_NAME STREQUAL Windows) ${qpid_system_module} ${qpid_poller_module} ) + set (qpidcommon_platform_LIBS - ${Boost_PROGRAM_OPTIONS_LIBRARY} - ${CMAKE_DL_LIBS} + "${CMAKE_DL_LIBS}" + "${clock_gettime_LIB}" + "${uuid_LIB}" ) set (qpidbroker_platform_SOURCES @@ -977,6 +1014,7 @@ set (qpidcommon_SOURCES qpid/StringUtils.cpp qpid/Url.cpp qpid/UrlArray.cpp + qpid/NullSaslClient.cpp qpid/NullSaslServer.cpp qpid/amqp_0_10/SessionHandler.cpp qpid/framing/AccumulatedAck.cpp @@ -1024,12 +1062,16 @@ set (qpidcommon_SOURCES qpid/amqp_0_10/Codecs.cpp qpid/amqp/CharSequence.h qpid/amqp/CharSequence.cpp + qpid/amqp/DataBuilder.h + qpid/amqp/DataBuilder.cpp qpid/amqp/Decoder.h qpid/amqp/Decoder.cpp qpid/amqp/Descriptor.h qpid/amqp/Descriptor.cpp qpid/amqp/Encoder.h qpid/amqp/Encoder.cpp + qpid/amqp/ListBuilder.h + qpid/amqp/ListBuilder.cpp qpid/amqp/MapHandler.h qpid/amqp/MapEncoder.h qpid/amqp/MapEncoder.cpp @@ -1060,20 +1102,17 @@ set (qpidcommon_SOURCES add_msvc_version (qpidcommon library dll) add_library (qpidcommon SHARED ${qpidcommon_SOURCES}) -if (CLOCK_GETTIME_IN_RT) - set (qpidcommon_platform_LIBS ${qpidcommon_platform_LIBS} rt) -endif (CLOCK_GETTIME_IN_RT) -# Not all platforms have NSS_LINK_FLAGS -if (NSS_LINK_FLAGS) - set (qpidcommon_LINK_FLAGS LINK_FLAGS ${NSS_LINK_FLAGS}) -endif (NSS_LINK_FLAGS) + target_link_libraries (qpidcommon qpidtypes ${qpidcommon_platform_LIBS} - ${qpidcommon_sasl_lib}) + ${Boost_PROGRAM_OPTIONS_LIBRARY} + "${sasl_LIB}" + ${ssl_LIBS}) + set_target_properties (qpidcommon PROPERTIES - VERSION ${qpidcommon_version} - SOVERSION ${qpidcommon_version_major} - ${qpidcommon_LINK_FLAGS}) + VERSION ${qpidcommon_version} + SOVERSION ${qpidcommon_version_major}) + install (TARGETS qpidcommon DESTINATION ${QPID_INSTALL_LIBDIR} COMPONENT ${QPID_COMPONENT_COMMON}) @@ -1085,17 +1124,26 @@ set(qpidtypes_SOURCES qpid/types/Variant.cpp ${qpidtypes_platform_SOURCES} ) +set_source_files_properties( + ${qpidtypes_SOURCES} + PROPERTIES + COMPILE_FLAGS "${HIDE_SYMBOL_FLAGS}") + add_msvc_version (qpidtypes library dll) add_library(qpidtypes SHARED ${qpidtypes_SOURCES}) target_link_libraries(qpidtypes ${qpidtypes_platform_LIBS}) -set_target_properties (qpidtypes PROPERTIES +set_target_properties (qpidtypes PROPERTIES + LINK_FLAGS "${HIDE_SYMBOL_FLAGS} ${LINK_VERSION_SCRIPT_FLAG}" VERSION ${qpidtypes_version} SOVERSION ${qpidtypes_version_major}) + install(TARGETS qpidtypes DESTINATION ${QPID_INSTALL_LIBDIR} COMPONENT ${QPID_COMPONENT_COMMON}) install_pdb (qpidtypes ${QPID_COMPONENT_COMMON}) +add_api_test(qpidtypes) + set (qpidclient_SOURCES ${rgen_client_srcs} ${qpidclient_platform_SOURCES} @@ -1137,9 +1185,15 @@ set (qpidclient_SOURCES add_msvc_version (qpidclient library dll) add_library (qpidclient SHARED ${qpidclient_SOURCES}) -target_link_libraries (qpidclient qpidcommon ${qpidclient_platform_LIBS}) -set_target_properties (qpidclient PROPERTIES VERSION ${qpidclient_version} -SOVERSION ${qpidclient_version_major}) + +target_link_libraries (qpidclient qpidcommon + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${ssl_LIBS}) + +set_target_properties (qpidclient PROPERTIES + VERSION ${qpidclient_version} + SOVERSION ${qpidclient_version_major}) + install (TARGETS qpidclient DESTINATION ${QPID_INSTALL_LIBDIR} COMPONENT ${QPID_COMPONENT_CLIENT}) @@ -1202,27 +1256,25 @@ set (qpidmessaging_SOURCES qpid/messaging/amqp/EncodedMessage.h qpid/messaging/amqp/EncodedMessage.cpp ) +set_source_files_properties( + ${qpidmessaging_SOURCES} + PROPERTIES + COMPILE_FLAGS "${HIDE_SYMBOL_FLAGS}") + add_msvc_version (qpidmessaging library dll) add_library (qpidmessaging SHARED ${qpidmessaging_SOURCES}) -target_link_libraries (qpidmessaging qpidclient) -set_target_properties (qpidmessaging PROPERTIES - VERSION ${qpidmessaging_version} +target_link_libraries (qpidmessaging qpidtypes qpidclient qpidcommon) +set_target_properties (qpidmessaging PROPERTIES + LINK_FLAGS "${HIDE_SYMBOL_FLAGS} ${LINK_VERSION_SCRIPT_FLAG}" + VERSION ${qpidmessaging_version} SOVERSION ${qpidmessaging_version_major}) install (TARGETS qpidmessaging DESTINATION ${QPID_INSTALL_LIBDIR} COMPONENT ${QPID_COMPONENT_CLIENT}) install_pdb (qpidmessaging ${QPID_COMPONENT_CLIENT}) -# Released source artifacts from Apache have the generated headers included in -# the source tree, not the binary tree. So don't attempt to grab them when -# they're not supposed to be there. -if (NOT QPID_GENERATED_HEADERS_IN_SOURCE) - install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../include/qpid - DESTINATION ${QPID_INSTALL_INCLUDEDIR} - COMPONENT ${QPID_COMPONENT_CLIENT_INCLUDE}) -endif (NOT QPID_GENERATED_HEADERS_IN_SOURCE) - +add_api_test(qpidmessaging) if (MSVC) # Install the DtcPlugin project and call it qpidxarm. @@ -1312,6 +1364,7 @@ set (qpidbroker_SOURCES qpid/broker/SelectorToken.cpp qpid/broker/SelectorValue.h qpid/broker/SelectorValue.cpp + qpid/broker/SelfDestructQueue.cpp qpid/broker/SemanticState.h qpid/broker/SemanticState.cpp qpid/broker/SessionAdapter.cpp @@ -1337,11 +1390,17 @@ set (qpidbroker_SOURCES ) add_msvc_version (qpidbroker library dll) add_library (qpidbroker SHARED ${qpidbroker_SOURCES}) -target_link_libraries (qpidbroker qpidcommon ${qpidbroker_platform_LIBS}) -set_target_properties (qpidbroker PROPERTIES + +target_link_libraries (qpidbroker qpidcommon qpidtypes + "${Boost_PROGRAM_OPTIONS_LIBRARY}" + "${sasl_LIB}" + ${ssl_server_LIBS}) + +set_target_properties (qpidbroker PROPERTIES VERSION ${qpidbroker_version} - SOVERSION ${qpidbroker_version_major} + SOVERSION ${qpidbroker_version_major} COMPILE_DEFINITIONS _IN_QPID_BROKER) + if (MSVC) set_target_properties (qpidbroker PROPERTIES COMPILE_FLAGS /wd4290) endif (MSVC) @@ -1373,30 +1432,6 @@ if (UNIX) install (CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/${QPID_LOCALSTATE_DIR}/spool/qpidd)") endif (UNIX) -set (qmf_SOURCES - qpid/agent/ManagementAgentImpl.cpp - qpid/agent/ManagementAgentImpl.h - ) -set (qmf_HEADERS - ../include/qpid/agent/ManagementAgent.h - ../include/qpid/agent/QmfAgentImportExport.h - ../include/qmf/BrokerImportExport.h - ) - -add_msvc_version (qmf library dll) -add_library (qmf SHARED ${qmf_SOURCES}) -target_link_libraries (qmf qmfengine) -set_target_properties (qmf PROPERTIES - VERSION ${qmf_version} - SOVERSION ${qmf_version_major}) -install (TARGETS qmf OPTIONAL - DESTINATION ${QPID_INSTALL_LIBDIR} - COMPONENT ${QPID_COMPONENT_QMF}) -install (FILES ${qmf_HEADERS} - DESTINATION ${QPID_INSTALL_INCLUDEDIR}/qpid/agent - COMPONENT ${QPID_COMPONENT_QMF}) -install_pdb (qmf ${QPID_COMPONENT_QMF}) - if (NOT WIN32) set (qmf2_platform_headers ../include/qmf/posix/EventNotifier.h @@ -1477,7 +1512,7 @@ endif (NOT WIN32) add_library (qmf2 SHARED ${qmf2_SOURCES}) target_link_libraries (qmf2 qpidmessaging qpidtypes qpidclient qpidcommon) set_target_properties (qmf2 PROPERTIES - VERSION ${qmf2_version} + VERSION ${qmf2_version} SOVERSION ${qmf2_version_major}) install (TARGETS qmf2 OPTIONAL DESTINATION ${QPID_INSTALL_LIBDIR} @@ -1487,111 +1522,6 @@ endif (NOT WIN32) COMPONENT ${QPID_COMPONENT_QMF}) install_pdb (qmf2 ${QPID_COMPONENT_QMF}) -set (qmfengine_SOURCES - qmf/engine/Agent.cpp - qmf/engine/BrokerProxyImpl.cpp - qmf/engine/BrokerProxyImpl.h - qmf/engine/ConnectionSettingsImpl.cpp - qmf/engine/ConnectionSettingsImpl.h - qmf/engine/ConsoleImpl.cpp - qmf/engine/ConsoleImpl.h - qmf/engine/EventImpl.cpp - qmf/engine/EventImpl.h - qmf/engine/MessageImpl.cpp - qmf/engine/MessageImpl.h - qmf/engine/ObjectIdImpl.cpp - qmf/engine/ObjectIdImpl.h - qmf/engine/ObjectImpl.cpp - qmf/engine/ObjectImpl.h - qmf/engine/Protocol.cpp - qmf/engine/Protocol.h - qmf/engine/QueryImpl.cpp - qmf/engine/QueryImpl.h - qmf/engine/SequenceManager.cpp - qmf/engine/SequenceManager.h - qmf/engine/SchemaImpl.cpp - qmf/engine/SchemaImpl.h - qmf/engine/ValueImpl.cpp - qmf/engine/ValueImpl.h - ) - -set (qmfengine_HEADERS - ../include/qmf/engine/Agent.h - ../include/qmf/engine/ConnectionSettings.h - ../include/qmf/engine/Console.h - ../include/qmf/engine/Event.h - ../include/qmf/engine/Message.h - ../include/qmf/engine/Object.h - ../include/qmf/engine/ObjectId.h - ../include/qmf/engine/QmfEngineImportExport.h - ../include/qmf/engine/Query.h - ../include/qmf/engine/ResilientConnection.h - ../include/qmf/engine/Schema.h - ../include/qmf/engine/Typecode.h - ../include/qmf/engine/Value.h - ) -install (FILES ${qmfengine_HEADERS} - DESTINATION ${QPID_INSTALL_INCLUDEDIR}/qmf/engine - COMPONENT ${QPID_COMPONENT_QMF}) - -if (NOT WIN32) - list(APPEND qmfengine_SOURCES qmf/engine/ResilientConnection.cpp) -endif (NOT WIN32) -add_msvc_version (qmfengine library dll) - -add_library (qmfengine SHARED ${qmfengine_SOURCES}) -target_link_libraries (qmfengine qpidclient) -set_target_properties (qmfengine PROPERTIES - VERSION ${qmfengine_version} - SOVERSION ${qmfengine_version_major}) -install (TARGETS qmfengine OPTIONAL - DESTINATION ${QPID_INSTALL_LIBDIR} - COMPONENT ${QPID_COMPONENT_QMF}) -install_pdb (qmfengine ${QPID_COMPONENT_QMF}) - -set (qmfconsole_SOURCES - qpid/console/Agent.cpp - qpid/console/Broker.cpp - qpid/console/ClassKey.cpp - qpid/console/Event.cpp - qpid/console/Object.cpp - qpid/console/ObjectId.cpp - qpid/console/Package.cpp - qpid/console/Schema.cpp - qpid/console/SequenceManager.cpp - qpid/console/SessionManager.cpp - qpid/console/Value.cpp - ) -set (qmfconsole_HEADERS - ../include/qpid/console/Agent.h - ../include/qpid/console/Broker.h - ../include/qpid/console/ClassKey.h - ../include/qpid/console/ConsoleImportExport.h - ../include/qpid/console/ConsoleListener.h - ../include/qpid/console/Event.h - ../include/qpid/console/Object.h - ../include/qpid/console/ObjectId.h - ../include/qpid/console/Package.h - ../include/qpid/console/Schema.h - ../include/qpid/console/SequenceManager.h - ../include/qpid/console/SessionManager.h - ../include/qpid/console/Value.h - ) -add_msvc_version (qmfconsole library dll) -add_library (qmfconsole SHARED ${qmfconsole_SOURCES}) -target_link_libraries (qmfconsole qpidclient) -set_target_properties (qmfconsole PROPERTIES - VERSION ${qmfconsole_version} - SOVERSION ${qmfconsole_version_major}) -install (TARGETS qmfconsole - DESTINATION ${QPID_INSTALL_LIBDIR} - COMPONENT ${QPID_COMPONENT_QMF}) -install (FILES ${qmfconsole_HEADERS} - DESTINATION ${QPID_INSTALL_INCLUDEDIR}/qpid/console - COMPONENT ${QPID_COMPONENT_QMF}) -install_pdb (qmfconsole ${QPID_COMPONENT_QMF}) - - # # Legacy store # diff --git a/qpid/cpp/src/Makefile.am b/qpid/cpp/src/Makefile.am deleted file mode 100644 index 8a98cea1ee..0000000000 --- a/qpid/cpp/src/Makefile.am +++ /dev/null @@ -1,1119 +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. -# - -SUBDIRS = . tests - -# The Windows-only sources are not compiled using this Makefile, but -# are listed here to ensure they're included in releases. They are built -# using Visual Studio solutions/projects. -windows_dist = \ - qpid/client/windows/SaslFactory.cpp \ - qpid/client/windows/SslConnector.cpp \ - qpid/client/windows/ClientDllMain.cpp \ - qpid/log/windows/SinkOptions.cpp \ - qpid/log/windows/SinkOptions.h \ - ../include/qpid/sys/windows/check.h \ - qpid/sys/MemStat.cpp \ - qpid/sys/windows/AsynchIO.cpp \ - qpid/sys/windows/AsynchIoResult.h \ - ../include/qpid/sys/windows/Condition.h \ - qpid/sys/windows/FileSysDir.cpp \ - ../include/qpid/sys/windows/IntegerTypes.h \ - qpid/sys/windows/IocpPoller.cpp \ - qpid/sys/windows/IOHandle.cpp \ - qpid/sys/windows/IoHandlePrivate.h \ - qpid/sys/windows/LockFile.cpp \ - qpid/sys/windows/MemoryMappedFile.cpp \ - qpid/sys/windows/mingw32_compat.h \ - qpid/sys/windows/PollableCondition.cpp \ - qpid/sys/windows/PipeHandle.cpp \ - ../include/qpid/sys/windows/Mutex.h \ - qpid/sys/windows/QpidDllMain.h \ - qpid/sys/windows/Shlib.cpp \ - qpid/sys/windows/SocketAddress.cpp \ - qpid/sys/windows/SslAsynchIO.cpp \ - qpid/sys/windows/SslAsynchIO.h \ - qpid/sys/windows/StrError.cpp \ - qpid/sys/windows/SystemInfo.cpp \ - qpid/sys/windows/Thread.cpp \ - qpid/sys/windows/Time.cpp \ - ../include/qpid/sys/windows/Time.h \ - qpid/sys/windows/uuid.cpp \ - qpid/sys/windows/uuid.h \ - qpid/sys/windows/WinSocket.cpp \ - qpid/sys/windows/WinSocket.h \ - windows/QpiddBroker.cpp \ - windows/SCM.h \ - windows/SCM.cpp \ - qpid/broker/windows/BrokerDefaults.cpp \ - qpid/broker/windows/SaslAuthenticator.cpp \ - qpid/broker/windows/SslProtocolFactory.cpp \ - qpid/messaging/HandleInstantiator.cpp \ - windows/resources/template-resource.rc \ - windows/resources/version-resource.h \ - windows/resources/qpid-icon.ico - -EXTRA_DIST= $(platform_dist) $(rgen_srcs) $(windows_dist) - -# Define variables that are be appended to by this file and included .mk files. -nobase_include_HEADERS = -libqpidcommon_la_SOURCES = -pkgconfig_DATA = - -## Generated code - -# Note: generated soure and makefiles included in distribution so a -# distribution can be built without code generation tools and XML -# sources. - -# This phony target is needed by generated makefile fragments: -force: - -if GENERATE - -# AMQP_FINAL_XML is defined in ../configure.ac -amqp_0_10_xml=@AMQP_FINAL_XML@ -specs=$(amqp_0_10_xml) - -# Ruby generator. -rgen_dir=$(top_srcdir)/rubygen -rgen_cmd=ruby -I $(rgen_dir) $(rgen_dir)/generate . ../include $(specs) all - -$(rgen_srcs) $(srcdir)/rubygen.mk: rgen.timestamp -rgen.timestamp: $(rgen_generator) $(specs) - $(rgen_cmd) $(srcdir)/rubygen.mk && touch $@ -$(rgen_generator): - -# The CMake version is needed for dist -$(srcdir)/rubygen.cmake: $(rgen_generator) $(specs) - $(rgen_cmd) $(srcdir)/rubygen.cmake - -# Management generator. -mgen_dir=$(top_srcdir)/managementgen -mgen_xml=$(top_srcdir)/../specs/management-schema.xml \ - $(srcdir)/qpid/acl/management-schema.xml \ - $(srcdir)/qpid/ha/management-schema.xml \ - $(srcdir)/qpid/legacystore/management-schema.xml -mgen_cmd=$(mgen_dir)/qmf-gen -m $(srcdir)/managementgen.mk \ - -c $(srcdir)/managementgen.cmake -q -b -l -o qmf \ - $(mgen_xml) - -$(srcdir)/managementgen.mk $(mgen_broker_cpp) $(dist_qpid_management_HEADERS): mgen.timestamp -mgen.timestamp: $(mgen_generator) $(mgen_xml) - $(mgen_cmd); touch $@ -$(mgen_generator): - -endif # GENERATE - -include $(srcdir)/rubygen.mk -include $(srcdir)/managementgen.mk - -## Compiler flags -AM_CXXFLAGS = $(WARNING_CFLAGS) -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(srcdir) -I=$(builddir) - -# -# Destination for intalled programs and tests defined here -# -qpidexecdir = $(libexecdir)/qpid -qpidexec_PROGRAMS = -qpidexec_SCRIPTS = -qpidtestdir = $(qpidexecdir)/tests -qpidtest_PROGRAMS = -qpidtest_SCRIPTS = -tmoduleexecdir = $(libdir)/qpid/tests -tmoduleexec_LTLIBRARIES= - -BROKER_CXXFLAGS = -D_IN_QPID_BROKER - -## Automake macros to build libraries and executables. -qpidd_CXXFLAGS = $(AM_CXXFLAGS) $(BROKER_CXXFLAGS) -DQPIDD_MODULE_DIR=\"$(dmoduleexecdir)\" -DQPIDD_CONF_FILE=\"$(sysconfdir)/qpidd.conf\" -DQPIDC_CONF_FILE=\"$(confdir)/qpidc.conf\" -libqpidcommon_la_CXXFLAGS = $(AM_CXXFLAGS) -libqpidbroker_la_CXXFLAGS = $(AM_CXXFLAGS) $(BROKER_CXXFLAGS) -libqpidclient_la_CXXFLAGS = $(AM_CXXFLAGS) -DQPIDC_MODULE_DIR=\"$(cmoduleexecdir)\" -DQPIDC_CONF_FILE=\"$(confdir)/qpidc.conf\" - -qpidd_LDADD = \ - libqpidbroker.la \ - libqpidcommon.la \ - -lboost_program_options - -posix_qpidd_src = posix/QpiddBroker.cpp - -sbin_PROGRAMS = qpidd -qpidd_SOURCES = qpidd.cpp qpidd.h $(posix_qpidd_src) - -## Platform specific code. - -# Posix-specific code -libqpidcommon_la_SOURCES += \ - qpid/log/posix/SinkOptions.cpp \ - qpid/sys/posix/IOHandle.cpp \ - qpid/sys/posix/BSDSocket.cpp \ - qpid/sys/posix/BSDSocket.h \ - qpid/sys/posix/SocketAddress.cpp \ - qpid/sys/posix/AsynchIO.cpp \ - qpid/sys/posix/FileSysDir.cpp \ - qpid/sys/posix/LockFile.cpp \ - qpid/sys/posix/MemoryMappedFile.cpp \ - qpid/sys/posix/Time.cpp \ - qpid/sys/posix/Thread.cpp \ - qpid/sys/posix/Shlib.cpp \ - qpid/sys/posix/MemStat.cpp \ - qpid/sys/posix/Mutex.cpp \ - qpid/sys/posix/Fork.cpp \ - qpid/sys/posix/StrError.cpp \ - qpid/sys/posix/PollableCondition.cpp \ - qpid/sys/posix/PidFile.h \ - qpid/sys/posix/PipeHandle.cpp \ - qpid/log/posix/SinkOptions.h \ - qpid/sys/posix/Fork.h - -nobase_include_HEADERS += \ - ../include/qpid/sys/posix/Condition.h \ - ../include/qpid/sys/posix/IntegerTypes.h \ - ../include/qpid/sys/posix/Mutex.h \ - ../include/qpid/sys/posix/PrivatePosix.h \ - ../include/qpid/sys/posix/Time.h \ - ../include/qpid/sys/posix/check.h - -if USE_EPOLL - poller = qpid/sys/epoll/EpollPoller.cpp -endif - -if USE_POLL - poller = qpid/sys/posix/PosixPoller.cpp -endif - -if USE_ECF - poller = qpid/sys/solaris/ECFPoller.cpp -endif - -if SUNOS - systeminfo = qpid/sys/solaris/SystemInfo.cpp -else - systeminfo = qpid/sys/posix/SystemInfo.cpp -endif - -libqpidcommon_la_SOURCES += $(poller) $(systeminfo) - -posix_broker_src = \ - qpid/broker/posix/BrokerDefaults.cpp \ - qpid/broker/posix/SocketFDPlugin.cpp - - -lib_LTLIBRARIES = libqpidtypes.la libqpidcommon.la libqpidbroker.la libqpidclient.la libqpidmessaging.la - - -# Definitions for client and daemon plugins -PLUGINLDFLAGS=-no-undefined -module -avoid-version -confdir=$(sysconfdir)/qpid -dmoduleexecdir=$(libdir)/qpid/daemon -cmoduleexecdir=$(libdir)/qpid/client -dmoduleexec_LTLIBRARIES = -cmoduleexec_LTLIBRARIES = - -include ha.mk -include qmf.mk -include qmfc.mk -if HAVE_XML -include xml.mk -endif -include legacystore.mk - -if RDMA - -# RDMA (Infiniband) protocol code -librdmawrap_la_SOURCES = \ - qpid/sys/rdma/rdma_exception.h \ - qpid/sys/rdma/rdma_factories.cpp \ - qpid/sys/rdma/rdma_factories.h \ - qpid/sys/rdma/RdmaIO.cpp \ - qpid/sys/rdma/RdmaIO.h \ - qpid/sys/rdma/rdma_wrap.cpp \ - qpid/sys/rdma/rdma_wrap.h -librdmawrap_la_LIBADD = \ - libqpidcommon.la \ - -lrdmacm \ - -libverbs -librdmawrap_la_CXXFLAGS = \ - $(AM_CXXFLAGS) -Wno-missing-field-initializers -lib_LTLIBRARIES += \ - librdmawrap.la -RDMAWRAP_VERSION_INFO = 2:0:0 -librdmawrap_la_LDFLAGS = -version-info $(RDMAWRAP_VERSION_INFO) -no-undefined - -rdma_la_SOURCES = \ - qpid/sys/RdmaIOPlugin.cpp -rdma_la_LIBADD = \ - libqpidbroker.la \ - librdmawrap.la \ - -libverbs -rdma_la_LDFLAGS = $(PLUGINLDFLAGS) -rdma_la_CXXFLAGS = \ - $(AM_CXXFLAGS) -Wno-missing-field-initializers -D_IN_QPID_BROKER -dmoduleexec_LTLIBRARIES += \ - rdma.la - -rdmaconnector_la_SOURCES = \ - qpid/client/RdmaConnector.cpp -rdmaconnector_la_LIBADD = \ - libqpidclient.la \ - librdmawrap.la \ - -libverbs -rdmaconnector_la_LDFLAGS = $(PLUGINLDFLAGS) -rdmaconnector_la_CXXFLAGS = \ - $(AM_CXXFLAGS) -Wno-missing-field-initializers -cmoduleexec_LTLIBRARIES += \ - rdmaconnector.la - -# RDMA test/sample programs -noinst_PROGRAMS = RdmaServer RdmaClient -RdmaServer_SOURCES = qpid/sys/rdma/RdmaServer.cpp -RdmaServer_LDADD = \ - librdmawrap.la libqpidcommon.la -RdmaClient_SOURCES = qpid/sys/rdma/RdmaClient.cpp -RdmaClient_CXXFLAGS = \ - $(AM_CXXFLAGS) -Wno-missing-field-initializers -RdmaClient_LDADD = \ - librdmawrap.la libqpidcommon.la - -endif - -EXTRA_DIST +=\ - CMakeLists.txt \ - config.h.cmake \ - amqp.cmake \ - rdma.cmake \ - legacystore.cmake \ - managementgen.cmake \ - rubygen.cmake \ - versions.cmake \ - finddb.cmake \ - $(rgen_amqp_0_10_srcs) \ - qpid/amqp_0_10/apply.h \ - qpid/amqp_0_10/built_in_types.h \ - qpid/amqp_0_10/complex_types.cpp \ - qpid/amqp_0_10/Array.h \ - qpid/amqp_0_10/Array.cpp \ - qpid/amqp_0_10/Body.h \ - qpid/amqp_0_10/Command.h \ - qpid/amqp_0_10/CommmandPacker.h \ - qpid/amqp_0_10/Control.h \ - qpid/amqp_0_10/Header.h \ - qpid/amqp_0_10/Header.cpp \ - qpid/amqp_0_10/FrameHeader.h \ - qpid/amqp_0_10/FrameHeader.cpp \ - qpid/amqp_0_10/Holder.h \ - qpid/amqp_0_10/Codec.h \ - qpid/amqp_0_10/Packer.h \ - qpid/amqp_0_10/Decimal.h \ - qpid/amqp_0_10/SerializableString.h \ - qpid/amqp_0_10/Map.h \ - qpid/amqp_0_10/Map.cpp \ - qpid/amqp_0_10/Struct.h \ - qpid/amqp_0_10/Struct32.h \ - qpid/amqp_0_10/Struct32.cpp \ - qpid/amqp_0_10/Unit.h \ - qpid/amqp_0_10/Unit.cpp \ - qpid/amqp_0_10/UnitHandler.h \ - qpid/amqp_0_10/UnknownType.h \ - qpid/amqp_0_10/UnknownType.cpp \ - qpid/amqp_0_10/UnknownStruct.h \ - qpid/amqp_0_10/UnknownStruct.cpp \ - qpid/store - -libqpidcommon_la_LIBADD = \ - libqpidtypes.la \ - -lboost_program_options \ - -luuid \ - -lpthread \ - $(LIB_DLOPEN) \ - $(LIB_CLOCK_GETTIME) - -libqpidcommon_la_SOURCES += \ - $(rgen_framing_srcs) \ - $(platform_src) \ - qpid/Address.cpp \ - qpid/DataDir.cpp \ - qpid/DataDir.h \ - qpid/DisableExceptionLogging.h \ - qpid/Exception.cpp \ - qpid/Modules.cpp \ - qpid/Modules.h \ - qpid/Options.cpp \ - qpid/Plugin.cpp \ - qpid/Plugin.h \ - qpid/RefCounted.h \ - qpid/RefCountedBuffer.cpp \ - qpid/RefCountedBuffer.h \ - qpid/BufferRef.h \ - qpid/Sasl.h \ - qpid/SaslFactory.cpp \ - qpid/SaslFactory.h \ - qpid/SaslServer.h \ - qpid/NullSaslServer.h \ - qpid/NullSaslServer.cpp \ - qpid/Serializer.h \ - qpid/SessionId.cpp \ - qpid/SessionState.cpp \ - qpid/SessionState.h \ - qpid/SessionState.h \ - qpid/SharedObject.h \ - qpid/StringUtils.cpp \ - qpid/StringUtils.h \ - qpid/Url.cpp \ - qpid/UrlArray.cpp \ - qpid/UrlArray.h \ - qpid/Version.h \ - qpid/amqp_0_10/Exception.h \ - qpid/amqp_0_10/SessionHandler.cpp \ - qpid/amqp_0_10/SessionHandler.h \ - qpid/amqp_0_10/apply.h \ - qpid/assert.cpp qpid/assert.h \ - qpid/assert.h \ - qpid/framing/AMQBody.cpp \ - qpid/framing/AMQBody.h \ - qpid/framing/AMQContentBody.cpp \ - qpid/framing/AMQContentBody.h \ - qpid/framing/AMQDataBlock.h \ - qpid/framing/AMQFrame.cpp \ - qpid/framing/AMQFrame.h \ - qpid/framing/AMQHeaderBody.cpp \ - qpid/framing/AMQHeaderBody.h \ - qpid/framing/AMQHeartbeatBody.cpp \ - qpid/framing/AMQHeartbeatBody.h \ - qpid/framing/AMQMethodBody.cpp \ - qpid/framing/AMQMethodBody.h \ - qpid/framing/AMQP_HighestVersion.h \ - qpid/framing/AMQP_HighestVersion.h \ - qpid/framing/AccumulatedAck.cpp \ - qpid/framing/AccumulatedAck.h \ - qpid/framing/Array.cpp \ - qpid/framing/BodyFactory.h \ - qpid/framing/Buffer.cpp \ - qpid/framing/ResizableBuffer.h \ - qpid/framing/ChannelHandler.h \ - qpid/framing/Endian.cpp \ - qpid/framing/Endian.h \ - qpid/framing/FieldTable.cpp \ - qpid/framing/FieldValue.cpp \ - qpid/framing/FrameDecoder.cpp \ - qpid/framing/FrameDecoder.h \ - qpid/framing/FrameDefaultVisitor.h \ - qpid/framing/FrameHandler.h \ - qpid/framing/FrameSet.cpp \ - qpid/framing/FrameSet.h \ - qpid/framing/Handler.h \ - qpid/framing/HeaderProperties.h \ - qpid/framing/InitiationHandler.h \ - qpid/framing/InputHandler.h \ - qpid/framing/Invoker.h \ - qpid/framing/IsInSequenceSet.h \ - qpid/framing/List.cpp \ - qpid/framing/MethodBodyFactory.h \ - qpid/framing/MethodContent.h \ - qpid/framing/ModelMethod.h \ - qpid/framing/ProtocolInitiation.cpp \ - qpid/framing/ProtocolInitiation.h \ - qpid/framing/ProtocolVersion.cpp \ - qpid/framing/Proxy.cpp \ - qpid/framing/Proxy.h \ - qpid/framing/SendContent.cpp \ - qpid/framing/SendContent.h \ - qpid/framing/SequenceNumber.cpp \ - qpid/framing/SequenceNumberSet.cpp \ - qpid/framing/SequenceNumberSet.h \ - qpid/framing/SequenceSet.cpp \ - qpid/framing/TransferContent.cpp \ - qpid/framing/TransferContent.h \ - qpid/framing/TypeFilter.h \ - qpid/framing/Uuid.cpp \ - qpid/framing/Visitor.h \ - qpid/framing/amqp_framing.h \ - qpid/framing/frame_functors.h \ - qpid/framing/variant.h \ - qpid/log/Helpers.h \ - qpid/log/Logger.cpp \ - qpid/log/Options.cpp \ - qpid/log/OstreamOutput.cpp \ - qpid/log/OstreamOutput.h \ - qpid/log/Selector.cpp \ - qpid/log/Statement.cpp \ - qpid/management/Buffer.cpp \ - qpid/management/ConnectionSettings.cpp \ - qpid/management/Manageable.cpp \ - qpid/management/ManagementObject.cpp \ - qpid/management/Mutex.cpp \ - qpid/memory.h \ - qpid/pointer_to_other.h \ - qpid/ptr_map.h \ - qpid/sys/AggregateOutput.cpp \ - qpid/sys/AggregateOutput.h \ - qpid/sys/AsynchIO.h \ - qpid/sys/AsynchIOHandler.cpp \ - qpid/sys/AsynchIOHandler.h \ - qpid/sys/AtomicCount.h \ - qpid/sys/AtomicValue.h \ - qpid/sys/AtomicValue_gcc.h \ - qpid/sys/AtomicValue_mutex.h \ - qpid/sys/BlockingQueue.h \ - qpid/sys/Codec.h \ - qpid/sys/ConnectionCodec.h \ - qpid/sys/ConnectionInputHandler.h \ - qpid/sys/ConnectionInputHandlerFactory.h \ - qpid/sys/ConnectionOutputHandler.h \ - qpid/sys/CopyOnWriteArray.h \ - qpid/sys/DeletionManager.h \ - qpid/sys/DispatchHandle.cpp \ - qpid/sys/DispatchHandle.h \ - qpid/sys/Dispatcher.cpp \ - qpid/sys/Dispatcher.h \ - qpid/sys/FileSysDir.h \ - qpid/sys/Fork.h \ - qpid/sys/LockFile.h \ - qpid/sys/LockPtr.h \ - qpid/sys/MemoryMappedFile.h \ - qpid/sys/MemStat.h \ - qpid/sys/OutputControl.h \ - qpid/sys/OutputTask.h \ - qpid/sys/PipeHandle.h \ - qpid/sys/PollableCondition.h \ - qpid/sys/PollableQueue.h \ - qpid/sys/Poller.h \ - qpid/sys/Probes.h \ - qpid/sys/regex.h \ - qpid/sys/Runnable.cpp \ - qpid/sys/ScopedIncrement.h \ - qpid/sys/SecurityLayer.h \ - qpid/sys/SecuritySettings.h \ - qpid/sys/Semaphore.h \ - qpid/sys/Shlib.cpp \ - qpid/sys/Shlib.h \ - qpid/sys/ShutdownHandler.h \ - qpid/sys/Socket.h \ - qpid/sys/SocketAddress.h \ - qpid/sys/StateMonitor.h \ - qpid/sys/Timer.cpp \ - qpid/sys/Timer.h \ - qpid/sys/TimerWarnings.cpp \ - qpid/sys/TimerWarnings.h \ - qpid/sys/Waitable.h \ - qpid/sys/uuid.h \ - qpid/sys/unordered_map.h \ - qpid/amqp_0_10/CodecsInternal.h \ - qpid/amqp_0_10/Codecs.cpp \ - qpid/amqp/CharSequence.h \ - qpid/amqp/CharSequence.cpp \ - qpid/amqp/Codec.h \ - qpid/amqp/Constructor.h \ - qpid/amqp/Decoder.h \ - qpid/amqp/Decoder.cpp \ - qpid/amqp/Descriptor.h \ - qpid/amqp/Descriptor.cpp \ - qpid/amqp/descriptors.h \ - qpid/amqp/Encoder.h \ - qpid/amqp/Encoder.cpp \ - qpid/amqp/ListReader.h \ - qpid/amqp/LoggingReader.h \ - qpid/amqp/MapHandler.h \ - qpid/amqp/MapEncoder.h \ - qpid/amqp/MapEncoder.cpp \ - qpid/amqp/MapSizeCalculator.h \ - qpid/amqp/MapSizeCalculator.cpp \ - qpid/amqp/MapBuilder.h \ - qpid/amqp/MapBuilder.cpp \ - qpid/amqp/MapReader.h \ - qpid/amqp/MapReader.cpp \ - qpid/amqp/MessageEncoder.h \ - qpid/amqp/MessageEncoder.cpp \ - qpid/amqp/MessageId.h \ - qpid/amqp/MessageId.cpp \ - qpid/amqp/MessageReader.h \ - qpid/amqp/MessageReader.cpp \ - qpid/amqp/Reader.h \ - qpid/amqp/Sasl.h \ - qpid/amqp/Sasl.cpp \ - qpid/amqp/SaslClient.h \ - qpid/amqp/SaslClient.cpp \ - qpid/amqp/SaslServer.h \ - qpid/amqp/SaslServer.cpp \ - qpid/amqp/typecodes.h - -#libqpidcommon is not really the 'right' place for the Transport -#interface, which is only used in 1.0 impl of messaging API, but this -#lets the 1.0 SSL support be included in the existing sslconnector lib -#which in turn addresses common ssl needs in qpidclient and -#qpidmessaging: -libqpidcommon_la_SOURCES += \ - qpid/messaging/amqp/Transport.h \ - qpid/messaging/amqp/Transport.cpp \ - qpid/messaging/amqp/TransportContext.h - -if HAVE_SASL -libqpidcommon_la_SOURCES += qpid/sys/cyrus/CyrusSecurityLayer.h -libqpidcommon_la_SOURCES += qpid/sys/cyrus/CyrusSecurityLayer.cpp -libqpidcommon_la_LIBADD += -lsasl2 -endif - -QPIDCOMMON_VERSION_INFO = 2:0:0 -libqpidcommon_la_LDFLAGS=-version-info $(QPIDCOMMON_VERSION_INFO) - -libqpidbroker_la_LIBADD = libqpidcommon.la -libqpidbroker_la_SOURCES = \ - $(mgen_broker_cpp) \ - $(posix_broker_src) \ - qpid/acl/Acl.cpp \ - qpid/acl/Acl.h \ - qpid/acl/AclConnectionCounter.cpp \ - qpid/acl/AclConnectionCounter.h \ - qpid/acl/AclData.cpp \ - qpid/acl/AclData.h \ - qpid/acl/AclPlugin.cpp \ - qpid/acl/AclReader.cpp \ - qpid/acl/AclReader.h \ - qpid/acl/AclResourceCounter.cpp \ - qpid/acl/AclResourceCounter.h \ - qpid/acl/AclTopicMatch.h \ - qpid/acl/AclValidator.cpp \ - qpid/acl/AclValidator.h \ - qpid/amqp_0_10/Connection.cpp \ - qpid/amqp_0_10/Connection.h \ - qpid/broker/AclModule.h \ - qpid/broker/Bridge.cpp \ - qpid/broker/Bridge.h \ - qpid/broker/Broker.cpp \ - qpid/broker/Broker.h \ - qpid/broker/BrokerImportExport.h \ - qpid/broker/amqp_0_10/Connection.cpp \ - qpid/broker/amqp_0_10/Connection.h \ - qpid/broker/ConnectionHandler.cpp \ - qpid/broker/ConnectionHandler.h \ - qpid/broker/Consumer.h \ - qpid/broker/Credit.h \ - qpid/broker/Credit.cpp \ - qpid/broker/ConsumerFactory.h \ - qpid/broker/Connection.h \ - qpid/broker/ConnectionObserver.h \ - qpid/broker/ConnectionObservers.h \ - qpid/broker/ConfigurationObserver.h \ - qpid/broker/ConfigurationObservers.h \ - qpid/broker/Daemon.cpp \ - qpid/broker/Daemon.h \ - qpid/broker/Deliverable.h \ - qpid/broker/DeliverableMessage.cpp \ - qpid/broker/DeliverableMessage.h \ - qpid/broker/DeliveryId.h \ - qpid/broker/DeliveryRecord.cpp \ - qpid/broker/DeliveryRecord.h \ - qpid/broker/DirectExchange.cpp \ - qpid/broker/DirectExchange.h \ - qpid/broker/DtxAck.cpp \ - qpid/broker/DtxAck.h \ - qpid/broker/DtxBuffer.cpp \ - qpid/broker/DtxBuffer.h \ - qpid/broker/DtxManager.cpp \ - qpid/broker/DtxManager.h \ - qpid/broker/DtxTimeout.cpp \ - qpid/broker/DtxTimeout.h \ - qpid/broker/DtxWorkRecord.cpp \ - qpid/broker/DtxWorkRecord.h \ - qpid/broker/Exchange.cpp \ - qpid/broker/Exchange.h \ - qpid/broker/ExchangeRegistry.cpp \ - qpid/broker/ExchangeRegistry.h \ - qpid/broker/ExpiryPolicy.cpp \ - qpid/broker/ExpiryPolicy.h \ - qpid/broker/Fairshare.h \ - qpid/broker/Fairshare.cpp \ - qpid/broker/FanOutExchange.cpp \ - qpid/broker/FanOutExchange.h \ - qpid/broker/FedOps.h \ - qpid/broker/HandlerImpl.h \ - qpid/broker/HeadersExchange.cpp \ - qpid/broker/HeadersExchange.h \ - qpid/broker/AsyncCompletion.h \ - qpid/broker/IngressCompletion.h \ - qpid/broker/IngressCompletion.cpp \ - qpid/broker/IndexedDeque.h \ - qpid/broker/Link.cpp \ - qpid/broker/Link.h \ - qpid/broker/LinkRegistry.cpp \ - qpid/broker/LinkRegistry.h \ - qpid/broker/Lvq.h \ - qpid/broker/Lvq.cpp \ - qpid/broker/Message.cpp \ - qpid/broker/Message.h \ - qpid/broker/MessageAdapter.cpp \ - qpid/broker/MessageAdapter.h \ - qpid/broker/MessageBuilder.cpp \ - qpid/broker/MessageBuilder.h \ - qpid/broker/MessageDeque.h \ - qpid/broker/MessageDeque.cpp \ - qpid/broker/MessageInterceptor.h \ - qpid/broker/MessageMap.h \ - qpid/broker/MessageMap.cpp \ - qpid/broker/Messages.h \ - qpid/broker/MessageStore.h \ - qpid/broker/MessageStoreModule.cpp \ - qpid/broker/MessageStoreModule.h \ - qpid/broker/PagedQueue.h \ - qpid/broker/PagedQueue.cpp \ - qpid/broker/PriorityQueue.h \ - qpid/broker/PriorityQueue.cpp \ - qpid/broker/Protocol.h \ - qpid/broker/Protocol.cpp \ - qpid/broker/NameGenerator.cpp \ - qpid/broker/NameGenerator.h \ - qpid/broker/NullMessageStore.cpp \ - qpid/broker/NullMessageStore.h \ - qpid/broker/ObjectFactory.h \ - qpid/broker/ObjectFactory.cpp \ - qpid/broker/Observers.h \ - qpid/broker/OwnershipToken.h \ - qpid/broker/Persistable.h \ - qpid/broker/PersistableConfig.h \ - qpid/broker/PersistableExchange.h \ - qpid/broker/PersistableMessage.cpp \ - qpid/broker/PersistableMessage.h \ - qpid/broker/PersistableObject.h \ - qpid/broker/PersistableObject.cpp \ - qpid/broker/PersistableQueue.h \ - qpid/broker/Queue.cpp \ - qpid/broker/Queue.h \ - qpid/broker/QueueBindings.cpp \ - qpid/broker/QueueBindings.h \ - qpid/broker/QueueCleaner.cpp \ - qpid/broker/QueueCleaner.h \ - qpid/broker/QueueCursor.h \ - qpid/broker/QueueCursor.cpp \ - qpid/broker/QueueDepth.h \ - qpid/broker/QueueDepth.cpp \ - qpid/broker/QueueFactory.h \ - qpid/broker/QueueFactory.cpp \ - qpid/broker/QueueSettings.h \ - qpid/broker/QueueSettings.cpp \ - qpid/broker/QueueListeners.cpp \ - qpid/broker/QueueListeners.h \ - qpid/broker/QueueObserver.h \ - qpid/broker/QueueRegistry.cpp \ - qpid/broker/QueueRegistry.h \ - qpid/broker/QueuedMessage.cpp \ - qpid/broker/QueuedMessage.h \ - qpid/broker/QueueFlowLimit.h \ - qpid/broker/QueueFlowLimit.cpp \ - qpid/broker/LossyQueue.h \ - qpid/broker/LossyQueue.cpp \ - qpid/broker/RecoverableConfig.h \ - qpid/broker/RecoverableExchange.h \ - qpid/broker/RecoverableMessage.h \ - qpid/broker/RecoverableQueue.h \ - qpid/broker/RecoverableTransaction.h \ - qpid/broker/RecoveredDequeue.cpp \ - qpid/broker/RecoveredDequeue.h \ - qpid/broker/RecoveredEnqueue.cpp \ - qpid/broker/RecoveredEnqueue.h \ - qpid/broker/RecoveryManager.h \ - qpid/broker/RecoveryManagerImpl.cpp \ - qpid/broker/RecoveryManagerImpl.h \ - qpid/broker/RecoverableMessageImpl.h \ - qpid/broker/RetryList.cpp \ - qpid/broker/RetryList.h \ - qpid/broker/SaslAuthenticator.cpp \ - qpid/broker/SaslAuthenticator.h \ - qpid/broker/SecureConnection.cpp \ - qpid/broker/SecureConnection.h \ - qpid/broker/SecureConnectionFactory.cpp \ - qpid/broker/SecureConnectionFactory.h \ - qpid/broker/Selector.cpp \ - qpid/broker/Selector.h \ - qpid/broker/SelectorExpression.cpp \ - qpid/broker/SelectorExpression.h \ - qpid/broker/SelectorToken.cpp \ - qpid/broker/SelectorToken.h \ - qpid/broker/SelectorValue.cpp \ - qpid/broker/SelectorValue.h \ - qpid/broker/SemanticState.cpp \ - qpid/broker/SemanticState.h \ - qpid/broker/SessionAdapter.cpp \ - qpid/broker/SessionAdapter.h \ - qpid/broker/SessionAdapter.h \ - qpid/broker/SessionContext.h \ - qpid/broker/SessionHandler.cpp \ - qpid/broker/SessionHandler.h \ - qpid/broker/SessionManager.cpp \ - qpid/broker/SessionManager.h \ - qpid/broker/SessionManager.h \ - qpid/broker/SessionOutputException.h \ - qpid/broker/SessionState.cpp \ - qpid/broker/SessionState.h \ - qpid/broker/SignalHandler.cpp \ - qpid/broker/SignalHandler.h \ - qpid/broker/System.cpp \ - qpid/broker/System.h \ - qpid/broker/ThresholdAlerts.cpp \ - qpid/broker/ThresholdAlerts.h \ - qpid/broker/TopicExchange.cpp \ - qpid/broker/TopicExchange.h \ - qpid/broker/TopicKeyNode.h \ - qpid/broker/TransactionalStore.h \ - qpid/broker/TxAccept.cpp \ - qpid/broker/TxAccept.h \ - qpid/broker/TxBuffer.cpp \ - qpid/broker/TxBuffer.h \ - qpid/broker/TxOp.h \ - qpid/broker/Vhost.cpp \ - qpid/broker/Vhost.h \ - qpid/broker/MessageDistributor.h \ - qpid/broker/FifoDistributor.h \ - qpid/broker/FifoDistributor.cpp \ - qpid/broker/MessageGroupManager.cpp \ - qpid/broker/MessageGroupManager.h \ - qpid/broker/amqp_0_10/MessageTransfer.h \ - qpid/broker/amqp_0_10/MessageTransfer.cpp \ - qpid/management/ManagementAgent.cpp \ - qpid/management/ManagementAgent.h \ - qpid/management/ManagementDirectExchange.cpp \ - qpid/management/ManagementDirectExchange.h \ - qpid/management/ManagementTopicExchange.cpp \ - qpid/management/ManagementTopicExchange.h \ - qpid/sys/TCPIOPlugin.cpp \ - qpid/sys/SocketTransport.cpp \ - qpid/sys/SocketTransport.h \ - qpid/sys/TransportFactory.h - -QPIDBROKER_VERSION_INFO = 2:0:0 -libqpidbroker_la_LDFLAGS = -version-info $(QPIDBROKER_VERSION_INFO) - -if HAVE_PROTON - -dmoduleexec_LTLIBRARIES += amqp.la -amqp_la_LIBADD = libqpidcommon.la -amqp_la_SOURCES = \ - qpid/broker/amqp/Authorise.h \ - qpid/broker/amqp/Authorise.cpp \ - qpid/broker/amqp/BrokerContext.h \ - qpid/broker/amqp/BrokerContext.cpp \ - qpid/broker/amqp/Connection.h \ - qpid/broker/amqp/Connection.cpp \ - qpid/broker/amqp/DataReader.h \ - qpid/broker/amqp/DataReader.cpp \ - qpid/broker/amqp/Domain.h \ - qpid/broker/amqp/Domain.cpp \ - qpid/broker/amqp/Exception.h \ - qpid/broker/amqp/Exception.cpp \ - qpid/broker/amqp/Filter.h \ - qpid/broker/amqp/Filter.cpp \ - qpid/broker/amqp/Header.h \ - qpid/broker/amqp/Header.cpp \ - qpid/broker/amqp/Incoming.h \ - qpid/broker/amqp/Incoming.cpp \ - qpid/broker/amqp/Interconnect.h \ - qpid/broker/amqp/Interconnect.cpp \ - qpid/broker/amqp/Interconnects.h \ - qpid/broker/amqp/Interconnects.cpp \ - qpid/broker/amqp/ManagedConnection.h \ - qpid/broker/amqp/ManagedConnection.cpp \ - qpid/broker/amqp/ManagedSession.h \ - qpid/broker/amqp/ManagedSession.cpp \ - qpid/broker/amqp/ManagedIncomingLink.h \ - qpid/broker/amqp/ManagedIncomingLink.cpp \ - qpid/broker/amqp/ManagedOutgoingLink.h \ - qpid/broker/amqp/ManagedOutgoingLink.cpp \ - qpid/broker/amqp/Message.h \ - qpid/broker/amqp/Message.cpp \ - qpid/broker/amqp/NodeProperties.h \ - qpid/broker/amqp/NodeProperties.cpp \ - qpid/broker/amqp/Outgoing.h \ - qpid/broker/amqp/Outgoing.cpp \ - qpid/broker/amqp/ProtocolPlugin.cpp \ - qpid/broker/amqp/Relay.h \ - qpid/broker/amqp/Relay.cpp \ - qpid/broker/amqp/Sasl.h \ - qpid/broker/amqp/Sasl.cpp \ - qpid/broker/amqp/SaslClient.h \ - qpid/broker/amqp/SaslClient.cpp \ - qpid/broker/amqp/Session.h \ - qpid/broker/amqp/Session.cpp \ - qpid/broker/amqp/Topic.h \ - qpid/broker/amqp/Topic.cpp \ - qpid/broker/amqp/Translation.h \ - qpid/broker/amqp/Translation.cpp - -amqp_la_CXXFLAGS=$(AM_CXXFLAGS) $(BROKER_CXXFLAGS) $(PROTON_CFLAGS) -amqp_la_LDFLAGS = $(PLUGINLDFLAGS) $(PROTON_LIBS) - -cmoduleexec_LTLIBRARIES += amqpc.la -amqpc_la_LIBADD = libqpidcommon.la -amqpc_la_SOURCES = \ - qpid/messaging/amqp/AddressHelper.h \ - qpid/messaging/amqp/AddressHelper.cpp \ - qpid/messaging/amqp/ConnectionContext.h \ - qpid/messaging/amqp/ConnectionContext.cpp \ - qpid/messaging/amqp/ConnectionHandle.h \ - qpid/messaging/amqp/ConnectionHandle.cpp \ - qpid/messaging/amqp/DriverImpl.h \ - qpid/messaging/amqp/DriverImpl.cpp \ - qpid/messaging/amqp/ReceiverContext.h \ - qpid/messaging/amqp/ReceiverContext.cpp \ - qpid/messaging/amqp/ReceiverHandle.h \ - qpid/messaging/amqp/ReceiverHandle.cpp \ - qpid/messaging/amqp/Sasl.h \ - qpid/messaging/amqp/Sasl.cpp \ - qpid/messaging/amqp/SenderContext.h \ - qpid/messaging/amqp/SenderContext.cpp \ - qpid/messaging/amqp/SenderHandle.h \ - qpid/messaging/amqp/SenderHandle.cpp \ - qpid/messaging/amqp/SessionContext.h \ - qpid/messaging/amqp/SessionContext.cpp \ - qpid/messaging/amqp/SessionHandle.h \ - qpid/messaging/amqp/SessionHandle.cpp \ - qpid/messaging/amqp/TcpTransport.h \ - qpid/messaging/amqp/TcpTransport.cpp - -amqpc_la_CXXFLAGS=$(AM_CXXFLAGS) $(PROTON_CFLAGS) -amqpc_la_LDFLAGS = $(PLUGINLDFLAGS) $(PROTON_LIBS) - -endif #HAVE_PROTON - -libqpidclient_la_LIBADD = libqpidcommon.la -luuid - -libqpidclient_la_SOURCES = \ - $(rgen_client_srcs) \ - qpid/client/Bounds.cpp \ - qpid/client/Bounds.h \ - qpid/client/ChainableFrameHandler.h \ - qpid/client/Completion.cpp \ - qpid/client/CompletionImpl.h \ - qpid/client/Connection.cpp \ - qpid/client/ConnectionAccess.h \ - qpid/client/ConnectionHandler.cpp \ - qpid/client/ConnectionHandler.h \ - qpid/client/ConnectionImpl.cpp \ - qpid/client/ConnectionImpl.h \ - qpid/client/ConnectionSettings.cpp \ - qpid/client/Connector.cpp \ - qpid/client/Connector.h \ - qpid/client/Demux.cpp \ - qpid/client/Demux.h \ - qpid/client/Dispatcher.cpp \ - qpid/client/Dispatcher.h \ - qpid/client/Execution.h \ - qpid/client/FailoverListener.cpp \ - qpid/client/FailoverManager.cpp \ - qpid/client/Future.cpp \ - qpid/client/FutureCompletion.cpp \ - qpid/client/FutureResult.cpp \ - qpid/client/LoadPlugins.h \ - qpid/client/LoadPlugins.cpp \ - qpid/client/LocalQueue.cpp \ - qpid/client/LocalQueueImpl.cpp \ - qpid/client/LocalQueueImpl.h \ - qpid/client/Message.cpp \ - qpid/client/MessageImpl.cpp \ - qpid/client/MessageImpl.h \ - qpid/client/MessageListener.cpp \ - qpid/client/MessageReplayTracker.cpp \ - qpid/client/PrivateImplRef.h \ - qpid/client/QueueOptions.cpp \ - qpid/client/Results.cpp \ - qpid/client/Results.h \ - qpid/client/SessionBase_0_10.cpp \ - qpid/client/SessionBase_0_10Access.h \ - qpid/client/SessionImpl.cpp \ - qpid/client/SessionImpl.h \ - qpid/client/StateManager.cpp \ - qpid/client/StateManager.h \ - qpid/client/Subscription.cpp \ - qpid/client/SubscriptionImpl.cpp \ - qpid/client/SubscriptionImpl.h \ - qpid/client/SubscriptionManager.cpp \ - qpid/client/SubscriptionManagerImpl.cpp \ - qpid/client/SubscriptionManagerImpl.h \ - qpid/client/TCPConnector.cpp \ - qpid/client/TCPConnector.h - -QPIDCLIENT_VERSION_INFO = 2:0:0 -libqpidclient_la_LDFLAGS = -version-info $(QPIDCLIENT_VERSION_INFO) - -if SSL -include ssl.mk -endif - -libqpidtypes_la_LIBADD= -luuid -libqpidtypes_la_SOURCES= \ - qpid/types/Exception.cpp \ - qpid/types/Uuid.cpp \ - qpid/types/Variant.cpp \ - ../include/qpid/types/ImportExport.h - -QPIDTYPES_VERSION_INFO = 1:0:0 -libqpidtypes_la_LDFLAGS = -version-info $(QPIDTYPES_VERSION_INFO) - -libqpidmessaging_la_LIBADD = libqpidclient.la libqpidtypes.la -libqpidmessaging_la_SOURCES = \ - qpid/messaging/Address.cpp \ - qpid/messaging/AddressImpl.h \ - qpid/messaging/AddressParser.h \ - qpid/messaging/AddressParser.cpp \ - qpid/messaging/Connection.cpp \ - qpid/messaging/ConnectionOptions.h \ - qpid/messaging/ConnectionOptions.cpp \ - qpid/messaging/Duration.cpp \ - qpid/messaging/exceptions.cpp \ - qpid/messaging/Message.cpp \ - qpid/messaging/MessageImpl.h \ - qpid/messaging/MessageImpl.cpp \ - qpid/messaging/PrivateImplRef.h \ - qpid/messaging/ProtocolRegistry.h \ - qpid/messaging/ProtocolRegistry.cpp \ - qpid/messaging/Sender.cpp \ - qpid/messaging/Receiver.cpp \ - qpid/messaging/Session.cpp \ - qpid/messaging/ConnectionImpl.h \ - qpid/messaging/SenderImpl.h \ - qpid/messaging/ReceiverImpl.h \ - qpid/messaging/SessionImpl.h \ - qpid/messaging/FailoverUpdates.cpp \ - qpid/messaging/amqp/EncodedMessage.h \ - qpid/messaging/amqp/EncodedMessage.cpp \ - qpid/client/amqp0_10/AcceptTracker.h \ - qpid/client/amqp0_10/AcceptTracker.cpp \ - qpid/client/amqp0_10/AddressResolution.h \ - qpid/client/amqp0_10/AddressResolution.cpp \ - qpid/client/amqp0_10/ConnectionImpl.h \ - qpid/client/amqp0_10/ConnectionImpl.cpp \ - qpid/client/amqp0_10/IncomingMessages.h \ - qpid/client/amqp0_10/IncomingMessages.cpp \ - qpid/client/amqp0_10/MessageSink.h \ - qpid/client/amqp0_10/MessageSource.h \ - qpid/client/amqp0_10/OutgoingMessage.h \ - qpid/client/amqp0_10/OutgoingMessage.cpp \ - qpid/client/amqp0_10/ReceiverImpl.h \ - qpid/client/amqp0_10/ReceiverImpl.cpp \ - qpid/client/amqp0_10/SessionImpl.h \ - qpid/client/amqp0_10/SessionImpl.cpp \ - qpid/client/amqp0_10/SenderImpl.h \ - qpid/client/amqp0_10/SenderImpl.cpp - -QPIDMESSAGING_VERSION_INFO = 2:0:0 -libqpidmessaging_la_LDFLAGS = -version-info $(QPIDMESSAGING_VERSION_INFO) - -# NOTE: only public header files (which should be in ../include) -# should go in this list. Private headers should go in the SOURCES -# list for one of the libraries or executables that includes it. -# Also included are the swig descriptor files. - -nobase_include_HEADERS += \ - ../include/qpid/Address.h \ - ../include/qpid/CommonImportExport.h \ - ../include/qpid/Exception.h \ - ../include/qpid/ImportExport.h \ - ../include/qpid/InlineAllocator.h \ - ../include/qpid/InlineVector.h \ - ../include/qpid/Msg.h \ - ../include/qpid/Options.h \ - ../include/qpid/RangeSet.h \ - ../include/qpid/SessionId.h \ - ../include/qpid/Url.h \ - ../include/qpid/amqp_0_10/Codecs.h \ - ../include/qpid/client/AsyncSession.h \ - ../include/qpid/client/ClientImportExport.h \ - ../include/qpid/client/Completion.h \ - ../include/qpid/client/Connection.h \ - ../include/qpid/client/ConnectionSettings.h \ - ../include/qpid/client/FailoverListener.h \ - ../include/qpid/client/FailoverManager.h \ - ../include/qpid/client/FlowControl.h \ - ../include/qpid/client/Future.h \ - ../include/qpid/client/FutureCompletion.h \ - ../include/qpid/client/FutureResult.h \ - ../include/qpid/client/Handle.h \ - ../include/qpid/client/LocalQueue.h \ - ../include/qpid/client/Message.h \ - ../include/qpid/client/MessageListener.h \ - ../include/qpid/client/MessageReplayTracker.h \ - ../include/qpid/client/QueueOptions.h \ - ../include/qpid/client/Session.h \ - ../include/qpid/client/SessionBase_0_10.h \ - ../include/qpid/client/Subscription.h \ - ../include/qpid/client/SubscriptionManager.h \ - ../include/qpid/client/SubscriptionSettings.h \ - ../include/qpid/client/TypedResult.h \ - ../include/qpid/framing/Array.h \ - ../include/qpid/framing/Buffer.h \ - ../include/qpid/framing/FieldTable.h \ - ../include/qpid/framing/FieldValue.h \ - ../include/qpid/framing/List.h \ - ../include/qpid/framing/ProtocolVersion.h \ - ../include/qpid/framing/SequenceNumber.h \ - ../include/qpid/framing/SequenceSet.h \ - ../include/qpid/framing/StructHelper.h \ - ../include/qpid/framing/Uuid.h \ - ../include/qpid/framing/amqp_types.h \ - ../include/qpid/framing/amqp_types_full.h \ - ../include/qpid/log/Logger.h \ - ../include/qpid/log/Options.h \ - ../include/qpid/log/Selector.h \ - ../include/qpid/log/SinkOptions.h \ - ../include/qpid/log/Statement.h \ - ../include/qpid/management/Args.h \ - ../include/qpid/management/Buffer.h \ - ../include/qpid/management/ConnectionSettings.h \ - ../include/qpid/management/Manageable.h \ - ../include/qpid/management/ManagementEvent.h \ - ../include/qpid/management/ManagementObject.h \ - ../include/qpid/management/Mutex.h \ - ../include/qpid/sys/Condition.h \ - ../include/qpid/sys/ExceptionHolder.h \ - ../include/qpid/sys/IOHandle.h \ - ../include/qpid/sys/IntegerTypes.h \ - ../include/qpid/sys/Monitor.h \ - ../include/qpid/sys/Mutex.h \ - ../include/qpid/sys/Runnable.h \ - ../include/qpid/sys/StrError.h \ - ../include/qpid/sys/SystemInfo.h \ - ../include/qpid/sys/Thread.h \ - ../include/qpid/sys/Time.h \ - ../include/qpid/messaging/Address.h \ - ../include/qpid/messaging/Connection.h \ - ../include/qpid/messaging/Duration.h \ - ../include/qpid/messaging/exceptions.h \ - ../include/qpid/messaging/Handle.h \ - ../include/qpid/messaging/ImportExport.h \ - ../include/qpid/messaging/Message.h \ - ../include/qpid/messaging/Receiver.h \ - ../include/qpid/messaging/Sender.h \ - ../include/qpid/messaging/Session.h \ - ../include/qpid/messaging/FailoverUpdates.h \ - ../include/qpid/types/Exception.h \ - ../include/qpid/types/Uuid.h \ - ../include/qpid/types/Variant.h \ - ../include/qpid/types/ImportExport.h \ - ../include/qpid/qpid.i \ - ../include/qmf/qmfengine.i \ - ../include/qmf/qmf2.i - -# Create the default data directory -install-data-local: - $(mkinstalldirs) $(DESTDIR)/$(localstatedir)/lib/qpidd - -# Support for pkg-config -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA += qpid.pc - diff --git a/qpid/cpp/src/amqp.cmake b/qpid/cpp/src/amqp.cmake index 2d0ca06250..38b7d01315 100644 --- a/qpid/cpp/src/amqp.cmake +++ b/qpid/cpp/src/amqp.cmake @@ -23,15 +23,43 @@ include(FindPkgConfig) pkg_check_modules(PROTON libqpid-proton) +if (NOT PROTON_FOUND) + # if pkg-config is absent or fails to find proton then use + # PROTON_ROOT command line option or environment variable to locate + # local installed proton build. + if (NOT PROTON_ROOT) + set (PROTON_ROOT "$ENV{PROTON_ROOT}") + endif() + if (PROTON_ROOT) + find_package(proton PATHS ${PROTON_ROOT} NO_DEFAULT_PATH) + + if (proton_FOUND EQUAL 1) + set(iFile "${PROTON_ROOT}/lib/proton.cmake/libqpid-proton.cmake") + if(EXISTS ${iFile}) + include("${iFile}") + else() + message(FATAL_ERROR "PROTON_ROOT defined but file ${iFile} is missing") + endif() + else() + message(FATAL_ERROR "Proton package files not found in ${PROTON_ROOT}") + endif() + endif() +endif() + set (amqp_default ${amqp_force}) -set (required_version 0.3) +set (minimum_version 0.5) +set (maximum_version 0.5) if (PROTON_FOUND) - if (PROTON_VERSION LESS ${required_version}) - message(STATUS "Qpid proton is too old, amqp 1.0 support not enabled") - else (PROTON_VERSION LESS ${required_version}) - message(STATUS "Qpid proton found, amqp 1.0 support enabled") - set (amqp_default ON) - endif (PROTON_VERSION LESS ${required_version}) + if (PROTON_VERSION LESS ${minimum_version}) + message(STATUS "Qpid proton ${PROTON_VERSION} is too old, require ${minimum_version} - ${maximum_version}; amqp 1.0 support not enabled") + else (PROTON_VERSION LESS ${minimum_version}) + if (PROTON_VERSION GREATER ${maximum_version}) + message(STATUS "Qpid proton ${PROTON_VERSION} is too new, require ${minimum_version} - ${maximum_version}; amqp 1.0 support not enabled") + else (PROTON_VERSION GREATER ${maximum_version}) + message(STATUS "Qpid proton found, amqp 1.0 support enabled") + set (amqp_default ON) + endif (PROTON_VERSION GREATER ${maximum_version}) + endif (PROTON_VERSION LESS ${minimum_version}) else (PROTON_FOUND) message(STATUS "Qpid proton not found, amqp 1.0 support not enabled") endif (PROTON_FOUND) @@ -43,15 +71,6 @@ if (BUILD_AMQP) message(FATAL_ERROR "Qpid proton not found, required for amqp 1.0 support") endif (NOT PROTON_FOUND) - foreach(f ${PROTON_CFLAGS}) - set (PROTON_COMPILE_FLAGS "${PROTON_COMPILE_FLAGS} ${f}") - endforeach(f) - - foreach(f ${PROTON_LDFLAGS}) - set (PROTON_LINK_FLAGS "${PROTON_LINK_FLAGS} ${f}") - endforeach(f) - - set (amqp_SOURCES qpid/broker/amqp/Authorise.h qpid/broker/amqp/Authorise.cpp @@ -103,18 +122,21 @@ if (BUILD_AMQP) qpid/broker/amqp/Translation.h qpid/broker/amqp/Translation.cpp ) + + include_directories(${PROTON_INCLUDE_DIRS}) + link_directories(${PROTON_LIBRARY_DIRS}) + add_library (amqp MODULE ${amqp_SOURCES}) - target_link_libraries (amqp qpidbroker qpidcommon) + target_link_libraries (amqp qpidtypes qpidbroker qpidcommon ${PROTON_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY}) set_target_properties (amqp PROPERTIES PREFIX "" - COMPILE_FLAGS "${PROTON_COMPILE_FLAGS}" - LINK_FLAGS "${PROTON_LINK_FLAGS}") - set_target_properties (amqp PROPERTIES COMPILE_DEFINITIONS _IN_QPID_BROKER) + LINK_FLAGS "${CATCH_UNDEFINED}" + COMPILE_DEFINITIONS _IN_QPID_BROKER) + install (TARGETS amqp DESTINATION ${QPIDD_MODULE_DIR} COMPONENT ${QPID_COMPONENT_BROKER}) - set (amqpc_SOURCES qpid/messaging/amqp/AddressHelper.h qpid/messaging/amqp/AddressHelper.cpp @@ -142,11 +164,11 @@ if (BUILD_AMQP) qpid/messaging/amqp/TcpTransport.cpp ) add_library (amqpc MODULE ${amqpc_SOURCES}) - target_link_libraries (amqpc qpidclient qpidcommon) + target_link_libraries (amqpc qpidmessaging qpidtypes qpidclient qpidcommon ${PROTON_LIBRARIES}) set_target_properties (amqpc PROPERTIES PREFIX "" - COMPILE_FLAGS "${PROTON_COMPILE_FLAGS}" - LINK_FLAGS "${PROTON_LINK_FLAGS}") + LINK_FLAGS "${CATCH_UNDEFINED}") + install (TARGETS amqpc DESTINATION ${QPIDC_MODULE_DIR} COMPONENT ${QPID_COMPONENT_CLIENT}) diff --git a/qpid/cpp/src/check-abi b/qpid/cpp/src/check-abi new file mode 100755 index 0000000000..2b5d4eda68 --- /dev/null +++ b/qpid/cpp/src/check-abi @@ -0,0 +1,81 @@ +#! /bin/bash + +# Ask the compiler the implementation specific type for a standard typedeffed type +# (int64_t, size_t etc.). Operates by test compiling and using the demangling ABI call. +# +# This works for gcc and clang on Unix. +full_type_of () { + prog=$(mktemp) + trap "rm $prog" EXIT + + ${CXX:-g++} -x c++ -o $prog - <<END-FILE +#include <stdint.h> +#include <stdlib.h> +#include <cxxabi.h> +#include <iostream> +#include <typeinfo> + +int main() { + int status; + char* printable_type = + __cxxabiv1::__cxa_demangle(typeid($1).name(), 0, 0, &status); + if (printable_type) { + std::cout << printable_type; + } else { + std::cout << "$1"; + } + ::free(printable_type); +} +END-FILE +$prog +} + +rc=0 +syms_desired=$(mktemp) +syms_library=$(mktemp) +syms_missing=$(mktemp) +syms_extra=$(mktemp) + +trap 'rm $syms_desired $syms_library $syms_missing $syms_extra' EXIT + +CXX=$1 +export CXX + +# Extract exported symbols from library +nm -DC --defined-only -f s $2 | cut -f1 -d'|' -s | sort -u > $syms_library + +# Process API syms (substitute in some typedefs etc.) +sed $3 -e " + s/uint64_t/$(full_type_of uint64_t)/ + s/uint32_t/unsigned int/ + s/uint16_t/unsigned short/ + s/uint8_t/unsigned char/ + s/size_t/$(full_type_of size_t)/ + s/int64_t/$(full_type_of int64_t)/ + s/int32_t/int/ + s/int16_t/short/ + s/int8_t/signed char/ + s/qpid::types::Variant::Map/std::map<std::string, qpid::types::Variant, std::less<std::string>, std::allocator<std::pair<std::string const, qpid::types::Variant> > >/ + s/qpid::types::Variant::List/std::list<qpid::types::Variant, std::allocator<qpid::types::Variant> >/ + /^\$/d + /^#.*\$/d +" | sort -u > $syms_desired + +comm -23 $syms_desired $syms_library > $syms_missing +comm -13 $syms_desired $syms_library > $syms_extra + +if [ -n "$(cat $syms_missing)" ] ; then + (echo "Not exported from library (should be)" + echo "=====================================" + cat $syms_missing ) 1>&2 + rc=1 +fi + + +if [ -n "$(cat $syms_extra)" ]; then + (echo "Exported by library but not in spec" + echo "===================================" + cat $syms_extra ) 1>&2 +fi + +exit $rc diff --git a/qpid/cpp/src/finddb.cmake b/qpid/cpp/src/finddb.cmake index fad827cffe..2f2f94f469 100644 --- a/qpid/cpp/src/finddb.cmake +++ b/qpid/cpp/src/finddb.cmake @@ -22,31 +22,33 @@ if(UNIX) # - Find BerkeleyDB # Find the BerkeleyDB includes and library # This module defines -# DB_INCLUDE_DIR, where to find db.h, etc. +# DB_CXX_INCLUDE_DIR, where to find db_cxx.h, etc. # DB_LIBRARIES, the libraries needed to use BerkeleyDB. # DB_FOUND, If false, do not try to use BerkeleyDB. # also defined, but not for general use are # DB_LIBRARY, where to find the BerkeleyDB library. -FIND_PATH(DB_INCLUDE_DIR db.h +FIND_PATH(DB_CXX_INCLUDE_DIR db_cxx.h /usr/local/include/db4 + /usr/local/include/libdb4 /usr/local/include /usr/include/db4 + /usr/include/libdb4 /usr/include ) -SET(DB_NAMES ${DB_NAMES} db_cxx) +SET(DB_NAMES ${DB_NAMES} db_cxx db_cxx-4) FIND_LIBRARY(DB_LIBRARY NAMES ${DB_NAMES} PATHS /usr/lib /usr/local/lib ) -IF (DB_LIBRARY AND DB_INCLUDE_DIR) +IF (DB_LIBRARY AND DB_CXX_INCLUDE_DIR) SET(DB_LIBRARIES ${DB_LIBRARY}) SET(DB_FOUND "YES") -ELSE (DB_LIBRARY AND DB_INCLUDE_DIR) +ELSE (DB_LIBRARY AND DB_CXX_INCLUDE_DIR) UNSET( DB_FOUND ) -ENDIF (DB_LIBRARY AND DB_INCLUDE_DIR) +ENDIF (DB_LIBRARY AND DB_CXX_INCLUDE_DIR) IF (DB_FOUND) @@ -60,15 +62,15 @@ ELSE (DB_FOUND) ENDIF (DB_FOUND) # Deprecated declarations. -SET (NATIVE_DB_INCLUDE_PATH ${DB_INCLUDE_DIR} ) +SET (NATIVE_DB_INCLUDE_PATH ${DB_CXX_INCLUDE_DIR} ) GET_FILENAME_COMPONENT (NATIVE_DB_LIB_PATH ${DB_LIBRARY} PATH) MARK_AS_ADVANCED( DB_LIBRARY - DB_INCLUDE_DIR + DB_CXX_INCLUDE_DIR ) else(UNIX) MESSAGE(STATUS "BerkeleyDB is ignored on non-Unix platforms") UNSET( DB_FOUND ) -endif(UNIX)
\ No newline at end of file +endif(UNIX) diff --git a/qpid/cpp/src/ha.mk b/qpid/cpp/src/ha.mk deleted file mode 100644 index aa3a572286..0000000000 --- a/qpid/cpp/src/ha.mk +++ /dev/null @@ -1,72 +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. -# -# -# HA plugin makefile fragment, to be included in Makefile.am -# - -dmoduleexec_LTLIBRARIES += ha.la - -ha_la_SOURCES = \ - qpid/ha/AlternateExchangeSetter.h \ - qpid/ha/Backup.cpp \ - qpid/ha/Backup.h \ - qpid/ha/BackupConnectionExcluder.h \ - qpid/ha/BrokerInfo.cpp \ - qpid/ha/BrokerInfo.h \ - qpid/ha/BrokerReplicator.cpp \ - qpid/ha/BrokerReplicator.h \ - qpid/ha/ConnectionObserver.cpp \ - qpid/ha/ConnectionObserver.h \ - qpid/ha/FailoverExchange.cpp \ - qpid/ha/FailoverExchange.h \ - qpid/ha/HaBroker.cpp \ - qpid/ha/HaBroker.h \ - qpid/ha/HaPlugin.cpp \ - qpid/ha/hash.h \ - qpid/ha/IdSetter.h \ - qpid/ha/QueueSnapshot.h \ - qpid/ha/makeMessage.cpp \ - qpid/ha/makeMessage.h \ - qpid/ha/Membership.cpp \ - qpid/ha/Membership.h \ - qpid/ha/Primary.cpp \ - qpid/ha/Primary.h \ - qpid/ha/QueueGuard.cpp \ - qpid/ha/QueueGuard.h \ - qpid/ha/QueueReplicator.cpp \ - qpid/ha/QueueReplicator.h \ - qpid/ha/QueueSnapshot.h \ - qpid/ha/QueueSnapshots.h \ - qpid/ha/RemoteBackup.cpp \ - qpid/ha/RemoteBackup.h \ - qpid/ha/ReplicatingSubscription.cpp \ - qpid/ha/ReplicatingSubscription.h \ - qpid/ha/ReplicationTest.cpp \ - qpid/ha/ReplicationTest.h \ - qpid/ha/Role.h \ - qpid/ha/Settings.h \ - qpid/ha/StandAlone.h \ - qpid/ha/StatusCheck.cpp \ - qpid/ha/StatusCheck.h \ - qpid/ha/types.cpp \ - qpid/ha/types.h - -ha_la_LIBADD = libqpidbroker.la libqpidmessaging.la -ha_la_LDFLAGS = $(PLUGINLDFLAGS) -ha_la_CXXFLAGS = $(AM_CXXFLAGS) -D_IN_QPID_BROKER diff --git a/qpid/cpp/src/legacystore.cmake b/qpid/cpp/src/legacystore.cmake index 9d6876b8d6..1fdb51aa32 100644 --- a/qpid/cpp/src/legacystore.cmake +++ b/qpid/cpp/src/legacystore.cmake @@ -126,10 +126,10 @@ if (BUILD_LEGACYSTORE) ) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/db-inc.h) - message(STATUS "Including BDB from ${DB_INCLUDE_DIR}/db_cxx.h") + message(STATUS "Including BDB from ${DB_CXX_INCLUDE_DIR}/db_cxx.h") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/db-inc.h - "#include <${DB_INCLUDE_DIR}/db_cxx.h>\n") + "#include <${DB_CXX_INCLUDE_DIR}/db_cxx.h>\n") endif() add_library (legacystore MODULE diff --git a/qpid/cpp/src/legacystore.mk b/qpid/cpp/src/legacystore.mk deleted file mode 100644 index 7dbfac8a28..0000000000 --- a/qpid/cpp/src/legacystore.mk +++ /dev/null @@ -1,110 +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. -# -# -# Legacy store plugin makefile fragment, to be included in Makefile.am -# NOTE: this fragment only includes legacystore sources in -# the distribution, it does not build the store. -# -# To build the store use the cmake build system, see ../INSTALL -# - -EXTRA_DIST += \ - qpid/legacystore/BindingDbt.cpp \ - qpid/legacystore/BindingDbt.h \ - qpid/legacystore/BufferValue.cpp \ - qpid/legacystore/BufferValue.h \ - qpid/legacystore/Cursor.h \ - qpid/legacystore/DataTokenImpl.cpp \ - qpid/legacystore/DataTokenImpl.h \ - qpid/legacystore/IdDbt.cpp \ - qpid/legacystore/IdDbt.h \ - qpid/legacystore/IdSequence.cpp \ - qpid/legacystore/IdSequence.h \ - qpid/legacystore/JournalImpl.cpp \ - qpid/legacystore/JournalImpl.h \ - qpid/legacystore/MessageStoreImpl.cpp \ - qpid/legacystore/MessageStoreImpl.h \ - qpid/legacystore/PreparedTransaction.cpp \ - qpid/legacystore/PreparedTransaction.h \ - qpid/legacystore/StoreException.h \ - qpid/legacystore/StorePlugin.cpp \ - qpid/legacystore/TxnCtxt.cpp \ - qpid/legacystore/TxnCtxt.h \ - qpid/legacystore/jrnl/aio.cpp \ - qpid/legacystore/jrnl/aio.h \ - qpid/legacystore/jrnl/aio_callback.h \ - qpid/legacystore/jrnl/cvar.cpp \ - qpid/legacystore/jrnl/cvar.h \ - qpid/legacystore/jrnl/data_tok.cpp \ - qpid/legacystore/jrnl/data_tok.h \ - qpid/legacystore/jrnl/deq_hdr.h \ - qpid/legacystore/jrnl/deq_rec.cpp \ - qpid/legacystore/jrnl/deq_rec.h \ - qpid/legacystore/jrnl/enq_hdr.h \ - qpid/legacystore/jrnl/enq_map.cpp \ - qpid/legacystore/jrnl/enq_map.h \ - qpid/legacystore/jrnl/enq_rec.cpp \ - qpid/legacystore/jrnl/enq_rec.h \ - qpid/legacystore/jrnl/enums.h \ - qpid/legacystore/jrnl/fcntl.cpp \ - qpid/legacystore/jrnl/fcntl.h \ - qpid/legacystore/jrnl/file_hdr.h \ - qpid/legacystore/jrnl/jcfg.h \ - qpid/legacystore/jrnl/jcntl.cpp \ - qpid/legacystore/jrnl/jcntl.h \ - qpid/legacystore/jrnl/jdir.cpp \ - qpid/legacystore/jrnl/jdir.h \ - qpid/legacystore/jrnl/jerrno.cpp \ - qpid/legacystore/jrnl/jerrno.h \ - qpid/legacystore/jrnl/jexception.cpp \ - qpid/legacystore/jrnl/jexception.h \ - qpid/legacystore/jrnl/jinf.cpp \ - qpid/legacystore/jrnl/jinf.h \ - qpid/legacystore/jrnl/jrec.cpp \ - qpid/legacystore/jrnl/jrec.h \ - qpid/legacystore/jrnl/lp_map.cpp \ - qpid/legacystore/jrnl/lp_map.h \ - qpid/legacystore/jrnl/lpmgr.cpp \ - qpid/legacystore/jrnl/lpmgr.h \ - qpid/legacystore/jrnl/pmgr.cpp \ - qpid/legacystore/jrnl/pmgr.h \ - qpid/legacystore/jrnl/rcvdat.h \ - qpid/legacystore/jrnl/rec_hdr.h \ - qpid/legacystore/jrnl/rec_tail.h \ - qpid/legacystore/jrnl/rfc.cpp \ - qpid/legacystore/jrnl/rfc.h \ - qpid/legacystore/jrnl/rmgr.cpp \ - qpid/legacystore/jrnl/rmgr.h \ - qpid/legacystore/jrnl/rrfc.cpp \ - qpid/legacystore/jrnl/rrfc.h \ - qpid/legacystore/jrnl/slock.cpp \ - qpid/legacystore/jrnl/slock.h \ - qpid/legacystore/jrnl/smutex.cpp \ - qpid/legacystore/jrnl/smutex.h \ - qpid/legacystore/jrnl/time_ns.cpp \ - qpid/legacystore/jrnl/time_ns.h \ - qpid/legacystore/jrnl/txn_hdr.h \ - qpid/legacystore/jrnl/txn_map.cpp \ - qpid/legacystore/jrnl/txn_map.h \ - qpid/legacystore/jrnl/txn_rec.cpp \ - qpid/legacystore/jrnl/txn_rec.h \ - qpid/legacystore/jrnl/wmgr.cpp \ - qpid/legacystore/jrnl/wmgr.h \ - qpid/legacystore/jrnl/wrfc.cpp \ - qpid/legacystore/jrnl/wrfc.h diff --git a/qpid/cpp/src/libqpidmessaging-api-symbols.txt b/qpid/cpp/src/libqpidmessaging-api-symbols.txt new file mode 100644 index 0000000000..dc889afaed --- /dev/null +++ b/qpid/cpp/src/libqpidmessaging-api-symbols.txt @@ -0,0 +1,214 @@ +# Address +qpid::messaging::Address::Address() +qpid::messaging::Address::Address(std::string const&) +qpid::messaging::Address::Address(std::string const&, std::string const&, qpid::types::Variant::Map const&, std::string const&) +qpid::messaging::Address::Address(qpid::messaging::Address const&) +qpid::messaging::Address::~Address() +qpid::messaging::Address::operator=(qpid::messaging::Address const&) +qpid::messaging::Address::getName() const +qpid::messaging::Address::setName(std::string const&) +qpid::messaging::Address::getSubject() const +qpid::messaging::Address::setSubject(std::string const&) +qpid::messaging::Address::getOptions() const +qpid::messaging::Address::getOptions() +qpid::messaging::Address::setOptions(qpid::types::Variant::Map const&) +qpid::messaging::Address::getType() const +qpid::messaging::Address::setType(std::string const&) +qpid::messaging::Address::str() const +qpid::messaging::Address::operator bool() const +qpid::messaging::Address::operator!() const + +qpid::messaging::operator<<(std::ostream&, qpid::messaging::Address const&) + +# Connection +qpid::messaging::Connection::Connection(qpid::messaging::ConnectionImpl*) +qpid::messaging::Connection::Connection(qpid::messaging::Connection const&) +qpid::messaging::Connection::Connection() +qpid::messaging::Connection::Connection(std::string const&, qpid::types::Variant::Map const&) +qpid::messaging::Connection::Connection(std::string const&, std::string const&) +qpid::messaging::Connection::~Connection() +qpid::messaging::Connection::operator=(qpid::messaging::Connection const&) +qpid::messaging::Connection::setOption(std::string const&, qpid::types::Variant const&) +qpid::messaging::Connection::open() +qpid::messaging::Connection::isOpen() +qpid::messaging::Connection::isOpen() const +qpid::messaging::Connection::close() +qpid::messaging::Connection::createTransactionalSession(std::string const&) +qpid::messaging::Connection::createSession(std::string const&) +qpid::messaging::Connection::getSession(std::string const&) const +qpid::messaging::Connection::getAuthenticatedUsername() + +# Duration +qpid::messaging::Duration::Duration(uint64_t) +qpid::messaging::Duration::getMilliseconds() const +qpid::messaging::Duration::FOREVER +qpid::messaging::Duration::IMMEDIATE +qpid::messaging::Duration::SECOND +qpid::messaging::Duration::MINUTE + +qpid::messaging::operator*(qpid::messaging::Duration const&, uint64_t) +qpid::messaging::operator*(uint64_t, qpid::messaging::Duration const&) +qpid::messaging::operator==(qpid::messaging::Duration const&, qpid::messaging::Duration const&) +qpid::messaging::operator!=(qpid::messaging::Duration const&, qpid::messaging::Duration const&) + +# FailoverUpdates (this is a very strange class - more like a property of a Connection) +qpid::messaging::FailoverUpdates::FailoverUpdates(qpid::messaging::Connection&) +qpid::messaging::FailoverUpdates::~FailoverUpdates() + +# Message +qpid::messaging::Message::Message(std::string const&) +qpid::messaging::Message::Message(char const*, size_t) +qpid::messaging::Message::Message(qpid::messaging::Message const&) +qpid::messaging::Message::Message(qpid::types::Variant&) +qpid::messaging::Message::~Message() +qpid::messaging::Message::operator=(qpid::messaging::Message const&) +qpid::messaging::Message::setReplyTo(qpid::messaging::Address const&) +qpid::messaging::Message::getReplyTo() const +qpid::messaging::Message::setSubject(std::string const&) +qpid::messaging::Message::getSubject() const +qpid::messaging::Message::setContentType(std::string const&) +qpid::messaging::Message::getContentType() const +qpid::messaging::Message::setMessageId(std::string const&) +qpid::messaging::Message::getMessageId() const +qpid::messaging::Message::setUserId(std::string const&) +qpid::messaging::Message::getUserId() const +qpid::messaging::Message::setCorrelationId(std::string const&) +qpid::messaging::Message::getCorrelationId() const +qpid::messaging::Message::setPriority(uint8_t) +qpid::messaging::Message::getPriority() const +qpid::messaging::Message::setTtl(qpid::messaging::Duration) +qpid::messaging::Message::getTtl() const +qpid::messaging::Message::setDurable(bool) +qpid::messaging::Message::getDurable() const +qpid::messaging::Message::getRedelivered() const +qpid::messaging::Message::setRedelivered(bool) +qpid::messaging::Message::getProperties() const +qpid::messaging::Message::getProperties() +qpid::messaging::Message::setContent(std::string const&) +qpid::messaging::Message::setContent(char const*, size_t) +qpid::messaging::Message::getContent() const +qpid::messaging::Message::setContentBytes(std::string const&) +qpid::messaging::Message::getContentBytes() const +qpid::messaging::Message::setContentObject(qpid::types::Variant const&) +qpid::messaging::Message::getContentObject() +qpid::messaging::Message::getContentObject() const +qpid::messaging::Message::getContentPtr() const +qpid::messaging::Message::getContentSize() const +qpid::messaging::Message::setProperty(std::string const&, qpid::types::Variant const&) + +# Receiver +qpid::messaging::Receiver::Receiver(qpid::messaging::ReceiverImpl*) +qpid::messaging::Receiver::Receiver(qpid::messaging::Receiver const&) +qpid::messaging::Receiver::~Receiver() +qpid::messaging::Receiver::operator=(qpid::messaging::Receiver const&) +qpid::messaging::Receiver::get(qpid::messaging::Message&, qpid::messaging::Duration) +qpid::messaging::Receiver::get(qpid::messaging::Duration) +qpid::messaging::Receiver::fetch(qpid::messaging::Message&, qpid::messaging::Duration) +qpid::messaging::Receiver::fetch(qpid::messaging::Duration) +qpid::messaging::Receiver::setCapacity(uint32_t) +qpid::messaging::Receiver::getCapacity() +qpid::messaging::Receiver::getAvailable() +qpid::messaging::Receiver::getUnsettled() +qpid::messaging::Receiver::close() +qpid::messaging::Receiver::isClosed() const +qpid::messaging::Receiver::getName() const +qpid::messaging::Receiver::getSession() const +qpid::messaging::Receiver::getAddress() const + +# Sender +qpid::messaging::Sender::Sender(qpid::messaging::SenderImpl*) +qpid::messaging::Sender::Sender(qpid::messaging::Sender const&) +qpid::messaging::Sender::~Sender() +qpid::messaging::Sender::operator=(qpid::messaging::Sender const&) +qpid::messaging::Sender::send(qpid::messaging::Message const&, bool) +qpid::messaging::Sender::close() +qpid::messaging::Sender::setCapacity(uint32_t) +qpid::messaging::Sender::getCapacity() +qpid::messaging::Sender::getUnsettled() +qpid::messaging::Sender::getAvailable() +qpid::messaging::Sender::getName() const +qpid::messaging::Sender::getSession() const +qpid::messaging::Sender::getAddress() const + +# Session +qpid::messaging::Session::Session(qpid::messaging::SessionImpl*) +qpid::messaging::Session::Session(qpid::messaging::Session const&) +qpid::messaging::Session::~Session() +qpid::messaging::Session::operator=(qpid::messaging::Session const&) +qpid::messaging::Session::close() +qpid::messaging::Session::commit() +qpid::messaging::Session::rollback() +qpid::messaging::Session::acknowledge(bool) +qpid::messaging::Session::acknowledge(qpid::messaging::Message&, bool) +qpid::messaging::Session::acknowledgeUpTo(qpid::messaging::Message&, bool) +qpid::messaging::Session::reject(qpid::messaging::Message&) +qpid::messaging::Session::release(qpid::messaging::Message&) +qpid::messaging::Session::sync(bool) +qpid::messaging::Session::getReceivable() +qpid::messaging::Session::getUnsettledAcks() +qpid::messaging::Session::nextReceiver(qpid::messaging::Receiver&, qpid::messaging::Duration) +qpid::messaging::Session::nextReceiver(qpid::messaging::Duration) +qpid::messaging::Session::createSender(qpid::messaging::Address const&) +qpid::messaging::Session::createSender(std::string const&) +qpid::messaging::Session::createReceiver(qpid::messaging::Address const&) +qpid::messaging::Session::createReceiver(std::string const&) +qpid::messaging::Session::getSender(std::string const&) const +qpid::messaging::Session::getReceiver(std::string const&) const +qpid::messaging::Session::getConnection() const +qpid::messaging::Session::hasError() +qpid::messaging::Session::checkError() + +# Codec routines (properly superceded now by Messsage::setContentObject() +qpid::messaging::decode(qpid::messaging::Message const&, qpid::types::Variant::Map&, std::string const&) +qpid::messaging::decode(qpid::messaging::Message const&, qpid::types::Variant::List&, std::string const&) +qpid::messaging::encode(qpid::types::Variant::Map const&, qpid::messaging::Message&, std::string const&) +qpid::messaging::encode(qpid::types::Variant::List const&, qpid::messaging::Message&, std::string const&) + +# Exceptions +qpid::messaging::EncodingException::EncodingException(std::string const&) +qpid::messaging::EncodingException::~EncodingException() + +qpid::messaging::MessagingException::MessagingException(std::string const&) +qpid::messaging::MessagingException::~MessagingException() + +qpid::messaging::InvalidOptionString::InvalidOptionString(std::string const&) +qpid::messaging::InvalidOptionString::~InvalidOptionString() +qpid::messaging::KeyError::KeyError(std::string const&) +qpid::messaging::KeyError::~KeyError() +qpid::messaging::LinkError::LinkError(std::string const&) +qpid::messaging::LinkError::~LinkError() +qpid::messaging::AddressError::AddressError(std::string const&) +qpid::messaging::AddressError::~AddressError() +qpid::messaging::ResolutionError::ResolutionError(std::string const&) +qpid::messaging::ResolutionError::~ResolutionError() +qpid::messaging::AssertionFailed::AssertionFailed(std::string const&) +qpid::messaging::AssertionFailed::~AssertionFailed() +qpid::messaging::NotFound::NotFound(std::string const&) +qpid::messaging::NotFound::~NotFound() +qpid::messaging::MalformedAddress::MalformedAddress(std::string const&) +qpid::messaging::MalformedAddress::~MalformedAddress() +qpid::messaging::ReceiverError::ReceiverError(std::string const&) +qpid::messaging::ReceiverError::~ReceiverError() +qpid::messaging::FetchError::FetchError(std::string const&) +qpid::messaging::FetchError::~FetchError() +qpid::messaging::NoMessageAvailable::NoMessageAvailable() +qpid::messaging::NoMessageAvailable::~NoMessageAvailable() +qpid::messaging::SenderError::SenderError(std::string const&) +qpid::messaging::SenderError::~SenderError() +qpid::messaging::SendError::SendError(std::string const&) +qpid::messaging::SendError::~SendError() +qpid::messaging::TargetCapacityExceeded::TargetCapacityExceeded(std::string const&) +qpid::messaging::TargetCapacityExceeded::~TargetCapacityExceeded() +qpid::messaging::SessionError::SessionError(std::string const&) +qpid::messaging::SessionError::~SessionError() +qpid::messaging::TransactionError::TransactionError(std::string const&) +qpid::messaging::TransactionError::~TransactionError() +qpid::messaging::TransactionAborted::TransactionAborted(std::string const&) +qpid::messaging::TransactionAborted::~TransactionAborted() +qpid::messaging::UnauthorizedAccess::UnauthorizedAccess(std::string const&) +qpid::messaging::UnauthorizedAccess::~UnauthorizedAccess() +qpid::messaging::ConnectionError::ConnectionError(std::string const&) +qpid::messaging::ConnectionError::~ConnectionError() +qpid::messaging::TransportFailure::TransportFailure(std::string const&) +qpid::messaging::TransportFailure::~TransportFailure() + diff --git a/qpid/cpp/src/libqpidtypes-api-symbols.txt b/qpid/cpp/src/libqpidtypes-api-symbols.txt new file mode 100644 index 0000000000..5703ed7fb8 --- /dev/null +++ b/qpid/cpp/src/libqpidtypes-api-symbols.txt @@ -0,0 +1,122 @@ +# Uuid +qpid::types::Uuid::SIZE +qpid::types::Uuid::Uuid(bool) +qpid::types::Uuid::Uuid(qpid::types::Uuid const&) +qpid::types::Uuid::operator=(qpid::types::Uuid const&) +qpid::types::Uuid::Uuid(unsigned char const*) +qpid::types::Uuid::Uuid(char const*) +qpid::types::Uuid::generate() +qpid::types::Uuid::clear() +qpid::types::Uuid::isNull() const +qpid::types::Uuid::operator bool() const +qpid::types::Uuid::operator!() const +qpid::types::Uuid::str() const +qpid::types::Uuid::size() const +qpid::types::Uuid::data() const +qpid::types::Uuid::hash() const + +qpid::types::operator==(qpid::types::Uuid const&, qpid::types::Uuid const&) +qpid::types::operator!=(qpid::types::Uuid const&, qpid::types::Uuid const&) +qpid::types::operator<(qpid::types::Uuid const&, qpid::types::Uuid const&) +qpid::types::operator>(qpid::types::Uuid const&, qpid::types::Uuid const&) +qpid::types::operator<=(qpid::types::Uuid const&, qpid::types::Uuid const&) +qpid::types::operator>=(qpid::types::Uuid const&, qpid::types::Uuid const&) +qpid::types::operator<<(std::ostream&, qpid::types::Uuid) +qpid::types::operator>>(std::istream&, qpid::types::Uuid&) + +# VariantType +qpid::types::getTypeName(qpid::types::VariantType) +qpid::types::isIntegerType(qpid::types::VariantType) + +# Variant +qpid::types::Variant::Variant() +qpid::types::Variant::Variant(bool) +qpid::types::Variant::Variant(uint8_t) +qpid::types::Variant::Variant(uint16_t) +qpid::types::Variant::Variant(uint32_t) +qpid::types::Variant::Variant(uint64_t) +qpid::types::Variant::Variant(int8_t) +qpid::types::Variant::Variant(int16_t) +qpid::types::Variant::Variant(int32_t) +qpid::types::Variant::Variant(int64_t) +qpid::types::Variant::Variant(float) +qpid::types::Variant::Variant(double) +qpid::types::Variant::Variant(std::string const&) +qpid::types::Variant::Variant(char const*) +qpid::types::Variant::Variant(qpid::types::Variant::Map const&) +qpid::types::Variant::Variant(qpid::types::Variant::List const&) +qpid::types::Variant::Variant(qpid::types::Variant const&) +qpid::types::Variant::Variant(qpid::types::Uuid const&) +qpid::types::Variant::~Variant() +qpid::types::Variant::getType() const +qpid::types::Variant::isVoid() const +qpid::types::Variant::operator=(bool) +qpid::types::Variant::operator=(uint8_t) +qpid::types::Variant::operator=(uint16_t) +qpid::types::Variant::operator=(uint32_t) +qpid::types::Variant::operator=(uint64_t) +qpid::types::Variant::operator=(int8_t) +qpid::types::Variant::operator=(int16_t) +qpid::types::Variant::operator=(int32_t) +qpid::types::Variant::operator=(int64_t) +qpid::types::Variant::operator=(float) +qpid::types::Variant::operator=(double) +qpid::types::Variant::operator=(std::string const&) +qpid::types::Variant::operator=(char const*) +qpid::types::Variant::operator=(qpid::types::Variant::Map const&) +qpid::types::Variant::operator=(qpid::types::Variant::List const&) +qpid::types::Variant::operator=(qpid::types::Variant const&) +qpid::types::Variant::operator=(qpid::types::Uuid const&) +qpid::types::Variant::parse(std::string const&) +qpid::types::Variant::asBool() const +qpid::types::Variant::asUint8() const +qpid::types::Variant::asUint16() const +qpid::types::Variant::asUint32() const +qpid::types::Variant::asUint64() const +qpid::types::Variant::asInt8() const +qpid::types::Variant::asInt16() const +qpid::types::Variant::asInt32() const +qpid::types::Variant::asInt64() const +qpid::types::Variant::asFloat() const +qpid::types::Variant::asDouble() const +qpid::types::Variant::asString() const +qpid::types::Variant::asUuid() const +qpid::types::Variant::asMap() const +qpid::types::Variant::asMap() +qpid::types::Variant::asList() const +qpid::types::Variant::asList() +qpid::types::Variant::getString() const +qpid::types::Variant::getString() +qpid::types::Variant::setEncoding(std::string const&) +qpid::types::Variant::getEncoding() const +qpid::types::Variant::operator bool() const +qpid::types::Variant::operator uint8_t() const +qpid::types::Variant::operator uint16_t() const +qpid::types::Variant::operator uint32_t() const +qpid::types::Variant::operator uint64_t() const +qpid::types::Variant::operator int8_t() const +qpid::types::Variant::operator int16_t() const +qpid::types::Variant::operator int32_t() const +qpid::types::Variant::operator int64_t() const +qpid::types::Variant::operator float() const +qpid::types::Variant::operator double() const +qpid::types::Variant::operator std::string() const +qpid::types::Variant::operator qpid::types::Uuid() const +qpid::types::Variant::isEqualTo(qpid::types::Variant const&) const +qpid::types::Variant::reset() + +qpid::types::operator<<(std::ostream&, qpid::types::Variant const&) +qpid::types::operator<<(std::ostream&, qpid::types::Variant::Map const&) +qpid::types::operator<<(std::ostream&, qpid::types::Variant::List const&) +qpid::types::operator==(qpid::types::Variant const&, qpid::types::Variant const&) +qpid::types::operator!=(qpid::types::Variant const&, qpid::types::Variant const&) + +# Root of qpid::types Exception hierarchy +qpid::types::Exception::Exception(std::string const&) +qpid::types::Exception::~Exception() +qpid::types::Exception::what() const + +qpid::types::InvalidConversion::InvalidConversion(std::string const&) +qpid::types::InvalidConversion::~InvalidConversion() + + diff --git a/qpid/cpp/src/prof b/qpid/cpp/src/prof index acfbaff2d4..6276ff620a 100755 --- a/qpid/cpp/src/prof +++ b/qpid/cpp/src/prof @@ -32,8 +32,8 @@ opcontrol --start opcontrol --stop opcontrol --dump opcontrol --shutdown -opreport -l ./.libs/lt-qpidd > stats.txt -opannotate --source --output-dir=qpidd-prof ./.libs/lt-qpidd +opreport -l ./qpidd > stats.txt +opannotate --source --output-dir=qpidd-prof ./qpidd # clear the relusts #opcontrol --reset diff --git a/qpid/cpp/src/qmf.mk b/qpid/cpp/src/qmf.mk deleted file mode 100644 index 6a4bce4087..0000000000 --- a/qpid/cpp/src/qmf.mk +++ /dev/null @@ -1,177 +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. -# - -# -# qmf library makefile fragment, to be included in Makefile.am -# -lib_LTLIBRARIES += \ - libqmf.la \ - libqmfengine.la \ - libqmf2.la - -# -# Public headers for the QMF API -# -QMF_API = \ - ../include/qpid/agent/ManagementAgent.h \ - ../include/qpid/agent/QmfAgentImportExport.h \ - ../include/qmf/BrokerImportExport.h - -# -# Public headers for the QMF2 API -# -QMF2_API = \ - ../include/qmf/AgentEvent.h \ - ../include/qmf/Agent.h \ - ../include/qmf/AgentSession.h \ - ../include/qmf/ConsoleEvent.h \ - ../include/qmf/ConsoleSession.h \ - ../include/qmf/DataAddr.h \ - ../include/qmf/Data.h \ - ../include/qmf/posix/EventNotifier.h \ - ../include/qmf/exceptions.h \ - ../include/qmf/Handle.h \ - ../include/qmf/ImportExport.h \ - ../include/qmf/Query.h \ - ../include/qmf/Schema.h \ - ../include/qmf/SchemaId.h \ - ../include/qmf/SchemaMethod.h \ - ../include/qmf/SchemaProperty.h \ - ../include/qmf/SchemaTypes.h \ - ../include/qmf/Subscription.h - - -# -# Public headers for the QMF Engine API -# -QMF_ENGINE_API = \ - ../include/qmf/engine/Agent.h \ - ../include/qmf/engine/ConnectionSettings.h \ - ../include/qmf/engine/Console.h \ - ../include/qmf/engine/Event.h \ - ../include/qmf/engine/Message.h \ - ../include/qmf/engine/Object.h \ - ../include/qmf/engine/ObjectId.h \ - ../include/qmf/engine/QmfEngineImportExport.h \ - ../include/qmf/engine/Query.h \ - ../include/qmf/engine/ResilientConnection.h \ - ../include/qmf/engine/Schema.h \ - ../include/qmf/engine/Typecode.h \ - ../include/qmf/engine/Value.h - -# Public header files -nobase_include_HEADERS += \ - $(QMF_API) \ - $(QMF_ENGINE_API) \ - $(QMF2_API) - -libqmf_la_SOURCES = \ - $(QMF_API) \ - qpid/agent/ManagementAgentImpl.cpp \ - qpid/agent/ManagementAgentImpl.h - -libqmf2_la_SOURCES = \ - $(QMF2_API) \ - qmf/agentCapability.h \ - qmf/Agent.cpp \ - qmf/AgentEvent.cpp \ - qmf/AgentEventImpl.h \ - qmf/AgentImpl.h \ - qmf/AgentSession.cpp \ - qmf/AgentSessionImpl.h \ - qmf/AgentSubscription.cpp \ - qmf/AgentSubscription.h \ - qmf/ConsoleEvent.cpp \ - qmf/ConsoleEventImpl.h \ - qmf/ConsoleSession.cpp \ - qmf/ConsoleSessionImpl.h \ - qmf/constants.cpp \ - qmf/constants.h \ - qmf/DataAddr.cpp \ - qmf/DataAddrImpl.h \ - qmf/Data.cpp \ - qmf/DataImpl.h \ - qmf/EventNotifierImpl.cpp \ - qmf/EventNotifierImpl.h \ - qmf/exceptions.cpp \ - qmf/Expression.cpp \ - qmf/Expression.h \ - qmf/Hash.cpp \ - qmf/Hash.h \ - qmf/PosixEventNotifier.cpp \ - qmf/PosixEventNotifierImpl.cpp \ - qmf/PosixEventNotifierImpl.h \ - qmf/PrivateImplRef.h \ - qmf/Query.cpp \ - qmf/QueryImpl.h \ - qmf/SchemaCache.cpp \ - qmf/SchemaCache.h \ - qmf/Schema.cpp \ - qmf/SchemaId.cpp \ - qmf/SchemaIdImpl.h \ - qmf/SchemaImpl.h \ - qmf/SchemaMethod.cpp \ - qmf/SchemaMethodImpl.h \ - qmf/SchemaProperty.cpp \ - qmf/SchemaPropertyImpl.h \ - qmf/Subscription.cpp \ - qmf/SubscriptionImpl.h - -libqmfengine_la_SOURCES = \ - $(QMF_ENGINE_API) \ - qmf/engine/Agent.cpp \ - qmf/engine/BrokerProxyImpl.cpp \ - qmf/engine/BrokerProxyImpl.h \ - qmf/engine/ConnectionSettingsImpl.cpp \ - qmf/engine/ConnectionSettingsImpl.h \ - qmf/engine/ConsoleImpl.cpp \ - qmf/engine/ConsoleImpl.h \ - qmf/engine/EventImpl.cpp \ - qmf/engine/EventImpl.h \ - qmf/engine/MessageImpl.cpp \ - qmf/engine/MessageImpl.h \ - qmf/engine/ObjectIdImpl.cpp \ - qmf/engine/ObjectIdImpl.h \ - qmf/engine/ObjectImpl.cpp \ - qmf/engine/ObjectImpl.h \ - qmf/engine/Protocol.cpp \ - qmf/engine/Protocol.h \ - qmf/engine/QueryImpl.cpp \ - qmf/engine/QueryImpl.h \ - qmf/engine/ResilientConnection.cpp \ - qmf/engine/SequenceManager.cpp \ - qmf/engine/SequenceManager.h \ - qmf/engine/SchemaImpl.cpp \ - qmf/engine/SchemaImpl.h \ - qmf/engine/ValueImpl.cpp \ - qmf/engine/ValueImpl.h - -libqmf_la_LIBADD = libqmfengine.la -libqmf2_la_LIBADD = libqpidmessaging.la libqpidtypes.la -libqmfengine_la_LIBADD = libqpidclient.la - -QMF_VERSION_INFO = 1:0:0 -QMF2_VERSION_INFO = 1:0:0 -QMFENGINE_VERSION_INFO = 1:1:0 - -libqmf_la_LDFLAGS = -version-info $(QMF_VERSION_INFO) -libqmf2_la_LDFLAGS = -version-info $(QMF2_VERSION_INFO) -libqmfengine_la_LDFLAGS = -version-info $(QMFENGINE_VERSION_INFO) - -pkgconfig_DATA += qmf2.pc diff --git a/qpid/cpp/src/qmf/engine/Agent.cpp b/qpid/cpp/src/qmf/engine/Agent.cpp deleted file mode 100644 index 1f08dded94..0000000000 --- a/qpid/cpp/src/qmf/engine/Agent.cpp +++ /dev/null @@ -1,915 +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. - */ - -#include "qmf/engine/Agent.h" -#include "qmf/engine/MessageImpl.h" -#include "qmf/engine/SchemaImpl.h" -#include "qmf/engine/Typecode.h" -#include "qmf/engine/EventImpl.h" -#include "qmf/engine/ObjectImpl.h" -#include "qmf/engine/ObjectIdImpl.h" -#include "qmf/engine/QueryImpl.h" -#include "qmf/engine/ValueImpl.h" -#include "qmf/engine/Protocol.h" -#include <qpid/framing/Buffer.h> -#include <qpid/framing/Uuid.h> -#include <qpid/framing/FieldTable.h> -#include <qpid/framing/FieldValue.h> -#include <qpid/sys/Mutex.h> -#include <qpid/log/Statement.h> -#include <qpid/sys/Time.h> -#include <string.h> -#include <string> -#include <deque> -#include <map> -#include <iostream> -#include <fstream> -#include <boost/shared_ptr.hpp> -#include <boost/noncopyable.hpp> - -using namespace std; -using namespace qmf::engine; -using namespace qpid::framing; -using namespace qpid::sys; - -namespace qmf { -namespace engine { - - struct AgentEventImpl { - typedef boost::shared_ptr<AgentEventImpl> Ptr; - AgentEvent::EventKind kind; - uint32_t sequence; - string authUserId; - string authToken; - string name; - Object* object; - boost::shared_ptr<ObjectId> objectId; - boost::shared_ptr<Query> query; - boost::shared_ptr<Value> arguments; - string exchange; - string bindingKey; - const SchemaObjectClass* objectClass; - - AgentEventImpl(AgentEvent::EventKind k) : - kind(k), sequence(0), object(0), objectClass(0) {} - ~AgentEventImpl() {} - AgentEvent copy(); - }; - - struct AgentQueryContext { - typedef boost::shared_ptr<AgentQueryContext> Ptr; - uint32_t sequence; - string exchange; - string key; - const SchemaMethod* schemaMethod; - AgentQueryContext() : schemaMethod(0) {} - }; - - class AgentImpl : public boost::noncopyable { - public: - AgentImpl(char* label, bool internalStore); - ~AgentImpl(); - - void setStoreDir(const char* path); - void setTransferDir(const char* path); - void handleRcvMessage(Message& message); - bool getXmtMessage(Message& item) const; - void popXmt(); - bool getEvent(AgentEvent& event) const; - void popEvent(); - void newSession(); - void startProtocol(); - void heartbeat(); - void methodResponse(uint32_t sequence, uint32_t status, char* text, const Value& arguments); - void queryResponse(uint32_t sequence, Object& object, bool prop, bool stat); - void queryComplete(uint32_t sequence); - void registerClass(SchemaObjectClass* cls); - void registerClass(SchemaEventClass* cls); - const ObjectId* addObject(Object& obj, uint64_t persistId); - const ObjectId* allocObjectId(uint64_t persistId); - const ObjectId* allocObjectId(uint32_t persistIdLo, uint32_t persistIdHi); - void raiseEvent(Event& event); - - private: - mutable Mutex lock; - Mutex addLock; - string label; - string queueName; - string storeDir; - string transferDir; - bool internalStore; - uint64_t nextTransientId; - Uuid systemId; - uint32_t requestedBrokerBank; - uint32_t requestedAgentBank; - uint32_t assignedBrokerBank; - uint32_t assignedAgentBank; - AgentAttachment attachment; - uint16_t bootSequence; - uint64_t nextObjectId; - uint32_t nextContextNum; - deque<AgentEventImpl::Ptr> eventQueue; - deque<MessageImpl::Ptr> xmtQueue; - map<uint32_t, AgentQueryContext::Ptr> contextMap; - bool attachComplete; - - static const char* QMF_EXCHANGE; - static const char* DIR_EXCHANGE; - static const char* BROKER_KEY; - static const uint32_t MERR_UNKNOWN_METHOD = 2; - static const uint32_t MERR_UNKNOWN_PACKAGE = 8; - static const uint32_t MERR_UNKNOWN_CLASS = 9; - static const uint32_t MERR_INTERNAL_ERROR = 10; -# define MA_BUFFER_SIZE 65536 - char outputBuffer[MA_BUFFER_SIZE]; - - struct AgentClassKey { - string name; - uint8_t hash[16]; - AgentClassKey(const string& n, const uint8_t* h) : name(n) { - memcpy(hash, h, 16); - } - AgentClassKey(Buffer& buffer) { - buffer.getShortString(name); - buffer.getBin128(hash); - } - string repr() { - return name; - } - }; - - struct AgentClassKeyComp { - bool operator() (const AgentClassKey& lhs, const AgentClassKey& rhs) const - { - if (lhs.name != rhs.name) - return lhs.name < rhs.name; - else - for (int i = 0; i < 16; i++) - if (lhs.hash[i] != rhs.hash[i]) - return lhs.hash[i] < rhs.hash[i]; - return false; - } - }; - - typedef map<AgentClassKey, SchemaObjectClass*, AgentClassKeyComp> ObjectClassMap; - typedef map<AgentClassKey, SchemaEventClass*, AgentClassKeyComp> EventClassMap; - - struct ClassMaps { - ObjectClassMap objectClasses; - EventClassMap eventClasses; - }; - - map<string, ClassMaps> packages; - - AgentEventImpl::Ptr eventDeclareQueue(const string& queueName); - AgentEventImpl::Ptr eventBind(const string& exchange, const string& queue, const string& key); - AgentEventImpl::Ptr eventSetupComplete(); - AgentEventImpl::Ptr eventQuery(uint32_t num, const string& userId, const string& package, const string& cls, - boost::shared_ptr<ObjectId> oid); - AgentEventImpl::Ptr eventMethod(uint32_t num, const string& userId, const string& method, - boost::shared_ptr<ObjectId> oid, boost::shared_ptr<Value> argMap, - const SchemaObjectClass* objectClass); - void sendBufferLH(Buffer& buf, const string& destination, const string& routingKey); - - void sendPackageIndicationLH(const string& packageName); - void sendClassIndicationLH(ClassKind kind, const string& packageName, const AgentClassKey& key); - void sendCommandCompleteLH(const string& exchange, const string& key, uint32_t seq, - uint32_t code = 0, const string& text = "OK"); - void sendMethodErrorLH(uint32_t sequence, const string& key, uint32_t code, const string& text=""); - void handleAttachResponse(Buffer& inBuffer); - void handlePackageRequest(Buffer& inBuffer); - void handleClassQuery(Buffer& inBuffer); - void handleSchemaRequest(Buffer& inBuffer, uint32_t sequence, - const string& replyToExchange, const string& replyToKey); - void handleGetQuery(Buffer& inBuffer, uint32_t sequence, const string& replyTo, const string& userId); - void handleMethodRequest(Buffer& inBuffer, uint32_t sequence, const string& replyTo, const string& userId); - void handleConsoleAddedIndication(); - }; -} -} - -const char* AgentImpl::QMF_EXCHANGE = "qpid.management"; -const char* AgentImpl::DIR_EXCHANGE = "amq.direct"; -const char* AgentImpl::BROKER_KEY = "broker"; - -#define STRING_REF(s) {if (!s.empty()) item.s = const_cast<char*>(s.c_str());} - -AgentEvent AgentEventImpl::copy() -{ - AgentEvent item; - - ::memset(&item, 0, sizeof(AgentEvent)); - item.kind = kind; - item.sequence = sequence; - item.object = object; - item.objectId = objectId.get(); - item.query = query.get(); - item.arguments = arguments.get(); - item.objectClass = objectClass; - - STRING_REF(authUserId); - STRING_REF(authToken); - STRING_REF(name); - STRING_REF(exchange); - STRING_REF(bindingKey); - - return item; -} - -AgentImpl::AgentImpl(char* _label, bool i) : - label(_label), queueName("qmfa-"), internalStore(i), nextTransientId(1), - requestedBrokerBank(0), requestedAgentBank(0), - assignedBrokerBank(0), assignedAgentBank(0), - bootSequence(1), nextObjectId(1), nextContextNum(1), attachComplete(false) -{ - queueName += Uuid(true).str(); -} - -AgentImpl::~AgentImpl() -{ -} - -void AgentImpl::setStoreDir(const char* path) -{ - Mutex::ScopedLock _lock(lock); - if (path) - storeDir = path; - else - storeDir.clear(); -} - -void AgentImpl::setTransferDir(const char* path) -{ - Mutex::ScopedLock _lock(lock); - if (path) - transferDir = path; - else - transferDir.clear(); -} - -void AgentImpl::handleRcvMessage(Message& message) -{ - Buffer inBuffer(message.body, message.length); - uint8_t opcode; - uint32_t sequence; - string replyToExchange(message.replyExchange ? message.replyExchange : ""); - string replyToKey(message.replyKey ? message.replyKey : ""); - string userId(message.userId ? message.userId : ""); - - while (Protocol::checkHeader(inBuffer, &opcode, &sequence)) { - if (opcode == Protocol::OP_ATTACH_RESPONSE) handleAttachResponse(inBuffer); - else if (opcode == Protocol::OP_SCHEMA_REQUEST) handleSchemaRequest(inBuffer, sequence, replyToExchange, replyToKey); - else if (opcode == Protocol::OP_CONSOLE_ADDED_INDICATION) handleConsoleAddedIndication(); - else if (opcode == Protocol::OP_GET_QUERY) handleGetQuery(inBuffer, sequence, replyToKey, userId); - else if (opcode == Protocol::OP_METHOD_REQUEST) handleMethodRequest(inBuffer, sequence, replyToKey, userId); - else { - QPID_LOG(error, "AgentImpl::handleRcvMessage invalid opcode=" << opcode); - break; - } - } -} - -bool AgentImpl::getXmtMessage(Message& item) const -{ - Mutex::ScopedLock _lock(lock); - if (xmtQueue.empty()) - return false; - item = xmtQueue.front()->copy(); - return true; -} - -void AgentImpl::popXmt() -{ - Mutex::ScopedLock _lock(lock); - if (!xmtQueue.empty()) - xmtQueue.pop_front(); -} - -bool AgentImpl::getEvent(AgentEvent& event) const -{ - Mutex::ScopedLock _lock(lock); - if (eventQueue.empty()) - return false; - event = eventQueue.front()->copy(); - return true; -} - -void AgentImpl::popEvent() -{ - Mutex::ScopedLock _lock(lock); - if (!eventQueue.empty()) - eventQueue.pop_front(); -} - -void AgentImpl::newSession() -{ - Mutex::ScopedLock _lock(lock); - eventQueue.clear(); - xmtQueue.clear(); - eventQueue.push_back(eventDeclareQueue(queueName)); - eventQueue.push_back(eventBind("amq.direct", queueName, queueName)); - eventQueue.push_back(eventSetupComplete()); -} - -void AgentImpl::startProtocol() -{ - Mutex::ScopedLock _lock(lock); - char rawbuffer[512]; - Buffer buffer(rawbuffer, 512); - - Protocol::encodeHeader(buffer, Protocol::OP_ATTACH_REQUEST); - buffer.putShortString(label); - systemId.encode(buffer); - buffer.putLong(requestedBrokerBank); - buffer.putLong(requestedAgentBank); - sendBufferLH(buffer, QMF_EXCHANGE, BROKER_KEY); - QPID_LOG(trace, "SENT AttachRequest: reqBroker=" << requestedBrokerBank << - " reqAgent=" << requestedAgentBank); -} - -void AgentImpl::heartbeat() -{ - Mutex::ScopedLock _lock(lock); - Buffer buffer(outputBuffer, MA_BUFFER_SIZE); - - Protocol::encodeHeader(buffer, Protocol::OP_HEARTBEAT_INDICATION); - buffer.putLongLong(uint64_t(Duration(EPOCH, now()))); - stringstream key; - key << "console.heartbeat." << assignedBrokerBank << "." << assignedAgentBank; - sendBufferLH(buffer, QMF_EXCHANGE, key.str()); - QPID_LOG(trace, "SENT HeartbeatIndication"); -} - -void AgentImpl::methodResponse(uint32_t sequence, uint32_t status, char* text, const Value& argMap) -{ - Mutex::ScopedLock _lock(lock); - map<uint32_t, AgentQueryContext::Ptr>::iterator iter = contextMap.find(sequence); - if (iter == contextMap.end()) - return; - AgentQueryContext::Ptr context = iter->second; - contextMap.erase(iter); - - char* buf(outputBuffer); - uint32_t bufLen(114 + strlen(text)); // header(8) + status(4) + mstring(2 + size) + margin(100) - bool allocated(false); - - if (status == 0) { - for (vector<const SchemaArgument*>::const_iterator aIter = context->schemaMethod->impl->arguments.begin(); - aIter != context->schemaMethod->impl->arguments.end(); aIter++) { - const SchemaArgument* schemaArg = *aIter; - if (schemaArg->getDirection() == DIR_OUT || schemaArg->getDirection() == DIR_IN_OUT) { - if (argMap.keyInMap(schemaArg->getName())) { - const Value* val = argMap.byKey(schemaArg->getName()); - bufLen += val->impl->encodedSize(); - } else { - Value val(schemaArg->getType()); - bufLen += val.impl->encodedSize(); - } - } - } - } - - if (bufLen > MA_BUFFER_SIZE) { - buf = (char*) malloc(bufLen); - allocated = true; - } - - Buffer buffer(buf, bufLen); - Protocol::encodeHeader(buffer, Protocol::OP_METHOD_RESPONSE, context->sequence); - buffer.putLong(status); - buffer.putMediumString(text); - if (status == 0) { - for (vector<const SchemaArgument*>::const_iterator aIter = context->schemaMethod->impl->arguments.begin(); - aIter != context->schemaMethod->impl->arguments.end(); aIter++) { - const SchemaArgument* schemaArg = *aIter; - if (schemaArg->getDirection() == DIR_OUT || schemaArg->getDirection() == DIR_IN_OUT) { - if (argMap.keyInMap(schemaArg->getName())) { - const Value* val = argMap.byKey(schemaArg->getName()); - val->impl->encode(buffer); - } else { - Value val(schemaArg->getType()); - val.impl->encode(buffer); - } - } - } - } - sendBufferLH(buffer, context->exchange, context->key); - if (allocated) - free(buf); - QPID_LOG(trace, "SENT MethodResponse seq=" << context->sequence << " status=" << status << " text=" << text); -} - -void AgentImpl::queryResponse(uint32_t sequence, Object& object, bool prop, bool stat) -{ - Mutex::ScopedLock _lock(lock); - map<uint32_t, AgentQueryContext::Ptr>::iterator iter = contextMap.find(sequence); - if (iter == contextMap.end()) - return; - AgentQueryContext::Ptr context = iter->second; - - Buffer buffer(outputBuffer, MA_BUFFER_SIZE); - Protocol::encodeHeader(buffer, Protocol::OP_OBJECT_INDICATION, context->sequence); - - object.impl->encodeSchemaKey(buffer); - object.impl->encodeManagedObjectData(buffer); - if (prop) - object.impl->encodeProperties(buffer); - if (stat) - object.impl->encodeStatistics(buffer); - - sendBufferLH(buffer, context->exchange, context->key); - QPID_LOG(trace, "SENT ContentIndication seq=" << context->sequence); -} - -void AgentImpl::queryComplete(uint32_t sequence) -{ - Mutex::ScopedLock _lock(lock); - map<uint32_t, AgentQueryContext::Ptr>::iterator iter = contextMap.find(sequence); - if (iter == contextMap.end()) - return; - - AgentQueryContext::Ptr context = iter->second; - contextMap.erase(iter); - sendCommandCompleteLH(context->exchange, context->key, context->sequence, 0, "OK"); -} - -void AgentImpl::registerClass(SchemaObjectClass* cls) -{ - Mutex::ScopedLock _lock(lock); - bool newPackage = false; - - map<string, ClassMaps>::iterator iter = packages.find(cls->getClassKey()->getPackageName()); - if (iter == packages.end()) { - packages[cls->getClassKey()->getPackageName()] = ClassMaps(); - iter = packages.find(cls->getClassKey()->getPackageName()); - newPackage = true; - } - - AgentClassKey key(cls->getClassKey()->getClassName(), cls->getClassKey()->getHash()); - iter->second.objectClasses[key] = cls; - - // Indicate this new schema if connected. - - if (attachComplete) { - - if (newPackage) { - sendPackageIndicationLH(iter->first); - } - sendClassIndicationLH(CLASS_OBJECT, iter->first, key); - } -} - -void AgentImpl::registerClass(SchemaEventClass* cls) -{ - Mutex::ScopedLock _lock(lock); - bool newPackage = false; - - map<string, ClassMaps>::iterator iter = packages.find(cls->getClassKey()->getPackageName()); - if (iter == packages.end()) { - packages[cls->getClassKey()->getPackageName()] = ClassMaps(); - iter = packages.find(cls->getClassKey()->getPackageName()); - newPackage = true; - } - - AgentClassKey key(cls->getClassKey()->getClassName(), cls->getClassKey()->getHash()); - iter->second.eventClasses[key] = cls; - - // Indicate this new schema if connected. - - if (attachComplete) { - - if (newPackage) { - sendPackageIndicationLH(iter->first); - } - sendClassIndicationLH(CLASS_EVENT, iter->first, key); - } -} - -const ObjectId* AgentImpl::addObject(Object&, uint64_t) -{ - Mutex::ScopedLock _lock(lock); - return 0; -} - -const ObjectId* AgentImpl::allocObjectId(uint64_t persistId) -{ - Mutex::ScopedLock _lock(lock); - uint16_t sequence = persistId ? 0 : bootSequence; - uint64_t objectNum = persistId ? persistId : nextObjectId++; - - ObjectId* oid = ObjectIdImpl::factory(&attachment, 0, sequence, objectNum); - return oid; -} - -const ObjectId* AgentImpl::allocObjectId(uint32_t persistIdLo, uint32_t persistIdHi) -{ - return allocObjectId(((uint64_t) persistIdHi) << 32 | (uint64_t) persistIdLo); -} - -void AgentImpl::raiseEvent(Event& event) -{ - Mutex::ScopedLock _lock(lock); - Buffer buffer(outputBuffer, MA_BUFFER_SIZE); - Protocol::encodeHeader(buffer, Protocol::OP_EVENT_INDICATION); - - event.impl->encodeSchemaKey(buffer); - buffer.putLongLong(uint64_t(Duration(EPOCH, now()))); - event.impl->encode(buffer); - string key(event.impl->getRoutingKey(assignedBrokerBank, assignedAgentBank)); - - sendBufferLH(buffer, QMF_EXCHANGE, key); - QPID_LOG(trace, "SENT EventIndication"); -} - -AgentEventImpl::Ptr AgentImpl::eventDeclareQueue(const string& name) -{ - AgentEventImpl::Ptr event(new AgentEventImpl(AgentEvent::DECLARE_QUEUE)); - event->name = name; - - return event; -} - -AgentEventImpl::Ptr AgentImpl::eventBind(const string& exchange, const string& queue, - const string& key) -{ - AgentEventImpl::Ptr event(new AgentEventImpl(AgentEvent::BIND)); - event->name = queue; - event->exchange = exchange; - event->bindingKey = key; - - return event; -} - -AgentEventImpl::Ptr AgentImpl::eventSetupComplete() -{ - AgentEventImpl::Ptr event(new AgentEventImpl(AgentEvent::SETUP_COMPLETE)); - return event; -} - -AgentEventImpl::Ptr AgentImpl::eventQuery(uint32_t num, const string& userId, const string& package, - const string& cls, boost::shared_ptr<ObjectId> oid) -{ - AgentEventImpl::Ptr event(new AgentEventImpl(AgentEvent::GET_QUERY)); - event->sequence = num; - event->authUserId = userId; - if (oid.get()) - event->query.reset(new Query(oid.get())); - else - event->query.reset(new Query(cls.c_str(), package.c_str())); - return event; -} - -AgentEventImpl::Ptr AgentImpl::eventMethod(uint32_t num, const string& userId, const string& method, - boost::shared_ptr<ObjectId> oid, boost::shared_ptr<Value> argMap, - const SchemaObjectClass* objectClass) -{ - AgentEventImpl::Ptr event(new AgentEventImpl(AgentEvent::METHOD_CALL)); - event->sequence = num; - event->authUserId = userId; - event->name = method; - event->objectId = oid; - event->arguments = argMap; - event->objectClass = objectClass; - return event; -} - -void AgentImpl::sendBufferLH(Buffer& buf, const string& destination, const string& routingKey) -{ - uint32_t length = buf.getPosition(); - MessageImpl::Ptr message(new MessageImpl); - - buf.reset(); - buf.getRawData(message->body, length); - message->destination = destination; - message->routingKey = routingKey; - message->replyExchange = "amq.direct"; - message->replyKey = queueName; - - xmtQueue.push_back(message); -} - -void AgentImpl::sendPackageIndicationLH(const string& packageName) -{ - Buffer buffer(outputBuffer, MA_BUFFER_SIZE); - Protocol::encodeHeader(buffer, Protocol::OP_PACKAGE_INDICATION); - buffer.putShortString(packageName); - sendBufferLH(buffer, QMF_EXCHANGE, BROKER_KEY); - QPID_LOG(trace, "SENT PackageIndication: package_name=" << packageName); -} - -void AgentImpl::sendClassIndicationLH(ClassKind kind, const string& packageName, const AgentClassKey& key) -{ - Buffer buffer(outputBuffer, MA_BUFFER_SIZE); - Protocol::encodeHeader(buffer, Protocol::OP_CLASS_INDICATION); - buffer.putOctet((int) kind); - buffer.putShortString(packageName); - buffer.putShortString(key.name); - buffer.putBin128(const_cast<uint8_t*>(key.hash)); // const_cast needed for older Qpid libraries - sendBufferLH(buffer, QMF_EXCHANGE, BROKER_KEY); - QPID_LOG(trace, "SENT ClassIndication: package_name=" << packageName << " class_name=" << key.name); -} - -void AgentImpl::sendCommandCompleteLH(const string& exchange, const string& replyToKey, - uint32_t sequence, uint32_t code, const string& text) -{ - Buffer buffer(outputBuffer, MA_BUFFER_SIZE); - Protocol::encodeHeader(buffer, Protocol::OP_COMMAND_COMPLETE, sequence); - buffer.putLong(code); - buffer.putShortString(text); - sendBufferLH(buffer, exchange, replyToKey); - QPID_LOG(trace, "SENT CommandComplete: seq=" << sequence << " code=" << code << " text=" << text); -} - -void AgentImpl::sendMethodErrorLH(uint32_t sequence, const string& key, uint32_t code, const string& text) -{ - Buffer buffer(outputBuffer, MA_BUFFER_SIZE); - Protocol::encodeHeader(buffer, Protocol::OP_METHOD_RESPONSE, sequence); - buffer.putLong(code); - - string fulltext; - switch (code) { - case MERR_UNKNOWN_PACKAGE: fulltext = "Unknown Package"; break; - case MERR_UNKNOWN_CLASS: fulltext = "Unknown Class"; break; - case MERR_UNKNOWN_METHOD: fulltext = "Unknown Method"; break; - case MERR_INTERNAL_ERROR: fulltext = "Internal Error"; break; - default: fulltext = "Unspecified Error"; break; - } - - if (!text.empty()) { - fulltext += " ("; - fulltext += text; - fulltext += ")"; - } - - buffer.putMediumString(fulltext); - sendBufferLH(buffer, DIR_EXCHANGE, key); - QPID_LOG(trace, "SENT MethodResponse: errorCode=" << code << " text=" << fulltext); -} - -void AgentImpl::handleAttachResponse(Buffer& inBuffer) -{ - Mutex::ScopedLock _lock(lock); - - assignedBrokerBank = inBuffer.getLong(); - assignedAgentBank = inBuffer.getLong(); - - QPID_LOG(trace, "RCVD AttachResponse: broker=" << assignedBrokerBank << " agent=" << assignedAgentBank); - - if ((assignedBrokerBank != requestedBrokerBank) || - (assignedAgentBank != requestedAgentBank)) { - if (requestedAgentBank == 0) { - QPID_LOG(notice, "Initial object-id bank assigned: " << assignedBrokerBank << "." << - assignedAgentBank); - } else { - QPID_LOG(warning, "Collision in object-id! New bank assigned: " << assignedBrokerBank << - "." << assignedAgentBank); - } - //storeData(); // TODO - requestedBrokerBank = assignedBrokerBank; - requestedAgentBank = assignedAgentBank; - } - - attachment.setBanks(assignedBrokerBank, assignedAgentBank); - - // Bind to qpid.management to receive commands - stringstream key; - key << "agent." << assignedBrokerBank << "." << assignedAgentBank; - eventQueue.push_back(eventBind(QMF_EXCHANGE, queueName, key.str())); - - // Send package indications for all local packages - for (map<string, ClassMaps>::iterator pIter = packages.begin(); - pIter != packages.end(); - pIter++) { - sendPackageIndicationLH(pIter->first); - - // Send class indications for all local classes - ClassMaps cMap = pIter->second; - for (ObjectClassMap::iterator cIter = cMap.objectClasses.begin(); - cIter != cMap.objectClasses.end(); cIter++) - sendClassIndicationLH(CLASS_OBJECT, pIter->first, cIter->first); - for (EventClassMap::iterator cIter = cMap.eventClasses.begin(); - cIter != cMap.eventClasses.end(); cIter++) - sendClassIndicationLH(CLASS_EVENT, pIter->first, cIter->first); - } - - attachComplete = true; -} - -void AgentImpl::handlePackageRequest(Buffer&) -{ - Mutex::ScopedLock _lock(lock); -} - -void AgentImpl::handleClassQuery(Buffer&) -{ - Mutex::ScopedLock _lock(lock); -} - -void AgentImpl::handleSchemaRequest(Buffer& inBuffer, uint32_t sequence, - const string& replyExchange, const string& replyKey) -{ - Mutex::ScopedLock _lock(lock); - string rExchange(replyExchange); - string rKey(replyKey); - string packageName; - inBuffer.getShortString(packageName); - AgentClassKey key(inBuffer); - - if (rExchange.empty()) - rExchange = QMF_EXCHANGE; - if (rKey.empty()) - rKey = BROKER_KEY; - - QPID_LOG(trace, "RCVD SchemaRequest: package=" << packageName << " class=" << key.name); - - map<string, ClassMaps>::iterator pIter = packages.find(packageName); - if (pIter == packages.end()) { - sendCommandCompleteLH(rExchange, rKey, sequence, 1, "package not found"); - return; - } - - ClassMaps cMap = pIter->second; - ObjectClassMap::iterator ocIter = cMap.objectClasses.find(key); - if (ocIter != cMap.objectClasses.end()) { - SchemaObjectClass* oImpl = ocIter->second; - Buffer buffer(outputBuffer, MA_BUFFER_SIZE); - Protocol::encodeHeader(buffer, Protocol::OP_SCHEMA_RESPONSE, sequence); - oImpl->impl->encode(buffer); - sendBufferLH(buffer, rExchange, rKey); - QPID_LOG(trace, "SENT SchemaResponse: (object) package=" << packageName << " class=" << key.name); - return; - } - - EventClassMap::iterator ecIter = cMap.eventClasses.find(key); - if (ecIter != cMap.eventClasses.end()) { - SchemaEventClass* eImpl = ecIter->second; - Buffer buffer(outputBuffer, MA_BUFFER_SIZE); - Protocol::encodeHeader(buffer, Protocol::OP_SCHEMA_RESPONSE, sequence); - eImpl->impl->encode(buffer); - sendBufferLH(buffer, rExchange, rKey); - QPID_LOG(trace, "SENT SchemaResponse: (event) package=" << packageName << " class=" << key.name); - return; - } - - sendCommandCompleteLH(rExchange, rKey, sequence, 1, "class not found"); -} - -void AgentImpl::handleGetQuery(Buffer& inBuffer, uint32_t sequence, const string& replyTo, const string& userId) -{ - Mutex::ScopedLock _lock(lock); - FieldTable ft; - FieldTable::ValuePtr value; - map<string, ClassMaps>::const_iterator pIter = packages.end(); - string pname; - string cname; - string oidRepr; - boost::shared_ptr<ObjectId> oid; - - ft.decode(inBuffer); - - QPID_LOG(trace, "RCVD GetQuery: seq=" << sequence << " map=" << ft); - - value = ft.get("_package"); - if (value.get() && value->convertsTo<string>()) { - pname = value->get<string>(); - pIter = packages.find(pname); - if (pIter == packages.end()) { - sendCommandCompleteLH(DIR_EXCHANGE, replyTo, sequence); - return; - } - } - - value = ft.get("_class"); - if (value.get() && value->convertsTo<string>()) { - cname = value->get<string>(); - // TODO - check for validity of class (in package or any package) - if (pIter == packages.end()) { - } else { - - } - } - - value = ft.get("_objectid"); - if (value.get() && value->convertsTo<string>()) { - oidRepr = value->get<string>(); - oid.reset(new ObjectId()); - oid->impl->fromString(oidRepr); - } - - AgentQueryContext::Ptr context(new AgentQueryContext); - uint32_t contextNum = nextContextNum++; - context->sequence = sequence; - context->exchange = DIR_EXCHANGE; - context->key = replyTo; - contextMap[contextNum] = context; - - eventQueue.push_back(eventQuery(contextNum, userId, pname, cname, oid)); -} - -void AgentImpl::handleMethodRequest(Buffer& buffer, uint32_t sequence, const string& replyTo, const string& userId) -{ - Mutex::ScopedLock _lock(lock); - string pname; - string method; - boost::shared_ptr<ObjectId> oid(ObjectIdImpl::factory(buffer)); - buffer.getShortString(pname); - AgentClassKey classKey(buffer); - buffer.getShortString(method); - - QPID_LOG(trace, "RCVD MethodRequest seq=" << sequence << " method=" << method); - - map<string, ClassMaps>::const_iterator pIter = packages.find(pname); - if (pIter == packages.end()) { - sendMethodErrorLH(sequence, replyTo, MERR_UNKNOWN_PACKAGE, pname); - return; - } - - ObjectClassMap::const_iterator cIter = pIter->second.objectClasses.find(classKey); - if (cIter == pIter->second.objectClasses.end()) { - sendMethodErrorLH(sequence, replyTo, MERR_UNKNOWN_CLASS, classKey.repr()); - return; - } - - const SchemaObjectClass* schema = cIter->second; - vector<const SchemaMethod*>::const_iterator mIter = schema->impl->methods.begin(); - for (; mIter != schema->impl->methods.end(); mIter++) { - if ((*mIter)->getName() == method) - break; - } - - if (mIter == schema->impl->methods.end()) { - sendMethodErrorLH(sequence, replyTo, MERR_UNKNOWN_METHOD, method); - return; - } - - const SchemaMethod* schemaMethod = *mIter; - boost::shared_ptr<Value> argMap(new Value(TYPE_MAP)); - Value* value; - for (vector<const SchemaArgument*>::const_iterator aIter = schemaMethod->impl->arguments.begin(); - aIter != schemaMethod->impl->arguments.end(); aIter++) { - const SchemaArgument* schemaArg = *aIter; - if (schemaArg->getDirection() == DIR_IN || schemaArg->getDirection() == DIR_IN_OUT) - value = ValueImpl::factory(schemaArg->getType(), buffer); - else - value = ValueImpl::factory(schemaArg->getType()); - argMap->insert(schemaArg->getName(), value); - } - - AgentQueryContext::Ptr context(new AgentQueryContext); - uint32_t contextNum = nextContextNum++; - context->sequence = sequence; - context->exchange = DIR_EXCHANGE; - context->key = replyTo; - context->schemaMethod = schemaMethod; - contextMap[contextNum] = context; - - eventQueue.push_back(eventMethod(contextNum, userId, method, oid, argMap, schema)); -} - -void AgentImpl::handleConsoleAddedIndication() -{ - Mutex::ScopedLock _lock(lock); -} - -//================================================================== -// Wrappers -//================================================================== - -Agent::Agent(char* label, bool internalStore) { impl = new AgentImpl(label, internalStore); } -Agent::~Agent() { delete impl; } -void Agent::setStoreDir(const char* path) { impl->setStoreDir(path); } -void Agent::setTransferDir(const char* path) { impl->setTransferDir(path); } -void Agent::handleRcvMessage(Message& message) { impl->handleRcvMessage(message); } -bool Agent::getXmtMessage(Message& item) const { return impl->getXmtMessage(item); } -void Agent::popXmt() { impl->popXmt(); } -bool Agent::getEvent(AgentEvent& event) const { return impl->getEvent(event); } -void Agent::popEvent() { impl->popEvent(); } -void Agent::newSession() { impl->newSession(); } -void Agent::startProtocol() { impl->startProtocol(); } -void Agent::heartbeat() { impl->heartbeat(); } -void Agent::methodResponse(uint32_t sequence, uint32_t status, char* text, const Value& arguments) { impl->methodResponse(sequence, status, text, arguments); } -void Agent::queryResponse(uint32_t sequence, Object& object, bool prop, bool stat) { impl->queryResponse(sequence, object, prop, stat); } -void Agent::queryComplete(uint32_t sequence) { impl->queryComplete(sequence); } -void Agent::registerClass(SchemaObjectClass* cls) { impl->registerClass(cls); } -void Agent::registerClass(SchemaEventClass* cls) { impl->registerClass(cls); } -const ObjectId* Agent::addObject(Object& obj, uint64_t persistId) { return impl->addObject(obj, persistId); } -const ObjectId* Agent::allocObjectId(uint64_t persistId) { return impl->allocObjectId(persistId); } -const ObjectId* Agent::allocObjectId(uint32_t persistIdLo, uint32_t persistIdHi) { return impl->allocObjectId(persistIdLo, persistIdHi); } -void Agent::raiseEvent(Event& event) { impl->raiseEvent(event); } - diff --git a/qpid/cpp/src/qmf/engine/BrokerProxyImpl.cpp b/qpid/cpp/src/qmf/engine/BrokerProxyImpl.cpp deleted file mode 100644 index 5fc71979fd..0000000000 --- a/qpid/cpp/src/qmf/engine/BrokerProxyImpl.cpp +++ /dev/null @@ -1,827 +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. - */ - -#include "qmf/engine/BrokerProxyImpl.h" -#include "qmf/engine/ConsoleImpl.h" -#include "qmf/engine/Protocol.h" -#include "qpid/Address.h" -#include "qpid/sys/SystemInfo.h" -#include <qpid/log/Statement.h> -#include <qpid/StringUtils.h> -#include <string.h> -#include <iostream> -#include <fstream> - -using namespace std; -using namespace qmf::engine; -using namespace qpid::framing; -using namespace qpid::sys; - -namespace { - const char* QMF_EXCHANGE = "qpid.management"; - const char* DIR_EXCHANGE = "amq.direct"; - const char* BROKER_KEY = "broker"; - const char* BROKER_PACKAGE = "org.apache.qpid.broker"; - const char* AGENT_CLASS = "agent"; - const char* BROKER_AGENT_KEY = "agent.1.0"; -} - -const Object* QueryResponseImpl::getObject(uint32_t idx) const -{ - vector<ObjectPtr>::const_iterator iter = results.begin(); - - while (idx > 0) { - if (iter == results.end()) - return 0; - iter++; - idx--; - } - - return iter->get(); -} - -#define STRING_REF(s) {if (!s.empty()) item.s = const_cast<char*>(s.c_str());} - -BrokerEvent BrokerEventImpl::copy() -{ - BrokerEvent item; - - ::memset(&item, 0, sizeof(BrokerEvent)); - item.kind = kind; - - STRING_REF(name); - STRING_REF(exchange); - STRING_REF(bindingKey); - item.context = context; - item.queryResponse = queryResponse.get(); - item.methodResponse = methodResponse.get(); - - return item; -} - -BrokerProxyImpl::BrokerProxyImpl(BrokerProxy& pub, Console& _console) : publicObject(pub), console(_console) -{ - stringstream qn; - qpid::Address addr; - - SystemInfo::getLocalHostname(addr); - qn << "qmfc-" << SystemInfo::getProcessName() << "-" << addr << "-" << SystemInfo::getProcessId(); - queueName = qn.str(); - - seqMgr.setUnsolicitedContext(SequenceContext::Ptr(new StaticContext(*this))); -} - -void BrokerProxyImpl::sessionOpened(SessionHandle& /*sh*/) -{ - Mutex::ScopedLock _lock(lock); - agentList.clear(); - eventQueue.clear(); - xmtQueue.clear(); - eventQueue.push_back(eventDeclareQueue(queueName)); - eventQueue.push_back(eventBind(DIR_EXCHANGE, queueName, queueName)); - eventQueue.push_back(eventSetupComplete()); - - // TODO: Store session handle -} - -void BrokerProxyImpl::sessionClosed() -{ - Mutex::ScopedLock _lock(lock); - agentList.clear(); - eventQueue.clear(); - xmtQueue.clear(); -} - -void BrokerProxyImpl::startProtocol() -{ - AgentProxyPtr agent(AgentProxyImpl::factory(console, publicObject, 0, "Agent embedded in broker")); - { - Mutex::ScopedLock _lock(lock); - char rawbuffer[512]; - Buffer buffer(rawbuffer, 512); - - agentList[0] = agent; - - requestsOutstanding = 1; - topicBound = false; - uint32_t sequence(seqMgr.reserve()); - Protocol::encodeHeader(buffer, Protocol::OP_BROKER_REQUEST, sequence); - sendBufferLH(buffer, QMF_EXCHANGE, BROKER_KEY); - QPID_LOG(trace, "SENT BrokerRequest seq=" << sequence); - } - - console.impl->eventAgentAdded(agent); -} - -void BrokerProxyImpl::sendBufferLH(Buffer& buf, const string& destination, const string& routingKey) -{ - uint32_t length = buf.getPosition(); - MessageImpl::Ptr message(new MessageImpl); - - buf.reset(); - buf.getRawData(message->body, length); - message->destination = destination; - message->routingKey = routingKey; - message->replyExchange = DIR_EXCHANGE; - message->replyKey = queueName; - - xmtQueue.push_back(message); -} - -void BrokerProxyImpl::handleRcvMessage(Message& message) -{ - Buffer inBuffer(message.body, message.length); - uint8_t opcode; - uint32_t sequence; - - while (Protocol::checkHeader(inBuffer, &opcode, &sequence)) - seqMgr.dispatch(opcode, sequence, message.routingKey ? string(message.routingKey) : string(), inBuffer); -} - -bool BrokerProxyImpl::getXmtMessage(Message& item) const -{ - Mutex::ScopedLock _lock(lock); - if (xmtQueue.empty()) - return false; - item = xmtQueue.front()->copy(); - return true; -} - -void BrokerProxyImpl::popXmt() -{ - Mutex::ScopedLock _lock(lock); - if (!xmtQueue.empty()) - xmtQueue.pop_front(); -} - -bool BrokerProxyImpl::getEvent(BrokerEvent& event) const -{ - Mutex::ScopedLock _lock(lock); - if (eventQueue.empty()) - return false; - event = eventQueue.front()->copy(); - return true; -} - -void BrokerProxyImpl::popEvent() -{ - Mutex::ScopedLock _lock(lock); - if (!eventQueue.empty()) - eventQueue.pop_front(); -} - -uint32_t BrokerProxyImpl::agentCount() const -{ - Mutex::ScopedLock _lock(lock); - return agentList.size(); -} - -const AgentProxy* BrokerProxyImpl::getAgent(uint32_t idx) const -{ - Mutex::ScopedLock _lock(lock); - for (map<uint32_t, AgentProxyPtr>::const_iterator iter = agentList.begin(); - iter != agentList.end(); iter++) - if (idx-- == 0) - return iter->second.get(); - return 0; -} - -void BrokerProxyImpl::sendQuery(const Query& query, void* context, const AgentProxy* agent) -{ - SequenceContext::Ptr queryContext(new QueryContext(*this, context)); - Mutex::ScopedLock _lock(lock); - bool sent = false; - if (agent != 0) { - if (sendGetRequestLH(queryContext, query, agent)) - sent = true; - } else { - // TODO (optimization) only send queries to agents that have the requested class+package - for (map<uint32_t, AgentProxyPtr>::const_iterator iter = agentList.begin(); - iter != agentList.end(); iter++) { - if (sendGetRequestLH(queryContext, query, iter->second.get())) - sent = true; - } - } - - if (!sent) { - queryContext->reserve(); - queryContext->release(); - } -} - -bool BrokerProxyImpl::sendGetRequestLH(SequenceContext::Ptr queryContext, const Query& query, const AgentProxy* agent) -{ - if (query.impl->singleAgent()) { - if (query.impl->agentBank() != agent->getAgentBank()) - return false; - } - stringstream key; - Buffer outBuffer(outputBuffer, MA_BUFFER_SIZE); - uint32_t sequence(seqMgr.reserve(queryContext)); - agent->impl->addSequence(sequence); - - Protocol::encodeHeader(outBuffer, Protocol::OP_GET_QUERY, sequence); - query.impl->encode(outBuffer); - key << "agent.1." << agent->impl->agentBank; - sendBufferLH(outBuffer, QMF_EXCHANGE, key.str()); - QPID_LOG(trace, "SENT GetQuery seq=" << sequence << " key=" << key.str()); - return true; -} - -string BrokerProxyImpl::encodeMethodArguments(const SchemaMethod* schema, const Value* argmap, Buffer& buffer) -{ - int argCount = schema->getArgumentCount(); - - if (argmap == 0 || !argmap->isMap()) - return string("Arguments must be in a map value"); - - for (int aIdx = 0; aIdx < argCount; aIdx++) { - const SchemaArgument* arg(schema->getArgument(aIdx)); - if (arg->getDirection() == DIR_IN || arg->getDirection() == DIR_IN_OUT) { - if (argmap->keyInMap(arg->getName())) { - const Value* argVal(argmap->byKey(arg->getName())); - if (argVal->getType() != arg->getType()) - return string("Argument is the wrong type: ") + arg->getName(); - argVal->impl->encode(buffer); - } else { - Value defaultValue(arg->getType()); - defaultValue.impl->encode(buffer); - } - } - } - - return string(); -} - -string BrokerProxyImpl::encodedSizeMethodArguments(const SchemaMethod* schema, const Value* argmap, uint32_t& size) -{ - int argCount = schema->getArgumentCount(); - - if (argmap == 0 || !argmap->isMap()) - return string("Arguments must be in a map value"); - - for (int aIdx = 0; aIdx < argCount; aIdx++) { - const SchemaArgument* arg(schema->getArgument(aIdx)); - if (arg->getDirection() == DIR_IN || arg->getDirection() == DIR_IN_OUT) { - if (argmap->keyInMap(arg->getName())) { - const Value* argVal(argmap->byKey(arg->getName())); - if (argVal->getType() != arg->getType()) - return string("Argument is the wrong type: ") + arg->getName(); - size += argVal->impl->encodedSize(); - } else { - Value defaultValue(arg->getType()); - size += defaultValue.impl->encodedSize(); - } - } - } - - return string(); -} - -void BrokerProxyImpl::sendMethodRequest(ObjectId* oid, const SchemaObjectClass* cls, - const string& methodName, const Value* args, void* userContext) -{ - int methodCount = cls->getMethodCount(); - int idx; - for (idx = 0; idx < methodCount; idx++) { - const SchemaMethod* method = cls->getMethod(idx); - if (string(method->getName()) == methodName) { - Mutex::ScopedLock _lock(lock); - SequenceContext::Ptr methodContext(new MethodContext(*this, userContext, method)); - stringstream key; - char* buf(outputBuffer); - uint32_t bufLen(1024); - bool allocated(false); - - string argErrorString = encodedSizeMethodArguments(method, args, bufLen); - if (!argErrorString.empty()) { - MethodResponsePtr argError(MethodResponseImpl::factory(1, argErrorString)); - eventQueue.push_back(eventMethodResponse(userContext, argError)); - return; - } - - if (bufLen > MA_BUFFER_SIZE) { - buf = (char*) malloc(bufLen); - allocated = true; - } - - Buffer outBuffer(buf, bufLen); - uint32_t sequence(seqMgr.reserve(methodContext)); - - Protocol::encodeHeader(outBuffer, Protocol::OP_METHOD_REQUEST, sequence); - oid->impl->encode(outBuffer); - cls->getClassKey()->impl->encode(outBuffer); - outBuffer.putShortString(methodName); - - encodeMethodArguments(method, args, outBuffer); - key << "agent.1." << oid->impl->getAgentBank(); - sendBufferLH(outBuffer, QMF_EXCHANGE, key.str()); - QPID_LOG(trace, "SENT MethodRequest seq=" << sequence << " method=" << methodName << " key=" << key.str()); - - if (allocated) - free(buf); - - return; - } - } - - MethodResponsePtr error(MethodResponseImpl::factory(1, string("Unknown method: ") + methodName)); - Mutex::ScopedLock _lock(lock); - eventQueue.push_back(eventMethodResponse(userContext, error)); -} - -void BrokerProxyImpl::addBinding(const string& exchange, const string& key) -{ - Mutex::ScopedLock _lock(lock); - eventQueue.push_back(eventBind(exchange, queueName, key)); -} - -BrokerEventImpl::Ptr BrokerProxyImpl::eventDeclareQueue(const string& queueName) -{ - BrokerEventImpl::Ptr event(new BrokerEventImpl(BrokerEvent::DECLARE_QUEUE)); - event->name = queueName; - return event; -} - -BrokerEventImpl::Ptr BrokerProxyImpl::eventBind(const string& exchange, const string& queue, const string& key) -{ - BrokerEventImpl::Ptr event(new BrokerEventImpl(BrokerEvent::BIND)); - event->name = queue; - event->exchange = exchange; - event->bindingKey = key; - - return event; -} - -BrokerEventImpl::Ptr BrokerProxyImpl::eventSetupComplete() -{ - BrokerEventImpl::Ptr event(new BrokerEventImpl(BrokerEvent::SETUP_COMPLETE)); - return event; -} - -BrokerEventImpl::Ptr BrokerProxyImpl::eventStable() -{ - QPID_LOG(trace, "Console Link to Broker Stable"); - BrokerEventImpl::Ptr event(new BrokerEventImpl(BrokerEvent::STABLE)); - return event; -} - -BrokerEventImpl::Ptr BrokerProxyImpl::eventQueryComplete(void* context, QueryResponsePtr response) -{ - BrokerEventImpl::Ptr event(new BrokerEventImpl(BrokerEvent::QUERY_COMPLETE)); - event->context = context; - event->queryResponse = response; - return event; -} - -BrokerEventImpl::Ptr BrokerProxyImpl::eventMethodResponse(void* context, MethodResponsePtr response) -{ - BrokerEventImpl::Ptr event(new BrokerEventImpl(BrokerEvent::METHOD_RESPONSE)); - event->context = context; - event->methodResponse = response; - return event; -} - -void BrokerProxyImpl::handleBrokerResponse(Buffer& inBuffer, uint32_t seq) -{ - brokerId.decode(inBuffer); - QPID_LOG(trace, "RCVD BrokerResponse seq=" << seq << " brokerId=" << brokerId); - Mutex::ScopedLock _lock(lock); - Buffer outBuffer(outputBuffer, MA_BUFFER_SIZE); - uint32_t sequence(seqMgr.reserve()); - incOutstandingLH(); - Protocol::encodeHeader(outBuffer, Protocol::OP_PACKAGE_REQUEST, sequence); - sendBufferLH(outBuffer, QMF_EXCHANGE, BROKER_KEY); - QPID_LOG(trace, "SENT PackageRequest seq=" << sequence); -} - -void BrokerProxyImpl::handlePackageIndication(Buffer& inBuffer, uint32_t seq) -{ - string package; - - inBuffer.getShortString(package); - QPID_LOG(trace, "RCVD PackageIndication seq=" << seq << " package=" << package); - console.impl->learnPackage(package); - - Mutex::ScopedLock _lock(lock); - Buffer outBuffer(outputBuffer, MA_BUFFER_SIZE); - uint32_t sequence(seqMgr.reserve()); - incOutstandingLH(); - Protocol::encodeHeader(outBuffer, Protocol::OP_CLASS_QUERY, sequence); - outBuffer.putShortString(package); - sendBufferLH(outBuffer, QMF_EXCHANGE, BROKER_KEY); - QPID_LOG(trace, "SENT ClassQuery seq=" << sequence << " package=" << package); -} - -void BrokerProxyImpl::handleCommandComplete(Buffer& inBuffer, uint32_t seq) -{ - string text; - uint32_t code = inBuffer.getLong(); - inBuffer.getShortString(text); - QPID_LOG(trace, "RCVD CommandComplete seq=" << seq << " code=" << code << " text=" << text); -} - -void BrokerProxyImpl::handleClassIndication(Buffer& inBuffer, uint32_t seq) -{ - uint8_t kind = inBuffer.getOctet(); - auto_ptr<SchemaClassKey> classKey(SchemaClassKeyImpl::factory(inBuffer)); - - QPID_LOG(trace, "RCVD ClassIndication seq=" << seq << " kind=" << (int) kind << " key=" << classKey->impl->str()); - - if (!console.impl->haveClass(classKey.get())) { - Mutex::ScopedLock _lock(lock); - incOutstandingLH(); - Buffer outBuffer(outputBuffer, MA_BUFFER_SIZE); - uint32_t sequence(seqMgr.reserve()); - Protocol::encodeHeader(outBuffer, Protocol::OP_SCHEMA_REQUEST, sequence); - classKey->impl->encode(outBuffer); - sendBufferLH(outBuffer, QMF_EXCHANGE, BROKER_KEY); - QPID_LOG(trace, "SENT SchemaRequest seq=" << sequence <<" key=" << classKey->impl->str()); - } -} - -MethodResponsePtr BrokerProxyImpl::handleMethodResponse(Buffer& inBuffer, uint32_t seq, const SchemaMethod* schema) -{ - MethodResponsePtr response(MethodResponseImpl::factory(inBuffer, schema)); - - QPID_LOG(trace, "RCVD MethodResponse seq=" << seq << " status=" << response->getStatus() << " text=" << - response->getException()->asString()); - - return response; -} - -void BrokerProxyImpl::handleHeartbeatIndication(Buffer& inBuffer, uint32_t seq, const string& routingKey) -{ - vector<string> tokens = qpid::split(routingKey, "."); - uint32_t agentBank; - uint64_t timestamp; - - if (routingKey.empty() || tokens.size() != 4) - agentBank = 0; - else - agentBank = ::atoi(tokens[3].c_str()); - - timestamp = inBuffer.getLongLong(); - map<uint32_t, AgentProxyPtr>::const_iterator iter = agentList.find(agentBank); - if (iter != agentList.end()) { - console.impl->eventAgentHeartbeat(iter->second, timestamp); - } - QPID_LOG(trace, "RCVD HeartbeatIndication seq=" << seq << " agentBank=" << agentBank); -} - -void BrokerProxyImpl::handleEventIndication(Buffer& inBuffer, uint32_t seq) -{ - auto_ptr<SchemaClassKey> classKey(SchemaClassKeyImpl::factory(inBuffer)); - const SchemaEventClass *schema = console.impl->getEventClass(classKey.get()); - if (schema == 0) { - QPID_LOG(trace, "No Schema Found for EventIndication. seq=" << seq << " key=" << classKey->impl->str()); - return; - } - - EventPtr eptr(EventImpl::factory(schema, inBuffer)); - - console.impl->eventEventReceived(eptr); - QPID_LOG(trace, "RCVD EventIndication seq=" << seq << " key=" << classKey->impl->str()); -} - -void BrokerProxyImpl::handleSchemaResponse(Buffer& inBuffer, uint32_t seq) -{ - SchemaObjectClass* oClassPtr; - SchemaEventClass* eClassPtr; - uint8_t kind = inBuffer.getOctet(); - const SchemaClassKey* key; - if (kind == CLASS_OBJECT) { - oClassPtr = SchemaObjectClassImpl::factory(inBuffer); - console.impl->learnClass(oClassPtr); - key = oClassPtr->getClassKey(); - QPID_LOG(trace, "RCVD SchemaResponse seq=" << seq << " kind=object key=" << key->impl->str()); - - // - // If we have just learned about the org.apache.qpid.broker:agent class, send a get - // request for the current list of agents so we can have it on-hand before we declare - // this session "stable". - // - if (key->impl->getClassName() == AGENT_CLASS && key->impl->getPackageName() == BROKER_PACKAGE) { - Mutex::ScopedLock _lock(lock); - incOutstandingLH(); - Buffer outBuffer(outputBuffer, MA_BUFFER_SIZE); - uint32_t sequence(seqMgr.reserve()); - Protocol::encodeHeader(outBuffer, Protocol::OP_GET_QUERY, sequence); - FieldTable ft; - ft.setString("_class", AGENT_CLASS); - ft.setString("_package", BROKER_PACKAGE); - ft.encode(outBuffer); - sendBufferLH(outBuffer, QMF_EXCHANGE, BROKER_AGENT_KEY); - QPID_LOG(trace, "SENT GetQuery seq=" << sequence << " key=" << BROKER_AGENT_KEY); - } - } else if (kind == CLASS_EVENT) { - eClassPtr = SchemaEventClassImpl::factory(inBuffer); - console.impl->learnClass(eClassPtr); - key = eClassPtr->getClassKey(); - QPID_LOG(trace, "RCVD SchemaResponse seq=" << seq << " kind=event key=" << key->impl->str()); - } - else { - QPID_LOG(error, "BrokerProxyImpl::handleSchemaResponse received unknown class kind: " << (int) kind); - } -} - -ObjectPtr BrokerProxyImpl::handleObjectIndication(Buffer& inBuffer, uint32_t seq, bool prop, bool stat) -{ - auto_ptr<SchemaClassKey> classKey(SchemaClassKeyImpl::factory(inBuffer)); - QPID_LOG(trace, "RCVD ObjectIndication seq=" << seq << " key=" << classKey->impl->str()); - - SchemaObjectClass* schema = console.impl->getSchema(classKey.get()); - if (schema == 0) { - QPID_LOG(trace, "No Schema Found for ObjectIndication. seq=" << seq << " key=" << classKey->impl->str()); - return ObjectPtr(); - } - - ObjectPtr optr(ObjectImpl::factory(schema, this, inBuffer, prop, stat, true)); - if (prop && classKey->impl->getPackageName() == BROKER_PACKAGE && classKey->impl->getClassName() == AGENT_CLASS) { - // - // We've intercepted information about a remote agent... update the agent list accordingly - // - updateAgentList(optr); - } - return optr; -} - -void BrokerProxyImpl::updateAgentList(ObjectPtr obj) -{ - Value* value = obj->getValue("agentBank"); - Mutex::ScopedLock _lock(lock); - if (value != 0 && value->isUint()) { - uint32_t agentBank = value->asUint(); - if (obj->isDeleted()) { - map<uint32_t, AgentProxyPtr>::iterator iter = agentList.find(agentBank); - if (iter != agentList.end()) { - AgentProxyPtr agent(iter->second); - console.impl->eventAgentDeleted(agent); - agentList.erase(agentBank); - QPID_LOG(trace, "Agent at bank " << agentBank << " removed from agent list"); - - // - // Release all sequence numbers for requests in-flight to this agent. - // Since the agent is no longer connected, these requests would not - // otherwise complete. - // - agent->impl->releaseInFlight(seqMgr); - } - } else { - Value* str = obj->getValue("label"); - string label; - if (str != 0 && str->isString()) - label = str->asString(); - map<uint32_t, AgentProxyPtr>::const_iterator iter = agentList.find(agentBank); - if (iter == agentList.end()) { - AgentProxyPtr agent(AgentProxyImpl::factory(console, publicObject, agentBank, label)); - agentList[agentBank] = agent; - console.impl->eventAgentAdded(agent); - QPID_LOG(trace, "Agent '" << label << "' found at bank " << agentBank); - } - } - } -} - -void BrokerProxyImpl::incOutstandingLH() -{ - requestsOutstanding++; -} - -void BrokerProxyImpl::decOutstanding() -{ - Mutex::ScopedLock _lock(lock); - requestsOutstanding--; - if (requestsOutstanding == 0 && !topicBound) { - topicBound = true; - for (vector<pair<string, string> >::const_iterator iter = console.impl->bindingList.begin(); - iter != console.impl->bindingList.end(); iter++) { - string exchange(iter->first.empty() ? QMF_EXCHANGE : iter->first); - string key(iter->second); - eventQueue.push_back(eventBind(exchange, queueName, key)); - } - eventQueue.push_back(eventStable()); - } -} - -MethodResponseImpl::MethodResponseImpl(const MethodResponseImpl& from) : - status(from.status), schema(from.schema) -{ - if (from.exception.get()) - exception.reset(new Value(*(from.exception))); - if (from.arguments.get()) - arguments.reset(new Value(*(from.arguments))); -} - -MethodResponseImpl::MethodResponseImpl(Buffer& buf, const SchemaMethod* s) : schema(s) -{ - string text; - - status = buf.getLong(); - buf.getMediumString(text); - exception.reset(new Value(TYPE_LSTR)); - exception->setString(text.c_str()); - - if (status != 0) - return; - - arguments.reset(new Value(TYPE_MAP)); - int argCount(schema->getArgumentCount()); - for (int idx = 0; idx < argCount; idx++) { - const SchemaArgument* arg = schema->getArgument(idx); - if (arg->getDirection() == DIR_OUT || arg->getDirection() == DIR_IN_OUT) { - Value* value(ValueImpl::factory(arg->getType(), buf)); - arguments->insert(arg->getName(), value); - } - } -} - -MethodResponseImpl::MethodResponseImpl(uint32_t s, const string& text) : schema(0) -{ - status = s; - exception.reset(new Value(TYPE_LSTR)); - exception->setString(text.c_str()); -} - -MethodResponse* MethodResponseImpl::factory(Buffer& buf, const SchemaMethod* schema) -{ - MethodResponseImpl* impl(new MethodResponseImpl(buf, schema)); - return new MethodResponse(impl); -} - -MethodResponse* MethodResponseImpl::factory(uint32_t status, const std::string& text) -{ - MethodResponseImpl* impl(new MethodResponseImpl(status, text)); - return new MethodResponse(impl); -} - -bool StaticContext::handleMessage(uint8_t opcode, uint32_t sequence, const string& routingKey, Buffer& buffer) -{ - ObjectPtr object; - bool completeContext = false; - - if (opcode == Protocol::OP_BROKER_RESPONSE) { - broker.handleBrokerResponse(buffer, sequence); - completeContext = true; - } - else if (opcode == Protocol::OP_COMMAND_COMPLETE) { - broker.handleCommandComplete(buffer, sequence); - completeContext = true; - } - else if (opcode == Protocol::OP_SCHEMA_RESPONSE) { - broker.handleSchemaResponse(buffer, sequence); - completeContext = true; - } - else if (opcode == Protocol::OP_PACKAGE_INDICATION) - broker.handlePackageIndication(buffer, sequence); - else if (opcode == Protocol::OP_CLASS_INDICATION) - broker.handleClassIndication(buffer, sequence); - else if (opcode == Protocol::OP_HEARTBEAT_INDICATION) - broker.handleHeartbeatIndication(buffer, sequence, routingKey); - else if (opcode == Protocol::OP_EVENT_INDICATION) - broker.handleEventIndication(buffer, sequence); - else if (opcode == Protocol::OP_PROPERTY_INDICATION) { - object = broker.handleObjectIndication(buffer, sequence, true, false); - broker.console.impl->eventObjectUpdate(object, true, false); - } - else if (opcode == Protocol::OP_STATISTIC_INDICATION) { - object = broker.handleObjectIndication(buffer, sequence, false, true); - broker.console.impl->eventObjectUpdate(object, false, true); - } - else if (opcode == Protocol::OP_OBJECT_INDICATION) { - object = broker.handleObjectIndication(buffer, sequence, true, true); - broker.console.impl->eventObjectUpdate(object, true, true); - } - else { - QPID_LOG(trace, "StaticContext::handleMessage invalid opcode: " << opcode); - completeContext = true; - } - - return completeContext; -} - -void QueryContext::reserve() -{ - Mutex::ScopedLock _lock(lock); - requestsOutstanding++; -} - -void QueryContext::release() -{ - { - Mutex::ScopedLock _lock(lock); - if (--requestsOutstanding > 0) - return; - } - - Mutex::ScopedLock _block(broker.lock); - broker.eventQueue.push_back(broker.eventQueryComplete(userContext, queryResponse)); -} - -bool QueryContext::handleMessage(uint8_t opcode, uint32_t sequence, const string& /*routingKey*/, Buffer& buffer) -{ - bool completeContext = false; - ObjectPtr object; - - if (opcode == Protocol::OP_COMMAND_COMPLETE) { - broker.handleCommandComplete(buffer, sequence); - completeContext = true; - - // - // Visit each agent and remove the sequence from that agent's in-flight list. - // This could be made more efficient because only one agent will have this sequence - // in its list. - // - map<uint32_t, AgentProxyPtr> copy; - { - Mutex::ScopedLock _block(broker.lock); - copy = broker.agentList; - } - for (map<uint32_t, AgentProxyPtr>::iterator iter = copy.begin(); iter != copy.end(); iter++) - iter->second->impl->delSequence(sequence); - } - else if (opcode == Protocol::OP_OBJECT_INDICATION) { - object = broker.handleObjectIndication(buffer, sequence, true, true); - if (object.get() != 0) - queryResponse->impl->results.push_back(object); - } - else { - QPID_LOG(trace, "QueryContext::handleMessage invalid opcode: " << opcode); - completeContext = true; - } - - return completeContext; -} - -void MethodContext::release() -{ - Mutex::ScopedLock _block(broker.lock); - broker.eventQueue.push_back(broker.eventMethodResponse(userContext, methodResponse)); -} - -bool MethodContext::handleMessage(uint8_t opcode, uint32_t sequence, const string& /*routingKey*/, Buffer& buffer) -{ - if (opcode == Protocol::OP_METHOD_RESPONSE) - methodResponse = broker.handleMethodResponse(buffer, sequence, schema); - else - QPID_LOG(trace, "QueryContext::handleMessage invalid opcode: " << opcode); - - return true; -} - - -//================================================================== -// Wrappers -//================================================================== - -AgentProxy::AgentProxy(AgentProxyImpl* i) : impl(i) {} -AgentProxy::AgentProxy(const AgentProxy& from) : impl(new AgentProxyImpl(*(from.impl))) {} -AgentProxy::~AgentProxy() { delete impl; } -const char* AgentProxy::getLabel() const { return impl->getLabel().c_str(); } -uint32_t AgentProxy::getBrokerBank() const { return impl->getBrokerBank(); } -uint32_t AgentProxy::getAgentBank() const { return impl->getAgentBank(); } - -BrokerProxy::BrokerProxy(Console& console) : impl(new BrokerProxyImpl(*this, console)) {} -BrokerProxy::~BrokerProxy() { delete impl; } -void BrokerProxy::sessionOpened(SessionHandle& sh) { impl->sessionOpened(sh); } -void BrokerProxy::sessionClosed() { impl->sessionClosed(); } -void BrokerProxy::startProtocol() { impl->startProtocol(); } -void BrokerProxy::handleRcvMessage(Message& message) { impl->handleRcvMessage(message); } -bool BrokerProxy::getXmtMessage(Message& item) const { return impl->getXmtMessage(item); } -void BrokerProxy::popXmt() { impl->popXmt(); } -bool BrokerProxy::getEvent(BrokerEvent& event) const { return impl->getEvent(event); } -void BrokerProxy::popEvent() { impl->popEvent(); } -uint32_t BrokerProxy::agentCount() const { return impl->agentCount(); } -const AgentProxy* BrokerProxy::getAgent(uint32_t idx) const { return impl->getAgent(idx); } -void BrokerProxy::sendQuery(const Query& query, void* context, const AgentProxy* agent) { impl->sendQuery(query, context, agent); } - -MethodResponse::MethodResponse(const MethodResponse& from) : impl(new MethodResponseImpl(*(from.impl))) {} -MethodResponse::MethodResponse(MethodResponseImpl* i) : impl(i) {} -MethodResponse::~MethodResponse() {} -uint32_t MethodResponse::getStatus() const { return impl->getStatus(); } -const Value* MethodResponse::getException() const { return impl->getException(); } -const Value* MethodResponse::getArgs() const { return impl->getArgs(); } - -QueryResponse::QueryResponse(QueryResponseImpl* i) : impl(i) {} -QueryResponse::~QueryResponse() {} -uint32_t QueryResponse::getStatus() const { return impl->getStatus(); } -const Value* QueryResponse::getException() const { return impl->getException(); } -uint32_t QueryResponse::getObjectCount() const { return impl->getObjectCount(); } -const Object* QueryResponse::getObject(uint32_t idx) const { return impl->getObject(idx); } - diff --git a/qpid/cpp/src/qmf/engine/BrokerProxyImpl.h b/qpid/cpp/src/qmf/engine/BrokerProxyImpl.h deleted file mode 100644 index 0542b67dbb..0000000000 --- a/qpid/cpp/src/qmf/engine/BrokerProxyImpl.h +++ /dev/null @@ -1,241 +0,0 @@ -#ifndef _QmfEngineBrokerProxyImpl_ -#define _QmfEngineBrokerProxyImpl_ - -/* - * 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 "qmf/engine/Console.h" -#include "qmf/engine/ObjectImpl.h" -#include "qmf/engine/EventImpl.h" -#include "qmf/engine/SchemaImpl.h" -#include "qmf/engine/ValueImpl.h" -#include "qmf/engine/QueryImpl.h" -#include "qmf/engine/SequenceManager.h" -#include "qmf/engine/MessageImpl.h" -#include "qpid/framing/Buffer.h" -#include "qpid/framing/Uuid.h" -#include "qpid/sys/Mutex.h" -#include "boost/shared_ptr.hpp" -#include "boost/noncopyable.hpp" -#include <memory> -#include <string> -#include <deque> -#include <map> -#include <set> -#include <vector> - -namespace qmf { -namespace engine { - - typedef boost::shared_ptr<MethodResponse> MethodResponsePtr; - struct MethodResponseImpl { - uint32_t status; - const SchemaMethod* schema; - std::auto_ptr<Value> exception; - std::auto_ptr<Value> arguments; - - MethodResponseImpl(const MethodResponseImpl& from); - MethodResponseImpl(qpid::framing::Buffer& buf, const SchemaMethod* schema); - MethodResponseImpl(uint32_t status, const std::string& text); - static MethodResponse* factory(qpid::framing::Buffer& buf, const SchemaMethod* schema); - static MethodResponse* factory(uint32_t status, const std::string& text); - ~MethodResponseImpl() {} - uint32_t getStatus() const { return status; } - const Value* getException() const { return exception.get(); } - const Value* getArgs() const { return arguments.get(); } - }; - - typedef boost::shared_ptr<QueryResponse> QueryResponsePtr; - struct QueryResponseImpl { - uint32_t status; - std::auto_ptr<Value> exception; - std::vector<ObjectPtr> results; - - QueryResponseImpl() : status(0) {} - static QueryResponse* factory() { - QueryResponseImpl* impl(new QueryResponseImpl()); - return new QueryResponse(impl); - } - ~QueryResponseImpl() {} - uint32_t getStatus() const { return status; } - const Value* getException() const { return exception.get(); } - uint32_t getObjectCount() const { return results.size(); } - const Object* getObject(uint32_t idx) const; - }; - - struct BrokerEventImpl { - typedef boost::shared_ptr<BrokerEventImpl> Ptr; - BrokerEvent::EventKind kind; - std::string name; - std::string exchange; - std::string bindingKey; - void* context; - QueryResponsePtr queryResponse; - MethodResponsePtr methodResponse; - - BrokerEventImpl(BrokerEvent::EventKind k) : kind(k), context(0) {} - ~BrokerEventImpl() {} - BrokerEvent copy(); - }; - - typedef boost::shared_ptr<AgentProxy> AgentProxyPtr; - struct AgentProxyImpl { - Console& console; - BrokerProxy& broker; - uint32_t agentBank; - std::string label; - std::set<uint32_t> inFlightSequences; - - AgentProxyImpl(Console& c, BrokerProxy& b, uint32_t ab, const std::string& l) : console(c), broker(b), agentBank(ab), label(l) {} - static AgentProxy* factory(Console& c, BrokerProxy& b, uint32_t ab, const std::string& l) { - AgentProxyImpl* impl(new AgentProxyImpl(c, b, ab, l)); - return new AgentProxy(impl); - } - ~AgentProxyImpl() {} - const std::string& getLabel() const { return label; } - uint32_t getBrokerBank() const { return 1; } - uint32_t getAgentBank() const { return agentBank; } - void addSequence(uint32_t seq) { inFlightSequences.insert(seq); } - void delSequence(uint32_t seq) { inFlightSequences.erase(seq); } - void releaseInFlight(SequenceManager& seqMgr) { - for (std::set<uint32_t>::iterator iter = inFlightSequences.begin(); iter != inFlightSequences.end(); iter++) - seqMgr.release(*iter); - inFlightSequences.clear(); - } - }; - - class BrokerProxyImpl : public boost::noncopyable { - public: - BrokerProxyImpl(BrokerProxy& pub, Console& _console); - ~BrokerProxyImpl() {} - - void sessionOpened(SessionHandle& sh); - void sessionClosed(); - void startProtocol(); - - void sendBufferLH(qpid::framing::Buffer& buf, const std::string& destination, const std::string& routingKey); - void handleRcvMessage(Message& message); - bool getXmtMessage(Message& item) const; - void popXmt(); - - bool getEvent(BrokerEvent& event) const; - void popEvent(); - - uint32_t agentCount() const; - const AgentProxy* getAgent(uint32_t idx) const; - void sendQuery(const Query& query, void* context, const AgentProxy* agent); - bool sendGetRequestLH(SequenceContext::Ptr queryContext, const Query& query, const AgentProxy* agent); - std::string encodeMethodArguments(const SchemaMethod* schema, const Value* args, qpid::framing::Buffer& buffer); - std::string encodedSizeMethodArguments(const SchemaMethod* schema, const Value* args, uint32_t& size); - void sendMethodRequest(ObjectId* oid, const SchemaObjectClass* cls, const std::string& method, const Value* args, void* context); - - void addBinding(const std::string& exchange, const std::string& key); - void staticRelease() { decOutstanding(); } - - private: - friend struct StaticContext; - friend struct QueryContext; - friend struct MethodContext; - BrokerProxy& publicObject; - mutable qpid::sys::Mutex lock; - Console& console; - std::string queueName; - qpid::framing::Uuid brokerId; - SequenceManager seqMgr; - uint32_t requestsOutstanding; - bool topicBound; - std::map<uint32_t, AgentProxyPtr> agentList; - std::deque<MessageImpl::Ptr> xmtQueue; - std::deque<BrokerEventImpl::Ptr> eventQueue; - -# define MA_BUFFER_SIZE 65536 - char outputBuffer[MA_BUFFER_SIZE]; - - BrokerEventImpl::Ptr eventDeclareQueue(const std::string& queueName); - BrokerEventImpl::Ptr eventBind(const std::string& exchange, const std::string& queue, const std::string& key); - BrokerEventImpl::Ptr eventSetupComplete(); - BrokerEventImpl::Ptr eventStable(); - BrokerEventImpl::Ptr eventQueryComplete(void* context, QueryResponsePtr response); - BrokerEventImpl::Ptr eventMethodResponse(void* context, MethodResponsePtr response); - - void handleBrokerResponse(qpid::framing::Buffer& inBuffer, uint32_t seq); - void handlePackageIndication(qpid::framing::Buffer& inBuffer, uint32_t seq); - void handleCommandComplete(qpid::framing::Buffer& inBuffer, uint32_t seq); - void handleClassIndication(qpid::framing::Buffer& inBuffer, uint32_t seq); - MethodResponsePtr handleMethodResponse(qpid::framing::Buffer& inBuffer, uint32_t seq, const SchemaMethod* schema); - void handleHeartbeatIndication(qpid::framing::Buffer& inBuffer, uint32_t seq, const std::string& routingKey); - void handleEventIndication(qpid::framing::Buffer& inBuffer, uint32_t seq); - void handleSchemaResponse(qpid::framing::Buffer& inBuffer, uint32_t seq); - ObjectPtr handleObjectIndication(qpid::framing::Buffer& inBuffer, uint32_t seq, bool prop, bool stat); - void updateAgentList(ObjectPtr obj); - void incOutstandingLH(); - void decOutstanding(); - }; - - // - // StaticContext is used to handle: - // - // 1) Responses to console-level requests (for schema info, etc.) - // 2) Unsolicited messages from agents (events, published updates, etc.) - // - struct StaticContext : public SequenceContext { - StaticContext(BrokerProxyImpl& b) : broker(b) {} - virtual ~StaticContext() {} - void reserve() {} - void release() { broker.staticRelease(); } - bool handleMessage(uint8_t opcode, uint32_t sequence, const std::string& routingKey, qpid::framing::Buffer& buffer); - BrokerProxyImpl& broker; - }; - - // - // QueryContext is used to track and handle responses associated with a single Get Query - // - struct QueryContext : public SequenceContext { - QueryContext(BrokerProxyImpl& b, void* u) : - broker(b), userContext(u), requestsOutstanding(0), queryResponse(QueryResponseImpl::factory()) {} - virtual ~QueryContext() {} - void reserve(); - void release(); - bool handleMessage(uint8_t opcode, uint32_t sequence, const std::string& routingKey, qpid::framing::Buffer& buffer); - - mutable qpid::sys::Mutex lock; - BrokerProxyImpl& broker; - void* userContext; - uint32_t requestsOutstanding; - QueryResponsePtr queryResponse; - }; - - struct MethodContext : public SequenceContext { - MethodContext(BrokerProxyImpl& b, void* u, const SchemaMethod* s) : broker(b), userContext(u), schema(s) {} - virtual ~MethodContext() {} - void reserve() {} - void release(); - bool handleMessage(uint8_t opcode, uint32_t sequence, const std::string& routingKey, qpid::framing::Buffer& buffer); - - BrokerProxyImpl& broker; - void* userContext; - const SchemaMethod* schema; - MethodResponsePtr methodResponse; - }; - -} -} - -#endif - diff --git a/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.cpp b/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.cpp deleted file mode 100644 index 22a65f28ca..0000000000 --- a/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.cpp +++ /dev/null @@ -1,278 +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. - */ - -#include "qmf/engine/ConnectionSettingsImpl.h" -#include "qmf/engine/Typecode.h" - -using namespace std; -using namespace qmf::engine; -using namespace qpid; - -const string attrProtocol("protocol"); -const string attrHost("host"); -const string attrPort("port"); -const string attrVirtualhost("virtualhost"); -const string attrUsername("username"); -const string attrPassword("password"); -const string attrMechanism("mechanism"); -const string attrLocale("locale"); -const string attrHeartbeat("heartbeat"); -const string attrMaxChannels("maxChannels"); -const string attrMaxFrameSize("maxFrameSize"); -const string attrBounds("bounds"); -const string attrTcpNoDelay("tcpNoDelay"); -const string attrService("service"); -const string attrMinSsf("minSsf"); -const string attrMaxSsf("maxSsf"); -const string attrRetryDelayMin("retryDelayMin"); -const string attrRetryDelayMax("retryDelayMax"); -const string attrRetryDelayFactor("retryDelayFactor"); -const string attrSendUserId("sendUserId"); - -ConnectionSettingsImpl::ConnectionSettingsImpl() : - retryDelayMin(1), retryDelayMax(64), retryDelayFactor(2), sendUserId(true) -{ -} - -ConnectionSettingsImpl::ConnectionSettingsImpl(const string& /*url*/) : - retryDelayMin(1), retryDelayMax(64), retryDelayFactor(2), sendUserId(true) -{ - // TODO: Parse the URL -} - -bool ConnectionSettingsImpl::setAttr(const string& key, const Value& value) -{ - if (key == attrProtocol) clientSettings.protocol = value.asString(); - else if (key == attrHost) clientSettings.host = value.asString(); - else if (key == attrPort) clientSettings.port = value.asUint(); - else if (key == attrVirtualhost) clientSettings.virtualhost = value.asString(); - else if (key == attrUsername) clientSettings.username = value.asString(); - else if (key == attrPassword) clientSettings.password = value.asString(); - else if (key == attrMechanism) clientSettings.mechanism = value.asString(); - else if (key == attrLocale) clientSettings.locale = value.asString(); - else if (key == attrHeartbeat) clientSettings.heartbeat = value.asUint(); - else if (key == attrMaxChannels) clientSettings.maxChannels = value.asUint(); - else if (key == attrMaxFrameSize) clientSettings.maxFrameSize = value.asUint(); - else if (key == attrBounds) clientSettings.bounds = value.asUint(); - else if (key == attrTcpNoDelay) clientSettings.tcpNoDelay = value.asBool(); - else if (key == attrService) clientSettings.service = value.asString(); - else if (key == attrMinSsf) clientSettings.minSsf = value.asUint(); - else if (key == attrMaxSsf) clientSettings.maxSsf = value.asUint(); - - else if (key == attrRetryDelayMin) retryDelayMin = value.asUint(); - else if (key == attrRetryDelayMax) retryDelayMax = value.asUint(); - else if (key == attrRetryDelayFactor) retryDelayFactor = value.asUint(); - else if (key == attrSendUserId) sendUserId = value.asBool(); - else - return false; - return true; -} - -Value ConnectionSettingsImpl::getAttr(const string& key) const -{ - Value strval(TYPE_LSTR); - Value intval(TYPE_UINT32); - Value boolval(TYPE_BOOL); - - if (key == attrProtocol) { - strval.setString(clientSettings.protocol.c_str()); - return strval; - } - - if (key == attrHost) { - strval.setString(clientSettings.host.c_str()); - return strval; - } - - if (key == attrPort) { - intval.setUint(clientSettings.port); - return intval; - } - - if (key == attrVirtualhost) { - strval.setString(clientSettings.virtualhost.c_str()); - return strval; - } - - if (key == attrUsername) { - strval.setString(clientSettings.username.c_str()); - return strval; - } - - if (key == attrPassword) { - strval.setString(clientSettings.password.c_str()); - return strval; - } - - if (key == attrMechanism) { - strval.setString(clientSettings.mechanism.c_str()); - return strval; - } - - if (key == attrLocale) { - strval.setString(clientSettings.locale.c_str()); - return strval; - } - - if (key == attrHeartbeat) { - intval.setUint(clientSettings.heartbeat); - return intval; - } - - if (key == attrMaxChannels) { - intval.setUint(clientSettings.maxChannels); - return intval; - } - - if (key == attrMaxFrameSize) { - intval.setUint(clientSettings.maxFrameSize); - return intval; - } - - if (key == attrBounds) { - intval.setUint(clientSettings.bounds); - return intval; - } - - if (key == attrTcpNoDelay) { - boolval.setBool(clientSettings.tcpNoDelay); - return boolval; - } - - if (key == attrService) { - strval.setString(clientSettings.service.c_str()); - return strval; - } - - if (key == attrMinSsf) { - intval.setUint(clientSettings.minSsf); - return intval; - } - - if (key == attrMaxSsf) { - intval.setUint(clientSettings.maxSsf); - return intval; - } - - if (key == attrRetryDelayMin) { - intval.setUint(retryDelayMin); - return intval; - } - - if (key == attrRetryDelayMax) { - intval.setUint(retryDelayMax); - return intval; - } - - if (key == attrRetryDelayFactor) { - intval.setUint(retryDelayFactor); - return intval; - } - - if (key == attrSendUserId) { - boolval.setBool(sendUserId); - return boolval; - } - - return strval; -} - -const string& ConnectionSettingsImpl::getAttrString() const -{ - // TODO: build and return attribute string - return attrString; -} - -void ConnectionSettingsImpl::transportTcp(uint16_t port) -{ - clientSettings.protocol = "tcp"; - clientSettings.port = port; -} - -void ConnectionSettingsImpl::transportSsl(uint16_t port) -{ - clientSettings.protocol = "ssl"; - clientSettings.port = port; -} - -void ConnectionSettingsImpl::transportRdma(uint16_t port) -{ - clientSettings.protocol = "rdma"; - clientSettings.port = port; -} - -void ConnectionSettingsImpl::authAnonymous(const string& username) -{ - clientSettings.mechanism = "ANONYMOUS"; - clientSettings.username = username; -} - -void ConnectionSettingsImpl::authPlain(const string& username, const string& password) -{ - clientSettings.mechanism = "PLAIN"; - clientSettings.username = username; - clientSettings.password = password; -} - -void ConnectionSettingsImpl::authGssapi(const string& serviceName, uint32_t minSsf, uint32_t maxSsf) -{ - clientSettings.mechanism = "GSSAPI"; - clientSettings.service = serviceName; - clientSettings.minSsf = minSsf; - clientSettings.maxSsf = maxSsf; -} - -void ConnectionSettingsImpl::setRetry(int delayMin, int delayMax, int delayFactor) -{ - retryDelayMin = delayMin; - retryDelayMax = delayMax; - retryDelayFactor = delayFactor; -} - -const client::ConnectionSettings& ConnectionSettingsImpl::getClientSettings() const -{ - return clientSettings; -} - -void ConnectionSettingsImpl::getRetrySettings(int* min, int* max, int* factor) const -{ - *min = retryDelayMin; - *max = retryDelayMax; - *factor = retryDelayFactor; -} - -//================================================================== -// Wrappers -//================================================================== - -ConnectionSettings::ConnectionSettings(const ConnectionSettings& from) { impl = new ConnectionSettingsImpl(*from.impl); } -ConnectionSettings::ConnectionSettings() { impl = new ConnectionSettingsImpl(); } -ConnectionSettings::ConnectionSettings(const char* url) { impl = new ConnectionSettingsImpl(url); } -ConnectionSettings::~ConnectionSettings() { delete impl; } -bool ConnectionSettings::setAttr(const char* key, const Value& value) { return impl->setAttr(key, value); } -Value ConnectionSettings::getAttr(const char* key) const { return impl->getAttr(key); } -const char* ConnectionSettings::getAttrString() const { return impl->getAttrString().c_str(); } -void ConnectionSettings::transportTcp(uint16_t port) { impl->transportTcp(port); } -void ConnectionSettings::transportSsl(uint16_t port) { impl->transportSsl(port); } -void ConnectionSettings::transportRdma(uint16_t port) { impl->transportRdma(port); } -void ConnectionSettings::authAnonymous(const char* username) { impl->authAnonymous(username); } -void ConnectionSettings::authPlain(const char* username, const char* password) { impl->authPlain(username, password); } -void ConnectionSettings::authGssapi(const char* serviceName, uint32_t minSsf, uint32_t maxSsf) { impl->authGssapi(serviceName, minSsf, maxSsf); } -void ConnectionSettings::setRetry(int delayMin, int delayMax, int delayFactor) { impl->setRetry(delayMin, delayMax, delayFactor); } - diff --git a/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.h b/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.h deleted file mode 100644 index 98bf87868b..0000000000 --- a/qpid/cpp/src/qmf/engine/ConnectionSettingsImpl.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _QmfEngineConnectionSettingsImpl_ -#define _QmfEngineConnectionSettingsImpl_ - -/* - * 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 "qmf/engine/ConnectionSettings.h" -#include "qmf/engine/Value.h" -#include "qpid/client/ConnectionSettings.h" -#include <string> -#include <map> - -namespace qmf { -namespace engine { - - class ConnectionSettingsImpl { - qpid::client::ConnectionSettings clientSettings; - mutable std::string attrString; - int retryDelayMin; - int retryDelayMax; - int retryDelayFactor; - bool sendUserId; - - public: - ConnectionSettingsImpl(); - ConnectionSettingsImpl(const std::string& url); - ~ConnectionSettingsImpl() {} - bool setAttr(const std::string& key, const Value& value); - Value getAttr(const std::string& key) const; - const std::string& getAttrString() const; - void transportTcp(uint16_t port); - void transportSsl(uint16_t port); - void transportRdma(uint16_t port); - void authAnonymous(const std::string& username); - void authPlain(const std::string& username, const std::string& password); - void authGssapi(const std::string& serviceName, uint32_t minSsf, uint32_t maxSsf); - void setRetry(int delayMin, int delayMax, int delayFactor); - - const qpid::client::ConnectionSettings& getClientSettings() const; - void getRetrySettings(int* delayMin, int* delayMax, int* delayFactor) const; - bool getSendUserId() const { return sendUserId; } - }; - -} -} - -#endif diff --git a/qpid/cpp/src/qmf/engine/ConsoleImpl.cpp b/qpid/cpp/src/qmf/engine/ConsoleImpl.cpp deleted file mode 100644 index 4a5da31bdc..0000000000 --- a/qpid/cpp/src/qmf/engine/ConsoleImpl.cpp +++ /dev/null @@ -1,458 +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. - */ - -#include "qmf/engine/ConsoleImpl.h" -#include "qmf/engine/MessageImpl.h" -#include "qmf/engine/SchemaImpl.h" -#include "qmf/engine/Typecode.h" -#include "qmf/engine/ObjectImpl.h" -#include "qmf/engine/ObjectIdImpl.h" -#include "qmf/engine/QueryImpl.h" -#include "qmf/engine/ValueImpl.h" -#include "qmf/engine/Protocol.h" -#include "qmf/engine/SequenceManager.h" -#include "qmf/engine/BrokerProxyImpl.h" -#include <qpid/framing/Buffer.h> -#include <qpid/framing/Uuid.h> -#include <qpid/framing/FieldTable.h> -#include <qpid/framing/FieldValue.h> -#include <qpid/log/Statement.h> -#include <qpid/sys/Time.h> -#include <qpid/sys/SystemInfo.h> -#include <string.h> -#include <iostream> -#include <fstream> - -using namespace std; -using namespace qmf::engine; -using namespace qpid::framing; -using namespace qpid::sys; - -namespace { - const char* QMF_EXCHANGE = "qpid.management"; -} - -#define STRING_REF(s) {if (!s.empty()) item.s = const_cast<char*>(s.c_str());} - -ConsoleEvent ConsoleEventImpl::copy() -{ - ConsoleEvent item; - - ::memset(&item, 0, sizeof(ConsoleEvent)); - item.kind = kind; - item.agent = agent.get(); - item.classKey = classKey; - item.object = object.get(); - item.context = context; - item.event = event.get(); - item.timestamp = timestamp; - item.hasProps = hasProps; - item.hasStats = hasStats; - - STRING_REF(name); - - return item; -} - -ConsoleImpl::ConsoleImpl(const ConsoleSettings& s) : settings(s) -{ - bindingList.push_back(pair<string, string>(string(), "schema.#")); - if (settings.rcvObjects && settings.rcvEvents && settings.rcvHeartbeats && !settings.userBindings) { - bindingList.push_back(pair<string, string>(string(), "console.#")); - } else { - if (settings.rcvObjects && !settings.userBindings) - bindingList.push_back(pair<string, string>(string(), "console.obj.#")); - else - bindingList.push_back(pair<string, string>(string(), "console.obj.*.*.org.apache.qpid.broker.agent")); - if (settings.rcvEvents) - bindingList.push_back(pair<string, string>(string(), "console.event.#")); - if (settings.rcvHeartbeats) - bindingList.push_back(pair<string, string>(string(), "console.heartbeat.#")); - } -} - -ConsoleImpl::~ConsoleImpl() -{ - // This function intentionally left blank. -} - -bool ConsoleImpl::getEvent(ConsoleEvent& event) const -{ - Mutex::ScopedLock _lock(lock); - if (eventQueue.empty()) - return false; - event = eventQueue.front()->copy(); - return true; -} - -void ConsoleImpl::popEvent() -{ - Mutex::ScopedLock _lock(lock); - if (!eventQueue.empty()) - eventQueue.pop_front(); -} - -void ConsoleImpl::addConnection(BrokerProxy& broker, void* /*context*/) -{ - Mutex::ScopedLock _lock(lock); - brokerList.push_back(broker.impl); -} - -void ConsoleImpl::delConnection(BrokerProxy& broker) -{ - Mutex::ScopedLock _lock(lock); - for (vector<BrokerProxyImpl*>::iterator iter = brokerList.begin(); - iter != brokerList.end(); iter++) - if (*iter == broker.impl) { - brokerList.erase(iter); - break; - } -} - -uint32_t ConsoleImpl::packageCount() const -{ - Mutex::ScopedLock _lock(lock); - return packages.size(); -} - -const string& ConsoleImpl::getPackageName(uint32_t idx) const -{ - const static string empty; - - Mutex::ScopedLock _lock(lock); - if (idx >= packages.size()) - return empty; - - PackageList::const_iterator iter = packages.begin(); - for (uint32_t i = 0; i < idx; i++) iter++; - return iter->first; -} - -uint32_t ConsoleImpl::classCount(const char* packageName) const -{ - Mutex::ScopedLock _lock(lock); - PackageList::const_iterator pIter = packages.find(packageName); - if (pIter == packages.end()) - return 0; - - const ObjectClassList& oList = pIter->second.first; - const EventClassList& eList = pIter->second.second; - - return oList.size() + eList.size(); -} - -const SchemaClassKey* ConsoleImpl::getClass(const char* packageName, uint32_t idx) const -{ - Mutex::ScopedLock _lock(lock); - PackageList::const_iterator pIter = packages.find(packageName); - if (pIter == packages.end()) - return 0; - - const ObjectClassList& oList = pIter->second.first; - const EventClassList& eList = pIter->second.second; - uint32_t count = 0; - - for (ObjectClassList::const_iterator oIter = oList.begin(); - oIter != oList.end(); oIter++) { - if (count == idx) - return oIter->second->getClassKey(); - count++; - } - - for (EventClassList::const_iterator eIter = eList.begin(); - eIter != eList.end(); eIter++) { - if (count == idx) - return eIter->second->getClassKey(); - count++; - } - - return 0; -} - -ClassKind ConsoleImpl::getClassKind(const SchemaClassKey* key) const -{ - Mutex::ScopedLock _lock(lock); - PackageList::const_iterator pIter = packages.find(key->getPackageName()); - if (pIter == packages.end()) - return CLASS_OBJECT; - - const EventClassList& eList = pIter->second.second; - if (eList.find(key) != eList.end()) - return CLASS_EVENT; - return CLASS_OBJECT; -} - -const SchemaObjectClass* ConsoleImpl::getObjectClass(const SchemaClassKey* key) const -{ - Mutex::ScopedLock _lock(lock); - PackageList::const_iterator pIter = packages.find(key->getPackageName()); - if (pIter == packages.end()) - return 0; - - const ObjectClassList& oList = pIter->second.first; - ObjectClassList::const_iterator iter = oList.find(key); - if (iter == oList.end()) - return 0; - return iter->second; -} - -const SchemaEventClass* ConsoleImpl::getEventClass(const SchemaClassKey* key) const -{ - Mutex::ScopedLock _lock(lock); - PackageList::const_iterator pIter = packages.find(key->getPackageName()); - if (pIter == packages.end()) - return 0; - - const EventClassList& eList = pIter->second.second; - EventClassList::const_iterator iter = eList.find(key); - if (iter == eList.end()) - return 0; - return iter->second; -} - -void ConsoleImpl::bindPackage(const char* packageName) -{ - stringstream key; - key << "console.obj.*.*." << packageName << ".#"; - Mutex::ScopedLock _lock(lock); - bindingList.push_back(pair<string, string>(string(), key.str())); - for (vector<BrokerProxyImpl*>::iterator iter = brokerList.begin(); - iter != brokerList.end(); iter++) - (*iter)->addBinding(QMF_EXCHANGE, key.str()); -} - -void ConsoleImpl::bindClass(const SchemaClassKey* classKey) -{ - stringstream key; - key << "console.obj.*.*." << classKey->getPackageName() << "." << classKey->getClassName() << ".#"; - Mutex::ScopedLock _lock(lock); - bindingList.push_back(pair<string, string>(string(), key.str())); - for (vector<BrokerProxyImpl*>::iterator iter = brokerList.begin(); - iter != brokerList.end(); iter++) - (*iter)->addBinding(QMF_EXCHANGE, key.str()); -} - -void ConsoleImpl::bindClass(const char* packageName, const char* className) -{ - stringstream key; - key << "console.obj.*.*." << packageName << "." << className << ".#"; - Mutex::ScopedLock _lock(lock); - bindingList.push_back(pair<string, string>(string(), key.str())); - for (vector<BrokerProxyImpl*>::iterator iter = brokerList.begin(); - iter != brokerList.end(); iter++) - (*iter)->addBinding(QMF_EXCHANGE, key.str()); -} - - -void ConsoleImpl::bindEvent(const SchemaClassKey* classKey) -{ - bindEvent(classKey->getPackageName(), classKey->getClassName()); -} - -void ConsoleImpl::bindEvent(const char* packageName, const char* eventName) -{ - if (!settings.userBindings) throw qpid::Exception("Console not configured for userBindings."); - if (settings.rcvEvents) throw qpid::Exception("Console already configured to receive all events."); - - stringstream key; - key << "console.event.*.*." << packageName; - if (eventName && *eventName) { - key << "." << eventName << ".#"; - } else { - key << ".#"; - } - - Mutex::ScopedLock _lock(lock); - bindingList.push_back(pair<string, string>(string(), key.str())); - for (vector<BrokerProxyImpl*>::iterator iter = brokerList.begin(); - iter != brokerList.end(); iter++) - (*iter)->addBinding(QMF_EXCHANGE, key.str()); -} - -/* -void ConsoleImpl::startSync(const Query& query, void* context, SyncQuery& sync) -{ -} - -void ConsoleImpl::touchSync(SyncQuery& sync) -{ -} - -void ConsoleImpl::endSync(SyncQuery& sync) -{ -} -*/ - -void ConsoleImpl::learnPackage(const string& packageName) -{ - Mutex::ScopedLock _lock(lock); - if (packages.find(packageName) == packages.end()) { - packages.insert(pair<string, pair<ObjectClassList, EventClassList> > - (packageName, pair<ObjectClassList, EventClassList>(ObjectClassList(), EventClassList()))); - eventNewPackage(packageName); - } -} - -void ConsoleImpl::learnClass(SchemaObjectClass* cls) -{ - Mutex::ScopedLock _lock(lock); - const SchemaClassKey* key = cls->getClassKey(); - PackageList::iterator pIter = packages.find(key->getPackageName()); - if (pIter == packages.end()) - return; - - ObjectClassList& list = pIter->second.first; - if (list.find(key) == list.end()) { - list[key] = cls; - eventNewClass(key); - } -} - -void ConsoleImpl::learnClass(SchemaEventClass* cls) -{ - Mutex::ScopedLock _lock(lock); - const SchemaClassKey* key = cls->getClassKey(); - PackageList::iterator pIter = packages.find(key->getPackageName()); - if (pIter == packages.end()) - return; - - EventClassList& list = pIter->second.second; - if (list.find(key) == list.end()) { - list[key] = cls; - eventNewClass(key); - } -} - -bool ConsoleImpl::haveClass(const SchemaClassKey* key) const -{ - Mutex::ScopedLock _lock(lock); - PackageList::const_iterator pIter = packages.find(key->getPackageName()); - if (pIter == packages.end()) - return false; - - const ObjectClassList& oList = pIter->second.first; - const EventClassList& eList = pIter->second.second; - - return oList.find(key) != oList.end() || eList.find(key) != eList.end(); -} - -SchemaObjectClass* ConsoleImpl::getSchema(const SchemaClassKey* key) const -{ - Mutex::ScopedLock _lock(lock); - PackageList::const_iterator pIter = packages.find(key->getPackageName()); - if (pIter == packages.end()) - return 0; - - const ObjectClassList& oList = pIter->second.first; - ObjectClassList::const_iterator iter = oList.find(key); - if (iter == oList.end()) - return 0; - - return iter->second; -} - -void ConsoleImpl::eventAgentAdded(boost::shared_ptr<AgentProxy> agent) -{ - ConsoleEventImpl::Ptr event(new ConsoleEventImpl(ConsoleEvent::AGENT_ADDED)); - event->agent = agent; - Mutex::ScopedLock _lock(lock); - eventQueue.push_back(event); -} - -void ConsoleImpl::eventAgentDeleted(boost::shared_ptr<AgentProxy> agent) -{ - ConsoleEventImpl::Ptr event(new ConsoleEventImpl(ConsoleEvent::AGENT_DELETED)); - event->agent = agent; - Mutex::ScopedLock _lock(lock); - eventQueue.push_back(event); -} - -void ConsoleImpl::eventNewPackage(const string& packageName) -{ - ConsoleEventImpl::Ptr event(new ConsoleEventImpl(ConsoleEvent::NEW_PACKAGE)); - event->name = packageName; - Mutex::ScopedLock _lock(lock); - eventQueue.push_back(event); -} - -void ConsoleImpl::eventNewClass(const SchemaClassKey* key) -{ - ConsoleEventImpl::Ptr event(new ConsoleEventImpl(ConsoleEvent::NEW_CLASS)); - event->classKey = key; - Mutex::ScopedLock _lock(lock); - eventQueue.push_back(event); -} - -void ConsoleImpl::eventObjectUpdate(ObjectPtr object, bool prop, bool stat) -{ - ConsoleEventImpl::Ptr event(new ConsoleEventImpl(ConsoleEvent::OBJECT_UPDATE)); - event->object = object; - event->hasProps = prop; - event->hasStats = stat; - Mutex::ScopedLock _lock(lock); - eventQueue.push_back(event); -} - -void ConsoleImpl::eventAgentHeartbeat(boost::shared_ptr<AgentProxy> agent, uint64_t timestamp) -{ - ConsoleEventImpl::Ptr event(new ConsoleEventImpl(ConsoleEvent::AGENT_HEARTBEAT)); - event->agent = agent; - event->timestamp = timestamp; - Mutex::ScopedLock _lock(lock); - eventQueue.push_back(event); -} - - -void ConsoleImpl::eventEventReceived(EventPtr event) -{ - ConsoleEventImpl::Ptr console_event(new ConsoleEventImpl(ConsoleEvent::EVENT_RECEIVED)); - console_event->event = event; - Mutex::ScopedLock _lock(lock); - eventQueue.push_back(console_event); -} - -//================================================================== -// Wrappers -//================================================================== - -Console::Console(const ConsoleSettings& settings) : impl(new ConsoleImpl(settings)) {} -Console::~Console() { delete impl; } -bool Console::getEvent(ConsoleEvent& event) const { return impl->getEvent(event); } -void Console::popEvent() { impl->popEvent(); } -void Console::addConnection(BrokerProxy& broker, void* context) { impl->addConnection(broker, context); } -void Console::delConnection(BrokerProxy& broker) { impl->delConnection(broker); } -uint32_t Console::packageCount() const { return impl->packageCount(); } -const char* Console::getPackageName(uint32_t idx) const { return impl->getPackageName(idx).c_str(); } -uint32_t Console::classCount(const char* packageName) const { return impl->classCount(packageName); } -const SchemaClassKey* Console::getClass(const char* packageName, uint32_t idx) const { return impl->getClass(packageName, idx); } -ClassKind Console::getClassKind(const SchemaClassKey* key) const { return impl->getClassKind(key); } -const SchemaObjectClass* Console::getObjectClass(const SchemaClassKey* key) const { return impl->getObjectClass(key); } -const SchemaEventClass* Console::getEventClass(const SchemaClassKey* key) const { return impl->getEventClass(key); } -void Console::bindPackage(const char* packageName) { impl->bindPackage(packageName); } -void Console::bindClass(const SchemaClassKey* key) { impl->bindClass(key); } -void Console::bindClass(const char* packageName, const char* className) { impl->bindClass(packageName, className); } - -void Console::bindEvent(const SchemaClassKey *key) { impl->bindEvent(key); } -void Console::bindEvent(const char* packageName, const char* eventName) { impl->bindEvent(packageName, eventName); } - -//void Console::startSync(const Query& query, void* context, SyncQuery& sync) { impl->startSync(query, context, sync); } -//void Console::touchSync(SyncQuery& sync) { impl->touchSync(sync); } -//void Console::endSync(SyncQuery& sync) { impl->endSync(sync); } - - diff --git a/qpid/cpp/src/qmf/engine/ConsoleImpl.h b/qpid/cpp/src/qmf/engine/ConsoleImpl.h deleted file mode 100644 index 0c27fdabcd..0000000000 --- a/qpid/cpp/src/qmf/engine/ConsoleImpl.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef _QmfEngineConsoleEngineImpl_ -#define _QmfEngineConsoleEngineImpl_ - -/* - * 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 "qmf/engine/Console.h" -#include "qmf/engine/MessageImpl.h" -#include "qmf/engine/SchemaImpl.h" -#include "qmf/engine/Typecode.h" -#include "qmf/engine/ObjectImpl.h" -#include "qmf/engine/ObjectIdImpl.h" -#include "qmf/engine/QueryImpl.h" -#include "qmf/engine/ValueImpl.h" -#include "qmf/engine/Protocol.h" -#include "qmf/engine/SequenceManager.h" -#include "qmf/engine/BrokerProxyImpl.h" -#include <qpid/framing/Buffer.h> -#include <qpid/framing/Uuid.h> -#include <qpid/framing/FieldTable.h> -#include <qpid/framing/FieldValue.h> -#include <qpid/sys/Mutex.h> -#include <qpid/sys/Time.h> -#include <qpid/sys/SystemInfo.h> -#include <string.h> -#include <string> -#include <deque> -#include <map> -#include <vector> -#include <iostream> -#include <fstream> -#include <boost/shared_ptr.hpp> -#include <boost/noncopyable.hpp> - -namespace qmf { -namespace engine { - - struct ConsoleEventImpl { - typedef boost::shared_ptr<ConsoleEventImpl> Ptr; - ConsoleEvent::EventKind kind; - boost::shared_ptr<AgentProxy> agent; - std::string name; - const SchemaClassKey* classKey; - boost::shared_ptr<Object> object; - void* context; - boost::shared_ptr<Event> event; - uint64_t timestamp; - bool hasProps; - bool hasStats; - - ConsoleEventImpl(ConsoleEvent::EventKind k) : - kind(k), classKey(0), context(0), timestamp(0) {} - ~ConsoleEventImpl() {} - ConsoleEvent copy(); - }; - - class ConsoleImpl : public boost::noncopyable { - public: - ConsoleImpl(const ConsoleSettings& settings = ConsoleSettings()); - ~ConsoleImpl(); - - bool getEvent(ConsoleEvent& event) const; - void popEvent(); - - void addConnection(BrokerProxy& broker, void* context); - void delConnection(BrokerProxy& broker); - - uint32_t packageCount() const; - const std::string& getPackageName(uint32_t idx) const; - - uint32_t classCount(const char* packageName) const; - const SchemaClassKey* getClass(const char* packageName, uint32_t idx) const; - - ClassKind getClassKind(const SchemaClassKey* key) const; - const SchemaObjectClass* getObjectClass(const SchemaClassKey* key) const; - const SchemaEventClass* getEventClass(const SchemaClassKey* key) const; - - void bindPackage(const char* packageName); - void bindClass(const SchemaClassKey* key); - void bindClass(const char* packageName, const char* className); - void bindEvent(const SchemaClassKey* key); - void bindEvent(const char* packageName, const char* eventName); - - /* - void startSync(const Query& query, void* context, SyncQuery& sync); - void touchSync(SyncQuery& sync); - void endSync(SyncQuery& sync); - */ - - private: - friend class BrokerProxyImpl; - friend struct StaticContext; - const ConsoleSettings& settings; - mutable qpid::sys::Mutex lock; - std::deque<ConsoleEventImpl::Ptr> eventQueue; - std::vector<BrokerProxyImpl*> brokerList; - std::vector<std::pair<std::string, std::string> > bindingList; // exchange/key (empty exchange => QMF_EXCHANGE) - - // Declare a compare class for the class maps that compares the dereferenced - // class key pointers. The default behavior would be to compare the pointer - // addresses themselves. - struct KeyCompare { - bool operator()(const SchemaClassKey* left, const SchemaClassKey* right) const { - return *left < *right; - } - }; - - typedef std::map<const SchemaClassKey*, SchemaObjectClass*, KeyCompare> ObjectClassList; - typedef std::map<const SchemaClassKey*, SchemaEventClass*, KeyCompare> EventClassList; - typedef std::map<std::string, std::pair<ObjectClassList, EventClassList> > PackageList; - - PackageList packages; - - void learnPackage(const std::string& packageName); - void learnClass(SchemaObjectClass* cls); - void learnClass(SchemaEventClass* cls); - bool haveClass(const SchemaClassKey* key) const; - SchemaObjectClass* getSchema(const SchemaClassKey* key) const; - - void eventAgentAdded(boost::shared_ptr<AgentProxy> agent); - void eventAgentDeleted(boost::shared_ptr<AgentProxy> agent); - void eventNewPackage(const std::string& packageName); - void eventNewClass(const SchemaClassKey* key); - void eventObjectUpdate(ObjectPtr object, bool prop, bool stat); - void eventAgentHeartbeat(boost::shared_ptr<AgentProxy> agent, uint64_t timestamp); - void eventEventReceived(boost::shared_ptr<Event> event); - }; -} -} - -#endif - diff --git a/qpid/cpp/src/qmf/engine/EventImpl.cpp b/qpid/cpp/src/qmf/engine/EventImpl.cpp deleted file mode 100644 index 4b034e8e83..0000000000 --- a/qpid/cpp/src/qmf/engine/EventImpl.cpp +++ /dev/null @@ -1,120 +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. - */ - -#include <qmf/engine/EventImpl.h> -#include <qmf/engine/ValueImpl.h> - -#include <sstream> - -using namespace std; -using namespace qmf::engine; -using qpid::framing::Buffer; - -EventImpl::EventImpl(const SchemaEventClass* type) : eventClass(type), timestamp(0), severity(0) -{ - int argCount = eventClass->getArgumentCount(); - int idx; - - for (idx = 0; idx < argCount; idx++) { - const SchemaArgument* arg = eventClass->getArgument(idx); - arguments[arg->getName()] = ValuePtr(new Value(arg->getType())); - } -} - - -EventImpl::EventImpl(const SchemaEventClass* type, Buffer& buffer) : - eventClass(type), timestamp(0), severity(0) -{ - int argCount = eventClass->getArgumentCount(); - int idx; - - timestamp = buffer.getLongLong(); - severity = buffer.getOctet(); - - for (idx = 0; idx < argCount; idx++) - { - const SchemaArgument *arg = eventClass->getArgument(idx); - Value* pval = ValueImpl::factory(arg->getType(), buffer); - arguments[arg->getName()] = ValuePtr(pval); - } -} - - -Event* EventImpl::factory(const SchemaEventClass* type, Buffer& buffer) -{ - EventImpl* impl(new EventImpl(type, buffer)); - return new Event(impl); -} - - -Value* EventImpl::getValue(const char* key) const -{ - map<string, ValuePtr>::const_iterator iter; - - iter = arguments.find(key); - if (iter != arguments.end()) - return iter->second.get(); - - return 0; -} - - -void EventImpl::encodeSchemaKey(Buffer& buffer) const -{ - buffer.putShortString(eventClass->getClassKey()->getPackageName()); - buffer.putShortString(eventClass->getClassKey()->getClassName()); - buffer.putBin128(const_cast<uint8_t*>(eventClass->getClassKey()->getHash())); -} - - -void EventImpl::encode(Buffer& buffer) const -{ - buffer.putOctet((uint8_t) eventClass->getSeverity()); - - int argCount = eventClass->getArgumentCount(); - for (int idx = 0; idx < argCount; idx++) { - const SchemaArgument* arg = eventClass->getArgument(idx); - ValuePtr value = arguments[arg->getName()]; - value->impl->encode(buffer); - } -} - - -string EventImpl::getRoutingKey(uint32_t brokerBank, uint32_t agentBank) const -{ - stringstream key; - - key << "console.event." << brokerBank << "." << agentBank << "." << - eventClass->getClassKey()->getPackageName() << "." << - eventClass->getClassKey()->getClassName(); - return key.str(); -} - - -//================================================================== -// Wrappers -//================================================================== - -Event::Event(const SchemaEventClass* type) : impl(new EventImpl(type)) {} -Event::Event(EventImpl* i) : impl(i) {} -Event::Event(const Event& from) : impl(new EventImpl(*(from.impl))) {} -Event::~Event() { delete impl; } -const SchemaEventClass* Event::getClass() const { return impl->getClass(); } -Value* Event::getValue(const char* key) const { return impl->getValue(key); } - diff --git a/qpid/cpp/src/qmf/engine/EventImpl.h b/qpid/cpp/src/qmf/engine/EventImpl.h deleted file mode 100644 index 4046e71ef9..0000000000 --- a/qpid/cpp/src/qmf/engine/EventImpl.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _QmfEngineEventImpl_ -#define _QmfEngineEventImpl_ - -/* - * 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 <qmf/engine/Event.h> -#include <qmf/engine/Schema.h> -#include <qpid/framing/Buffer.h> -#include <boost/shared_ptr.hpp> -#include <map> - -namespace qmf { -namespace engine { - - typedef boost::shared_ptr<Event> EventPtr; - - struct EventImpl { - typedef boost::shared_ptr<Value> ValuePtr; - const SchemaEventClass* eventClass; - uint64_t timestamp; - uint8_t severity; - mutable std::map<std::string, ValuePtr> arguments; - - EventImpl(const SchemaEventClass* type); - EventImpl(const SchemaEventClass* type, qpid::framing::Buffer& buffer); - static Event* factory(const SchemaEventClass* type, qpid::framing::Buffer& buffer); - - const SchemaEventClass* getClass() const { return eventClass; } - Value* getValue(const char* key) const; - - void encodeSchemaKey(qpid::framing::Buffer& buffer) const; - void encode(qpid::framing::Buffer& buffer) const; - std::string getRoutingKey(uint32_t brokerBank, uint32_t agentBank) const; - }; - -} -} - -#endif - diff --git a/qpid/cpp/src/qmf/engine/MessageImpl.cpp b/qpid/cpp/src/qmf/engine/MessageImpl.cpp deleted file mode 100644 index 0047d3eb9d..0000000000 --- a/qpid/cpp/src/qmf/engine/MessageImpl.cpp +++ /dev/null @@ -1,43 +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. - */ - -#include "qmf/engine/MessageImpl.h" -#include <string.h> - -using namespace std; -using namespace qmf::engine; - -#define STRING_REF(s) {if (!s.empty()) item.s = const_cast<char*>(s.c_str());} - -Message MessageImpl::copy() -{ - Message item; - - ::memset(&item, 0, sizeof(Message)); - item.body = const_cast<char*>(body.c_str()); - item.length = body.length(); - STRING_REF(destination); - STRING_REF(routingKey); - STRING_REF(replyExchange); - STRING_REF(replyKey); - STRING_REF(userId); - - return item; -} - diff --git a/qpid/cpp/src/qmf/engine/MessageImpl.h b/qpid/cpp/src/qmf/engine/MessageImpl.h deleted file mode 100644 index b91291d2e4..0000000000 --- a/qpid/cpp/src/qmf/engine/MessageImpl.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _QmfEngineMessageImpl_ -#define _QmfEngineMessageImpl_ - -/* - * 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 "qmf/engine/Message.h" -#include <string> -#include <boost/shared_ptr.hpp> - -namespace qmf { -namespace engine { - - struct MessageImpl { - typedef boost::shared_ptr<MessageImpl> Ptr; - std::string body; - std::string destination; - std::string routingKey; - std::string replyExchange; - std::string replyKey; - std::string userId; - - Message copy(); - }; -} -} - -#endif diff --git a/qpid/cpp/src/qmf/engine/ObjectIdImpl.cpp b/qpid/cpp/src/qmf/engine/ObjectIdImpl.cpp deleted file mode 100644 index 9216f7bac0..0000000000 --- a/qpid/cpp/src/qmf/engine/ObjectIdImpl.cpp +++ /dev/null @@ -1,210 +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. - */ - -#include "qmf/engine/ObjectIdImpl.h" -#include <stdlib.h> -#include <sstream> - -using namespace std; -using namespace qmf::engine; -using qpid::framing::Buffer; - -void AgentAttachment::setBanks(uint32_t broker, uint32_t agent) -{ - first = - ((uint64_t) (broker & 0x000fffff)) << 28 | - ((uint64_t) (agent & 0x0fffffff)); -} - -ObjectIdImpl::ObjectIdImpl(Buffer& buffer) : agent(0) -{ - decode(buffer); -} - -ObjectIdImpl::ObjectIdImpl(AgentAttachment* a, uint8_t flags, uint16_t seq, uint64_t object) : agent(a) -{ - first = - ((uint64_t) (flags & 0x0f)) << 60 | - ((uint64_t) (seq & 0x0fff)) << 48; - second = object; -} - -ObjectId* ObjectIdImpl::factory(Buffer& buffer) -{ - ObjectIdImpl* impl(new ObjectIdImpl(buffer)); - return new ObjectId(impl); -} - -ObjectId* ObjectIdImpl::factory(AgentAttachment* agent, uint8_t flags, uint16_t seq, uint64_t object) -{ - ObjectIdImpl* impl(new ObjectIdImpl(agent, flags, seq, object)); - return new ObjectId(impl); -} - -void ObjectIdImpl::decode(Buffer& buffer) -{ - first = buffer.getLongLong(); - second = buffer.getLongLong(); -} - -void ObjectIdImpl::encode(Buffer& buffer) const -{ - if (agent == 0) - buffer.putLongLong(first); - else - buffer.putLongLong(first | agent->first); - buffer.putLongLong(second); -} - -void ObjectIdImpl::fromString(const std::string& repr) -{ -#define FIELDS 5 -#if defined (_WIN32) && !defined (atoll) -# define atoll(X) _atoi64(X) -#endif - - std::string copy(repr.c_str()); - char* cText; - char* field[FIELDS]; - bool atFieldStart = true; - int idx = 0; - - cText = const_cast<char*>(copy.c_str()); - for (char* cursor = cText; *cursor; cursor++) { - if (atFieldStart) { - if (idx >= FIELDS) - return; // TODO error - field[idx++] = cursor; - atFieldStart = false; - } else { - if (*cursor == '-') { - *cursor = '\0'; - atFieldStart = true; - } - } - } - - if (idx != FIELDS) - return; // TODO error - - first = (atoll(field[0]) << 60) + - (atoll(field[1]) << 48) + - (atoll(field[2]) << 28) + - atoll(field[3]); - second = atoll(field[4]); - agent = 0; -} - -const string& ObjectIdImpl::asString() const -{ - stringstream val; - - val << (int) getFlags() << "-" << getSequence() << "-" << getBrokerBank() << "-" << - getAgentBank() << "-" << getObjectNum(); - repr = val.str(); - return repr; -} - -#define ACTUAL_FIRST (agent == 0 ? first : first | agent->first) -#define ACTUAL_OTHER (other.agent == 0 ? other.first : other.first | other.agent->first) - -uint8_t ObjectIdImpl::getFlags() const -{ - return (ACTUAL_FIRST & 0xF000000000000000LL) >> 60; -} - -uint16_t ObjectIdImpl::getSequence() const -{ - return (ACTUAL_FIRST & 0x0FFF000000000000LL) >> 48; -} - -uint32_t ObjectIdImpl::getBrokerBank() const -{ - return (ACTUAL_FIRST & 0x0000FFFFF0000000LL) >> 28; -} - -uint32_t ObjectIdImpl::getAgentBank() const -{ - return ACTUAL_FIRST & 0x000000000FFFFFFFLL; -} - -uint64_t ObjectIdImpl::getObjectNum() const -{ - return second; -} - -uint32_t ObjectIdImpl::getObjectNumHi() const -{ - return (uint32_t) (second >> 32); -} - -uint32_t ObjectIdImpl::getObjectNumLo() const -{ - return (uint32_t) (second & 0x00000000FFFFFFFFLL); -} - -bool ObjectIdImpl::operator==(const ObjectIdImpl& other) const -{ - return ACTUAL_FIRST == ACTUAL_OTHER && second == other.second; -} - -bool ObjectIdImpl::operator<(const ObjectIdImpl& other) const -{ - return (ACTUAL_FIRST < ACTUAL_OTHER) || ((ACTUAL_FIRST == ACTUAL_OTHER) && (second < other.second)); -} - -bool ObjectIdImpl::operator>(const ObjectIdImpl& other) const -{ - return (ACTUAL_FIRST > ACTUAL_OTHER) || ((ACTUAL_FIRST == ACTUAL_OTHER) && (second > other.second)); -} - - -//================================================================== -// Wrappers -//================================================================== - -ObjectId::ObjectId() : impl(new ObjectIdImpl()) {} -ObjectId::ObjectId(const ObjectId& from) : impl(new ObjectIdImpl(*(from.impl))) {} -ObjectId::ObjectId(ObjectIdImpl* i) : impl(i) {} -ObjectId::~ObjectId() { delete impl; } -uint64_t ObjectId::getObjectNum() const { return impl->getObjectNum(); } -uint32_t ObjectId::getObjectNumHi() const { return impl->getObjectNumHi(); } -uint32_t ObjectId::getObjectNumLo() const { return impl->getObjectNumLo(); } -bool ObjectId::isDurable() const { return impl->isDurable(); } -const char* ObjectId::str() const { return impl->asString().c_str(); } -uint8_t ObjectId::getFlags() const { return impl->getFlags(); } -uint16_t ObjectId::getSequence() const { return impl->getSequence(); } -uint32_t ObjectId::getBrokerBank() const { return impl->getBrokerBank(); } -uint32_t ObjectId::getAgentBank() const { return impl->getAgentBank(); } -bool ObjectId::operator==(const ObjectId& other) const { return *impl == *other.impl; } -bool ObjectId::operator<(const ObjectId& other) const { return *impl < *other.impl; } -bool ObjectId::operator>(const ObjectId& other) const { return *impl > *other.impl; } -bool ObjectId::operator<=(const ObjectId& other) const { return !(*impl > *other.impl); } -bool ObjectId::operator>=(const ObjectId& other) const { return !(*impl < *other.impl); } -ObjectId& ObjectId::operator=(const ObjectId& other) { - ObjectIdImpl *old; - if (this != &other) { - old = impl; - impl = new ObjectIdImpl(*(other.impl)); - if (old) - delete old; - } - return *this; -} - diff --git a/qpid/cpp/src/qmf/engine/ObjectIdImpl.h b/qpid/cpp/src/qmf/engine/ObjectIdImpl.h deleted file mode 100644 index d70c8efff4..0000000000 --- a/qpid/cpp/src/qmf/engine/ObjectIdImpl.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _QmfEngineObjectIdImpl_ -#define _QmfEngineObjectIdImpl_ - -/* - * 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 <qmf/engine/ObjectId.h> -#include <qpid/framing/Buffer.h> - -namespace qmf { -namespace engine { - - struct AgentAttachment { - uint64_t first; - - AgentAttachment() : first(0) {} - void setBanks(uint32_t broker, uint32_t bank); - uint64_t getFirst() const { return first; } - }; - - struct ObjectIdImpl { - AgentAttachment* agent; - uint64_t first; - uint64_t second; - mutable std::string repr; - - ObjectIdImpl() : agent(0), first(0), second(0) {} - ObjectIdImpl(qpid::framing::Buffer& buffer); - ObjectIdImpl(AgentAttachment* agent, uint8_t flags, uint16_t seq, uint64_t object); - - static ObjectId* factory(qpid::framing::Buffer& buffer); - static ObjectId* factory(AgentAttachment* agent, uint8_t flags, uint16_t seq, uint64_t object); - - void decode(qpid::framing::Buffer& buffer); - void encode(qpid::framing::Buffer& buffer) const; - void fromString(const std::string& repr); - const std::string& asString() const; - uint8_t getFlags() const; - uint16_t getSequence() const; - uint32_t getBrokerBank() const; - uint32_t getAgentBank() const; - uint64_t getObjectNum() const; - uint32_t getObjectNumHi() const; - uint32_t getObjectNumLo() const; - bool isDurable() const { return getSequence() == 0; } - void setValue(uint64_t f, uint64_t s) { first = f; second = s; agent = 0; } - - bool operator==(const ObjectIdImpl& other) const; - bool operator<(const ObjectIdImpl& other) const; - bool operator>(const ObjectIdImpl& other) const; - }; -} -} - -#endif - diff --git a/qpid/cpp/src/qmf/engine/ObjectImpl.cpp b/qpid/cpp/src/qmf/engine/ObjectImpl.cpp deleted file mode 100644 index 45925cb804..0000000000 --- a/qpid/cpp/src/qmf/engine/ObjectImpl.cpp +++ /dev/null @@ -1,232 +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. - */ - -#include "qmf/engine/ObjectImpl.h" -#include "qmf/engine/ValueImpl.h" -#include "qmf/engine/BrokerProxyImpl.h" -#include <qpid/sys/Time.h> - -using namespace std; -using namespace qmf::engine; -using namespace qpid::sys; -using qpid::framing::Buffer; - -ObjectImpl::ObjectImpl(const SchemaObjectClass* type) : objectClass(type), broker(0), createTime(uint64_t(Duration(EPOCH, now()))), destroyTime(0), lastUpdatedTime(createTime) -{ - int propCount = objectClass->getPropertyCount(); - int statCount = objectClass->getStatisticCount(); - int idx; - - for (idx = 0; idx < propCount; idx++) { - const SchemaProperty* prop = objectClass->getProperty(idx); - properties[prop->getName()] = ValuePtr(new Value(prop->getType())); - } - - for (idx = 0; idx < statCount; idx++) { - const SchemaStatistic* stat = objectClass->getStatistic(idx); - statistics[stat->getName()] = ValuePtr(new Value(stat->getType())); - } -} - -ObjectImpl::ObjectImpl(const SchemaObjectClass* type, BrokerProxyImpl* b, Buffer& buffer, bool prop, bool stat, bool managed) : - objectClass(type), broker(b), createTime(0), destroyTime(0), lastUpdatedTime(0) -{ - int idx; - - if (managed) { - lastUpdatedTime = buffer.getLongLong(); - createTime = buffer.getLongLong(); - destroyTime = buffer.getLongLong(); - objectId.reset(ObjectIdImpl::factory(buffer)); - } - - if (prop) { - int propCount = objectClass->getPropertyCount(); - set<string> excludes; - parsePresenceMasks(buffer, excludes); - for (idx = 0; idx < propCount; idx++) { - const SchemaProperty* prop = objectClass->getProperty(idx); - if (excludes.count(prop->getName()) != 0) { - properties[prop->getName()] = ValuePtr(new Value(prop->getType())); - } else { - Value* pval = ValueImpl::factory(prop->getType(), buffer); - properties[prop->getName()] = ValuePtr(pval); - } - } - } - - if (stat) { - int statCount = objectClass->getStatisticCount(); - for (idx = 0; idx < statCount; idx++) { - const SchemaStatistic* stat = objectClass->getStatistic(idx); - Value* sval = ValueImpl::factory(stat->getType(), buffer); - statistics[stat->getName()] = ValuePtr(sval); - } - } -} - -Object* ObjectImpl::factory(const SchemaObjectClass* type, BrokerProxyImpl* b, Buffer& buffer, bool prop, bool stat, bool managed) -{ - ObjectImpl* impl(new ObjectImpl(type, b, buffer, prop, stat, managed)); - return new Object(impl); -} - -ObjectImpl::~ObjectImpl() -{ -} - -void ObjectImpl::destroy() -{ - destroyTime = uint64_t(Duration(EPOCH, now())); - // TODO - flag deletion -} - -Value* ObjectImpl::getValue(const string& key) const -{ - map<string, ValuePtr>::const_iterator iter; - - iter = properties.find(key); - if (iter != properties.end()) - return iter->second.get(); - - iter = statistics.find(key); - if (iter != statistics.end()) - return iter->second.get(); - - return 0; -} - -void ObjectImpl::invokeMethod(const string& methodName, const Value* inArgs, void* context) const -{ - if (broker != 0 && objectId.get() != 0) - broker->sendMethodRequest(objectId.get(), objectClass, methodName, inArgs, context); -} - -void ObjectImpl::merge(const Object& from) -{ - for (map<string, ValuePtr>::const_iterator piter = from.impl->properties.begin(); - piter != from.impl->properties.end(); piter++) - properties[piter->first] = piter->second; - for (map<string, ValuePtr>::const_iterator siter = from.impl->statistics.begin(); - siter != from.impl->statistics.end(); siter++) - statistics[siter->first] = siter->second; -} - -void ObjectImpl::parsePresenceMasks(Buffer& buffer, set<string>& excludeList) -{ - int propCount = objectClass->getPropertyCount(); - excludeList.clear(); - uint8_t bit = 0; - uint8_t mask = 0; - - for (int idx = 0; idx < propCount; idx++) { - const SchemaProperty* prop = objectClass->getProperty(idx); - if (prop->isOptional()) { - if (bit == 0) { - mask = buffer.getOctet(); - bit = 1; - } - if ((mask & bit) == 0) - excludeList.insert(string(prop->getName())); - if (bit == 0x80) - bit = 0; - else - bit = bit << 1; - } - } -} - -void ObjectImpl::encodeSchemaKey(qpid::framing::Buffer& buffer) const -{ - buffer.putShortString(objectClass->getClassKey()->getPackageName()); - buffer.putShortString(objectClass->getClassKey()->getClassName()); - buffer.putBin128(const_cast<uint8_t*>(objectClass->getClassKey()->getHash())); -} - -void ObjectImpl::encodeManagedObjectData(qpid::framing::Buffer& buffer) const -{ - buffer.putLongLong(lastUpdatedTime); - buffer.putLongLong(createTime); - buffer.putLongLong(destroyTime); - objectId->impl->encode(buffer); -} - -void ObjectImpl::encodeProperties(qpid::framing::Buffer& buffer) const -{ - int propCount = objectClass->getPropertyCount(); - uint8_t bit = 0; - uint8_t mask = 0; - ValuePtr value; - - for (int idx = 0; idx < propCount; idx++) { - const SchemaProperty* prop = objectClass->getProperty(idx); - if (prop->isOptional()) { - value = properties[prop->getName()]; - if (bit == 0) - bit = 1; - if (!value->isNull()) - mask |= bit; - if (bit == 0x80) { - buffer.putOctet(mask); - bit = 0; - mask = 0; - } else - bit = bit << 1; - } - } - if (bit != 0) { - buffer.putOctet(mask); - } - - for (int idx = 0; idx < propCount; idx++) { - const SchemaProperty* prop = objectClass->getProperty(idx); - value = properties[prop->getName()]; - if (!prop->isOptional() || !value->isNull()) { - value->impl->encode(buffer); - } - } -} - -void ObjectImpl::encodeStatistics(qpid::framing::Buffer& buffer) const -{ - int statCount = objectClass->getStatisticCount(); - for (int idx = 0; idx < statCount; idx++) { - const SchemaStatistic* stat = objectClass->getStatistic(idx); - ValuePtr value = statistics[stat->getName()]; - value->impl->encode(buffer); - } -} - -//================================================================== -// Wrappers -//================================================================== - -Object::Object(const SchemaObjectClass* type) : impl(new ObjectImpl(type)) {} -Object::Object(ObjectImpl* i) : impl(i) {} -Object::Object(const Object& from) : impl(new ObjectImpl(*(from.impl))) {} -Object::~Object() { delete impl; } -void Object::destroy() { impl->destroy(); } -const ObjectId* Object::getObjectId() const { return impl->getObjectId(); } -void Object::setObjectId(ObjectId* oid) { impl->setObjectId(oid); } -const SchemaObjectClass* Object::getClass() const { return impl->getClass(); } -Value* Object::getValue(const char* key) const { return impl->getValue(key); } -void Object::invokeMethod(const char* m, const Value* a, void* c) const { impl->invokeMethod(m, a, c); } -bool Object::isDeleted() const { return impl->isDeleted(); } -void Object::merge(const Object& from) { impl->merge(from); } - diff --git a/qpid/cpp/src/qmf/engine/ObjectImpl.h b/qpid/cpp/src/qmf/engine/ObjectImpl.h deleted file mode 100644 index 6f25867004..0000000000 --- a/qpid/cpp/src/qmf/engine/ObjectImpl.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef _QmfEngineObjectImpl_ -#define _QmfEngineObjectImpl_ - -/* - * 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 <qmf/engine/Object.h> -#include <qmf/engine/ObjectIdImpl.h> -#include <map> -#include <set> -#include <string> -#include <qpid/framing/Buffer.h> -#include <boost/shared_ptr.hpp> -#include <qpid/sys/Mutex.h> - -namespace qmf { -namespace engine { - - class BrokerProxyImpl; - - typedef boost::shared_ptr<Object> ObjectPtr; - - struct ObjectImpl { - typedef boost::shared_ptr<Value> ValuePtr; - const SchemaObjectClass* objectClass; - BrokerProxyImpl* broker; - boost::shared_ptr<ObjectId> objectId; - uint64_t createTime; - uint64_t destroyTime; - uint64_t lastUpdatedTime; - mutable std::map<std::string, ValuePtr> properties; - mutable std::map<std::string, ValuePtr> statistics; - - ObjectImpl(const SchemaObjectClass* type); - ObjectImpl(const SchemaObjectClass* type, BrokerProxyImpl* b, qpid::framing::Buffer& buffer, - bool prop, bool stat, bool managed); - static Object* factory(const SchemaObjectClass* type, BrokerProxyImpl* b, qpid::framing::Buffer& buffer, - bool prop, bool stat, bool managed); - ~ObjectImpl(); - - void destroy(); - const ObjectId* getObjectId() const { return objectId.get(); } - void setObjectId(ObjectId* oid) { objectId.reset(new ObjectId(*oid)); } - const SchemaObjectClass* getClass() const { return objectClass; } - Value* getValue(const std::string& key) const; - void invokeMethod(const std::string& methodName, const Value* inArgs, void* context) const; - bool isDeleted() const { return destroyTime != 0; } - void merge(const Object& from); - - void parsePresenceMasks(qpid::framing::Buffer& buffer, std::set<std::string>& excludeList); - void encodeSchemaKey(qpid::framing::Buffer& buffer) const; - void encodeManagedObjectData(qpid::framing::Buffer& buffer) const; - void encodeProperties(qpid::framing::Buffer& buffer) const; - void encodeStatistics(qpid::framing::Buffer& buffer) const; - }; -} -} - -#endif - diff --git a/qpid/cpp/src/qmf/engine/Protocol.cpp b/qpid/cpp/src/qmf/engine/Protocol.cpp deleted file mode 100644 index 9e5f490604..0000000000 --- a/qpid/cpp/src/qmf/engine/Protocol.cpp +++ /dev/null @@ -1,52 +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. - */ - -#include "qmf/engine/Protocol.h" -#include "qpid/framing/Buffer.h" - -using namespace std; -using namespace qmf::engine; -using namespace qpid::framing; - - -bool Protocol::checkHeader(Buffer& buf, uint8_t *opcode, uint32_t *seq) -{ - if (buf.available() < 8) - return false; - - uint8_t h1 = buf.getOctet(); - uint8_t h2 = buf.getOctet(); - uint8_t h3 = buf.getOctet(); - - *opcode = buf.getOctet(); - *seq = buf.getLong(); - - return h1 == 'A' && h2 == 'M' && h3 == '2'; -} - -void Protocol::encodeHeader(qpid::framing::Buffer& buf, uint8_t opcode, uint32_t seq) -{ - buf.putOctet('A'); - buf.putOctet('M'); - buf.putOctet('2'); - buf.putOctet(opcode); - buf.putLong (seq); -} - - diff --git a/qpid/cpp/src/qmf/engine/Protocol.h b/qpid/cpp/src/qmf/engine/Protocol.h deleted file mode 100644 index 1cdfa60c84..0000000000 --- a/qpid/cpp/src/qmf/engine/Protocol.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _QmfEngineProtocol_ -#define _QmfEngineProtocol_ - -/* - * 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 <qpid/sys/IntegerTypes.h> - -namespace qpid { - namespace framing { - class Buffer; - } -} - -namespace qmf { -namespace engine { - - class Protocol { - public: - static bool checkHeader(qpid::framing::Buffer& buf, uint8_t *opcode, uint32_t *seq); - static void encodeHeader(qpid::framing::Buffer& buf, uint8_t opcode, uint32_t seq = 0); - - const static uint8_t OP_ATTACH_REQUEST = 'A'; - const static uint8_t OP_ATTACH_RESPONSE = 'a'; - - const static uint8_t OP_BROKER_REQUEST = 'B'; - const static uint8_t OP_BROKER_RESPONSE = 'b'; - - const static uint8_t OP_CONSOLE_ADDED_INDICATION = 'x'; - const static uint8_t OP_COMMAND_COMPLETE = 'z'; - const static uint8_t OP_HEARTBEAT_INDICATION = 'h'; - - const static uint8_t OP_PACKAGE_REQUEST = 'P'; - const static uint8_t OP_PACKAGE_INDICATION = 'p'; - const static uint8_t OP_CLASS_QUERY = 'Q'; - const static uint8_t OP_CLASS_INDICATION = 'q'; - const static uint8_t OP_SCHEMA_REQUEST = 'S'; - const static uint8_t OP_SCHEMA_RESPONSE = 's'; - - const static uint8_t OP_METHOD_REQUEST = 'M'; - const static uint8_t OP_METHOD_RESPONSE = 'm'; - const static uint8_t OP_GET_QUERY = 'G'; - const static uint8_t OP_OBJECT_INDICATION = 'g'; - const static uint8_t OP_PROPERTY_INDICATION = 'c'; - const static uint8_t OP_STATISTIC_INDICATION = 'i'; - const static uint8_t OP_EVENT_INDICATION = 'e'; - }; - -} -} - -#endif - diff --git a/qpid/cpp/src/qmf/engine/QueryImpl.cpp b/qpid/cpp/src/qmf/engine/QueryImpl.cpp deleted file mode 100644 index 6f2beeee87..0000000000 --- a/qpid/cpp/src/qmf/engine/QueryImpl.cpp +++ /dev/null @@ -1,103 +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. - */ - -#include "qmf/engine/QueryImpl.h" -#include "qmf/engine/ObjectIdImpl.h" -#include "qpid/framing/Buffer.h" -#include "qpid/framing/FieldTable.h" - -using namespace std; -using namespace qmf::engine; -using namespace qpid::framing; - -bool QueryElementImpl::evaluate(const Object* /*object*/) const -{ - // TODO: Implement this - return false; -} - -bool QueryExpressionImpl::evaluate(const Object* /*object*/) const -{ - // TODO: Implement this - return false; -} - -QueryImpl::QueryImpl(Buffer& buffer) -{ - FieldTable ft; - ft.decode(buffer); - // TODO -} - -Query* QueryImpl::factory(Buffer& buffer) -{ - QueryImpl* impl(new QueryImpl(buffer)); - return new Query(impl); -} - -void QueryImpl::encode(Buffer& buffer) const -{ - FieldTable ft; - - if (oid.get() != 0) { - ft.setString("_objectid", oid->impl->asString()); - } else { - if (!packageName.empty()) - ft.setString("_package", packageName); - ft.setString("_class", className); - } - - ft.encode(buffer); -} - - -//================================================================== -// Wrappers -//================================================================== - -QueryElement::QueryElement(const char* attrName, const Value* value, ValueOper oper) : impl(new QueryElementImpl(attrName, value, oper)) {} -QueryElement::QueryElement(QueryElementImpl* i) : impl(i) {} -QueryElement::~QueryElement() { delete impl; } -bool QueryElement::evaluate(const Object* object) const { return impl->evaluate(object); } - -QueryExpression::QueryExpression(ExprOper oper, const QueryOperand* operand1, const QueryOperand* operand2) : impl(new QueryExpressionImpl(oper, operand1, operand2)) {} -QueryExpression::QueryExpression(QueryExpressionImpl* i) : impl(i) {} -QueryExpression::~QueryExpression() { delete impl; } -bool QueryExpression::evaluate(const Object* object) const { return impl->evaluate(object); } - -Query::Query(const char* className, const char* packageName) : impl(new QueryImpl(className, packageName)) {} -Query::Query(const SchemaClassKey* key) : impl(new QueryImpl(key)) {} -Query::Query(const ObjectId* oid) : impl(new QueryImpl(oid)) {} -Query::Query(QueryImpl* i) : impl(i) {} -Query::Query(const Query& from) : impl(new QueryImpl(*(from.impl))) {} -Query::~Query() { delete impl; } -void Query::setSelect(const QueryOperand* criterion) { impl->setSelect(criterion); } -void Query::setLimit(uint32_t maxResults) { impl->setLimit(maxResults); } -void Query::setOrderBy(const char* attrName, bool decreasing) { impl->setOrderBy(attrName, decreasing); } -const char* Query::getPackage() const { return impl->getPackage().c_str(); } -const char* Query::getClass() const { return impl->getClass().c_str(); } -const ObjectId* Query::getObjectId() const { return impl->getObjectId(); } -bool Query::haveSelect() const { return impl->haveSelect(); } -bool Query::haveLimit() const { return impl->haveLimit(); } -bool Query::haveOrderBy() const { return impl->haveOrderBy(); } -const QueryOperand* Query::getSelect() const { return impl->getSelect(); } -uint32_t Query::getLimit() const { return impl->getLimit(); } -const char* Query::getOrderBy() const { return impl->getOrderBy().c_str(); } -bool Query::getDecreasing() const { return impl->getDecreasing(); } - diff --git a/qpid/cpp/src/qmf/engine/QueryImpl.h b/qpid/cpp/src/qmf/engine/QueryImpl.h deleted file mode 100644 index 8ebe0d932f..0000000000 --- a/qpid/cpp/src/qmf/engine/QueryImpl.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef _QmfEngineQueryImpl_ -#define _QmfEngineQueryImpl_ - -/* - * 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 "qmf/engine/Query.h" -#include "qmf/engine/Schema.h" -#include <string> -#include <boost/shared_ptr.hpp> - -namespace qpid { - namespace framing { - class Buffer; - } -} - -namespace qmf { -namespace engine { - - struct QueryElementImpl { - QueryElementImpl(const std::string& a, const Value* v, ValueOper o) : attrName(a), value(v), oper(o) {} - ~QueryElementImpl() {} - bool evaluate(const Object* object) const; - - std::string attrName; - const Value* value; - ValueOper oper; - }; - - struct QueryExpressionImpl { - QueryExpressionImpl(ExprOper o, const QueryOperand* operand1, const QueryOperand* operand2) : oper(o), left(operand1), right(operand2) {} - ~QueryExpressionImpl() {} - bool evaluate(const Object* object) const; - - ExprOper oper; - const QueryOperand* left; - const QueryOperand* right; - }; - - struct QueryImpl { - // Constructors mapped to public - QueryImpl(const std::string& c, const std::string& p) : packageName(p), className(c), select(0), resultLimit(0) {} - QueryImpl(const SchemaClassKey* key) : packageName(key->getPackageName()), className(key->getClassName()), select(0), resultLimit(0) {} - QueryImpl(const ObjectId* oid) : oid(new ObjectId(*oid)), select(0), resultLimit(0) {} - - // Factory constructors - QueryImpl(qpid::framing::Buffer& buffer); - - ~QueryImpl() {}; - static Query* factory(qpid::framing::Buffer& buffer); - - void setSelect(const QueryOperand* criterion) { select = criterion; } - void setLimit(uint32_t maxResults) { resultLimit = maxResults; } - void setOrderBy(const std::string& attrName, bool decreasing) { - orderBy = attrName; orderDecreasing = decreasing; - } - - const std::string& getPackage() const { return packageName; } - const std::string& getClass() const { return className; } - const ObjectId* getObjectId() const { return oid.get(); } - - bool haveSelect() const { return select != 0; } - bool haveLimit() const { return resultLimit > 0; } - bool haveOrderBy() const { return !orderBy.empty(); } - const QueryOperand* getSelect() const { return select; } - uint32_t getLimit() const { return resultLimit; } - const std::string& getOrderBy() const { return orderBy; } - bool getDecreasing() const { return orderDecreasing; } - - void encode(qpid::framing::Buffer& buffer) const; - bool singleAgent() const { return oid.get() != 0; } - uint32_t agentBank() const { return singleAgent() ? oid->getAgentBank() : 0; } - - std::string packageName; - std::string className; - boost::shared_ptr<ObjectId> oid; - const QueryOperand* select; - uint32_t resultLimit; - std::string orderBy; - bool orderDecreasing; - }; -} -} - -#endif diff --git a/qpid/cpp/src/qmf/engine/ResilientConnection.cpp b/qpid/cpp/src/qmf/engine/ResilientConnection.cpp deleted file mode 100644 index 851193ccc1..0000000000 --- a/qpid/cpp/src/qmf/engine/ResilientConnection.cpp +++ /dev/null @@ -1,512 +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. - */ - -#include "qmf/engine/ResilientConnection.h" -#include "qmf/engine/MessageImpl.h" -#include "qmf/engine/ConnectionSettingsImpl.h" -#include <qpid/client/Connection.h> -#include <qpid/client/Session.h> -#include <qpid/client/MessageListener.h> -#include <qpid/client/SubscriptionManager.h> -#include <qpid/client/Message.h> -#include <qpid/sys/Thread.h> -#include <qpid/sys/Runnable.h> -#include <qpid/sys/Mutex.h> -#include <qpid/sys/Condition.h> -#include <qpid/sys/Time.h> -#include <qpid/log/Statement.h> -#include <qpid/RefCounted.h> -#include <boost/bind.hpp> -#include <string> -#include <deque> -#include <vector> -#include <set> -#include <boost/intrusive_ptr.hpp> -#include <boost/noncopyable.hpp> -#include <unistd.h> -#include <fcntl.h> - -using namespace std; -using namespace qmf::engine; -using namespace qpid; -using qpid::sys::Mutex; - -namespace qmf { -namespace engine { - struct ResilientConnectionEventImpl { - ResilientConnectionEvent::EventKind kind; - void* sessionContext; - string errorText; - MessageImpl message; - - ResilientConnectionEventImpl(ResilientConnectionEvent::EventKind k, - const MessageImpl& m = MessageImpl()) : - kind(k), sessionContext(0), message(m) {} - ResilientConnectionEvent copy(); - }; - - struct RCSession : public client::MessageListener, public qpid::sys::Runnable, public qpid::RefCounted { - typedef boost::intrusive_ptr<RCSession> Ptr; - ResilientConnectionImpl& connImpl; - string name; - client::Connection& connection; - client::Session session; - client::SubscriptionManager* subscriptions; - string userId; - void* userContext; - vector<string> dests; - qpid::sys::Thread thread; - - RCSession(ResilientConnectionImpl& ci, const string& n, client::Connection& c, void* uc); - ~RCSession(); - void received(client::Message& msg); - void run(); - void stop(); - }; - - class ResilientConnectionImpl : public qpid::sys::Runnable, public boost::noncopyable { - public: - ResilientConnectionImpl(const ConnectionSettings& settings); - ~ResilientConnectionImpl(); - - bool isConnected() const; - bool getEvent(ResilientConnectionEvent& event); - void popEvent(); - bool createSession(const char* name, void* sessionContext, SessionHandle& handle); - void destroySession(SessionHandle handle); - void sendMessage(SessionHandle handle, qmf::engine::Message& message); - void declareQueue(SessionHandle handle, char* queue); - void deleteQueue(SessionHandle handle, char* queue); - void bind(SessionHandle handle, char* exchange, char* queue, char* key); - void unbind(SessionHandle handle, char* exchange, char* queue, char* key); - void setNotifyFd(int fd); - void notify(); - - void run(); - void failure(); - void sessionClosed(RCSession* sess); - - void EnqueueEvent(ResilientConnectionEvent::EventKind kind, - void* sessionContext = 0, - const MessageImpl& message = MessageImpl(), - const string& errorText = ""); - - private: - int notifyFd; - bool connected; - bool shutdown; - string lastError; - const ConnectionSettings settings; - client::Connection connection; - mutable qpid::sys::Mutex lock; - int delayMin; - int delayMax; - int delayFactor; - qpid::sys::Condition cond; - deque<ResilientConnectionEventImpl> eventQueue; - set<RCSession::Ptr> sessions; - qpid::sys::Thread connThread; - }; -} -} - -ResilientConnectionEvent ResilientConnectionEventImpl::copy() -{ - ResilientConnectionEvent item; - - ::memset(&item, 0, sizeof(ResilientConnectionEvent)); - item.kind = kind; - item.sessionContext = sessionContext; - item.message = message.copy(); - item.errorText = const_cast<char*>(errorText.c_str()); - - return item; -} - -RCSession::RCSession(ResilientConnectionImpl& ci, const string& n, client::Connection& c, void* uc) : - connImpl(ci), name(n), connection(c), session(connection.newSession(name)), - subscriptions(new client::SubscriptionManager(session)), userContext(uc), thread(*this) -{ - const qpid::client::ConnectionSettings& operSettings = connection.getNegotiatedSettings(); - userId = operSettings.username; -} - -RCSession::~RCSession() -{ - subscriptions->stop(); - thread.join(); - session.close(); - delete subscriptions; -} - -void RCSession::run() -{ - try { - subscriptions->run(); - } catch (exception& /*e*/) { - connImpl.sessionClosed(this); - } -} - -void RCSession::stop() -{ - subscriptions->stop(); -} - -void RCSession::received(client::Message& msg) -{ - MessageImpl qmsg; - qmsg.body = msg.getData(); - - qpid::framing::DeliveryProperties dp = msg.getDeliveryProperties(); - if (dp.hasRoutingKey()) { - qmsg.routingKey = dp.getRoutingKey(); - } - - qpid::framing::MessageProperties mp = msg.getMessageProperties(); - if (mp.hasReplyTo()) { - const qpid::framing::ReplyTo& rt = mp.getReplyTo(); - qmsg.replyExchange = rt.getExchange(); - qmsg.replyKey = rt.getRoutingKey(); - } - - if (mp.hasUserId()) { - qmsg.userId = mp.getUserId(); - } - - connImpl.EnqueueEvent(ResilientConnectionEvent::RECV, userContext, qmsg); -} - -ResilientConnectionImpl::ResilientConnectionImpl(const ConnectionSettings& _settings) : - notifyFd(-1), connected(false), shutdown(false), settings(_settings), delayMin(1), connThread(*this) -{ - connection.registerFailureCallback(boost::bind(&ResilientConnectionImpl::failure, this)); - settings.impl->getRetrySettings(&delayMin, &delayMax, &delayFactor); -} - -ResilientConnectionImpl::~ResilientConnectionImpl() -{ - shutdown = true; - connected = false; - cond.notify(); - connThread.join(); - connection.close(); -} - -bool ResilientConnectionImpl::isConnected() const -{ - Mutex::ScopedLock _lock(lock); - return connected; -} - -bool ResilientConnectionImpl::getEvent(ResilientConnectionEvent& event) -{ - Mutex::ScopedLock _lock(lock); - if (eventQueue.empty()) - return false; - event = eventQueue.front().copy(); - return true; -} - -void ResilientConnectionImpl::popEvent() -{ - Mutex::ScopedLock _lock(lock); - if (!eventQueue.empty()) - eventQueue.pop_front(); -} - -bool ResilientConnectionImpl::createSession(const char* name, void* sessionContext, - SessionHandle& handle) -{ - Mutex::ScopedLock _lock(lock); - if (!connected) - return false; - - RCSession::Ptr sess = RCSession::Ptr(new RCSession(*this, name, connection, sessionContext)); - - handle.impl = (void*) sess.get(); - sessions.insert(sess); - - return true; -} - -void ResilientConnectionImpl::destroySession(SessionHandle handle) -{ - Mutex::ScopedLock _lock(lock); - RCSession::Ptr sess = RCSession::Ptr((RCSession*) handle.impl); - set<RCSession::Ptr>::iterator iter = sessions.find(sess); - if (iter != sessions.end()) { - for (vector<string>::iterator dIter = sess->dests.begin(); dIter != sess->dests.end(); dIter++) - sess->subscriptions->cancel(dIter->c_str()); - sess->subscriptions->stop(); - sess->subscriptions->wait(); - - sessions.erase(iter); - return; - } -} - -void ResilientConnectionImpl::sendMessage(SessionHandle handle, qmf::engine::Message& message) -{ - Mutex::ScopedLock _lock(lock); - RCSession::Ptr sess = RCSession::Ptr((RCSession*) handle.impl); - set<RCSession::Ptr>::iterator iter = sessions.find(sess); - qpid::client::Message msg; - string data(message.body, message.length); - msg.getDeliveryProperties().setRoutingKey(message.routingKey); - msg.getMessageProperties().setReplyTo(qpid::framing::ReplyTo(message.replyExchange, message.replyKey)); - if (settings.impl->getSendUserId()) - msg.getMessageProperties().setUserId(sess->userId); - msg.setData(data); - - try { - sess->session.messageTransfer(client::arg::content=msg, client::arg::destination=message.destination); - } catch(exception& e) { - QPID_LOG(error, "Session Exception during message-transfer: " << e.what()); - sessions.erase(iter); - EnqueueEvent(ResilientConnectionEvent::SESSION_CLOSED, (*iter)->userContext); - } -} - -void ResilientConnectionImpl::declareQueue(SessionHandle handle, char* queue) -{ - Mutex::ScopedLock _lock(lock); - RCSession* sess = (RCSession*) handle.impl; - - sess->session.queueDeclare(client::arg::queue=queue, client::arg::autoDelete=true, client::arg::exclusive=true); - sess->subscriptions->setAcceptMode(client::ACCEPT_MODE_NONE); - sess->subscriptions->setAcquireMode(client::ACQUIRE_MODE_PRE_ACQUIRED); - sess->subscriptions->subscribe(*sess, queue, queue); - sess->subscriptions->setFlowControl(queue, client::FlowControl::unlimited()); - sess->dests.push_back(string(queue)); -} - -void ResilientConnectionImpl::deleteQueue(SessionHandle handle, char* queue) -{ - Mutex::ScopedLock _lock(lock); - RCSession* sess = (RCSession*) handle.impl; - - sess->session.queueDelete(client::arg::queue=queue); - for (vector<string>::iterator iter = sess->dests.begin(); - iter != sess->dests.end(); iter++) - if (*iter == queue) { - sess->subscriptions->cancel(queue); - sess->dests.erase(iter); - break; - } -} - -void ResilientConnectionImpl::bind(SessionHandle handle, - char* exchange, char* queue, char* key) -{ - Mutex::ScopedLock _lock(lock); - RCSession* sess = (RCSession*) handle.impl; - - sess->session.exchangeBind(client::arg::exchange=exchange, client::arg::queue=queue, client::arg::bindingKey=key); -} - -void ResilientConnectionImpl::unbind(SessionHandle handle, - char* exchange, char* queue, char* key) -{ - Mutex::ScopedLock _lock(lock); - RCSession* sess = (RCSession*) handle.impl; - - sess->session.exchangeUnbind(client::arg::exchange=exchange, client::arg::queue=queue, client::arg::bindingKey=key); -} - -void ResilientConnectionImpl::notify() -{ - if (notifyFd != -1) - { - if (::write(notifyFd, ".", 1)) {} - } -} - - -void ResilientConnectionImpl::setNotifyFd(int fd) -{ - notifyFd = fd; - if (notifyFd > 0) { - int original = fcntl(notifyFd, F_GETFL); - fcntl(notifyFd, F_SETFL, O_NONBLOCK | original); - } -} - -void ResilientConnectionImpl::run() -{ - int delay(delayMin); - - while (true) { - try { - QPID_LOG(trace, "Trying to open connection..."); - connection.open(settings.impl->getClientSettings()); - { - Mutex::ScopedLock _lock(lock); - connected = true; - EnqueueEvent(ResilientConnectionEvent::CONNECTED); - - while (connected) - cond.wait(lock); - delay = delayMin; - - while (!sessions.empty()) { - set<RCSession::Ptr>::iterator iter = sessions.begin(); - RCSession::Ptr sess = *iter; - sessions.erase(iter); - EnqueueEvent(ResilientConnectionEvent::SESSION_CLOSED, sess->userContext); - Mutex::ScopedUnlock _u(lock); - sess->stop(); - - // Nullify the intrusive pointer within the scoped unlock, otherwise, - // the reference is held until overwritted above (under lock) which causes - // the session destructor to be called with the lock held. - sess = 0; - } - - EnqueueEvent(ResilientConnectionEvent::DISCONNECTED); - - if (shutdown) - return; - } - connection.close(); - } catch (exception &e) { - QPID_LOG(debug, "connection.open exception: " << e.what()); - Mutex::ScopedLock _lock(lock); - lastError = e.what(); - if (delay < delayMax) - delay *= delayFactor; - } - - ::qpid::sys::sleep(delay); - } -} - -void ResilientConnectionImpl::failure() -{ - Mutex::ScopedLock _lock(lock); - - connected = false; - lastError = "Closed by Peer"; - cond.notify(); -} - -void ResilientConnectionImpl::sessionClosed(RCSession*) -{ - Mutex::ScopedLock _lock(lock); - connected = false; - lastError = "Closed due to Session failure"; - cond.notify(); -} - -void ResilientConnectionImpl::EnqueueEvent(ResilientConnectionEvent::EventKind kind, - void* sessionContext, - const MessageImpl& message, - const string& errorText) -{ - { - Mutex::ScopedLock _lock(lock); - ResilientConnectionEventImpl event(kind, message); - - event.sessionContext = sessionContext; - event.errorText = errorText; - - eventQueue.push_back(event); - } - - if (notifyFd != -1) - { - if (::write(notifyFd, ".", 1)) {} - } -} - - -//================================================================== -// Wrappers -//================================================================== - -ResilientConnection::ResilientConnection(const ConnectionSettings& settings) -{ - impl = new ResilientConnectionImpl(settings); -} - -ResilientConnection::~ResilientConnection() -{ - delete impl; -} - -bool ResilientConnection::isConnected() const -{ - return impl->isConnected(); -} - -bool ResilientConnection::getEvent(ResilientConnectionEvent& event) -{ - return impl->getEvent(event); -} - -void ResilientConnection::popEvent() -{ - impl->popEvent(); -} - -bool ResilientConnection::createSession(const char* name, void* sessionContext, SessionHandle& handle) -{ - return impl->createSession(name, sessionContext, handle); -} - -void ResilientConnection::destroySession(SessionHandle handle) -{ - impl->destroySession(handle); -} - -void ResilientConnection::sendMessage(SessionHandle handle, qmf::engine::Message& message) -{ - impl->sendMessage(handle, message); -} - -void ResilientConnection::declareQueue(SessionHandle handle, char* queue) -{ - impl->declareQueue(handle, queue); -} - -void ResilientConnection::deleteQueue(SessionHandle handle, char* queue) -{ - impl->deleteQueue(handle, queue); -} - -void ResilientConnection::bind(SessionHandle handle, char* exchange, char* queue, char* key) -{ - impl->bind(handle, exchange, queue, key); -} - -void ResilientConnection::unbind(SessionHandle handle, char* exchange, char* queue, char* key) -{ - impl->unbind(handle, exchange, queue, key); -} - -void ResilientConnection::setNotifyFd(int fd) -{ - impl->setNotifyFd(fd); -} - -void ResilientConnection::notify() -{ - impl->notify(); -} - diff --git a/qpid/cpp/src/qmf/engine/SchemaImpl.cpp b/qpid/cpp/src/qmf/engine/SchemaImpl.cpp deleted file mode 100644 index 9d363d3012..0000000000 --- a/qpid/cpp/src/qmf/engine/SchemaImpl.cpp +++ /dev/null @@ -1,610 +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. - */ - -#include "qmf/engine/SchemaImpl.h" -#include <qpid/framing/Buffer.h> -#include <qpid/framing/FieldTable.h> -#include <qpid/framing/Uuid.h> -#include <string.h> -#include <string> -#include <vector> -#include <sstream> - -using namespace std; -using namespace qmf::engine; -using qpid::framing::Buffer; -using qpid::framing::FieldTable; -using qpid::framing::Uuid; - -SchemaHash::SchemaHash() -{ - for (int idx = 0; idx < 16; idx++) - hash.b[idx] = 0x5A; -} - -void SchemaHash::encode(Buffer& buffer) const -{ - buffer.putBin128(hash.b); -} - -void SchemaHash::decode(Buffer& buffer) -{ - buffer.getBin128(hash.b); -} - -void SchemaHash::update(uint8_t data) -{ - update((char*) &data, 1); -} - -void SchemaHash::update(const char* data, uint32_t len) -{ - uint64_t* first = &hash.q[0]; - uint64_t* second = &hash.q[1]; - for (uint32_t idx = 0; idx < len; idx++) { - *first = *first ^ (uint64_t) data[idx]; - *second = *second << 1; - *second |= ((*first & 0x8000000000000000LL) >> 63); - *first = *first << 1; - *first = *first ^ *second; - } -} - -bool SchemaHash::operator==(const SchemaHash& other) const -{ - return ::memcmp(&hash, &other.hash, 16) == 0; -} - -bool SchemaHash::operator<(const SchemaHash& other) const -{ - return ::memcmp(&hash, &other.hash, 16) < 0; -} - -bool SchemaHash::operator>(const SchemaHash& other) const -{ - return ::memcmp(&hash, &other.hash, 16) > 0; -} - -SchemaArgumentImpl::SchemaArgumentImpl(Buffer& buffer) -{ - FieldTable map; - map.decode(buffer); - - name = map.getAsString("name"); - typecode = (Typecode) map.getAsInt("type"); - unit = map.getAsString("unit"); - description = map.getAsString("desc"); - - dir = DIR_IN; - string dstr(map.getAsString("dir")); - if (dstr == "O") - dir = DIR_OUT; - else if (dstr == "IO") - dir = DIR_IN_OUT; -} - -SchemaArgument* SchemaArgumentImpl::factory(Buffer& buffer) -{ - SchemaArgumentImpl* impl(new SchemaArgumentImpl(buffer)); - return new SchemaArgument(impl); -} - -void SchemaArgumentImpl::encode(Buffer& buffer) const -{ - FieldTable map; - - map.setString("name", name); - map.setInt("type", (int) typecode); - if (dir == DIR_IN) - map.setString("dir", "I"); - else if (dir == DIR_OUT) - map.setString("dir", "O"); - else - map.setString("dir", "IO"); - if (!unit.empty()) - map.setString("unit", unit); - if (!description.empty()) - map.setString("desc", description); - - map.encode(buffer); -} - -void SchemaArgumentImpl::updateHash(SchemaHash& hash) const -{ - hash.update(name); - hash.update(typecode); - hash.update(dir); - hash.update(unit); - hash.update(description); -} - -SchemaMethodImpl::SchemaMethodImpl(Buffer& buffer) -{ - FieldTable map; - int argCount; - - map.decode(buffer); - name = map.getAsString("name"); - argCount = map.getAsInt("argCount"); - description = map.getAsString("desc"); - - for (int idx = 0; idx < argCount; idx++) { - SchemaArgument* arg = SchemaArgumentImpl::factory(buffer); - addArgument(arg); - } -} - -SchemaMethod* SchemaMethodImpl::factory(Buffer& buffer) -{ - SchemaMethodImpl* impl(new SchemaMethodImpl(buffer)); - return new SchemaMethod(impl); -} - -void SchemaMethodImpl::encode(Buffer& buffer) const -{ - FieldTable map; - - map.setString("name", name); - map.setInt("argCount", arguments.size()); - if (!description.empty()) - map.setString("desc", description); - map.encode(buffer); - - for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin(); - iter != arguments.end(); iter++) - (*iter)->impl->encode(buffer); -} - -void SchemaMethodImpl::addArgument(const SchemaArgument* argument) -{ - arguments.push_back(argument); -} - -const SchemaArgument* SchemaMethodImpl::getArgument(int idx) const -{ - int count = 0; - for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin(); - iter != arguments.end(); iter++, count++) - if (idx == count) - return (*iter); - return 0; -} - -void SchemaMethodImpl::updateHash(SchemaHash& hash) const -{ - hash.update(name); - hash.update(description); - for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin(); - iter != arguments.end(); iter++) - (*iter)->impl->updateHash(hash); -} - -SchemaPropertyImpl::SchemaPropertyImpl(Buffer& buffer) -{ - FieldTable map; - map.decode(buffer); - - name = map.getAsString("name"); - typecode = (Typecode) map.getAsInt("type"); - access = (Access) map.getAsInt("access"); - index = map.getAsInt("index") != 0; - optional = map.getAsInt("optional") != 0; - unit = map.getAsString("unit"); - description = map.getAsString("desc"); -} - -SchemaProperty* SchemaPropertyImpl::factory(Buffer& buffer) -{ - SchemaPropertyImpl* impl(new SchemaPropertyImpl(buffer)); - return new SchemaProperty(impl); -} - -void SchemaPropertyImpl::encode(Buffer& buffer) const -{ - FieldTable map; - - map.setString("name", name); - map.setInt("type", (int) typecode); - map.setInt("access", (int) access); - map.setInt("index", index ? 1 : 0); - map.setInt("optional", optional ? 1 : 0); - if (!unit.empty()) - map.setString("unit", unit); - if (!description.empty()) - map.setString("desc", description); - - map.encode(buffer); -} - -void SchemaPropertyImpl::updateHash(SchemaHash& hash) const -{ - hash.update(name); - hash.update(typecode); - hash.update(access); - hash.update(index); - hash.update(optional); - hash.update(unit); - hash.update(description); -} - -SchemaStatisticImpl::SchemaStatisticImpl(Buffer& buffer) -{ - FieldTable map; - map.decode(buffer); - - name = map.getAsString("name"); - typecode = (Typecode) map.getAsInt("type"); - unit = map.getAsString("unit"); - description = map.getAsString("desc"); -} - -SchemaStatistic* SchemaStatisticImpl::factory(Buffer& buffer) -{ - SchemaStatisticImpl* impl(new SchemaStatisticImpl(buffer)); - return new SchemaStatistic(impl); -} - -void SchemaStatisticImpl::encode(Buffer& buffer) const -{ - FieldTable map; - - map.setString("name", name); - map.setInt("type", (int) typecode); - if (!unit.empty()) - map.setString("unit", unit); - if (!description.empty()) - map.setString("desc", description); - - map.encode(buffer); -} - -void SchemaStatisticImpl::updateHash(SchemaHash& hash) const -{ - hash.update(name); - hash.update(typecode); - hash.update(unit); - hash.update(description); -} - -SchemaClassKeyImpl::SchemaClassKeyImpl(const string& p, const string& n, const SchemaHash& h) : package(p), name(n), hash(h) {} - -SchemaClassKeyImpl::SchemaClassKeyImpl(Buffer& buffer) : package(packageContainer), name(nameContainer), hash(hashContainer) -{ - buffer.getShortString(packageContainer); - buffer.getShortString(nameContainer); - hashContainer.decode(buffer); -} - -SchemaClassKey* SchemaClassKeyImpl::factory(const string& package, const string& name, const SchemaHash& hash) -{ - SchemaClassKeyImpl* impl(new SchemaClassKeyImpl(package, name, hash)); - return new SchemaClassKey(impl); -} - -SchemaClassKey* SchemaClassKeyImpl::factory(Buffer& buffer) -{ - SchemaClassKeyImpl* impl(new SchemaClassKeyImpl(buffer)); - return new SchemaClassKey(impl); -} - -void SchemaClassKeyImpl::encode(Buffer& buffer) const -{ - buffer.putShortString(package); - buffer.putShortString(name); - hash.encode(buffer); -} - -bool SchemaClassKeyImpl::operator==(const SchemaClassKeyImpl& other) const -{ - return package == other.package && - name == other.name && - hash == other.hash; -} - -bool SchemaClassKeyImpl::operator<(const SchemaClassKeyImpl& other) const -{ - if (package < other.package) return true; - if (package > other.package) return false; - if (name < other.name) return true; - if (name > other.name) return false; - return hash < other.hash; -} - -const string& SchemaClassKeyImpl::str() const -{ - Uuid printableHash(hash.get()); - stringstream str; - str << package << ":" << name << "(" << printableHash << ")"; - repr = str.str(); - return repr; -} - -SchemaObjectClassImpl::SchemaObjectClassImpl(Buffer& buffer) : hasHash(true), classKey(SchemaClassKeyImpl::factory(package, name, hash)) -{ - buffer.getShortString(package); - buffer.getShortString(name); - hash.decode(buffer); - - uint16_t propCount = buffer.getShort(); - uint16_t statCount = buffer.getShort(); - uint16_t methodCount = buffer.getShort(); - - for (uint16_t idx = 0; idx < propCount; idx++) { - const SchemaProperty* property = SchemaPropertyImpl::factory(buffer); - addProperty(property); - } - - for (uint16_t idx = 0; idx < statCount; idx++) { - const SchemaStatistic* statistic = SchemaStatisticImpl::factory(buffer); - addStatistic(statistic); - } - - for (uint16_t idx = 0; idx < methodCount; idx++) { - SchemaMethod* method = SchemaMethodImpl::factory(buffer); - addMethod(method); - } -} - -SchemaObjectClass* SchemaObjectClassImpl::factory(Buffer& buffer) -{ - SchemaObjectClassImpl* impl(new SchemaObjectClassImpl(buffer)); - return new SchemaObjectClass(impl); -} - -void SchemaObjectClassImpl::encode(Buffer& buffer) const -{ - buffer.putOctet((uint8_t) CLASS_OBJECT); - buffer.putShortString(package); - buffer.putShortString(name); - hash.encode(buffer); - //buffer.putOctet(0); // No parent class - buffer.putShort((uint16_t) properties.size()); - buffer.putShort((uint16_t) statistics.size()); - buffer.putShort((uint16_t) methods.size()); - - for (vector<const SchemaProperty*>::const_iterator iter = properties.begin(); - iter != properties.end(); iter++) - (*iter)->impl->encode(buffer); - for (vector<const SchemaStatistic*>::const_iterator iter = statistics.begin(); - iter != statistics.end(); iter++) - (*iter)->impl->encode(buffer); - for (vector<const SchemaMethod*>::const_iterator iter = methods.begin(); - iter != methods.end(); iter++) - (*iter)->impl->encode(buffer); -} - -const SchemaClassKey* SchemaObjectClassImpl::getClassKey() const -{ - if (!hasHash) { - hasHash = true; - hash.update(package); - hash.update(name); - for (vector<const SchemaProperty*>::const_iterator iter = properties.begin(); - iter != properties.end(); iter++) - (*iter)->impl->updateHash(hash); - for (vector<const SchemaStatistic*>::const_iterator iter = statistics.begin(); - iter != statistics.end(); iter++) - (*iter)->impl->updateHash(hash); - for (vector<const SchemaMethod*>::const_iterator iter = methods.begin(); - iter != methods.end(); iter++) - (*iter)->impl->updateHash(hash); - } - - return classKey.get(); -} - -void SchemaObjectClassImpl::addProperty(const SchemaProperty* property) -{ - properties.push_back(property); -} - -void SchemaObjectClassImpl::addStatistic(const SchemaStatistic* statistic) -{ - statistics.push_back(statistic); -} - -void SchemaObjectClassImpl::addMethod(const SchemaMethod* method) -{ - methods.push_back(method); -} - -const SchemaProperty* SchemaObjectClassImpl::getProperty(int idx) const -{ - int count = 0; - for (vector<const SchemaProperty*>::const_iterator iter = properties.begin(); - iter != properties.end(); iter++, count++) - if (idx == count) - return *iter; - return 0; -} - -const SchemaStatistic* SchemaObjectClassImpl::getStatistic(int idx) const -{ - int count = 0; - for (vector<const SchemaStatistic*>::const_iterator iter = statistics.begin(); - iter != statistics.end(); iter++, count++) - if (idx == count) - return *iter; - return 0; -} - -const SchemaMethod* SchemaObjectClassImpl::getMethod(int idx) const -{ - int count = 0; - for (vector<const SchemaMethod*>::const_iterator iter = methods.begin(); - iter != methods.end(); iter++, count++) - if (idx == count) - return *iter; - return 0; -} - -SchemaEventClassImpl::SchemaEventClassImpl(Buffer& buffer) : hasHash(true), classKey(SchemaClassKeyImpl::factory(package, name, hash)) -{ - buffer.getShortString(package); - buffer.getShortString(name); - hash.decode(buffer); - - uint16_t argCount = buffer.getShort(); - - for (uint16_t idx = 0; idx < argCount; idx++) { - SchemaArgument* argument = SchemaArgumentImpl::factory(buffer); - addArgument(argument); - } -} - -SchemaEventClass* SchemaEventClassImpl::factory(Buffer& buffer) -{ - SchemaEventClassImpl* impl(new SchemaEventClassImpl(buffer)); - return new SchemaEventClass(impl); -} - -void SchemaEventClassImpl::encode(Buffer& buffer) const -{ - buffer.putOctet((uint8_t) CLASS_EVENT); - buffer.putShortString(package); - buffer.putShortString(name); - hash.encode(buffer); - buffer.putShort((uint16_t) arguments.size()); - - for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin(); - iter != arguments.end(); iter++) - (*iter)->impl->encode(buffer); -} - -const SchemaClassKey* SchemaEventClassImpl::getClassKey() const -{ - if (!hasHash) { - hasHash = true; - hash.update(package); - hash.update(name); - for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin(); - iter != arguments.end(); iter++) - (*iter)->impl->updateHash(hash); - } - return classKey.get(); -} - -void SchemaEventClassImpl::addArgument(const SchemaArgument* argument) -{ - arguments.push_back(argument); -} - -const SchemaArgument* SchemaEventClassImpl::getArgument(int idx) const -{ - int count = 0; - for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin(); - iter != arguments.end(); iter++, count++) - if (idx == count) - return (*iter); - return 0; -} - - -//================================================================== -// Wrappers -//================================================================== - -SchemaArgument::SchemaArgument(const char* name, Typecode typecode) { impl = new SchemaArgumentImpl(name, typecode); } -SchemaArgument::SchemaArgument(SchemaArgumentImpl* i) : impl(i) {} -SchemaArgument::SchemaArgument(const SchemaArgument& from) : impl(new SchemaArgumentImpl(*(from.impl))) {} -SchemaArgument::~SchemaArgument() { delete impl; } -void SchemaArgument::setDirection(Direction dir) { impl->setDirection(dir); } -void SchemaArgument::setUnit(const char* val) { impl->setUnit(val); } -void SchemaArgument::setDesc(const char* desc) { impl->setDesc(desc); } -const char* SchemaArgument::getName() const { return impl->getName().c_str(); } -Typecode SchemaArgument::getType() const { return impl->getType(); } -Direction SchemaArgument::getDirection() const { return impl->getDirection(); } -const char* SchemaArgument::getUnit() const { return impl->getUnit().c_str(); } -const char* SchemaArgument::getDesc() const { return impl->getDesc().c_str(); } - -SchemaMethod::SchemaMethod(const char* name) : impl(new SchemaMethodImpl(name)) {} -SchemaMethod::SchemaMethod(SchemaMethodImpl* i) : impl(i) {} -SchemaMethod::SchemaMethod(const SchemaMethod& from) : impl(new SchemaMethodImpl(*(from.impl))) {} -SchemaMethod::~SchemaMethod() { delete impl; } -void SchemaMethod::addArgument(const SchemaArgument* argument) { impl->addArgument(argument); } -void SchemaMethod::setDesc(const char* desc) { impl->setDesc(desc); } -const char* SchemaMethod::getName() const { return impl->getName().c_str(); } -const char* SchemaMethod::getDesc() const { return impl->getDesc().c_str(); } -int SchemaMethod::getArgumentCount() const { return impl->getArgumentCount(); } -const SchemaArgument* SchemaMethod::getArgument(int idx) const { return impl->getArgument(idx); } - -SchemaProperty::SchemaProperty(const char* name, Typecode typecode) : impl(new SchemaPropertyImpl(name, typecode)) {} -SchemaProperty::SchemaProperty(SchemaPropertyImpl* i) : impl(i) {} -SchemaProperty::SchemaProperty(const SchemaProperty& from) : impl(new SchemaPropertyImpl(*(from.impl))) {} -SchemaProperty::~SchemaProperty() { delete impl; } -void SchemaProperty::setAccess(Access access) { impl->setAccess(access); } -void SchemaProperty::setIndex(bool val) { impl->setIndex(val); } -void SchemaProperty::setOptional(bool val) { impl->setOptional(val); } -void SchemaProperty::setUnit(const char* val) { impl->setUnit(val); } -void SchemaProperty::setDesc(const char* desc) { impl->setDesc(desc); } -const char* SchemaProperty::getName() const { return impl->getName().c_str(); } -Typecode SchemaProperty::getType() const { return impl->getType(); } -Access SchemaProperty::getAccess() const { return impl->getAccess(); } -bool SchemaProperty::isIndex() const { return impl->isIndex(); } -bool SchemaProperty::isOptional() const { return impl->isOptional(); } -const char* SchemaProperty::getUnit() const { return impl->getUnit().c_str(); } -const char* SchemaProperty::getDesc() const { return impl->getDesc().c_str(); } - -SchemaStatistic::SchemaStatistic(const char* name, Typecode typecode) : impl(new SchemaStatisticImpl(name, typecode)) {} -SchemaStatistic::SchemaStatistic(SchemaStatisticImpl* i) : impl(i) {} -SchemaStatistic::SchemaStatistic(const SchemaStatistic& from) : impl(new SchemaStatisticImpl(*(from.impl))) {} -SchemaStatistic::~SchemaStatistic() { delete impl; } -void SchemaStatistic::setUnit(const char* val) { impl->setUnit(val); } -void SchemaStatistic::setDesc(const char* desc) { impl->setDesc(desc); } -const char* SchemaStatistic::getName() const { return impl->getName().c_str(); } -Typecode SchemaStatistic::getType() const { return impl->getType(); } -const char* SchemaStatistic::getUnit() const { return impl->getUnit().c_str(); } -const char* SchemaStatistic::getDesc() const { return impl->getDesc().c_str(); } - -SchemaClassKey::SchemaClassKey(SchemaClassKeyImpl* i) : impl(i) {} -SchemaClassKey::SchemaClassKey(const SchemaClassKey& from) : impl(new SchemaClassKeyImpl(*(from.impl))) {} -SchemaClassKey::~SchemaClassKey() { delete impl; } -const char* SchemaClassKey::getPackageName() const { return impl->getPackageName().c_str(); } -const char* SchemaClassKey::getClassName() const { return impl->getClassName().c_str(); } -const uint8_t* SchemaClassKey::getHash() const { return impl->getHash(); } -const char* SchemaClassKey::asString() const { return impl->str().c_str(); } -bool SchemaClassKey::operator==(const SchemaClassKey& other) const { return *impl == *(other.impl); } -bool SchemaClassKey::operator<(const SchemaClassKey& other) const { return *impl < *(other.impl); } - -SchemaObjectClass::SchemaObjectClass(const char* package, const char* name) : impl(new SchemaObjectClassImpl(package, name)) {} -SchemaObjectClass::SchemaObjectClass(SchemaObjectClassImpl* i) : impl(i) {} -SchemaObjectClass::SchemaObjectClass(const SchemaObjectClass& from) : impl(new SchemaObjectClassImpl(*(from.impl))) {} -SchemaObjectClass::~SchemaObjectClass() { delete impl; } -void SchemaObjectClass::addProperty(const SchemaProperty* property) { impl->addProperty(property); } -void SchemaObjectClass::addStatistic(const SchemaStatistic* statistic) { impl->addStatistic(statistic); } -void SchemaObjectClass::addMethod(const SchemaMethod* method) { impl->addMethod(method); } -const SchemaClassKey* SchemaObjectClass::getClassKey() const { return impl->getClassKey(); } -int SchemaObjectClass::getPropertyCount() const { return impl->getPropertyCount(); } -int SchemaObjectClass::getStatisticCount() const { return impl->getStatisticCount(); } -int SchemaObjectClass::getMethodCount() const { return impl->getMethodCount(); } -const SchemaProperty* SchemaObjectClass::getProperty(int idx) const { return impl->getProperty(idx); } -const SchemaStatistic* SchemaObjectClass::getStatistic(int idx) const { return impl->getStatistic(idx); } -const SchemaMethod* SchemaObjectClass::getMethod(int idx) const { return impl->getMethod(idx); } - -SchemaEventClass::SchemaEventClass(const char* package, const char* name, Severity s) : impl(new SchemaEventClassImpl(package, name, s)) {} -SchemaEventClass::SchemaEventClass(SchemaEventClassImpl* i) : impl(i) {} -SchemaEventClass::SchemaEventClass(const SchemaEventClass& from) : impl(new SchemaEventClassImpl(*(from.impl))) {} -SchemaEventClass::~SchemaEventClass() { delete impl; } -void SchemaEventClass::addArgument(const SchemaArgument* argument) { impl->addArgument(argument); } -void SchemaEventClass::setDesc(const char* desc) { impl->setDesc(desc); } -const SchemaClassKey* SchemaEventClass::getClassKey() const { return impl->getClassKey(); } -Severity SchemaEventClass::getSeverity() const { return impl->getSeverity(); } -int SchemaEventClass::getArgumentCount() const { return impl->getArgumentCount(); } -const SchemaArgument* SchemaEventClass::getArgument(int idx) const { return impl->getArgument(idx); } - diff --git a/qpid/cpp/src/qmf/engine/SchemaImpl.h b/qpid/cpp/src/qmf/engine/SchemaImpl.h deleted file mode 100644 index 683fb6f8f0..0000000000 --- a/qpid/cpp/src/qmf/engine/SchemaImpl.h +++ /dev/null @@ -1,230 +0,0 @@ -#ifndef _QmfEngineSchemaImpl_ -#define _QmfEngineSchemaImpl_ - -/* - * 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 "qmf/engine/Schema.h" -#include "qpid/framing/Buffer.h" - -#include <string> -#include <vector> -#include <memory> - -namespace qmf { -namespace engine { - - // TODO: Destructors for schema classes - // TODO: Add "frozen" attribute for schema classes so they can't be modified after - // they've been registered. - - class SchemaHash { - union h { - uint8_t b[16]; - uint64_t q[2]; - } hash; - public: - SchemaHash(); - void encode(qpid::framing::Buffer& buffer) const; - void decode(qpid::framing::Buffer& buffer); - void update(const char* data, uint32_t len); - void update(uint8_t data); - void update(const std::string& data) { update(data.c_str(), data.size()); } - void update(Typecode t) { update((uint8_t) t); } - void update(Direction d) { update((uint8_t) d); } - void update(Access a) { update((uint8_t) a); } - void update(bool b) { update((uint8_t) (b ? 1 : 0)); } - const uint8_t* get() const { return hash.b; } - bool operator==(const SchemaHash& other) const; - bool operator<(const SchemaHash& other) const; - bool operator>(const SchemaHash& other) const; - }; - - struct SchemaArgumentImpl { - std::string name; - Typecode typecode; - Direction dir; - std::string unit; - std::string description; - - SchemaArgumentImpl(const char* n, Typecode t) : name(n), typecode(t), dir(DIR_IN) {} - SchemaArgumentImpl(qpid::framing::Buffer& buffer); - static SchemaArgument* factory(qpid::framing::Buffer& buffer); - void encode(qpid::framing::Buffer& buffer) const; - void setDirection(Direction d) { dir = d; } - void setUnit(const char* val) { unit = val; } - void setDesc(const char* desc) { description = desc; } - const std::string& getName() const { return name; } - Typecode getType() const { return typecode; } - Direction getDirection() const { return dir; } - const std::string& getUnit() const { return unit; } - const std::string& getDesc() const { return description; } - void updateHash(SchemaHash& hash) const; - }; - - struct SchemaMethodImpl { - std::string name; - std::string description; - std::vector<const SchemaArgument*> arguments; - - SchemaMethodImpl(const char* n) : name(n) {} - SchemaMethodImpl(qpid::framing::Buffer& buffer); - static SchemaMethod* factory(qpid::framing::Buffer& buffer); - void encode(qpid::framing::Buffer& buffer) const; - void addArgument(const SchemaArgument* argument); - void setDesc(const char* desc) { description = desc; } - const std::string& getName() const { return name; } - const std::string& getDesc() const { return description; } - int getArgumentCount() const { return arguments.size(); } - const SchemaArgument* getArgument(int idx) const; - void updateHash(SchemaHash& hash) const; - }; - - struct SchemaPropertyImpl { - std::string name; - Typecode typecode; - Access access; - bool index; - bool optional; - std::string unit; - std::string description; - - SchemaPropertyImpl(const char* n, Typecode t) : name(n), typecode(t), access(ACCESS_READ_ONLY), index(false), optional(false) {} - SchemaPropertyImpl(qpid::framing::Buffer& buffer); - static SchemaProperty* factory(qpid::framing::Buffer& buffer); - void encode(qpid::framing::Buffer& buffer) const; - void setAccess(Access a) { access = a; } - void setIndex(bool val) { index = val; } - void setOptional(bool val) { optional = val; } - void setUnit(const char* val) { unit = val; } - void setDesc(const char* desc) { description = desc; } - const std::string& getName() const { return name; } - Typecode getType() const { return typecode; } - Access getAccess() const { return access; } - bool isIndex() const { return index; } - bool isOptional() const { return optional; } - const std::string& getUnit() const { return unit; } - const std::string& getDesc() const { return description; } - void updateHash(SchemaHash& hash) const; - }; - - struct SchemaStatisticImpl { - std::string name; - Typecode typecode; - std::string unit; - std::string description; - - SchemaStatisticImpl(const char* n, Typecode t) : name(n), typecode(t) {} - SchemaStatisticImpl(qpid::framing::Buffer& buffer); - static SchemaStatistic* factory(qpid::framing::Buffer& buffer); - void encode(qpid::framing::Buffer& buffer) const; - void setUnit(const char* val) { unit = val; } - void setDesc(const char* desc) { description = desc; } - const std::string& getName() const { return name; } - Typecode getType() const { return typecode; } - const std::string& getUnit() const { return unit; } - const std::string& getDesc() const { return description; } - void updateHash(SchemaHash& hash) const; - }; - - struct SchemaClassKeyImpl { - const std::string& package; - const std::string& name; - const SchemaHash& hash; - mutable std::string repr; - - // The *Container elements are only used if there isn't an external place to - // store these values. - std::string packageContainer; - std::string nameContainer; - SchemaHash hashContainer; - - SchemaClassKeyImpl(const std::string& package, const std::string& name, const SchemaHash& hash); - SchemaClassKeyImpl(qpid::framing::Buffer& buffer); - static SchemaClassKey* factory(const std::string& package, const std::string& name, const SchemaHash& hash); - static SchemaClassKey* factory(qpid::framing::Buffer& buffer); - - const std::string& getPackageName() const { return package; } - const std::string& getClassName() const { return name; } - const uint8_t* getHash() const { return hash.get(); } - - void encode(qpid::framing::Buffer& buffer) const; - bool operator==(const SchemaClassKeyImpl& other) const; - bool operator<(const SchemaClassKeyImpl& other) const; - const std::string& str() const; - }; - - struct SchemaObjectClassImpl { - std::string package; - std::string name; - mutable SchemaHash hash; - mutable bool hasHash; - std::auto_ptr<SchemaClassKey> classKey; - std::vector<const SchemaProperty*> properties; - std::vector<const SchemaStatistic*> statistics; - std::vector<const SchemaMethod*> methods; - - SchemaObjectClassImpl(const char* p, const char* n) : - package(p), name(n), hasHash(false), classKey(SchemaClassKeyImpl::factory(package, name, hash)) {} - SchemaObjectClassImpl(qpid::framing::Buffer& buffer); - static SchemaObjectClass* factory(qpid::framing::Buffer& buffer); - - void encode(qpid::framing::Buffer& buffer) const; - void addProperty(const SchemaProperty* property); - void addStatistic(const SchemaStatistic* statistic); - void addMethod(const SchemaMethod* method); - - const SchemaClassKey* getClassKey() const; - int getPropertyCount() const { return properties.size(); } - int getStatisticCount() const { return statistics.size(); } - int getMethodCount() const { return methods.size(); } - const SchemaProperty* getProperty(int idx) const; - const SchemaStatistic* getStatistic(int idx) const; - const SchemaMethod* getMethod(int idx) const; - }; - - struct SchemaEventClassImpl { - std::string package; - std::string name; - mutable SchemaHash hash; - mutable bool hasHash; - std::auto_ptr<SchemaClassKey> classKey; - std::string description; - Severity severity; - std::vector<const SchemaArgument*> arguments; - - SchemaEventClassImpl(const char* p, const char* n, Severity sev) : - package(p), name(n), hasHash(false), classKey(SchemaClassKeyImpl::factory(package, name, hash)), severity(sev) {} - SchemaEventClassImpl(qpid::framing::Buffer& buffer); - static SchemaEventClass* factory(qpid::framing::Buffer& buffer); - - void encode(qpid::framing::Buffer& buffer) const; - void addArgument(const SchemaArgument* argument); - void setDesc(const char* desc) { description = desc; } - - const SchemaClassKey* getClassKey() const; - Severity getSeverity() const { return severity; } - int getArgumentCount() const { return arguments.size(); } - const SchemaArgument* getArgument(int idx) const; - }; -} -} - -#endif - diff --git a/qpid/cpp/src/qmf/engine/SequenceManager.cpp b/qpid/cpp/src/qmf/engine/SequenceManager.cpp deleted file mode 100644 index 4a4644a8b9..0000000000 --- a/qpid/cpp/src/qmf/engine/SequenceManager.cpp +++ /dev/null @@ -1,96 +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. - */ - -#include "qmf/engine/SequenceManager.h" - -using namespace std; -using namespace qmf::engine; -using namespace qpid::sys; - -SequenceManager::SequenceManager() : nextSequence(1) {} - -void SequenceManager::setUnsolicitedContext(SequenceContext::Ptr ctx) -{ - unsolicitedContext = ctx; -} - -uint32_t SequenceManager::reserve(SequenceContext::Ptr ctx) -{ - Mutex::ScopedLock _lock(lock); - if (ctx.get() == 0) - ctx = unsolicitedContext; - uint32_t seq = nextSequence; - while (contextMap.find(seq) != contextMap.end()) - seq = seq < 0xFFFFFFFF ? seq + 1 : 1; - nextSequence = seq < 0xFFFFFFFF ? seq + 1 : 1; - contextMap[seq] = ctx; - ctx->reserve(); - return seq; -} - -void SequenceManager::release(uint32_t sequence) -{ - Mutex::ScopedLock _lock(lock); - - if (sequence == 0) { - if (unsolicitedContext.get() != 0) - unsolicitedContext->release(); - return; - } - - map<uint32_t, SequenceContext::Ptr>::iterator iter = contextMap.find(sequence); - if (iter != contextMap.end()) { - if (iter->second != 0) - iter->second->release(); - contextMap.erase(iter); - } -} - -void SequenceManager::releaseAll() -{ - Mutex::ScopedLock _lock(lock); - contextMap.clear(); -} - -void SequenceManager::dispatch(uint8_t opcode, uint32_t sequence, const string& routingKey, qpid::framing::Buffer& buffer) -{ - Mutex::ScopedLock _lock(lock); - bool done; - - if (sequence == 0) { - if (unsolicitedContext.get() != 0) { - done = unsolicitedContext->handleMessage(opcode, sequence, routingKey, buffer); - if (done) - unsolicitedContext->release(); - } - return; - } - - map<uint32_t, SequenceContext::Ptr>::iterator iter = contextMap.find(sequence); - if (iter != contextMap.end()) { - if (iter->second != 0) { - done = iter->second->handleMessage(opcode, sequence, routingKey, buffer); - if (done) { - iter->second->release(); - contextMap.erase(iter); - } - } - } -} - diff --git a/qpid/cpp/src/qmf/engine/SequenceManager.h b/qpid/cpp/src/qmf/engine/SequenceManager.h deleted file mode 100644 index 9e47e38610..0000000000 --- a/qpid/cpp/src/qmf/engine/SequenceManager.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _QmfEngineSequenceManager_ -#define _QmfEngineSequenceManager_ - -/* - * 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 "qpid/sys/Mutex.h" -#include <boost/shared_ptr.hpp> -#include <map> - -namespace qpid { - namespace framing { - class Buffer; - } -} - -namespace qmf { -namespace engine { - - class SequenceContext { - public: - typedef boost::shared_ptr<SequenceContext> Ptr; - SequenceContext() {} - virtual ~SequenceContext() {} - - virtual void reserve() = 0; - virtual bool handleMessage(uint8_t opcode, uint32_t sequence, const std::string& routingKey, qpid::framing::Buffer& buffer) = 0; - virtual void release() = 0; - }; - - class SequenceManager { - public: - SequenceManager(); - - void setUnsolicitedContext(SequenceContext::Ptr ctx); - uint32_t reserve(SequenceContext::Ptr ctx = SequenceContext::Ptr()); - void release(uint32_t sequence); - void releaseAll(); - void dispatch(uint8_t opcode, uint32_t sequence, const std::string& routingKey, qpid::framing::Buffer& buffer); - - private: - mutable qpid::sys::Mutex lock; - uint32_t nextSequence; - SequenceContext::Ptr unsolicitedContext; - std::map<uint32_t, SequenceContext::Ptr> contextMap; - }; - -} -} - -#endif - diff --git a/qpid/cpp/src/qmf/engine/ValueImpl.cpp b/qpid/cpp/src/qmf/engine/ValueImpl.cpp deleted file mode 100644 index f9ebbf5028..0000000000 --- a/qpid/cpp/src/qmf/engine/ValueImpl.cpp +++ /dev/null @@ -1,571 +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. - */ - -#include "qmf/engine/ValueImpl.h" -#include <qpid/framing/FieldValue.h> -#include <qpid/framing/FieldTable.h> -#include <qpid/framing/List.h> -#include <qpid/log/Statement.h> - -using namespace std; -using namespace qmf::engine; -//using qpid::framing::Buffer; -//using qpid::framing::FieldTable; -//using qpid::framing::FieldValue; -using namespace qpid::framing; - -ValueImpl::ValueImpl(Typecode t, Buffer& buf) : typecode(t) -{ - uint64_t first; - uint64_t second; - FieldTable ft; - List fl; - - switch (typecode) { - case TYPE_UINT8 : value.u32 = (uint32_t) buf.getOctet(); break; - case TYPE_UINT16 : value.u32 = (uint32_t) buf.getShort(); break; - case TYPE_UINT32 : value.u32 = (uint32_t) buf.getLong(); break; - case TYPE_UINT64 : value.u64 = buf.getLongLong(); break; - case TYPE_SSTR : buf.getShortString(stringVal); break; - case TYPE_LSTR : buf.getMediumString(stringVal); break; - case TYPE_ABSTIME : value.s64 = buf.getLongLong(); break; - case TYPE_DELTATIME : value.u64 = buf.getLongLong(); break; - case TYPE_BOOL : value.boolVal = (buf.getOctet() != 0); break; - case TYPE_FLOAT : value.floatVal = buf.getFloat(); break; - case TYPE_DOUBLE : value.doubleVal = buf.getDouble(); break; - case TYPE_INT8 : value.s32 = (int32_t) ((int8_t) buf.getOctet()); break; - case TYPE_INT16 : value.s32 = (int32_t) ((int16_t) buf.getShort()); break; - case TYPE_INT32 : value.s32 = (int32_t) buf.getLong(); break; - case TYPE_INT64 : value.s64 = buf.getLongLong(); break; - case TYPE_UUID : buf.getBin128(value.uuidVal); break; - case TYPE_REF: - first = buf.getLongLong(); - second = buf.getLongLong(); - refVal.impl->setValue(first, second); - break; - - case TYPE_MAP: - ft.decode(buf); - initMap(ft); - break; - - case TYPE_LIST: - fl.decode(buf); - initList(fl); - break; - - case TYPE_ARRAY: - case TYPE_OBJECT: - default: - break; - } -} - -ValueImpl::ValueImpl(Typecode t, Typecode at) : typecode(t), valid(false), arrayTypecode(at) -{ -} - -ValueImpl::ValueImpl(Typecode t) : typecode(t) -{ - ::memset(&value, 0, sizeof(value)); -} - -Value* ValueImpl::factory(Typecode t, Buffer& b) -{ - ValueImpl* impl(new ValueImpl(t, b)); - return new Value(impl); -} - -Value* ValueImpl::factory(Typecode t) -{ - ValueImpl* impl(new ValueImpl(t)); - return new Value(impl); -} - -ValueImpl::~ValueImpl() -{ -} - -void ValueImpl::initMap(const FieldTable& ft) -{ - for (FieldTable::ValueMap::const_iterator iter = ft.begin(); - iter != ft.end(); iter++) { - const string& name(iter->first); - const FieldValue& fvalue(*iter->second); - uint8_t amqType = fvalue.getType(); - - if (amqType == 0x32) { - Value* subval(new Value(TYPE_UINT64)); - subval->setUint64(fvalue.get<int64_t>()); - insert(name.c_str(), subval); - } else if ((amqType & 0xCF) == 0x02) { - Value* subval(new Value(TYPE_UINT32)); - switch (amqType) { - case 0x02 : subval->setUint(fvalue.get<int>()); break; - case 0x12 : subval->setUint(fvalue.get<int>()); break; - case 0x22 : subval->setUint(fvalue.get<int>()); break; - } - insert(name.c_str(), subval); - } else if (amqType == 0x31) { // int64 - Value* subval(new Value(TYPE_INT64)); - subval->setInt64(fvalue.get<int64_t>()); - insert(name.c_str(), subval); - } else if ((amqType & 0xCF) == 0x01) { // 0x01:int8, 0x11:int16, 0x21:int21 - Value* subval(new Value(TYPE_INT32)); - subval->setInt((int32_t)fvalue.get<int>()); - insert(name.c_str(), subval); - } else if (amqType == 0x85 || amqType == 0x95) { - Value* subval(new Value(TYPE_LSTR)); - subval->setString(fvalue.get<string>().c_str()); - insert(name.c_str(), subval); - } else if (amqType == 0x23 || amqType == 0x33) { - Value* subval(new Value(TYPE_DOUBLE)); - subval->setDouble(fvalue.get<double>()); - insert(name.c_str(), subval); - } else if (amqType == 0xa8) { - FieldTable subFt; - bool valid = qpid::framing::getEncodedValue<FieldTable>(iter->second, subFt); - if (valid) { - Value* subval(new Value(TYPE_MAP)); - subval->impl->initMap(subFt); - insert(name.c_str(), subval); - } - } else if (amqType == 0xa9) { - List subList; - bool valid = qpid::framing::getEncodedValue<List>(iter->second, subList); - if (valid) { - Value* subval(new Value(TYPE_LIST)); - subval->impl->initList(subList); - insert(name.c_str(), subval); - } - } else if (amqType == 0x08) { - Value* subval(new Value(TYPE_BOOL)); - subval->setBool(fvalue.get<int>() ? true : false); - insert(name.c_str(), subval); - } else { - QPID_LOG(error, "Unable to decode unsupported AMQP typecode=" << amqType << " map index=" << name); - } - } -} - -void ValueImpl::mapToFieldTable(FieldTable& ft) const -{ - FieldTable subFt; - - for (map<string, Value>::const_iterator iter = mapVal.begin(); - iter != mapVal.end(); iter++) { - const string& name(iter->first); - const Value& subval(iter->second); - - switch (subval.getType()) { - case TYPE_UINT8: - case TYPE_UINT16: - case TYPE_UINT32: - ft.setUInt64(name, (uint64_t) subval.asUint()); - break; - case TYPE_UINT64: - case TYPE_DELTATIME: - ft.setUInt64(name, subval.asUint64()); - break; - case TYPE_SSTR: - case TYPE_LSTR: - ft.setString(name, subval.asString()); - break; - case TYPE_INT64: - case TYPE_ABSTIME: - ft.setInt64(name, subval.asInt64()); - break; - case TYPE_BOOL: - ft.set(name, FieldTable::ValuePtr(new BoolValue(subval.asBool()))); - break; - case TYPE_FLOAT: - ft.setFloat(name, subval.asFloat()); - break; - case TYPE_DOUBLE: - ft.setDouble(name, subval.asDouble()); - break; - case TYPE_INT8: - case TYPE_INT16: - case TYPE_INT32: - ft.setInt(name, subval.asInt()); - break; - case TYPE_MAP: - subFt.clear(); - subval.impl->mapToFieldTable(subFt); - ft.setTable(name, subFt); - break; - case TYPE_LIST: - { - List subList; - subval.impl->listToFramingList(subList); - ft.set(name, - ::qpid::framing::FieldTable::ValuePtr( - new ListValue( - subList))); - } break; - case TYPE_ARRAY: - case TYPE_OBJECT: - case TYPE_UUID: - case TYPE_REF: - default: - break; - } - } - } - - -void ValueImpl::initList(const List& fl) -{ - for (List::const_iterator iter = fl.begin(); - iter != fl.end(); iter++) { - const FieldValue& fvalue(*iter->get()); - uint8_t amqType = fvalue.getType(); - - if (amqType == 0x32) { - Value* subval(new Value(TYPE_UINT64)); - subval->setUint64(fvalue.get<int64_t>()); - appendToList(subval); - } else if ((amqType & 0xCF) == 0x02) { - Value* subval(new Value(TYPE_UINT32)); - switch (amqType) { - case 0x02 : subval->setUint(fvalue.get<int>()); break; // uint8 - case 0x12 : subval->setUint(fvalue.get<int>()); break; // uint16 - case 0x22 : subval->setUint(fvalue.get<int>()); break; // uint32 - } - appendToList(subval); - } else if (amqType == 0x31) { // int64 - Value* subval(new Value(TYPE_INT64)); - subval->setInt64(fvalue.get<int64_t>()); - appendToList(subval); - } else if ((amqType & 0xCF) == 0x01) { // 0x01:int8, 0x11:int16, 0x21:int32 - Value* subval(new Value(TYPE_INT32)); - subval->setInt((int32_t)fvalue.get<int>()); - appendToList(subval); - } else if (amqType == 0x85 || amqType == 0x95) { - Value* subval(new Value(TYPE_LSTR)); - subval->setString(fvalue.get<string>().c_str()); - appendToList(subval); - } else if (amqType == 0x23 || amqType == 0x33) { - Value* subval(new Value(TYPE_DOUBLE)); - subval->setDouble(fvalue.get<double>()); - appendToList(subval); - } else if (amqType == 0xa8) { - FieldTable subFt; - bool valid = qpid::framing::getEncodedValue<FieldTable>(*iter, subFt); - if (valid) { - Value* subval(new Value(TYPE_MAP)); - subval->impl->initMap(subFt); - appendToList(subval); - } - } else if (amqType == 0xa9) { - List subList; - bool valid = qpid::framing::getEncodedValue<List>(*iter, subList); - if (valid) { - Value *subVal(new Value(TYPE_LIST)); - subVal->impl->initList(subList); - appendToList(subVal); - } - } else if (amqType == 0x08) { - Value* subval(new Value(TYPE_BOOL)); - subval->setBool(fvalue.get<int>() ? true : false); - appendToList(subval); - } else { - QPID_LOG(error, "Unable to decode unsupported AMQP typecode =" << amqType); - } - } -} - -void ValueImpl::listToFramingList(List& fl) const -{ - for (vector<Value>::const_iterator iter = vectorVal.begin(); - iter != vectorVal.end(); iter++) { - const Value& subval(*iter); - - switch (subval.getType()) { - case TYPE_UINT8: - case TYPE_UINT16: - case TYPE_UINT32: - fl.push_back(List::ValuePtr(new Unsigned64Value((uint64_t) subval.asUint()))); - break; - case TYPE_UINT64: - case TYPE_DELTATIME: - fl.push_back(List::ValuePtr(new Unsigned64Value(subval.asUint64()))); - break; - case TYPE_SSTR: - case TYPE_LSTR: - fl.push_back(List::ValuePtr(new Str16Value(subval.asString()))); - break; - case TYPE_INT64: - case TYPE_ABSTIME: - fl.push_back(List::ValuePtr(new Integer64Value(subval.asInt64()))); - break; - case TYPE_BOOL: - fl.push_back(List::ValuePtr(new BoolValue(subval.asBool() ? 1 : 0))); - break; - case TYPE_FLOAT: - fl.push_back(List::ValuePtr(new FloatValue(subval.asFloat()))); - break; - case TYPE_DOUBLE: - fl.push_back(List::ValuePtr(new DoubleValue(subval.asDouble()))); - break; - case TYPE_INT8: - case TYPE_INT16: - case TYPE_INT32: - fl.push_back(List::ValuePtr(new IntegerValue(subval.asInt()))); - break; - case TYPE_MAP: - { - FieldTable subFt; - subval.impl->mapToFieldTable(subFt); - fl.push_back(List::ValuePtr(new FieldTableValue(subFt))); - - } break; - case TYPE_LIST: - { - List subList; - subval.impl->listToFramingList(subList); - fl.push_back(List::ValuePtr(new ListValue(subList))); - } break; - - case TYPE_ARRAY: - case TYPE_OBJECT: - case TYPE_UUID: - case TYPE_REF: - default: - break; - } - } - } - - - -void ValueImpl::encode(Buffer& buf) const -{ - FieldTable ft; - List fl; - - switch (typecode) { - case TYPE_UINT8 : buf.putOctet((uint8_t) value.u32); break; - case TYPE_UINT16 : buf.putShort((uint16_t) value.u32); break; - case TYPE_UINT32 : buf.putLong(value.u32); break; - case TYPE_UINT64 : buf.putLongLong(value.u64); break; - case TYPE_SSTR : buf.putShortString(stringVal); break; - case TYPE_LSTR : buf.putMediumString(stringVal); break; - case TYPE_ABSTIME : buf.putLongLong(value.s64); break; - case TYPE_DELTATIME : buf.putLongLong(value.u64); break; - case TYPE_BOOL : buf.putOctet(value.boolVal ? 1 : 0); break; - case TYPE_FLOAT : buf.putFloat(value.floatVal); break; - case TYPE_DOUBLE : buf.putDouble(value.doubleVal); break; - case TYPE_INT8 : buf.putOctet((uint8_t) value.s32); break; - case TYPE_INT16 : buf.putShort((uint16_t) value.s32); break; - case TYPE_INT32 : buf.putLong(value.s32); break; - case TYPE_INT64 : buf.putLongLong(value.s64); break; - case TYPE_UUID : buf.putBin128(value.uuidVal); break; - case TYPE_REF : refVal.impl->encode(buf); break; - case TYPE_MAP: - mapToFieldTable(ft); - ft.encode(buf); - break; - case TYPE_LIST: - listToFramingList(fl); - fl.encode(buf); - break; - - case TYPE_ARRAY: - case TYPE_OBJECT: - default: - break; - } -} - -uint32_t ValueImpl::encodedSize() const -{ - FieldTable ft; - List fl; - - switch (typecode) { - case TYPE_UINT8 : - case TYPE_BOOL : - case TYPE_INT8 : return 1; - - case TYPE_UINT16 : - case TYPE_INT16 : return 2; - - case TYPE_UINT32 : - case TYPE_INT32 : - case TYPE_FLOAT : return 4; - - case TYPE_UINT64 : - case TYPE_INT64 : - case TYPE_DOUBLE : - case TYPE_ABSTIME : - case TYPE_DELTATIME : return 8; - - case TYPE_UUID : - case TYPE_REF : return 16; - - case TYPE_SSTR : return 1 + stringVal.size(); - case TYPE_LSTR : return 2 + stringVal.size(); - case TYPE_MAP: - mapToFieldTable(ft); - return ft.encodedSize(); - - case TYPE_LIST: - listToFramingList(fl); - return fl.encodedSize(); - - case TYPE_ARRAY: - case TYPE_OBJECT: - default: - break; - } - - return 0; -} - -bool ValueImpl::keyInMap(const char* key) const -{ - return typecode == TYPE_MAP && mapVal.count(key) > 0; -} - -Value* ValueImpl::byKey(const char* key) -{ - if (keyInMap(key)) { - map<string, Value>::iterator iter = mapVal.find(key); - if (iter != mapVal.end()) - return &iter->second; - } - return 0; -} - -const Value* ValueImpl::byKey(const char* key) const -{ - if (keyInMap(key)) { - map<string, Value>::const_iterator iter = mapVal.find(key); - if (iter != mapVal.end()) - return &iter->second; - } - return 0; -} - -void ValueImpl::deleteKey(const char* key) -{ - mapVal.erase(key); -} - -void ValueImpl::insert(const char* key, Value* val) -{ - pair<string, Value> entry(key, *val); - mapVal.insert(entry); -} - -const char* ValueImpl::key(uint32_t idx) const -{ - map<string, Value>::const_iterator iter = mapVal.begin(); - for (uint32_t i = 0; i < idx; i++) { - if (iter == mapVal.end()) - break; - iter++; - } - - if (iter == mapVal.end()) - return 0; - else - return iter->first.c_str(); -} - -Value* ValueImpl::arrayItem(uint32_t) -{ - return 0; -} - -void ValueImpl::appendToArray(Value*) -{ -} - -void ValueImpl::deleteArrayItem(uint32_t) -{ -} - - -//================================================================== -// Wrappers -//================================================================== - -Value::Value(const Value& from) : impl(new ValueImpl(*(from.impl))) {} -Value::Value(Typecode t, Typecode at) : impl(new ValueImpl(t, at)) {} -Value::Value(ValueImpl* i) : impl(i) {} -Value::~Value() { delete impl;} - -Typecode Value::getType() const { return impl->getType(); } -bool Value::isNull() const { return impl->isNull(); } -void Value::setNull() { impl->setNull(); } -bool Value::isObjectId() const { return impl->isObjectId(); } -const ObjectId& Value::asObjectId() const { return impl->asObjectId(); } -void Value::setObjectId(const ObjectId& oid) { impl->setObjectId(oid); } -bool Value::isUint() const { return impl->isUint(); } -uint32_t Value::asUint() const { return impl->asUint(); } -void Value::setUint(uint32_t val) { impl->setUint(val); } -bool Value::isInt() const { return impl->isInt(); } -int32_t Value::asInt() const { return impl->asInt(); } -void Value::setInt(int32_t val) { impl->setInt(val); } -bool Value::isUint64() const { return impl->isUint64(); } -uint64_t Value::asUint64() const { return impl->asUint64(); } -void Value::setUint64(uint64_t val) { impl->setUint64(val); } -bool Value::isInt64() const { return impl->isInt64(); } -int64_t Value::asInt64() const { return impl->asInt64(); } -void Value::setInt64(int64_t val) { impl->setInt64(val); } -bool Value::isString() const { return impl->isString(); } -const char* Value::asString() const { return impl->asString(); } -void Value::setString(const char* val) { impl->setString(val); } -bool Value::isBool() const { return impl->isBool(); } -bool Value::asBool() const { return impl->asBool(); } -void Value::setBool(bool val) { impl->setBool(val); } -bool Value::isFloat() const { return impl->isFloat(); } -float Value::asFloat() const { return impl->asFloat(); } -void Value::setFloat(float val) { impl->setFloat(val); } -bool Value::isDouble() const { return impl->isDouble(); } -double Value::asDouble() const { return impl->asDouble(); } -void Value::setDouble(double val) { impl->setDouble(val); } -bool Value::isUuid() const { return impl->isUuid(); } -const uint8_t* Value::asUuid() const { return impl->asUuid(); } -void Value::setUuid(const uint8_t* val) { impl->setUuid(val); } -bool Value::isObject() const { return impl->isObject(); } -const Object* Value::asObject() const { return impl->asObject(); } -void Value::setObject(Object* val) { impl->setObject(val); } -bool Value::isMap() const { return impl->isMap(); } -bool Value::keyInMap(const char* key) const { return impl->keyInMap(key); } -Value* Value::byKey(const char* key) { return impl->byKey(key); } -const Value* Value::byKey(const char* key) const { return impl->byKey(key); } -void Value::deleteKey(const char* key) { impl->deleteKey(key); } -void Value::insert(const char* key, Value* val) { impl->insert(key, val); } -uint32_t Value::keyCount() const { return impl->keyCount(); } -const char* Value::key(uint32_t idx) const { return impl->key(idx); } -bool Value::isList() const { return impl->isList(); } -uint32_t Value::listItemCount() const { return impl->listItemCount(); } -Value* Value::listItem(uint32_t idx) { return impl->listItem(idx); } -void Value::appendToList(Value* val) { impl->appendToList(val); } -void Value::deleteListItem(uint32_t idx) { impl->deleteListItem(idx); } -bool Value::isArray() const { return impl->isArray(); } -Typecode Value::arrayType() const { return impl->arrayType(); } -uint32_t Value::arrayItemCount() const { return impl->arrayItemCount(); } -Value* Value::arrayItem(uint32_t idx) { return impl->arrayItem(idx); } -void Value::appendToArray(Value* val) { impl->appendToArray(val); } -void Value::deleteArrayItem(uint32_t idx) { impl->deleteArrayItem(idx); } - diff --git a/qpid/cpp/src/qmf/engine/ValueImpl.h b/qpid/cpp/src/qmf/engine/ValueImpl.h deleted file mode 100644 index 8de8c5329f..0000000000 --- a/qpid/cpp/src/qmf/engine/ValueImpl.h +++ /dev/null @@ -1,166 +0,0 @@ -#ifndef _QmfEngineValueImpl_ -#define _QmfEngineValueImpl_ - -/* - * 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 <qmf/engine/Value.h> -#include <qmf/engine/ObjectIdImpl.h> -#include <qmf/engine/Object.h> -#include <qpid/framing/Buffer.h> -#include <string> -#include <string.h> -#include <map> -#include <vector> -#include <boost/shared_ptr.hpp> - -namespace qpid { -namespace framing { - class FieldTable; - class List; -} -} - -namespace qmf { -namespace engine { - - // TODO: set valid flag on all value settors - // TODO: add a modified flag and accessors - - struct ValueImpl { - const Typecode typecode; - bool valid; - - ObjectId refVal; - std::string stringVal; - std::auto_ptr<Object> objectVal; - std::map<std::string, Value> mapVal; - std::vector<Value> vectorVal; - Typecode arrayTypecode; - - union { - uint32_t u32; - uint64_t u64; - int32_t s32; - int64_t s64; - bool boolVal; - float floatVal; - double doubleVal; - uint8_t uuidVal[16]; - } value; - - ValueImpl(const ValueImpl& from) : - typecode(from.typecode), valid(from.valid), refVal(from.refVal), stringVal(from.stringVal), - objectVal(from.objectVal.get() ? new Object(*(from.objectVal)) : 0), - mapVal(from.mapVal), vectorVal(from.vectorVal), arrayTypecode(from.arrayTypecode), - value(from.value) {} - - ValueImpl(Typecode t, Typecode at); - ValueImpl(Typecode t, qpid::framing::Buffer& b); - ValueImpl(Typecode t); - static Value* factory(Typecode t, qpid::framing::Buffer& b); - static Value* factory(Typecode t); - ~ValueImpl(); - - void encode(qpid::framing::Buffer& b) const; - uint32_t encodedSize() const; - - Typecode getType() const { return typecode; } - bool isNull() const { return !valid; } - void setNull() { valid = false; } - - bool isObjectId() const { return typecode == TYPE_REF; } - const ObjectId& asObjectId() const { return refVal; } - void setObjectId(const ObjectId& o) { refVal = o; } // TODO - - bool isUint() const { return typecode >= TYPE_UINT8 && typecode <= TYPE_UINT32; } - uint32_t asUint() const { return value.u32; } - void setUint(uint32_t val) { value.u32 = val; } - - bool isInt() const { return typecode >= TYPE_INT8 && typecode <= TYPE_INT32; } - int32_t asInt() const { return value.s32; } - void setInt(int32_t val) { value.s32 = val; } - - bool isUint64() const { return typecode == TYPE_UINT64 || typecode == TYPE_DELTATIME; } - uint64_t asUint64() const { return value.u64; } - void setUint64(uint64_t val) { value.u64 = val; } - - bool isInt64() const { return typecode == TYPE_INT64 || typecode == TYPE_ABSTIME; } - int64_t asInt64() const { return value.s64; } - void setInt64(int64_t val) { value.s64 = val; } - - bool isString() const { return typecode == TYPE_SSTR || typecode == TYPE_LSTR; } - const char* asString() const { return stringVal.c_str(); } - void setString(const char* val) { stringVal = val; } - - bool isBool() const { return typecode == TYPE_BOOL; } - bool asBool() const { return value.boolVal; } - void setBool(bool val) { value.boolVal = val; } - - bool isFloat() const { return typecode == TYPE_FLOAT; } - float asFloat() const { return value.floatVal; } - void setFloat(float val) { value.floatVal = val; } - - bool isDouble() const { return typecode == TYPE_DOUBLE; } - double asDouble() const { return value.doubleVal; } - void setDouble(double val) { value.doubleVal = val; } - - bool isUuid() const { return typecode == TYPE_UUID; } - const uint8_t* asUuid() const { return value.uuidVal; } - void setUuid(const uint8_t* val) { ::memcpy(value.uuidVal, val, 16); } - - bool isObject() const { return typecode == TYPE_OBJECT; } - Object* asObject() const { return objectVal.get(); } - void setObject(Object* val) { objectVal.reset(val); } - - bool isMap() const { return typecode == TYPE_MAP; } - bool keyInMap(const char* key) const; - Value* byKey(const char* key); - const Value* byKey(const char* key) const; - void deleteKey(const char* key); - void insert(const char* key, Value* val); - uint32_t keyCount() const { return mapVal.size(); } - const char* key(uint32_t idx) const; - - bool isList() const { return typecode == TYPE_LIST; } - uint32_t listItemCount() const { return vectorVal.size(); } - Value* listItem(uint32_t idx) { return idx < listItemCount() ? &vectorVal[idx] : 0; } - const Value* listItem(uint32_t idx) const { return idx < listItemCount() ? &vectorVal[idx] : 0; } - void appendToList(Value* val) { vectorVal.push_back(*val); } - void deleteListItem(uint32_t idx) { if (idx < listItemCount()) vectorVal.erase(vectorVal.begin()+idx); } - - bool isArray() const { return typecode == TYPE_ARRAY; } - Typecode arrayType() const { return arrayTypecode; } - uint32_t arrayItemCount() const { return 0; } - Value* arrayItem(uint32_t idx); - void appendToArray(Value* val); - void deleteArrayItem(uint32_t idx); - - private: - void mapToFieldTable(qpid::framing::FieldTable& ft) const; - void initMap(const qpid::framing::FieldTable& ft); - - void listToFramingList(qpid::framing::List& fl) const; - void initList(const qpid::framing::List& fl); - }; -} -} - -#endif - diff --git a/qpid/cpp/src/qmfc.mk b/qpid/cpp/src/qmfc.mk deleted file mode 100644 index e445a538a1..0000000000 --- a/qpid/cpp/src/qmfc.mk +++ /dev/null @@ -1,57 +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. -# - -# -# qmf console library makefile fragment, to be included in Makefile.am -# -lib_LTLIBRARIES += libqmfconsole.la - -# Public header files. -nobase_include_HEADERS += \ - ../include/qpid/console/Agent.h \ - ../include/qpid/console/Broker.h \ - ../include/qpid/console/ClassKey.h \ - ../include/qpid/console/ConsoleImportExport.h \ - ../include/qpid/console/ConsoleListener.h \ - ../include/qpid/console/Event.h \ - ../include/qpid/console/Object.h \ - ../include/qpid/console/ObjectId.h \ - ../include/qpid/console/Package.h \ - ../include/qpid/console/Schema.h \ - ../include/qpid/console/SequenceManager.h \ - ../include/qpid/console/SessionManager.h \ - ../include/qpid/console/Value.h - -libqmfconsole_la_SOURCES = \ - qpid/console/Agent.cpp \ - qpid/console/Broker.cpp \ - qpid/console/ClassKey.cpp \ - qpid/console/Event.cpp \ - qpid/console/Object.cpp \ - qpid/console/ObjectId.cpp \ - qpid/console/Package.cpp \ - qpid/console/Schema.cpp \ - qpid/console/SequenceManager.cpp \ - qpid/console/SessionManager.cpp \ - qpid/console/Value.cpp - -libqmfconsole_la_LIBADD = libqpidclient.la - -QMFCONSOLE_VERSION_INFO = 2:0:0 -libqmfconsole_la_LDFLAGS = -version-info $(QMFCONSOLE_VERSION_INFO) diff --git a/qpid/cpp/src/qpid.linkmap b/qpid/cpp/src/qpid.linkmap new file mode 100644 index 0000000000..4556985b1b --- /dev/null +++ b/qpid/cpp/src/qpid.linkmap @@ -0,0 +1,10 @@ +{ + global: + extern "C++" { + typeinfo*qpid::*; + vtable*qpid::*; + qpid::*; + qpid::*operator*qpid::*; + }; + local: *; +}; diff --git a/qpid/cpp/include/qpid/Address.h b/qpid/cpp/src/qpid/Address.h index edb405db92..fe43f3847d 100755 --- a/qpid/cpp/include/qpid/Address.h +++ b/qpid/cpp/src/qpid/Address.h @@ -33,8 +33,8 @@ namespace client { struct ConnectionSettings; } */ struct Address { public: - static const std::string TCP; // Default TCP protocol tag. - static const uint16_t AMQP_PORT=5672; // Default AMQP port. + QPID_COMMON_EXTERN static const std::string TCP; // Default TCP protocol tag. + QPID_COMMON_EXTERN static const uint16_t AMQP_PORT=5672; // Default AMQP port. QPID_COMMON_INLINE_EXTERN explicit Address( const std::string& protocol_=std::string(), diff --git a/qpid/cpp/include/qpid/CommonImportExport.h b/qpid/cpp/src/qpid/CommonImportExport.h index dd2b900b73..dd2b900b73 100644 --- a/qpid/cpp/include/qpid/CommonImportExport.h +++ b/qpid/cpp/src/qpid/CommonImportExport.h diff --git a/qpid/cpp/include/qpid/Exception.h b/qpid/cpp/src/qpid/Exception.h index cbd175214d..cbd175214d 100644 --- a/qpid/cpp/include/qpid/Exception.h +++ b/qpid/cpp/src/qpid/Exception.h diff --git a/qpid/cpp/include/qpid/InlineAllocator.h b/qpid/cpp/src/qpid/InlineAllocator.h index 2502545dcb..2502545dcb 100644 --- a/qpid/cpp/include/qpid/InlineAllocator.h +++ b/qpid/cpp/src/qpid/InlineAllocator.h diff --git a/qpid/cpp/include/qpid/InlineVector.h b/qpid/cpp/src/qpid/InlineVector.h index c55db295f3..c55db295f3 100644 --- a/qpid/cpp/include/qpid/InlineVector.h +++ b/qpid/cpp/src/qpid/InlineVector.h diff --git a/qpid/cpp/include/qpid/Msg.h b/qpid/cpp/src/qpid/Msg.h index 5f0b11bc60..5f0b11bc60 100644 --- a/qpid/cpp/include/qpid/Msg.h +++ b/qpid/cpp/src/qpid/Msg.h diff --git a/qpid/cpp/include/qpid/console/SequenceManager.h b/qpid/cpp/src/qpid/NullSaslClient.cpp index ea0ccf3f77..d1f2706f50 100644 --- a/qpid/cpp/include/qpid/console/SequenceManager.h +++ b/qpid/cpp/src/qpid/NullSaslClient.cpp @@ -18,37 +18,37 @@ * under the License. * */ -#ifndef _QPID_CONSOLE_SEQUENCEMANAGER_H_ -#define _QPID_CONSOLE_SEQUENCEMANAGER_H_ - -#include "qpid/console/ConsoleImportExport.h" -#include "qpid/sys/Mutex.h" -#include <map> -#include <string> -#include <set> +#include "NullSaslClient.h" +#include "qpid/sys/SecurityLayer.h" +#include "Exception.h" namespace qpid { -namespace console { - - /** - * - * \ingroup qpidconsoleapi - */ - class SequenceManager { - public: - typedef std::set<uint32_t> set; - - SequenceManager() : sequence(0) {} - QPID_CONSOLE_EXTERN uint32_t reserve(const std::string& context = ""); - QPID_CONSOLE_EXTERN std::string release(uint32_t seq); +namespace { +const std::string ANONYMOUS("ANONYMOUS"); +} - private: - sys::Mutex lock; - uint32_t sequence; - std::map<uint32_t, std::string> pending; - }; +bool NullSaslClient::start(const std::string& mechanisms, std::string&, + const qpid::sys::SecuritySettings*) +{ + if (mechanisms.find(ANONYMOUS) == std::string::npos) { + throw qpid::Exception("No suitable mechanism!"); + } + return false; } +std::string NullSaslClient::step(const std::string&) +{ + return std::string(); } - - -#endif +std::string NullSaslClient::getMechanism() +{ + return ANONYMOUS; +} +std::string NullSaslClient::getUserId() +{ + return ANONYMOUS; +} +std::auto_ptr<qpid::sys::SecurityLayer> NullSaslClient::getSecurityLayer(uint16_t) +{ + return std::auto_ptr<qpid::sys::SecurityLayer>(); +} +} // namespace qpid diff --git a/qpid/cpp/src/qpid/NullSaslClient.h b/qpid/cpp/src/qpid/NullSaslClient.h new file mode 100644 index 0000000000..b0a63a8ecb --- /dev/null +++ b/qpid/cpp/src/qpid/NullSaslClient.h @@ -0,0 +1,41 @@ +#ifndef QPID_NULLSASLCLIENT_H +#define QPID_NULLSASLCLIENT_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 "Sasl.h" + +namespace qpid { + +class NullSaslClient : public Sasl +{ + public: + bool start(const std::string& mechanisms, std::string& response, + const qpid::sys::SecuritySettings* externalSecuritySettings = 0); + std::string step(const std::string& challenge); + std::string getMechanism(); + std::string getUserId(); + std::auto_ptr<qpid::sys::SecurityLayer> getSecurityLayer(uint16_t maxFrameSize); + private: +}; +} // namespace qpid + +#endif /*!QPID_NULLSASLCLIENT_H*/ diff --git a/qpid/cpp/src/qpid/NullSaslServer.h b/qpid/cpp/src/qpid/NullSaslServer.h index 810defe574..22a1b293a3 100644 --- a/qpid/cpp/src/qpid/NullSaslServer.h +++ b/qpid/cpp/src/qpid/NullSaslServer.h @@ -21,6 +21,7 @@ * under the License. * */ +#include "qpid/CommonImportExport.h" #include "qpid/SaslServer.h" namespace qpid { @@ -34,7 +35,7 @@ namespace qpid { class NullSaslServer : public SaslServer { public: - NullSaslServer(const std::string& realm); + QPID_COMMON_EXTERN NullSaslServer(const std::string& realm); Status start(const std::string& mechanism, const std::string* response, std::string& challenge); Status step(const std::string* response, std::string& challenge); std::string getMechanisms(); diff --git a/qpid/cpp/include/qpid/Options.h b/qpid/cpp/src/qpid/Options.h index 6c908518b8..6c908518b8 100644 --- a/qpid/cpp/include/qpid/Options.h +++ b/qpid/cpp/src/qpid/Options.h diff --git a/qpid/cpp/include/qpid/RangeSet.h b/qpid/cpp/src/qpid/RangeSet.h index ef0ad032da..ef0ad032da 100644 --- a/qpid/cpp/include/qpid/RangeSet.h +++ b/qpid/cpp/src/qpid/RangeSet.h diff --git a/qpid/cpp/src/qpid/Sasl.h b/qpid/cpp/src/qpid/Sasl.h index efda92d718..1164fb5ec3 100644 --- a/qpid/cpp/src/qpid/Sasl.h +++ b/qpid/cpp/src/qpid/Sasl.h @@ -24,6 +24,7 @@ #include <memory> #include <string> +#include "qpid/CommonImportExport.h" #include "qpid/sys/IntegerTypes.h" namespace qpid { @@ -53,7 +54,7 @@ class Sasl virtual std::string getMechanism() = 0; virtual std::string getUserId() = 0; virtual std::auto_ptr<qpid::sys::SecurityLayer> getSecurityLayer(uint16_t maxFrameSize) = 0; - virtual ~Sasl() {} + QPID_COMMON_EXTERN virtual ~Sasl() {} }; } // namespace qpid diff --git a/qpid/cpp/src/qpid/SaslFactory.cpp b/qpid/cpp/src/qpid/SaslFactory.cpp index 97e1d6e18a..bd771fc920 100644 --- a/qpid/cpp/src/qpid/SaslFactory.cpp +++ b/qpid/cpp/src/qpid/SaslFactory.cpp @@ -20,6 +20,7 @@ */ #include "qpid/SaslFactory.h" #include "qpid/SaslServer.h" +#include "qpid/NullSaslClient.h" #include "qpid/NullSaslServer.h" #include <map> #include <string.h> @@ -48,7 +49,8 @@ SaslFactory& SaslFactory::getInstance() std::auto_ptr<Sasl> SaslFactory::create( const std::string &, const std::string &, const std::string &, const std::string &, int, int, bool ) { - return std::auto_ptr<Sasl>(); + std::auto_ptr<Sasl> client(new NullSaslClient); + return client; } std::auto_ptr<SaslServer> SaslFactory::createServer(const std::string& realm, bool /*encryptionRequired*/, const qpid::sys::SecuritySettings&) diff --git a/qpid/cpp/src/qpid/SaslFactory.h b/qpid/cpp/src/qpid/SaslFactory.h index da7e892f1d..5d99bd2e51 100644 --- a/qpid/cpp/src/qpid/SaslFactory.h +++ b/qpid/cpp/src/qpid/SaslFactory.h @@ -21,6 +21,7 @@ * under the License. * */ +#include "qpid/CommonImportExport.h" #include "qpid/Sasl.h" #include "qpid/sys/Mutex.h" #include <memory> diff --git a/qpid/cpp/src/qpid/SaslServer.h b/qpid/cpp/src/qpid/SaslServer.h index a707a468eb..88909c69a9 100644 --- a/qpid/cpp/src/qpid/SaslServer.h +++ b/qpid/cpp/src/qpid/SaslServer.h @@ -35,7 +35,7 @@ class SaslServer { public: typedef enum {OK, FAIL, CHALLENGE} Status; - virtual ~SaslServer() {} + QPID_COMMON_EXTERN virtual ~SaslServer() {} virtual Status start(const std::string& mechanism, const std::string* response, std::string& challenge) = 0; virtual Status step(const std::string* response, std::string& challenge) = 0; virtual std::string getMechanisms() = 0; diff --git a/qpid/cpp/include/qpid/SessionId.h b/qpid/cpp/src/qpid/SessionId.h index e18b360999..e18b360999 100644 --- a/qpid/cpp/include/qpid/SessionId.h +++ b/qpid/cpp/src/qpid/SessionId.h diff --git a/qpid/cpp/include/qpid/Url.h b/qpid/cpp/src/qpid/Url.h index f9ed87c24b..f9ed87c24b 100644 --- a/qpid/cpp/include/qpid/Url.h +++ b/qpid/cpp/src/qpid/Url.h diff --git a/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp b/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp index 3d703066b4..7a5d0ab53d 100644 --- a/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp +++ b/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp @@ -102,10 +102,12 @@ bool ConnectionCounter::countConnectionLH( if (eRef != theMap.end()) { count = (uint16_t)(*eRef).second + 1; (*eRef).second = count; - result = (enforceLimit ? count <= theLimit : true); } else { theMap[theName] = count = 1; } + if (enforceLimit) { + result = count <= theLimit; + } if (emitLog) { QPID_LOG(trace, "ACL ConnectionApprover user=" << theName << " limit=" << theLimit diff --git a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp deleted file mode 100644 index a48789973a..0000000000 --- a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp +++ /dev/null @@ -1,1434 +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. -// - -#include "qpid/management/Manageable.h" -#include "qpid/management/ManagementObject.h" -#include "qpid/log/Statement.h" -#include "qpid/agent/ManagementAgentImpl.h" -#include "qpid/amqp_0_10/Codecs.h" -#include <list> -#include <string.h> -#include <stdlib.h> -#include <sys/types.h> -#include <iostream> -#include <fstream> -#include <boost/lexical_cast.hpp> - -namespace qpid { -namespace management { - -using namespace qpid::client; -using namespace qpid::framing; -using namespace qpid::sys; -using namespace std; -using std::stringstream; -using std::ofstream; -using std::ifstream; -using std::string; -using std::endl; -using qpid::types::Variant; -using qpid::amqp_0_10::MapCodec; -using qpid::amqp_0_10::ListCodec; - -namespace { - qpid::sys::Mutex lock; - bool disabled = false; - ManagementAgent* agent = 0; - int refCount = 0; - - const string defaultVendorName("vendor"); - const string defaultProductName("product"); - - // Create a valid binding key substring by - // replacing all '.' chars with '_' - const string keyifyNameStr(const string& name) - { - string n2 = name; - - size_t pos = n2.find('.'); - while (pos != n2.npos) { - n2.replace(pos, 1, "_"); - pos = n2.find('.', pos); - } - return n2; - } -} - -ManagementAgent::Singleton::Singleton(bool disableManagement) -{ - sys::Mutex::ScopedLock _lock(lock); - if (disableManagement && !disabled) { - disabled = true; - assert(refCount == 0); // can't disable after agent has been allocated - } - if (refCount == 0 && !disabled) - agent = new ManagementAgentImpl(); - refCount++; -} - -ManagementAgent::Singleton::~Singleton() -{ - sys::Mutex::ScopedLock _lock(lock); - refCount--; - if (refCount == 0 && !disabled) { - delete agent; - agent = 0; - } -} - -ManagementAgent* ManagementAgent::Singleton::getInstance() -{ - return agent; -} - -const string ManagementAgentImpl::storeMagicNumber("MA02"); - -ManagementAgentImpl::ManagementAgentImpl() : - interval(10), extThread(false), pipeHandle(0), notifyCallback(0), notifyContext(0), - notifyable(0), inCallback(false), - initialized(false), connected(false), useMapMsg(false), lastFailure("never connected"), - topicExchange("qmf.default.topic"), directExchange("qmf.default.direct"), - schemaTimestamp(Duration(EPOCH, now())), - publishAllData(true), requestedBrokerBank(0), requestedAgentBank(0), - assignedBrokerBank(0), assignedAgentBank(0), bootSequence(0), - maxV2ReplyObjs(10), // KAG todo: make this a tuneable parameter - connThreadBody(*this), connThread(connThreadBody), - pubThreadBody(*this), pubThread(pubThreadBody) -{ -} - -ManagementAgentImpl::~ManagementAgentImpl() -{ - // shutdown & cleanup all threads - connThreadBody.close(); - pubThreadBody.close(); - - connThread.join(); - pubThread.join(); - - if (pipeHandle) { - delete pipeHandle; - pipeHandle = 0; - } -} - -void ManagementAgentImpl::setName(const string& vendor, const string& product, const string& instance) -{ - if (vendor.find(':') != vendor.npos) { - throw Exception("vendor string cannot contain a ':' character."); - } - if (product.find(':') != product.npos) { - throw Exception("product string cannot contain a ':' character."); - } - - attrMap["_vendor"] = vendor; - attrMap["_product"] = product; - if (!instance.empty()) { - attrMap["_instance"] = instance; - } -} - - -void ManagementAgentImpl::getName(string& vendor, string& product, string& instance) -{ - vendor = std::string(attrMap["_vendor"]); - product = std::string(attrMap["_product"]); - instance = std::string(attrMap["_instance"]); -} - - -const std::string& ManagementAgentImpl::getAddress() -{ - return name_address; -} - - -void ManagementAgentImpl::init(const string& brokerHost, - uint16_t brokerPort, - uint16_t intervalSeconds, - bool useExternalThread, - const string& _storeFile, - const string& uid, - const string& pwd, - const string& mech, - const string& proto) -{ - management::ConnectionSettings settings; - settings.protocol = proto; - settings.host = brokerHost; - settings.port = brokerPort; - settings.username = uid; - settings.password = pwd; - settings.mechanism = mech; - settings.heartbeat = 10; - init(settings, intervalSeconds, useExternalThread, _storeFile); -} - -void ManagementAgentImpl::init(const qpid::management::ConnectionSettings& settings, - uint16_t intervalSeconds, - bool useExternalThread, - const string& _storeFile) -{ - std::string cfgVendor, cfgProduct, cfgInstance; - - interval = intervalSeconds; - extThread = useExternalThread; - storeFile = _storeFile; - nextObjectId = 1; - - // - // Convert from management::ConnectionSettings to client::ConnectionSettings - // - connectionSettings.protocol = settings.protocol; - connectionSettings.host = settings.host; - connectionSettings.port = settings.port; - connectionSettings.virtualhost = settings.virtualhost; - connectionSettings.username = settings.username; - connectionSettings.password = settings.password; - connectionSettings.mechanism = settings.mechanism; - connectionSettings.locale = settings.locale; - connectionSettings.heartbeat = settings.heartbeat; - connectionSettings.maxChannels = settings.maxChannels; - connectionSettings.maxFrameSize = settings.maxFrameSize; - connectionSettings.bounds = settings.bounds; - connectionSettings.tcpNoDelay = settings.tcpNoDelay; - connectionSettings.service = settings.service; - connectionSettings.minSsf = settings.minSsf; - connectionSettings.maxSsf = settings.maxSsf; - - retrieveData(cfgVendor, cfgProduct, cfgInstance); - - bootSequence++; - if ((bootSequence & 0xF000) != 0) - bootSequence = 1; - - // setup the agent's name. The name may be set via a call to setName(). If setName() - // has not been called, the name can be read from the configuration file. If there is - // no name in the configuration file, a unique default name is provided. - if (attrMap.empty()) { - // setName() never called by application, so use names retrieved from config, otherwise defaults. - setName(cfgVendor.empty() ? defaultVendorName : cfgVendor, - cfgProduct.empty() ? defaultProductName : cfgProduct, - cfgInstance.empty() ? qpid::types::Uuid(true).str() : cfgInstance); - } else if (attrMap.find("_instance") == attrMap.end()) { - // setName() called, but instance was not specified, use config or generate a uuid - setName(attrMap["_vendor"].asString(), attrMap["_product"].asString(), - cfgInstance.empty() ? qpid::types::Uuid(true).str() : cfgInstance); - } - - name_address = attrMap["_vendor"].asString() + ":" + attrMap["_product"].asString() + ":" + attrMap["_instance"].asString(); - vendorNameKey = keyifyNameStr(attrMap["_vendor"].asString()); - productNameKey = keyifyNameStr(attrMap["_product"].asString()); - instanceNameKey = keyifyNameStr(attrMap["_instance"].asString()); - attrMap["_name"] = name_address; - - storeData(true); - - QPID_LOG(info, "QMF Agent Initialized: broker=" << settings.host << ":" << settings.port << - " interval=" << intervalSeconds << " storeFile=" << _storeFile << " name=" << name_address); - - initialized = true; -} - -void ManagementAgentImpl::registerClass(const string& packageName, - const string& className, - uint8_t* md5Sum, - ManagementObject::writeSchemaCall_t schemaCall) -{ - sys::Mutex::ScopedLock lock(agentLock); - PackageMap::iterator pIter = findOrAddPackage(packageName); - addClassLocal(ManagementItem::CLASS_KIND_TABLE, pIter, className, md5Sum, schemaCall); -} - -void ManagementAgentImpl::registerEvent(const string& packageName, - const string& eventName, - uint8_t* md5Sum, - ManagementObject::writeSchemaCall_t schemaCall) -{ - sys::Mutex::ScopedLock lock(agentLock); - PackageMap::iterator pIter = findOrAddPackage(packageName); - addClassLocal(ManagementItem::CLASS_KIND_EVENT, pIter, eventName, md5Sum, schemaCall); -} - -// old-style add object: 64bit id - deprecated -ObjectId ManagementAgentImpl::addObject(ManagementObject* object, - uint64_t persistId) -{ - std::string key; - if (persistId) { - key = boost::lexical_cast<std::string>(persistId); - } - return addObject(object, key, persistId != 0); -} - - -// new style add object - use this approach! -ObjectId ManagementAgentImpl::addObject(ManagementObject* object, - const std::string& key, - bool persistent) -{ - sys::Mutex::ScopedLock lock(addLock); - - uint16_t sequence = persistent ? 0 : bootSequence; - - ObjectId objectId(&attachment, 0, sequence); - if (key.empty()) - objectId.setV2Key(*object); // let object generate the key - else - objectId.setV2Key(key); - objectId.setAgentName(name_address); - - object->setObjectId(objectId); - newManagementObjects[objectId] = boost::shared_ptr<ManagementObject>(object); - return objectId; -} - - -void ManagementAgentImpl::raiseEvent(const ManagementEvent& event, severity_t severity) -{ - static const std::string severityStr[] = { - "emerg", "alert", "crit", "error", "warn", - "note", "info", "debug" - }; - string content; - stringstream key; - Variant::Map headers; - - { - sys::Mutex::ScopedLock lock(agentLock); - Buffer outBuffer(eventBuffer, MA_BUFFER_SIZE); - uint8_t sev = (severity == SEV_DEFAULT) ? event.getSeverity() : (uint8_t) severity; - - // key << "console.event." << assignedBrokerBank << "." << assignedAgentBank << "." << - // event.getPackageName() << "." << event.getEventName(); - key << "agent.ind.event." << keyifyNameStr(event.getPackageName()) - << "." << keyifyNameStr(event.getEventName()) - << "." << severityStr[sev] - << "." << vendorNameKey - << "." << productNameKey - << "." << instanceNameKey; - - Variant::Map map_; - Variant::Map schemaId; - Variant::Map values; - - map_["_schema_id"] = mapEncodeSchemaId(event.getPackageName(), - event.getEventName(), - event.getMd5Sum(), - ManagementItem::CLASS_KIND_EVENT); - event.mapEncode(values); - map_["_values"] = values; - map_["_timestamp"] = uint64_t(Duration(EPOCH, now())); - map_["_severity"] = sev; - - headers["method"] = "indication"; - headers["qmf.opcode"] = "_data_indication"; - headers["qmf.content"] = "_event"; - headers["qmf.agent"] = name_address; - - Variant::List list; - list.push_back(map_); - ListCodec::encode(list, content); - } - - connThreadBody.sendBuffer(content, "", headers, topicExchange, key.str(), "amqp/list"); -} - -uint32_t ManagementAgentImpl::pollCallbacks(uint32_t callLimit) -{ - sys::Mutex::ScopedLock lock(agentLock); - - if (inCallback) { - QPID_LOG(critical, "pollCallbacks invoked from the agent's thread!"); - return 0; - } - - for (uint32_t idx = 0; callLimit == 0 || idx < callLimit; idx++) { - if (methodQueue.empty()) - break; - - QueuedMethod* item = methodQueue.front(); - methodQueue.pop_front(); - { - sys::Mutex::ScopedUnlock unlock(agentLock); - invokeMethodRequest(item->body, item->cid, item->replyToExchange, item->replyToKey, item->userId); - delete item; - } - } - - if (pipeHandle != 0) { - char rbuf[100]; - while (pipeHandle->read(rbuf, 100) > 0) ; // Consume all signaling bytes - } - return methodQueue.size(); -} - -int ManagementAgentImpl::getSignalFd() -{ - if (extThread) { - if (pipeHandle == 0) - pipeHandle = new PipeHandle(true); - return pipeHandle->getReadHandle(); - } - - return -1; -} - -void ManagementAgentImpl::setSignalCallback(cb_t callback, void* context) -{ - sys::Mutex::ScopedLock lock(agentLock); - notifyCallback = callback; - notifyContext = context; -} - -void ManagementAgentImpl::setSignalCallback(Notifyable& _notifyable) -{ - sys::Mutex::ScopedLock lock(agentLock); - notifyable = &_notifyable; -} - -void ManagementAgentImpl::startProtocol() -{ - sendHeartbeat(); - { - sys::Mutex::ScopedLock lock(agentLock); - publishAllData = true; - } -} - -void ManagementAgentImpl::storeData(bool requested) -{ - if (!storeFile.empty()) { - ofstream outFile(storeFile.c_str()); - uint32_t brokerBankToWrite = requested ? requestedBrokerBank : assignedBrokerBank; - uint32_t agentBankToWrite = requested ? requestedAgentBank : assignedAgentBank; - - if (outFile.good()) { - outFile << storeMagicNumber << " " << brokerBankToWrite << " " << - agentBankToWrite << " " << bootSequence << endl; - - if (attrMap.find("_vendor") != attrMap.end()) - outFile << "vendor=" << attrMap["_vendor"] << endl; - if (attrMap.find("_product") != attrMap.end()) - outFile << "product=" << attrMap["_product"] << endl; - if (attrMap.find("_instance") != attrMap.end()) - outFile << "instance=" << attrMap["_instance"] << endl; - - outFile.close(); - } - } -} - -void ManagementAgentImpl::retrieveData(std::string& vendor, std::string& product, std::string& inst) -{ - vendor.clear(); - product.clear(); - inst.clear(); - - if (!storeFile.empty()) { - ifstream inFile(storeFile.c_str()); - string mn; - - if (inFile.good()) { - inFile >> mn; - if (mn == storeMagicNumber) { - std::string inText; - - inFile >> requestedBrokerBank; - inFile >> requestedAgentBank; - inFile >> bootSequence; - - while (inFile.good()) { - std::getline(inFile, inText); - if (!inText.compare(0, 7, "vendor=")) { - vendor = inText.substr(7); - QPID_LOG(debug, "read vendor name [" << vendor << "] from configuration file."); - } else if (!inText.compare(0, 8, "product=")) { - product = inText.substr(8); - QPID_LOG(debug, "read product name [" << product << "] from configuration file."); - } else if (!inText.compare(0, 9, "instance=")) { - inst = inText.substr(9); - QPID_LOG(debug, "read instance name [" << inst << "] from configuration file."); - } - } - } - inFile.close(); - } - } -} - -void ManagementAgentImpl::sendHeartbeat() -{ - static const string addr_key_base("agent.ind.heartbeat."); - - Variant::Map map; - Variant::Map headers; - string content; - std::stringstream addr_key; - - addr_key << addr_key_base << vendorNameKey - << "." << productNameKey - << "." << instanceNameKey; - - headers["method"] = "indication"; - headers["qmf.opcode"] = "_agent_heartbeat_indication"; - headers["qmf.agent"] = name_address; - - getHeartbeatContent(map); - MapCodec::encode(map, content); - - // Set TTL (in msecs) on outgoing heartbeat indications based on the interval - // time to prevent stale heartbeats from getting to the consoles. - - connThreadBody.sendBuffer(content, "", headers, topicExchange, addr_key.str(), - "amqp/map", interval * 2 * 1000); - - QPID_LOG(trace, "SENT AgentHeartbeat name=" << name_address); -} - -void ManagementAgentImpl::sendException(const string& rte, const string& rtk, const string& cid, - const string& text, uint32_t code) -{ - Variant::Map map; - Variant::Map headers; - Variant::Map values; - string content; - - headers["method"] = "indication"; - headers["qmf.opcode"] = "_exception"; - headers["qmf.agent"] = name_address; - - values["error_code"] = code; - values["error_text"] = text; - map["_values"] = values; - - MapCodec::encode(map, content); - connThreadBody.sendBuffer(content, cid, headers, rte, rtk); - - QPID_LOG(trace, "SENT Exception code=" << code <<" text=" << text); -} - -void ManagementAgentImpl::handleSchemaRequest(Buffer& inBuffer, uint32_t sequence, const string& rte, const string& rtk) -{ - string packageName; - SchemaClassKey key; - uint32_t outLen(0); - char localBuffer[MA_BUFFER_SIZE]; - Buffer outBuffer(localBuffer, MA_BUFFER_SIZE); - bool found(false); - - inBuffer.getShortString(packageName); - inBuffer.getShortString(key.name); - inBuffer.getBin128(key.hash); - - QPID_LOG(trace, "RCVD SchemaRequest: package=" << packageName << " class=" << key.name); - - { - sys::Mutex::ScopedLock lock(agentLock); - PackageMap::iterator pIter = packages.find(packageName); - if (pIter != packages.end()) { - ClassMap& cMap = pIter->second; - ClassMap::iterator cIter = cMap.find(key); - if (cIter != cMap.end()) { - SchemaClass& schema = cIter->second; - string body; - - encodeHeader(outBuffer, 's', sequence); - schema.writeSchemaCall(body); - outBuffer.putRawData(body); - outLen = MA_BUFFER_SIZE - outBuffer.available(); - outBuffer.reset(); - found = true; - } - } - } - - if (found) { - connThreadBody.sendBuffer(outBuffer, outLen, rte, rtk); - QPID_LOG(trace, "SENT SchemaInd: package=" << packageName << " class=" << key.name); - } -} - -void ManagementAgentImpl::handleConsoleAddedIndication() -{ - sys::Mutex::ScopedLock lock(agentLock); - publishAllData = true; - - QPID_LOG(trace, "RCVD ConsoleAddedInd"); -} - -void ManagementAgentImpl::invokeMethodRequest(const string& body, const string& cid, const string& rte, const string& rtk, const string& userId) -{ - string methodName; - bool failed = false; - Variant::Map inMap; - Variant::Map outMap; - Variant::Map::const_iterator oid, mid; - string content; - - MapCodec::decode(body, inMap); - - if ((oid = inMap.find("_object_id")) == inMap.end() || - (mid = inMap.find("_method_name")) == inMap.end()) { - sendException(rte, rtk, cid, Manageable::StatusText(Manageable::STATUS_PARAMETER_INVALID), - Manageable::STATUS_PARAMETER_INVALID); - failed = true; - } else { - string methodName; - ObjectId objId; - Variant::Map inArgs; - Variant::Map callMap; - - try { - // conversions will throw if input is invalid. - objId = ObjectId(oid->second.asMap()); - methodName = mid->second.getString(); - - mid = inMap.find("_arguments"); - if (mid != inMap.end()) { - inArgs = (mid->second).asMap(); - } - - QPID_LOG(trace, "Invoking Method: name=" << methodName << " args=" << inArgs); - - boost::shared_ptr<ManagementObject> oPtr; - { - sys::Mutex::ScopedLock lock(agentLock); - ObjectMap::iterator iter = managementObjects.find(objId); - if (iter != managementObjects.end() && !iter->second->isDeleted()) - oPtr = iter->second; - } - - if (oPtr.get() == 0) { - sendException(rte, rtk, cid, Manageable::StatusText(Manageable::STATUS_UNKNOWN_OBJECT), - Manageable::STATUS_UNKNOWN_OBJECT); - failed = true; - } else { - oPtr->doMethod(methodName, inArgs, callMap, userId); - - if (callMap["_status_code"].asUint32() == 0) { - outMap["_arguments"] = Variant::Map(); - for (Variant::Map::const_iterator iter = callMap.begin(); - iter != callMap.end(); iter++) - if (iter->first != "_status_code" && iter->first != "_status_text") - outMap["_arguments"].asMap()[iter->first] = iter->second; - } else { - sendException(rte, rtk, cid, callMap["_status_text"], callMap["_status_code"]); - failed = true; - } - } - - } catch(types::InvalidConversion& e) { - sendException(rte, rtk, cid, e.what(), Manageable::STATUS_EXCEPTION); - failed = true; - } - } - - if (!failed) { - Variant::Map headers; - headers["method"] = "response"; - headers["qmf.agent"] = name_address; - headers["qmf.opcode"] = "_method_response"; - QPID_LOG(trace, "SENT MethodResponse map=" << outMap); - MapCodec::encode(outMap, content); - connThreadBody.sendBuffer(content, cid, headers, rte, rtk); - } -} - -void ManagementAgentImpl::handleGetQuery(const string& body, const string& cid, const string& rte, const string& rtk) -{ - { - sys::Mutex::ScopedLock lock(agentLock); - moveNewObjectsLH(lock); - } - - Variant::Map inMap; - Variant::Map::const_iterator i; - Variant::Map headers; - - MapCodec::decode(body, inMap); - QPID_LOG(trace, "RCVD GetQuery: map=" << inMap << " cid=" << cid); - - headers["method"] = "response"; - headers["qmf.opcode"] = "_query_response"; - headers["qmf.agent"] = name_address; - headers["partial"] = Variant(); - - Variant::List list_; - Variant::Map map_; - Variant::Map values; - Variant::Map oidMap; - string content; - - /* - * Unpack the _what element of the query. Currently we only support OBJECT queries. - */ - i = inMap.find("_what"); - if (i == inMap.end()) { - sendException(rte, rtk, cid, "_what element missing in Query"); - return; - } - - if (i->second.getType() != qpid::types::VAR_STRING) { - sendException(rte, rtk, cid, "_what element is not a string"); - return; - } - - if (i->second.asString() == "OBJECT") { - headers["qmf.content"] = "_data"; - /* - * Unpack the _object_id element of the query if it is present. If it is present, find that one - * object and return it. If it is not present, send a class-based result. - */ - i = inMap.find("_object_id"); - if (i != inMap.end() && i->second.getType() == qpid::types::VAR_MAP) { - ObjectId objId(i->second.asMap()); - boost::shared_ptr<ManagementObject> object; - - { - sys::Mutex::ScopedLock lock(agentLock); - ObjectMap::iterator iter = managementObjects.find(objId); - if (iter != managementObjects.end()) - object = iter->second; - } - - if (object.get() != 0) { - if (object->getConfigChanged() || object->getInstChanged()) - object->setUpdateTime(); - - object->mapEncodeValues(values, true, true); // write both stats and properties - objId.mapEncode(oidMap); - map_["_values"] = values; - map_["_object_id"] = oidMap; - object->writeTimestamps(map_); - map_["_schema_id"] = mapEncodeSchemaId(object->getPackageName(), - object->getClassName(), - object->getMd5Sum()); - list_.push_back(map_); - headers.erase("partial"); - - ListCodec::encode(list_, content); - connThreadBody.sendBuffer(content, cid, headers, rte, rtk, "amqp/list"); - QPID_LOG(trace, "SENT QueryResponse (query by object_id) to=" << rte << "/" << rtk); - return; - } - } else { // match using schema_id, if supplied - - string className; - string packageName; - - i = inMap.find("_schema_id"); - if (i != inMap.end() && i->second.getType() == qpid::types::VAR_MAP) { - const Variant::Map& schemaIdMap(i->second.asMap()); - - Variant::Map::const_iterator s_iter = schemaIdMap.find("_class_name"); - if (s_iter != schemaIdMap.end() && s_iter->second.getType() == qpid::types::VAR_STRING) - className = s_iter->second.asString(); - - s_iter = schemaIdMap.find("_package_name"); - if (s_iter != schemaIdMap.end() && s_iter->second.getType() == qpid::types::VAR_STRING) - packageName = s_iter->second.asString(); - - typedef list<boost::shared_ptr<ManagementObject> > StageList; - StageList staging; - - { - sys::Mutex::ScopedLock lock(agentLock); - for (ObjectMap::iterator iter = managementObjects.begin(); - iter != managementObjects.end(); - iter++) { - ManagementObject* object = iter->second.get(); - if (object->getClassName() == className && - (packageName.empty() || object->getPackageName() == packageName)) - staging.push_back(iter->second); - } - } - - unsigned int objCount = 0; - for (StageList::iterator iter = staging.begin(); iter != staging.end(); iter++) { - ManagementObject* object = iter->get(); - if (object->getClassName() == className && - (packageName.empty() || object->getPackageName() == packageName)) { - - values.clear(); - oidMap.clear(); - map_.clear(); - - if (object->getConfigChanged() || object->getInstChanged()) - object->setUpdateTime(); - - object->mapEncodeValues(values, true, true); // write both stats and properties - object->getObjectId().mapEncode(oidMap); - map_["_values"] = values; - map_["_object_id"] = oidMap; - object->writeTimestamps(map_); - map_["_schema_id"] = mapEncodeSchemaId(object->getPackageName(), - object->getClassName(), - object->getMd5Sum()); - list_.push_back(map_); - - if (++objCount >= maxV2ReplyObjs) { - objCount = 0; - ListCodec::encode(list_, content); - connThreadBody.sendBuffer(content, cid, headers, rte, rtk, "amqp/list"); - QPID_LOG(trace, "SENT QueryResponse (query by schema_id) to=" << rte << "/" << rtk); - content.clear(); - list_.clear(); - } - } - } - } - } - - // Send last "non-partial" message to indicate CommandComplete - headers.erase("partial"); - ListCodec::encode(list_, content); - connThreadBody.sendBuffer(content, cid, headers, rte, rtk, "amqp/list"); - QPID_LOG(trace, "SENT QueryResponse (last message, no 'partial' indicator) to=" << rte << "/" << rtk); - - } else if (i->second.asString() == "SCHEMA_ID") { - headers["qmf.content"] = "_schema_id"; - /** - * @todo - support for a predicate. For now, send a list of all known schema class keys. - */ - for (PackageMap::iterator pIter = packages.begin(); - pIter != packages.end(); pIter++) { - for (ClassMap::iterator cIter = pIter->second.begin(); - cIter != pIter->second.end(); cIter++) { - - list_.push_back(mapEncodeSchemaId( pIter->first, - cIter->first.name, - cIter->first.hash, - cIter->second.kind )); - } - } - - headers.erase("partial"); - ListCodec::encode(list_, content); - connThreadBody.sendBuffer(content, cid, headers, rte, rtk, "amqp/list"); - QPID_LOG(trace, "SENT QueryResponse (SchemaId) to=" << rte << "/" << rtk); - - } else { - // Unknown query target - sendException(rte, rtk, cid, "Query for _what => '" + i->second.asString() + "' not supported"); - } -} - -void ManagementAgentImpl::handleLocateRequest(const string&, const string& cid, const string& rte, const string& rtk) -{ - QPID_LOG(trace, "RCVD AgentLocateRequest"); - - Variant::Map map; - Variant::Map headers; - string content; - - headers["method"] = "indication"; - headers["qmf.opcode"] = "_agent_locate_response"; - headers["qmf.agent"] = name_address; - - getHeartbeatContent(map); - MapCodec::encode(map, content); - connThreadBody.sendBuffer(content, cid, headers, rte, rtk); - - QPID_LOG(trace, "SENT AgentLocateResponse replyTo=" << rte << "/" << rtk); - - { - sys::Mutex::ScopedLock lock(agentLock); - publishAllData = true; - } -} - -void ManagementAgentImpl::handleMethodRequest(const string& body, const string& cid, const string& rte, const string& rtk, const string& userId) -{ - if (extThread) { - sys::Mutex::ScopedLock lock(agentLock); - - methodQueue.push_back(new QueuedMethod(cid, rte, rtk, body, userId)); - if (pipeHandle != 0) { - pipeHandle->write("X", 1); - } else if (notifyable != 0) { - inCallback = true; - { - sys::Mutex::ScopedUnlock unlock(agentLock); - notifyable->notify(); - } - inCallback = false; - } else if (notifyCallback != 0) { - inCallback = true; - { - sys::Mutex::ScopedUnlock unlock(agentLock); - notifyCallback(notifyContext); - } - inCallback = false; - } - } else { - invokeMethodRequest(body, cid, rte, rtk, userId); - } - - QPID_LOG(trace, "RCVD MethodRequest"); -} - -void ManagementAgentImpl::received(Message& msg) -{ - string replyToExchange; - string replyToKey; - framing::MessageProperties mp = msg.getMessageProperties(); - if (mp.hasReplyTo()) { - const framing::ReplyTo& rt = mp.getReplyTo(); - replyToExchange = rt.getExchange(); - replyToKey = rt.getRoutingKey(); - } - - string userId; - if (mp.hasUserId()) - userId = mp.getUserId(); - - if (mp.hasAppId() && mp.getAppId() == "qmf2") - { - string opcode = mp.getApplicationHeaders().getAsString("qmf.opcode"); - string cid = msg.getMessageProperties().getCorrelationId(); - - if (opcode == "_agent_locate_request") handleLocateRequest(msg.getData(), cid, replyToExchange, replyToKey); - else if (opcode == "_method_request") handleMethodRequest(msg.getData(), cid, replyToExchange, replyToKey, userId); - else if (opcode == "_query_request") handleGetQuery(msg.getData(), cid, replyToExchange, replyToKey); - else { - QPID_LOG(warning, "Support for QMF V2 Opcode [" << opcode << "] TBD!!!"); - } - return; - } - - // old preV2 binary messages - - uint32_t sequence; - string data = msg.getData(); - Buffer inBuffer(const_cast<char*>(data.c_str()), data.size()); - uint8_t opcode; - - - if (checkHeader(inBuffer, &opcode, &sequence)) - { - if (opcode == 'S') handleSchemaRequest(inBuffer, sequence, replyToExchange, replyToKey); - else if (opcode == 'x') handleConsoleAddedIndication(); - else - QPID_LOG(warning, "Ignoring old-format QMF Request! opcode=" << char(opcode)); - } -} - - -void ManagementAgentImpl::encodeHeader(Buffer& buf, uint8_t opcode, uint32_t seq) -{ - buf.putOctet('A'); - buf.putOctet('M'); - buf.putOctet('2'); - buf.putOctet(opcode); - buf.putLong (seq); -} - -Variant::Map ManagementAgentImpl::mapEncodeSchemaId(const string& pname, - const string& cname, - const uint8_t *md5Sum, - uint8_t type) -{ - Variant::Map map_; - - map_["_package_name"] = pname; - map_["_class_name"] = cname; - map_["_hash"] = types::Uuid(md5Sum); - if (type == ManagementItem::CLASS_KIND_EVENT) - map_["_type"] = "_event"; - else - map_["_type"] = "_data"; - - return map_; -} - - -bool ManagementAgentImpl::checkHeader(Buffer& buf, uint8_t *opcode, uint32_t *seq) -{ - if (buf.getSize() < 8) - return false; - - uint8_t h1 = buf.getOctet(); - uint8_t h2 = buf.getOctet(); - uint8_t h3 = buf.getOctet(); - - *opcode = buf.getOctet(); - *seq = buf.getLong(); - - return h1 == 'A' && h2 == 'M' && h3 == '2'; -} - -ManagementAgentImpl::PackageMap::iterator ManagementAgentImpl::findOrAddPackage(const string& name) -{ - PackageMap::iterator pIter = packages.find(name); - if (pIter != packages.end()) - return pIter; - - // No such package found, create a new map entry. - pair<PackageMap::iterator, bool> result = - packages.insert(pair<string, ClassMap>(name, ClassMap())); - - return result.first; -} - -// note well: caller must hold agentLock when calling this! -void ManagementAgentImpl::moveNewObjectsLH(const sys::Mutex::ScopedLock& /*agentLock*/) -{ - sys::Mutex::ScopedLock lock(addLock); - ObjectMap::iterator newObj = newManagementObjects.begin(); - while (newObj != newManagementObjects.end()) { - // before adding a new mgmt object, check for duplicates: - ObjectMap::iterator oldObj = managementObjects.find(newObj->first); - if (oldObj == managementObjects.end()) { - managementObjects[newObj->first] = newObj->second; - newManagementObjects.erase(newObj++); // post inc iterator safe! - } else { - // object exists with same object id. This may be legit, for example, when a - // recently deleted object is re-added before the mgmt poll runs. - if (newObj->second->isDeleted()) { - // @TODO fixme: we missed an add-delete for the new object - QPID_LOG(warning, "Mgmt Object deleted before update sent, oid=" << newObj->first); - newManagementObjects.erase(newObj++); // post inc iterator safe! - } else if (oldObj->second->isDeleted()) { - // skip adding newObj, try again later once oldObj has been cleaned up by poll - ++newObj; - } else { - // real bad - two objects exist with same OID. This is a bug in the application - QPID_LOG(error, "Detected two Mgmt Objects using the same object id! oid=" << newObj->first - << ", this is bad!"); - // what to do here? Can't erase an active obj - owner has a pointer to it. - // for now I punt. Maybe the flood of log messages will get someone's attention :P - ++newObj; - } - } - } -} - -void ManagementAgentImpl::addClassLocal(uint8_t classKind, - PackageMap::iterator pIter, - const string& className, - uint8_t* md5Sum, - ManagementObject::writeSchemaCall_t schemaCall) -{ - SchemaClassKey key; - ClassMap& cMap = pIter->second; - - key.name = className; - memcpy(&key.hash, md5Sum, 16); - - ClassMap::iterator cIter = cMap.find(key); - if (cIter != cMap.end()) - return; - - // No such class found, create a new class with local information. - cMap.insert(pair<SchemaClassKey, SchemaClass>(key, SchemaClass(schemaCall, classKind))); - schemaTimestamp = Duration(EPOCH, now()); - QPID_LOG(trace, "Updated schema timestamp, now=" << uint64_t(schemaTimestamp)); -} - -void ManagementAgentImpl::encodePackageIndication(Buffer& buf, - PackageMap::iterator pIter) -{ - buf.putShortString((*pIter).first); - - QPID_LOG(trace, "SENT PackageInd: package=" << (*pIter).first); -} - -void ManagementAgentImpl::encodeClassIndication(Buffer& buf, - PackageMap::iterator pIter, - ClassMap::iterator cIter) -{ - SchemaClassKey key = (*cIter).first; - - buf.putOctet((*cIter).second.kind); - buf.putShortString((*pIter).first); - buf.putShortString(key.name); - buf.putBin128(key.hash); - - QPID_LOG(trace, "SENT ClassInd: package=" << (*pIter).first << " class=" << key.name); -} - -struct MessageItem { - string content; - Variant::Map headers; - string key; - MessageItem(const Variant::Map& h, const string& k) : headers(h), key(k) {} -}; - -void ManagementAgentImpl::periodicProcessing() -{ - string addr_key_base = "agent.ind.data."; - list<ObjectId> deleteList; - list<boost::shared_ptr<MessageItem> > message_list; - - sendHeartbeat(); - - { - sys::Mutex::ScopedLock lock(agentLock); - - if (!connected) - return; - - moveNewObjectsLH(lock); - - // - // Clear the been-here flag on all objects in the map. - // - for (ObjectMap::iterator iter = managementObjects.begin(); - iter != managementObjects.end(); - iter++) { - ManagementObject* object = iter->second.get(); - object->setFlags(0); - if (publishAllData) { - object->setForcePublish(true); - } - } - - publishAllData = false; - - // - // Process the entire object map. - // - uint32_t v2Objs = 0; - - for (ObjectMap::iterator baseIter = managementObjects.begin(); - baseIter != managementObjects.end(); - baseIter++) { - ManagementObject* baseObject = baseIter->second.get(); - - // - // Skip until we find a base object requiring a sent message. - // - if (baseObject->getFlags() == 1 || - (!baseObject->getConfigChanged() && - !baseObject->getInstChanged() && - !baseObject->getForcePublish() && - !baseObject->isDeleted())) - continue; - - std::string packageName = baseObject->getPackageName(); - std::string className = baseObject->getClassName(); - - Variant::List list_; - std::stringstream addr_key; - Variant::Map headers; - - addr_key << addr_key_base; - addr_key << keyifyNameStr(packageName) - << "." << keyifyNameStr(className) - << "." << vendorNameKey - << "." << productNameKey - << "." << instanceNameKey; - - headers["method"] = "indication"; - headers["qmf.opcode"] = "_data_indication"; - headers["qmf.content"] = "_data"; - headers["qmf.agent"] = name_address; - - for (ObjectMap::iterator iter = baseIter; - iter != managementObjects.end(); - iter++) { - ManagementObject* object = iter->second.get(); - bool send_stats, send_props; - if (baseObject->isSameClass(*object) && object->getFlags() == 0) { - object->setFlags(1); - if (object->getConfigChanged() || object->getInstChanged()) - object->setUpdateTime(); - - send_props = (object->getConfigChanged() || object->getForcePublish() || object->isDeleted()); - send_stats = (object->hasInst() && (object->getInstChanged() || object->getForcePublish())); - - if (send_stats || send_props) { - Variant::Map map_; - Variant::Map values; - Variant::Map oid; - - object->getObjectId().mapEncode(oid); - map_["_object_id"] = oid; - map_["_schema_id"] = mapEncodeSchemaId(object->getPackageName(), - object->getClassName(), - object->getMd5Sum()); - object->writeTimestamps(map_); - object->mapEncodeValues(values, send_props, send_stats); - map_["_values"] = values; - list_.push_back(map_); - - if (++v2Objs >= maxV2ReplyObjs) { - v2Objs = 0; - boost::shared_ptr<MessageItem> item(new MessageItem(headers, addr_key.str())); - ListCodec::encode(list_, item->content); - message_list.push_back(item); - list_.clear(); - } - } - - if (object->isDeleted()) - deleteList.push_back(iter->first); - object->setForcePublish(false); - } - } - - if (!list_.empty()) { - boost::shared_ptr<MessageItem> item(new MessageItem(headers, addr_key.str())); - ListCodec::encode(list_, item->content); - message_list.push_back(item); - } - } - - // Delete flagged objects - for (list<ObjectId>::reverse_iterator iter = deleteList.rbegin(); - iter != deleteList.rend(); - iter++) - managementObjects.erase(*iter); - } - - while (!message_list.empty()) { - boost::shared_ptr<MessageItem> item(message_list.front()); - message_list.pop_front(); - connThreadBody.sendBuffer(item->content, "", item->headers, topicExchange, item->key, "amqp/list"); - QPID_LOG(trace, "SENT DataIndication"); - } -} - - -void ManagementAgentImpl::getHeartbeatContent(qpid::types::Variant::Map& map) -{ - map["_values"] = attrMap; - map["_values"].asMap()["_timestamp"] = uint64_t(Duration(EPOCH, now())); - map["_values"].asMap()["_heartbeat_interval"] = interval; - map["_values"].asMap()["_epoch"] = bootSequence; - map["_values"].asMap()["_schema_updated"] = uint64_t(schemaTimestamp); -} - -void ManagementAgentImpl::ConnectionThread::run() -{ - static const int delayMin(1); - static const int delayMax(128); - static const int delayFactor(2); - int delay(delayMin); - string dest("qmfagent"); - ConnectionThread::shared_ptr tmp; - - sessionId.generate(); - queueName << "qmfagent-" << sessionId; - - while (true) { - try { - if (agent.initialized) { - QPID_LOG(debug, "QMF Agent attempting to connect to the broker..."); - connection.open(agent.connectionSettings); - session = connection.newSession(queueName.str()); - subscriptions.reset(new client::SubscriptionManager(session)); - - session.queueDeclare(arg::queue=queueName.str(), arg::autoDelete=true, - arg::exclusive=true); - session.exchangeBind(arg::exchange="amq.direct", arg::queue=queueName.str(), - arg::bindingKey=queueName.str()); - session.exchangeBind(arg::exchange=agent.directExchange, arg::queue=queueName.str(), - arg::bindingKey=agent.name_address); - session.exchangeBind(arg::exchange=agent.topicExchange, arg::queue=queueName.str(), - arg::bindingKey="console.#"); - - subscriptions->subscribe(agent, queueName.str(), dest); - QPID_LOG(info, "Connection established with broker"); - { - sys::Mutex::ScopedLock _lock(connLock); - if (shutdown) - return; - operational = true; - agent.connected = true; - agent.startProtocol(); - try { - sys::Mutex::ScopedUnlock _unlock(connLock); - subscriptions->run(); - } catch (exception) {} - - QPID_LOG(warning, "Connection to the broker has been lost"); - - operational = false; - agent.connected = false; - tmp = subscriptions; - subscriptions.reset(); - } - tmp.reset(); // frees the subscription outside the lock - delay = delayMin; - connection.close(); - } - } catch (exception &e) { - if (delay < delayMax) - delay *= delayFactor; - QPID_LOG(debug, "Connection failed: exception=" << e.what()); - } - - { - // sleep for "delay" seconds, but peridically check if the - // agent is shutting down so we don't hang for up to delayMax - // seconds during agent shutdown - sys::Mutex::ScopedLock _lock(connLock); - if (shutdown) - return; - sleeping = true; - int totalSleep = 0; - do { - sys::Mutex::ScopedUnlock _unlock(connLock); - qpid::sys::sleep(delayMin); - totalSleep += delayMin; - } while (totalSleep < delay && !shutdown); - sleeping = false; - if (shutdown) - return; - } - } -} - -ManagementAgentImpl::ConnectionThread::~ConnectionThread() -{ -} - -void ManagementAgentImpl::ConnectionThread::sendBuffer(Buffer& buf, - uint32_t length, - const string& exchange, - const string& routingKey) -{ - Message msg; - string data; - - buf.getRawData(data, length); - msg.setData(data); - sendMessage(msg, exchange, routingKey); -} - - - -void ManagementAgentImpl::ConnectionThread::sendBuffer(const string& data, - const string& cid, - const Variant::Map headers, - const string& exchange, - const string& routingKey, - const string& contentType, - uint64_t ttl_msec) -{ - Message msg; - Variant::Map::const_iterator i; - - if (!cid.empty()) - msg.getMessageProperties().setCorrelationId(cid); - - if (!contentType.empty()) - msg.getMessageProperties().setContentType(contentType); - - if (ttl_msec) - msg.getDeliveryProperties().setTtl(ttl_msec); - - for (i = headers.begin(); i != headers.end(); ++i) { - msg.getHeaders().setString(i->first, i->second.asString()); - } - - msg.setData(data); - sendMessage(msg, exchange, routingKey); -} - - - - - -void ManagementAgentImpl::ConnectionThread::sendMessage(Message msg, - const string& exchange, - const string& routingKey) -{ - ConnectionThread::shared_ptr s; - { - sys::Mutex::ScopedLock _lock(connLock); - if (!operational) - return; - s = subscriptions; - } - - msg.getDeliveryProperties().setRoutingKey(routingKey); - msg.getMessageProperties().setReplyTo(ReplyTo("amq.direct", queueName.str())); - msg.getMessageProperties().getApplicationHeaders().setString("qmf.agent", agent.name_address); - msg.getMessageProperties().setAppId("qmf2"); - try { - session.messageTransfer(arg::content=msg, arg::destination=exchange); - } catch(exception& e) { - QPID_LOG(error, "Exception caught in sendMessage: " << e.what()); - // Bounce the connection - if (s) - s->stop(); - } -} - - - -void ManagementAgentImpl::ConnectionThread::bindToBank(uint32_t brokerBank, uint32_t agentBank) -{ - stringstream key; - key << "agent." << brokerBank << "." << agentBank; - session.exchangeBind(arg::exchange="qpid.management", arg::queue=queueName.str(), - arg::bindingKey=key.str()); -} - -void ManagementAgentImpl::ConnectionThread::close() -{ - ConnectionThread::shared_ptr s; - { - sys::Mutex::ScopedLock _lock(connLock); - shutdown = true; - s = subscriptions; - } - if (s) - s->stop(); -} - -bool ManagementAgentImpl::ConnectionThread::isSleeping() const -{ - sys::Mutex::ScopedLock _lock(connLock); - return sleeping; -} - - -void ManagementAgentImpl::PublishThread::run() -{ - uint16_t totalSleep; - uint16_t sleepTime; - - while (!shutdown) { - agent.periodicProcessing(); - totalSleep = 0; - - // - // Calculate a sleep time that is no greater than 5 seconds and - // no less than 1 second. - // - sleepTime = agent.getInterval(); - if (sleepTime > 5) - sleepTime = 5; - else if (sleepTime == 0) - sleepTime = 1; - - while (totalSleep < agent.getInterval() && !shutdown) { - qpid::sys::sleep(sleepTime); - totalSleep += sleepTime; - } - } -} - -}} - diff --git a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h deleted file mode 100644 index 4c97bc89da..0000000000 --- a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h +++ /dev/null @@ -1,294 +0,0 @@ -#ifndef _qpid_agent_ManagementAgentImpl_ -#define _qpid_agent_ManagementAgentImpl_ - -// -// 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 "qpid/agent/ManagementAgent.h" -#include "qpid/client/Connection.h" -#include "qpid/client/ConnectionSettings.h" -#include "qpid/client/SubscriptionManager.h" -#include "qpid/client/Session.h" -#include "qpid/client/AsyncSession.h" -#include "qpid/client/Message.h" -#include "qpid/client/MessageListener.h" -#include "qpid/sys/Thread.h" -#include "qpid/sys/Runnable.h" -#include "qpid/sys/Mutex.h" -#include "qpid/sys/PipeHandle.h" -#include "qpid/sys/Time.h" -#include "qpid/framing/Uuid.h" -#include <iostream> -#include <sstream> -#include <deque> - -namespace qpid { -namespace management { - -class ManagementAgentImpl : public ManagementAgent, public client::MessageListener -{ - public: - - ManagementAgentImpl(); - virtual ~ManagementAgentImpl(); - - // - // Methods from ManagementAgent - // - int getMaxThreads() { return 1; } - void setName(const std::string& vendor, - const std::string& product, - const std::string& instance=""); - void getName(std::string& vendor, std::string& product, std::string& instance); - const std::string& getAddress(); - void init(const std::string& brokerHost = "localhost", - uint16_t brokerPort = 5672, - uint16_t intervalSeconds = 10, - bool useExternalThread = false, - const std::string& storeFile = "", - const std::string& uid = "", - const std::string& pwd = "", - const std::string& mech = "PLAIN", - const std::string& proto = "tcp"); - void init(const management::ConnectionSettings& settings, - uint16_t intervalSeconds = 10, - bool useExternalThread = false, - const std::string& storeFile = ""); - bool isConnected() { return connected; } - std::string& getLastFailure() { return lastFailure; } - void registerClass(const std::string& packageName, - const std::string& className, - uint8_t* md5Sum, - management::ManagementObject::writeSchemaCall_t schemaCall); - void registerEvent(const std::string& packageName, - const std::string& eventName, - uint8_t* md5Sum, - management::ManagementObject::writeSchemaCall_t schemaCall); - ObjectId addObject(management::ManagementObject* objectPtr, uint64_t persistId = 0); - ObjectId addObject(management::ManagementObject* objectPtr, const std::string& key, - bool persistent); - void raiseEvent(const management::ManagementEvent& event, severity_t severity = SEV_DEFAULT); - uint32_t pollCallbacks(uint32_t callLimit = 0); - int getSignalFd(); - void setSignalCallback(cb_t callback, void* context); - void setSignalCallback(Notifyable& n); - - uint16_t getInterval() { return interval; } - void periodicProcessing(); - - uint16_t getBootSequence(void) { return bootSequence; } - void setBootSequence(uint16_t b) { bootSequence = b; } - - private: - - struct SchemaClassKey { - std::string name; - uint8_t hash[16]; - }; - - struct SchemaClassKeyComp { - bool operator() (const SchemaClassKey& lhs, const SchemaClassKey& rhs) const - { - if (lhs.name != rhs.name) - return lhs.name < rhs.name; - else - for (int i = 0; i < 16; i++) - if (lhs.hash[i] != rhs.hash[i]) - return lhs.hash[i] < rhs.hash[i]; - return false; - } - }; - - struct SchemaClass { - management::ManagementObject::writeSchemaCall_t writeSchemaCall; - uint8_t kind; - - SchemaClass(const management::ManagementObject::writeSchemaCall_t call, - const uint8_t _kind) : writeSchemaCall(call), kind(_kind) {} - }; - - struct QueuedMethod { - QueuedMethod(const std::string& _cid, const std::string& _rte, const std::string& _rtk, const std::string& _body, const std::string& _uid) : - cid(_cid), replyToExchange(_rte), replyToKey(_rtk), body(_body), userId(_uid) {} - - std::string cid; - std::string replyToExchange; - std::string replyToKey; - std::string body; - std::string userId; - }; - - typedef std::deque<QueuedMethod*> MethodQueue; - typedef std::map<SchemaClassKey, SchemaClass, SchemaClassKeyComp> ClassMap; - typedef std::map<std::string, ClassMap> PackageMap; - - PackageMap packages; - AgentAttachment attachment; - - typedef std::map<ObjectId, boost::shared_ptr<ManagementObject> > ObjectMap; - - ObjectMap managementObjects; - ObjectMap newManagementObjects; - MethodQueue methodQueue; - - void received (client::Message& msg); - - qpid::types::Variant::Map attrMap; - std::string name_address; - std::string vendorNameKey; // vendor name with "." --> "_" - std::string productNameKey; // product name with "." --> "_" - std::string instanceNameKey; // agent instance with "." --> "_" - uint16_t interval; - bool extThread; - sys::PipeHandle* pipeHandle; - uint64_t nextObjectId; - cb_t notifyCallback; - void* notifyContext; - Notifyable* notifyable; - bool inCallback; - std::string storeFile; - sys::Mutex agentLock; - sys::Mutex addLock; - framing::Uuid systemId; - client::ConnectionSettings connectionSettings; - bool initialized; - bool connected; - bool useMapMsg; - std::string lastFailure; - std::string topicExchange; - std::string directExchange; - qpid::sys::Duration schemaTimestamp; - - bool publishAllData; - uint32_t requestedBrokerBank; - uint32_t requestedAgentBank; - uint32_t assignedBrokerBank; - uint32_t assignedAgentBank; - uint16_t bootSequence; - - // Maximum # of objects allowed in a single V2 response - // message. - uint32_t maxV2ReplyObjs; - - static const uint8_t DEBUG_OFF = 0; - static const uint8_t DEBUG_CONN = 1; - static const uint8_t DEBUG_PROTO = 2; - static const uint8_t DEBUG_PUBLISH = 3; - -# define MA_BUFFER_SIZE 65536 - char outputBuffer[MA_BUFFER_SIZE]; - char eventBuffer[MA_BUFFER_SIZE]; - - friend class ConnectionThread; - class ConnectionThread : public sys::Runnable - { - typedef boost::shared_ptr<client::SubscriptionManager> shared_ptr; - - bool operational; - ManagementAgentImpl& agent; - framing::Uuid sessionId; - client::Connection connection; - client::Session session; - ConnectionThread::shared_ptr subscriptions; - std::stringstream queueName; - mutable sys::Mutex connLock; - bool shutdown; - bool sleeping; - void run(); - public: - ConnectionThread(ManagementAgentImpl& _agent) : - operational(false), agent(_agent), - shutdown(false), sleeping(false) {} - ~ConnectionThread(); - void sendBuffer(qpid::framing::Buffer& buf, - uint32_t length, - const std::string& exchange, - const std::string& routingKey); - void sendBuffer(const std::string& data, - const std::string& cid, - const qpid::types::Variant::Map headers, - const std::string& exchange, - const std::string& routingKey, - const std::string& contentType="amqp/map", - uint64_t ttl_msec=0); - void sendMessage(qpid::client::Message msg, - const std::string& exchange, - const std::string& routingKey); - void bindToBank(uint32_t brokerBank, uint32_t agentBank); - void close(); - bool isSleeping() const; - }; - - class PublishThread : public sys::Runnable - { - ManagementAgentImpl& agent; - void run(); - bool shutdown; - public: - PublishThread(ManagementAgentImpl& _agent) : - agent(_agent), shutdown(false) {} - void close() { shutdown = true; } - }; - - ConnectionThread connThreadBody; - sys::Thread connThread; - PublishThread pubThreadBody; - sys::Thread pubThread; - - static const std::string storeMagicNumber; - - void startProtocol(); - void storeData(bool requested=false); - void retrieveData(std::string& vendor, std::string& product, std::string& inst); - PackageMap::iterator findOrAddPackage(const std::string& name); - void moveNewObjectsLH(const sys::Mutex::ScopedLock& agentLock); - void addClassLocal (uint8_t classKind, - PackageMap::iterator pIter, - const std::string& className, - uint8_t* md5Sum, - management::ManagementObject::writeSchemaCall_t schemaCall); - void encodePackageIndication (framing::Buffer& buf, - PackageMap::iterator pIter); - void encodeClassIndication (framing::Buffer& buf, - PackageMap::iterator pIter, - ClassMap::iterator cIter); - void encodeHeader (framing::Buffer& buf, uint8_t opcode, uint32_t seq = 0); - qpid::types::Variant::Map mapEncodeSchemaId(const std::string& pname, - const std::string& cname, - const uint8_t *md5Sum, - uint8_t type=ManagementItem::CLASS_KIND_TABLE); - bool checkHeader (framing::Buffer& buf, uint8_t *opcode, uint32_t *seq); - void sendHeartbeat(); - void sendException(const std::string& replyToExchange, const std::string& replyToKey, const std::string& cid, - const std::string& text, uint32_t code=1); - void handlePackageRequest (qpid::framing::Buffer& inBuffer); - void handleClassQuery (qpid::framing::Buffer& inBuffer); - void handleSchemaRequest (qpid::framing::Buffer& inBuffer, uint32_t sequence, const std::string& rte, const std::string& rtk); - void invokeMethodRequest (const std::string& body, const std::string& cid, const std::string& rte, const std::string& rtk, const std::string& userId); - - void handleGetQuery (const std::string& body, const std::string& cid, const std::string& rte, const std::string& rtk); - void handleLocateRequest (const std::string& body, const std::string& sequence, const std::string& rte, const std::string& rtk); - void handleMethodRequest (const std::string& body, const std::string& sequence, const std::string& rte, const std::string& rtk, const std::string& userId); - void handleConsoleAddedIndication(); - void getHeartbeatContent (qpid::types::Variant::Map& map); -}; - -}} - -#endif /*!_qpid_agent_ManagementAgentImpl_*/ diff --git a/qpid/cpp/src/qpid/amqp/DataBuilder.cpp b/qpid/cpp/src/qpid/amqp/DataBuilder.cpp new file mode 100644 index 0000000000..91c9393457 --- /dev/null +++ b/qpid/cpp/src/qpid/amqp/DataBuilder.cpp @@ -0,0 +1,194 @@ +/* + * + * 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 "DataBuilder.h" +#include "CharSequence.h" +#include "qpid/log/Statement.h" +#include "qpid/types/encodings.h" + +namespace qpid { +namespace amqp { + +void DataBuilder::onNull(const Descriptor*) +{ + handle(qpid::types::Variant()); +} +void DataBuilder::onBoolean(bool v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onUByte(uint8_t v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onUShort(uint16_t v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onUInt(uint32_t v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onULong(uint64_t v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onByte(int8_t v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onShort(int16_t v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onInt(int32_t v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onLong(int64_t v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onFloat(float v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onDouble(double v, const Descriptor*) +{ + handle(v); +} +void DataBuilder::onUuid(const CharSequence& v, const Descriptor*) +{ + if (v.size == qpid::types::Uuid::SIZE) { + handle(qpid::types::Uuid(v.data)); + } +} +void DataBuilder::onTimestamp(int64_t v, const Descriptor*) +{ + handle(v); +} + +void DataBuilder::handle(const qpid::types::Variant& v) +{ + switch (nested.top()->getType()) { + case qpid::types::VAR_MAP: + nested.push(&nested.top()->asMap()[v.asString()]); + break; + case qpid::types::VAR_LIST: + nested.top()->asList().push_back(v); + break; + default: + *(nested.top()) = v; + nested.pop(); + break; + } +} + +void DataBuilder::onBinary(const CharSequence& v, const Descriptor*) +{ + onString(std::string(v.data, v.size), qpid::types::encodings::BINARY); +} +void DataBuilder::onString(const CharSequence& v, const Descriptor*) +{ + onString(std::string(v.data, v.size), qpid::types::encodings::UTF8); +} +void DataBuilder::onSymbol(const CharSequence& v, const Descriptor*) +{ + onString(std::string(v.data, v.size), qpid::types::encodings::ASCII); +} + +void DataBuilder::onString(const std::string& value, const std::string& encoding) +{ + switch (nested.top()->getType()) { + case qpid::types::VAR_MAP: + nested.push(&nested.top()->asMap()[value]); + break; + case qpid::types::VAR_LIST: + nested.top()->asList().push_back(qpid::types::Variant(value)); + nested.top()->asList().back().setEncoding(encoding); + break; + default: + qpid::types::Variant& v = *(nested.top()); + v = value; + v.setEncoding(encoding); + nested.pop(); + break; + } +} + +bool DataBuilder::proceed() +{ + return !nested.empty(); +} + +bool DataBuilder::nest(const qpid::types::Variant& n) +{ + switch (nested.top()->getType()) { + case qpid::types::VAR_MAP: + QPID_LOG(error, QPID_MSG("Expecting map key; got " << n)); + break; + case qpid::types::VAR_LIST: + nested.top()->asList().push_back(n); + nested.push(&nested.top()->asList().back()); + break; + default: + qpid::types::Variant& value = *(nested.top()); + value = n; + nested.pop(); + nested.push(&value); + break; + } + return true; +} + +bool DataBuilder::onStartList(uint32_t, const CharSequence&, const CharSequence&, const Descriptor*) +{ + return nest(qpid::types::Variant::List()); +} +void DataBuilder::onEndList(uint32_t /*count*/, const Descriptor*) +{ + nested.pop(); +} +bool DataBuilder::onStartMap(uint32_t /*count*/, const CharSequence&, const CharSequence&, const Descriptor*) +{ + return nest(qpid::types::Variant::Map()); +} +void DataBuilder::onEndMap(uint32_t /*count*/, const Descriptor*) +{ + nested.pop(); +} +bool DataBuilder::onStartArray(uint32_t count, const CharSequence&, const Constructor&, const Descriptor*) +{ + return onStartList(count, CharSequence::create(), CharSequence::create(), 0); +} +void DataBuilder::onEndArray(uint32_t count, const Descriptor*) +{ + onEndList(count, 0); +} +qpid::types::Variant& DataBuilder::getValue() +{ + return base; +} +DataBuilder::DataBuilder(qpid::types::Variant v) : base(v) +{ + nested.push(&base); +} +DataBuilder::~DataBuilder() {} +}} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/DataBuilder.h b/qpid/cpp/src/qpid/amqp/DataBuilder.h new file mode 100644 index 0000000000..51ee3da5f8 --- /dev/null +++ b/qpid/cpp/src/qpid/amqp/DataBuilder.h @@ -0,0 +1,79 @@ +#ifndef QPID_AMQP_DATABUILDER_H +#define QPID_AMQP_DATABUILDER_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 "Reader.h" +#include "qpid/types/Variant.h" +#include "qpid/CommonImportExport.h" +#include <stack> + +namespace qpid { +namespace amqp { + +/** + * Utility to build a Variant based structure (or value) from a data stream + */ +class DataBuilder : public Reader +{ + public: + QPID_COMMON_EXTERN DataBuilder(qpid::types::Variant); + QPID_COMMON_EXTERN virtual ~DataBuilder(); + QPID_COMMON_EXTERN void onNull(const Descriptor*); + QPID_COMMON_EXTERN void onBoolean(bool, const Descriptor*); + QPID_COMMON_EXTERN void onUByte(uint8_t, const Descriptor*); + QPID_COMMON_EXTERN void onUShort(uint16_t, const Descriptor*); + QPID_COMMON_EXTERN void onUInt(uint32_t, const Descriptor*); + QPID_COMMON_EXTERN void onULong(uint64_t, const Descriptor*); + QPID_COMMON_EXTERN void onByte(int8_t, const Descriptor*); + QPID_COMMON_EXTERN void onShort(int16_t, const Descriptor*); + QPID_COMMON_EXTERN void onInt(int32_t, const Descriptor*); + QPID_COMMON_EXTERN void onLong(int64_t, const Descriptor*); + QPID_COMMON_EXTERN void onFloat(float, const Descriptor*); + QPID_COMMON_EXTERN void onDouble(double, const Descriptor*); + QPID_COMMON_EXTERN void onUuid(const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN void onTimestamp(int64_t, const Descriptor*); + + QPID_COMMON_EXTERN void onBinary(const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN void onString(const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN void onSymbol(const CharSequence&, const Descriptor*); + + QPID_COMMON_EXTERN bool onStartList(uint32_t /*count*/, const CharSequence&, const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN bool onStartMap(uint32_t /*count*/, const CharSequence&, const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN bool onStartArray(uint32_t /*count*/, const CharSequence&, const Constructor&, const Descriptor*); + QPID_COMMON_EXTERN void onEndList(uint32_t /*count*/, const Descriptor*); + QPID_COMMON_EXTERN void onEndMap(uint32_t /*count*/, const Descriptor*); + QPID_COMMON_EXTERN void onEndArray(uint32_t /*count*/, const Descriptor*); + + QPID_COMMON_EXTERN bool proceed(); + QPID_COMMON_EXTERN qpid::types::Variant& getValue(); + private: + qpid::types::Variant base; + std::stack<qpid::types::Variant*> nested; + std::string key; + + void handle(const qpid::types::Variant& v); + bool nest(const qpid::types::Variant& v); + void onString(const std::string&, const std::string&); +}; +}} // namespace qpid::amqp + +#endif /*!QPID_AMQP_DATABUILDER_H*/ diff --git a/qpid/cpp/src/qpid/amqp/Decoder.cpp b/qpid/cpp/src/qpid/amqp/Decoder.cpp index 1d5abc99c7..1058f83e38 100644 --- a/qpid/cpp/src/qpid/amqp/Decoder.cpp +++ b/qpid/cpp/src/qpid/amqp/Decoder.cpp @@ -22,6 +22,7 @@ #include "qpid/amqp/CharSequence.h" #include "qpid/amqp/Constructor.h" #include "qpid/amqp/Descriptor.h" +#include "qpid/amqp/MapBuilder.h" #include "qpid/amqp/Reader.h" #include "qpid/amqp/typecodes.h" #include "qpid/types/Uuid.h" @@ -34,121 +35,13 @@ namespace amqp { using namespace qpid::amqp::typecodes; -Decoder::Decoder(const char* d, size_t s) : start(d), size(s), position(0) {} +Decoder::Decoder(const char* d, size_t s) : start(d), size(s), position(0), current(0) {} -namespace { -class MapBuilder : public Reader -{ - public: - void onNull(const Descriptor*) - { - qpid::types::Variant v; - handle(v, NULL_NAME); - } - void onBoolean(bool v, const Descriptor*) - { - handle(v, BOOLEAN_NAME); - } - void onUByte(uint8_t v, const Descriptor*) - { - handle(v, UBYTE_NAME); - } - void onUShort(uint16_t v, const Descriptor*) - { - handle(v, USHORT_NAME); - } - void onUInt(uint32_t v, const Descriptor*) - { - handle(v, UINT_NAME); - } - void onULong(uint64_t v, const Descriptor*) - { - handle(v, ULONG_NAME); - } - void onByte(int8_t v, const Descriptor*) - { - handle(v, BYTE_NAME); - } - void onShort(int16_t v, const Descriptor*) - { - handle(v, SHORT_NAME); - } - void onInt(int32_t v, const Descriptor*) - { - handle(v, INT_NAME); - } - void onLong(int64_t v, const Descriptor*) - { - handle(v, LONG_NAME); - } - void onFloat(float v, const Descriptor*) - { - handle(v, FLOAT_NAME); - } - void onDouble(double v, const Descriptor*) - { - handle(v, DOUBLE_NAME); - } - void onUuid(const CharSequence& v, const Descriptor*) - { - handle(v, UUID_NAME); - } - void onTimestamp(int64_t v, const Descriptor*) - { - handle(v, TIMESTAMP_NAME); - } - void onBinary(const CharSequence& v, const Descriptor*) - { - handle(v); - } - void onString(const CharSequence& v, const Descriptor*) - { - handle(v); - } - void onSymbol(const CharSequence& v, const Descriptor*) - { - handle(v); - } - MapBuilder(qpid::types::Variant::Map& m) : map(m), state(KEY) {} - private: - qpid::types::Variant::Map& map; - enum {KEY, SKIP, VALUE} state; - std::string key; - - template <typename T> void handle(T value, const std::string& name) - { - switch (state) { - case KEY: - QPID_LOG(warning, "Ignoring key of type " << name); - state = SKIP; - break; - case VALUE: - map[key] = value; - case SKIP: - state = KEY; - break; - } - } - void handle(const CharSequence& value) - { - switch (state) { - case KEY: - key = value.str(); - state = VALUE; - break; - case VALUE: - map[key] = value.str(); - case SKIP: - state = KEY; - break; - } - } -}; -} void Decoder::readMap(qpid::types::Variant::Map& map) { - MapBuilder builder(map); + MapBuilder builder; read(builder); + map = builder.getMap(); } qpid::types::Variant::Map Decoder::readMap() @@ -168,6 +61,7 @@ void Decoder::read(Reader& reader) void Decoder::readOne(Reader& reader) { const char* temp = start + position; + current = position; Constructor c = readConstructor(); if (c.isDescribed) reader.onDescriptor(c.descriptor, temp); readValue(reader, c.code, c.isDescribed ? &c.descriptor : 0); @@ -263,7 +157,7 @@ void Decoder::readValue(Reader& reader, uint8_t code, const Descriptor* descript break; case LIST0: - reader.onStartList(0, CharSequence::create(), descriptor); + reader.onStartList(0, CharSequence::create(), getCurrent(0), descriptor); reader.onEndList(0, descriptor); break; case LIST8: @@ -333,7 +227,7 @@ void Decoder::readArray32(Reader& reader, const Descriptor* descriptor) void Decoder::readList(Reader& reader, uint32_t size, uint32_t count, const Descriptor* descriptor) { - if (reader.onStartList(count, CharSequence::create(data(), size), descriptor)) { + if (reader.onStartList(count, CharSequence::create(data(), size), getCurrent(size), descriptor)) { for (uint32_t i = 0; i < count; ++i) { readOne(reader); } @@ -345,7 +239,7 @@ void Decoder::readList(Reader& reader, uint32_t size, uint32_t count, const Desc } void Decoder::readMap(Reader& reader, uint32_t size, uint32_t count, const Descriptor* descriptor) { - if (reader.onStartMap(count, CharSequence::create(data(), size), descriptor)) { + if (reader.onStartMap(count, CharSequence::create(data(), size), getCurrent(size), descriptor)) { for (uint32_t i = 0; i < count; ++i) { readOne(reader); } @@ -401,7 +295,7 @@ Descriptor Decoder::readDescriptor() case ULONG_ZERO: return Descriptor((uint64_t) 0); default: - throw qpid::Exception(QPID_MSG("Expected descriptor of type ulong or symbol; found " << code)); + throw qpid::Exception(QPID_MSG("Expected descriptor of type ulong or symbol; found " << (int)code)); } } @@ -542,4 +436,10 @@ CharSequence Decoder::readRawUuid() size_t Decoder::getPosition() const { return position; } size_t Decoder::getSize() const { return size; } void Decoder::resetSize(size_t s) { size = s; } + +CharSequence Decoder::getCurrent(size_t remaining) const +{ + return CharSequence::create(start + current, (position-current)+remaining); +} + }} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/Decoder.h b/qpid/cpp/src/qpid/amqp/Decoder.h index 7ddfe0f17f..a78518be2b 100644 --- a/qpid/cpp/src/qpid/amqp/Decoder.h +++ b/qpid/cpp/src/qpid/amqp/Decoder.h @@ -77,6 +77,7 @@ class Decoder const char* const start; size_t size; size_t position; + size_t current; void readOne(Reader& reader); void readValue(Reader& reader, uint8_t code, const Descriptor* descriptor); @@ -92,7 +93,7 @@ class Decoder CharSequence readRawUuid(); Constructor readConstructor(); const char* data(); - + CharSequence getCurrent(size_t remaining) const; }; }} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/Descriptor.cpp b/qpid/cpp/src/qpid/amqp/Descriptor.cpp index 1d2df01e6e..384eba15b0 100644 --- a/qpid/cpp/src/qpid/amqp/Descriptor.cpp +++ b/qpid/cpp/src/qpid/amqp/Descriptor.cpp @@ -59,7 +59,7 @@ std::ostream& operator<<(std::ostream& os, const Descriptor& d) else os << "null"; break; case Descriptor::NUMERIC: - os << d.value.code; + os << "0x" << std::hex << d.value.code; break; } return os; diff --git a/qpid/cpp/src/qpid/amqp/Descriptor.h b/qpid/cpp/src/qpid/amqp/Descriptor.h index 789f4dcc63..b9a83628e7 100644 --- a/qpid/cpp/src/qpid/amqp/Descriptor.h +++ b/qpid/cpp/src/qpid/amqp/Descriptor.h @@ -42,13 +42,13 @@ struct Descriptor SYMBOLIC } type; - Descriptor(uint64_t code); - Descriptor(const CharSequence& symbol); - bool match(const std::string&, uint64_t) const; - size_t getSize() const; + QPID_COMMON_EXTERN Descriptor(uint64_t code); + QPID_COMMON_EXTERN Descriptor(const CharSequence& symbol); + QPID_COMMON_EXTERN bool match(const std::string&, uint64_t) const; + QPID_COMMON_EXTERN size_t getSize() const; }; -std::ostream& operator<<(std::ostream& os, const Descriptor& d); +QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const Descriptor& d); }} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/Encoder.cpp b/qpid/cpp/src/qpid/amqp/Encoder.cpp index 549b6d1e4e..627cc4aed6 100644 --- a/qpid/cpp/src/qpid/amqp/Encoder.cpp +++ b/qpid/cpp/src/qpid/amqp/Encoder.cpp @@ -23,11 +23,15 @@ #include "qpid/amqp/Descriptor.h" #include "qpid/amqp/typecodes.h" #include "qpid/types/Uuid.h" +#include "qpid/types/Variant.h" +#include "qpid/types/encodings.h" #include "qpid/log/Statement.h" #include "qpid/Exception.h" #include <assert.h> #include <string.h> +using namespace qpid::types::encodings; + namespace qpid { namespace amqp { @@ -373,6 +377,87 @@ void Encoder::endArray32(size_t count, void* token) end<uint32_t>(count, token, data+position); } +void Encoder::writeMap(const std::map<std::string, qpid::types::Variant>& value, const Descriptor* d, bool large) +{ + void* token = large ? startMap32(d) : startMap8(d); + for (qpid::types::Variant::Map::const_iterator i = value.begin(); i != value.end(); ++i) { + writeString(i->first); + writeValue(i->second); + } + if (large) endMap32(value.size()*2, token); + else endMap8(value.size()*2, token); +} + +void Encoder::writeList(const std::list<qpid::types::Variant>& value, const Descriptor* d, bool large) +{ + void* token = large ? startList32(d) : startList8(d); + for (qpid::types::Variant::List::const_iterator i = value.begin(); i != value.end(); ++i) { + writeValue(*i); + } + if (large) endList32(value.size(), token); + else endList8(value.size(), token); +} + +void Encoder::writeValue(const qpid::types::Variant& value, const Descriptor* d) +{ + switch (value.getType()) { + case qpid::types::VAR_VOID: + writeNull(d); + break; + case qpid::types::VAR_BOOL: + writeBoolean(value.asBool(), d); + break; + case qpid::types::VAR_UINT8: + writeUByte(value.asUint8(), d); + break; + case qpid::types::VAR_UINT16: + writeUShort(value.asUint16(), d); + break; + case qpid::types::VAR_UINT32: + writeUInt(value.asUint32(), d); + break; + case qpid::types::VAR_UINT64: + writeULong(value.asUint64(), d); + break; + case qpid::types::VAR_INT8: + writeByte(value.asInt8(), d); + break; + case qpid::types::VAR_INT16: + writeShort(value.asInt16(), d); + break; + case qpid::types::VAR_INT32: + writeInt(value.asInt32(), d); + break; + case qpid::types::VAR_INT64: + writeLong(value.asInt64(), d); + break; + case qpid::types::VAR_FLOAT: + writeFloat(value.asFloat(), d); + break; + case qpid::types::VAR_DOUBLE: + writeDouble(value.asDouble(), d); + break; + case qpid::types::VAR_STRING: + if (value.getEncoding() == UTF8) { + writeString(value.getString(), d); + } else if (value.getEncoding() == ASCII) { + writeSymbol(value.getString(), d); + } else { + writeBinary(value.getString(), d); + } + break; + case qpid::types::VAR_MAP: + writeMap(value.asMap(), d); + break; + case qpid::types::VAR_LIST: + writeList(value.asList(), d); + break; + case qpid::types::VAR_UUID: + writeUuid(value.asUuid(), d); + break; + } + +} void Encoder::writeDescriptor(const Descriptor& d) { diff --git a/qpid/cpp/src/qpid/amqp/Encoder.h b/qpid/cpp/src/qpid/amqp/Encoder.h index c661e4ac5d..e79ed76726 100644 --- a/qpid/cpp/src/qpid/amqp/Encoder.h +++ b/qpid/cpp/src/qpid/amqp/Encoder.h @@ -23,12 +23,15 @@ */ #include "qpid/sys/IntegerTypes.h" #include "qpid/amqp/Constructor.h" +#include <list> +#include <map> #include <stddef.h> #include <string> namespace qpid { namespace types { class Uuid; +class Variant; } namespace amqp { struct CharSequence; @@ -74,7 +77,7 @@ class Encoder void writeString(const CharSequence&, const Descriptor* d=0); void writeString(const std::string&, const Descriptor* d=0); void writeBinary(const CharSequence&, const Descriptor* d=0); - void writeBinary(const std::string&, const Descriptor* d=0); + QPID_COMMON_EXTERN void writeBinary(const std::string&, const Descriptor* d=0); void* startList8(const Descriptor* d=0); void* startList32(const Descriptor* d=0); @@ -91,9 +94,13 @@ class Encoder void endArray8(size_t count, void*); void endArray32(size_t count, void*); + QPID_COMMON_EXTERN void writeValue(const qpid::types::Variant&, const Descriptor* d=0); + QPID_COMMON_EXTERN void writeMap(const std::map<std::string, qpid::types::Variant>& value, const Descriptor* d=0, bool large=true); + QPID_COMMON_EXTERN void writeList(const std::list<qpid::types::Variant>& value, const Descriptor* d=0, bool large=true); + void writeDescriptor(const Descriptor&); - Encoder(char* data, size_t size); - size_t getPosition(); + QPID_COMMON_EXTERN Encoder(char* data, size_t size); + QPID_COMMON_EXTERN size_t getPosition(); void resetPosition(size_t p); char* skip(size_t); void writeBytes(const char* bytes, size_t count); diff --git a/qpid/cpp/src/qpid/console/Agent.cpp b/qpid/cpp/src/qpid/amqp/ListBuilder.cpp index fa76a13583..f2ca8e8805 100644 --- a/qpid/cpp/src/qpid/console/Agent.cpp +++ b/qpid/cpp/src/qpid/amqp/ListBuilder.cpp @@ -7,9 +7,9 @@ * 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 @@ -18,13 +18,16 @@ * under the License. * */ +#include "ListBuilder.h" + +namespace qpid { +namespace amqp { -#include "qpid/console/Agent.h" +ListBuilder::ListBuilder() : DataBuilder(qpid::types::Variant::List()) {} -std::ostream& qpid::console::operator<<(std::ostream& o, const Agent& agent) +qpid::types::Variant::List& ListBuilder::getList() { - o << "Agent at bank " << agent.getBrokerBank() << "." << agent.getAgentBank() << - " (" << agent.getLabel() << ")"; - return o; + return getValue().asList(); } +}} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/ListBuilder.h b/qpid/cpp/src/qpid/amqp/ListBuilder.h new file mode 100644 index 0000000000..825f384f56 --- /dev/null +++ b/qpid/cpp/src/qpid/amqp/ListBuilder.h @@ -0,0 +1,41 @@ +#ifndef QPID_AMQP_LISTBUILDER_H +#define QPID_AMQP_LISTBUILDER_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 "DataBuilder.h" +#include "qpid/CommonImportExport.h" + +namespace qpid { +namespace amqp { + +/** + * Utility to build a Variant::List from a data stream + */ +class ListBuilder : public DataBuilder +{ + public: + QPID_COMMON_EXTERN ListBuilder(); + QPID_COMMON_EXTERN qpid::types::Variant::List& getList(); +}; +}} // namespace qpid::amqp + +#endif /*!QPID_AMQP_LISTBUILDER_H*/ diff --git a/qpid/cpp/src/qpid/amqp/ListReader.h b/qpid/cpp/src/qpid/amqp/ListReader.h index dce874bf2f..fafe2a1f9c 100644 --- a/qpid/cpp/src/qpid/amqp/ListReader.h +++ b/qpid/cpp/src/qpid/amqp/ListReader.h @@ -53,10 +53,10 @@ class ListReader : public Reader virtual void onString(const CharSequence& v, const Descriptor* descriptor) { getReader().onString(v, descriptor); } virtual void onSymbol(const CharSequence& v, const Descriptor* descriptor) { getReader().onSymbol(v, descriptor); } - virtual bool onStartList(uint32_t count, const CharSequence& v, const Descriptor* descriptor) + virtual bool onStartList(uint32_t count, const CharSequence& elements, const CharSequence& all, const Descriptor* descriptor) { ++level; - getReader().onStartList(count, v, descriptor); + getReader().onStartList(count, elements, all, descriptor); return false; } virtual void onEndList(uint32_t count, const Descriptor* descriptor) @@ -64,10 +64,10 @@ class ListReader : public Reader --level; getReader().onEndList(count, descriptor); } - virtual bool onStartMap(uint32_t count, const CharSequence& v, const Descriptor* descriptor) + virtual bool onStartMap(uint32_t count, const CharSequence& elements, const CharSequence& all, const Descriptor* descriptor) { ++level; - getReader().onStartMap(count, v, descriptor); + getReader().onStartMap(count, elements, all, descriptor); return false; } virtual void onEndMap(uint32_t count, const Descriptor* descriptor) diff --git a/qpid/cpp/src/qpid/amqp/MapBuilder.cpp b/qpid/cpp/src/qpid/amqp/MapBuilder.cpp index a554497791..ce8eea038e 100644 --- a/qpid/cpp/src/qpid/amqp/MapBuilder.cpp +++ b/qpid/cpp/src/qpid/amqp/MapBuilder.cpp @@ -19,112 +19,12 @@ * */ #include "MapBuilder.h" -#include <assert.h> namespace qpid { namespace amqp { -namespace { -const std::string BINARY("binary"); -const std::string UTF8("utf8"); -const std::string ASCII("ascii"); -} - +MapBuilder::MapBuilder() : DataBuilder(qpid::types::Variant::Map()) {} qpid::types::Variant::Map MapBuilder::getMap() { - return map; -} -const qpid::types::Variant::Map MapBuilder::getMap() const -{ - return map; -} - -void MapBuilder::onNullValue(const CharSequence& key, const Descriptor*) -{ - map[std::string(key.data, key.size)] = qpid::types::Variant(); -} -void MapBuilder::onBooleanValue(const CharSequence& key, bool value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} -void MapBuilder::onUByteValue(const CharSequence& key, uint8_t value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onUShortValue(const CharSequence& key, uint16_t value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onUIntValue(const CharSequence& key, uint32_t value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onULongValue(const CharSequence& key, uint64_t value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onByteValue(const CharSequence& key, int8_t value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onShortValue(const CharSequence& key, int16_t value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onIntValue(const CharSequence& key, int32_t value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onLongValue(const CharSequence& key, int64_t value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onFloatValue(const CharSequence& key, float value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onDoubleValue(const CharSequence& key, double value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onUuidValue(const CharSequence& key, const CharSequence& value, const Descriptor*) -{ - assert(value.size == 16); - map[std::string(key.data, key.size)] = qpid::types::Uuid(value.data); -} - -void MapBuilder::onTimestampValue(const CharSequence& key, int64_t value, const Descriptor*) -{ - map[std::string(key.data, key.size)] = value; -} - -void MapBuilder::onBinaryValue(const CharSequence& key, const CharSequence& value, const Descriptor*) -{ - qpid::types::Variant& v = map[std::string(key.data, key.size)]; - v = std::string(value.data, value.size); - v.setEncoding(BINARY); -} - -void MapBuilder::onStringValue(const CharSequence& key, const CharSequence& value, const Descriptor*) -{ - qpid::types::Variant& v = map[std::string(key.data, key.size)]; - v = std::string(value.data, value.size); - v.setEncoding(UTF8); -} - -void MapBuilder::onSymbolValue(const CharSequence& key, const CharSequence& value, const Descriptor*) -{ - qpid::types::Variant& v = map[std::string(key.data, key.size)]; - v = std::string(value.data, value.size); - v.setEncoding(ASCII); + return getValue().asMap(); } }} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/MapBuilder.h b/qpid/cpp/src/qpid/amqp/MapBuilder.h index 0e3b95f633..fd94ae04af 100644 --- a/qpid/cpp/src/qpid/amqp/MapBuilder.h +++ b/qpid/cpp/src/qpid/amqp/MapBuilder.h @@ -21,42 +21,20 @@ * under the License. * */ -#include "MapReader.h" -#include "qpid/types/Variant.h" +#include "DataBuilder.h" +#include "qpid/CommonImportExport.h" namespace qpid { namespace amqp { /** - * Utility to build a Variant::Map from a data stream (doesn't handle - * nested maps or lists yet) + * Utility to build a Variant::Map from a data stream */ -class MapBuilder : public MapReader +class MapBuilder : public DataBuilder { public: - void onNullValue(const CharSequence& /*key*/, const Descriptor*); - void onBooleanValue(const CharSequence& /*key*/, bool, const Descriptor*); - void onUByteValue(const CharSequence& /*key*/, uint8_t, const Descriptor*); - void onUShortValue(const CharSequence& /*key*/, uint16_t, const Descriptor*); - void onUIntValue(const CharSequence& /*key*/, uint32_t, const Descriptor*); - void onULongValue(const CharSequence& /*key*/, uint64_t, const Descriptor*); - void onByteValue(const CharSequence& /*key*/, int8_t, const Descriptor*); - void onShortValue(const CharSequence& /*key*/, int16_t, const Descriptor*); - void onIntValue(const CharSequence& /*key*/, int32_t, const Descriptor*); - void onLongValue(const CharSequence& /*key*/, int64_t, const Descriptor*); - void onFloatValue(const CharSequence& /*key*/, float, const Descriptor*); - void onDoubleValue(const CharSequence& /*key*/, double, const Descriptor*); - void onUuidValue(const CharSequence& /*key*/, const CharSequence&, const Descriptor*); - void onTimestampValue(const CharSequence& /*key*/, int64_t, const Descriptor*); - - void onBinaryValue(const CharSequence& /*key*/, const CharSequence&, const Descriptor*); - void onStringValue(const CharSequence& /*key*/, const CharSequence&, const Descriptor*); - void onSymbolValue(const CharSequence& /*key*/, const CharSequence&, const Descriptor*); - - qpid::types::Variant::Map getMap(); - const qpid::types::Variant::Map getMap() const; - private: - qpid::types::Variant::Map map; + QPID_COMMON_EXTERN MapBuilder(); + QPID_COMMON_EXTERN qpid::types::Variant::Map getMap(); }; }} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/MapReader.cpp b/qpid/cpp/src/qpid/amqp/MapReader.cpp index aff885c5d3..b6c31849f0 100644 --- a/qpid/cpp/src/qpid/amqp/MapReader.cpp +++ b/qpid/cpp/src/qpid/amqp/MapReader.cpp @@ -219,7 +219,7 @@ void MapReader::onSymbol(const CharSequence& v, const Descriptor* d) } } -bool MapReader::onStartList(uint32_t count, const CharSequence&, const Descriptor* d) +bool MapReader::onStartList(uint32_t count, const CharSequence&, const CharSequence&, const Descriptor* d) { if (!level) throw qpid::Exception(QPID_MSG("Expecting map as top level datum")); if (key) { @@ -232,7 +232,7 @@ bool MapReader::onStartList(uint32_t count, const CharSequence&, const Descripto return true; } -bool MapReader::onStartMap(uint32_t count, const CharSequence&, const Descriptor* d) +bool MapReader::onStartMap(uint32_t count, const CharSequence&, const CharSequence&, const Descriptor* d) { if (level++) { if (key) { diff --git a/qpid/cpp/src/qpid/amqp/MapReader.h b/qpid/cpp/src/qpid/amqp/MapReader.h index cb977e1326..875f919d63 100644 --- a/qpid/cpp/src/qpid/amqp/MapReader.h +++ b/qpid/cpp/src/qpid/amqp/MapReader.h @@ -68,36 +68,36 @@ class MapReader : public Reader //this class implements the Reader interface, thus acting as a transformer into a more map oriented scheme - void onNull(const Descriptor*); - void onBoolean(bool, const Descriptor*); - void onUByte(uint8_t, const Descriptor*); - void onUShort(uint16_t, const Descriptor*); - void onUInt(uint32_t, const Descriptor*); - void onULong(uint64_t, const Descriptor*); - void onByte(int8_t, const Descriptor*); - void onShort(int16_t, const Descriptor*); - void onInt(int32_t, const Descriptor*); - void onLong(int64_t, const Descriptor*); - void onFloat(float, const Descriptor*); - void onDouble(double, const Descriptor*); - void onUuid(const CharSequence&, const Descriptor*); - void onTimestamp(int64_t, const Descriptor*); + QPID_COMMON_EXTERN void onNull(const Descriptor*); + QPID_COMMON_EXTERN void onBoolean(bool, const Descriptor*); + QPID_COMMON_EXTERN void onUByte(uint8_t, const Descriptor*); + QPID_COMMON_EXTERN void onUShort(uint16_t, const Descriptor*); + QPID_COMMON_EXTERN void onUInt(uint32_t, const Descriptor*); + QPID_COMMON_EXTERN void onULong(uint64_t, const Descriptor*); + QPID_COMMON_EXTERN void onByte(int8_t, const Descriptor*); + QPID_COMMON_EXTERN void onShort(int16_t, const Descriptor*); + QPID_COMMON_EXTERN void onInt(int32_t, const Descriptor*); + QPID_COMMON_EXTERN void onLong(int64_t, const Descriptor*); + QPID_COMMON_EXTERN void onFloat(float, const Descriptor*); + QPID_COMMON_EXTERN void onDouble(double, const Descriptor*); + QPID_COMMON_EXTERN void onUuid(const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN void onTimestamp(int64_t, const Descriptor*); - void onBinary(const CharSequence&, const Descriptor*); - void onString(const CharSequence&, const Descriptor*); - void onSymbol(const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN void onBinary(const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN void onString(const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN void onSymbol(const CharSequence&, const Descriptor*); - bool onStartList(uint32_t /*count*/, const CharSequence&, const Descriptor*); - bool onStartMap(uint32_t /*count*/, const CharSequence&, const Descriptor*); - bool onStartArray(uint32_t /*count*/, const CharSequence&, const Constructor&, const Descriptor*); - void onEndList(uint32_t /*count*/, const Descriptor*); - void onEndMap(uint32_t /*count*/, const Descriptor*); - void onEndArray(uint32_t /*count*/, const Descriptor*); + QPID_COMMON_EXTERN bool onStartList(uint32_t /*count*/, const CharSequence&, const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN bool onStartMap(uint32_t /*count*/, const CharSequence&, const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN bool onStartArray(uint32_t /*count*/, const CharSequence&, const Constructor&, const Descriptor*); + QPID_COMMON_EXTERN void onEndList(uint32_t /*count*/, const Descriptor*); + QPID_COMMON_EXTERN void onEndMap(uint32_t /*count*/, const Descriptor*); + QPID_COMMON_EXTERN void onEndArray(uint32_t /*count*/, const Descriptor*); - MapReader(); - static const int SYMBOL_KEY; - static const int STRING_KEY; - void setAllowedKeyType(int); + QPID_COMMON_EXTERN MapReader(); + QPID_COMMON_EXTERN static const int SYMBOL_KEY; + QPID_COMMON_EXTERN static const int STRING_KEY; + QPID_COMMON_EXTERN void setAllowedKeyType(int); private: CharSequence key; size_t level; diff --git a/qpid/cpp/src/qpid/amqp/MessageEncoder.cpp b/qpid/cpp/src/qpid/amqp/MessageEncoder.cpp index 3b493d1de7..beaea2befd 100644 --- a/qpid/cpp/src/qpid/amqp/MessageEncoder.cpp +++ b/qpid/cpp/src/qpid/amqp/MessageEncoder.cpp @@ -156,68 +156,6 @@ void MessageEncoder::writeApplicationProperties(const qpid::types::Variant::Map& writeMap(properties, &qpid::amqp::message::APPLICATION_PROPERTIES, large); } -void MessageEncoder::writeMap(const qpid::types::Variant::Map& properties, const Descriptor* d, bool large) -{ - void* token = large ? startMap32(d) : startMap8(d); - for (qpid::types::Variant::Map::const_iterator i = properties.begin(); i != properties.end(); ++i) { - writeString(i->first); - switch (i->second.getType()) { - case qpid::types::VAR_MAP: - case qpid::types::VAR_LIST: - //not allowed (TODO: revise, only strictly true for application-properties) whereas this is now a more general method) - QPID_LOG(warning, "Ignoring nested map/list; not allowed in application-properties for AMQP 1.0"); - case qpid::types::VAR_VOID: - writeNull(); - break; - case qpid::types::VAR_BOOL: - writeBoolean(i->second); - break; - case qpid::types::VAR_UINT8: - writeUByte(i->second); - break; - case qpid::types::VAR_UINT16: - writeUShort(i->second); - break; - case qpid::types::VAR_UINT32: - writeUInt(i->second); - break; - case qpid::types::VAR_UINT64: - writeULong(i->second); - break; - case qpid::types::VAR_INT8: - writeByte(i->second); - break; - case qpid::types::VAR_INT16: - writeShort(i->second); - break; - case qpid::types::VAR_INT32: - writeInt(i->second); - break; - case qpid::types::VAR_INT64: - writeULong(i->second); - break; - case qpid::types::VAR_FLOAT: - writeFloat(i->second); - break; - case qpid::types::VAR_DOUBLE: - writeDouble(i->second); - break; - case qpid::types::VAR_STRING: - if (i->second.getEncoding() == BINARY) { - writeBinary(i->second); - } else { - writeString(i->second); - } - break; - case qpid::types::VAR_UUID: - writeUuid(i->second); - break; - } - } - if (large) endMap32(properties.size()*2, token); - else endMap8(properties.size()*2, token); -} - size_t MessageEncoder::getEncodedSize(const Header& h, const Properties& p, const qpid::types::Variant::Map& ap, const std::string& d) { return getEncodedSize(h) + getEncodedSize(p, ap, d); @@ -288,46 +226,56 @@ size_t MessageEncoder::getEncodedSizeForElements(const qpid::types::Variant::Map { size_t total = 0; for (qpid::types::Variant::Map::const_iterator i = map.begin(); i != map.end(); ++i) { - total += 1/*code*/ + encodedSize(i->first); - - switch (i->second.getType()) { - case qpid::types::VAR_MAP: - case qpid::types::VAR_LIST: - case qpid::types::VAR_VOID: - case qpid::types::VAR_BOOL: - total += 1; - break; - - case qpid::types::VAR_UINT8: - case qpid::types::VAR_INT8: - total += 2; - break; - - case qpid::types::VAR_UINT16: - case qpid::types::VAR_INT16: - total += 3; - break; - - case qpid::types::VAR_UINT32: - case qpid::types::VAR_INT32: - case qpid::types::VAR_FLOAT: - total += 5; - break; - - case qpid::types::VAR_UINT64: - case qpid::types::VAR_INT64: - case qpid::types::VAR_DOUBLE: - total += 9; - break; - - case qpid::types::VAR_UUID: - total += 17; - break; - - case qpid::types::VAR_STRING: - total += 1/*code*/ + encodedSize(i->second); - break; - } + total += 1/*code*/ + encodedSize(i->first) + getEncodedSizeForValue(i->second); + } + return total; +} + +size_t MessageEncoder::getEncodedSizeForValue(const qpid::types::Variant& value) +{ + size_t total = 0; + switch (value.getType()) { + case qpid::types::VAR_MAP: + total += getEncodedSize(value.asMap(), true); + break; + case qpid::types::VAR_LIST: + total += getEncodedSize(value.asList(), true); + break; + + case qpid::types::VAR_VOID: + case qpid::types::VAR_BOOL: + total += 1; + break; + + case qpid::types::VAR_UINT8: + case qpid::types::VAR_INT8: + total += 2; + break; + + case qpid::types::VAR_UINT16: + case qpid::types::VAR_INT16: + total += 3; + break; + + case qpid::types::VAR_UINT32: + case qpid::types::VAR_INT32: + case qpid::types::VAR_FLOAT: + total += 5; + break; + + case qpid::types::VAR_UINT64: + case qpid::types::VAR_INT64: + case qpid::types::VAR_DOUBLE: + total += 9; + break; + + case qpid::types::VAR_UUID: + total += 17; + break; + + case qpid::types::VAR_STRING: + total += 1/*code*/ + encodedSize(value.getString()); + break; } return total; } @@ -345,4 +293,20 @@ size_t MessageEncoder::getEncodedSize(const qpid::types::Variant::Map& map, bool return total; } + +size_t MessageEncoder::getEncodedSize(const qpid::types::Variant::List& list, bool alwaysUseLargeList) +{ + size_t total(0); + for (qpid::types::Variant::List::const_iterator i = list.begin(); i != list.end(); ++i) { + total += getEncodedSizeForValue(*i); + } + + //its not just the count that determines whether we can use a small list, but the aggregate size: + if (alwaysUseLargeList || list.size()*2 > 255 || total > 255) total += 4/*size*/ + 4/*count*/; + else total += 1/*size*/ + 1/*count*/; + + total += 1 /*code for list itself*/; + + return total; +} }} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/MessageEncoder.h b/qpid/cpp/src/qpid/amqp/MessageEncoder.h index 1de3d47bb2..05e1714004 100644 --- a/qpid/cpp/src/qpid/amqp/MessageEncoder.h +++ b/qpid/cpp/src/qpid/amqp/MessageEncoder.h @@ -39,7 +39,7 @@ class MessageEncoder : public Encoder virtual ~Header() {} virtual bool isDurable() const = 0; virtual uint8_t getPriority() const = 0; - virtual bool hasTtl() const = 0; + QPID_COMMON_EXTERN virtual bool hasTtl() const = 0; virtual uint32_t getTtl() const = 0; virtual bool isFirstAcquirer() const = 0; virtual uint32_t getDeliveryCount() const = 0; @@ -84,29 +84,33 @@ class MessageEncoder : public Encoder virtual void handle(MapHandler&) const = 0; }; - MessageEncoder(char* d, size_t s, bool o=false) : Encoder(d, s), optimise(o) {} - void writeHeader(const Header&); - void writeProperties(const Properties&); - void writeApplicationProperties(const ApplicationProperties&); - void writeApplicationProperties(const qpid::types::Variant::Map& properties); - void writeApplicationProperties(const qpid::types::Variant::Map& properties, bool useLargeMap); + QPID_COMMON_EXTERN MessageEncoder(char* d, size_t s) : Encoder(d, s), optimise(true) {} + QPID_COMMON_EXTERN void writeHeader(const Header&); + QPID_COMMON_EXTERN void writeProperties(const Properties&); + QPID_COMMON_EXTERN void writeApplicationProperties(const ApplicationProperties&); + QPID_COMMON_EXTERN void writeApplicationProperties(const qpid::types::Variant::Map& properties); + QPID_COMMON_EXTERN void writeApplicationProperties(const qpid::types::Variant::Map& properties, bool useLargeMap); - void writeMap(const qpid::types::Variant::Map& map, const Descriptor*, bool useLargeMap); + QPID_COMMON_EXTERN static size_t getEncodedSize(const Header&); + QPID_COMMON_EXTERN static size_t getEncodedSize(const Properties&); + QPID_COMMON_EXTERN static size_t getEncodedSize(const ApplicationProperties&); - static size_t getEncodedSize(const Header&); - static size_t getEncodedSize(const Properties&); - static size_t getEncodedSize(const ApplicationProperties&); - static size_t getEncodedSize(const Header&, const Properties&, const ApplicationProperties&, const std::string&); + QPID_COMMON_EXTERN static size_t getEncodedSize(const qpid::types::Variant::List&, bool useLargeList); + QPID_COMMON_EXTERN static size_t getEncodedSize(const qpid::types::Variant::Map&, bool useLargeMap); + + QPID_COMMON_EXTERN static size_t getEncodedSizeForValue(const qpid::types::Variant& value); + QPID_COMMON_EXTERN static size_t getEncodedSizeForContent(const std::string&); + + //used in translating 0-10 content to 1.0, to determine buffer space needed + QPID_COMMON_EXTERN static size_t getEncodedSize(const Properties&, const qpid::types::Variant::Map&, const std::string&); - static size_t getEncodedSize(const qpid::types::Variant::Map&, bool useLargeMap); - static size_t getEncodedSize(const qpid::types::Variant::Map&); - static size_t getEncodedSize(const Header&, const Properties&, const qpid::types::Variant::Map&, const std::string&); - static size_t getEncodedSize(const Properties&, const qpid::types::Variant::Map&, const std::string&); private: bool optimise; + static size_t getEncodedSize(const Header&, const Properties&, const ApplicationProperties&, const std::string&); + static size_t getEncodedSize(const Header&, const Properties&, const qpid::types::Variant::Map&, const std::string&); + static size_t getEncodedSizeForElements(const qpid::types::Variant::Map&); - static size_t getEncodedSizeForContent(const std::string&); }; }} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/MessageReader.cpp b/qpid/cpp/src/qpid/amqp/MessageReader.cpp index 1550fa1977..70374f4cd6 100644 --- a/qpid/cpp/src/qpid/amqp/MessageReader.cpp +++ b/qpid/cpp/src/qpid/amqp/MessageReader.cpp @@ -21,6 +21,7 @@ #include "qpid/amqp/MessageReader.h" #include "qpid/amqp/Descriptor.h" #include "qpid/amqp/descriptors.h" +#include "qpid/amqp/typecodes.h" #include "qpid/types/Uuid.h" #include "qpid/types/Variant.h" #include "qpid/log/Statement.h" @@ -55,40 +56,6 @@ const size_t REPLY_TO_GROUP_ID(12); } -/* -Reader& MessageReader::HeaderReader::getReader(size_t index) -{ - switch (index) { - case DURABLE: return durableReader; - case PRIORITY: return priorityReader; - case TTL: return ttlReader; - case FIRST_ACQUIRER: return firstAcquirerReader; - case DELIVERY_COUNT: return deliveryCountReader; - default: return noSuchFieldReader; - } -} - -Reader& MessageReader::PropertiesReader::getReader(size_t index) -{ - switch (index) { - case MESSAGE_ID: return messageIdReader; - case USER_ID: return userIdReader; - case TO: return toReader; - case SUBJECT: return subjectReader; - case REPLY_TO: return replyToReader; - case CORRELATION_ID: return correlationIdReader; - case CONTENT_TYPE: return contentTypeReader; - case CONTENT_ENCODING: return contentEncodingReader; - case ABSOLUTE_EXPIRY_TIME: return absoluteExpiryTimeReader; - case CREATION_TIME: return creationTimeReader; - case GROUP_ID: return groupIdReader; - case GROUP_SEQUENCE: return groupSequenceReader; - case REPLY_TO_GROUP_ID: return replyToGroupIdReader; - default: return noSuchFieldReader; - } -} -*/ - MessageReader::HeaderReader::HeaderReader(MessageReader& p) : parent(p), index(0) {} void MessageReader::HeaderReader::onBoolean(bool v, const Descriptor*) // durable, first-acquirer { @@ -132,7 +99,7 @@ void MessageReader::PropertiesReader::onUuid(const CharSequence& v, const Descri if (index == MESSAGE_ID) { parent.onMessageId(v, qpid::types::VAR_UUID); } else if (index == CORRELATION_ID) { - parent.onCorrelationId(v); + parent.onCorrelationId(v, qpid::types::VAR_UUID); } else { QPID_LOG(warning, "Unexpected message format, got uuid at index " << index << " of properties"); } @@ -154,7 +121,7 @@ void MessageReader::PropertiesReader::onBinary(const CharSequence& v, const Desc if (index == MESSAGE_ID) { parent.onMessageId(v, qpid::types::VAR_STRING); } else if (index == CORRELATION_ID) { - parent.onCorrelationId(v); + parent.onCorrelationId(v, qpid::types::VAR_STRING); } else if (index == USER_ID) { parent.onUserId(v); } else { @@ -165,9 +132,9 @@ void MessageReader::PropertiesReader::onBinary(const CharSequence& v, const Desc void MessageReader::PropertiesReader::onString(const CharSequence& v, const Descriptor*) // message-id, correlation-id, group-id, reply-to-group-id, subject, to, reply-to { if (index == MESSAGE_ID) { - parent.onMessageId(v); + parent.onMessageId(v, qpid::types::VAR_STRING); } else if (index == CORRELATION_ID) { - parent.onCorrelationId(v); + parent.onCorrelationId(v, qpid::types::VAR_STRING); } else if (index == GROUP_ID) { parent.onGroupId(v); } else if (index == REPLY_TO_GROUP_ID) { @@ -218,129 +185,76 @@ void MessageReader::PropertiesReader::onNull(const Descriptor*) { ++index; } - -/* -MessageReader::DurableReader::DurableReader(MessageReader& p) : parent(p) {} -void MessageReader::DurableReader::onBoolean(bool v, const Descriptor*) -{ - parent.onDurable(v); -} -MessageReader::PriorityReader::PriorityReader(MessageReader& p) : parent(p) {} -void MessageReader::PriorityReader::onUByte(uint8_t v, const Descriptor*) -{ - parent.onPriority(v); -} -MessageReader::TtlReader::TtlReader(MessageReader& p) : parent(p) {} -void MessageReader::TtlReader::onUInt(uint32_t v, const Descriptor*) -{ - parent.onTtl(v); -} -MessageReader::FirstAcquirerReader::FirstAcquirerReader(MessageReader& p) : parent(p) {} -void MessageReader::FirstAcquirerReader::onBoolean(bool v, const Descriptor*) -{ - parent.onFirstAcquirer(v); -} -MessageReader::DeliveryCountReader::DeliveryCountReader(MessageReader& p) : parent(p) {} -void MessageReader::DeliveryCountReader::onUInt(uint32_t v, const Descriptor*) -{ - parent.onDeliveryCount(v); -} -MessageReader::MessageIdReader::MessageIdReader(MessageReader& p) : parent(p) {} -void MessageReader::MessageIdReader::onUuid(const qpid::types::Uuid& v, const Descriptor*) -{ - parent.onMessageId(v); -} -void MessageReader::MessageIdReader::onULong(uint64_t v, const Descriptor*) +void MessageReader::PropertiesReader::onBoolean(bool, const Descriptor*) { - parent.onMessageId(v); -} -void MessageReader::MessageIdReader::onString(const CharSequence& v, const Descriptor*) -{ - parent.onMessageId(v); -} -void MessageReader::MessageIdReader::onBinary(const CharSequence& v, const Descriptor*) -{ - parent.onMessageId(v); -} -MessageReader::UserIdReader::UserIdReader(MessageReader& p) : parent(p) {} -void MessageReader::UserIdReader::onBinary(const CharSequence& v, const Descriptor*) -{ - parent.onUserId(v); -} -MessageReader::ToReader::ToReader(MessageReader& p) : parent(p) {} -void MessageReader::ToReader::onString(const CharSequence& v, const Descriptor*) -{ - parent.onTo(v); -} -MessageReader::SubjectReader::SubjectReader(MessageReader& p) : parent(p) {} -void MessageReader::SubjectReader::onString(const CharSequence& v, const Descriptor*) -{ - parent.onSubject(v); -} -MessageReader::ReplyToReader::ReplyToReader(MessageReader& p) : parent(p) {} -void MessageReader::ReplyToReader::onString(const CharSequence& v, const Descriptor*) -{ - parent.onReplyTo(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (boolean)"); + ++index; } -MessageReader::CorrelationIdReader::CorrelationIdReader(MessageReader& p) : parent(p) {} -void MessageReader::CorrelationIdReader::onUuid(const qpid::types::Uuid& v, const Descriptor*) +void MessageReader::PropertiesReader::onUByte(uint8_t, const Descriptor*) { - parent.onCorrelationId(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (ubyte)"); + ++index; } -void MessageReader::CorrelationIdReader::onULong(uint64_t v, const Descriptor*) +void MessageReader::PropertiesReader::onUShort(uint16_t, const Descriptor*) { - parent.onCorrelationId(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (ushort)"); + ++index; } -void MessageReader::CorrelationIdReader::onString(const CharSequence& v, const Descriptor*) +void MessageReader::PropertiesReader::onByte(int8_t, const Descriptor*) { - parent.onCorrelationId(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (byte)"); + ++index; } -void MessageReader::CorrelationIdReader::onBinary(const CharSequence& v, const Descriptor*) +void MessageReader::PropertiesReader::onShort(int16_t, const Descriptor*) { - parent.onCorrelationId(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (short)"); + ++index; } -MessageReader::ContentTypeReader::ContentTypeReader(MessageReader& p) : parent(p) {} -void MessageReader::ContentTypeReader::onString(const CharSequence& v, const Descriptor*) +void MessageReader::PropertiesReader::onInt(int32_t, const Descriptor*) { - parent.onContentType(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (int)"); + ++index; } -MessageReader::ContentEncodingReader::ContentEncodingReader(MessageReader& p) : parent(p) {} -void MessageReader::ContentEncodingReader::onString(const CharSequence& v, const Descriptor*) +void MessageReader::PropertiesReader::onLong(int64_t, const Descriptor*) { - parent.onContentEncoding(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (long)"); + ++index; } -MessageReader::AbsoluteExpiryTimeReader::AbsoluteExpiryTimeReader(MessageReader& p) : parent(p) {} -void MessageReader::AbsoluteExpiryTimeReader::onTimestamp(int64_t v, const Descriptor*) +void MessageReader::PropertiesReader::onFloat(float, const Descriptor*) { - parent.onAbsoluteExpiryTime(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (float)"); + ++index; } -MessageReader::CreationTimeReader::CreationTimeReader(MessageReader& p) : parent(p) {} -void MessageReader::CreationTimeReader::onTimestamp(int64_t v, const Descriptor*) +void MessageReader::PropertiesReader::onDouble(double, const Descriptor*) { - parent.onCreationTime(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (double)"); + ++index; } -MessageReader::GroupIdReader::GroupIdReader(MessageReader& p) : parent(p) {} -void MessageReader::GroupIdReader::onString(const CharSequence& v, const Descriptor*) +bool MessageReader::PropertiesReader::onStartList(uint32_t /*count*/, const CharSequence& /*elements*/, const CharSequence& /*complete*/, const Descriptor*) { - parent.onGroupId(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (list)"); + ++index; + return false; } -MessageReader::GroupSequenceReader::GroupSequenceReader(MessageReader& p) : parent(p) {} -void MessageReader::GroupSequenceReader::onUInt(uint32_t v, const Descriptor*) +bool MessageReader::PropertiesReader::onStartMap(uint32_t /*count*/, const CharSequence& /*elements*/, const CharSequence& /*complete*/, const Descriptor*) { - parent.onGroupSequence(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (map)"); + ++index; + return false; } -MessageReader::ReplyToGroupIdReader::ReplyToGroupIdReader(MessageReader& p) : parent(p) {} -void MessageReader::ReplyToGroupIdReader::onString(const CharSequence& v, const Descriptor*) +bool MessageReader::PropertiesReader::onStartArray(uint32_t /*count*/, const CharSequence&, const Constructor&, const Descriptor*) { - parent.onReplyToGroupId(v); + QPID_LOG(info, "skipping message property at index " << index << " unexpected type (array)"); + ++index; + return false; } -*/ + //header, properties, amqp-sequence, amqp-value -bool MessageReader::onStartList(uint32_t count, const CharSequence& raw, const Descriptor* descriptor) +bool MessageReader::onStartList(uint32_t count, const CharSequence& elements, const CharSequence& raw, const Descriptor* descriptor) { if (delegate) { - return delegate->onStartList(count, raw, descriptor); + return delegate->onStartList(count, elements, raw, descriptor); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got no descriptor for list."); @@ -351,8 +265,11 @@ bool MessageReader::onStartList(uint32_t count, const CharSequence& raw, const D } else if (descriptor->match(PROPERTIES_SYMBOL, PROPERTIES_CODE)) { delegate = &propertiesReader; return true; - } else if (descriptor->match(AMQP_SEQUENCE_SYMBOL, AMQP_SEQUENCE_CODE) || descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { - onBody(raw, *descriptor); + } else if (descriptor->match(AMQP_SEQUENCE_SYMBOL, AMQP_SEQUENCE_CODE)) { + onAmqpSequence(raw); + return false; + } else if (descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { + onAmqpValue(elements, qpid::amqp::typecodes::LIST_NAME); return false; } else { QPID_LOG(warning, "Unexpected described list: " << *descriptor); @@ -372,28 +289,28 @@ void MessageReader::onEndList(uint32_t count, const Descriptor* descriptor) } //delivery-annotations, message-annotations, application-properties, amqp-value -bool MessageReader::onStartMap(uint32_t count, const CharSequence& raw, const Descriptor* descriptor) +bool MessageReader::onStartMap(uint32_t count, const CharSequence& elements, const CharSequence& raw, const Descriptor* descriptor) { if (delegate) { - return delegate->onStartMap(count, raw, descriptor); + return delegate->onStartMap(count, elements, raw, descriptor); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got no descriptor for map."); return false; } else if (descriptor->match(DELIVERY_ANNOTATIONS_SYMBOL, DELIVERY_ANNOTATIONS_CODE)) { - onDeliveryAnnotations(raw); + onDeliveryAnnotations(elements, raw); return false; } else if (descriptor->match(MESSAGE_ANNOTATIONS_SYMBOL, MESSAGE_ANNOTATIONS_CODE)) { - onMessageAnnotations(raw); + onMessageAnnotations(elements, raw); return false; } else if (descriptor->match(FOOTER_SYMBOL, FOOTER_CODE)) { - onFooter(raw); + onFooter(elements, raw); return false; } else if (descriptor->match(APPLICATION_PROPERTIES_SYMBOL, APPLICATION_PROPERTIES_CODE)) { - onApplicationProperties(raw); + onApplicationProperties(elements, raw); return false; } else if (descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { - onBody(raw, *descriptor); + onAmqpValue(elements, qpid::amqp::typecodes::MAP_NAME); return false; } else { QPID_LOG(warning, "Unexpected described map: " << *descriptor); @@ -417,8 +334,10 @@ void MessageReader::onBinary(const CharSequence& bytes, const Descriptor* descri } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got binary value with no descriptor."); - } else if (descriptor->match(DATA_SYMBOL, DATA_CODE) || descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { - onBody(bytes, *descriptor); + } else if (descriptor->match(DATA_SYMBOL, DATA_CODE)) { + onData(bytes); + } else if (descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { + onAmqpValue(bytes, qpid::amqp::typecodes::BINARY_NAME); } else { QPID_LOG(warning, "Unexpected binary value with descriptor: " << *descriptor); } @@ -434,7 +353,7 @@ void MessageReader::onNull(const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant v; - onBody(v, *descriptor); + onAmqpValue(v); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got null value with no descriptor."); @@ -450,7 +369,7 @@ void MessageReader::onString(const CharSequence& v, const Descriptor* descriptor delegate->onString(v, descriptor); } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { - onBody(v, *descriptor); + onAmqpValue(v, qpid::amqp::typecodes::STRING_NAME); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got string value with no descriptor."); @@ -466,7 +385,7 @@ void MessageReader::onSymbol(const CharSequence& v, const Descriptor* descriptor delegate->onSymbol(v, descriptor); } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { - onBody(v, *descriptor); + onAmqpValue(v, qpid::amqp::typecodes::SYMBOL_NAME); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got symbol value with no descriptor."); @@ -484,7 +403,7 @@ void MessageReader::onBoolean(bool v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got boolean value with no descriptor."); @@ -502,7 +421,7 @@ void MessageReader::onUByte(uint8_t v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got ubyte value with no descriptor."); @@ -520,7 +439,7 @@ void MessageReader::onUShort(uint16_t v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got ushort value with no descriptor."); @@ -538,7 +457,7 @@ void MessageReader::onUInt(uint32_t v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got uint value with no descriptor."); @@ -556,7 +475,7 @@ void MessageReader::onULong(uint64_t v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got ulong value with no descriptor."); @@ -574,7 +493,7 @@ void MessageReader::onByte(int8_t v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got byte value with no descriptor."); @@ -592,7 +511,7 @@ void MessageReader::onShort(int16_t v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got short value with no descriptor."); @@ -610,7 +529,7 @@ void MessageReader::onInt(int32_t v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got int value with no descriptor."); @@ -628,7 +547,7 @@ void MessageReader::onLong(int64_t v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got long value with no descriptor."); @@ -646,7 +565,7 @@ void MessageReader::onFloat(float v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got float value with no descriptor."); @@ -664,7 +583,7 @@ void MessageReader::onDouble(double v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got double value with no descriptor."); @@ -681,7 +600,7 @@ void MessageReader::onUuid(const CharSequence& v, const Descriptor* descriptor) delegate->onUuid(v, descriptor); } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { - onBody(v, *descriptor); + onAmqpValue(v, qpid::amqp::typecodes::UUID_NAME); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got uuid value with no descriptor."); @@ -699,7 +618,7 @@ void MessageReader::onTimestamp(int64_t v, const Descriptor* descriptor) } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { qpid::types::Variant body = v; - onBody(body, *descriptor); + onAmqpValue(body); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got timestamp value with no descriptor."); @@ -716,7 +635,8 @@ bool MessageReader::onStartArray(uint32_t count, const CharSequence& raw, const return delegate->onStartArray(count, raw, constructor, descriptor); } else { if (descriptor && descriptor->match(AMQP_VALUE_SYMBOL, AMQP_VALUE_CODE)) { - onBody(raw, *descriptor); + //TODO: might be better to decode this here + onAmqpValue(raw, qpid::amqp::typecodes::ARRAY_NAME); } else { if (!descriptor) { QPID_LOG(warning, "Expected described type but got array with no descriptor."); diff --git a/qpid/cpp/src/qpid/amqp/MessageReader.h b/qpid/cpp/src/qpid/amqp/MessageReader.h index 5d26b288f5..4e2248070b 100644 --- a/qpid/cpp/src/qpid/amqp/MessageReader.h +++ b/qpid/cpp/src/qpid/amqp/MessageReader.h @@ -24,7 +24,6 @@ #include "qpid/amqp/CharSequence.h" #include "qpid/amqp/Reader.h" -#include "qpid/amqp/ListReader.h" #include "qpid/types/Variant.h" #include "qpid/CommonImportExport.h" @@ -40,11 +39,11 @@ class MessageReader : public Reader QPID_COMMON_EXTERN MessageReader(); //header, properties, amqp-sequence, amqp-value - QPID_COMMON_EXTERN bool onStartList(uint32_t, const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN bool onStartList(uint32_t, const CharSequence&, const CharSequence&, const Descriptor*); QPID_COMMON_EXTERN void onEndList(uint32_t, const Descriptor*); //delivery-annotations, message-annotations, application-headers, amqp-value - QPID_COMMON_EXTERN bool onStartMap(uint32_t, const CharSequence&, const Descriptor*); + QPID_COMMON_EXTERN bool onStartMap(uint32_t, const CharSequence&, const CharSequence&, const Descriptor*); QPID_COMMON_EXTERN void onEndMap(uint32_t, const Descriptor*); //data, amqp-value @@ -95,175 +94,24 @@ class MessageReader : public Reader virtual void onGroupSequence(uint32_t) = 0; virtual void onReplyToGroupId(const CharSequence&) = 0; - virtual void onApplicationProperties(const CharSequence&) = 0; - virtual void onDeliveryAnnotations(const CharSequence&) = 0; - virtual void onMessageAnnotations(const CharSequence&) = 0; - virtual void onBody(const CharSequence&, const Descriptor&) = 0; - virtual void onBody(const qpid::types::Variant&, const Descriptor&) = 0; - virtual void onFooter(const CharSequence&) = 0; + virtual void onApplicationProperties(const CharSequence& /*values*/, const CharSequence& /*full*/) = 0; + virtual void onDeliveryAnnotations(const CharSequence& /*values*/, const CharSequence& /*full*/) = 0; + virtual void onMessageAnnotations(const CharSequence& /*values*/, const CharSequence& /*full*/) = 0; + + virtual void onData(const CharSequence&) = 0; + virtual void onAmqpSequence(const CharSequence&) = 0; + virtual void onAmqpValue(const CharSequence&, const std::string& type) = 0; + virtual void onAmqpValue(const qpid::types::Variant&) = 0; + + virtual void onFooter(const CharSequence& /*values*/, const CharSequence& /*full*/) = 0; QPID_COMMON_EXTERN CharSequence getBareMessage() const; private: - /* - class DurableReader : public Reader - { - public: - DurableReader(MessageReader&); - void onBoolean(bool v, const Descriptor*); - private: - MessageReader& parent; - }; - class PriorityReader : public Reader - { - public: - PriorityReader(MessageReader&); - void onUByte(uint8_t v, const Descriptor*); - private: - MessageReader& parent; - }; - class TtlReader : public Reader - { - public: - TtlReader(MessageReader&); - void onUInt(uint32_t v, const Descriptor*); - private: - MessageReader& parent; - }; - class FirstAcquirerReader : public Reader - { - public: - FirstAcquirerReader(MessageReader&); - void onBoolean(bool v, const Descriptor*); - private: - MessageReader& parent; - }; - class DeliveryCountReader : public Reader - { - public: - DeliveryCountReader(MessageReader&); - void onUInt(uint32_t v, const Descriptor*); - private: - MessageReader& parent; - }; - class MessageIdReader : public Reader - { - public: - MessageIdReader(MessageReader&); - void onUuid(const qpid::types::Uuid& v, const Descriptor*); - void onULong(uint64_t v, const Descriptor*); - void onString(const CharSequence& v, const Descriptor*); - void onBinary(const CharSequence& v, const Descriptor*); - private: - MessageReader& parent; - }; - class UserIdReader : public Reader - { - public: - UserIdReader(MessageReader&); - void onBinary(const CharSequence& v, const Descriptor*); - private: - MessageReader& parent; - }; - class ToReader : public Reader + class HeaderReader : public Reader { public: - ToReader(MessageReader&); - void onString(const CharSequence& v, const Descriptor*); - private: - MessageReader& parent; - }; - class SubjectReader : public Reader - { - public: - SubjectReader(MessageReader&); - void onString(const CharSequence& v, const Descriptor*); - private: - MessageReader& parent; - }; - class ReplyToReader : public Reader - { - public: - ReplyToReader(MessageReader&); - void onString(const CharSequence& v, const Descriptor*); - private: - MessageReader& parent; - }; - class CorrelationIdReader : public Reader - { - public: - CorrelationIdReader(MessageReader&); - void onUuid(const qpid::types::Uuid& v, const Descriptor*); - void onULong(uint64_t v, const Descriptor*); - void onString(const CharSequence& v, const Descriptor*); - void onBinary(const CharSequence& v, const Descriptor*); - private: - MessageReader& parent; - }; - class ContentTypeReader : public Reader - { - public: - ContentTypeReader(MessageReader&); - void onString(const CharSequence& v, const Descriptor*); - private: - MessageReader& parent; - }; - class ContentEncodingReader : public Reader - { - public: - ContentEncodingReader(MessageReader&); - void onString(const CharSequence& v, const Descriptor*); - private: - MessageReader& parent; - }; - class AbsoluteExpiryTimeReader : public Reader - { - public: - AbsoluteExpiryTimeReader(MessageReader&); - void onTimestamp(int64_t v, const Descriptor*); - private: - MessageReader& parent; - }; - class CreationTimeReader : public Reader - { - public: - CreationTimeReader(MessageReader&); - void onTimestamp(int64_t v, const Descriptor*); - private: - MessageReader& parent; - }; - class GroupIdReader : public Reader - { - public: - GroupIdReader(MessageReader&); - void onString(const CharSequence& v, const Descriptor*); - private: - MessageReader& parent; - }; - class GroupSequenceReader : public Reader - { - public: - GroupSequenceReader(MessageReader&); - void onUInt(uint32_t v, const Descriptor*); - private: - MessageReader& parent; - }; - class ReplyToGroupIdReader : public Reader - { - public: - ReplyToGroupIdReader(MessageReader&); - void onString(const CharSequence& v, const Descriptor*); - private: - MessageReader& parent; - }; - */ - - class HeaderReader : public Reader //public ListReader - { - public: - //Reader& getReader(size_t index); - HeaderReader(MessageReader&); void onBoolean(bool v, const Descriptor*); // durable, first-acquirer void onUByte(uint8_t v, const Descriptor*); // priority @@ -273,11 +121,9 @@ class MessageReader : public Reader MessageReader& parent; size_t index; }; - class PropertiesReader : public Reader //public ListReader + class PropertiesReader : public Reader { public: - //Reader& getReader(size_t index); - PropertiesReader(MessageReader&); void onUuid(const CharSequence& v, const Descriptor*); // message-id, correlation-id void onULong(uint64_t v, const Descriptor*); // message-id, correlation-id @@ -287,6 +133,20 @@ class MessageReader : public Reader void onTimestamp(int64_t v, const Descriptor*); // absolute-expiry-time, creation-time void onUInt(uint32_t v, const Descriptor*); // group-sequence void onNull(const Descriptor*); + + void onBoolean(bool, const Descriptor*); + void onUByte(uint8_t, const Descriptor*); + void onUShort(uint16_t, const Descriptor*); + void onByte(int8_t, const Descriptor*); + void onShort(int16_t, const Descriptor*); + void onInt(int32_t, const Descriptor*); + void onLong(int64_t, const Descriptor*); + void onFloat(float, const Descriptor*); + void onDouble(double, const Descriptor*); + bool onStartList(uint32_t /*count*/, const CharSequence& /*elements*/, const CharSequence& /*complete*/, const Descriptor*); + bool onStartMap(uint32_t /*count*/, const CharSequence& /*elements*/, const CharSequence& /*complete*/, const Descriptor*); + bool onStartArray(uint32_t /*count*/, const CharSequence&, const Constructor&, const Descriptor*); + private: MessageReader& parent; size_t index; diff --git a/qpid/cpp/src/qpid/amqp/Reader.h b/qpid/cpp/src/qpid/amqp/Reader.h index 64019d1521..32f33dc33f 100644 --- a/qpid/cpp/src/qpid/amqp/Reader.h +++ b/qpid/cpp/src/qpid/amqp/Reader.h @@ -63,8 +63,8 @@ class Reader * @return true to get elements of the compound value, false * to skip over it */ - virtual bool onStartList(uint32_t /*count*/, const CharSequence&, const Descriptor*) { return true; } - virtual bool onStartMap(uint32_t /*count*/, const CharSequence&, const Descriptor*) { return true; } + virtual bool onStartList(uint32_t /*count*/, const CharSequence& /*elements*/, const CharSequence& /*complete*/, const Descriptor*) { return true; } + virtual bool onStartMap(uint32_t /*count*/, const CharSequence& /*elements*/, const CharSequence& /*complete*/, const Descriptor*) { return true; } virtual bool onStartArray(uint32_t /*count*/, const CharSequence&, const Constructor&, const Descriptor*) { return true; } virtual void onEndList(uint32_t /*count*/, const Descriptor*) {} virtual void onEndMap(uint32_t /*count*/, const Descriptor*) {} diff --git a/qpid/cpp/src/qpid/amqp/Sasl.h b/qpid/cpp/src/qpid/amqp/Sasl.h index 558f6071fc..8235a9b9ed 100644 --- a/qpid/cpp/src/qpid/amqp/Sasl.h +++ b/qpid/cpp/src/qpid/amqp/Sasl.h @@ -35,12 +35,12 @@ namespace amqp { class Sasl : protected Reader { public: - Sasl(const std::string& id); - virtual ~Sasl(); - std::size_t read(const char* data, size_t available); - std::size_t write(char* data, size_t available); - std::size_t readProtocolHeader(const char* buffer, std::size_t size); - std::size_t writeProtocolHeader(char* buffer, std::size_t size); + QPID_COMMON_EXTERN Sasl(const std::string& id); + QPID_COMMON_EXTERN virtual ~Sasl(); + QPID_COMMON_EXTERN std::size_t read(const char* data, size_t available); + QPID_COMMON_EXTERN std::size_t write(char* data, size_t available); + QPID_COMMON_EXTERN std::size_t readProtocolHeader(const char* buffer, std::size_t size); + QPID_COMMON_EXTERN std::size_t writeProtocolHeader(char* buffer, std::size_t size); protected: const std::string id; std::vector<char> buffer; diff --git a/qpid/cpp/src/qpid/amqp/SaslClient.cpp b/qpid/cpp/src/qpid/amqp/SaslClient.cpp index 69660e9294..d8a38750c5 100644 --- a/qpid/cpp/src/qpid/amqp/SaslClient.cpp +++ b/qpid/cpp/src/qpid/amqp/SaslClient.cpp @@ -116,7 +116,7 @@ class SaslOutcomeReader : public Reader }; } -bool SaslClient::onStartList(uint32_t count, const CharSequence& arguments, const Descriptor* descriptor) +bool SaslClient::onStartList(uint32_t count, const CharSequence& arguments, const CharSequence& /*full raw data*/, const Descriptor* descriptor) { if (!descriptor) { QPID_LOG(error, "Expected described type in SASL negotiation but got no descriptor"); diff --git a/qpid/cpp/src/qpid/amqp/SaslClient.h b/qpid/cpp/src/qpid/amqp/SaslClient.h index 9f3eefadc2..d22887de1a 100644 --- a/qpid/cpp/src/qpid/amqp/SaslClient.h +++ b/qpid/cpp/src/qpid/amqp/SaslClient.h @@ -21,6 +21,7 @@ * under the License. * */ +#include <qpid/CommonImportExport.h> #include "qpid/amqp/Sasl.h" namespace qpid { @@ -33,19 +34,19 @@ namespace amqp { class SaslClient : public Sasl { public: - SaslClient(const std::string& id); - virtual ~SaslClient(); - virtual void mechanisms(const std::string&) = 0; - virtual void challenge(const std::string&) = 0; - virtual void challenge() = 0; //null != empty string - virtual void outcome(uint8_t result, const std::string&) = 0; - virtual void outcome(uint8_t result) = 0; + QPID_COMMON_EXTERN SaslClient(const std::string& id); + QPID_COMMON_EXTERN virtual ~SaslClient(); + QPID_COMMON_EXTERN virtual void mechanisms(const std::string&) = 0; + QPID_COMMON_EXTERN virtual void challenge(const std::string&) = 0; + QPID_COMMON_EXTERN virtual void challenge() = 0; //null != empty string + QPID_COMMON_EXTERN virtual void outcome(uint8_t result, const std::string&) = 0; + QPID_COMMON_EXTERN virtual void outcome(uint8_t result) = 0; - void init(const std::string& mechanism, const std::string* response, const std::string* hostname); - void response(const std::string*); + QPID_COMMON_EXTERN void init(const std::string& mechanism, const std::string* response, const std::string* hostname); + QPID_COMMON_EXTERN void response(const std::string*); private: - bool onStartList(uint32_t count, const CharSequence& arguments, const Descriptor* descriptor); + QPID_COMMON_EXTERN bool onStartList(uint32_t count, const CharSequence& arguments, const CharSequence&, const Descriptor* descriptor); }; diff --git a/qpid/cpp/src/qpid/amqp/SaslServer.cpp b/qpid/cpp/src/qpid/amqp/SaslServer.cpp index 403730ad69..250858bda0 100644 --- a/qpid/cpp/src/qpid/amqp/SaslServer.cpp +++ b/qpid/cpp/src/qpid/amqp/SaslServer.cpp @@ -158,7 +158,7 @@ class SaslResponseReader : public Reader }; } -bool SaslServer::onStartList(uint32_t count, const CharSequence& arguments, const Descriptor* descriptor) +bool SaslServer::onStartList(uint32_t count, const CharSequence& arguments, const CharSequence& /*full raw data*/, const Descriptor* descriptor) { if (!descriptor) { QPID_LOG(error, "Expected described type in SASL negotiation but got no descriptor"); diff --git a/qpid/cpp/src/qpid/amqp/SaslServer.h b/qpid/cpp/src/qpid/amqp/SaslServer.h index 43b960454f..68d0854488 100644 --- a/qpid/cpp/src/qpid/amqp/SaslServer.h +++ b/qpid/cpp/src/qpid/amqp/SaslServer.h @@ -33,17 +33,17 @@ namespace amqp { class SaslServer : public Sasl { public: - SaslServer(const std::string& id); - virtual ~SaslServer(); + QPID_COMMON_EXTERN SaslServer(const std::string& id); + QPID_COMMON_EXTERN virtual ~SaslServer(); virtual void init(const std::string& mechanism, const std::string* response, const std::string* hostname) = 0; virtual void response(const std::string*) = 0; - void mechanisms(const std::string& mechanisms); - void challenge(const std::string*); - void completed(bool succeeded); + QPID_COMMON_EXTERN void mechanisms(const std::string& mechanisms); + QPID_COMMON_EXTERN void challenge(const std::string*); + QPID_COMMON_EXTERN void completed(bool succeeded); private: - bool onStartList(uint32_t count, const CharSequence& arguments, const Descriptor* descriptor); + QPID_COMMON_EXTERN bool onStartList(uint32_t count, const CharSequence& arguments, const CharSequence&, const Descriptor* descriptor); }; }} // namespace qpid::amqp diff --git a/qpid/cpp/src/qpid/amqp/descriptors.h b/qpid/cpp/src/qpid/amqp/descriptors.h index 248d6df2df..e395fc25d7 100644 --- a/qpid/cpp/src/qpid/amqp/descriptors.h +++ b/qpid/cpp/src/qpid/amqp/descriptors.h @@ -52,6 +52,7 @@ const Descriptor DELIVERY_ANNOTATIONS(DELIVERY_ANNOTATIONS_CODE); const Descriptor MESSAGE_ANNOTATIONS(MESSAGE_ANNOTATIONS_CODE); const Descriptor PROPERTIES(PROPERTIES_CODE); const Descriptor APPLICATION_PROPERTIES(APPLICATION_PROPERTIES_CODE); +const Descriptor AMQP_VALUE(AMQP_VALUE_CODE); const Descriptor DATA(DATA_CODE); } diff --git a/qpid/cpp/src/qpid/amqp/typecodes.h b/qpid/cpp/src/qpid/amqp/typecodes.h index 3c6bd17b97..915b75ca3f 100644 --- a/qpid/cpp/src/qpid/amqp/typecodes.h +++ b/qpid/cpp/src/qpid/amqp/typecodes.h @@ -83,7 +83,7 @@ const uint8_t ARRAY32(0xf0); const std::string NULL_NAME("null"); -const std::string BOOLEAN_NAME("name"); +const std::string BOOLEAN_NAME("bool"); const std::string UBYTE_NAME("ubyte"); const std::string USHORT_NAME("ushort"); diff --git a/qpid/cpp/include/qpid/amqp_0_10/Codecs.h b/qpid/cpp/src/qpid/amqp_0_10/Codecs.h index 408307eb7a..408307eb7a 100644 --- a/qpid/cpp/include/qpid/amqp_0_10/Codecs.h +++ b/qpid/cpp/src/qpid/amqp_0_10/Codecs.h diff --git a/qpid/cpp/src/qpid/broker/Broker.cpp b/qpid/cpp/src/qpid/broker/Broker.cpp index 69894e1633..85900f8061 100644 --- a/qpid/cpp/src/qpid/broker/Broker.cpp +++ b/qpid/cpp/src/qpid/broker/Broker.cpp @@ -38,6 +38,7 @@ #include "qpid/broker/PersistableObject.h" #include "qpid/broker/QueueFlowLimit.h" #include "qpid/broker/QueueSettings.h" +#include "qpid/broker/TransactionObserver.h" #include "qpid/broker/MessageGroupManager.h" #include "qmf/org/apache/qpid/broker/Package.h" @@ -139,7 +140,7 @@ Broker::Options::Options(const std::string& name) : requireEncrypted(false), knownHosts(knownHostsNone), qmf2Support(true), - qmf1Support(true), + qmf1Support(false), queueFlowStopRatio(80), queueFlowResumeRatio(70), queueThresholdEventRatio(80), @@ -399,7 +400,7 @@ boost::intrusive_ptr<Broker> Broker::create(const Options& opts) return boost::intrusive_ptr<Broker>(new Broker(opts)); } -void Broker::setStore (boost::shared_ptr<MessageStore>& _store) +void Broker::setStore (const boost::shared_ptr<MessageStore>& _store) { store.reset(new MessageStoreModule (_store)); setStore(); @@ -442,6 +443,8 @@ void Broker::shutdown() { } Broker::~Broker() { + if (mgmtObject != 0) + mgmtObject->debugStats("destroying"); shutdown(); finalize(); // Finalize any plugins. if (config.auth) @@ -1446,7 +1449,7 @@ void Broker::bind(const std::string& queueName, throw framing::NotFoundException(QPID_MSG("Bind failed. No such exchange: " << exchangeName)); } else { if (queue->bind(exchange, key, arguments)) { - getConfigurationObservers().bind(exchange, queue, key, arguments); + getBrokerObservers().bind(exchange, queue, key, arguments); if (managementAgent.get()) { managementAgent->raiseEvent(_qmf::EventBind(connectionId, userId, exchangeName, queueName, key, ManagementAgent::toMap(arguments))); @@ -1488,7 +1491,7 @@ void Broker::unbind(const std::string& queueName, if (exchange->isDurable() && queue->isDurable()) { store->unbind(*exchange, *queue, key, qpid::framing::FieldTable()); } - getConfigurationObservers().unbind( + getBrokerObservers().unbind( exchange, queue, key, framing::FieldTable()); if (managementAgent.get()) { managementAgent->raiseEvent(_qmf::EventUnbind(connectionId, userId, exchangeName, queueName, key)); diff --git a/qpid/cpp/src/qpid/broker/Broker.h b/qpid/cpp/src/qpid/broker/Broker.h index 52b79a0944..3e22fb491b 100644 --- a/qpid/cpp/src/qpid/broker/Broker.h +++ b/qpid/cpp/src/qpid/broker/Broker.h @@ -38,7 +38,7 @@ #include "qpid/broker/System.h" #include "qpid/broker/ConsumerFactory.h" #include "qpid/broker/ConnectionObservers.h" -#include "qpid/broker/ConfigurationObservers.h" +#include "qpid/broker/BrokerObservers.h" #include "qpid/management/Manageable.h" #include "qpid/sys/ConnectionCodec.h" #include "qpid/sys/Mutex.h" @@ -65,6 +65,7 @@ class AclModule; class ExpiryPolicy; class Message; struct QueueSettings; + static const uint16_t DEFAULT_PORT=5672; struct NoSuchTransportException : qpid::Exception @@ -175,7 +176,7 @@ class Broker : public sys::Runnable, public Plugin::Target, AclModule* acl; DataDir dataDir; ConnectionObservers connectionObservers; - ConfigurationObservers configurationObservers; + BrokerObservers brokerObservers; QueueRegistry queues; ExchangeRegistry exchanges; @@ -225,7 +226,8 @@ class Broker : public sys::Runnable, public Plugin::Target, /** Shut down the broker */ QPID_BROKER_EXTERN virtual void shutdown(); - QPID_BROKER_EXTERN void setStore (boost::shared_ptr<MessageStore>& store); + QPID_BROKER_EXTERN void setStore (const boost::shared_ptr<MessageStore>& store); + bool hasStore() const { return store.get(); } MessageStore& getStore() { return *store; } void setAcl (AclModule* _acl) {acl = _acl;} AclModule* getAcl() { return acl; } @@ -352,7 +354,7 @@ class Broker : public sys::Runnable, public Plugin::Target, ConsumerFactories& getConsumerFactories() { return consumerFactories; } ConnectionObservers& getConnectionObservers() { return connectionObservers; } - ConfigurationObservers& getConfigurationObservers() { return configurationObservers; } + BrokerObservers& getBrokerObservers() { return brokerObservers; } /** Properties to be set on outgoing link connections */ QPID_BROKER_EXTERN framing::FieldTable getLinkClientProperties() const; diff --git a/qpid/cpp/src/qpid/broker/ConfigurationObserver.h b/qpid/cpp/src/qpid/broker/BrokerObserver.h index 789490e08c..2249d33e64 100644 --- a/qpid/cpp/src/qpid/broker/ConfigurationObserver.h +++ b/qpid/cpp/src/qpid/broker/BrokerObserver.h @@ -1,5 +1,5 @@ -#ifndef QPID_BROKER_CONFIGURATIONOBSERVER_H -#define QPID_BROKER_CONFIGURATIONOBSERVER_H +#ifndef QPID_BROKER_BROKEROBSERVER_H +#define QPID_BROKER_BROKEROBSERVER_H /* * @@ -34,7 +34,8 @@ class FieldTable; namespace broker { class Queue; class Exchange; - +class TxBuffer; +class DtxBuffer; /** * Observer for changes to configuration (aka wiring) @@ -43,10 +44,10 @@ class Exchange; * the registry lock held. This is necessary to ensure * they are called in the correct sequence. */ -class ConfigurationObserver +class BrokerObserver { public: - virtual ~ConfigurationObserver() {} + virtual ~BrokerObserver() {} virtual void queueCreate(const boost::shared_ptr<Queue>&) {} virtual void queueDestroy(const boost::shared_ptr<Queue>&) {} virtual void exchangeCreate(const boost::shared_ptr<Exchange>&) {} @@ -59,7 +60,9 @@ class ConfigurationObserver const boost::shared_ptr<Queue>& , const std::string& /*key*/, const framing::FieldTable& /*args*/) {} + virtual void startTx(const boost::shared_ptr<TxBuffer>&) {} + virtual void startDtx(const boost::shared_ptr<DtxBuffer>&) {} }; }} // namespace qpid::broker -#endif /*!QPID_BROKER_CONFIGURATIONOBSERVER_H*/ +#endif /*!QPID_BROKER_BROKEROBSERVER_H*/ diff --git a/qpid/cpp/src/qpid/broker/ConfigurationObservers.h b/qpid/cpp/src/qpid/broker/BrokerObservers.h index 4c1159747d..5ba7bac890 100644 --- a/qpid/cpp/src/qpid/broker/ConfigurationObservers.h +++ b/qpid/cpp/src/qpid/broker/BrokerObservers.h @@ -1,5 +1,5 @@ -#ifndef QPID_BROKER_CONFIGURATIONOBSERVERS_H -#define QPID_BROKER_CONFIGURATIONOBSERVERS_H +#ifndef QPID_BROKER_BROKEROBSERVERS_H +#define QPID_BROKER_BROKEROBSERVERS_H /* * @@ -22,7 +22,7 @@ * */ -#include "ConfigurationObserver.h" +#include "BrokerObserver.h" #include "Observers.h" #include "qpid/sys/Mutex.h" @@ -30,43 +30,48 @@ namespace qpid { namespace broker { /** - * A configuration observer that delegates to a collection of - * configuration observers. + * A broker observer that delegates to a collection of broker observers. * * THREAD SAFE */ -class ConfigurationObservers : public ConfigurationObserver, - public Observers<ConfigurationObserver> +class BrokerObservers : public BrokerObserver, + public Observers<BrokerObserver> { public: void queueCreate(const boost::shared_ptr<Queue>& q) { - each(boost::bind(&ConfigurationObserver::queueCreate, _1, q)); + each(boost::bind(&BrokerObserver::queueCreate, _1, q)); } void queueDestroy(const boost::shared_ptr<Queue>& q) { - each(boost::bind(&ConfigurationObserver::queueDestroy, _1, q)); + each(boost::bind(&BrokerObserver::queueDestroy, _1, q)); } void exchangeCreate(const boost::shared_ptr<Exchange>& e) { - each(boost::bind(&ConfigurationObserver::exchangeCreate, _1, e)); + each(boost::bind(&BrokerObserver::exchangeCreate, _1, e)); } void exchangeDestroy(const boost::shared_ptr<Exchange>& e) { - each(boost::bind(&ConfigurationObserver::exchangeDestroy, _1, e)); + each(boost::bind(&BrokerObserver::exchangeDestroy, _1, e)); } void bind(const boost::shared_ptr<Exchange>& exchange, const boost::shared_ptr<Queue>& queue, const std::string& key, const framing::FieldTable& args) { each(boost::bind( - &ConfigurationObserver::bind, _1, exchange, queue, key, args)); + &BrokerObserver::bind, _1, exchange, queue, key, args)); } void unbind(const boost::shared_ptr<Exchange>& exchange, const boost::shared_ptr<Queue>& queue, const std::string& key, const framing::FieldTable& args) { each(boost::bind( - &ConfigurationObserver::unbind, _1, exchange, queue, key, args)); + &BrokerObserver::unbind, _1, exchange, queue, key, args)); + } + void startTx(const boost::shared_ptr<TxBuffer>& tx) { + each(boost::bind(&BrokerObserver::startTx, _1, tx)); + } + void startDtx(const boost::shared_ptr<DtxBuffer>& dtx) { + each(boost::bind(&BrokerObserver::startDtx, _1, dtx)); } }; }} // namespace qpid::broker -#endif /*!QPID_BROKER_CONFIGURATIONOBSERVERS_H*/ +#endif /*!QPID_BROKER_BROKEROBSERVERS_H*/ diff --git a/qpid/cpp/src/qpid/broker/DeliveryRecord.cpp b/qpid/cpp/src/qpid/broker/DeliveryRecord.cpp index 14a2e94571..06ecf62ed4 100644 --- a/qpid/cpp/src/qpid/broker/DeliveryRecord.cpp +++ b/qpid/cpp/src/qpid/broker/DeliveryRecord.cpp @@ -106,7 +106,9 @@ void DeliveryRecord::dequeue(TransactionContext* ctxt) const void DeliveryRecord::committed() const { - queue->dequeueCommitted(msg); + if (acquired && !ended) { + queue->dequeueCommitted(msg); + } } void DeliveryRecord::reject() diff --git a/qpid/cpp/src/qpid/broker/DirectExchange.cpp b/qpid/cpp/src/qpid/broker/DirectExchange.cpp index 773a99d2c9..8ab7b59ed1 100644 --- a/qpid/cpp/src/qpid/broker/DirectExchange.cpp +++ b/qpid/cpp/src/qpid/broker/DirectExchange.cpp @@ -196,6 +196,9 @@ bool DirectExchange::isBound(Queue::shared_ptr queue, const string* const routin return false; } -DirectExchange::~DirectExchange() {} +DirectExchange::~DirectExchange() { + if (mgmtExchange != 0) + mgmtExchange->debugStats("destroying"); +} const std::string DirectExchange::typeName("direct"); diff --git a/qpid/cpp/src/qpid/broker/DirectExchange.h b/qpid/cpp/src/qpid/broker/DirectExchange.h index 833be52c1c..cfefef54e8 100644 --- a/qpid/cpp/src/qpid/broker/DirectExchange.h +++ b/qpid/cpp/src/qpid/broker/DirectExchange.h @@ -42,7 +42,7 @@ class DirectExchange : public virtual Exchange { qpid::sys::Mutex lock; public: - static const std::string typeName; + QPID_BROKER_EXTERN static const std::string typeName; QPID_BROKER_EXTERN DirectExchange(const std::string& name, management::Manageable* parent = 0, Broker* broker = 0); diff --git a/qpid/cpp/src/qpid/broker/DtxAck.h b/qpid/cpp/src/qpid/broker/DtxAck.h index 10d63f5b0c..5775edf5de 100644 --- a/qpid/cpp/src/qpid/broker/DtxAck.h +++ b/qpid/cpp/src/qpid/broker/DtxAck.h @@ -39,6 +39,9 @@ class DtxAck : public TxOp{ virtual bool prepare(TransactionContext* ctxt) throw(); virtual void commit() throw(); virtual void rollback() throw(); + // TODO aconway 2013-07-08: + virtual void callObserver(const boost::shared_ptr<TransactionObserver>&) {} + virtual ~DtxAck(){} const DeliveryRecords& getPending() const { return pending; } }; diff --git a/qpid/cpp/src/qpid/broker/Exchange.cpp b/qpid/cpp/src/qpid/broker/Exchange.cpp index b9080cdda5..0a25d57cd8 100644 --- a/qpid/cpp/src/qpid/broker/Exchange.cpp +++ b/qpid/cpp/src/qpid/broker/Exchange.cpp @@ -353,6 +353,7 @@ Exchange::Binding::Binding(const string& _key, Queue::shared_ptr _queue, Exchang Exchange::Binding::~Binding () { if (mgmtBinding != 0) { + mgmtBinding->debugStats("destroying"); _qmf::Queue::shared_ptr mo = boost::dynamic_pointer_cast<_qmf::Queue>(queue->GetManagementObject()); if (mo != 0) mo->dec_bindingCount(); diff --git a/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp b/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp index 645918d526..9eeffadb90 100644 --- a/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp +++ b/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp @@ -81,7 +81,7 @@ pair<Exchange::shared_ptr, bool> ExchangeRegistry::declare( result = std::pair<Exchange::shared_ptr, bool>(exchange, true); if (alternate) exchange->setAlternate(alternate); // Call exchangeCreate inside the lock to ensure correct ordering. - if (broker) broker->getConfigurationObservers().exchangeCreate(exchange); + if (broker) broker->getBrokerObservers().exchangeCreate(exchange); } else { result = std::pair<Exchange::shared_ptr, bool>(i->second, false); } @@ -118,7 +118,7 @@ void ExchangeRegistry::destroy( if (broker) { // Call exchangeDestroy and raiseEvent inside the lock to ensure // correct ordering. - broker->getConfigurationObservers().exchangeDestroy(i->second); + broker->getBrokerObservers().exchangeDestroy(i->second); if (broker->getManagementAgent()) broker->getManagementAgent()->raiseEvent( _qmf::EventExchangeDelete(connectionId, userId, name)); diff --git a/qpid/cpp/src/qpid/broker/FanOutExchange.cpp b/qpid/cpp/src/qpid/broker/FanOutExchange.cpp index 43c67af810..20ca06e048 100644 --- a/qpid/cpp/src/qpid/broker/FanOutExchange.cpp +++ b/qpid/cpp/src/qpid/broker/FanOutExchange.cpp @@ -117,6 +117,9 @@ bool FanOutExchange::isBound(Queue::shared_ptr queue, const string* const, const } -FanOutExchange::~FanOutExchange() {} +FanOutExchange::~FanOutExchange() { + if (mgmtExchange != 0) + mgmtExchange->debugStats("destroying"); +} const std::string FanOutExchange::typeName("fanout"); diff --git a/qpid/cpp/src/qpid/broker/HeadersExchange.cpp b/qpid/cpp/src/qpid/broker/HeadersExchange.cpp index 82284feaeb..4e86b09565 100644 --- a/qpid/cpp/src/qpid/broker/HeadersExchange.cpp +++ b/qpid/cpp/src/qpid/broker/HeadersExchange.cpp @@ -339,7 +339,10 @@ void HeadersExchange::getNonFedArgs(const FieldTable* args, FieldTable& nonFedAr } } -HeadersExchange::~HeadersExchange() {} +HeadersExchange::~HeadersExchange() { + if (mgmtExchange != 0) + mgmtExchange->debugStats("destroying"); +} const std::string HeadersExchange::typeName("headers"); diff --git a/qpid/cpp/src/qpid/broker/HeadersExchange.h b/qpid/cpp/src/qpid/broker/HeadersExchange.h index b5b10350d2..e51478d365 100644 --- a/qpid/cpp/src/qpid/broker/HeadersExchange.h +++ b/qpid/cpp/src/qpid/broker/HeadersExchange.h @@ -79,7 +79,7 @@ class HeadersExchange : public virtual Exchange { framing::FieldTable& nonFedArgs); public: - static const std::string typeName; + QPID_BROKER_EXTERN static const std::string typeName; QPID_BROKER_EXTERN HeadersExchange(const std::string& name, management::Manageable* parent = 0, Broker* broker = 0); diff --git a/qpid/cpp/src/qpid/broker/IngressCompletion.h b/qpid/cpp/src/qpid/broker/IngressCompletion.h index 28bb9cf03d..ca21ec9837 100644 --- a/qpid/cpp/src/qpid/broker/IngressCompletion.h +++ b/qpid/cpp/src/qpid/broker/IngressCompletion.h @@ -38,7 +38,7 @@ class Queue; class IngressCompletion : public AsyncCompletion { public: - virtual ~IngressCompletion(); + QPID_BROKER_EXTERN virtual ~IngressCompletion(); void enqueueAsync(boost::shared_ptr<Queue>); void flush(); diff --git a/qpid/cpp/src/qpid/broker/Link.cpp b/qpid/cpp/src/qpid/broker/Link.cpp index 31685eb1de..cd7ba35dd8 100644 --- a/qpid/cpp/src/qpid/broker/Link.cpp +++ b/qpid/cpp/src/qpid/broker/Link.cpp @@ -536,7 +536,7 @@ bool Link::tryFailoverLH() { if (url.empty()) return false; Address next = url[reconnectNext++]; if (next.host != host || next.port != port || next.protocol != transport) { - QPID_LOG(notice, "Inter-broker link '" << name << "' failing over to " << next); + QPID_LOG(info, "Inter-broker link '" << name << "' failing over to " << next); reconnectLH(next); return true; } diff --git a/qpid/cpp/src/qpid/broker/Link.h b/qpid/cpp/src/qpid/broker/Link.h index d9924feec3..ceee0186f3 100644 --- a/qpid/cpp/src/qpid/broker/Link.h +++ b/qpid/cpp/src/qpid/broker/Link.h @@ -151,8 +151,8 @@ class Link : public PersistableConfig, public management::Manageable { bool isDurable() { return durable; } void maintenanceVisit (); - framing::ChannelId nextChannel(); // allocate channel from link free pool - void returnChannel(framing::ChannelId); // return channel to link free pool + QPID_BROKER_EXTERN framing::ChannelId nextChannel(); // allocate channel from link free pool + QPID_BROKER_EXTERN void returnChannel(framing::ChannelId); // return channel to link free pool void add(Bridge::shared_ptr); void cancel(Bridge::shared_ptr); diff --git a/qpid/cpp/src/qpid/broker/LossyQueue.cpp b/qpid/cpp/src/qpid/broker/LossyQueue.cpp index 4104503dac..ba7dfd11a1 100644 --- a/qpid/cpp/src/qpid/broker/LossyQueue.cpp +++ b/qpid/cpp/src/qpid/broker/LossyQueue.cpp @@ -52,7 +52,7 @@ bool LossyQueue::checkDepth(const QueueDepth& increment, const Message& message) QPID_LOG(debug, "purging " << name << ": current depth is [" << current << "], max depth is [" << settings.maxDepth << "], new message has size " << increment.getSize()); qpid::sys::Mutex::ScopedUnlock u(messageLock); //TODO: arguably we should try and purge expired messages first but that is potentially expensive - if (remove(1, settings.priorities ? boost::bind(&isLowerPriorityThan, message.getPriority(), _1) : MessagePredicate(), MessageFunctor(), PURGE, false)) { + if (remove(1, settings.priorities ? boost::bind(&isLowerPriorityThan, message.getPriority(), _1) : MessagePredicate(), boost::bind(&reroute, alternateExchange, _1), PURGE, false)) { if (mgmtObject) { mgmtObject->inc_discardsRing(1); if (brokerMgmtObject) diff --git a/qpid/cpp/src/qpid/broker/Lvq.cpp b/qpid/cpp/src/qpid/broker/Lvq.cpp index ff13b97dbd..34f080c57f 100644 --- a/qpid/cpp/src/qpid/broker/Lvq.cpp +++ b/qpid/cpp/src/qpid/broker/Lvq.cpp @@ -57,7 +57,8 @@ void Lvq::push(Message& message, bool isRecovery) copy.notify(); if (removed) { if (isRecovery) pendingDequeues.push_back(old); - else dequeueFromStore(old.getPersistentContext());//do outside of lock + else if (old.isPersistent()) + dequeueFromStore(old.getPersistentContext());//do outside of lock } } }} // namespace qpid::broker diff --git a/qpid/cpp/src/qpid/broker/Message.cpp b/qpid/cpp/src/qpid/broker/Message.cpp index ec44404793..e71125b4ab 100644 --- a/qpid/cpp/src/qpid/broker/Message.cpp +++ b/qpid/cpp/src/qpid/broker/Message.cpp @@ -145,7 +145,7 @@ uint64_t Message::getTtl() const } } -bool Message::getTtl(uint64_t ttl) const +bool Message::getTtl(uint64_t& ttl) const { if (encoding->getTtl(ttl) && expiration < FAR_FUTURE) { sys::Duration remaining(sys::AbsTime::now(), getExpiration()); @@ -182,8 +182,10 @@ void Message::addAnnotation(const std::string& key, const qpid::types::Variant& void Message::annotationsChanged() { if (persistentContext) { + uint64_t id = persistentContext->getPersistenceId(); persistentContext = persistentContext->merge(annotations); persistentContext->setIngressCompletion(encoding); + persistentContext->setPersistenceId(id); } } diff --git a/qpid/cpp/src/qpid/broker/Message.h b/qpid/cpp/src/qpid/broker/Message.h index 03ef21e77a..84f62a771d 100644 --- a/qpid/cpp/src/qpid/broker/Message.h +++ b/qpid/cpp/src/qpid/broker/Message.h @@ -39,7 +39,7 @@ namespace qpid { namespace amqp { class MapHandler; -class MessageId; +struct MessageId; } namespace management { @@ -104,7 +104,7 @@ public: sys::AbsTime getExpiration() const { return expiration; } void setExpiration(sys::AbsTime exp) { expiration = exp; } uint64_t getTtl() const; - bool getTtl(uint64_t) const; + QPID_BROKER_EXTERN bool getTtl(uint64_t&) const; /** set the timestamp delivery property to the current time-of-day */ QPID_BROKER_EXTERN void setTimestamp(); @@ -136,7 +136,7 @@ public: QPID_BROKER_EXTERN qpid::types::Variant getAnnotation(const std::string& key) const; QPID_BROKER_EXTERN const qpid::types::Variant::Map& getAnnotations() const; - std::string getUserId() const; + QPID_BROKER_EXTERN std::string getUserId() const; QPID_BROKER_EXTERN std::string getContent() const;//Used for ha, management, when content needs to be decoded diff --git a/qpid/cpp/src/qpid/broker/MessageStoreModule.cpp b/qpid/cpp/src/qpid/broker/MessageStoreModule.cpp index f19b31fa76..edfe6e7819 100644 --- a/qpid/cpp/src/qpid/broker/MessageStoreModule.cpp +++ b/qpid/cpp/src/qpid/broker/MessageStoreModule.cpp @@ -33,7 +33,7 @@ using std::string; namespace qpid { namespace broker { -MessageStoreModule::MessageStoreModule(boost::shared_ptr<MessageStore>& _store) +MessageStoreModule::MessageStoreModule(const boost::shared_ptr<MessageStore>& _store) : store(_store) {} MessageStoreModule::~MessageStoreModule() diff --git a/qpid/cpp/src/qpid/broker/MessageStoreModule.h b/qpid/cpp/src/qpid/broker/MessageStoreModule.h index 82308db84c..a71e8cc9b6 100644 --- a/qpid/cpp/src/qpid/broker/MessageStoreModule.h +++ b/qpid/cpp/src/qpid/broker/MessageStoreModule.h @@ -38,7 +38,7 @@ class MessageStoreModule : public MessageStore { boost::shared_ptr<MessageStore> store; public: - MessageStoreModule(boost::shared_ptr<MessageStore>& store); + MessageStoreModule(const boost::shared_ptr<MessageStore>& store); bool init(const Options* options); std::auto_ptr<TransactionContext> begin(); diff --git a/qpid/cpp/src/qpid/broker/ObjectFactory.h b/qpid/cpp/src/qpid/broker/ObjectFactory.h index 1b8f0356d6..d1b570da2f 100644 --- a/qpid/cpp/src/qpid/broker/ObjectFactory.h +++ b/qpid/cpp/src/qpid/broker/ObjectFactory.h @@ -21,6 +21,7 @@ * under the License. * */ +#include "qpid/broker/BrokerImportExport.h" #include "qpid/types/Variant.h" #include <vector> @@ -56,7 +57,7 @@ class ObjectFactoryRegistry : public ObjectFactory bool recoverObject(Broker&, const std::string& type, const std::string& name, const qpid::types::Variant::Map& properties, uint64_t persistenceId); ~ObjectFactoryRegistry(); - void add(ObjectFactory*); + QPID_BROKER_EXTERN void add(ObjectFactory*); private: typedef std::vector<ObjectFactory*> Factories; Factories factories; diff --git a/qpid/cpp/src/qpid/broker/PagedQueue.cpp b/qpid/cpp/src/qpid/broker/PagedQueue.cpp index 9bce28061a..862e9c0d48 100644 --- a/qpid/cpp/src/qpid/broker/PagedQueue.cpp +++ b/qpid/cpp/src/qpid/broker/PagedQueue.cpp @@ -64,7 +64,7 @@ size_t decode(ProtocolRegistry& protocols, Message& msg, const char* data, size_ } PagedQueue::PagedQueue(const std::string& name, const std::string& directory, uint m, uint factor, ProtocolRegistry& p) - : pageSize(file.getPageSize()*factor), maxLoaded(m), protocols(p), offset(0) + : pageSize(file.getPageSize()*factor), maxLoaded(m), protocols(p), offset(0), loaded(0), version(0) { path = file.open(name, directory); QPID_LOG(debug, "PagedQueue[" << path << "]"); @@ -295,7 +295,8 @@ void PagedQueue::Page::load(MemoryMappedFile& file, ProtocolRegistry& protocols) bool haveData = used > 0; used = 4;//first 4 bytes are the count if (haveData) { - uint32_t count = *(reinterpret_cast<uint32_t*>(region)); + qpid::framing::Buffer buffer(region, sizeof(uint32_t)); + uint32_t count = buffer.getLong(); //decode messages into Page::messages for (size_t i = 0; i < count; ++i) { Message message; @@ -331,7 +332,8 @@ void PagedQueue::Page::unload(MemoryMappedFile& file) if (i->getState() == ACQUIRED) acquired.add(i->getSequence()); } uint32_t count = messages.size(); - ::memcpy(region, &count, sizeof(count)); + qpid::framing::Buffer buffer(region, sizeof(uint32_t)); + buffer.putLong(count); file.flush(region, size); file.unmap(region, size); //remove messages from memory diff --git a/qpid/cpp/src/qpid/broker/PersistableMessage.h b/qpid/cpp/src/qpid/broker/PersistableMessage.h index 85ac4a3b85..cfcf8f0afc 100644 --- a/qpid/cpp/src/qpid/broker/PersistableMessage.h +++ b/qpid/cpp/src/qpid/broker/PersistableMessage.h @@ -62,8 +62,8 @@ class PersistableMessage : public Persistable mutable uint64_t persistenceId; public: - virtual ~PersistableMessage(); - PersistableMessage(); + QPID_BROKER_EXTERN virtual ~PersistableMessage(); + QPID_BROKER_EXTERN PersistableMessage(); virtual QPID_BROKER_EXTERN bool isPersistent() const = 0; diff --git a/qpid/cpp/src/qpid/broker/PersistableObject.h b/qpid/cpp/src/qpid/broker/PersistableObject.h index c6aff466f7..4d7e5e4498 100644 --- a/qpid/cpp/src/qpid/broker/PersistableObject.h +++ b/qpid/cpp/src/qpid/broker/PersistableObject.h @@ -21,6 +21,7 @@ * under the License. * */ +#include "qpid/broker/BrokerImportExport.h" #include "PersistableConfig.h" #include "qpid/types/Variant.h" #include <vector> @@ -37,13 +38,13 @@ class RecoverableConfig; class PersistableObject : public PersistableConfig { public: - PersistableObject(const std::string& name, const std::string& type, const qpid::types::Variant::Map properties); - virtual ~PersistableObject(); - const std::string& getName() const; - void setPersistenceId(uint64_t id) const; - uint64_t getPersistenceId() const; - void encode(framing::Buffer& buffer) const; - uint32_t encodedSize() const; + QPID_BROKER_EXTERN PersistableObject(const std::string& name, const std::string& type, const qpid::types::Variant::Map properties); + QPID_BROKER_EXTERN virtual ~PersistableObject(); + QPID_BROKER_EXTERN const std::string& getName() const; + QPID_BROKER_EXTERN void setPersistenceId(uint64_t id) const; + QPID_BROKER_EXTERN uint64_t getPersistenceId() const; + QPID_BROKER_EXTERN void encode(framing::Buffer& buffer) const; + QPID_BROKER_EXTERN uint32_t encodedSize() const; friend class RecoveredObjects; private: std::string name; diff --git a/qpid/cpp/src/qpid/broker/PriorityQueue.cpp b/qpid/cpp/src/qpid/broker/PriorityQueue.cpp index 99488ded13..5e60fe5cce 100644 --- a/qpid/cpp/src/qpid/broker/PriorityQueue.cpp +++ b/qpid/cpp/src/qpid/broker/PriorityQueue.cpp @@ -135,7 +135,12 @@ void PriorityQueue::publish(const Message& published) Message* PriorityQueue::release(const QueueCursor& cursor) { MessagePointer* ptr = fifo.release(cursor); - return ptr ? &(ptr->holder->message) : 0; + if (ptr) { + messages[ptr->holder->priority].resetCursors(); + return &(ptr->holder->message); + } else { + return 0; + } } void PriorityQueue::foreach(Functor f) diff --git a/qpid/cpp/src/qpid/broker/Protocol.h b/qpid/cpp/src/qpid/broker/Protocol.h index 282e4bd83d..e736e4b367 100644 --- a/qpid/cpp/src/qpid/broker/Protocol.h +++ b/qpid/cpp/src/qpid/broker/Protocol.h @@ -72,7 +72,7 @@ class ProtocolRegistry : public Protocol QPID_BROKER_EXTERN Message decode(qpid::framing::Buffer&); QPID_BROKER_EXTERN ~ProtocolRegistry(); - void add(const std::string&, Protocol*); + QPID_BROKER_EXTERN void add(const std::string&, Protocol*); private: //name may be useful for descriptive purposes or even for some //limited manipulation of ordering diff --git a/qpid/cpp/src/qpid/broker/Queue.cpp b/qpid/cpp/src/qpid/broker/Queue.cpp index 1d0a8017ef..5a43df44a4 100644 --- a/qpid/cpp/src/qpid/broker/Queue.cpp +++ b/qpid/cpp/src/qpid/broker/Queue.cpp @@ -34,6 +34,7 @@ #include "qpid/broker/NullMessageStore.h" #include "qpid/broker/QueueRegistry.h" #include "qpid/broker/Selector.h" +#include "qpid/broker/TransactionObserver.h" //TODO: get rid of this #include "qpid/broker/amqp_0_10/MessageTransfer.h" @@ -167,6 +168,12 @@ void Queue::TxPublish::rollback() throw() } } +void Queue::TxPublish::callObserver( + const boost::shared_ptr<TransactionObserver>& observer) +{ + observer->enqueue(queue, message); +} + Queue::Queue(const string& _name, const QueueSettings& _settings, MessageStore* const _store, Manageable* parent, @@ -216,6 +223,8 @@ Queue::Queue(const string& _name, const QueueSettings& _settings, Queue::~Queue() { + if (mgmtObject != 0) + mgmtObject->debugStats("destroying"); } bool Queue::isLocal(const Message& msg) @@ -270,6 +279,7 @@ void Queue::deliver(Message msg, TxBuffer* txn) void Queue::deliverTo(Message msg, TxBuffer* txn) { if (accept(msg)) { + interceptors.record(msg); if (txn) { TxOp::shared_ptr op(new TxPublish(msg, shared_from_this())); txn->enlist(op); @@ -385,6 +395,7 @@ bool Queue::getNextMessage(Message& m, Consumer::shared_ptr& c) if (!checkNotDeleted(c)) return false; QueueListeners::NotificationSet set; ScopedAutoDelete autodelete(*this); + bool messageFound(false); while (true) { //TODO: reduce lock scope Mutex::ScopedLock locker(messageLock); @@ -426,7 +437,8 @@ bool Queue::getNextMessage(Message& m, Consumer::shared_ptr& c) QPID_LOG(debug, "Message " << msg->getSequence() << " retrieved from '" << name << "'"); m = *msg; - return true; + messageFound = true; + break; } else { //message(s) are available but consumer hasn't got enough credit QPID_LOG(debug, "Consumer can't currently accept message from '" << name << "'"); @@ -448,11 +460,12 @@ bool Queue::getNextMessage(Message& m, Consumer::shared_ptr& c) } else { QPID_LOG(debug, "No messages to dispatch on queue '" << name << "'"); listeners.addListener(c); - return false; + break; } + } set.notify(); - return false; + return messageFound; } void Queue::removeListener(Consumer::shared_ptr c) @@ -677,17 +690,6 @@ namespace { return new MessageFilter(); } - bool reroute(boost::shared_ptr<Exchange> e, const Message& m) - { - if (e) { - DeliverableMessage d(m, 0); - d.getMessage().clearTrace(); - e->routeWithAlternate(d); - return true; - } else { - return false; - } - } void moveTo(boost::shared_ptr<Queue> q, Message& m) { if (q) { @@ -846,7 +848,6 @@ bool Queue::isEmpty(const Mutex::ScopedLock&) const */ bool Queue::enqueue(TransactionContext* ctxt, Message& msg) { - interceptors.record(msg); ScopedUse u(barrier); if (!u.acquired) return false; @@ -1684,6 +1685,19 @@ void Queue::setMgmtRedirectState( std::string peer, bool enabled, bool isSrc ) { mgmtObject->set_redirectSource(isSrc); } } + +bool Queue::reroute(boost::shared_ptr<Exchange> e, const Message& m) +{ + if (e) { + DeliverableMessage d(m, 0); + d.getMessage().clearTrace(); + e->routeWithAlternate(d); + return true; + } else { + return false; + } +} + Queue::QueueUsers::QueueUsers() : consumers(0), browsers(0), others(0), controller(false) {} void Queue::QueueUsers::addConsumer() { ++consumers; } void Queue::QueueUsers::addBrowser() { ++browsers; } diff --git a/qpid/cpp/src/qpid/broker/Queue.h b/qpid/cpp/src/qpid/broker/Queue.h index 5598ee5d13..a832b95feb 100644 --- a/qpid/cpp/src/qpid/broker/Queue.h +++ b/qpid/cpp/src/qpid/broker/Queue.h @@ -118,6 +118,7 @@ class Queue : public boost::enable_shared_from_this<Queue>, bool prepare(TransactionContext* ctxt) throw(); void commit() throw(); void rollback() throw(); + void callObserver(const boost::shared_ptr<TransactionObserver>&); }; /** @@ -501,6 +502,9 @@ class Queue : public boost::enable_shared_from_this<Queue>, QPID_BROKER_EXTERN bool isRedirectSource() const { return redirectSource; } QPID_BROKER_EXTERN void setMgmtRedirectState( std::string peer, bool enabled, bool isSrc ); + //utility function + static bool reroute(boost::shared_ptr<Exchange> e, const Message& m); + friend class QueueFactory; }; } diff --git a/qpid/cpp/src/qpid/broker/QueueFactory.cpp b/qpid/cpp/src/qpid/broker/QueueFactory.cpp index 67499c9985..807026ef0d 100644 --- a/qpid/cpp/src/qpid/broker/QueueFactory.cpp +++ b/qpid/cpp/src/qpid/broker/QueueFactory.cpp @@ -33,6 +33,7 @@ #include "qpid/broker/PagedQueue.h" #include "qpid/broker/PriorityQueue.h" #include "qpid/broker/QueueFlowLimit.h" +#include "qpid/broker/SelfDestructQueue.h" #include "qpid/broker/ThresholdAlerts.h" #include "qpid/broker/FifoDistributor.h" #include "qpid/log/Statement.h" @@ -53,6 +54,8 @@ boost::shared_ptr<Queue> QueueFactory::create(const std::string& name, const Que boost::shared_ptr<Queue> queue; if (settings.dropMessagesAtLimit) { queue = boost::shared_ptr<Queue>(new LossyQueue(name, settings, settings.durable ? store : 0, parent, broker)); + } else if (settings.selfDestructAtLimit) { + queue = boost::shared_ptr<Queue>(new SelfDestructQueue(name, settings, settings.durable ? store : 0, parent, broker)); } else if (settings.lvqKey.size()) { std::auto_ptr<MessageMap> map(new MessageMap(settings.lvqKey)); queue = boost::shared_ptr<Queue>(new Lvq(name, map, settings, settings.durable ? store : 0, parent, broker)); diff --git a/qpid/cpp/src/qpid/broker/QueueRegistry.cpp b/qpid/cpp/src/qpid/broker/QueueRegistry.cpp index 13f9bbe23c..606a8cceae 100644 --- a/qpid/cpp/src/qpid/broker/QueueRegistry.cpp +++ b/qpid/cpp/src/qpid/broker/QueueRegistry.cpp @@ -59,8 +59,8 @@ QueueRegistry::declare(const string& name, const QueueSettings& settings, QueueMap::iterator i = queues.find(name); if (i == queues.end()) { Queue::shared_ptr queue = create(name, settings); - // Allow ConfigurationObserver to modify settings before storing the message. - if (getBroker()) getBroker()->getConfigurationObservers().queueCreate(queue); + // Allow BrokerObserver to modify settings before storing the message. + if (getBroker()) getBroker()->getBrokerObservers().queueCreate(queue); //Move this to factory also? if (alternate) queue->setAlternateExchange(alternate);//need to do this *before* create @@ -100,7 +100,7 @@ void QueueRegistry::destroy( // NOTE: queueDestroy and raiseEvent must be called with the // lock held in order to ensure events are generated // in the correct order. - getBroker()->getConfigurationObservers().queueDestroy(q); + getBroker()->getBrokerObservers().queueDestroy(q); if (getBroker()->getManagementAgent()) getBroker()->getManagementAgent()->raiseEvent( _qmf::EventQueueDelete(connectionId, userId, name)); @@ -121,7 +121,9 @@ Queue::shared_ptr QueueRegistry::find(const string& name){ Queue::shared_ptr QueueRegistry::get(const string& name) { Queue::shared_ptr q = find(name); - if (!q) throw framing::NotFoundException(QPID_MSG("Queue not found: "<<name)); + if (!q) { + throw framing::NotFoundException(QPID_MSG("Queue not found: "<<name)); + } return q; } diff --git a/qpid/cpp/src/qpid/broker/QueueSettings.cpp b/qpid/cpp/src/qpid/broker/QueueSettings.cpp index fd90d11d76..c505217dbb 100644 --- a/qpid/cpp/src/qpid/broker/QueueSettings.cpp +++ b/qpid/cpp/src/qpid/broker/QueueSettings.cpp @@ -38,6 +38,7 @@ const std::string MAX_FILE_SIZE("qpid.file_size"); const std::string POLICY_TYPE("qpid.policy_type"); const std::string POLICY_TYPE_REJECT("reject"); const std::string POLICY_TYPE_RING("ring"); +const std::string POLICY_TYPE_SELF_DESTRUCT("self-destruct"); const std::string NO_LOCAL("no-local"); const std::string BROWSE_ONLY("qpid.browse-only"); const std::string TRACE_ID("qpid.trace.id"); @@ -96,6 +97,7 @@ QueueSettings::QueueSettings(bool d, bool a) : shareGroups(false), addTimestamp(false), dropMessagesAtLimit(false), + selfDestructAtLimit(false), paging(false), maxPages(0), pageFactor(0), @@ -120,6 +122,9 @@ bool QueueSettings::handle(const std::string& key, const qpid::types::Variant& v if (value.getString() == POLICY_TYPE_RING) { dropMessagesAtLimit = true; return true; + } else if (value.getString() == POLICY_TYPE_SELF_DESTRUCT) { + selfDestructAtLimit = true; + return true; } else if (value.getString() == POLICY_TYPE_REJECT) { //do nothing, thats the default return true; @@ -168,6 +173,7 @@ bool QueueSettings::handle(const std::string& key, const qpid::types::Variant& v return true; } else if (key == AUTO_DELETE_TIMEOUT) { autoDeleteDelay = value; + if (autoDeleteDelay) autodelete = true; return true; } else if (key == QueueFlowLimit::flowStopCountKey) { flowStop.setCount(value); diff --git a/qpid/cpp/src/qpid/broker/QueueSettings.h b/qpid/cpp/src/qpid/broker/QueueSettings.h index 166445be18..8d72115e18 100644 --- a/qpid/cpp/src/qpid/broker/QueueSettings.h +++ b/qpid/cpp/src/qpid/broker/QueueSettings.h @@ -70,6 +70,7 @@ struct QueueSettings QueueDepth maxDepth; bool dropMessagesAtLimit;//aka ring queue policy + bool selfDestructAtLimit; //PagedQueue: bool paging; diff --git a/qpid/cpp/src/qpid/broker/RecoverableMessageImpl.h b/qpid/cpp/src/qpid/broker/RecoverableMessageImpl.h index 7cef5fd265..900eae4e1e 100644 --- a/qpid/cpp/src/qpid/broker/RecoverableMessageImpl.h +++ b/qpid/cpp/src/qpid/broker/RecoverableMessageImpl.h @@ -33,7 +33,7 @@ class RecoverableMessageImpl : public RecoverableMessage { Message msg; public: - RecoverableMessageImpl(const Message& _msg); + QPID_BROKER_EXTERN RecoverableMessageImpl(const Message& _msg); ~RecoverableMessageImpl() {}; void setPersistenceId(uint64_t id); void setRedelivered(); diff --git a/qpid/cpp/src/qpid/broker/RecoveredDequeue.h b/qpid/cpp/src/qpid/broker/RecoveredDequeue.h index 87f768eefd..b85919975c 100644 --- a/qpid/cpp/src/qpid/broker/RecoveredDequeue.h +++ b/qpid/cpp/src/qpid/broker/RecoveredDequeue.h @@ -41,6 +41,8 @@ namespace qpid { virtual bool prepare(TransactionContext* ctxt) throw(); virtual void commit() throw(); virtual void rollback() throw(); + // TODO aconway 2013-07-08: revisit + virtual void callObserver(const boost::shared_ptr<TransactionObserver>&) {} virtual ~RecoveredDequeue(){} boost::shared_ptr<Queue> getQueue() const { return queue; } diff --git a/qpid/cpp/src/qpid/broker/RecoveredEnqueue.h b/qpid/cpp/src/qpid/broker/RecoveredEnqueue.h index d1f8e1106c..01c350af92 100644 --- a/qpid/cpp/src/qpid/broker/RecoveredEnqueue.h +++ b/qpid/cpp/src/qpid/broker/RecoveredEnqueue.h @@ -41,6 +41,8 @@ class RecoveredEnqueue : public TxOp{ virtual bool prepare(TransactionContext* ctxt) throw(); virtual void commit() throw(); virtual void rollback() throw(); + // TODO aconway 2013-07-08: revisit + virtual void callObserver(const boost::shared_ptr<TransactionObserver>&) {} virtual ~RecoveredEnqueue(){} boost::shared_ptr<Queue> getQueue() const { return queue; } diff --git a/qpid/cpp/src/qpid/broker/Selector.h b/qpid/cpp/src/qpid/broker/Selector.h index 1d98f6ea8f..0e151ecd0e 100644 --- a/qpid/cpp/src/qpid/broker/Selector.h +++ b/qpid/cpp/src/qpid/broker/Selector.h @@ -64,7 +64,7 @@ public: * @param msg message to filter against selector * @return true if msg meets the selector specification */ - bool filter(const Message& msg); + QPID_BROKER_EXTERN bool filter(const Message& msg); }; /** diff --git a/qpid/cpp/src/qpid/broker/SelfDestructQueue.cpp b/qpid/cpp/src/qpid/broker/SelfDestructQueue.cpp new file mode 100644 index 0000000000..f8b26a62ad --- /dev/null +++ b/qpid/cpp/src/qpid/broker/SelfDestructQueue.cpp @@ -0,0 +1,45 @@ +/* + * + * 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 "SelfDestructQueue.h" +#include "AclModule.h" +#include "Broker.h" +#include "QueueDepth.h" +#include "qpid/log/Statement.h" + +namespace qpid { +namespace broker { +SelfDestructQueue::SelfDestructQueue(const std::string& n, const QueueSettings& s, MessageStore* const ms, management::Manageable* p, Broker* b) : Queue(n, s, ms, p, b) +{ + QPID_LOG_CAT(debug, model, "Self-destruct queue created: " << name); +} +bool SelfDestructQueue::checkDepth(const QueueDepth& increment, const Message&) +{ + if (settings.maxDepth && (settings.maxDepth - current < increment)) { + broker->getQueues().destroy(name); + if (broker->getAcl()) + broker->getAcl()->recordDestroyQueue(name); + QPID_LOG_CAT(debug, model, "Queue " << name << " deleted itself due to reaching limit: " << current << " (policy is " << settings.maxDepth << ")"); + destroyed(); + } + current += increment; + return true; +} +}} // namespace qpid::broker diff --git a/qpid/cpp/src/qpid/broker/SelfDestructQueue.h b/qpid/cpp/src/qpid/broker/SelfDestructQueue.h new file mode 100644 index 0000000000..110eb1dcf7 --- /dev/null +++ b/qpid/cpp/src/qpid/broker/SelfDestructQueue.h @@ -0,0 +1,45 @@ +#ifndef QPID_BROKER_SELFDESTRUCTQUEUE_H +#define QPID_BROKER_SELFDESTRUCTQUEUE_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 "qpid/broker/Queue.h" + +namespace qpid { +namespace broker { + +/** + * Deletes itself when breaching specified maximum depth (useful as + * subscription queue for consumers that should be ejecetd from topic + * when they can't keep up). + */ +class SelfDestructQueue : public Queue +{ + public: + public: + SelfDestructQueue(const std::string&, const QueueSettings&, MessageStore* const, management::Manageable*, Broker*); + bool checkDepth(const QueueDepth& increment, const Message&); + private: + private: +}; +}} // namespace qpid::broker + +#endif /*!QPID_BROKER_SELFDESTRUCTQUEUE_H*/ diff --git a/qpid/cpp/src/qpid/broker/SemanticState.cpp b/qpid/cpp/src/qpid/broker/SemanticState.cpp index 4570e3bd87..18c29c09f9 100644 --- a/qpid/cpp/src/qpid/broker/SemanticState.cpp +++ b/qpid/cpp/src/qpid/broker/SemanticState.cpp @@ -31,6 +31,7 @@ #include "qpid/broker/Selector.h" #include "qpid/broker/SessionContext.h" #include "qpid/broker/SessionOutputException.h" +#include "qpid/broker/TransactionObserver.h" #include "qpid/broker/TxAccept.h" #include "qpid/broker/amqp_0_10/MessageTransfer.h" #include "qpid/framing/reply_exceptions.h" @@ -65,6 +66,7 @@ namespace broker { using namespace std; using boost::intrusive_ptr; +using boost::shared_ptr; using boost::bind; using namespace qpid::broker; using namespace qpid::framing; @@ -165,13 +167,15 @@ bool SemanticState::cancel(const string& tag) void SemanticState::startTx() { txBuffer = TxBuffer::shared_ptr(new TxBuffer()); + session.getBroker().getBrokerObservers().startTx(txBuffer); + session.startTx(); //just to update statistics } void SemanticState::commit(MessageStore* const store) { if (!txBuffer) throw CommandInvalidException(QPID_MSG("Session has not been selected for use with transactions")); - + session.commitTx(); //just to update statistics TxOp::shared_ptr txAck(static_cast<TxOp*>(new TxAccept(accumulatedAck, unacked))); txBuffer->enlist(txAck); if (txBuffer->commitLocal(store)) { @@ -185,7 +189,7 @@ void SemanticState::rollback() { if (!txBuffer) throw CommandInvalidException(QPID_MSG("Session has not been selected for use with transactions")); - + session.rollbackTx(); //just to update statistics txBuffer->rollback(); accumulatedAck.clear(); } @@ -202,6 +206,7 @@ void SemanticState::startDtx(const std::string& xid, DtxManager& mgr, bool join) } dtxBuffer.reset(new DtxBuffer(xid)); txBuffer = dtxBuffer; + session.getBroker().getBrokerObservers().startDtx(dtxBuffer); if (join) { mgr.join(xid, dtxBuffer); } else { @@ -432,8 +437,10 @@ bool SemanticStateConsumerImpl::checkCredit(const Message& msg) SemanticStateConsumerImpl::~SemanticStateConsumerImpl() { - if (mgmtObject != 0) + if (mgmtObject != 0) { + mgmtObject->debugStats("destroying"); mgmtObject->resourceDestroy (); + } } void SemanticState::disable(ConsumerImpl::shared_ptr c) @@ -658,9 +665,7 @@ Queue::shared_ptr SemanticState::getQueue(const string& name) const { if (name.empty()) { throw NotAllowedException(QPID_MSG("No queue name specified.")); } else { - queue = session.getBroker().getQueues().find(name); - if (!queue) - throw NotFoundException(QPID_MSG("Queue not found: "<<name)); + queue = session.getBroker().getQueues().get(name); } return queue; } @@ -767,7 +772,6 @@ void SemanticState::accepted(const SequenceSet& commands) { TxOp::shared_ptr txAck(new DtxAck(accumulatedAck, unacked)); accumulatedAck.clear(); dtxBuffer->enlist(txAck); - //mark the relevant messages as 'ended' in unacked //if the messages are already completed, they can be //removed from the record diff --git a/qpid/cpp/src/qpid/broker/SessionAdapter.cpp b/qpid/cpp/src/qpid/broker/SessionAdapter.cpp index 0124e88832..64e3fe1b8a 100644 --- a/qpid/cpp/src/qpid/broker/SessionAdapter.cpp +++ b/qpid/cpp/src/qpid/broker/SessionAdapter.cpp @@ -685,9 +685,7 @@ Queue::shared_ptr SessionAdapter::HandlerHelper::getQueue(const string& name) co if (name.empty()) { throw framing::IllegalArgumentException(QPID_MSG("No queue name specified.")); } else { - queue = session.getBroker().getQueues().find(name); - if (!queue) - throw framing::NotFoundException(QPID_MSG("Queue not found: "<<name)); + queue = session.getBroker().getQueues().get(name); } return queue; } diff --git a/qpid/cpp/src/qpid/broker/SessionHandler.cpp b/qpid/cpp/src/qpid/broker/SessionHandler.cpp index 93977c8a6e..ff7693e93a 100644 --- a/qpid/cpp/src/qpid/broker/SessionHandler.cpp +++ b/qpid/cpp/src/qpid/broker/SessionHandler.cpp @@ -39,7 +39,11 @@ SessionHandler::SessionHandler(amqp_0_10::Connection& c, ChannelId ch) proxy(out) {} -SessionHandler::~SessionHandler() {} +SessionHandler::~SessionHandler() +{ + if (session.get()) + connection.getBroker().getSessionManager().forget(session->getId()); +} void SessionHandler::connectionException( framing::connection::CloseCode code, const std::string& msg) diff --git a/qpid/cpp/src/qpid/broker/SessionState.cpp b/qpid/cpp/src/qpid/broker/SessionState.cpp index 421dc008a9..3995eb85dc 100644 --- a/qpid/cpp/src/qpid/broker/SessionState.cpp +++ b/qpid/cpp/src/qpid/broker/SessionState.cpp @@ -79,7 +79,27 @@ void SessionState::addManagementObject() { } } +void SessionState::startTx() { + if (mgmtObject) { mgmtObject->inc_TxnStarts(); } +} + +void SessionState::commitTx() { + if (mgmtObject) { + mgmtObject->inc_TxnCommits(); + mgmtObject->inc_TxnCount(); + } +} + +void SessionState::rollbackTx() { + if (mgmtObject) { + mgmtObject->inc_TxnRejects(); + mgmtObject->inc_TxnCount(); + } +} + SessionState::~SessionState() { + if (mgmtObject != 0) + mgmtObject->debugStats("destroying"); asyncCommandCompleter->cancel(); semanticState.closed(); if (mgmtObject != 0) diff --git a/qpid/cpp/src/qpid/broker/SessionState.h b/qpid/cpp/src/qpid/broker/SessionState.h index daf3767969..500a211a6f 100644 --- a/qpid/cpp/src/qpid/broker/SessionState.h +++ b/qpid/cpp/src/qpid/broker/SessionState.h @@ -127,6 +127,11 @@ class SessionState : public qpid::SessionState, // belonging to inter-broker bridges void addManagementObject(); + // transaction-related methods just to update statistics + void startTx(); + void commitTx(); + void rollbackTx(); + private: void handleCommand(framing::AMQMethodBody* method, const framing::SequenceNumber& id); void handleContent(framing::AMQFrame& frame, const framing::SequenceNumber& id); diff --git a/qpid/cpp/src/qpid/broker/System.cpp b/qpid/cpp/src/qpid/broker/System.cpp index 8d54427fdc..f3b6f96d0c 100644 --- a/qpid/cpp/src/qpid/broker/System.cpp +++ b/qpid/cpp/src/qpid/broker/System.cpp @@ -80,3 +80,9 @@ System::System (string _dataDir, Broker* broker) } } +System::~System () +{ + if (mgmtObject != 0) + mgmtObject->debugStats("destroying"); +} + diff --git a/qpid/cpp/src/qpid/broker/System.h b/qpid/cpp/src/qpid/broker/System.h index 52643fb2d5..4a4af275c4 100644 --- a/qpid/cpp/src/qpid/broker/System.h +++ b/qpid/cpp/src/qpid/broker/System.h @@ -45,6 +45,8 @@ class System : public management::Manageable System (std::string _dataDir, Broker* broker = 0); + ~System (); + management::ManagementObject::shared_ptr GetManagementObject(void) const { return mgmtObject; } diff --git a/qpid/cpp/src/qpid/broker/TopicExchange.cpp b/qpid/cpp/src/qpid/broker/TopicExchange.cpp index d49464b4e1..6a081bf65f 100644 --- a/qpid/cpp/src/qpid/broker/TopicExchange.cpp +++ b/qpid/cpp/src/qpid/broker/TopicExchange.cpp @@ -333,7 +333,10 @@ bool TopicExchange::isBound(Queue::shared_ptr queue, const string* const routing return false; } -TopicExchange::~TopicExchange() {} +TopicExchange::~TopicExchange() { + if (mgmtExchange != 0) + mgmtExchange->debugStats("destroying"); +} const std::string TopicExchange::typeName("topic"); diff --git a/qpid/cpp/src/qpid/broker/TopicExchange.h b/qpid/cpp/src/qpid/broker/TopicExchange.h index 46871a1c6b..b8b67bdafa 100644 --- a/qpid/cpp/src/qpid/broker/TopicExchange.h +++ b/qpid/cpp/src/qpid/broker/TopicExchange.h @@ -81,7 +81,7 @@ class TopicExchange : public virtual Exchange { }; public: - static const std::string typeName; + QPID_BROKER_EXTERN static const std::string typeName; static QPID_BROKER_EXTERN std::string normalize(const std::string& pattern); diff --git a/qpid/cpp/src/qpid/broker/TransactionObserver.h b/qpid/cpp/src/qpid/broker/TransactionObserver.h new file mode 100644 index 0000000000..5333d7b8d6 --- /dev/null +++ b/qpid/cpp/src/qpid/broker/TransactionObserver.h @@ -0,0 +1,82 @@ +#ifndef QPID_BROKER_TRANSACTIONOBSERVER_H +#define QPID_BROKER_TRANSACTIONOBSERVER_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 "DeliveryRecord.h" +#include <boost/shared_ptr.hpp> + +namespace qpid { + +namespace framing { +class SequenceSet; +} + +namespace broker { +class Queue; +class Message; +class TxBuffer; +class DtxBuffer; + +/** + * Interface for intercepting events in a transaction. + */ +class TransactionObserver { + public: + typedef boost::shared_ptr<Queue> QueuePtr; + typedef framing::SequenceNumber SequenceNumber; + + virtual ~TransactionObserver() {} + + /** Message enqueued in the transaction. */ + virtual void enqueue(const QueuePtr&, const Message&) = 0; + + /** + * Message is dequeued in the transaction (it was accepted by a consumer.) + *@param queuePosition: Sequence number of message on queue. + *@param replicationId: Replication sequence number, may be different. + */ + virtual void dequeue(const QueuePtr& queue, + SequenceNumber queueSeq, + SequenceNumber replicationSeq) = 0; + + virtual bool prepare() = 0; + virtual void commit() = 0; + virtual void rollback() = 0; +}; + +/** + * No-op TransactionObserver. + */ +class NullTransactionObserver : public TransactionObserver { + public: + void enqueue(const QueuePtr&, const Message&) {} + void dequeue(const QueuePtr&, SequenceNumber, SequenceNumber) {} + bool prepare() { return true; } + void commit() {} + void rollback() {} +}; + +}} // namespace qpid::broker + +#endif /*!QPID_BROKER_TRANSACTIONOBSERVER_H*/ diff --git a/qpid/cpp/src/qpid/broker/TxAccept.cpp b/qpid/cpp/src/qpid/broker/TxAccept.cpp index 928ac12c10..ee30dff957 100644 --- a/qpid/cpp/src/qpid/broker/TxAccept.cpp +++ b/qpid/cpp/src/qpid/broker/TxAccept.cpp @@ -7,9 +7,9 @@ * 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 @@ -19,6 +19,8 @@ * */ #include "qpid/broker/TxAccept.h" +#include "qpid/broker/TransactionObserver.h" +#include "qpid/broker/Queue.h" #include "qpid/log/Statement.h" using std::bind1st; @@ -28,54 +30,23 @@ using namespace qpid::broker; using qpid::framing::SequenceSet; using qpid::framing::SequenceNumber; -TxAccept::RangeOp::RangeOp(const AckRange& r) : range(r) {} -void TxAccept::RangeOp::prepare(TransactionContext* ctxt) +TxAccept::TxAccept(const SequenceSet& _acked, DeliveryRecords& _unacked) : + acked(_acked), unacked(_unacked) { - for_each(range.start, range.end, bind(&DeliveryRecord::dequeue, _1, ctxt)); + for(SequenceSet::RangeIterator i = acked.rangesBegin(); i != acked.rangesEnd(); ++i) + ranges.push_back(DeliveryRecord::findRange(unacked, i->first(), i->last())); } -void TxAccept::RangeOp::commit() -{ - for_each(range.start, range.end, bind(&DeliveryRecord::committed, _1)); - for_each(range.start, range.end, bind(&DeliveryRecord::setEnded, _1)); -} - -TxAccept::RangeOps::RangeOps(DeliveryRecords& u) : unacked(u) {} - -void TxAccept::RangeOps::operator()(SequenceNumber start, SequenceNumber end) -{ - ranges.push_back(RangeOp(DeliveryRecord::findRange(unacked, start, end))); -} - -void TxAccept::RangeOps::prepare(TransactionContext* ctxt) -{ - std::for_each(ranges.begin(), ranges.end(), bind(&RangeOp::prepare, _1, ctxt)); -} - -void TxAccept::RangeOps::commit() -{ - std::for_each(ranges.begin(), ranges.end(), bind(&RangeOp::commit, _1)); - //now remove if isRedundant(): - if (!ranges.empty()) { - DeliveryRecords::iterator begin = ranges.front().range.start; - DeliveryRecords::iterator end = ranges.back().range.end; - DeliveryRecords::iterator removed = remove_if(begin, end, mem_fun_ref(&DeliveryRecord::isRedundant)); - unacked.erase(removed, end); - } -} - -TxAccept::TxAccept(const SequenceSet& _acked, DeliveryRecords& _unacked) : - acked(_acked), unacked(_unacked), ops(unacked) -{ - //populate the ops - acked.for_each(ops); +void TxAccept::each(boost::function<void(DeliveryRecord&)> f) { + for(AckRanges::iterator i = ranges.begin(); i != ranges.end(); ++i) + for_each(i->start, i->end, f); } bool TxAccept::prepare(TransactionContext* ctxt) throw() { try{ - ops.prepare(ctxt); + each(bind(&DeliveryRecord::dequeue, _1, ctxt)); return true; }catch(const std::exception& e){ QPID_LOG(error, "Failed to prepare: " << e.what()); @@ -86,10 +57,19 @@ bool TxAccept::prepare(TransactionContext* ctxt) throw() } } -void TxAccept::commit() throw() +void TxAccept::commit() throw() { try { - ops.commit(); + each(bind(&DeliveryRecord::committed, _1)); + each(bind(&DeliveryRecord::setEnded, _1)); + //now remove if isRedundant(): + if (!ranges.empty()) { + DeliveryRecords::iterator begin = ranges.front().start; + DeliveryRecords::iterator end = ranges.back().end; + DeliveryRecords::iterator removed = + remove_if(begin, end, mem_fun_ref(&DeliveryRecord::isRedundant)); + unacked.erase(removed, end); + } } catch (const std::exception& e) { QPID_LOG(error, "Failed to commit: " << e.what()); } catch(...) { @@ -98,3 +78,13 @@ void TxAccept::commit() throw() } void TxAccept::rollback() throw() {} + +namespace { +void callObserverDR(boost::shared_ptr<TransactionObserver> observer, DeliveryRecord& dr) { + observer->dequeue(dr.getQueue(), dr.getMessageId(), dr.getReplicationId()); +} +} // namespace + +void TxAccept::callObserver(const ObserverPtr& observer) { + each(boost::bind(&callObserverDR, observer, _1)); +} diff --git a/qpid/cpp/src/qpid/broker/TxAccept.h b/qpid/cpp/src/qpid/broker/TxAccept.h index daf192285a..b4d55155a8 100644 --- a/qpid/cpp/src/qpid/broker/TxAccept.h +++ b/qpid/cpp/src/qpid/broker/TxAccept.h @@ -7,9 +7,9 @@ * 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 @@ -21,58 +21,45 @@ #ifndef _TxAccept_ #define _TxAccept_ -#include <algorithm> -#include <functional> -#include <list> #include "qpid/framing/SequenceSet.h" +#include "qpid/broker/BrokerImportExport.h" #include "qpid/broker/DeliveryRecord.h" #include "qpid/broker/TxOp.h" +#include <boost/function.hpp> +#include <algorithm> +#include <functional> +#include <list> namespace qpid { - namespace broker { - /** - * Defines the transactional behaviour for accepts received by - * a transactional channel. - */ - class TxAccept : public TxOp { - struct RangeOp - { - AckRange range; - - RangeOp(const AckRange& r); - void prepare(TransactionContext* ctxt); - void commit(); - }; - - struct RangeOps - { - std::vector<RangeOp> ranges; - DeliveryRecords& unacked; - - RangeOps(DeliveryRecords& u); +namespace broker { +/** + * Defines the transactional behaviour for accepts received by + * a transactional channel. + */ +class TxAccept : public TxOp { + typedef std::vector<AckRange> AckRanges; + typedef boost::shared_ptr<TransactionObserver> ObserverPtr; - void operator()(framing::SequenceNumber start, framing::SequenceNumber end); - void prepare(TransactionContext* ctxt); - void commit(); - }; + void each(boost::function<void(DeliveryRecord&)>); - framing::SequenceSet acked; - DeliveryRecords& unacked; - RangeOps ops; + framing::SequenceSet acked; + DeliveryRecords& unacked; + AckRanges ranges; - public: - /** - * @param acked a representation of the accumulation of - * acks received - * @param unacked the record of delivered messages - */ - TxAccept(const framing::SequenceSet& acked, DeliveryRecords& unacked); - virtual bool prepare(TransactionContext* ctxt) throw(); - virtual void commit() throw(); - virtual void rollback() throw(); - virtual ~TxAccept(){} - }; - } + public: + /** + * @param acked a representation of the accumulation of + * acks received + * @param unacked the record of delivered messages + */ + QPID_BROKER_EXTERN TxAccept(const framing::SequenceSet& acked, DeliveryRecords& unacked); + virtual bool prepare(TransactionContext* ctxt) throw(); + virtual void commit() throw(); + virtual void rollback() throw(); + virtual void callObserver(const ObserverPtr&); + virtual ~TxAccept(){} +}; +} } diff --git a/qpid/cpp/src/qpid/broker/TxBuffer.cpp b/qpid/cpp/src/qpid/broker/TxBuffer.cpp index 7663cc525f..a8df4fb214 100644 --- a/qpid/cpp/src/qpid/broker/TxBuffer.cpp +++ b/qpid/cpp/src/qpid/broker/TxBuffer.cpp @@ -19,6 +19,7 @@ * */ #include "qpid/broker/TxBuffer.h" +#include "qpid/broker/TransactionObserver.h" #include "qpid/log/Statement.h" #include <boost/mem_fn.hpp> @@ -26,8 +27,11 @@ using boost::mem_fn; using namespace qpid::broker; +TxBuffer::TxBuffer() : observer(new NullTransactionObserver) {} + bool TxBuffer::prepare(TransactionContext* const ctxt) { + if (!observer->prepare()) return false; for(op_iterator i = ops.begin(); i != ops.end(); i++){ if(!(*i)->prepare(ctxt)){ return false; @@ -38,18 +42,21 @@ bool TxBuffer::prepare(TransactionContext* const ctxt) void TxBuffer::commit() { + observer->commit(); std::for_each(ops.begin(), ops.end(), mem_fn(&TxOp::commit)); ops.clear(); } void TxBuffer::rollback() { + observer->rollback(); std::for_each(ops.begin(), ops.end(), mem_fn(&TxOp::rollback)); ops.clear(); } void TxBuffer::enlist(TxOp::shared_ptr op) { + op->callObserver(observer); ops.push_back(op); } diff --git a/qpid/cpp/src/qpid/broker/TxBuffer.h b/qpid/cpp/src/qpid/broker/TxBuffer.h index 22e2f06be1..4570c570a2 100644 --- a/qpid/cpp/src/qpid/broker/TxBuffer.h +++ b/qpid/cpp/src/qpid/broker/TxBuffer.h @@ -7,9 +7,9 @@ * 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 @@ -34,21 +34,21 @@ * transaction. This work can be committed or rolled back. Committing * is a two-stage process: first all the operations should be * prepared, then if that succeeds they can be committed. - * + * * In the 2pc case, a successful prepare may be followed by either a * commit or a rollback. - * + * * Atomicity of prepare is ensured by using a lower level * transactional facility. This saves explicitly rolling back all the * successfully prepared ops when one of them fails. i.e. we do not * use 2pc internally, we instead ensure that prepare is atomic at a * lower level. This makes individual prepare operations easier to * code. - * + * * Transactions on a messaging broker effect three types of 'action': * (1) updates to persistent storage (2) updates to transient storage * or cached data (3) network writes. - * + * * Of these, (1) should always occur atomically during prepare to * ensure that if the broker crashes while a transaction is being * completed the persistent state (which is all that then remains) is @@ -58,59 +58,74 @@ * TransactionalStore in use. */ namespace qpid { - namespace broker { - class TxBuffer{ - typedef std::vector<TxOp::shared_ptr>::iterator op_iterator; - std::vector<TxOp::shared_ptr> ops; - protected: - - public: - typedef boost::shared_ptr<TxBuffer> shared_ptr; - /** - * Adds an operation to the transaction. - */ - QPID_BROKER_EXTERN void enlist(TxOp::shared_ptr op); - - /** - * Requests that all ops are prepared. This should - * primarily involve making sure that a persistent record - * of the operations is stored where necessary. - * - * Once prepared, a transaction can be committed (or in - * the 2pc case, rolled back). - * - * @returns true if all the operations prepared - * successfully, false if not. - */ - QPID_BROKER_EXTERN bool prepare(TransactionContext* const ctxt); - - /** - * Signals that the ops all prepared successfully and can - * now commit, i.e. the operation can now be fully carried - * out. - * - * Should only be called after a call to prepare() returns - * true. - */ - QPID_BROKER_EXTERN void commit(); - - /** - * Signals that all ops can be rolled back. - * - * Should only be called either after a call to prepare() - * returns true (2pc) or instead of a prepare call - * ('server-local') - */ - QPID_BROKER_EXTERN void rollback(); - - /** - * Helper method for managing the process of server local - * commit - */ - QPID_BROKER_EXTERN bool commitLocal(TransactionalStore* const store); - }; + +namespace broker { +class TransactionObserver; + +class TxBuffer { + private: + typedef std::vector<TxOp::shared_ptr>::iterator op_iterator; + std::vector<TxOp::shared_ptr> ops; + boost::shared_ptr<TransactionObserver> observer; + + public: + typedef boost::shared_ptr<TxBuffer> shared_ptr; + + QPID_BROKER_EXTERN TxBuffer(); + + /** + * Adds an operation to the transaction. + */ + QPID_BROKER_EXTERN void enlist(TxOp::shared_ptr op); + + /** + * Requests that all ops are prepared. This should + * primarily involve making sure that a persistent record + * of the operations is stored where necessary. + * + * Once prepared, a transaction can be committed (or in + * the 2pc case, rolled back). + * + * @returns true if all the operations prepared + * successfully, false if not. + */ + QPID_BROKER_EXTERN bool prepare(TransactionContext* const ctxt); + + /** + * Signals that the ops all prepared successfully and can + * now commit, i.e. the operation can now be fully carried + * out. + * + * Should only be called after a call to prepare() returns + * true. + */ + QPID_BROKER_EXTERN void commit(); + + /** + * Signals that all ops can be rolled back. + * + * Should only be called either after a call to prepare() + * returns true (2pc) or instead of a prepare call + * ('server-local') + */ + QPID_BROKER_EXTERN void rollback(); + + /** + * Helper method for managing the process of server local + * commit + */ + QPID_BROKER_EXTERN bool commitLocal(TransactionalStore* const store); + + + QPID_BROKER_EXTERN void setObserver(boost::shared_ptr<TransactionObserver> o) { + observer = o; + } + + QPID_BROKER_EXTERN boost::shared_ptr<TransactionObserver> getObserver() const { + return observer; } -} +}; +}} // namespace qpid::broker #endif diff --git a/qpid/cpp/src/qpid/broker/TxOp.h b/qpid/cpp/src/qpid/broker/TxOp.h index 775efc92f7..00303eb27c 100644 --- a/qpid/cpp/src/qpid/broker/TxOp.h +++ b/qpid/cpp/src/qpid/broker/TxOp.h @@ -25,17 +25,19 @@ #include <boost/shared_ptr.hpp> namespace qpid { - namespace broker { +namespace broker { +class TransactionObserver; - class TxOp{ - public: - typedef boost::shared_ptr<TxOp> shared_ptr; +class TxOp{ + public: + typedef boost::shared_ptr<TxOp> shared_ptr; - virtual bool prepare(TransactionContext*) throw() = 0; - virtual void commit() throw() = 0; - virtual void rollback() throw() = 0; - virtual ~TxOp(){} - }; + virtual bool prepare(TransactionContext*) throw() = 0; + virtual void commit() throw() = 0; + virtual void rollback() throw() = 0; + virtual void callObserver(const boost::shared_ptr<TransactionObserver>&) = 0; + virtual ~TxOp(){} +}; }} // namespace qpid::broker diff --git a/qpid/cpp/src/qpid/broker/Vhost.cpp b/qpid/cpp/src/qpid/broker/Vhost.cpp index e72118b570..8fd88601f5 100644 --- a/qpid/cpp/src/qpid/broker/Vhost.cpp +++ b/qpid/cpp/src/qpid/broker/Vhost.cpp @@ -43,6 +43,11 @@ Vhost::Vhost (qpid::management::Manageable* parentBroker, Broker* broker) } } +Vhost::~Vhost () { + if (mgmtObject != 0) + mgmtObject->debugStats("destroying"); +} + void Vhost::setFederationTag(const std::string& tag) { mgmtObject->set_federationTag(tag); diff --git a/qpid/cpp/src/qpid/broker/Vhost.h b/qpid/cpp/src/qpid/broker/Vhost.h index 599b821870..06a11db8ea 100644 --- a/qpid/cpp/src/qpid/broker/Vhost.h +++ b/qpid/cpp/src/qpid/broker/Vhost.h @@ -40,6 +40,8 @@ class Vhost : public management::Manageable Vhost (management::Manageable* parentBroker, Broker* broker = 0); + ~Vhost (); + management::ManagementObject::shared_ptr GetManagementObject (void) const { return mgmtObject; } void setFederationTag(const std::string& tag); diff --git a/qpid/cpp/src/qpid/broker/amqp/Connection.cpp b/qpid/cpp/src/qpid/broker/amqp/Connection.cpp index 2cb0994138..d4221246c5 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Connection.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Connection.cpp @@ -182,12 +182,9 @@ void Connection::open() void Connection::readPeerProperties() { - /** - * TODO: enable when proton 0.5 has been released: qpid::types::Variant::Map properties; DataReader::read(pn_connection_remote_properties(connection), properties); setPeerProperties(properties); - */ } void Connection::closed() diff --git a/qpid/cpp/src/qpid/broker/amqp/DataReader.cpp b/qpid/cpp/src/qpid/broker/amqp/DataReader.cpp index 957134d0e6..ca3e6daabd 100644 --- a/qpid/cpp/src/qpid/broker/amqp/DataReader.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/DataReader.cpp @@ -160,7 +160,7 @@ void DataReader::readArray(pn_data_t* /*data*/, const qpid::amqp::Descriptor* /* void DataReader::readList(pn_data_t* data, const qpid::amqp::Descriptor* descriptor) { size_t count = pn_data_get_list(data); - bool skip = reader.onStartList(count, qpid::amqp::CharSequence(), descriptor); + bool skip = reader.onStartList(count, qpid::amqp::CharSequence(), qpid::amqp::CharSequence(), descriptor); if (!skip) { pn_data_enter(data); for (size_t i = 0; i < count && pn_data_next(data); ++i) { @@ -174,7 +174,7 @@ void DataReader::readList(pn_data_t* data, const qpid::amqp::Descriptor* descrip void DataReader::readMap(pn_data_t* data, const qpid::amqp::Descriptor* descriptor) { size_t count = pn_data_get_map(data); - reader.onStartMap(count, qpid::amqp::CharSequence(), descriptor); + reader.onStartMap(count, qpid::amqp::CharSequence(), qpid::amqp::CharSequence(), descriptor); pn_data_enter(data); for (size_t i = 0; i < count && pn_data_next(data); ++i) { read(data); diff --git a/qpid/cpp/src/qpid/broker/amqp/Incoming.cpp b/qpid/cpp/src/qpid/broker/amqp/Incoming.cpp index 119d05af60..f54328bc2e 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Incoming.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Incoming.cpp @@ -25,6 +25,7 @@ #include "qpid/amqp/descriptors.h" #include "qpid/broker/AsyncCompletion.h" #include "qpid/broker/Message.h" +#include "qpid/broker/Broker.h" namespace qpid { namespace broker { @@ -104,7 +105,7 @@ namespace { } DecodingIncoming::DecodingIncoming(pn_link_t* link, Broker& broker, Session& parent, const std::string& source, const std::string& target, const std::string& name) - : Incoming(link, broker, parent, source, target, name), session(parent.shared_from_this()) {} + : Incoming(link, broker, parent, source, target, name), session(parent.shared_from_this()), expiryPolicy(broker.getExpiryPolicy()) {} DecodingIncoming::~DecodingIncoming() {} void DecodingIncoming::readable(pn_delivery_t* delivery) @@ -116,6 +117,7 @@ void DecodingIncoming::readable(pn_delivery_t* delivery) qpid::broker::Message message(received, received); userid.verify(message.getUserId()); + message.computeExpiration(expiryPolicy); handle(message); --window; received->begin(); diff --git a/qpid/cpp/src/qpid/broker/amqp/Incoming.h b/qpid/cpp/src/qpid/broker/amqp/Incoming.h index 8852766eda..127f8cecf9 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Incoming.h +++ b/qpid/cpp/src/qpid/broker/amqp/Incoming.h @@ -77,6 +77,7 @@ class DecodingIncoming : public Incoming virtual void handle(qpid::broker::Message&) = 0; private: boost::shared_ptr<Session> session; + boost::intrusive_ptr<ExpiryPolicy> expiryPolicy; }; }}} // namespace qpid::broker::amqp diff --git a/qpid/cpp/src/qpid/broker/amqp/Message.cpp b/qpid/cpp/src/qpid/broker/amqp/Message.cpp index 3dcf1c14e6..572eea3881 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Message.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Message.cpp @@ -21,9 +21,13 @@ #include "Message.h" #include "qpid/amqp/Decoder.h" #include "qpid/amqp/descriptors.h" -#include "qpid/amqp/Reader.h" -#include "qpid/amqp/MessageEncoder.h" +#include "qpid/amqp/ListBuilder.h" +#include "qpid/amqp/MapBuilder.h" #include "qpid/amqp/MapHandler.h" +#include "qpid/amqp/MessageEncoder.h" +#include "qpid/amqp/Reader.h" +#include "qpid/amqp/typecodes.h" +#include "qpid/types/encodings.h" #include "qpid/log/Statement.h" #include "qpid/framing/Buffer.h" #include <string.h> @@ -121,8 +125,8 @@ namespace { } } - bool onStartList(uint32_t, const CharSequence&, const Descriptor*) { return false; } - bool onStartMap(uint32_t, const CharSequence&, const Descriptor*) { return false; } + bool onStartList(uint32_t, const CharSequence&, const CharSequence&, const Descriptor*) { return false; } + bool onStartMap(uint32_t, const CharSequence&, const CharSequence&, const Descriptor*) { return false; } bool onStartArray(uint32_t, const CharSequence&, const Constructor&, const Descriptor*) { return false; } public: @@ -144,8 +148,12 @@ void Message::processProperties(MapHandler& mh) const { //and whether it should indeed only be the content that is thus //measured uint64_t Message::getContentSize() const { return data.size(); } -//getContent() is used primarily for decoding qmf messages in management and ha -std::string Message::getContent() const { return empty; } +//getContent() is used primarily for decoding qmf messages in +//management and ha, but also by the xml exchange +std::string Message::getContent() const +{ + return std::string(body.data, body.size); +} Message::Message(size_t size) : data(size) { @@ -253,12 +261,54 @@ void Message::onGroupId(const qpid::amqp::CharSequence&) {} void Message::onGroupSequence(uint32_t) {} void Message::onReplyToGroupId(const qpid::amqp::CharSequence&) {} -void Message::onApplicationProperties(const qpid::amqp::CharSequence& v) { applicationProperties = v; } -void Message::onDeliveryAnnotations(const qpid::amqp::CharSequence& v) { deliveryAnnotations = v; } -void Message::onMessageAnnotations(const qpid::amqp::CharSequence& v) { messageAnnotations = v; } -void Message::onBody(const qpid::amqp::CharSequence& v, const qpid::amqp::Descriptor&) { body = v; } -void Message::onBody(const qpid::types::Variant&, const qpid::amqp::Descriptor&) {} -void Message::onFooter(const qpid::amqp::CharSequence& v) { footer = v; } +void Message::onApplicationProperties(const qpid::amqp::CharSequence& v, const qpid::amqp::CharSequence&) { applicationProperties = v; } +void Message::onDeliveryAnnotations(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence& v) { deliveryAnnotations = v; } +void Message::onMessageAnnotations(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence& v) { messageAnnotations = v; } + +void Message::onData(const qpid::amqp::CharSequence& v) { body = v; } +void Message::onAmqpSequence(const qpid::amqp::CharSequence& v) { body = v; bodyType = qpid::amqp::typecodes::LIST_NAME; } +void Message::onAmqpValue(const qpid::amqp::CharSequence& v, const std::string& t) +{ + body = v; + if (t == qpid::amqp::typecodes::STRING_NAME) { + bodyType = qpid::types::encodings::UTF8; + } else if (t == qpid::amqp::typecodes::SYMBOL_NAME) { + bodyType = qpid::types::encodings::ASCII; + } else if (t == qpid::amqp::typecodes::BINARY_NAME) { + bodyType = qpid::types::encodings::BINARY; + } else { + bodyType = t; + } +} +void Message::onAmqpValue(const qpid::types::Variant& v) { typedBody = v; } + +void Message::onFooter(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence& v) { footer = v; } + +bool Message::isTypedBody() const +{ + return !typedBody.isVoid() || !bodyType.empty(); +} + +qpid::types::Variant Message::getTypedBody() const +{ + if (bodyType == qpid::amqp::typecodes::LIST_NAME) { + qpid::amqp::ListBuilder builder; + qpid::amqp::Decoder decoder(body.data, body.size); + decoder.read(builder); + return builder.getList(); + } else if (bodyType == qpid::amqp::typecodes::MAP_NAME) { + qpid::amqp::MapBuilder builder; + qpid::amqp::Decoder decoder(body.data, body.size); + decoder.read(builder); + return builder.getMap(); + } else if (!bodyType.empty()) { + qpid::types::Variant value(std::string(body.data, body.size)); + value.setEncoding(bodyType); + return value; + } else { + return typedBody; + } +} //PersistableMessage interface: @@ -292,31 +342,41 @@ void Message::decodeHeader(framing::Buffer& buffer) } void Message::decodeContent(framing::Buffer& /*buffer*/) {} -boost::intrusive_ptr<PersistableMessage> Message::merge(const std::map<std::string, qpid::types::Variant>& annotations) const +boost::intrusive_ptr<PersistableMessage> Message::merge(const std::map<std::string, qpid::types::Variant>& added) const { //message- or delivery- annotations? would have to determine that from the name, for now assume always message-annotations - size_t extra = 0; + std::map<std::string, qpid::types::Variant> combined; + const std::map<std::string, qpid::types::Variant>* annotations(0); if (messageAnnotations) { - //TODO: actual merge required + //combine existing and added annotations (TODO: this could be + //optimised by avoiding the decode and simply 'editing' the + //size and count in the raw data, then appending the new + //elements). + qpid::amqp::MapBuilder builder; + qpid::amqp::Decoder decoder(messageAnnotations.data, messageAnnotations.size); + decoder.read(builder); + combined = builder.getMap(); + for (std::map<std::string, qpid::types::Variant>::const_iterator i = added.begin(); i != added.end(); ++i) { + combined[i->first] = i->second; + } + annotations = &combined; } else { - //add whole new section - extra = qpid::amqp::MessageEncoder::getEncodedSize(annotations, true); + //additions form a whole new section + annotations = &added; } - boost::intrusive_ptr<Message> copy(new Message(data.size()+extra)); + size_t annotationsSize = qpid::amqp::MessageEncoder::getEncodedSize(*annotations, true) + 3/*descriptor*/; + + boost::intrusive_ptr<Message> copy(new Message(bareMessage.size+footer.size+deliveryAnnotations.size+annotationsSize)); size_t position(0); - if (deliveryAnnotations) { + if (deliveryAnnotations.size) { ::memcpy(©->data[position], deliveryAnnotations.data, deliveryAnnotations.size); position += deliveryAnnotations.size; } - if (messageAnnotations) { - //TODO: actual merge required - ::memcpy(©->data[position], messageAnnotations.data, messageAnnotations.size); - position += messageAnnotations.size; - } else { - qpid::amqp::MessageEncoder encoder(©->data[position], extra); - encoder.writeMap(annotations, &qpid::amqp::message::MESSAGE_ANNOTATIONS, true); - position += extra; - } + + qpid::amqp::Encoder encoder(©->data[position], annotationsSize); + encoder.writeMap(*annotations, &qpid::amqp::message::MESSAGE_ANNOTATIONS, true); + position += encoder.getPosition(); + if (bareMessage) { ::memcpy(©->data[position], bareMessage.data, bareMessage.size); position += bareMessage.size; @@ -325,7 +385,18 @@ boost::intrusive_ptr<PersistableMessage> Message::merge(const std::map<std::stri ::memcpy(©->data[position], footer.data, footer.size); position += footer.size; } + copy->data.resize(position);//annotationsSize may be slightly bigger than needed if optimisations are used (e.g. smallint) copy->scan(); + { + qpid::amqp::MapBuilder builder; + qpid::amqp::Decoder decoder(copy->messageAnnotations.data, copy->messageAnnotations.size); + decoder.read(builder); + QPID_LOG(notice, "Merged annotations are now: " << builder.getMap() << " raw=" << std::hex << std::string(copy->messageAnnotations.data, copy->messageAnnotations.size) << " " << copy->messageAnnotations.size << " bytes"); + } + assert(copy->messageAnnotations); + assert(copy->bareMessage.size == bareMessage.size); + assert(copy->footer.size == footer.size); + assert(copy->deliveryAnnotations.size == deliveryAnnotations.size); return copy; } diff --git a/qpid/cpp/src/qpid/broker/amqp/Message.h b/qpid/cpp/src/qpid/broker/amqp/Message.h index cbf8669fc1..3a7c4529de 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Message.h +++ b/qpid/cpp/src/qpid/broker/amqp/Message.h @@ -64,6 +64,8 @@ class Message : public qpid::broker::Message::Encoding, private qpid::amqp::Mess qpid::amqp::CharSequence getBareMessage() const; qpid::amqp::CharSequence getBody() const; qpid::amqp::CharSequence getFooter() const; + bool isTypedBody() const; + qpid::types::Variant getTypedBody() const; Message(size_t size); char* getData(); @@ -109,6 +111,8 @@ class Message : public qpid::broker::Message::Encoding, private qpid::amqp::Mess //body: qpid::amqp::CharSequence body; + qpid::types::Variant typedBody; + std::string bodyType; //footer: qpid::amqp::CharSequence footer; @@ -136,12 +140,16 @@ class Message : public qpid::broker::Message::Encoding, private qpid::amqp::Mess void onGroupSequence(uint32_t); void onReplyToGroupId(const qpid::amqp::CharSequence&); - void onApplicationProperties(const qpid::amqp::CharSequence&); - void onDeliveryAnnotations(const qpid::amqp::CharSequence&); - void onMessageAnnotations(const qpid::amqp::CharSequence&); - void onBody(const qpid::amqp::CharSequence&, const qpid::amqp::Descriptor&); - void onBody(const qpid::types::Variant&, const qpid::amqp::Descriptor&); - void onFooter(const qpid::amqp::CharSequence&); + void onApplicationProperties(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence&); + void onDeliveryAnnotations(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence&); + void onMessageAnnotations(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence&); + + void onData(const qpid::amqp::CharSequence&); + void onAmqpSequence(const qpid::amqp::CharSequence&); + void onAmqpValue(const qpid::amqp::CharSequence&, const std::string& type); + void onAmqpValue(const qpid::types::Variant&); + + void onFooter(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence&); }; }}} // namespace qpid::broker::amqp diff --git a/qpid/cpp/src/qpid/broker/amqp/Outgoing.cpp b/qpid/cpp/src/qpid/broker/amqp/Outgoing.cpp index 68ff979aa4..e8c05ed7b0 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Outgoing.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Outgoing.cpp @@ -29,6 +29,7 @@ #include "qpid/sys/OutputControl.h" #include "qpid/amqp/descriptors.h" #include "qpid/amqp/MessageEncoder.h" +#include "qpid/framing/Buffer.h" #include "qpid/framing/reply_exceptions.h" #include "qpid/log/Statement.h" @@ -44,14 +45,16 @@ void Outgoing::wakeup() session.wakeup(); } -OutgoingFromQueue::OutgoingFromQueue(Broker& broker, const std::string& source, const std::string& target, boost::shared_ptr<Queue> q, pn_link_t* l, Session& session, qpid::sys::OutputControl& o, bool e, bool p) +OutgoingFromQueue::OutgoingFromQueue(Broker& broker, const std::string& source, const std::string& target, boost::shared_ptr<Queue> q, pn_link_t* l, Session& session, + qpid::sys::OutputControl& o, SubscriptionType type, bool e, bool p) : Outgoing(broker, session, source, target, pn_link_name(l)), - Consumer(pn_link_name(l), /*FIXME*/CONSUMER), + Consumer(pn_link_name(l), type), exclusive(e), isControllingUser(p), queue(q), deliveries(5000), link(l), out(o), current(0), outstanding(0), - buffer(1024)/*used only for header at present*/ + buffer(1024)/*used only for header at present*/, + unreliable(pn_link_remote_snd_settle_mode(link) == PN_SND_SETTLED) { for (size_t i = 0 ; i < deliveries.capacity(); ++i) { deliveries[i].init(i); @@ -91,8 +94,7 @@ void OutgoingFromQueue::write(const char* data, size_t size) void OutgoingFromQueue::handle(pn_delivery_t* delivery) { - pn_delivery_tag_t tag = pn_delivery_tag(delivery); - size_t i = *reinterpret_cast<const size_t*>(tag.bytes); + size_t i = Record::getIndex(pn_delivery_tag(delivery)); Record& r = deliveries[i]; if (pn_delivery_writable(delivery)) { assert(r.msg); @@ -104,6 +106,7 @@ void OutgoingFromQueue::handle(pn_delivery_t* delivery) write(&buffer[0], encoder.getPosition()); Translation t(r.msg); t.write(*this); + if (unreliable) pn_delivery_settle(delivery); if (pn_link_advance(link)) { --outstanding; outgoingMessageSent(); @@ -112,26 +115,28 @@ void OutgoingFromQueue::handle(pn_delivery_t* delivery) QPID_LOG(error, "Failed to send message " << r.msg.getSequence() << " from " << queue->getName() << ", index=" << r.index); } } - if (pn_delivery_updated(delivery)) { + if (unreliable) { + if (preAcquires()) queue->dequeue(0, r.cursor); + r.reset(); + } else if (pn_delivery_updated(delivery)) { assert(r.delivery == delivery); r.disposition = pn_delivery_remote_state(delivery); if (r.disposition) { switch (r.disposition) { case PN_ACCEPTED: - //TODO: only if consuming - queue->dequeue(0, r.cursor); + if (preAcquires()) queue->dequeue(0, r.cursor); outgoingMessageAccepted(); break; case PN_REJECTED: - queue->reject(r.cursor); + if (preAcquires()) queue->reject(r.cursor); outgoingMessageRejected(); break; case PN_RELEASED: - queue->release(r.cursor, false);//TODO: for PN_RELEASED, delivery count should not be incremented + if (preAcquires()) queue->release(r.cursor, false);//TODO: for PN_RELEASED, delivery count should not be incremented outgoingMessageRejected();//TODO: not quite true... break; case PN_MODIFIED: - queue->release(r.cursor, true);//TODO: proper handling of modified + if (preAcquires()) queue->release(r.cursor, true);//TODO: proper handling of modified outgoingMessageRejected();//TODO: not quite true... break; default: @@ -251,12 +256,17 @@ qpid::broker::OwnershipToken* OutgoingFromQueue::getSession() return 0; } -OutgoingFromQueue::Record::Record() : delivery(0), disposition(0), index(0) {} +OutgoingFromQueue::Record::Record() : delivery(0), disposition(0), index(0) +{ + tag.bytes = tagData; + tag.size = TAG_WIDTH; +} void OutgoingFromQueue::Record::init(size_t i) { index = i; - tag.bytes = reinterpret_cast<const char*>(&index); - tag.size = sizeof(index); + qpid::framing::Buffer buffer(tagData, tag.size); + assert(index <= std::numeric_limits<uint32_t>::max()); + buffer.putLong(index); } void OutgoingFromQueue::Record::reset() { @@ -266,5 +276,13 @@ void OutgoingFromQueue::Record::reset() disposition = 0; } +size_t OutgoingFromQueue::Record::getIndex(pn_delivery_tag_t t) +{ + assert(t.size == TAG_WIDTH); + qpid::framing::Buffer buffer(const_cast<char*>(t.bytes)/*won't ever be written to*/, t.size); + return (size_t) buffer.getLong(); +} + + }}} // namespace qpid::broker::amqp diff --git a/qpid/cpp/src/qpid/broker/amqp/Outgoing.h b/qpid/cpp/src/qpid/broker/amqp/Outgoing.h index 86d7d46111..81994f2b66 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Outgoing.h +++ b/qpid/cpp/src/qpid/broker/amqp/Outgoing.h @@ -88,7 +88,8 @@ class Outgoing : public ManagedOutgoingLink class OutgoingFromQueue : public Outgoing, public qpid::broker::Consumer, public boost::enable_shared_from_this<OutgoingFromQueue> { public: - OutgoingFromQueue(Broker&, const std::string& source, const std::string& target, boost::shared_ptr<Queue> q, pn_link_t* l, Session&, qpid::sys::OutputControl& o, bool exclusive, bool isControllingUser); + OutgoingFromQueue(Broker&, const std::string& source, const std::string& target, boost::shared_ptr<Queue> q, pn_link_t* l, Session&, + qpid::sys::OutputControl& o, SubscriptionType type, bool exclusive, bool isControllingUser); void setSubjectFilter(const std::string&); void setSelectorFilter(const std::string&); void init(); @@ -117,10 +118,17 @@ class OutgoingFromQueue : public Outgoing, public qpid::broker::Consumer, public int disposition; size_t index; pn_delivery_tag_t tag; + //The delivery tag is a 4 byte value representing the + //index. It is encoded separately to avoid alignment issues. + //The number of deliveries held here is always strictly + //bounded, so 4 bytes is more than enough. + static const size_t TAG_WIDTH = sizeof(uint32_t); + char tagData[TAG_WIDTH]; Record(); void init(size_t i); void reset(); + static size_t getIndex(pn_delivery_tag_t); }; const bool exclusive; @@ -134,6 +142,7 @@ class OutgoingFromQueue : public Outgoing, public qpid::broker::Consumer, public std::vector<char> buffer; std::string subjectFilter; boost::scoped_ptr<Selector> selector; + bool unreliable; }; }}} // namespace qpid::broker::amqp diff --git a/qpid/cpp/src/qpid/broker/amqp/Relay.cpp b/qpid/cpp/src/qpid/broker/amqp/Relay.cpp index a08971cb5c..83b3e64ee6 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Relay.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Relay.cpp @@ -105,14 +105,14 @@ void Relay::detached(Outgoing*) { out = 0; isDetached = true; - std::cerr << "Outgoing link detached from relay" << std::endl; + QPID_LOG(info, "Outgoing link detached from relay [" << this << "]"); if (in) in->wakeup(); } void Relay::detached(Incoming*) { in = 0; isDetached = true; - std::cerr << "Incoming link detached from relay" << std::endl; + QPID_LOG(info, "Incoming link detached from relay [" << this << "]"); if (out) out->wakeup(); } @@ -139,13 +139,13 @@ void OutgoingFromRelay::handle(pn_delivery_t* delivery) if (pn_delivery_writable(delivery)) { if (transfer->write(link)) { outgoingMessageSent(); - QPID_LOG(debug, "Sent relayed message " << name); + QPID_LOG(debug, "Sent relayed message " << name << " [" << relay.get() << "]"); } else { - QPID_LOG(error, "Failed to send relayed message " << name); + QPID_LOG(error, "Failed to send relayed message " << name << " [" << relay.get() << "]"); } } if (pn_delivery_updated(delivery)) { - pn_disposition_t d = transfer->updated(); + uint64_t d = transfer->updated(); switch (d) { case PN_ACCEPTED: outgoingMessageAccepted(); @@ -226,6 +226,7 @@ void IncomingToRelay::detached() relay->detached(this); } +BufferedTransfer::BufferedTransfer() : disposition(0) {} void BufferedTransfer::initIn(pn_link_t* link, pn_delivery_t* d) { in.handle = d; @@ -264,7 +265,7 @@ void BufferedTransfer::initOut(pn_link_t* link) pn_delivery_set_context(out.handle, this); } -pn_disposition_t BufferedTransfer::updated() +uint64_t BufferedTransfer::updated() { disposition = pn_delivery_remote_state(out.handle); if (disposition) { diff --git a/qpid/cpp/src/qpid/broker/amqp/Relay.h b/qpid/cpp/src/qpid/broker/amqp/Relay.h index 0c2d48b346..ef700690fd 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Relay.h +++ b/qpid/cpp/src/qpid/broker/amqp/Relay.h @@ -45,10 +45,11 @@ struct Delivery class BufferedTransfer { public: + BufferedTransfer(); void initIn(pn_link_t* link, pn_delivery_t* d); bool settle(); void initOut(pn_link_t* link); - pn_disposition_t updated(); + uint64_t updated(); bool write(pn_link_t*); private: std::vector<char> data; @@ -56,7 +57,7 @@ class BufferedTransfer Delivery out; pn_delivery_tag_t dt; std::vector<char> tag; - pn_disposition_t disposition; + uint64_t disposition; }; /** diff --git a/qpid/cpp/src/qpid/broker/amqp/SaslClient.cpp b/qpid/cpp/src/qpid/broker/amqp/SaslClient.cpp index 678fddbba9..4317d18525 100644 --- a/qpid/cpp/src/qpid/broker/amqp/SaslClient.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/SaslClient.cpp @@ -36,7 +36,7 @@ namespace amqp { SaslClient::SaslClient(qpid::sys::OutputControl& out_, const std::string& id, boost::shared_ptr<Interconnect> c, std::auto_ptr<qpid::Sasl> s, const std::string& hostname_, const std::string& mechs, const qpid::sys::SecuritySettings& t) : qpid::amqp::SaslClient(id), out(out_), connection(c), sasl(s), - hostname(hostname_), allowedMechanisms(mechs), transport(t), readHeader(true), writeHeader(false), haveOutput(false), state(NONE) {} + hostname(hostname_), allowedMechanisms(mechs), transport(t), readHeader(true), writeHeader(false), haveOutput(false), initialised(false), state(NONE) {} SaslClient::~SaslClient() { @@ -67,8 +67,10 @@ std::size_t SaslClient::encode(char* buffer, std::size_t size) encoded += writeProtocolHeader(buffer, size); writeHeader = !encoded; } - if (state == NONE && encoded < size) { - encoded += write(buffer + encoded, size - encoded); + if ((!initialised || state == NONE) && encoded < size) { + size_t extra = write(buffer + encoded, size - encoded); + encoded += extra; + initialised = extra > 0; } else if (state == SUCCEEDED) { if (securityLayer.get()) encoded += securityLayer->encode(buffer + encoded, size - encoded); else encoded += connection->encode(buffer + encoded, size - encoded); diff --git a/qpid/cpp/src/qpid/broker/amqp/SaslClient.h b/qpid/cpp/src/qpid/broker/amqp/SaslClient.h index 4d802f6f65..fca293879e 100644 --- a/qpid/cpp/src/qpid/broker/amqp/SaslClient.h +++ b/qpid/cpp/src/qpid/broker/amqp/SaslClient.h @@ -64,6 +64,7 @@ class SaslClient : public qpid::sys::ConnectionCodec, qpid::amqp::SaslClient bool readHeader; bool writeHeader; bool haveOutput; + bool initialised; enum { NONE, FAILED, SUCCEEDED } state; diff --git a/qpid/cpp/src/qpid/broker/amqp/Session.cpp b/qpid/cpp/src/qpid/broker/amqp/Session.cpp index e6ea694d54..4627d724a5 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Session.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Session.cpp @@ -36,6 +36,7 @@ #include "qpid/broker/TopicExchange.h" #include "qpid/broker/FanOutExchange.h" #include "qpid/broker/Queue.h" +#include "qpid/broker/QueueCursor.h" #include "qpid/broker/Selector.h" #include "qpid/broker/TopicExchange.h" #include "qpid/broker/amqp/Filter.h" @@ -56,15 +57,16 @@ namespace broker { namespace amqp { namespace { -bool is_capability_requested(const std::string& name, pn_data_t* capabilities) +pn_bytes_t convert(const std::string& s) { - pn_data_rewind(capabilities); - while (pn_data_next(capabilities)) { - pn_bytes_t c = pn_data_get_symbol(capabilities); - std::string s(c.start, c.size); - if (s == name) return true; - } - return false; + pn_bytes_t result; + result.start = const_cast<char*>(s.data()); + result.size = s.size(); + return result; +} +std::string convert(pn_bytes_t in) +{ + return std::string(in.start, in.size); } //capabilities const std::string CREATE_ON_DEMAND("create-on-demand"); @@ -75,40 +77,90 @@ const std::string DIRECT_FILTER("legacy-amqp-direct-binding"); const std::string TOPIC_FILTER("legacy-amqp-topic-binding"); const std::string SHARED("shared"); -void setCapabilities(pn_data_t* in, pn_data_t* out, boost::shared_ptr<Queue> node) +void writeCapabilities(pn_data_t* out, const std::vector<std::string>& supported) { - pn_data_rewind(in); - while (pn_data_next(in)) { - pn_bytes_t c = pn_data_get_symbol(in); - std::string s(c.start, c.size); - if (s == DURABLE) { - if (node->isDurable()) pn_data_put_symbol(out, c); - } else if (s == CREATE_ON_DEMAND || s == QUEUE || s == DIRECT_FILTER || s == TOPIC_FILTER) { - pn_data_put_symbol(out, c); + if (supported.size() == 1) { + pn_data_put_symbol(out, convert(supported.front())); + } else if (supported.size() > 1) { + pn_data_put_array(out, false, PN_SYMBOL); + pn_data_enter(out); + for (std::vector<std::string>::const_iterator i = supported.begin(); i != supported.end(); ++i) { + pn_data_put_symbol(out, convert(*i)); } + pn_data_exit(out); } } -void setCapabilities(pn_data_t* in, pn_data_t* out, boost::shared_ptr<Exchange> node) +template <class F> +void readCapabilities(pn_data_t* data, F f) { - pn_data_rewind(in); - while (pn_data_next(in)) { - pn_bytes_t c = pn_data_get_symbol(in); - std::string s(c.start, c.size); - if (s == DURABLE) { - if (node->isDurable()) pn_data_put_symbol(out, c); - } else if (s == SHARED) { - pn_data_put_symbol(out, c); - } else if (s == CREATE_ON_DEMAND || s == TOPIC) { - pn_data_put_symbol(out, c); - } else if (s == DIRECT_FILTER) { - if (node->getType() == DirectExchange::typeName) pn_data_put_symbol(out, c); - } else if (s == TOPIC_FILTER) { - if (node->getType() == TopicExchange::typeName) pn_data_put_symbol(out, c); + pn_data_rewind(data); + if (pn_data_next(data)) { + pn_type_t type = pn_data_type(data); + if (type == PN_ARRAY) { + pn_data_enter(data); + while (pn_data_next(data)) { + f(convert(pn_data_get_symbol(data))); + } + pn_data_exit(data); + } else if (type == PN_SYMBOL) { + f(convert(pn_data_get_symbol(data))); + } else { + QPID_LOG(error, "Skipping capabilities field of type " << pn_type_name(type)); } } } +void matchCapability(const std::string& name, bool* result, const std::string& s) +{ + if (s == name) *result = true; +} + +bool is_capability_requested(const std::string& name, pn_data_t* capabilities) +{ + bool result(false); + readCapabilities(capabilities, boost::bind(&matchCapability, name, &result, _1)); + return result; +} + +void collectQueueCapabilities(boost::shared_ptr<Queue> node, std::vector<std::string>* supported, const std::string& s) +{ + if (s == DURABLE) { + if (node->isDurable()) supported->push_back(s); + } else if (s == CREATE_ON_DEMAND || s == QUEUE || s == DIRECT_FILTER || s == TOPIC_FILTER) { + supported->push_back(s); + } +} + +void collectExchangeCapabilities(boost::shared_ptr<Exchange> node, std::vector<std::string>* supported, const std::string& s) +{ + if (s == DURABLE) { + if (node->isDurable()) supported->push_back(s); + } else if (s == SHARED) { + supported->push_back(s); + } else if (s == CREATE_ON_DEMAND || s == TOPIC) { + supported->push_back(s); + } else if (s == DIRECT_FILTER) { + if (node->getType() == DirectExchange::typeName) supported->push_back(s); + } else if (s == TOPIC_FILTER) { + if (node->getType() == TopicExchange::typeName) supported->push_back(s); + } +} + +void setCapabilities(pn_data_t* in, pn_data_t* out, boost::shared_ptr<Queue> node) +{ + std::vector<std::string> supported; + readCapabilities(in, boost::bind(&collectQueueCapabilities, node, &supported, _1)); + writeCapabilities(out, supported); +} + +void setCapabilities(pn_data_t* in, pn_data_t* out, boost::shared_ptr<Exchange> node) +{ + std::vector<std::string> supported; + readCapabilities(in, boost::bind(&collectExchangeCapabilities, node, &supported, _1)); + writeCapabilities(out, supported); +} + } class IncomingToQueue : public DecodingIncoming @@ -149,6 +201,12 @@ Session::ResolvedNode Session::resolve(const std::string name, pn_terminus_t* te node.queue = connection.getBroker().getQueues().find(name); node.topic = connection.getTopics().get(name); if (node.topic) node.exchange = node.topic->getExchange(); + if (node.exchange && !node.queue && is_capability_requested(CREATE_ON_DEMAND, pn_terminus_capabilities(terminus))) { + node.properties.read(pn_terminus_properties(terminus)); + if (!node.properties.getExchangeType().empty() && node.properties.getExchangeType() != node.exchange->getType()) { + throw Exception(qpid::amqp::error_conditions::PRECONDITION_FAILED, "Exchange of different type already exists"); + } + } if (!node.queue && !node.exchange) { if (pn_terminus_is_dynamic(terminus) || is_capability_requested(CREATE_ON_DEMAND, pn_terminus_capabilities(terminus))) { //is it a queue or an exchange? @@ -316,10 +374,10 @@ void Session::setupOutgoing(pn_link_t* link, pn_terminus_t* source, const std::s target = targetAddress; } - if (node.queue) { authorise.outgoing(node.queue); - boost::shared_ptr<Outgoing> q(new OutgoingFromQueue(connection.getBroker(), name, target, node.queue, link, *this, out, false, node.properties.trackControllingLink())); + SubscriptionType type = pn_terminus_get_distribution_mode(source) == PN_DIST_MODE_COPY ? BROWSER : CONSUMER; + boost::shared_ptr<Outgoing> q(new OutgoingFromQueue(connection.getBroker(), name, target, node.queue, link, *this, out, type, false, node.properties.trackControllingLink())); q->init(); filter.apply(q); outgoing[link] = q; @@ -333,8 +391,12 @@ void Session::setupOutgoing(pn_link_t* link, pn_terminus_t* source, const std::s settings.durable = durable; settings.autodelete = !durable; } + settings.autoDeleteDelay = pn_terminus_get_timeout(source); + if (settings.autoDeleteDelay) { + settings.autodelete = true; + settings.original["qpid.auto_delete_timeout"] = settings.autoDeleteDelay; + } filter.configure(settings); - //TODO: populate settings from source details when available from engine std::stringstream queueName; if (shared) { //just use link name (TODO: could allow this to be @@ -350,9 +412,9 @@ void Session::setupOutgoing(pn_link_t* link, pn_terminus_t* source, const std::s if (!shared) queue->setExclusiveOwner(this); authorise.outgoing(node.exchange, queue, filter); filter.bind(node.exchange, queue); - boost::shared_ptr<Outgoing> q(new OutgoingFromQueue(connection.getBroker(), name, target, queue, link, *this, out, !shared, false)); - outgoing[link] = q; + boost::shared_ptr<Outgoing> q(new OutgoingFromQueue(connection.getBroker(), name, target, queue, link, *this, out, CONSUMER, !shared, false)); q->init(); + outgoing[link] = q; } else if (node.relay) { boost::shared_ptr<Outgoing> out(new OutgoingFromRelay(link, connection.getBroker(), *this, name, target, pn_link_name(link), node.relay)); outgoing[link] = out; @@ -503,7 +565,6 @@ bool Session::dispatch() void Session::close() { - exclusiveQueues.clear(); for (OutgoingLinks::iterator i = outgoing.begin(); i != outgoing.end(); ++i) { i->second->detached(); } @@ -516,6 +577,7 @@ void Session::close() for (std::set< boost::shared_ptr<Queue> >::const_iterator i = exclusiveQueues.begin(); i != exclusiveQueues.end(); ++i) { (*i)->releaseExclusiveOwnership(); } + exclusiveQueues.clear(); qpid::sys::Mutex::ScopedLock l(lock); deleted = true; } diff --git a/qpid/cpp/src/qpid/broker/amqp/Topic.cpp b/qpid/cpp/src/qpid/broker/amqp/Topic.cpp index 7d77343f26..4bb581628b 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Topic.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Topic.cpp @@ -47,6 +47,13 @@ bool testProperty(const std::string& k, const qpid::types::Variant::Map& m) else return i->second; } +qpid::types::Variant::Map filter(const qpid::types::Variant::Map& properties) +{ + qpid::types::Variant::Map filtered = properties; + filtered.erase(DURABLE); + filtered.erase(EXCHANGE); + return filtered; +} } Topic::Topic(Broker& broker, const std::string& n, const qpid::types::Variant::Map& properties) @@ -60,7 +67,7 @@ Topic::Topic(Broker& broker, const std::string& n, const qpid::types::Variant::M qpid::management::ManagementAgent* agent = broker.getManagementAgent(); if (agent != 0) { topic = _qmf::Topic::shared_ptr(new _qmf::Topic(agent, this, name, exchange->GetManagementObject()->getObjectId(), durable)); - topic->set_properties(policy.asMap()); + topic->set_properties(filter(properties)); agent->addObject(topic); } } @@ -117,8 +124,12 @@ bool TopicRegistry::deleteObject(Broker& broker, const std::string& type, const { if (type == TOPIC) { boost::shared_ptr<Topic> topic = remove(name); - if (topic->isDurable()) broker.getStore().destroy(*topic); - return true; + if (topic) { + if (topic->isDurable()) broker.getStore().destroy(*topic); + return true; + } else { + return false; + } } else { return false; } diff --git a/qpid/cpp/src/qpid/broker/amqp/Translation.cpp b/qpid/cpp/src/qpid/broker/amqp/Translation.cpp index e04d44d2c8..2196c8ff3d 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Translation.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Translation.cpp @@ -27,6 +27,7 @@ #include "qpid/amqp/MessageEncoder.h" #include "qpid/amqp_0_10/Codecs.h" #include "qpid/types/Variant.h" +#include "qpid/types/encodings.h" #include "qpid/framing/MessageTransferBody.h" #include "qpid/log/Statement.h" #include <boost/lexical_cast.hpp> @@ -38,6 +39,9 @@ namespace { const std::string EMPTY; const std::string FORWARD_SLASH("/"); +const std::string TEXT_PLAIN("text/plain"); +const std::string SUBJECT_KEY("qpid.subject"); +const std::string APP_ID("x-amqp-0-10.app-id"); qpid::framing::ReplyTo translate(const std::string address, Broker* broker) { @@ -98,8 +102,25 @@ class Properties_0_10 : public qpid::amqp::MessageEncoder::Properties std::string getUserId() const { return messageProperties ? messageProperties->getUserId() : EMPTY; } bool hasTo() const { return getDestination().size() || hasSubject(); } std::string getTo() const { return getDestination().size() ? getDestination() : getSubject(); } - bool hasSubject() const { return deliveryProperties && getDestination().size() && deliveryProperties->hasRoutingKey(); } - std::string getSubject() const { return deliveryProperties && getDestination().size() ? deliveryProperties->getRoutingKey() : EMPTY; } + bool hasSubject() const + { + if (getDestination().empty()) { + return getApplicationProperties().isSet(SUBJECT_KEY); + } else { + return deliveryProperties && deliveryProperties->hasRoutingKey(); + } + } + std::string getSubject() const + { + if (getDestination().empty()) { + //message was sent to default exchange, routing key is the queue name + return getApplicationProperties().getAsString(SUBJECT_KEY); + } else if (deliveryProperties) { + return deliveryProperties->getRoutingKey(); + } else { + return EMPTY; + } + } bool hasReplyTo() const { return messageProperties && messageProperties->hasReplyTo(); } std::string getReplyTo() const { return messageProperties ? translate(messageProperties->getReplyTo()) : EMPTY; } bool hasCorrelationId() const { return messageProperties && messageProperties->hasCorrelationId(); } @@ -119,7 +140,7 @@ class Properties_0_10 : public qpid::amqp::MessageEncoder::Properties bool hasReplyToGroupId() const { return false; } std::string getReplyToGroupId() const { return EMPTY; } - const qpid::framing::FieldTable& getApplicationProperties() { return messageProperties->getApplicationHeaders(); } + const qpid::framing::FieldTable& getApplicationProperties() const { return messageProperties->getApplicationHeaders(); } Properties_0_10(const qpid::broker::amqp_0_10::MessageTransfer& t) : transfer(t), messageProperties(transfer.getProperties<qpid::framing::MessageProperties>()), deliveryProperties(transfer.getProperties<qpid::framing::DeliveryProperties>()) @@ -138,7 +159,6 @@ class Properties_0_10 : public qpid::amqp::MessageEncoder::Properties Translation::Translation(const qpid::broker::Message& m, Broker* b) : original(m), broker(b) {} - boost::intrusive_ptr<const qpid::broker::amqp_0_10::MessageTransfer> Translation::getTransfer() { boost::intrusive_ptr<const qpid::broker::amqp_0_10::MessageTransfer> t = @@ -161,13 +181,38 @@ boost::intrusive_ptr<const qpid::broker::amqp_0_10::MessageTransfer> Translation transfer->getFrames().append(method); transfer->getFrames().append(header); - qpid::amqp::CharSequence body = message->getBody(); - content.castBody<qpid::framing::AMQContentBody>()->getData().assign(body.data, body.size); - transfer->getFrames().append(content); - qpid::framing::MessageProperties* props = transfer->getFrames().getHeaders()->get<qpid::framing::MessageProperties>(true); - props->setContentLength(body.size); + + if (message->isTypedBody()) { + qpid::types::Variant body = message->getTypedBody(); + std::string& data = content.castBody<qpid::framing::AMQContentBody>()->getData(); + if (body.getType() == qpid::types::VAR_MAP) { + qpid::amqp_0_10::MapCodec::encode(body.asMap(), data); + props->setContentType(qpid::amqp_0_10::MapCodec::contentType); + } else if (body.getType() == qpid::types::VAR_LIST) { + qpid::amqp_0_10::ListCodec::encode(body.asList(), data); + props->setContentType(qpid::amqp_0_10::ListCodec::contentType); + } else if (body.getType() == qpid::types::VAR_STRING) { + data = body.getString(); + if (body.getEncoding() == qpid::types::encodings::UTF8 || body.getEncoding() == qpid::types::encodings::ASCII) { + props->setContentType(TEXT_PLAIN); + } + } else { + qpid::types::Variant::List container; + container.push_back(body); + qpid::amqp_0_10::ListCodec::encode(container, data); + props->setContentType(qpid::amqp_0_10::ListCodec::contentType); + } + transfer->getFrames().append(content); + props->setContentLength(data.size()); + } else { + qpid::amqp::CharSequence body = message->getBody(); + content.castBody<qpid::framing::AMQContentBody>()->getData().assign(body.data, body.size); + transfer->getFrames().append(content); + + props->setContentLength(body.size); + } qpid::amqp::MessageId mid = message->getMessageId(); qpid::framing::Uuid uuid; @@ -209,13 +254,25 @@ boost::intrusive_ptr<const qpid::broker::amqp_0_10::MessageTransfer> Translation if (ap) { qpid::amqp::Decoder d(ap.data, ap.size); qpid::amqp_0_10::translate(d.readMap(), props->getApplicationHeaders()); + std::string appid = props->getApplicationHeaders().getAsString(APP_ID); + if (!appid.empty()) { + props->setAppId(appid); + } } qpid::framing::DeliveryProperties* dp = transfer->getFrames().getHeaders()->get<qpid::framing::DeliveryProperties>(true); dp->setPriority(message->getPriority()); if (message->isPersistent()) dp->setDeliveryMode(2); - if (message->getRoutingKey().size()) dp->setRoutingKey(message->getRoutingKey()); + if (message->getRoutingKey().size()) { + if (message->getRoutingKey().size() > std::numeric_limits<uint8_t>::max()) { + //have to truncate routing key as it is specified to be a str8 + dp->setRoutingKey(message->getRoutingKey().substr(0,std::numeric_limits<uint8_t>::max())); + } else { + dp->setRoutingKey(message->getRoutingKey()); + } + props->getApplicationHeaders().setString(SUBJECT_KEY, message->getRoutingKey()); + } return transfer.get(); } else { @@ -226,10 +283,11 @@ boost::intrusive_ptr<const qpid::broker::amqp_0_10::MessageTransfer> Translation void Translation::write(OutgoingFromQueue& out) { - const Message* message = dynamic_cast<const Message*>(&original.getEncoding()); + const Message* message = dynamic_cast<const Message*>(original.getPersistentContext().get()); + //persistent context will contain any newly added annotations + if (!message) message = dynamic_cast<const Message*>(&original.getEncoding()); if (message) { //write annotations - //TODO: merge in any newly added annotations qpid::amqp::CharSequence deliveryAnnotations = message->getDeliveryAnnotations(); qpid::amqp::CharSequence messageAnnotations = message->getMessageAnnotations(); if (deliveryAnnotations.size) out.write(deliveryAnnotations.data, deliveryAnnotations.size); @@ -246,14 +304,40 @@ void Translation::write(OutgoingFromQueue& out) Properties_0_10 properties(*transfer); qpid::types::Variant::Map applicationProperties; qpid::amqp_0_10::translate(properties.getApplicationProperties(), applicationProperties); - std::string content = transfer->getContent(); - size_t size = qpid::amqp::MessageEncoder::getEncodedSize(properties, applicationProperties, content); - std::vector<char> buffer(size); - qpid::amqp::MessageEncoder encoder(&buffer[0], buffer.size()); - encoder.writeProperties(properties); - encoder.writeApplicationProperties(applicationProperties); - if (content.size()) encoder.writeBinary(content, &qpid::amqp::message::DATA); - out.write(&buffer[0], encoder.getPosition()); + if (properties.getContentType() == qpid::amqp_0_10::MapCodec::contentType) { + qpid::types::Variant::Map content; + qpid::amqp_0_10::MapCodec::decode(transfer->getContent(), content); + size_t size = qpid::amqp::MessageEncoder::getEncodedSize(properties); + size += qpid::amqp::MessageEncoder::getEncodedSize(applicationProperties, true) + 3;/*descriptor*/ + size += qpid::amqp::MessageEncoder::getEncodedSize(content, true) + 3/*descriptor*/; + std::vector<char> buffer(size); + qpid::amqp::MessageEncoder encoder(&buffer[0], buffer.size()); + encoder.writeProperties(properties); + encoder.writeApplicationProperties(applicationProperties); + encoder.writeMap(content, &qpid::amqp::message::AMQP_VALUE); + out.write(&buffer[0], encoder.getPosition()); + } else if (properties.getContentType() == qpid::amqp_0_10::ListCodec::contentType) { + qpid::types::Variant::List content; + qpid::amqp_0_10::ListCodec::decode(transfer->getContent(), content); + size_t size = qpid::amqp::MessageEncoder::getEncodedSize(properties); + size += qpid::amqp::MessageEncoder::getEncodedSize(applicationProperties, true) + 3;/*descriptor*/ + size += qpid::amqp::MessageEncoder::getEncodedSize(content, true) + 3/*descriptor*/; + std::vector<char> buffer(size); + qpid::amqp::MessageEncoder encoder(&buffer[0], buffer.size()); + encoder.writeProperties(properties); + encoder.writeApplicationProperties(applicationProperties); + encoder.writeList(content, &qpid::amqp::message::AMQP_VALUE); + out.write(&buffer[0], encoder.getPosition()); + } else { + std::string content = transfer->getContent(); + size_t size = qpid::amqp::MessageEncoder::getEncodedSize(properties, applicationProperties, content); + std::vector<char> buffer(size); + qpid::amqp::MessageEncoder encoder(&buffer[0], buffer.size()); + encoder.writeProperties(properties); + encoder.writeApplicationProperties(applicationProperties); + if (content.size()) encoder.writeBinary(content, &qpid::amqp::message::DATA); + out.write(&buffer[0], encoder.getPosition()); + } } else { QPID_LOG(error, "Could not write message data in AMQP 1.0 format"); } diff --git a/qpid/cpp/src/qpid/broker/amqp_0_10/Connection.cpp b/qpid/cpp/src/qpid/broker/amqp_0_10/Connection.cpp index 6732b66ed4..4cfe988b72 100644 --- a/qpid/cpp/src/qpid/broker/amqp_0_10/Connection.cpp +++ b/qpid/cpp/src/qpid/broker/amqp_0_10/Connection.cpp @@ -174,6 +174,7 @@ void Connection::requestIOProcessing(boost::function0<void> callback) Connection::~Connection() { if (mgmtObject != 0) { + mgmtObject->debugStats("destroying"); if (!link) agent->raiseEvent(_qmf::EventClientDisconnect(mgmtId, getUserId(), mgmtObject->get_remoteProperties())); QPID_LOG_CAT(debug, model, "Delete connection. user:" << getUserId() diff --git a/qpid/cpp/include/qpid/client/AsyncSession.h b/qpid/cpp/src/qpid/client/AsyncSession.h index d91efeb4f1..d91efeb4f1 100644 --- a/qpid/cpp/include/qpid/client/AsyncSession.h +++ b/qpid/cpp/src/qpid/client/AsyncSession.h diff --git a/qpid/cpp/include/qpid/client/ClientImportExport.h b/qpid/cpp/src/qpid/client/ClientImportExport.h index 2a3a5a52e9..2a3a5a52e9 100644 --- a/qpid/cpp/include/qpid/client/ClientImportExport.h +++ b/qpid/cpp/src/qpid/client/ClientImportExport.h diff --git a/qpid/cpp/include/qpid/client/Completion.h b/qpid/cpp/src/qpid/client/Completion.h index 9546db9258..9546db9258 100644 --- a/qpid/cpp/include/qpid/client/Completion.h +++ b/qpid/cpp/src/qpid/client/Completion.h diff --git a/qpid/cpp/src/qpid/client/Connection.cpp b/qpid/cpp/src/qpid/client/Connection.cpp index 8b4eafccaa..26e69233af 100644 --- a/qpid/cpp/src/qpid/client/Connection.cpp +++ b/qpid/cpp/src/qpid/client/Connection.cpp @@ -127,7 +127,7 @@ void Connection::open(const ConnectionSettings& settings) impl->registerFailureCallback ( failureCallback ); } -const ConnectionSettings& Connection::getNegotiatedSettings() +const ConnectionSettings& Connection::getNegotiatedSettings() const { if (!isOpen()) throw Exception(QPID_MSG("Connection is not open.")); diff --git a/qpid/cpp/include/qpid/client/Connection.h b/qpid/cpp/src/qpid/client/Connection.h index c0db0f301d..fb502cb40a 100644 --- a/qpid/cpp/include/qpid/client/Connection.h +++ b/qpid/cpp/src/qpid/client/Connection.h @@ -216,7 +216,7 @@ class QPID_CLIENT_CLASS_EXTERN Connection /** * Return the set of client negotiated settings */ - QPID_CLIENT_EXTERN const ConnectionSettings& getNegotiatedSettings(); + QPID_CLIENT_EXTERN const ConnectionSettings& getNegotiatedSettings() const; friend struct ConnectionAccess; ///<@internal friend class SessionBase_0_10; ///<@internal diff --git a/qpid/cpp/src/qpid/client/ConnectionHandler.cpp b/qpid/cpp/src/qpid/client/ConnectionHandler.cpp index 4f88cb97ee..3ee3f1cd40 100644 --- a/qpid/cpp/src/qpid/client/ConnectionHandler.cpp +++ b/qpid/cpp/src/qpid/client/ConnectionHandler.cpp @@ -50,6 +50,7 @@ using qpid::sys::Mutex; namespace { const std::string OK("OK"); const std::string PLAIN("PLAIN"); +const std::string ANONYMOUS("ANONYMOUS"); const std::string en_US("en_US"); const std::string INVALID_STATE_START("start received in invalid state"); @@ -244,6 +245,7 @@ void ConnectionHandler::start(const FieldTable& /*serverProps*/, const Array& me std::vector<std::string> mechlist; mechlist.reserve(mechanisms.size()); + if (mechanism.empty()) { //mechlist is simply what the server offers std::transform(mechanisms.begin(), mechanisms.end(), std::back_inserter(mechlist), Array::get<std::string, Array::ValuePtr>); @@ -273,9 +275,25 @@ void ConnectionHandler::start(const FieldTable& /*serverProps*/, const Array& me proxy.send(body); } } else { - //TODO: verify that desired mechanism and locale are supported - std::string response = ((char)0) + username + ((char)0) + password; - proxy.startOk(properties, mechanism, response, locale); + bool haveAnonymous(false); + bool havePlain(false); + for (std::vector<std::string>::const_iterator i = mechlist.begin(); i != mechlist.end(); ++i) { + if (*i == ANONYMOUS) { + haveAnonymous = true; + break; + } else if (*i == PLAIN) { + havePlain = true; + } + } + if (haveAnonymous && (mechanism.empty() || mechanism.find(ANONYMOUS) != std::string::npos)) { + proxy.startOk(properties, ANONYMOUS, username, locale); + } else if (havePlain && (mechanism.empty() || mechanism.find(PLAIN) !=std::string::npos)) { + std::string response = ((char)0) + username + ((char)0) + password; + proxy.startOk(properties, PLAIN, response, locale); + } else { + if (!mechanism.empty()) throw Exception(QPID_MSG("Desired mechanism(s) not valid: " << mechanism << "; client supports PLAIN or ANONYMOUS, broker supports: " << join(mechlist))); + throw Exception(QPID_MSG("No valid mechanism; client supports PLAIN or ANONYMOUS, broker supports: " << join(mechlist))); + } } } diff --git a/qpid/cpp/include/qpid/client/ConnectionSettings.h b/qpid/cpp/src/qpid/client/ConnectionSettings.h index a0c209badf..a0c209badf 100644 --- a/qpid/cpp/include/qpid/client/ConnectionSettings.h +++ b/qpid/cpp/src/qpid/client/ConnectionSettings.h diff --git a/qpid/cpp/include/qpid/client/FailoverListener.h b/qpid/cpp/src/qpid/client/FailoverListener.h index 53c7c26211..53c7c26211 100644 --- a/qpid/cpp/include/qpid/client/FailoverListener.h +++ b/qpid/cpp/src/qpid/client/FailoverListener.h diff --git a/qpid/cpp/include/qpid/client/FailoverManager.h b/qpid/cpp/src/qpid/client/FailoverManager.h index bc739fd0f5..bc739fd0f5 100644 --- a/qpid/cpp/include/qpid/client/FailoverManager.h +++ b/qpid/cpp/src/qpid/client/FailoverManager.h diff --git a/qpid/cpp/include/qpid/client/FlowControl.h b/qpid/cpp/src/qpid/client/FlowControl.h index bff7071b3b..bff7071b3b 100644 --- a/qpid/cpp/include/qpid/client/FlowControl.h +++ b/qpid/cpp/src/qpid/client/FlowControl.h diff --git a/qpid/cpp/include/qpid/client/Future.h b/qpid/cpp/src/qpid/client/Future.h index 630a7e03c0..630a7e03c0 100644 --- a/qpid/cpp/include/qpid/client/Future.h +++ b/qpid/cpp/src/qpid/client/Future.h diff --git a/qpid/cpp/include/qpid/client/FutureCompletion.h b/qpid/cpp/src/qpid/client/FutureCompletion.h index 0970f494b7..0970f494b7 100644 --- a/qpid/cpp/include/qpid/client/FutureCompletion.h +++ b/qpid/cpp/src/qpid/client/FutureCompletion.h diff --git a/qpid/cpp/include/qpid/client/FutureResult.h b/qpid/cpp/src/qpid/client/FutureResult.h index ead4929571..ead4929571 100644 --- a/qpid/cpp/include/qpid/client/FutureResult.h +++ b/qpid/cpp/src/qpid/client/FutureResult.h diff --git a/qpid/cpp/include/qpid/client/Handle.h b/qpid/cpp/src/qpid/client/Handle.h index b8315481a9..b8315481a9 100644 --- a/qpid/cpp/include/qpid/client/Handle.h +++ b/qpid/cpp/src/qpid/client/Handle.h diff --git a/qpid/cpp/include/qpid/client/LocalQueue.h b/qpid/cpp/src/qpid/client/LocalQueue.h index 1a19a8499d..1a19a8499d 100644 --- a/qpid/cpp/include/qpid/client/LocalQueue.h +++ b/qpid/cpp/src/qpid/client/LocalQueue.h diff --git a/qpid/cpp/include/qpid/client/Message.h b/qpid/cpp/src/qpid/client/Message.h index ba50dda9ba..ba50dda9ba 100644 --- a/qpid/cpp/include/qpid/client/Message.h +++ b/qpid/cpp/src/qpid/client/Message.h diff --git a/qpid/cpp/include/qpid/client/MessageListener.h b/qpid/cpp/src/qpid/client/MessageListener.h index 3ca2fa964a..3ca2fa964a 100644 --- a/qpid/cpp/include/qpid/client/MessageListener.h +++ b/qpid/cpp/src/qpid/client/MessageListener.h diff --git a/qpid/cpp/include/qpid/client/MessageReplayTracker.h b/qpid/cpp/src/qpid/client/MessageReplayTracker.h index 06a3f29c7d..06a3f29c7d 100644 --- a/qpid/cpp/include/qpid/client/MessageReplayTracker.h +++ b/qpid/cpp/src/qpid/client/MessageReplayTracker.h diff --git a/qpid/cpp/include/qpid/client/QueueOptions.h b/qpid/cpp/src/qpid/client/QueueOptions.h index 3984b63fdd..3984b63fdd 100644 --- a/qpid/cpp/include/qpid/client/QueueOptions.h +++ b/qpid/cpp/src/qpid/client/QueueOptions.h diff --git a/qpid/cpp/include/qpid/client/Session.h b/qpid/cpp/src/qpid/client/Session.h index c40549bbc5..c40549bbc5 100644 --- a/qpid/cpp/include/qpid/client/Session.h +++ b/qpid/cpp/src/qpid/client/Session.h diff --git a/qpid/cpp/include/qpid/client/SessionBase_0_10.h b/qpid/cpp/src/qpid/client/SessionBase_0_10.h index 630987c11d..630987c11d 100644 --- a/qpid/cpp/include/qpid/client/SessionBase_0_10.h +++ b/qpid/cpp/src/qpid/client/SessionBase_0_10.h diff --git a/qpid/cpp/include/qpid/client/Subscription.h b/qpid/cpp/src/qpid/client/Subscription.h index bb9b98e8ff..bb9b98e8ff 100644 --- a/qpid/cpp/include/qpid/client/Subscription.h +++ b/qpid/cpp/src/qpid/client/Subscription.h diff --git a/qpid/cpp/include/qpid/client/SubscriptionManager.h b/qpid/cpp/src/qpid/client/SubscriptionManager.h index 404a9c6eb9..404a9c6eb9 100644 --- a/qpid/cpp/include/qpid/client/SubscriptionManager.h +++ b/qpid/cpp/src/qpid/client/SubscriptionManager.h diff --git a/qpid/cpp/include/qpid/client/SubscriptionSettings.h b/qpid/cpp/src/qpid/client/SubscriptionSettings.h index bee39f6816..bee39f6816 100644 --- a/qpid/cpp/include/qpid/client/SubscriptionSettings.h +++ b/qpid/cpp/src/qpid/client/SubscriptionSettings.h diff --git a/qpid/cpp/include/qpid/client/TypedResult.h b/qpid/cpp/src/qpid/client/TypedResult.h index 8e1a16580c..8e1a16580c 100644 --- a/qpid/cpp/include/qpid/client/TypedResult.h +++ b/qpid/cpp/src/qpid/client/TypedResult.h diff --git a/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp b/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp index dac2a4a6d9..872e1d59df 100644 --- a/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp +++ b/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp @@ -89,6 +89,7 @@ const std::string NODE("node"); const std::string LINK("link"); const std::string MODE("mode"); const std::string RELIABILITY("reliability"); +const std::string TIMEOUT("timeout"); const std::string NAME("name"); const std::string DURABLE("durable"); const std::string X_DECLARE("x-declare"); @@ -240,8 +241,8 @@ class Subscription : public Exchange, public MessageSource void cancel(qpid::client::AsyncSession& session, const std::string& destination); private: const std::string queue; - const bool reliable; const bool durable; + const bool reliable; const std::string actualType; const bool exclusiveQueue; const bool exclusiveSubscription; @@ -516,13 +517,25 @@ std::string Subscription::getSubscriptionName(const std::string& base, const std Subscription::Subscription(const Address& address, const std::string& type) : Exchange(address), queue(getSubscriptionName(name, (Opt(address)/LINK/NAME).str())), - reliable(AddressResolution::is_reliable(address)), durable(Opt(address)/LINK/DURABLE), + //if the link is durable, then assume it is also reliable unless explicitly stated otherwise + //if not assume it is unreliable unless explicitly stated otherwise + reliable(durable ? !AddressResolution::is_unreliable(address) : AddressResolution::is_reliable(address)), actualType(type.empty() ? (specifiedType.empty() ? TOPIC_EXCHANGE : specifiedType) : type), exclusiveQueue((Opt(address)/LINK/X_DECLARE/EXCLUSIVE).asBool(true)), exclusiveSubscription((Opt(address)/LINK/X_SUBSCRIBE/EXCLUSIVE).asBool(exclusiveQueue)), alternateExchange((Opt(address)/LINK/X_DECLARE/ALTERNATE_EXCHANGE).str()) { + const Variant* timeout = (Opt(address)/LINK/TIMEOUT).value; + if (timeout) { + if (timeout->asUint32()) queueOptions.setInt("qpid.auto_delete_timeout", timeout->asUint32()); + } else if (durable && !(Opt(address)/LINK/RELIABILITY).value) { + //if durable but not explicitly reliable, then set a non-zero + //default for the autodelete timeout (previously this would + //have defaulted to autodelete immediately anyway, so the risk + //of the change causing problems is mitigated) + queueOptions.setInt("qpid.auto_delete_delay", 15*60); + } (Opt(address)/LINK/X_DECLARE/ARGUMENTS).collect(queueOptions); (Opt(address)/LINK/X_SUBSCRIBE/ARGUMENTS).collect(subscriptionOptions); std::string selector = Opt(address)/LINK/SELECTOR; @@ -584,7 +597,7 @@ void Subscription::subscribe(qpid::client::AsyncSession& session, const std::str //create subscription queue: session.queueDeclare(arg::queue=queue, arg::exclusive=exclusiveQueue, - arg::autoDelete=!reliable, arg::durable=durable, + arg::autoDelete=!(durable || reliable), arg::durable=durable, arg::alternateExchange=alternateExchange, arg::arguments=queueOptions); //'default' binding: @@ -997,6 +1010,7 @@ Verifier::Verifier() link[NAME] = true; link[DURABLE] = true; link[RELIABILITY] = true; + link[TIMEOUT] = true; link[X_SUBSCRIBE] = true; link[X_DECLARE] = true; link[X_BINDINGS] = true; diff --git a/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp b/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp index 668b500570..9406c992fe 100644 --- a/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp +++ b/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp @@ -43,6 +43,7 @@ using qpid::framing::Uuid; namespace { const std::string TCP("tcp"); +const std::string COLON(":"); double FOREVER(std::numeric_limits<double>::max()); // Time values in seconds can be specified as integer or floating point values. @@ -86,9 +87,9 @@ bool expired(const sys::AbsTime& start, double timeout) } // namespace ConnectionImpl::ConnectionImpl(const std::string& url, const Variant::Map& options) : - replaceUrls(false), reconnect(false), timeout(FOREVER), limit(-1), + replaceUrls(false), autoReconnect(false), timeout(FOREVER), limit(-1), minReconnectInterval(0.001), maxReconnectInterval(2), - retries(0), reconnectOnLimitExceeded(true) + retries(0), reconnectOnLimitExceeded(true), disableAutoDecode(false) { setOptions(options); urls.insert(urls.begin(), url); @@ -106,7 +107,7 @@ void ConnectionImpl::setOption(const std::string& name, const Variant& value) { sys::Mutex::ScopedLock l(lock); if (name == "reconnect") { - reconnect = value; + autoReconnect = value; } else if (name == "reconnect-timeout" || name == "reconnect_timeout") { timeout = timeValue(value); } else if (name == "reconnect-limit" || name == "reconnect_limit") { @@ -157,8 +158,10 @@ void ConnectionImpl::setOption(const std::string& name, const Variant& value) settings.sslCertName = value.asString(); } else if (name == "x-reconnect-on-limit-exceeded" || name == "x_reconnect_on_limit_exceeded") { reconnectOnLimitExceeded = value; - } else if (name == "client-properties") { + } else if (name == "client-properties" || name == "client_properties") { amqp_0_10::translate(value.asMap(), settings.clientProperties); + } else if (name == "disable-auto-decode" || name == "disable_auto_decode") { + disableAutoDecode = value; } else { throw qpid::messaging::MessagingException(QPID_MSG("Invalid option: " << name << " not recognised")); } @@ -254,7 +257,7 @@ void ConnectionImpl::open() void ConnectionImpl::reopen() { - if (!reconnect) { + if (!autoReconnect) { throw qpid::messaging::TransportFailure("Failed to connect (reconnect disabled)"); } open(); @@ -265,7 +268,7 @@ void ConnectionImpl::connect(const qpid::sys::AbsTime& started) { QPID_LOG(debug, "Starting connection, urls=" << asString(urls)); for (double i = minReconnectInterval; !tryConnect(); i = std::min(i*2, maxReconnectInterval)) { - if (!reconnect) { + if (!autoReconnect) { throw qpid::messaging::TransportFailure("Failed to connect (reconnect disabled)"); } if (limit >= 0 && retries++ >= limit) { @@ -341,9 +344,52 @@ bool ConnectionImpl::backoff() } } +void ConnectionImpl::reconnect(const std::string& u) +{ + sys::Mutex::ScopedLock l(lock); + try { + QPID_LOG(info, "Trying to connect to " << u << "..."); + Url url(u, settings.protocol.size() ? settings.protocol : TCP); + if (url.getUser().size()) settings.username = url.getUser(); + if (url.getPass().size()) settings.password = url.getPass(); + connection.open(url, settings); + QPID_LOG(info, "Connected to " << u); + mergeUrls(connection.getInitialBrokers(), l); + if (!resetSessions(l)) throw qpid::messaging::TransportFailure("Could not re-establish sessions"); + } catch (const qpid::TransportFailure& e) { + QPID_LOG(info, "Failed to connect to " << u << ": " << e.what()); + throw qpid::messaging::TransportFailure(e.what()); + } catch (const std::exception& e) { + QPID_LOG(info, "Error while connecting to " << u << ": " << e.what()); + throw qpid::messaging::MessagingException(e.what()); + } +} + +void ConnectionImpl::reconnect() +{ + if (!tryConnect()) { + throw qpid::messaging::TransportFailure("Could not reconnect"); + } +} +std::string ConnectionImpl::getUrl() const +{ + if (isOpen()) { + std::stringstream u; + u << connection.getNegotiatedSettings().protocol << COLON << connection.getNegotiatedSettings().host << COLON << connection.getNegotiatedSettings().port; + return u.str(); + } else { + return std::string(); + } +} + std::string ConnectionImpl::getAuthenticatedUsername() { return connection.getNegotiatedSettings().username; } +bool ConnectionImpl::getAutoDecode() const +{ + return !disableAutoDecode; +} + }}} // namespace qpid::client::amqp0_10 diff --git a/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.h b/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.h index d1ac4533d5..ae839dc690 100644 --- a/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.h +++ b/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.h @@ -53,6 +53,10 @@ class ConnectionImpl : public qpid::messaging::ConnectionImpl void setOption(const std::string& name, const qpid::types::Variant& value); bool backoff(); std::string getAuthenticatedUsername(); + void reconnect(const std::string& url); + void reconnect(); + std::string getUrl() const; + bool getAutoDecode() const; private: typedef std::map<std::string, qpid::messaging::Session> Sessions; @@ -63,13 +67,14 @@ class ConnectionImpl : public qpid::messaging::ConnectionImpl bool replaceUrls; // Replace rather than merging with reconnect-urls std::vector<std::string> urls; qpid::client::ConnectionSettings settings; - bool reconnect; + bool autoReconnect; double timeout; int32_t limit; double minReconnectInterval; double maxReconnectInterval; int32_t retries; bool reconnectOnLimitExceeded; + bool disableAutoDecode; void setOptions(const qpid::types::Variant::Map& options); void connect(const qpid::sys::AbsTime& started); diff --git a/qpid/cpp/src/qpid/client/amqp0_10/IncomingMessages.cpp b/qpid/cpp/src/qpid/client/amqp0_10/IncomingMessages.cpp index db6e843cf6..27a2107702 100644 --- a/qpid/cpp/src/qpid/client/amqp0_10/IncomingMessages.cpp +++ b/qpid/cpp/src/qpid/client/amqp0_10/IncomingMessages.cpp @@ -399,7 +399,7 @@ void populate(qpid::messaging::Message& message, FrameSet& command) //need to be able to link the message back to the transfer it was delivered by //e.g. for rejecting. MessageImplAccess::get(message).setInternalId(command.getId()); - + message.setContent(command.getContent()); populateHeaders(message, command.getHeaders()); diff --git a/qpid/cpp/src/qpid/client/amqp0_10/OutgoingMessage.cpp b/qpid/cpp/src/qpid/client/amqp0_10/OutgoingMessage.cpp index 348f9e160c..834ba1fe9f 100644 --- a/qpid/cpp/src/qpid/client/amqp0_10/OutgoingMessage.cpp +++ b/qpid/cpp/src/qpid/client/amqp0_10/OutgoingMessage.cpp @@ -21,6 +21,7 @@ #include "qpid/client/amqp0_10/OutgoingMessage.h" #include "qpid/client/amqp0_10/AddressResolution.h" #include "qpid/amqp_0_10/Codecs.h" +#include "qpid/types/encodings.h" #include "qpid/types/Variant.h" #include "qpid/messaging/Address.h" #include "qpid/messaging/Message.h" @@ -45,13 +46,30 @@ const std::string SUBJECT("qpid.subject"); const std::string X_APP_ID("x-amqp-0-10.app-id"); const std::string X_ROUTING_KEY("x-amqp-0-10.routing-key"); const std::string X_CONTENT_ENCODING("x-amqp-0-10.content-encoding"); +const std::string TEXT_PLAIN("text/plain"); } void OutgoingMessage::convert(const qpid::messaging::Message& from) { //TODO: need to avoid copying as much as possible - message.setData(from.getContent()); - message.getMessageProperties().setContentType(from.getContentType()); + if (from.getContentObject().getType() == qpid::types::VAR_MAP) { + std::string content; + qpid::amqp_0_10::MapCodec::encode(from.getContentObject().asMap(), content); + message.getMessageProperties().setContentType(qpid::amqp_0_10::MapCodec::contentType); + message.setData(content); + } else if (from.getContentObject().getType() == qpid::types::VAR_LIST) { + std::string content; + qpid::amqp_0_10::ListCodec::encode(from.getContentObject().asList(), content); + message.getMessageProperties().setContentType(qpid::amqp_0_10::ListCodec::contentType); + message.setData(content); + } else if (from.getContentObject().getType() == qpid::types::VAR_STRING && + (from.getContentObject().getEncoding() == qpid::types::encodings::UTF8 || from.getContentObject().getEncoding() == qpid::types::encodings::ASCII)) { + message.getMessageProperties().setContentType(TEXT_PLAIN); + message.setData(from.getContent()); + } else { + message.setData(from.getContent()); + message.getMessageProperties().setContentType(from.getContentType()); + } if ( !from.getCorrelationId().empty() ) message.getMessageProperties().setCorrelationId(from.getCorrelationId()); message.getMessageProperties().setUserId(from.getUserId()); diff --git a/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp b/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp index 7e8de21247..c356bc298b 100644 --- a/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp +++ b/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp @@ -25,6 +25,8 @@ #include "qpid/messaging/exceptions.h" #include "qpid/messaging/Receiver.h" #include "qpid/messaging/Session.h" +#include "qpid/amqp_0_10/Codecs.h" +#include "qpid/types/encodings.h" namespace qpid { namespace client { @@ -83,6 +85,7 @@ void ReceiverImpl::start() if (state == STOPPED) { state = STARTED; startFlow(l); + session.sendCompletion(); } } @@ -148,18 +151,42 @@ qpid::messaging::Address ReceiverImpl::getAddress() const } ReceiverImpl::ReceiverImpl(SessionImpl& p, const std::string& name, - const qpid::messaging::Address& a) : + const qpid::messaging::Address& a, bool autoDecode_) : - parent(&p), destination(name), address(a), byteCredit(0xFFFFFFFF), + parent(&p), destination(name), address(a), byteCredit(0xFFFFFFFF), autoDecode(autoDecode_), state(UNRESOLVED), capacity(0), window(0) {} +namespace { +const std::string TEXT_PLAIN("text/plain"); +} + bool ReceiverImpl::getImpl(qpid::messaging::Message& message, qpid::messaging::Duration timeout) { { sys::Mutex::ScopedLock l(lock); if (state == CANCELLED) return false; } - return parent->get(*this, message, timeout); + if (parent->get(*this, message, timeout)) { + if (autoDecode) { + if (message.getContentType() == qpid::amqp_0_10::MapCodec::contentType) { + message.getContentObject() = qpid::types::Variant::Map(); + decode(message, message.getContentObject().asMap()); + } else if (message.getContentType() == qpid::amqp_0_10::ListCodec::contentType) { + message.getContentObject() = qpid::types::Variant::List(); + decode(message, message.getContentObject().asList()); + } else if (!message.getContentBytes().empty()) { + message.getContentObject() = message.getContentBytes(); + if (message.getContentType() == TEXT_PLAIN) { + message.getContentObject().setEncoding(qpid::types::encodings::UTF8); + } else { + message.getContentObject().setEncoding(qpid::types::encodings::BINARY); + } + } + } + return true; + } else { + return false; + } } bool ReceiverImpl::fetchImpl(qpid::messaging::Message& message, qpid::messaging::Duration timeout) diff --git a/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h b/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h index 4dba76c8d9..0d3366907b 100644 --- a/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h +++ b/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h @@ -48,7 +48,7 @@ class ReceiverImpl : public qpid::messaging::ReceiverImpl enum State {UNRESOLVED, STOPPED, STARTED, CANCELLED}; ReceiverImpl(SessionImpl& parent, const std::string& name, - const qpid::messaging::Address& address); + const qpid::messaging::Address& address, bool autoDecode); void init(qpid::client::AsyncSession session, AddressResolution& resolver); bool get(qpid::messaging::Message& message, qpid::messaging::Duration timeout); @@ -74,6 +74,7 @@ class ReceiverImpl : public qpid::messaging::ReceiverImpl const std::string destination; const qpid::messaging::Address address; const uint32_t byteCredit; + const bool autoDecode; State state; std::auto_ptr<MessageSource> source; diff --git a/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp b/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp index e4c2c6afb8..982bfa3503 100644 --- a/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp +++ b/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp @@ -207,7 +207,7 @@ Receiver SessionImpl::createReceiverImpl(const qpid::messaging::Address& address ScopedLock l(lock); std::string name = address.getName(); getFreeKey(name, receivers); - Receiver receiver(new ReceiverImpl(*this, name, address)); + Receiver receiver(new ReceiverImpl(*this, name, address, connection->getAutoDecode())); getImplPtr<Receiver, ReceiverImpl>(receiver)->init(session, resolver); receivers[name] = receiver; return receiver; diff --git a/qpid/cpp/src/qpid/client/windows/SaslFactory.cpp b/qpid/cpp/src/qpid/client/windows/SaslFactory.cpp index 53d825771b..5ffd14596f 100644 --- a/qpid/cpp/src/qpid/client/windows/SaslFactory.cpp +++ b/qpid/cpp/src/qpid/client/windows/SaslFactory.cpp @@ -26,6 +26,7 @@ #include "qpid/sys/SecurityLayer.h" #include "qpid/sys/SecuritySettings.h" #include "qpid/log/Statement.h" +#include "qpid/NullSaslServer.h" #include "boost/tokenizer.hpp" @@ -107,6 +108,12 @@ std::auto_ptr<Sasl> SaslFactory::create( const std::string & username, const std return sasl; } +std::auto_ptr<SaslServer> SaslFactory::createServer( const std::string& realm, bool /*encryptionRequired*/, const qpid::sys::SecuritySettings& ) +{ + std::auto_ptr<SaslServer> server(new NullSaslServer(realm)); + return server; +} + namespace { const std::string ANONYMOUS = "ANONYMOUS"; const std::string PLAIN = "PLAIN"; diff --git a/qpid/cpp/src/qpid/console/Broker.cpp b/qpid/cpp/src/qpid/console/Broker.cpp deleted file mode 100644 index 86a17d4a10..0000000000 --- a/qpid/cpp/src/qpid/console/Broker.cpp +++ /dev/null @@ -1,333 +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. - * - */ - -#include "qpid/console/Broker.h" -#include "qpid/console/Object.h" -#include "qpid/console/Value.h" -#include "qpid/console/SessionManager.h" -#include "qpid/console/ConsoleListener.h" -#include "qpid/log/Statement.h" -#include "qpid/sys/SystemInfo.h" - -using namespace qpid::client; -using namespace qpid::console; -using namespace qpid::framing; -using namespace qpid::sys; -using namespace std; - -Broker::Broker(SessionManager& sm, ConnectionSettings& settings) : - sessionManager(sm), connected(false), connectionSettings(settings), - reqsOutstanding(1), syncInFlight(false), topicBound(false), methodObject(0), - connThreadBody(*this), connThread(connThreadBody) -{ - string osName; - string nodeName; - string release; - string version; - string machine; - - sys::SystemInfo::getSystemId(osName, nodeName, release, version, machine); - uint32_t pid = sys::SystemInfo::getParentProcessId(); - - stringstream text; - - text << "qmfc-cpp-" << nodeName << "-" << pid; - amqpSessionId = string(text.str()); - - QPID_LOG(debug, "Broker::Broker: constructed, amqpSessionId=" << amqpSessionId); -} - -Broker::~Broker() -{ - connThreadBody.shutdown(); - connThread.join(); - resetAgents(); - // resetAgents() does not delete the broker agent... - for (AgentMap::iterator iter = agents.begin(); iter != agents.end(); iter++) { - delete iter->second; - } -} - -string Broker::getUrl() const -{ - stringstream url; - url << connectionSettings.host << ":" << connectionSettings.port; - return url.str(); -} - -void Broker::encodeHeader(Buffer& buf, uint8_t opcode, uint32_t seq) const -{ - buf.putOctet('A'); - buf.putOctet('M'); - buf.putOctet('2'); - buf.putOctet(opcode); - buf.putLong (seq); -} - -bool Broker::checkHeader(Buffer& buf, uint8_t *opcode, uint32_t *seq) const -{ - if (buf.getSize() < 8) - return false; - - uint8_t h1 = buf.getOctet(); - uint8_t h2 = buf.getOctet(); - uint8_t h3 = buf.getOctet(); - - *opcode = buf.getOctet(); - *seq = buf.getLong(); - - return h1 == 'A' && h2 == 'M' && h3 == '2'; -} - -void Broker::received(qpid::client::Message& msg) -{ -#define QMF_HEADER_SIZE 8 - string data = msg.getData(); - Buffer inBuffer(const_cast<char*>(data.c_str()), data.size()); - uint8_t opcode; - uint32_t sequence; - - while (inBuffer.available() >= QMF_HEADER_SIZE) { - if (checkHeader(inBuffer, &opcode, &sequence)) { - QPID_LOG(trace, "Broker::received: opcode=" << opcode << " seq=" << sequence); - - if (opcode == 'b') sessionManager.handleBrokerResp(this, inBuffer, sequence); - else if (opcode == 'p') sessionManager.handlePackageInd(this, inBuffer, sequence); - else if (opcode == 'z') sessionManager.handleCommandComplete(this, inBuffer, sequence); - else if (opcode == 'q') sessionManager.handleClassInd(this, inBuffer, sequence); - else if (opcode == 'm') sessionManager.handleMethodResp(this, inBuffer, sequence); - else if (opcode == 'h') sessionManager.handleHeartbeatInd(this, inBuffer, sequence); - else if (opcode == 'e') sessionManager.handleEventInd(this, inBuffer, sequence); - else if (opcode == 's') sessionManager.handleSchemaResp(this, inBuffer, sequence); - else if (opcode == 'c') sessionManager.handleContentInd(this, inBuffer, sequence, true, false); - else if (opcode == 'i') sessionManager.handleContentInd(this, inBuffer, sequence, false, true); - else if (opcode == 'g') sessionManager.handleContentInd(this, inBuffer, sequence, true, true); - } else - return; - } -} - -void Broker::resetAgents() -{ - for (AgentMap::iterator iter = agents.begin(); iter != agents.end(); iter++) { - if (sessionManager.listener != 0) - sessionManager.listener->delAgent(*(iter->second)); - delete iter->second; - } - - agents.clear(); - agents[0x0000000100000000LL] = new Agent(this, 0, "BrokerAgent"); -} - -void Broker::updateAgent(const Object& object) -{ - uint32_t brokerBank = object.attrUint("brokerBank"); - uint32_t agentBank = object.attrUint("agentBank"); - uint64_t agentKey = ((uint64_t) brokerBank << 32) | (uint64_t) agentBank; - AgentMap::iterator iter = agents.find(agentKey); - - if (object.isDeleted()) { - if (iter != agents.end()) { - if (sessionManager.listener != 0) - sessionManager.listener->delAgent(*(iter->second)); - delete iter->second; - agents.erase(iter); - } - } else { - if (iter == agents.end()) { - Agent* agent = new Agent(this, agentBank, object.attrString("label")); - agents[agentKey] = agent; - if (sessionManager.listener != 0) - sessionManager.listener->newAgent(*agent); - } - } -} - -void Broker::ConnectionThread::run() -{ - static const int delayMin(1); - static const int delayMax(128); - static const int delayFactor(2); - int delay(delayMin); - string dest("qmfc"); - - sessionId.generate(); - queueName << "qmfc-" << sessionId; - - while (true) { - try { - broker.topicBound = false; - broker.reqsOutstanding = 1; - connection.open(broker.connectionSettings); - session = connection.newSession(queueName.str()); - subscriptions = new client::SubscriptionManager(session); - - session.queueDeclare(arg::queue=queueName.str(), arg::autoDelete=true, - arg::exclusive=true); - session.exchangeBind(arg::exchange="amq.direct", arg::queue=queueName.str(), - arg::bindingKey=queueName.str()); - - subscriptions->setAcceptMode(ACCEPT_MODE_NONE); - subscriptions->setAcquireMode(ACQUIRE_MODE_PRE_ACQUIRED); - subscriptions->subscribe(broker, queueName.str(), dest); - subscriptions->setFlowControl(dest, FlowControl::unlimited()); - { - Mutex::ScopedLock _lock(connLock); - if (shuttingDown) - return; - operational = true; - broker.resetAgents(); - broker.connected = true; - broker.sessionManager.handleBrokerConnect(&broker); - broker.sessionManager.startProtocol(&broker); - try { - Mutex::ScopedUnlock _unlock(connLock); - subscriptions->run(); - } catch (std::exception) {} - - operational = false; - broker.connected = false; - broker.sessionManager.handleBrokerDisconnect(&broker); - } - delay = delayMin; - connection.close(); - delete subscriptions; - subscriptions = 0; - } catch (std::exception &e) { - QPID_LOG(debug, " outer exception: " << e.what()); - if (delay < delayMax) - delay *= delayFactor; - } - - { - Mutex::ScopedLock _lock(connLock); - if (shuttingDown) - return; - { - Mutex::ScopedUnlock _unlock(connLock); - ::sleep(delay); - } - if (shuttingDown) - return; - } - } -} - -Broker::ConnectionThread::~ConnectionThread() -{ - if (subscriptions != 0) { - delete subscriptions; - } -} - -void Broker::ConnectionThread::sendBuffer(Buffer& buf, uint32_t length, - const string& exchange, const string& routingKey) -{ - { - Mutex::ScopedLock _lock(connLock); - if (!operational) - return; - } - - client::Message msg; - string data; - - buf.getRawData(data, length); - msg.getDeliveryProperties().setRoutingKey(routingKey); - msg.getMessageProperties().setReplyTo(ReplyTo("amq.direct", queueName.str())); - msg.setData(data); - try { - session.messageTransfer(arg::content=msg, arg::destination=exchange); - } catch(std::exception&) {} -} - -void Broker::ConnectionThread::bindExchange(const std::string& exchange, const std::string& key) -{ - { - Mutex::ScopedLock _lock(connLock); - if (!operational) - return; - } - - QPID_LOG(debug, "Broker::ConnectionThread::bindExchange: exchange=" << exchange << " key=" << key); - session.exchangeBind(arg::exchange=exchange, arg::queue=queueName.str(), - arg::bindingKey=key); -} - -void Broker::ConnectionThread::shutdown() -{ - { - Mutex::ScopedLock _lock(connLock); - shuttingDown = true; - } - if (subscriptions) - subscriptions->stop(); -} - -void Broker::waitForStable() -{ - Mutex::ScopedLock l(lock); - if (reqsOutstanding == 0) - return; - syncInFlight = true; - while (reqsOutstanding != 0) { - bool result = cond.wait(lock, AbsTime(now(), TIME_SEC * sessionManager.settings.getTimeout)); - if (!result) - throw(Exception("Timed out waiting for broker to synchronize")); - } -} - -void Broker::incOutstanding() -{ - Mutex::ScopedLock l(lock); - reqsOutstanding++; -} - -void Broker::decOutstanding() -{ - Mutex::ScopedLock l(lock); - reqsOutstanding--; - if (reqsOutstanding == 0) { - if (!topicBound) { - topicBound = true; - for (vector<string>::const_iterator iter = sessionManager.bindingKeyList.begin(); - iter != sessionManager.bindingKeyList.end(); iter++) - connThreadBody.bindExchange("qpid.management", *iter); - } - if (syncInFlight) { - syncInFlight = false; - cond.notify(); - } - } -} - -void Broker::appendAgents(Agent::Vector& agentlist) const -{ - for (AgentMap::const_iterator iter = agents.begin(); iter != agents.end(); iter++) { - agentlist.push_back(iter->second); - } -} - -ostream& qpid::console::operator<<(ostream& o, const Broker& k) -{ - o << "Broker: " << k.connectionSettings.host << ":" << k.connectionSettings.port; - return o; -} diff --git a/qpid/cpp/src/qpid/console/ClassKey.cpp b/qpid/cpp/src/qpid/console/ClassKey.cpp deleted file mode 100644 index d4b59fc413..0000000000 --- a/qpid/cpp/src/qpid/console/ClassKey.cpp +++ /dev/null @@ -1,106 +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. - * - */ - -#include "qpid/console/ClassKey.h" -#include <string.h> -#include <iostream> -#include <cstdio> - -using namespace std; -using namespace qpid::console; - -ClassKey::ClassKey(const string& _package, const string& _name, const uint8_t* _hash) : - package(_package), name(_name) -{ - ::memcpy(hash, _hash, HASH_SIZE); -} - -string ClassKey::getHashString() const -{ - char cstr[36]; - ::sprintf(cstr, "%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x", - hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7], - hash[8], hash[9], hash[10], hash[11], hash[12], hash[13], hash[14], hash[15]); - return string(cstr); -} - -string ClassKey::str() const -{ - string result(package + ":" + name + "(" + getHashString() + ")"); - return result; -} - -bool ClassKey::operator==(const ClassKey& other) const -{ - return ::memcmp(hash, other.hash, HASH_SIZE) == 0 && - name == other.name && - package == other.package; -} - -bool ClassKey::operator!=(const ClassKey& other) const -{ - return !(*this == other); -} - -bool ClassKey::operator<(const ClassKey& other) const -{ - int cmp = ::memcmp(hash, other.hash, HASH_SIZE); - if (cmp != 0) - return cmp < 0; - cmp = name.compare(other.name); - if (cmp != 0) - return cmp < 0; - return package < other.package; -} - -bool ClassKey::operator>(const ClassKey& other) const -{ - int cmp = ::memcmp(hash, other.hash, HASH_SIZE); - if (cmp != 0) - return cmp > 0; - cmp = name.compare(other.name); - if (cmp != 0) - return cmp > 0; - return package > other.package; -} - -bool ClassKey::operator<=(const ClassKey& other) const -{ - return !(*this > other); -} - -bool ClassKey::operator>=(const ClassKey& other) const -{ - return !(*this < other); -} - -void ClassKey::encode(qpid::framing::Buffer& buffer) const -{ - buffer.putShortString(package); - buffer.putShortString(name); - buffer.putBin128(const_cast<uint8_t*>(hash)); -} - -ostream& qpid::console::operator<<(ostream& o, const ClassKey& k) -{ - o << k.str(); - return o; -} diff --git a/qpid/cpp/src/qpid/console/Event.cpp b/qpid/cpp/src/qpid/console/Event.cpp deleted file mode 100644 index 3e14804b35..0000000000 --- a/qpid/cpp/src/qpid/console/Event.cpp +++ /dev/null @@ -1,205 +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. - * - */ - -#include "qpid/console/Broker.h" -#include "qpid/console/ClassKey.h" -#include "qpid/console/Schema.h" -#include "qpid/console/Event.h" -#include "qpid/console/Value.h" -#include "qpid/sys/Time.h" -#include "qpid/framing/Buffer.h" - -using namespace qpid::console; -using namespace std; -using qpid::framing::Uuid; -using qpid::framing::FieldTable; - -Event::Event(Broker* _broker, SchemaClass* _schema, qpid::framing::Buffer& buffer) : - broker(_broker), schema(_schema) -{ - timestamp = buffer.getLongLong(); - severity = (Severity) buffer.getOctet(); - for (vector<SchemaArgument*>::const_iterator aIter = schema->arguments.begin(); - aIter != schema->arguments.end(); aIter++) { - SchemaArgument* argument = *aIter; - attributes[argument->name] = argument->decodeValue(buffer); - } -} - -const ClassKey& Event::getClassKey() const -{ - return schema->getClassKey(); -} - -string Event::getSeverityString() const -{ - switch (severity) { - case SEV_EMERGENCY : return string("EMER"); - case SEV_ALERT : return string("ALERT"); - case SEV_CRITICAL : return string("CRIT"); - case SEV_ERROR : return string("ERROR"); - case SEV_WARNING : return string("WARN"); - case SEV_NOTICE : return string("NOTIC"); - case SEV_INFO : return string("INFO"); - case SEV_DEBUG : return string("DEBUG"); - } - return string("<UNKNOWN>"); -} - -ObjectId Event::attrRef(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return ObjectId(); - Value::Ptr val = iter->second; - if (!val->isObjectId()) - return ObjectId(); - return val->asObjectId(); -} - -uint32_t Event::attrUint(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0; - Value::Ptr val = iter->second; - if (!val->isUint()) - return 0; - return val->asUint(); -} - -int32_t Event::attrInt(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0; - Value::Ptr val = iter->second; - if (!val->isInt()) - return 0; - return val->asInt(); -} - -uint64_t Event::attrUint64(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0; - Value::Ptr val = iter->second; - if (!val->isUint64()) - return 0; - return val->asUint64(); -} - -int64_t Event::attrInt64(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0; - Value::Ptr val = iter->second; - if (!val->isInt64()) - return 0; - return val->asInt64(); -} - -string Event::attrString(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return string(); - Value::Ptr val = iter->second; - if (!val->isString()) - return string(); - return val->asString(); -} - -bool Event::attrBool(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return false; - Value::Ptr val = iter->second; - if (!val->isBool()) - return false; - return val->asBool(); -} - -float Event::attrFloat(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0.0; - Value::Ptr val = iter->second; - if (!val->isFloat()) - return 0.0; - return val->asFloat(); -} - -double Event::attrDouble(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0.0; - Value::Ptr val = iter->second; - if (!val->isDouble()) - return 0.0; - return val->asDouble(); -} - -Uuid Event::attrUuid(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return Uuid(); - Value::Ptr val = iter->second; - if (!val->isUuid()) - return Uuid(); - return val->asUuid(); -} - -FieldTable Event::attrMap(const string& key) const -{ - Object::AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return FieldTable(); - Value::Ptr val = iter->second; - if (!val->isMap()) - return FieldTable(); - return val->asMap(); -} - - -std::ostream& qpid::console::operator<<(std::ostream& o, const Event& event) -{ - const ClassKey& key = event.getClassKey(); - sys::AbsTime aTime(sys::AbsTime(), sys::Duration(event.getTimestamp())); - o << aTime << " " << event.getSeverityString() << " " << - key.getPackageName() << ":" << key.getClassName() << - " broker=" << event.getBroker()->getUrl(); - - const Object::AttributeMap& attributes = event.getAttributes(); - for (Object::AttributeMap::const_iterator iter = attributes.begin(); - iter != attributes.end(); iter++) { - o << " " << iter->first << "=" << iter->second->str(); - } - return o; -} - - diff --git a/qpid/cpp/src/qpid/console/Object.cpp b/qpid/cpp/src/qpid/console/Object.cpp deleted file mode 100644 index 6570e293ab..0000000000 --- a/qpid/cpp/src/qpid/console/Object.cpp +++ /dev/null @@ -1,384 +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. - * - */ - -#include "qpid/console/SessionManager.h" -#include "qpid/console/Broker.h" -#include "qpid/console/Object.h" -#include "qpid/console/Schema.h" -#include "qpid/console/ClassKey.h" -#include "qpid/console/Value.h" -#include "qpid/framing/Buffer.h" -#include "qpid/sys/Mutex.h" - -using namespace qpid::console; -using namespace qpid::sys; -using namespace qpid; -using namespace std; -using qpid::framing::Uuid; -using qpid::framing::FieldTable; - -void Object::AttributeMap::addRef(const string& key, const ObjectId& val) -{ - (*this)[key] = Value::Ptr(new RefValue(val)); -} - -void Object::AttributeMap::addUint(const string& key, uint32_t val) -{ - (*this)[key] = Value::Ptr(new UintValue(val)); -} - -void Object::AttributeMap::addInt(const string& key, int32_t val) -{ - (*this)[key] = Value::Ptr(new IntValue(val)); -} - -void Object::AttributeMap::addUint64(const string& key, uint64_t val) -{ - (*this)[key] = Value::Ptr(new Uint64Value(val)); -} - -void Object::AttributeMap::addInt64(const string& key, int64_t val) -{ - (*this)[key] = Value::Ptr(new Int64Value(val)); -} - -void Object::AttributeMap::addString(const string& key, const string& val) -{ - (*this)[key] = Value::Ptr(new StringValue(val)); -} - -void Object::AttributeMap::addBool(const string& key, bool val) -{ - (*this)[key] = Value::Ptr(new BoolValue(val)); -} - -void Object::AttributeMap::addFloat(const string& key, float val) -{ - (*this)[key] = Value::Ptr(new FloatValue(val)); -} - -void Object::AttributeMap::addDouble(const string& key, double val) -{ - (*this)[key] = Value::Ptr(new DoubleValue(val)); -} - -void Object::AttributeMap::addUuid(const string& key, const Uuid& val) -{ - (*this)[key] = Value::Ptr(new UuidValue(val)); -} - -void Object::AttributeMap::addMap(const string& key, const FieldTable& val) -{ - (*this)[key] = Value::Ptr(new MapValue(val)); -} - -Object::Object(Broker* b, SchemaClass* s, framing::Buffer& buffer, bool prop, bool stat) : - broker(b), schema(s), pendingMethod(0) -{ - currentTime = buffer.getLongLong(); - createTime = buffer.getLongLong(); - deleteTime = buffer.getLongLong(); - objectId.decode(buffer); - - if (prop) { - set<string> excludes; - parsePresenceMasks(buffer, excludes); - for (vector<SchemaProperty*>::const_iterator pIter = schema->properties.begin(); - pIter != schema->properties.end(); pIter++) { - SchemaProperty* property = *pIter; - if (excludes.count(property->name) != 0) { - attributes[property->name] = Value::Ptr(new NullValue()); - } else { - attributes[property->name] = property->decodeValue(buffer); - } - } - } - - if (stat) { - for (vector<SchemaStatistic*>::const_iterator sIter = schema->statistics.begin(); - sIter != schema->statistics.end(); sIter++) { - SchemaStatistic* statistic = *sIter; - attributes[statistic->name] = statistic->decodeValue(buffer); - } - } -} - -Object::~Object() {} - -const ClassKey& Object::getClassKey() const -{ - return schema->getClassKey(); -} - -string Object::getIndex() const -{ - string result; - - for (vector<SchemaProperty*>::const_iterator pIter = schema->properties.begin(); - pIter != schema->properties.end(); pIter++) { - SchemaProperty* property = *pIter; - if (property->isIndex) { - AttributeMap::const_iterator vIter = attributes.find(property->name); - if (vIter != attributes.end()) { - if (!result.empty()) - result += ":"; - result += vIter->second->str(); - } - } - } - return result; -} - -void Object::mergeUpdate(const Object& /*updated*/) -{ - // TODO -} - -void Object::invokeMethod(const string name, const AttributeMap& args, MethodResponse& result) -{ - for (vector<SchemaMethod*>::const_iterator iter = schema->methods.begin(); - iter != schema->methods.end(); iter++) { - if ((*iter)->name == name) { - SchemaMethod* method = *iter; - char rawbuffer[65536]; - framing::Buffer buffer(rawbuffer, 65536); - uint32_t sequence = broker->sessionManager.sequenceManager.reserve("method"); - pendingMethod = method; - broker->methodObject = this; - broker->encodeHeader(buffer, 'M', sequence); - objectId.encode(buffer); - schema->key.encode(buffer); - buffer.putShortString(name); - - for (vector<SchemaArgument*>::const_iterator aIter = method->arguments.begin(); - aIter != method->arguments.end(); aIter++) { - SchemaArgument* arg = *aIter; - if (arg->dirInput) { - AttributeMap::const_iterator attr = args.find(arg->name); - if (attr != args.end()) { - ValueFactory::encodeValue(arg->typeCode, attr->second, buffer); - } else { - // TODO Use the default value instead of throwing - throw Exception("Missing arguments in method call"); - } - } - } - - uint32_t length = buffer.getPosition(); - buffer.reset(); - stringstream routingKey; - routingKey << "agent." << objectId.getBrokerBank() << "." << objectId.getAgentBank(); - broker->connThreadBody.sendBuffer(buffer, length, "qpid.management", routingKey.str()); - - { - Mutex::ScopedLock l(broker->lock); - bool ok = true; - while (pendingMethod != 0 && ok) { - ok = broker->cond.wait(broker->lock, AbsTime(now(), broker->sessionManager.settings.methodTimeout * TIME_SEC)); - } - - if (!ok) { - result.code = 0x1001; - result.text.assign("Method call timed out"); - result.arguments.clear(); - } else { - result = methodResponse; - } - } - } - } -} - -void Object::handleMethodResp(framing::Buffer& buffer, uint32_t sequence) -{ - broker->sessionManager.sequenceManager.release(sequence); - methodResponse.code = buffer.getLong(); - buffer.getMediumString(methodResponse.text); - methodResponse.arguments.clear(); - - for (vector<SchemaArgument*>::const_iterator aIter = pendingMethod->arguments.begin(); - aIter != pendingMethod->arguments.end(); aIter++) { - SchemaArgument* arg = *aIter; - if (arg->dirOutput) { - methodResponse.arguments[arg->name] = arg->decodeValue(buffer); - } - } - - { - Mutex::ScopedLock l(broker->lock); - pendingMethod = 0; - broker->cond.notify(); - } -} - -ObjectId Object::attrRef(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return ObjectId(); - Value::Ptr val = iter->second; - if (!val->isObjectId()) - return ObjectId(); - return val->asObjectId(); -} - -uint32_t Object::attrUint(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0; - Value::Ptr val = iter->second; - if (!val->isUint()) - return 0; - return val->asUint(); -} - -int32_t Object::attrInt(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0; - Value::Ptr val = iter->second; - if (!val->isInt()) - return 0; - return val->asInt(); -} - -uint64_t Object::attrUint64(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0; - Value::Ptr val = iter->second; - if (!val->isUint64()) - return 0; - return val->asUint64(); -} - -int64_t Object::attrInt64(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0; - Value::Ptr val = iter->second; - if (!val->isInt64()) - return 0; - return val->asInt64(); -} - -string Object::attrString(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return string(); - Value::Ptr val = iter->second; - if (!val->isString()) - return string(); - return val->asString(); -} - -bool Object::attrBool(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return false; - Value::Ptr val = iter->second; - if (!val->isBool()) - return false; - return val->asBool(); -} - -float Object::attrFloat(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0.0; - Value::Ptr val = iter->second; - if (!val->isFloat()) - return 0.0; - return val->asFloat(); -} - -double Object::attrDouble(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return 0.0; - Value::Ptr val = iter->second; - if (!val->isDouble()) - return 0.0; - return val->asDouble(); -} - -Uuid Object::attrUuid(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return Uuid(); - Value::Ptr val = iter->second; - if (!val->isUuid()) - return Uuid(); - return val->asUuid(); -} - -FieldTable Object::attrMap(const string& key) const -{ - AttributeMap::const_iterator iter = attributes.find(key); - if (iter == attributes.end()) - return FieldTable(); - Value::Ptr val = iter->second; - if (!val->isMap()) - return FieldTable(); - return val->asMap(); -} - -void Object::parsePresenceMasks(framing::Buffer& buffer, set<string>& excludeList) -{ - excludeList.clear(); - uint8_t bit = 0; - uint8_t mask = 0; - - for (vector<SchemaProperty*>::const_iterator pIter = schema->properties.begin(); - pIter != schema->properties.end(); pIter++) { - SchemaProperty* property = *pIter; - if (property->isOptional) { - if (bit == 0) { - mask = buffer.getOctet(); - bit = 1; - } - if ((mask & bit) == 0) - excludeList.insert(property->name); - if (bit == 0x80) - bit = 0; - else - bit = bit << 1; - } - } -} - -ostream& qpid::console::operator<<(ostream& o, const Object& object) -{ - const ClassKey& key = object.getClassKey(); - o << key.getPackageName() << ":" << key.getClassName() << "[" << object.getObjectId() << "] " << - object.getIndex(); - return o; -} - diff --git a/qpid/cpp/src/qpid/console/ObjectId.cpp b/qpid/cpp/src/qpid/console/ObjectId.cpp deleted file mode 100644 index fbaad20d57..0000000000 --- a/qpid/cpp/src/qpid/console/ObjectId.cpp +++ /dev/null @@ -1,91 +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. - * - */ - -#include "qpid/console/ObjectId.h" -#include "qpid/framing/Buffer.h" - -using namespace qpid::console; -using namespace qpid; -using namespace std; - -ObjectId::ObjectId(framing::Buffer& buffer) -{ - decode(buffer); -} - -void ObjectId::decode(framing::Buffer& buffer) -{ - first = buffer.getLongLong(); - second = buffer.getLongLong(); -} - -void ObjectId::encode(framing::Buffer& buffer) -{ - buffer.putLongLong(first); - buffer.putLongLong(second); -} - -bool ObjectId::operator==(const ObjectId& other) const -{ - return second == other.second && first == other.first; -} - -bool ObjectId::operator!=(const ObjectId& other) const -{ - return !(*this == other); -} - -bool ObjectId::operator<(const ObjectId& other) const -{ - if (first < other.first) - return true; - if (first > other.first) - return false; - return second < other.second; -} - -bool ObjectId::operator>(const ObjectId& other) const -{ - if (first > other.first) - return true; - if (first < other.first) - return false; - return second > other.second; -} - -bool ObjectId::operator<=(const ObjectId& other) const -{ - return !(*this > other); -} - -bool ObjectId::operator>=(const ObjectId& other) const -{ - return !(*this < other); -} - -ostream& qpid::console::operator<<(ostream& o, const ObjectId& id) -{ - o << (int) id.getFlags() << "-" << id.getSequence() << "-" << id.getBrokerBank() << "-" << - id.getAgentBank() << "-" << id.getObject(); - return o; -} - - diff --git a/qpid/cpp/src/qpid/console/Package.cpp b/qpid/cpp/src/qpid/console/Package.cpp deleted file mode 100644 index e5d6fa29fd..0000000000 --- a/qpid/cpp/src/qpid/console/Package.cpp +++ /dev/null @@ -1,41 +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. - * - */ - -#include "qpid/console/Package.h" - -using namespace qpid::console; - -SchemaClass* Package::getClass(const std::string& className, uint8_t* hash) -{ - NameHash key(className, hash); - ClassMap::iterator iter = classes.find(key); - if (iter != classes.end()) - return iter->second; - return 0; -} - -void Package::addClass(const std::string& className, uint8_t* hash, SchemaClass* schemaClass) -{ - NameHash key(className, hash); - ClassMap::iterator iter = classes.find(key); - if (iter == classes.end()) - classes[key] = schemaClass; -} diff --git a/qpid/cpp/src/qpid/console/Schema.cpp b/qpid/cpp/src/qpid/console/Schema.cpp deleted file mode 100644 index a3dbd91201..0000000000 --- a/qpid/cpp/src/qpid/console/Schema.cpp +++ /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. - * - */ - -#include "qpid/console/Schema.h" -#include "qpid/console/Value.h" -#include "qpid/framing/FieldTable.h" - -using namespace qpid::console; -using namespace qpid; -using std::string; -using std::vector; - -SchemaArgument::SchemaArgument(framing::Buffer& buffer, bool forMethod) -{ - framing::FieldTable map; - map.decode(buffer); - - name = map.getAsString("name"); - typeCode = map.getAsInt("type"); - unit = map.getAsString("unit"); - min = map.getAsInt("min"); - max = map.getAsInt("max"); - maxLen = map.getAsInt("maxlen"); - desc = map.getAsString("desc"); - - dirInput = false; - dirOutput = false; - if (forMethod) { - string dir(map.getAsString("dir")); - if (dir.find('I') != dir.npos || dir.find('i') != dir.npos) - dirInput = true; - if (dir.find('O') != dir.npos || dir.find('o') != dir.npos) - dirOutput = true; - } -} - -Value::Ptr SchemaArgument::decodeValue(framing::Buffer& buffer) -{ - return ValueFactory::newValue(typeCode, buffer); -} - -SchemaProperty::SchemaProperty(framing::Buffer& buffer) -{ - framing::FieldTable map; - map.decode(buffer); - - name = map.getAsString("name"); - typeCode = map.getAsInt("type"); - accessCode = map.getAsInt("access"); - isIndex = map.getAsInt("index") != 0; - isOptional = map.getAsInt("optional") != 0; - unit = map.getAsString("unit"); - min = map.getAsInt("min"); - max = map.getAsInt("max"); - maxLen = map.getAsInt("maxlen"); - desc = map.getAsString("desc"); -} - -Value::Ptr SchemaProperty::decodeValue(framing::Buffer& buffer) -{ - return ValueFactory::newValue(typeCode, buffer); -} - -SchemaStatistic::SchemaStatistic(framing::Buffer& buffer) -{ - framing::FieldTable map; - map.decode(buffer); - - name = map.getAsString("name"); - typeCode = map.getAsInt("type"); - unit = map.getAsString("unit"); - desc = map.getAsString("desc"); -} - -Value::Ptr SchemaStatistic::decodeValue(framing::Buffer& buffer) -{ - return ValueFactory::newValue(typeCode, buffer); -} - -SchemaMethod::SchemaMethod(framing::Buffer& buffer) -{ - framing::FieldTable map; - map.decode(buffer); - - name = map.getAsString("name"); - desc = map.getAsString("desc"); - int argCount = map.getAsInt("argCount"); - - for (int i = 0; i < argCount; i++) - arguments.push_back(new SchemaArgument(buffer, true)); -} - -SchemaMethod::~SchemaMethod() -{ - for (vector<SchemaArgument*>::iterator iter = arguments.begin(); - iter != arguments.end(); iter++) - delete *iter; -} - -SchemaClass::SchemaClass(const uint8_t _kind, const ClassKey& _key, framing::Buffer& buffer) : - kind(_kind), key(_key) -{ - if (kind == KIND_TABLE) { - uint8_t hasSupertype = 0; //buffer.getOctet(); - uint16_t propCount = buffer.getShort(); - uint16_t statCount = buffer.getShort(); - uint16_t methodCount = buffer.getShort(); - - if (hasSupertype) { - string unused; - buffer.getShortString(unused); - buffer.getShortString(unused); - buffer.getLongLong(); - buffer.getLongLong(); - } - - for (uint16_t idx = 0; idx < propCount; idx++) - properties.push_back(new SchemaProperty(buffer)); - for (uint16_t idx = 0; idx < statCount; idx++) - statistics.push_back(new SchemaStatistic(buffer)); - for (uint16_t idx = 0; idx < methodCount; idx++) - methods.push_back(new SchemaMethod(buffer)); - - } else if (kind == KIND_EVENT) { - uint16_t argCount = buffer.getShort(); - - for (uint16_t idx = 0; idx < argCount; idx++) - arguments.push_back(new SchemaArgument(buffer)); - } -} - -SchemaClass::~SchemaClass() -{ - for (vector<SchemaProperty*>::iterator iter = properties.begin(); - iter != properties.end(); iter++) - delete *iter; - for (vector<SchemaStatistic*>::iterator iter = statistics.begin(); - iter != statistics.end(); iter++) - delete *iter; - for (vector<SchemaMethod*>::iterator iter = methods.begin(); - iter != methods.end(); iter++) - delete *iter; - for (vector<SchemaArgument*>::iterator iter = arguments.begin(); - iter != arguments.end(); iter++) - delete *iter; -} - diff --git a/qpid/cpp/src/qpid/console/SequenceManager.cpp b/qpid/cpp/src/qpid/console/SequenceManager.cpp deleted file mode 100644 index 86ea829749..0000000000 --- a/qpid/cpp/src/qpid/console/SequenceManager.cpp +++ /dev/null @@ -1,48 +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. - * - */ - -#include "qpid/console/SequenceManager.h" - -using namespace qpid::console; -using namespace qpid::sys; -using std::string; -using std::cout; -using std::endl; - -uint32_t SequenceManager::reserve(const std::string& context) -{ - Mutex::ScopedLock l(lock); - uint32_t result = sequence++; - pending[result] = context; - return result; -} - -std::string SequenceManager::release(uint32_t seq) -{ - Mutex::ScopedLock l(lock); - std::map<uint32_t, string>::iterator iter = pending.find(seq); - if (iter == pending.end()) - return string(); - string result(iter->second); - pending.erase(iter); - return result; -} - diff --git a/qpid/cpp/src/qpid/console/SessionManager.cpp b/qpid/cpp/src/qpid/console/SessionManager.cpp deleted file mode 100644 index 910ae22be8..0000000000 --- a/qpid/cpp/src/qpid/console/SessionManager.cpp +++ /dev/null @@ -1,516 +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. - * - */ -#include "qpid/console/SessionManager.h" -#include "qpid/console/Schema.h" -#include "qpid/console/Agent.h" -#include "qpid/console/ConsoleListener.h" -#include "qpid/log/Statement.h" -#include "qpid/sys/Time.h" -#include "qpid/framing/Buffer.h" -#include "qpid/framing/Uuid.h" -#include "qpid/framing/FieldTable.h" - -using namespace qpid::console; -using namespace qpid::sys; -using namespace qpid; -using namespace std; -using qpid::framing::Buffer; -using qpid::framing::FieldTable; - -SessionManager::SessionManager(ConsoleListener* _listener, Settings _settings) : - listener(_listener), settings(_settings) -{ - bindingKeys(); -} - -SessionManager::~SessionManager() -{ - for (vector<Broker*>::iterator iter = brokers.begin(); - iter != brokers.end(); iter++) - delete *iter; - - for (map<string, Package*>::iterator iter = packages.begin(); - iter != packages.end(); iter++) { - for (Package::ClassMap::iterator citer = iter->second->classes.begin(); - citer != iter->second->classes.end(); - citer++) - delete citer->second; - delete iter->second; - } -} - -Broker* SessionManager::addBroker(client::ConnectionSettings& settings) -{ - Broker* broker(new Broker(*this, settings)); - { - Mutex::ScopedLock l(brokerListLock); - brokers.push_back(broker); - } - return broker; -} - -void SessionManager::delBroker(Broker* broker) -{ - Mutex::ScopedLock l(brokerListLock); - for (vector<Broker*>::iterator iter = brokers.begin(); - iter != brokers.end(); iter++) - if (*iter == broker) { - brokers.erase(iter); - delete broker; - return; - } -} - -void SessionManager::getPackages(NameVector& packageNames) -{ - allBrokersStable(); - packageNames.clear(); - { - Mutex::ScopedLock l(lock); - for (map<string, Package*>::iterator iter = packages.begin(); - iter != packages.end(); iter++) - packageNames.push_back(iter->first); - } -} - -void SessionManager::getClasses(KeyVector& classKeys, const std::string& packageName) -{ - allBrokersStable(); - classKeys.clear(); - map<string, Package*>::iterator iter = packages.find(packageName); - if (iter == packages.end()) - return; - - Package& package = *(iter->second); - for (Package::ClassMap::const_iterator piter = package.classes.begin(); - piter != package.classes.end(); piter++) { - ClassKey key(piter->second->getClassKey()); - classKeys.push_back(key); - } -} - -SchemaClass& SessionManager::getSchema(const ClassKey& classKey) -{ - allBrokersStable(); - map<string, Package*>::iterator iter = packages.find(classKey.getPackageName()); - if (iter == packages.end()) - throw Exception("Unknown package"); - - Package& package = *(iter->second); - Package::NameHash key(classKey.getClassName(), classKey.getHash()); - Package::ClassMap::iterator cIter = package.classes.find(key); - if (cIter == package.classes.end()) - throw Exception("Unknown class"); - - return *(cIter->second); -} - -void SessionManager::bindPackage(const std::string& packageName) -{ - stringstream key; - key << "console.obj.*.*." << packageName << ".#"; - bindingKeyList.push_back(key.str()); - for (vector<Broker*>::iterator iter = brokers.begin(); iter != brokers.end(); iter++) - (*iter)->addBinding(key.str()); -} - -void SessionManager::bindClass(const ClassKey& classKey) -{ - bindClass(classKey.getPackageName(), classKey.getClassName()); -} - -void SessionManager::bindClass(const std::string& packageName, const std::string& className) -{ - stringstream key; - key << "console.obj.*.*." << packageName << "." << className << ".#"; - bindingKeyList.push_back(key.str()); - for (vector<Broker*>::iterator iter = brokers.begin(); - iter != brokers.end(); iter++) - (*iter)->addBinding(key.str()); -} - - -void SessionManager::bindEvent(const ClassKey& classKey) -{ - bindEvent(classKey.getPackageName(), classKey.getClassName()); -} - - -void SessionManager::bindEvent(const std::string& packageName, const std::string& eventName) -{ - if (!settings.userBindings) throw Exception("Session not configured for userBindings."); - if (settings.rcvEvents) throw Exception("Session already configured to receive all events."); - - stringstream key; - key << "console.event.*.*." << packageName; - if (eventName.length()) { - key << "." << eventName << ".#"; - } else { - key << ".#"; - } - - bindingKeyList.push_back(key.str()); - for (vector<Broker*>::iterator iter = brokers.begin(); - iter != brokers.end(); iter++) - (*iter)->addBinding(key.str()); -} - - -void SessionManager::getAgents(Agent::Vector& agents, Broker* broker) -{ - agents.clear(); - if (broker != 0) { - broker->appendAgents(agents); - } else { - for (vector<Broker*>::iterator iter = brokers.begin(); iter != brokers.end(); iter++) { - (*iter)->appendAgents(agents); - } - } -} - -void SessionManager::getObjects(Object::Vector& objects, const std::string& className, - Broker* _broker, Agent* _agent) -{ - Agent::Vector agentList; - - if (_agent != 0) { - agentList.push_back(_agent); - _agent->getBroker()->waitForStable(); - } else { - if (_broker != 0) { - _broker->appendAgents(agentList); - _broker->waitForStable(); - } else { - allBrokersStable(); - Mutex::ScopedLock _lock(brokerListLock); - for (vector<Broker*>::iterator iter = brokers.begin(); iter != brokers.end(); iter++) { - (*iter)->appendAgents(agentList); - } - } - } - - FieldTable ft; - uint32_t sequence; - ft.setString("_class", className); - - getResult.clear(); - syncSequenceList.clear(); - error = string(); - - if (agentList.empty()) { - objects = getResult; - return; - } - - for (Agent::Vector::iterator iter = agentList.begin(); iter != agentList.end(); iter++) { - Agent* agent = *iter; - char rawbuffer[512]; - Buffer buffer(rawbuffer, 512); - stringstream routingKey; - routingKey << "agent." << agent->getBrokerBank() << "." << agent->getAgentBank(); - { - Mutex::ScopedLock _lock(lock); - sequence = sequenceManager.reserve("multiget"); - syncSequenceList.insert(sequence); - } - agent->getBroker()->encodeHeader(buffer, 'G', sequence); - ft.encode(buffer); - uint32_t length = buffer.getPosition(); - buffer.reset(); - agent->getBroker()->connThreadBody.sendBuffer(buffer, length, "qpid.management", routingKey.str()); - } - - { - Mutex::ScopedLock _lock(lock); - sys::AbsTime startTime = sys::now(); - while (!syncSequenceList.empty() && error.empty()) { - cv.wait(lock, AbsTime(now(), settings.getTimeout * TIME_SEC)); - sys::AbsTime currTime = sys::now(); - if (sys::Duration(startTime, currTime) > settings.getTimeout * TIME_SEC) - break; - } - } - - objects = getResult; -} - -void SessionManager::bindingKeys() -{ - bindingKeyList.push_back("schema.#"); - if (settings.rcvObjects && settings.rcvEvents && settings.rcvHeartbeats && !settings.userBindings) { - bindingKeyList.push_back("console.#"); - } else { - if (settings.rcvObjects && !settings.userBindings) - bindingKeyList.push_back("console.obj.#"); - else - bindingKeyList.push_back("console.obj.*.*.org.apache.qpid.broker.agent"); - if (settings.rcvEvents) - bindingKeyList.push_back("console.event.#"); - if (settings.rcvHeartbeats) - bindingKeyList.push_back("console.heartbeat"); - } -} - -void SessionManager::allBrokersStable() -{ - Mutex::ScopedLock l(brokerListLock); - for (vector<Broker*>::iterator iter = brokers.begin(); - iter != brokers.end(); iter++) - if ((*iter)->isConnected()) - (*iter)->waitForStable(); -} - -void SessionManager::startProtocol(Broker* broker) -{ - char rawbuffer[512]; - Buffer buffer(rawbuffer, 512); - - broker->encodeHeader(buffer, 'B'); - uint32_t length = 512 - buffer.available(); - buffer.reset(); - broker->connThreadBody.sendBuffer(buffer, length); -} - - -void SessionManager::handleBrokerResp(Broker* broker, Buffer& inBuffer, uint32_t) -{ - framing::Uuid brokerId; - - brokerId.decode(inBuffer); - broker->setBrokerId(brokerId); - - char rawbuffer[512]; - Buffer buffer(rawbuffer, 512); - - uint32_t sequence = sequenceManager.reserve("startup"); - broker->encodeHeader(buffer, 'P', sequence); - uint32_t length = 512 - buffer.available(); - buffer.reset(); - broker->connThreadBody.sendBuffer(buffer, length); - - if (listener != 0) { - listener->brokerInfo(*broker); - } -} - -void SessionManager::handlePackageInd(Broker* broker, Buffer& inBuffer, uint32_t) -{ - string packageName; - inBuffer.getShortString(packageName); - - { - Mutex::ScopedLock l(lock); - map<string, Package*>::iterator iter = packages.find(packageName); - if (iter == packages.end()) { - packages[packageName] = new Package(packageName); - if (listener != 0) - listener->newPackage(packageName); - } - } - - broker->incOutstanding(); - char rawbuffer[512]; - Buffer buffer(rawbuffer, 512); - - uint32_t sequence = sequenceManager.reserve("startup"); - broker->encodeHeader(buffer, 'Q', sequence); - buffer.putShortString(packageName); - uint32_t length = 512 - buffer.available(); - buffer.reset(); - broker->connThreadBody.sendBuffer(buffer, length); -} - -void SessionManager::handleCommandComplete(Broker* broker, Buffer& inBuffer, uint32_t sequence) -{ - Mutex::ScopedLock l(lock); - uint32_t resultCode = inBuffer.getLong(); - string resultText; - inBuffer.getShortString(resultText); - string context = sequenceManager.release(sequence); - if (resultCode != 0) - QPID_LOG(debug, "Received error in completion: " << resultCode << " " << resultText); - if (context == "startup") { - broker->decOutstanding(); - } else if (context == "multiget") { - if (syncSequenceList.count(sequence) == 1) { - syncSequenceList.erase(sequence); - if (syncSequenceList.empty()) { - cv.notify(); - } - } - } - // TODO: Other context cases -} - -void SessionManager::handleClassInd(Broker* broker, Buffer& inBuffer, uint32_t) -{ - string packageName; - string className; - uint8_t hash[16]; - - /*kind*/ (void) inBuffer.getOctet(); - inBuffer.getShortString(packageName); - inBuffer.getShortString(className); - inBuffer.getBin128(hash); - - { - Mutex::ScopedLock l(lock); - map<string, Package*>::iterator pIter = packages.find(packageName); - if (pIter == packages.end() || pIter->second->getClass(className, hash)) - return; - } - - broker->incOutstanding(); - char rawbuffer[512]; - Buffer buffer(rawbuffer, 512); - - uint32_t sequence = sequenceManager.reserve("startup"); - broker->encodeHeader(buffer, 'S', sequence); - buffer.putShortString(packageName); - buffer.putShortString(className); - buffer.putBin128(hash); - uint32_t length = 512 - buffer.available(); - buffer.reset(); - broker->connThreadBody.sendBuffer(buffer, length); -} - -void SessionManager::handleMethodResp(Broker* broker, Buffer& buffer, uint32_t sequence) -{ - if (broker->methodObject) { - broker->methodObject->handleMethodResp(buffer, sequence); - } -} - -void SessionManager::handleHeartbeatInd(Broker* /*broker*/, Buffer& /*inBuffer*/, uint32_t /*sequence*/) -{ -} - -void SessionManager::handleEventInd(Broker* broker, Buffer& buffer, uint32_t /*sequence*/) -{ - string packageName; - string className; - uint8_t hash[16]; - SchemaClass* schemaClass; - - buffer.getShortString(packageName); - buffer.getShortString(className); - buffer.getBin128(hash); - - { - Mutex::ScopedLock l(lock); - map<string, Package*>::iterator pIter = packages.find(packageName); - if (pIter == packages.end()) - return; - schemaClass = pIter->second->getClass(className, hash); - if (schemaClass == 0) - return; - } - - Event event(broker, schemaClass, buffer); - - if (listener) - listener->event(event); -} - -void SessionManager::handleSchemaResp(Broker* broker, Buffer& inBuffer, uint32_t sequence) -{ - uint8_t kind; - string packageName; - string className; - uint8_t hash[16]; - - kind = inBuffer.getOctet(); - inBuffer.getShortString(packageName); - inBuffer.getShortString(className); - inBuffer.getBin128(hash); - - { - Mutex::ScopedLock l(lock); - map<string, Package*>::iterator pIter = packages.find(packageName); - if (pIter != packages.end() && !pIter->second->getClass(className, hash)) { - ClassKey key(packageName, className, hash); - SchemaClass* schemaClass(new SchemaClass(kind, key, inBuffer)); - pIter->second->addClass(className, hash, schemaClass); - if (listener != 0) { - listener->newClass(schemaClass->getClassKey()); - } - } - } - - sequenceManager.release(sequence); - broker->decOutstanding(); -} - -void SessionManager::handleContentInd(Broker* broker, Buffer& buffer, uint32_t sequence, bool prop, bool stat) -{ - string packageName; - string className; - uint8_t hash[16]; - SchemaClass* schemaClass; - - buffer.getShortString(packageName); - buffer.getShortString(className); - buffer.getBin128(hash); - - { - Mutex::ScopedLock l(lock); - map<string, Package*>::iterator pIter = packages.find(packageName); - if (pIter == packages.end()) - return; - schemaClass = pIter->second->getClass(className, hash); - if (schemaClass == 0) - return; - } - - Object object(broker, schemaClass, buffer, prop, stat); - - if (prop && className == "agent" && packageName == "org.apache.qpid.broker") - broker->updateAgent(object); - - { - Mutex::ScopedLock l(lock); - if (syncSequenceList.count(sequence) == 1) { - if (!object.isDeleted()) - getResult.push_back(object); - return; - } - } - - if (listener) { - if (prop) - listener->objectProps(*broker, object); - if (stat) - listener->objectStats(*broker, object); - } -} - -void SessionManager::handleBrokerConnect(Broker* broker) -{ - if (listener != 0) - listener->brokerConnected(*broker); -} - -void SessionManager::handleBrokerDisconnect(Broker* broker) -{ - if (listener != 0) - listener->brokerDisconnected(*broker); -} - diff --git a/qpid/cpp/src/qpid/console/Value.cpp b/qpid/cpp/src/qpid/console/Value.cpp deleted file mode 100644 index 47c6a4ce57..0000000000 --- a/qpid/cpp/src/qpid/console/Value.cpp +++ /dev/null @@ -1,171 +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. - * - */ - -#include "qpid/console/Value.h" -#include "qpid/framing/Buffer.h" - -#include <sstream> - -using namespace qpid; -using namespace qpid::console; -using namespace std; - -string NullValue::str() const -{ - return "<Null>"; -} - -RefValue::RefValue(framing::Buffer& buffer) -{ - uint64_t first = buffer.getLongLong(); - uint64_t second = buffer.getLongLong(); - value.setValue(first, second); -} - -string RefValue::str() const -{ - stringstream s; - s << value; - return s.str(); -} - -string UintValue::str() const -{ - stringstream s; - s << value; - return s.str(); -} - -string IntValue::str() const -{ - stringstream s; - s << value; - return s.str(); -} - -string Uint64Value::str() const -{ - stringstream s; - s << value; - return s.str(); -} - -string Int64Value::str() const -{ - stringstream s; - s << value; - return s.str(); -} - -StringValue::StringValue(framing::Buffer& buffer, int tc) -{ - if (tc == 6) - buffer.getShortString(value); - else - buffer.getMediumString(value); -} - -string BoolValue::str() const -{ - return value ? "T" : "F"; -} - -string FloatValue::str() const -{ - stringstream s; - s << value; - return s.str(); -} - -string DoubleValue::str() const -{ - stringstream s; - s << value; - return s.str(); -} - -UuidValue::UuidValue(framing::Buffer& buffer) -{ - value.decode(buffer); -} - -string MapValue::str() const -{ - stringstream s; - s << value; - return s.str(); -} - -MapValue::MapValue(framing::Buffer& buffer) -{ - value.decode(buffer); -} - - -Value::Ptr ValueFactory::newValue(int typeCode, framing::Buffer& buffer) -{ - switch (typeCode) { - case 1: return Value::Ptr(new UintValue(buffer.getOctet())); // U8 - case 2: return Value::Ptr(new UintValue(buffer.getShort())); // U16 - case 3: return Value::Ptr(new UintValue(buffer.getLong())); // U32 - case 4: return Value::Ptr(new Uint64Value(buffer.getLongLong())); // U64 - case 6: return Value::Ptr(new StringValue(buffer, 6)); // SSTR - case 7: return Value::Ptr(new StringValue(buffer, 7)); // LSTR - case 8: return Value::Ptr(new Int64Value(buffer.getLongLong())); // ABSTIME - case 9: return Value::Ptr(new Uint64Value(buffer.getLongLong())); // DELTATIME - case 10: return Value::Ptr(new RefValue(buffer)); // REF - case 11: return Value::Ptr(new BoolValue(buffer.getOctet())); // BOOL - case 12: return Value::Ptr(new FloatValue(buffer.getFloat())); // FLOAT - case 13: return Value::Ptr(new DoubleValue(buffer.getDouble())); // DOUBLE - case 14: return Value::Ptr(new UuidValue(buffer)); // UUID - case 15: return Value::Ptr(new MapValue(buffer)); // MAP - case 16: return Value::Ptr(new IntValue(buffer.getOctet())); // S8 - case 17: return Value::Ptr(new IntValue(buffer.getShort())); // S16 - case 18: return Value::Ptr(new IntValue(buffer.getLong())); // S32 - case 19: return Value::Ptr(new Int64Value(buffer.getLongLong())); // S64 - } - - return Value::Ptr(); -} - -void ValueFactory::encodeValue(int typeCode, Value::Ptr value, framing::Buffer& buffer) -{ - switch (typeCode) { - case 1: buffer.putOctet(value->asUint()); return; // U8 - case 2: buffer.putShort(value->asUint()); return; // U16 - case 3: buffer.putLong(value->asUint()); return; // U32 - case 4: buffer.putLongLong(value->asUint64()); return; // U64 - case 6: buffer.putShortString(value->asString()); return; // SSTR - case 7: buffer.putMediumString(value->asString()); return; // LSTR - case 8: buffer.putLongLong(value->asInt64()); return; // ABSTIME - case 9: buffer.putLongLong(value->asUint64()); return; // DELTATIME - case 10: value->asObjectId().encode(buffer); return; // REF - case 11: buffer.putOctet(value->asBool() ? 1 : 0); return; // BOOL - case 12: buffer.putFloat(value->asFloat()); return; // FLOAT - case 13: buffer.putDouble(value->asDouble()); return; // DOUBLE - case 14: value->asUuid().encode(buffer); return; // UUID - case 15: value->asMap().encode(buffer); return; // MAP - case 16: buffer.putOctet(value->asInt()); return; // S8 - case 17: buffer.putShort(value->asInt()); return; // S16 - case 18: buffer.putLong(value->asInt()); return; // S32 - case 19: buffer.putLongLong(value->asInt64()); return; // S64 - } -} diff --git a/qpid/cpp/include/qpid/framing/Array.h b/qpid/cpp/src/qpid/framing/Array.h index 6254f6271a..6254f6271a 100644 --- a/qpid/cpp/include/qpid/framing/Array.h +++ b/qpid/cpp/src/qpid/framing/Array.h diff --git a/qpid/cpp/src/qpid/framing/Buffer.cpp b/qpid/cpp/src/qpid/framing/Buffer.cpp index ef977cc8a3..1c4caef046 100644 --- a/qpid/cpp/src/qpid/framing/Buffer.cpp +++ b/qpid/cpp/src/qpid/framing/Buffer.cpp @@ -182,27 +182,27 @@ double Buffer::getDouble(){ } template <> -uint64_t Buffer::getUInt<1>() { +QPID_COMMON_EXTERN uint64_t Buffer::getUInt<1>() { return getOctet(); } template <> -uint64_t Buffer::getUInt<2>() { +QPID_COMMON_EXTERN uint64_t Buffer::getUInt<2>() { return getShort(); } template <> -uint64_t Buffer::getUInt<4>() { +QPID_COMMON_EXTERN uint64_t Buffer::getUInt<4>() { return getLong(); } template <> -uint64_t Buffer::getUInt<8>() { +QPID_COMMON_EXTERN uint64_t Buffer::getUInt<8>() { return getLongLong(); } template <> -void Buffer::putUInt<1>(uint64_t i) { +QPID_COMMON_EXTERN void Buffer::putUInt<1>(uint64_t i) { if (std::numeric_limits<uint8_t>::min() <= i && i <= std::numeric_limits<uint8_t>::max()) { putOctet(i); return; @@ -211,7 +211,7 @@ void Buffer::putUInt<1>(uint64_t i) { } template <> -void Buffer::putUInt<2>(uint64_t i) { +QPID_COMMON_EXTERN void Buffer::putUInt<2>(uint64_t i) { if (std::numeric_limits<uint16_t>::min() <= i && i <= std::numeric_limits<uint16_t>::max()) { putShort(i); return; @@ -220,7 +220,7 @@ void Buffer::putUInt<2>(uint64_t i) { } template <> -void Buffer::putUInt<4>(uint64_t i) { +QPID_COMMON_EXTERN void Buffer::putUInt<4>(uint64_t i) { if (std::numeric_limits<uint32_t>::min() <= i && i <= std::numeric_limits<uint32_t>::max()) { putLong(i); return; @@ -229,7 +229,7 @@ void Buffer::putUInt<4>(uint64_t i) { } template <> -void Buffer::putUInt<8>(uint64_t i) { +QPID_COMMON_EXTERN void Buffer::putUInt<8>(uint64_t i) { putLongLong(i); } diff --git a/qpid/cpp/include/qpid/framing/Buffer.h b/qpid/cpp/src/qpid/framing/Buffer.h index 166b524e3c..166b524e3c 100644 --- a/qpid/cpp/include/qpid/framing/Buffer.h +++ b/qpid/cpp/src/qpid/framing/Buffer.h diff --git a/qpid/cpp/include/qpid/framing/FieldTable.h b/qpid/cpp/src/qpid/framing/FieldTable.h index 1986a72d10..1986a72d10 100644 --- a/qpid/cpp/include/qpid/framing/FieldTable.h +++ b/qpid/cpp/src/qpid/framing/FieldTable.h diff --git a/qpid/cpp/include/qpid/framing/FieldValue.h b/qpid/cpp/src/qpid/framing/FieldValue.h index 1adcb2fa07..1adcb2fa07 100644 --- a/qpid/cpp/include/qpid/framing/FieldValue.h +++ b/qpid/cpp/src/qpid/framing/FieldValue.h diff --git a/qpid/cpp/src/qpid/framing/FrameSet.h b/qpid/cpp/src/qpid/framing/FrameSet.h index 9640abb7ac..4188fd9b8c 100644 --- a/qpid/cpp/src/qpid/framing/FrameSet.h +++ b/qpid/cpp/src/qpid/framing/FrameSet.h @@ -9,9 +9,9 @@ * 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 @@ -44,6 +44,8 @@ class FrameSet public: typedef boost::shared_ptr<FrameSet> shared_ptr; + typedef Frames::iterator iterator; + typedef Frames::const_iterator const_iterator; QPID_COMMON_EXTERN FrameSet(const SequenceNumber& id); QPID_COMMON_EXTERN FrameSet(const FrameSet&); @@ -62,7 +64,7 @@ public: QPID_COMMON_EXTERN AMQMethodBody* getMethod(); QPID_COMMON_EXTERN const AMQHeaderBody* getHeaders() const; QPID_COMMON_EXTERN AMQHeaderBody* getHeaders(); - + template <class T> bool isA() const { const AMQMethodBody* method = getMethod(); return method && method->isA<T>(); @@ -71,12 +73,12 @@ public: template <class T> const T* as() const { const AMQMethodBody* method = getMethod(); return (method && method->isA<T>()) ? dynamic_cast<const T*>(method) : 0; - } + } template <class T> T* as() { AMQMethodBody* method = getMethod(); return (method && method->isA<T>()) ? dynamic_cast<T*>(method) : 0; - } + } template <class T> const T* getHeaderProperties() const { const AMQHeaderBody* header = getHeaders(); @@ -85,7 +87,7 @@ public: Frames::const_iterator begin() const { return parts.begin(); } Frames::const_iterator end() const { return parts.end(); } - + const SequenceNumber& getId() const { return id; } template <class P> void remove(P predicate) { diff --git a/qpid/cpp/include/qpid/framing/List.h b/qpid/cpp/src/qpid/framing/List.h index 681445947c..681445947c 100644 --- a/qpid/cpp/include/qpid/framing/List.h +++ b/qpid/cpp/src/qpid/framing/List.h diff --git a/qpid/cpp/include/qpid/framing/ProtocolVersion.h b/qpid/cpp/src/qpid/framing/ProtocolVersion.h index 309e543516..309e543516 100644 --- a/qpid/cpp/include/qpid/framing/ProtocolVersion.h +++ b/qpid/cpp/src/qpid/framing/ProtocolVersion.h diff --git a/qpid/cpp/include/qpid/framing/SequenceNumber.h b/qpid/cpp/src/qpid/framing/SequenceNumber.h index 00fa2469c8..00fa2469c8 100644 --- a/qpid/cpp/include/qpid/framing/SequenceNumber.h +++ b/qpid/cpp/src/qpid/framing/SequenceNumber.h diff --git a/qpid/cpp/include/qpid/framing/SequenceSet.h b/qpid/cpp/src/qpid/framing/SequenceSet.h index 827c8999b3..827c8999b3 100644 --- a/qpid/cpp/include/qpid/framing/SequenceSet.h +++ b/qpid/cpp/src/qpid/framing/SequenceSet.h diff --git a/qpid/cpp/include/qpid/framing/StructHelper.h b/qpid/cpp/src/qpid/framing/StructHelper.h index fe2fa64ce7..fe2fa64ce7 100644 --- a/qpid/cpp/include/qpid/framing/StructHelper.h +++ b/qpid/cpp/src/qpid/framing/StructHelper.h diff --git a/qpid/cpp/include/qpid/framing/Uuid.h b/qpid/cpp/src/qpid/framing/Uuid.h index e9e56ed7c9..e9e56ed7c9 100644 --- a/qpid/cpp/include/qpid/framing/Uuid.h +++ b/qpid/cpp/src/qpid/framing/Uuid.h diff --git a/qpid/cpp/include/qpid/framing/amqp_types.h b/qpid/cpp/src/qpid/framing/amqp_types.h index 2072a83904..2072a83904 100644 --- a/qpid/cpp/include/qpid/framing/amqp_types.h +++ b/qpid/cpp/src/qpid/framing/amqp_types.h diff --git a/qpid/cpp/include/qpid/framing/amqp_types_full.h b/qpid/cpp/src/qpid/framing/amqp_types_full.h index c5d84dedea..c5d84dedea 100644 --- a/qpid/cpp/include/qpid/framing/amqp_types_full.h +++ b/qpid/cpp/src/qpid/framing/amqp_types_full.h diff --git a/qpid/cpp/src/qpid/ha/AlternateExchangeSetter.h b/qpid/cpp/src/qpid/ha/AlternateExchangeSetter.h index 2386a01084..fbf4755e7d 100644 --- a/qpid/cpp/src/qpid/ha/AlternateExchangeSetter.h +++ b/qpid/cpp/src/qpid/ha/AlternateExchangeSetter.h @@ -25,7 +25,6 @@ #include "qpid/log/Statement.h" #include "qpid/broker/Exchange.h" #include "qpid/broker/ExchangeRegistry.h" -#include "boost/function.hpp" #include <map> namespace qpid { diff --git a/qpid/cpp/src/qpid/ha/Backup.cpp b/qpid/cpp/src/qpid/ha/Backup.cpp index e28ca1fa6a..503de3e351 100644 --- a/qpid/cpp/src/qpid/ha/Backup.cpp +++ b/qpid/cpp/src/qpid/ha/Backup.cpp @@ -52,9 +52,7 @@ using sys::Mutex; Backup::Backup(HaBroker& hb, const Settings& s) : logPrefix("Backup: "), membership(hb.getMembership()), stopped(false), haBroker(hb), broker(hb.getBroker()), settings(s), - statusCheck( - new StatusCheck( - logPrefix, broker.getOptions().linkHeartbeatInterval, hb.getBrokerInfo())) + statusCheck(new StatusCheck(hb)) {} void Backup::setBrokerUrl(const Url& brokers) { diff --git a/qpid/cpp/src/qpid/ha/Backup.h b/qpid/cpp/src/qpid/ha/Backup.h index 4943ca5e2e..88194158ce 100644 --- a/qpid/cpp/src/qpid/ha/Backup.h +++ b/qpid/cpp/src/qpid/ha/Backup.h @@ -59,6 +59,8 @@ class Backup : public Role Role* promote(); + boost::shared_ptr<BrokerReplicator> getBrokerReplicator() { return replicator; } + private: void stop(sys::Mutex::ScopedLock&); Role* recover(sys::Mutex::ScopedLock&); diff --git a/qpid/cpp/src/qpid/ha/BrokerInfo.h b/qpid/cpp/src/qpid/ha/BrokerInfo.h index bd1ad86392..87d51f5113 100644 --- a/qpid/cpp/src/qpid/ha/BrokerInfo.h +++ b/qpid/cpp/src/qpid/ha/BrokerInfo.h @@ -23,6 +23,7 @@ */ #include "types.h" +#include "hash.h" #include "qpid/Url.h" #include "qpid/framing/FieldTable.h" #include "qpid/types/Uuid.h" @@ -42,7 +43,7 @@ class BrokerInfo { public: typedef std::set<BrokerInfo> Set; - typedef qpid::sys::unordered_map<types::Uuid, BrokerInfo, types::Uuid::Hasher> Map; + typedef qpid::sys::unordered_map<types::Uuid, BrokerInfo, Hasher<types::Uuid> > Map; BrokerInfo(); BrokerInfo(const types::Uuid& id, BrokerStatus, const Address& = Address()); diff --git a/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp b/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp index 17b00185ef..eb1206437a 100644 --- a/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp +++ b/qpid/cpp/src/qpid/ha/BrokerReplicator.cpp @@ -21,6 +21,7 @@ #include "BrokerReplicator.h" #include "HaBroker.h" #include "QueueReplicator.h" +#include "TxReplicator.h" #include "qpid/broker/Broker.h" #include "qpid/broker/amqp_0_10/Connection.h" #include "qpid/broker/ConnectionObserver.h" @@ -129,7 +130,6 @@ const string COLON(":"); void sendQuery(const string& packageName, const string& className, const string& queueName, SessionHandler& sessionHandler) { - framing::AMQP_ServerProxy peer(sessionHandler.out); Variant::Map request; request[WHAT] = OBJECT; Variant::Map schema; @@ -229,8 +229,8 @@ class BrokerReplicator::UpdateTracker { typedef boost::function<void (const std::string&)> CleanFn; UpdateTracker(const std::string& type_, // "queue" or "exchange" - CleanFn f, const ReplicationTest& rt) - : type(type_), cleanFn(f), repTest(rt) {} + CleanFn f) + : type(type_), cleanFn(f) {} /** Destructor cleans up remaining initial queues. */ ~UpdateTracker() { @@ -245,16 +245,10 @@ class BrokerReplicator::UpdateTracker { } /** Add an exchange name */ - void addExchange(Exchange::shared_ptr ex) { - if (repTest.getLevel(*ex)) - initial.insert(ex->getName()); - } + void addExchange(Exchange::shared_ptr ex) { initial.insert(ex->getName()); } /** Add a queue name. */ - void addQueue(Queue::shared_ptr q) { - if (repTest.getLevel(*q)) - initial.insert(q->getName()); - } + void addQueue(Queue::shared_ptr q) { initial.insert(q->getName()); } /** Received an event for name */ void event(const std::string& name) { @@ -275,13 +269,13 @@ class BrokerReplicator::UpdateTracker { void clean(const std::string& name) { QPID_LOG(info, "Backup: Deleted " << type << " " << name << ": no longer exists on primary"); - cleanFn(name); + try { cleanFn(name); } + catch (const framing::NotFoundException&) {} } std::string type; Names initial, events; CleanFn cleanFn; - ReplicationTest repTest; }; namespace { @@ -349,7 +343,8 @@ BrokerReplicator::~BrokerReplicator() { shutdown(); } namespace { void collectQueueReplicators( - const boost::shared_ptr<Exchange> ex, set<boost::shared_ptr<QueueReplicator> >& collect) + const boost::shared_ptr<Exchange>& ex, + set<boost::shared_ptr<QueueReplicator> >& collect) { boost::shared_ptr<QueueReplicator> qr(boost::dynamic_pointer_cast<QueueReplicator>(ex)); if (qr) collect.insert(qr); @@ -390,16 +385,13 @@ void BrokerReplicator::connected(Bridge& bridge, SessionHandler& sessionHandler) exchangeTracker.reset( new UpdateTracker("exchange", - boost::bind(&BrokerReplicator::deleteExchange, this, _1), - replicationTest)); - exchanges.eachExchange( - boost::bind(&UpdateTracker::addExchange, exchangeTracker.get(), _1)); + boost::bind(&BrokerReplicator::deleteExchange, this, _1))); + exchanges.eachExchange(boost::bind(&BrokerReplicator::existingExchange, this, _1)); queueTracker.reset( new UpdateTracker("queue", - boost::bind(&BrokerReplicator::deleteQueue, this, _1, true), - replicationTest)); - queues.eachQueue(boost::bind(&UpdateTracker::addQueue, queueTracker.get(), _1)); + boost::bind(&BrokerReplicator::deleteQueue, this, _1, true))); + queues.eachQueue(boost::bind(&BrokerReplicator::existingQueue, this, _1)); framing::AMQP_ServerProxy peer(sessionHandler.out); const qmf::org::apache::qpid::broker::ArgsLinkBridge& args(bridge.getArgs()); @@ -428,6 +420,21 @@ void BrokerReplicator::connected(Bridge& bridge, SessionHandler& sessionHandler) sendQuery(ORG_APACHE_QPID_BROKER, BINDING, queueName, sessionHandler); } +// Called for each queue in existence when the backup connects to a primary. +void BrokerReplicator::existingQueue(const boost::shared_ptr<Queue>& q) { + if (replicationTest.getLevel(*q)) { + QPID_LOG(debug, "Existing queue: " << q->getName()); + queueTracker->addQueue(q); + } +} + +void BrokerReplicator::existingExchange(const boost::shared_ptr<Exchange>& ex) { + if (replicationTest.getLevel(*ex)) { + QPID_LOG(debug, "Existing exchange: " << ex->getName()); + exchangeTracker->addExchange(ex); + } +} + void BrokerReplicator::route(Deliverable& msg) { // We transition from JOINING->CATCHUP on the first message received from the primary. // Until now we couldn't be sure if we had a good connection to the primary. @@ -554,11 +561,7 @@ void BrokerReplicator::doEventExchangeDeclare(Variant::Map& values) { void BrokerReplicator::doEventExchangeDelete(Variant::Map& values) { string name = values[EXNAME].asString(); boost::shared_ptr<Exchange> exchange = exchanges.find(name); - if (!exchange) { - QPID_LOG(warning, logPrefix << "Exchange delete event, not found: " << name); - } else if (!replicationTest.getLevel(*exchange)) { - QPID_LOG(warning, logPrefix << "Exchange delete event, not replicated: " << name); - } else { + if (exchange && replicationTest.getLevel(*exchange)) { QPID_LOG(debug, logPrefix << "Exchange delete event:" << name); if (exchangeTracker.get()) exchangeTracker->event(name); deleteExchange(name); @@ -651,8 +654,10 @@ void BrokerReplicator::doResponseQueue(Variant::Map& values) { if (!queueTracker.get()) throw Exception(QPID_MSG("Unexpected queue response: " << values)); if (!queueTracker->response(name)) return; // Response is out-of-date + QPID_LOG(debug, logPrefix << "Queue response: " << name); boost::shared_ptr<Queue> queue = queues.find(name); + if (queue) { // Already exists bool uuidOk = (getHaUuid(queue->getSettings().original) == getHaUuid(argsMap)); if (!uuidOk) QPID_LOG(debug, logPrefix << "UUID mismatch for queue: " << name); @@ -660,6 +665,7 @@ void BrokerReplicator::doResponseQueue(Variant::Map& values) { QPID_LOG(debug, logPrefix << "Queue response replacing queue: " << name); deleteQueue(name); } + framing::FieldTable args; qpid::amqp_0_10::translate(argsMap, args); boost::shared_ptr<QueueReplicator> qr = replicateQueue( @@ -770,8 +776,13 @@ boost::shared_ptr<QueueReplicator> BrokerReplicator::startQueueReplicator( const boost::shared_ptr<Queue>& queue) { if (replicationTest.getLevel(*queue) == ALL) { - boost::shared_ptr<QueueReplicator> qr( - new QueueReplicator(haBroker, queue, link)); + boost::shared_ptr<QueueReplicator> qr; + if (TxReplicator::isTxQueue(queue->getName())){ + qr.reset(new TxReplicator(haBroker, queue, link)); + } + else { + qr.reset(new QueueReplicator(haBroker, queue, link)); + } qr->activate(); return qr; } @@ -785,7 +796,7 @@ void BrokerReplicator::deleteQueue(const std::string& name, bool purge) { // messages. Any reroutes will be done at the primary and // replicated as normal. if (purge) queue->purge(0, boost::shared_ptr<Exchange>()); - broker.deleteQueue(name, userId, remoteHost); + haBroker.getBroker().deleteQueue(name, userId, remoteHost); QPID_LOG(debug, logPrefix << "Queue deleted: " << name); } } @@ -864,28 +875,35 @@ bool BrokerReplicator::isBound(boost::shared_ptr<Queue>, const string* const, co string BrokerReplicator::getType() const { return QPID_CONFIGURATION_REPLICATOR; } -void BrokerReplicator::autoDeleteCheck(boost::shared_ptr<Exchange> ex) { +void BrokerReplicator::disconnectedExchange(boost::shared_ptr<Exchange> ex) { boost::shared_ptr<QueueReplicator> qr(boost::dynamic_pointer_cast<QueueReplicator>(ex)); - if (!qr) return; - assert(qr); - if (qr->getQueue()->isAutoDelete() && qr->isSubscribed()) { - if (qr->getQueue()->getSettings().autoDeleteDelay) { - // Start the auto-delete timer - qr->getQueue()->releaseFromUse(); - qr->getQueue()->scheduleAutoDelete(); + if (qr) { + qr->disconnect(); + if (TxReplicator::isTxQueue(qr->getQueue()->getName())) { + // Transactions are aborted on failover so clean up tx-queues + deleteQueue(qr->getQueue()->getName()); } - else { - // Delete immediately. Don't purge, the primary is gone so we need - // to reroute the deleted messages. - deleteQueue(qr->getQueue()->getName(), false); + else if (qr->getQueue()->isAutoDelete() && qr->isSubscribed()) { + if (qr->getQueue()->getSettings().autoDeleteDelay) { + // Start the auto-delete timer + qr->getQueue()->releaseFromUse(); + qr->getQueue()->scheduleAutoDelete(); + } + else { + // Delete immediately. Don't purge, the primary is gone so we need + // to reroute the deleted messages. + deleteQueue(qr->getQueue()->getName(), false); + } } } } +typedef vector<boost::shared_ptr<Exchange> > ExchangeVector; + // Callback function for accumulating exchange candidates namespace { - void exchangeAccumulatorCallback(vector<boost::shared_ptr<Exchange> >& c, const Exchange::shared_ptr& i) { - c.push_back(i); + void exchangeAccumulatorCallback(ExchangeVector& ev, const Exchange::shared_ptr& i) { + ev.push_back(i); } } @@ -893,13 +911,12 @@ namespace { void BrokerReplicator::disconnected() { QPID_LOG(info, logPrefix << "Disconnected from primary " << primary); connection = 0; - // Clean up auto-delete queues - vector<boost::shared_ptr<Exchange> > collect; - // Make a copy so we can work outside the ExchangeRegistry lock - exchanges.eachExchange( - boost::bind(&exchangeAccumulatorCallback, boost::ref(collect), _1)); - for_each(collect.begin(), collect.end(), - boost::bind(&BrokerReplicator::autoDeleteCheck, this, _1)); + + // Make copy of exchanges so we can work outside the registry lock. + ExchangeVector exs; + exchanges.eachExchange(boost::bind(&exchangeAccumulatorCallback, boost::ref(exs), _1)); + for_each(exs.begin(), exs.end(), + boost::bind(&BrokerReplicator::disconnectedExchange, this, _1)); } void BrokerReplicator::setMembership(const Variant::List& brokers) { diff --git a/qpid/cpp/src/qpid/ha/BrokerReplicator.h b/qpid/cpp/src/qpid/ha/BrokerReplicator.h index f93e25cb81..395f0706d9 100644 --- a/qpid/cpp/src/qpid/ha/BrokerReplicator.h +++ b/qpid/cpp/src/qpid/ha/BrokerReplicator.h @@ -71,6 +71,8 @@ class BrokerReplicator : public broker::Exchange, public boost::enable_shared_from_this<BrokerReplicator> { public: + typedef boost::shared_ptr<QueueReplicator> QueueReplicatorPtr; + BrokerReplicator(HaBroker&, const boost::shared_ptr<broker::Link>&); ~BrokerReplicator(); @@ -84,8 +86,9 @@ class BrokerReplicator : public broker::Exchange, bool isBound(boost::shared_ptr<broker::Queue>, const std::string* const, const framing::FieldTable* const); void shutdown(); + QueueReplicatorPtr findQueueReplicator(const std::string& qname); + private: - typedef boost::shared_ptr<QueueReplicator> QueueReplicatorPtr; typedef std::pair<boost::shared_ptr<broker::Queue>, bool> CreateQueueResult; typedef std::pair<boost::shared_ptr<broker::Exchange>, bool> CreateExchangeResult; @@ -99,6 +102,8 @@ class BrokerReplicator : public broker::Exchange, class ConnectionObserver; void connected(broker::Bridge&, broker::SessionHandler&); + void existingQueue(const boost::shared_ptr<broker::Queue>&); + void existingExchange(const boost::shared_ptr<broker::Exchange>&); void doEventQueueDeclare(types::Variant::Map& values); void doEventQueueDelete(types::Variant::Map& values); @@ -114,7 +119,6 @@ class BrokerReplicator : public broker::Exchange, void doResponseBind(types::Variant::Map& values); void doResponseHaBroker(types::Variant::Map& values); - QueueReplicatorPtr findQueueReplicator(const std::string& qname); QueueReplicatorPtr startQueueReplicator(const boost::shared_ptr<broker::Queue>&); QueueReplicatorPtr replicateQueue( @@ -135,8 +139,7 @@ class BrokerReplicator : public broker::Exchange, void deleteQueue(const std::string& name, bool purge=true); void deleteExchange(const std::string& name); - void autoDeleteCheck(boost::shared_ptr<broker::Exchange>); - + void disconnectedExchange(boost::shared_ptr<broker::Exchange>); void disconnected(); void setMembership(const types::Variant::List&); // Set membership from list. diff --git a/qpid/cpp/src/qpid/ha/makeMessage.cpp b/qpid/cpp/src/qpid/ha/Event.cpp index 5b063a23e7..8265a6edd3 100644 --- a/qpid/cpp/src/qpid/ha/makeMessage.cpp +++ b/qpid/cpp/src/qpid/ha/Event.cpp @@ -18,45 +18,69 @@ * under the License. * */ -#include "makeMessage.h" +#include "Event.h" #include "qpid/broker/amqp_0_10/MessageTransfer.h" #include "qpid/framing/AMQFrame.h" +#include "qpid/framing/DeliveryProperties.h" #include "qpid/framing/MessageTransferBody.h" +#include "qpid/log/Statement.h" namespace qpid { namespace ha { -broker::Message makeMessage(const framing::Buffer& buffer, - const std::string& destination) -{ - using namespace framing; - using broker::amqp_0_10::MessageTransfer; +using namespace std; +using namespace framing; +using namespace broker::amqp_0_10; + +namespace { +const string QPID_HA(QPID_HA_PREFIX); +} + +bool isEventKey(const std::string& key) { + const std::string& prefix = QPID_HA; + bool ret = key.size() > prefix.size() && key.compare(0, prefix.size(), prefix) == 0; + return ret; +} + +const string DequeueEvent::KEY(QPID_HA+"de"); +const string IdEvent::KEY(QPID_HA+"id"); +const string TxEnqueueEvent::KEY(QPID_HA+"txenq"); +const string TxDequeueEvent::KEY(QPID_HA+"txdeq"); +const string TxPrepareEvent::KEY(QPID_HA+"txpre"); +const string TxCommitEvent::KEY(QPID_HA+"txcom"); +const string TxRollbackEvent::KEY(QPID_HA+"txrb"); +const string TxPrepareOkEvent::KEY(QPID_HA+"txok"); +const string TxPrepareFailEvent::KEY(QPID_HA+"txno"); +const string TxMembersEvent::KEY(QPID_HA+"txmem"); - boost::intrusive_ptr<MessageTransfer> transfer( - new qpid::broker::amqp_0_10::MessageTransfer()); +broker::Message makeMessage( + const string& data, const string& destination, const string& routingKey) +{ + boost::intrusive_ptr<MessageTransfer> transfer(new MessageTransfer()); AMQFrame method((MessageTransferBody(ProtocolVersion(), destination, 0, 0))); + method.setBof(true); + method.setEof(false); + method.setBos(true); + method.setEos(true); AMQFrame header((AMQHeaderBody())); - AMQFrame content((AMQContentBody())); - // AMQContentBody::decode is missing a const declaration, so cast it here. - content.castBody<AMQContentBody>()->decode( - const_cast<Buffer&>(buffer), buffer.getSize()); header.setBof(false); header.setEof(false); header.setBos(true); header.setEos(true); + AMQFrame content((AMQContentBody())); content.setBof(false); content.setEof(true); content.setBos(true); content.setEos(true); + Buffer buffer(const_cast<char*>(&data[0]), data.size()); + content.castBody<AMQContentBody>()->decode( + const_cast<Buffer&>(buffer), buffer.getSize()); transfer->getFrames().append(method); transfer->getFrames().append(header); transfer->getFrames().append(content); + transfer->getFrames().getHeaders()-> + get<DeliveryProperties>(true)->setRoutingKey(routingKey); return broker::Message(transfer, 0); } -broker::Message makeMessage(const std::string& content, const std::string& destination) { - framing::Buffer buffer(const_cast<char*>(&content[0]), content.size()); - return makeMessage(buffer, destination); -} - }} // namespace qpid::ha diff --git a/qpid/cpp/src/qpid/ha/Event.h b/qpid/cpp/src/qpid/ha/Event.h new file mode 100644 index 0000000000..f292499e7b --- /dev/null +++ b/qpid/cpp/src/qpid/ha/Event.h @@ -0,0 +1,193 @@ +#ifndef QPID_HA_EVENT_H +#define QPID_HA_EVENT_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 "types.h" +#include "qpid/broker/Message.h" +#include "qpid/framing/BufferTypes.h" + +/**@file Defines event messages used to pass transaction information from + * primary observers to backup replicators. + */ + +namespace qpid { +namespace ha { + +broker::Message makeMessage( + const std::string& content, + const std::string& destination, + const std::string& routingKey); + + +/** Test if a string is an event key */ +bool isEventKey(const std::string& key); + +/** Base class for encodable events */ +class Event { + public: + virtual ~Event() {} + virtual void encode(framing::Buffer& buffer) const = 0; + virtual void decode(framing::Buffer& buffer) = 0; + virtual size_t encodedSize() const = 0; + virtual std::string key() const = 0; // Routing key + virtual void print(std::ostream& o) const = 0; + broker::Message message(const std::string& destination=std::string()) const { + return makeMessage(framing::encodeStr(*this), destination, key()); } +}; + + +inline std::ostream& operator<<(std::ostream& o, const Event& e) { + o << "<" << e.key() << ":"; + e.print(o); + return o << ">"; +} + +/** Event base template */ +template <class Derived> class EventBase : public Event { + public: + std::string key() const { return Derived::KEY; } +}; + +//////////////// Specific event type + +//// QueueReplicator events + +struct DequeueEvent : public EventBase<DequeueEvent> { + static const std::string KEY; + ReplicationIdSet ids; + + DequeueEvent(ReplicationIdSet ids_=ReplicationIdSet()) : ids(ids_) {} + void encode(framing::Buffer& b) const { b.put(ids); } + void decode(framing::Buffer& b) { b.get(ids); } + virtual size_t encodedSize() const { return ids.encodedSize(); } + void print(std::ostream& o) const { o << ids; } +}; + +struct IdEvent : public EventBase<IdEvent> { + static const std::string KEY; + ReplicationId id; + + IdEvent(ReplicationId id_=0) : id(id_) {} + void encode(framing::Buffer& b) const { b.put(id); } + void decode(framing::Buffer& b) { b.get(id); } + virtual size_t encodedSize() const { return id.encodedSize(); } + void print(std::ostream& o) const { o << id; } +}; + +//// Transaction events + +struct TxEnqueueEvent : public EventBase<TxEnqueueEvent> { + static const std::string KEY; + framing::LongString queue; + ReplicationId id; + + TxEnqueueEvent(std::string q=std::string(), ReplicationId i=ReplicationId()) + : queue(q), id(i) {} + void encode(framing::Buffer& b) const { b.put(queue); b.put(id); } + void decode(framing::Buffer& b) { b.get(queue); b.get(id); } + virtual size_t encodedSize() const { return queue.encodedSize()+id.encodedSize(); } + void print(std::ostream& o) const { o << queue.value << " " << id; } +}; + +struct TxDequeueEvent : public EventBase<TxDequeueEvent> { + static const std::string KEY; + framing::LongString queue; + ReplicationId id; + + TxDequeueEvent(std::string q=std::string(), ReplicationId r=0) : + queue(q), id(r) {} + void encode(framing::Buffer& b) const { b.put(queue);b.put(id); } + void decode(framing::Buffer& b) { b.get(queue);b.get(id); } + virtual size_t encodedSize() const { return queue.encodedSize()+id.encodedSize(); } + void print(std::ostream& o) const { o << queue.value << " " << id; } +}; + +struct TxPrepareEvent : public EventBase<TxPrepareEvent> { + static const std::string KEY; + void encode(framing::Buffer&) const {} + void decode(framing::Buffer&) {} + virtual size_t encodedSize() const { return 0; } + void print(std::ostream&) const {} +}; + +struct TxCommitEvent : public EventBase<TxCommitEvent> { + static const std::string KEY; + void encode(framing::Buffer&) const {} + void decode(framing::Buffer&) {} + virtual size_t encodedSize() const { return 0; } + void print(std::ostream&) const {} +}; + +struct TxRollbackEvent : public EventBase<TxRollbackEvent> { + static const std::string KEY; + void encode(framing::Buffer&) const {} + void decode(framing::Buffer&) {} + virtual size_t encodedSize() const { return 0; } + void print(std::ostream&) const {} +}; + +struct TxPrepareOkEvent : public EventBase<TxPrepareOkEvent> { + static const std::string KEY; + types::Uuid broker; + TxPrepareOkEvent(const types::Uuid& b=types::Uuid()) : broker(b) {} + + void encode(framing::Buffer& b) const { + b.putRawData(broker.data(), broker.size()); + } + + void decode(framing::Buffer& b) { + std::string s; + b.getRawData(s, broker.size()); + broker = types::Uuid(&s[0]); + } + virtual size_t encodedSize() const { return broker.size(); } + void print(std::ostream& o) const { o << broker; } +}; + +struct TxPrepareFailEvent : public EventBase<TxPrepareFailEvent> { + static const std::string KEY; + types::Uuid broker; + TxPrepareFailEvent(const types::Uuid& b=types::Uuid()) : broker(b) {} + void encode(framing::Buffer& b) const { b.putRawData(broker.data(), broker.size()); } + void decode(framing::Buffer& b) { + std::string s; + b.getRawData(s, broker.size()); + broker = types::Uuid(&s[0]); + } + virtual size_t encodedSize() const { return broker.size(); } + void print(std::ostream& o) const { o << broker; } +}; + +struct TxMembersEvent : public EventBase<TxMembersEvent> { + static const std::string KEY; + UuidSet members; + TxMembersEvent(const UuidSet& s=UuidSet()) : members(s) {} + void encode(framing::Buffer& b) const { b.put(members); } + void decode(framing::Buffer& b) { b.get(members); } + size_t encodedSize() const { return members.encodedSize(); } + void print(std::ostream& o) const { o << members; } +}; + +}} // namespace qpid::ha + +#endif /*!QPID_HA_EVENT_H*/ diff --git a/qpid/cpp/src/qpid/ha/FailoverExchange.cpp b/qpid/cpp/src/qpid/ha/FailoverExchange.cpp index 556c7458b6..9c7b986bf8 100644 --- a/qpid/cpp/src/qpid/ha/FailoverExchange.cpp +++ b/qpid/cpp/src/qpid/ha/FailoverExchange.cpp @@ -19,7 +19,7 @@ * */ #include "FailoverExchange.h" -#include "makeMessage.h" +#include "Event.h" #include "qpid/broker/amqp_0_10/MessageTransfer.h" #include "qpid/broker/Message.h" #include "qpid/broker/DeliverableMessage.h" @@ -117,7 +117,7 @@ void FailoverExchange::sendUpdate(const Queue::shared_ptr& queue, sys::Mutex::Sc if (urls.empty()) return; framing::Array array = vectorToUrlArray(urls); const ProtocolVersion v; - broker::Message message(makeMessage(Buffer(), typeName)); + broker::Message message(makeMessage(std::string(), typeName, typeName)); MessageTransfer& transfer = MessageTransfer::get(message); MessageProperties* props = transfer.getFrames().getHeaders()->get<framing::MessageProperties>(true); diff --git a/qpid/cpp/src/qpid/ha/HaBroker.cpp b/qpid/cpp/src/qpid/ha/HaBroker.cpp index 7efeaad5b2..61561b3af6 100644 --- a/qpid/cpp/src/qpid/ha/HaBroker.cpp +++ b/qpid/cpp/src/qpid/ha/HaBroker.cpp @@ -64,6 +64,7 @@ using boost::dynamic_pointer_cast; HaBroker::HaBroker(broker::Broker& b, const Settings& s) : systemId(b.getSystem()->getSystemId().data()), settings(s), + userId(s.username+"@"+b.getOptions().realm), broker(b), observer(new ConnectionObserver(*this, systemId)), role(new StandAlone), @@ -75,14 +76,14 @@ HaBroker::HaBroker(broker::Broker& b, const Settings& s) // otherwise there's a window for a client to connect before we get to // initialize() if (settings.cluster) { - QPID_LOG(debug, "Broker startup, rejecting client connections."); + QPID_LOG(debug, "Backup starting, rejecting client connections."); shared_ptr<broker::ConnectionObserver> excluder(new BackupConnectionExcluder); observer->setObserver(excluder, "Backup: "); broker.getConnectionObservers().add(observer); broker.getExchanges().registerExchange(failoverExchange); } // QueueSnapshots are needed for standalone replication as well as cluster. - broker.getConfigurationObservers().add(queueSnapshots); + broker.getBrokerObservers().add(queueSnapshots); } namespace { @@ -94,7 +95,7 @@ bool isNone(const std::string& x) { return x.empty() || x == NONE; } void HaBroker::initialize() { if (settings.cluster) { membership.setStatus(JOINING); - QPID_LOG(notice, "Initializing HA broker: " << membership.getInfo()); + QPID_LOG(notice, "Initializing HA broker: " << membership.getSelf()); } // Set up the management object. @@ -202,7 +203,7 @@ std::vector<Url> HaBroker::getKnownBrokers() const { } void HaBroker::shutdown(const std::string& message) { - QPID_LOG(critical, message); + QPID_LOG(critical, "Shutting down: " << message); broker.shutdown(); throw Exception(message); } @@ -213,7 +214,7 @@ BrokerStatus HaBroker::getStatus() const { void HaBroker::setAddress(const Address& a) { QPID_LOG(info, role->getLogPrefix() << "Set self address to: " << a); - membership.setAddress(a); + membership.setSelfAddress(a); } boost::shared_ptr<QueueReplicator> HaBroker::findQueueReplicator(const std::string& queueName) { diff --git a/qpid/cpp/src/qpid/ha/HaBroker.h b/qpid/cpp/src/qpid/ha/HaBroker.h index 8e5d30acfb..d10014846c 100644 --- a/qpid/cpp/src/qpid/ha/HaBroker.h +++ b/qpid/cpp/src/qpid/ha/HaBroker.h @@ -84,6 +84,7 @@ class HaBroker : public management::Manageable broker::Broker& getBroker() { return broker; } const Settings& getSettings() const { return settings; } + boost::shared_ptr<Role> getRole() const {return role; } /** Shut down the broker because of a critical error. */ void shutdown(const std::string& message); @@ -91,7 +92,7 @@ class HaBroker : public management::Manageable BrokerStatus getStatus() const; boost::shared_ptr<ConnectionObserver> getObserver() { return observer; } - BrokerInfo getBrokerInfo() const { return membership.getInfo(); } + BrokerInfo getBrokerInfo() const { return membership.getSelf(); } Membership& getMembership() { return membership; } types::Uuid getSystemId() const { return systemId; } @@ -101,6 +102,9 @@ class HaBroker : public management::Manageable boost::shared_ptr<QueueReplicator> findQueueReplicator(const std::string& queueName); + /** Authenticated user ID for queue create/delete */ + std::string getUserId() const { return userId; } + private: void setPublicUrl(const Url&); void setBrokerUrl(const Url&); @@ -111,6 +115,7 @@ class HaBroker : public management::Manageable // Immutable members const types::Uuid systemId; const Settings settings; + const std::string userId; // Member variables protected by lock mutable sys::Mutex lock; diff --git a/qpid/cpp/src/qpid/ha/Membership.cpp b/qpid/cpp/src/qpid/ha/Membership.cpp index 411bad3841..2f8ef1da97 100644 --- a/qpid/cpp/src/qpid/ha/Membership.cpp +++ b/qpid/cpp/src/qpid/ha/Membership.cpp @@ -107,6 +107,14 @@ BrokerInfo::Set Membership::otherBackups() const { return result; } +BrokerInfo::Set Membership::getBrokers() const { + Mutex::ScopedLock l(lock); + BrokerInfo::Set result; + transform(brokers.begin(), brokers.end(), inserter(result, result.begin()), + boost::bind(&BrokerInfo::Map::value_type::second, _1)); + return result; +} + bool Membership::get(const types::Uuid& id, BrokerInfo& result) const { Mutex::ScopedLock l(lock); BrokerInfo::Map::const_iterator i = brokers.find(id); @@ -136,10 +144,9 @@ bool checkTransition(BrokerStatus from, BrokerStatus to) { } } // namespace - void Membership::update(Mutex::ScopedLock& l) { QPID_LOG(info, "Membership: " << brokers); - // Update managment and send update event. +// Update managment and send update event. BrokerStatus newStatus = getStatus(l); Variant::List brokerList = asList(l); if (mgmtObject) { @@ -198,14 +205,14 @@ BrokerStatus Membership::getStatus(sys::Mutex::ScopedLock&) const { return i->second.getStatus(); } -BrokerInfo Membership::getInfo() const { +BrokerInfo Membership::getSelf() const { Mutex::ScopedLock l(lock); BrokerInfo::Map::const_iterator i = brokers.find(self); assert(i != brokers.end()); return i->second; } -void Membership::setAddress(const Address& a) { +void Membership::setSelfAddress(const Address& a) { Mutex::ScopedLock l(lock); brokers[self].setAddress(a); update(l); diff --git a/qpid/cpp/src/qpid/ha/Membership.h b/qpid/cpp/src/qpid/ha/Membership.h index f442586a71..5b2b72e2fc 100644 --- a/qpid/cpp/src/qpid/ha/Membership.h +++ b/qpid/cpp/src/qpid/ha/Membership.h @@ -26,6 +26,7 @@ #include "types.h" #include "qpid/log/Statement.h" #include "qpid/sys/Mutex.h" +#include "qpid/sys/Time.h" #include "qpid/types/Variant.h" #include <boost/function.hpp> #include <set> @@ -69,16 +70,19 @@ class Membership /** Return IDs of all READY backups other than self */ BrokerInfo::Set otherBackups() const; + /** Return IDs of all brokers */ + BrokerInfo::Set getBrokers() const; + void assign(const types::Variant::List&); types::Variant::List asList() const; bool get(const types::Uuid& id, BrokerInfo& result) const; - types::Uuid getSelf() const { return self; } - BrokerInfo getInfo() const; + BrokerInfo getSelf() const; BrokerStatus getStatus() const; void setStatus(BrokerStatus s); - void setAddress(const Address&); + + void setSelfAddress(const Address&); private: void update(sys::Mutex::ScopedLock&); diff --git a/qpid/cpp/src/qpid/ha/Primary.cpp b/qpid/cpp/src/qpid/ha/Primary.cpp index beabab4e32..e7fdc5035f 100644 --- a/qpid/cpp/src/qpid/ha/Primary.cpp +++ b/qpid/cpp/src/qpid/ha/Primary.cpp @@ -27,17 +27,19 @@ #include "RemoteBackup.h" #include "ConnectionObserver.h" #include "QueueReplicator.h" +#include "PrimaryTxObserver.h" #include "qpid/assert.h" #include "qpid/broker/Broker.h" -#include "qpid/broker/ConfigurationObserver.h" +#include "qpid/broker/BrokerObserver.h" #include "qpid/broker/Connection.h" #include "qpid/broker/Queue.h" #include "qpid/framing/FieldTable.h" #include "qpid/framing/FieldValue.h" -#include "qpid/framing/Uuid.h" #include "qpid/log/Statement.h" +#include "qpid/types/Uuid.h" #include "qpid/sys/Timer.h" #include <boost/bind.hpp> +#include <boost/shared_ptr.hpp> namespace qpid { namespace ha { @@ -59,15 +61,18 @@ class PrimaryConnectionObserver : public broker::ConnectionObserver Primary& primary; }; -class PrimaryConfigurationObserver : public broker::ConfigurationObserver +class PrimaryBrokerObserver : public broker::BrokerObserver { public: - PrimaryConfigurationObserver(Primary& p) : primary(p) {} + PrimaryBrokerObserver(Primary& p) : primary(p) {} void queueCreate(const Primary::QueuePtr& q) { primary.queueCreate(q); } void queueDestroy(const Primary::QueuePtr& q) { primary.queueDestroy(q); } void exchangeCreate(const Primary::ExchangePtr& q) { primary.exchangeCreate(q); } void exchangeDestroy(const Primary::ExchangePtr& q) { primary.exchangeDestroy(q); } - private: + void startTx(const shared_ptr<broker::TxBuffer>& tx) { primary.startTx(tx); } + void startDtx(const shared_ptr<broker::DtxBuffer>& dtx) { primary.startDtx(dtx); } + + private: Primary& primary; }; @@ -82,8 +87,6 @@ class ExpectedBackupTimerTask : public sys::TimerTask { } // namespace -Primary* Primary::instance = 0; - Primary::Primary(HaBroker& hb, const BrokerInfo::Set& expect) : haBroker(hb), membership(hb.getMembership()), logPrefix("Primary: "), active(false), @@ -92,13 +95,11 @@ Primary::Primary(HaBroker& hb, const BrokerInfo::Set& expect) : hb.getMembership().setStatus(RECOVERING); broker::QueueRegistry& queues = hb.getBroker().getQueues(); queues.eachQueue(boost::bind(&Primary::initializeQueue, this, _1)); - assert(instance == 0); - instance = this; // Let queue replicators find us. if (expect.empty()) { QPID_LOG(notice, logPrefix << "Promoted to primary. No expected backups."); } else { - // NOTE: RemoteBackups must be created before we set the ConfigurationObserver + // NOTE: RemoteBackups must be created before we set the BrokerObserver // or ConnectionObserver so that there is no client activity while // the QueueGuards are created. QPID_LOG(notice, logPrefix << "Promoted to primary. Expected backups: " << expect); @@ -113,8 +114,8 @@ Primary::Primary(HaBroker& hb, const BrokerInfo::Set& expect) : timerTask = new ExpectedBackupTimerTask(*this, deadline); hb.getBroker().getTimer().add(timerTask); } - configurationObserver.reset(new PrimaryConfigurationObserver(*this)); - haBroker.getBroker().getConfigurationObservers().add(configurationObserver); + brokerObserver.reset(new PrimaryBrokerObserver(*this)); + haBroker.getBroker().getBrokerObservers().add(brokerObserver); checkReady(); // Outside lock // Allow client connections @@ -124,7 +125,7 @@ Primary::Primary(HaBroker& hb, const BrokerInfo::Set& expect) : Primary::~Primary() { if (timerTask) timerTask->cancel(); - haBroker.getBroker().getConfigurationObservers().remove(configurationObserver); + haBroker.getBroker().getBrokerObservers().remove(brokerObserver); haBroker.getObserver()->reset(); } @@ -212,14 +213,42 @@ void Primary::readyReplica(const ReplicatingSubscription& rs) { if (backup) checkReady(backup); } +void Primary::addReplica(ReplicatingSubscription& rs) { + // Note this is called before the ReplicatingSubscription has been activated + // on the queue. + sys::Mutex::ScopedLock l(lock); + replicas[make_pair(rs.getBrokerInfo().getSystemId(), rs.getQueue())] = &rs; +} + +void Primary::skip( + const types::Uuid& backup, + const boost::shared_ptr<broker::Queue>& queue, + const ReplicationIdSet& ids) +{ + sys::Mutex::ScopedLock l(lock); + ReplicaMap::const_iterator i = replicas.find(make_pair(backup, queue)); + if (i != replicas.end()) i->second->addSkip(ids); +} + +void Primary::removeReplica(const ReplicatingSubscription& rs) { + sys::Mutex::ScopedLock l(lock); + replicas.erase(make_pair(rs.getBrokerInfo().getSystemId(), rs.getQueue())); + + TxMap::const_iterator i = txMap.find(rs.getQueue()->getName()); + if (i != txMap.end()) { + boost::shared_ptr<PrimaryTxObserver> tx = i->second.lock(); + if (tx) tx->cancel(rs); + } +} + // NOTE: Called with queue registry lock held. void Primary::queueCreate(const QueuePtr& q) { // Set replication argument. ReplicateLevel level = replicationTest.useLevel(*q); - QPID_LOG(debug, logPrefix << "Created queue " << q->getName() - << " replication: " << printable(level)); q->addArgument(QPID_REPLICATE, printable(level).str()); if (level) { + QPID_LOG(debug, logPrefix << "Created queue " << q->getName() + << " replication: " << printable(level)); initializeQueue(q); // Give each queue a unique id. Used by backups to avoid confusion of // same-named queues. @@ -235,24 +264,26 @@ void Primary::queueCreate(const QueuePtr& q) { // NOTE: Called with queue registry lock held. void Primary::queueDestroy(const QueuePtr& q) { - QPID_LOG(debug, logPrefix << "Destroyed queue " << q->getName()); - { - Mutex::ScopedLock l(lock); - for (BackupMap::iterator i = backups.begin(); i != backups.end(); ++i) - i->second->queueDestroy(q); + if (replicationTest.useLevel(*q)) { + QPID_LOG(debug, logPrefix << "Destroyed queue " << q->getName()); + { + Mutex::ScopedLock l(lock); + for (BackupMap::iterator i = backups.begin(); i != backups.end(); ++i) + i->second->queueDestroy(q); + } + checkReady(); // Outside lock } - checkReady(); // Outside lock } // NOTE: Called with exchange registry lock held. void Primary::exchangeCreate(const ExchangePtr& ex) { ReplicateLevel level = replicationTest.useLevel(*ex); - QPID_LOG(debug, logPrefix << "Created exchange " << ex->getName() - << " replication: " << printable(level)); FieldTable args = ex->getArgs(); args.setString(QPID_REPLICATE, printable(level).str()); // Set replication arg. if (level) { - // Give each exchange a unique id to avoid confusion of same-named exchanges. + QPID_LOG(debug, logPrefix << "Created exchange " << ex->getName() + << " replication: " << printable(level)); + // Give each exchange a unique id to avoid confusion of same-named exchanges. args.set(QPID_HA_UUID, FieldTable::ValuePtr(new UuidValue(&Uuid(true)[0]))); } ex->setArgs(args); @@ -260,8 +291,10 @@ void Primary::exchangeCreate(const ExchangePtr& ex) { // NOTE: Called with exchange registry lock held. void Primary::exchangeDestroy(const ExchangePtr& ex) { - QPID_LOG(debug, logPrefix << "Destroyed exchange " << ex->getName()); - // Do nothing + if (replicationTest.useLevel(*ex)) { + QPID_LOG(debug, logPrefix << "Destroyed exchange " << ex->getName()); + // Do nothing + } } // New backup connected @@ -280,6 +313,7 @@ void Primary::backupDisconnect(shared_ptr<RemoteBackup> backup, Mutex::ScopedLoc backup->cancel(); expectedBackups.erase(backup); backups.erase(id); + membership.remove(id); } @@ -365,4 +399,19 @@ void Primary::setCatchupQueues(const RemoteBackupPtr& backup, bool createGuards) backup->startCatchup(); } +shared_ptr<PrimaryTxObserver> Primary::makeTxObserver() { + shared_ptr<PrimaryTxObserver> observer(new PrimaryTxObserver(haBroker)); + observer->initialize(); + txMap[observer->getTxQueue()->getName()] = observer; + return observer; +} + +void Primary::startTx(const boost::shared_ptr<broker::TxBuffer>& tx) { + tx->setObserver(makeTxObserver()); +} + +void Primary::startDtx(const boost::shared_ptr<broker::DtxBuffer>& dtx) { + dtx->setObserver(makeTxObserver()); +} + }} // namespace qpid::ha diff --git a/qpid/cpp/src/qpid/ha/Primary.h b/qpid/cpp/src/qpid/ha/Primary.h index 3e1ec48ce6..d1350ab261 100644 --- a/qpid/cpp/src/qpid/ha/Primary.h +++ b/qpid/cpp/src/qpid/ha/Primary.h @@ -23,12 +23,14 @@ */ #include "types.h" +#include "hash.h" #include "BrokerInfo.h" #include "ReplicationTest.h" #include "Role.h" #include "qpid/sys/Mutex.h" #include "qpid/sys/unordered_map.h" #include <boost/shared_ptr.hpp> +#include <boost/weak_ptr.hpp> #include <boost/intrusive_ptr.hpp> #include <string> @@ -38,7 +40,9 @@ namespace broker { class Queue; class Connection; class ConnectionObserver; -class ConfigurationObserver; +class BrokerObserver; +class TxBuffer; +class DtxBuffer; } namespace sys { @@ -51,6 +55,7 @@ class ReplicatingSubscription; class RemoteBackup; class QueueGuard; class Membership; +class PrimaryTxObserver; /** * State associated with a primary broker: @@ -66,8 +71,6 @@ class Primary : public Role typedef boost::shared_ptr<broker::Exchange> ExchangePtr; typedef boost::shared_ptr<RemoteBackup> RemoteBackupPtr; - static Primary* get() { return instance; } - Primary(HaBroker& hb, const BrokerInfo::Set& expectedBackups); ~Primary(); @@ -77,13 +80,21 @@ class Primary : public Role void setBrokerUrl(const Url&) {} void readyReplica(const ReplicatingSubscription&); - void removeReplica(const std::string& q); + void addReplica(ReplicatingSubscription&); + void removeReplica(const ReplicatingSubscription&); + + /** Skip replication of ids to queue on backup. */ + void skip(const types::Uuid& backup, + const boost::shared_ptr<broker::Queue>& queue, + const ReplicationIdSet& ids); - // Called via ConfigurationObserver + // Called via BrokerObserver void queueCreate(const QueuePtr&); void queueDestroy(const QueuePtr&); void exchangeCreate(const ExchangePtr&); void exchangeDestroy(const ExchangePtr&); + void startTx(const boost::shared_ptr<broker::TxBuffer>&); + void startDtx(const boost::shared_ptr<broker::DtxBuffer>&); // Called via ConnectionObserver void opened(broker::Connection& connection); @@ -95,11 +106,18 @@ class Primary : public Role void timeoutExpectedBackups(); private: - typedef qpid::sys::unordered_map< - types::Uuid, RemoteBackupPtr, types::Uuid::Hasher > BackupMap; + typedef sys::unordered_map< + types::Uuid, RemoteBackupPtr, Hasher<types::Uuid> > BackupMap; typedef std::set<RemoteBackupPtr > BackupSet; + typedef std::pair<types::Uuid, boost::shared_ptr<broker::Queue> > UuidQueue; + typedef sys::unordered_map<UuidQueue, ReplicatingSubscription*, + Hasher<UuidQueue> > ReplicaMap; + + // Map of PrimaryTxObservers by tx-queue name + typedef sys::unordered_map<std::string, boost::weak_ptr<PrimaryTxObserver> > TxMap; + RemoteBackupPtr backupConnect(const BrokerInfo&, broker::Connection&, sys::Mutex::ScopedLock&); void backupDisconnect(RemoteBackupPtr, sys::Mutex::ScopedLock&); @@ -107,8 +125,10 @@ class Primary : public Role void checkReady(); void checkReady(RemoteBackupPtr); void setCatchupQueues(const RemoteBackupPtr&, bool createGuards); + void deduplicate(); + boost::shared_ptr<PrimaryTxObserver> makeTxObserver(); - sys::Mutex lock; + mutable sys::Mutex lock; HaBroker& haBroker; Membership& membership; std::string logPrefix; @@ -126,9 +146,10 @@ class Primary : public Role */ BackupMap backups; boost::shared_ptr<broker::ConnectionObserver> connectionObserver; - boost::shared_ptr<broker::ConfigurationObserver> configurationObserver; + boost::shared_ptr<broker::BrokerObserver> brokerObserver; boost::intrusive_ptr<sys::TimerTask> timerTask; - static Primary* instance; + ReplicaMap replicas; + TxMap txMap; }; }} // namespace qpid::ha diff --git a/qpid/cpp/src/qpid/ha/PrimaryTxObserver.cpp b/qpid/cpp/src/qpid/ha/PrimaryTxObserver.cpp new file mode 100644 index 0000000000..41494694de --- /dev/null +++ b/qpid/cpp/src/qpid/ha/PrimaryTxObserver.cpp @@ -0,0 +1,227 @@ +/* + * + * 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 "Event.h" +#include "HaBroker.h" +#include "Primary.h" +#include "PrimaryTxObserver.h" +#include "QueueGuard.h" +#include "RemoteBackup.h" +#include "ReplicatingSubscription.h" +#include "QueueReplicator.h" + +#include "qpid/broker/Broker.h" +#include "qpid/broker/Queue.h" +#include <boost/lexical_cast.hpp> +#include <algorithm> + +namespace qpid { +namespace framing { +class FieldTable; +} +namespace ha { + +using namespace std; +using namespace qpid::broker; +using namespace qpid::framing; + +// Exchange to receive prepare OK events. +class PrimaryTxObserver::Exchange : public broker::Exchange { + public: + Exchange(const boost::shared_ptr<PrimaryTxObserver>& tx_) : + broker::Exchange(tx_->getExchangeName()), + tx(tx_) + { + dispatch[TxPrepareOkEvent::KEY] = + boost::bind(&PrimaryTxObserver::txPrepareOkEvent, tx, _1); + dispatch[TxPrepareFailEvent::KEY] = + boost::bind(&PrimaryTxObserver::txPrepareFailEvent, tx, _1); + } + + void route(Deliverable& deliverable) { + const broker::Message& message(deliverable.getMessage()); + DispatchMap::iterator i = dispatch.find(message.getRoutingKey()); + if (i != dispatch.end()) i->second(message.getContent()); + } + + bool bind(boost::shared_ptr<Queue>, const string&, const FieldTable*) { return false; } + bool unbind(boost::shared_ptr<Queue>, const string&, const FieldTable*) { return false; } + bool isBound(boost::shared_ptr<Queue>, const string* const, const FieldTable* const) { return false; } + string getType() const { return TYPE_NAME; } + + private: + static const string TYPE_NAME; + typedef boost::function<void(const std::string&)> DispatchFn; + typedef qpid::sys::unordered_map<std::string, DispatchFn> DispatchMap; + + DispatchMap dispatch; + boost::shared_ptr<PrimaryTxObserver> tx; +}; + +const string PrimaryTxObserver::Exchange::TYPE_NAME(string(QPID_HA_PREFIX)+"primary-tx-observer"); + +PrimaryTxObserver::PrimaryTxObserver(HaBroker& hb) : + haBroker(hb), broker(hb.getBroker()), + replicationTest(hb.getSettings().replicateDefault.get()), + id(true), + exchangeName(TRANSACTION_REPLICATOR_PREFIX+id.str()), + failed(false), ended(false), complete(false) +{ + logPrefix = "Primary transaction "+shortStr(id)+": "; + + // The brokers known at this point are the ones that will be included + // in the transaction. Brokers that join later are not included. + // + BrokerInfo::Set backups(haBroker.getMembership().otherBackups()); + std::transform(backups.begin(), backups.end(), inserter(members, members.begin()), + boost::bind(&BrokerInfo::getSystemId, _1)); + + QPID_LOG(debug, logPrefix << "Started TX " << id); + QPID_LOG(debug, logPrefix << "Members: " << members); + unprepared = unfinished = members; + + pair<QueuePtr, bool> result = + broker.getQueues().declare( + exchangeName, QueueSettings(/*durable*/false, /*autodelete*/true)); + assert(result.second); + txQueue = result.first; + txQueue->deliver(TxMembersEvent(members).message()); +} + +PrimaryTxObserver::~PrimaryTxObserver() {} + + +void PrimaryTxObserver::initialize() { + boost::shared_ptr<Exchange> ex(new Exchange(shared_from_this())); + FieldTable args = ex->getArgs(); + args.setString(QPID_REPLICATE, printable(NONE).str()); // Set replication arg. + broker.getExchanges().registerExchange(ex); +} + +void PrimaryTxObserver::enqueue(const QueuePtr& q, const broker::Message& m) +{ + sys::Mutex::ScopedLock l(lock); + if (replicationTest.useLevel(*q) == ALL) { // Ignore unreplicated queues. + QPID_LOG(trace, logPrefix << "Enqueue: " << LogMessageId(*q, m)); + enqueues[q] += m.getReplicationId(); + txQueue->deliver(TxEnqueueEvent(q->getName(), m.getReplicationId()).message()); + txQueue->deliver(m); + } +} + +void PrimaryTxObserver::dequeue( + const QueuePtr& q, QueuePosition pos, ReplicationId id) +{ + sys::Mutex::ScopedLock l(lock); + if (replicationTest.useLevel(*q) == ALL) { // Ignore unreplicated queues. + QPID_LOG(trace, logPrefix << "Dequeue: " << LogMessageId(*q, pos, id)); + txQueue->deliver(TxDequeueEvent(q->getName(), id).message()); + } + else { + QPID_LOG(warning, logPrefix << "Dequeue skipped, queue not replicated: " + << LogMessageId(*q, pos, id)); + } +} + +void PrimaryTxObserver::deduplicate(sys::Mutex::ScopedLock&) { + boost::shared_ptr<Primary> primary(boost::dynamic_pointer_cast<Primary>(haBroker.getRole())); + assert(primary); + // Tell replicating subscriptions to skip IDs in the transaction. + for (UuidSet::iterator b = members.begin(); b != members.end(); ++b) + for (QueueIdsMap::iterator q = enqueues.begin(); q != enqueues.end(); ++q) + primary->skip(*b, q->first, q->second); +} + +bool PrimaryTxObserver::prepare() { + sys::Mutex::ScopedLock l(lock); + QPID_LOG(debug, logPrefix << "Prepare"); + deduplicate(l); + txQueue->deliver(TxPrepareEvent().message()); + // TODO aconway 2013-09-04: Blocks the current thread till backups respond. + // Need a non-blocking approach (e.g. async completion or borrowing a thread) + while (!unprepared.empty() && !failed) lock.wait(); + return !failed; +} + +void PrimaryTxObserver::commit() { + sys::Mutex::ScopedLock l(lock); + QPID_LOG(debug, logPrefix << "Commit"); + txQueue->deliver(TxCommitEvent().message()); + complete = true; + end(l); +} + +void PrimaryTxObserver::rollback() { + sys::Mutex::ScopedLock l(lock); + QPID_LOG(debug, logPrefix << "Rollback"); + txQueue->deliver(TxRollbackEvent().message()); + complete = true; + end(l); +} + +void PrimaryTxObserver::end(sys::Mutex::ScopedLock&) { + // Don't destroy the tx-queue until the transaction is complete and there + // are no connected subscriptions. + if (!ended && complete && unfinished.empty()) { + ended = true; + try { + haBroker.getBroker().deleteQueue(txQueue->getName(), haBroker.getUserId(), string()); + } catch (const std::exception& e) { + QPID_LOG(error, logPrefix << "Deleting transaction queue: " << e.what()); + } + try { + broker.getExchanges().destroy(getExchangeName()); + } catch (const std::exception& e) { + QPID_LOG(error, logPrefix << "Deleting transaction exchange: " << e.what()); + } + } +} + +void PrimaryTxObserver::txPrepareOkEvent(const string& data) { + sys::Mutex::ScopedLock l(lock); + types::Uuid backup = decodeStr<TxPrepareOkEvent>(data).broker; + QPID_LOG(debug, logPrefix << "Backup prepared ok: " << backup); + unprepared.erase(backup); + lock.notify(); +} + +void PrimaryTxObserver::txPrepareFailEvent(const string& data) { + sys::Mutex::ScopedLock l(lock); + types::Uuid backup = decodeStr<TxPrepareFailEvent>(data).broker; + QPID_LOG(error, logPrefix << "Backup prepare failed: " << backup); + unprepared.erase(backup); + failed = true; + lock.notify(); +} + +void PrimaryTxObserver::cancel(const ReplicatingSubscription& rs) { + sys::Mutex::ScopedLock l(lock); + types::Uuid backup = rs.getBrokerInfo().getSystemId(); + if (unprepared.find(backup) != unprepared.end()) { + complete = failed = true; // Canceled before prepared. + unprepared.erase(backup); // Consider it prepared-fail + } + unfinished.erase(backup); + lock.notify(); + end(l); +} + +}} // namespace qpid::ha diff --git a/qpid/cpp/src/qpid/ha/PrimaryTxObserver.h b/qpid/cpp/src/qpid/ha/PrimaryTxObserver.h new file mode 100644 index 0000000000..fb9db25e85 --- /dev/null +++ b/qpid/cpp/src/qpid/ha/PrimaryTxObserver.h @@ -0,0 +1,115 @@ +#ifndef QPID_HA_PRIMARYTXOBSERVER_H +#define QPID_HA_PRIMARYTXOBSERVER_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 "types.h" +#include "ReplicationTest.h" +#include "qpid/broker/TransactionObserver.h" +#include "qpid/log/Statement.h" +#include "qpid/types/Uuid.h" +#include "qpid/sys/unordered_map.h" +#include "qpid/sys/Monitor.h" +#include <boost/enable_shared_from_this.hpp> + +namespace qpid { + +namespace broker { +class Broker; +class Message; +class Consumer; +} + +namespace ha { +class HaBroker; +class ReplicatingSubscription; + +/** + * Observe events in the lifecycle of a transaction. + * + * The observer is called by TxBuffer for each transactional event. + * It puts the events on a special tx-queue. + * A TxReplicator on the backup replicates the tx-queue and creates + * a TxBuffer on the backup equivalent to the one on the primary. + * + * Also observes the tx-queue for prepare-complete messages and + * subscription cancellations. + * + * THREAD SAFE: called in user connection thread for TX events, + * and in backup connection threads for prepare-completed events + * and unsubscriptions. + */ +class PrimaryTxObserver : public broker::TransactionObserver, + public boost::enable_shared_from_this<PrimaryTxObserver> +{ + public: + PrimaryTxObserver(HaBroker&); + ~PrimaryTxObserver(); + + /** Call immediately after constructor, uses shared_from_this. */ + void initialize(); + + void enqueue(const QueuePtr&, const broker::Message&); + void dequeue(const QueuePtr& queue, QueuePosition, ReplicationId); + bool prepare(); + void commit(); + void rollback(); + + types::Uuid getId() const { return id; } + QueuePtr getTxQueue() const { return txQueue; } + std::string getExchangeName() const { return exchangeName; } + + // Notify that a backup subscription has been cancelled. + void cancel(const ReplicatingSubscription&); + + private: + class Exchange; + typedef qpid::sys::unordered_map< + QueuePtr, ReplicationIdSet, Hasher<QueuePtr> > QueueIdsMap; + + void membership(const BrokerInfo::Map&); + void deduplicate(sys::Mutex::ScopedLock&); + void end(sys::Mutex::ScopedLock&); + void txPrepareOkEvent(const std::string& data); + void txPrepareFailEvent(const std::string& data); + + + sys::Monitor lock; + std::string logPrefix; + HaBroker& haBroker; + broker::Broker& broker; + ReplicationTest replicationTest; + + types::Uuid id; + std::string exchangeName; + QueuePtr txQueue; + QueueIdsMap enqueues; + bool failed, ended, complete; + + UuidSet members; // All members of transaction. + UuidSet unprepared; // Members that have not yet responded to prepare. + UuidSet unfinished; // Members that have not yet disconnected. +}; + +}} // namespace qpid::ha + +#endif /*!QPID_HA_PRIMARYTXOBSERVER_H*/ diff --git a/qpid/cpp/src/qpid/ha/QueueGuard.h b/qpid/cpp/src/qpid/ha/QueueGuard.h index e41a92c74f..33967970eb 100644 --- a/qpid/cpp/src/qpid/ha/QueueGuard.h +++ b/qpid/cpp/src/qpid/ha/QueueGuard.h @@ -89,7 +89,7 @@ class QueueGuard { class QueueObserver; typedef qpid::sys::unordered_map<ReplicationId, boost::intrusive_ptr<broker::AsyncCompletion>, - TrivialHasher<ReplicationId> > Delayed; + Hasher<ReplicationId> > Delayed; bool complete(ReplicationId, sys::Mutex::ScopedLock &); void complete(Delayed::iterator, sys::Mutex::ScopedLock &); diff --git a/qpid/cpp/src/qpid/ha/QueueReplicator.cpp b/qpid/cpp/src/qpid/ha/QueueReplicator.cpp index d99602fdda..22af7284a8 100644 --- a/qpid/cpp/src/qpid/ha/QueueReplicator.cpp +++ b/qpid/cpp/src/qpid/ha/QueueReplicator.cpp @@ -19,12 +19,13 @@ * */ -#include "makeMessage.h" +#include "Event.h" #include "HaBroker.h" #include "QueueReplicator.h" #include "QueueSnapshots.h" #include "ReplicatingSubscription.h" #include "Settings.h" +#include "types.h" #include "qpid/broker/Bridge.h" #include "qpid/broker/Broker.h" #include "qpid/broker/Link.h" @@ -38,36 +39,31 @@ #include "qpid/Msg.h" #include "qpid/assert.h" #include <boost/shared_ptr.hpp> +#include <boost/bind.hpp> -namespace { -const std::string QPID_REPLICATOR_("qpid.replicator-"); -const std::string TYPE_NAME("qpid.queue-replicator"); -const std::string QPID_HA("qpid.ha-"); -} namespace qpid { namespace ha { using namespace broker; using namespace framing; using namespace std; +using std::exception; using sys::Mutex; -const std::string QueueReplicator::DEQUEUE_EVENT_KEY(QPID_HA+"dequeue"); -const std::string QueueReplicator::ID_EVENT_KEY(QPID_HA+"id"); const std::string QueueReplicator::QPID_SYNC_FREQUENCY("qpid.sync_frequency"); -std::string QueueReplicator::replicatorName(const std::string& queueName) { - return QPID_REPLICATOR_ + queueName; +namespace { +const string QPID_HA(QPID_HA_PREFIX); +const std::string TYPE_NAME(QPID_HA+"queue-replicator"); } -bool QueueReplicator::isReplicatorName(const std::string& name) { - return name.compare(0, QPID_REPLICATOR_.size(), QPID_REPLICATOR_) == 0; + +std::string QueueReplicator::replicatorName(const std::string& queueName) { + return QUEUE_REPLICATOR_PREFIX + queueName; } -bool QueueReplicator::isEventKey(const std::string key) { - const std::string& prefix = QPID_HA; - bool ret = key.size() > prefix.size() && key.compare(0, prefix.size(), prefix) == 0; - return ret; +bool QueueReplicator::isReplicatorName(const std::string& name) { + return startsWith(name, QUEUE_REPLICATOR_PREFIX); } class QueueReplicator::ErrorListener : public SessionHandler::ErrorListener { @@ -109,12 +105,15 @@ QueueReplicator::QueueReplicator(HaBroker& hb, boost::shared_ptr<Link> l) : Exchange(replicatorName(q->getName()), 0, q->getBroker()), haBroker(hb), + brokerInfo(hb.getBrokerInfo()), + link(l), + queue(q), + sessionHandler(0), logPrefix("Backup of "+q->getName()+": "), - queue(q), link(l), brokerInfo(hb.getBrokerInfo()), subscribed(false), - settings(hb.getSettings()), destroyed(false), + subscribed(false), + settings(hb.getSettings()), nextId(0), maxId(0) { - QPID_LOG(debug, logPrefix << "Created"); args.setString(QPID_REPLICATE, printable(NONE).str()); Uuid uuid(true); bridgeName = replicatorName(q->getName()) + std::string(".") + uuid.str(); @@ -122,12 +121,18 @@ QueueReplicator::QueueReplicator(HaBroker& hb, args.setString(QPID_REPLICATE, printable(NONE).str()); setArgs(args); if (q->isAutoDelete()) q->markInUse(); + + dispatch[DequeueEvent::KEY] = + boost::bind(&QueueReplicator::dequeueEvent, this, _1, _2); + dispatch[IdEvent::KEY] = + boost::bind(&QueueReplicator::idEvent, this, _1, _2); } // This must be called immediately after the constructor. // It has to be separate so we can call shared_from_this(). void QueueReplicator::activate() { Mutex::ScopedLock l(lock); + QPID_LOG(debug, logPrefix << "Created"); if (!queue) return; // Already destroyed // Enable callback to route() @@ -163,6 +168,11 @@ void QueueReplicator::activate() { boost::shared_ptr<QueueObserver>(new QueueObserver(shared_from_this()))); } +void QueueReplicator::disconnect() { + Mutex::ScopedLock l(lock); + sessionHandler = 0; +} + QueueReplicator::~QueueReplicator() {} // Called from Queue::destroyed() @@ -170,25 +180,24 @@ void QueueReplicator::destroy() { boost::shared_ptr<Bridge> bridge2; // To call outside of lock { Mutex::ScopedLock l(lock); - if (destroyed) return; - destroyed = true; + if (!queue) return; // Already destroyed QPID_LOG(debug, logPrefix << "Destroyed"); + bridge2 = bridge; // call close outside the lock. // Need to drop shared pointers to avoid pointer cycles keeping this in memory. queue.reset(); - link.reset(); bridge.reset(); getBroker()->getExchanges().destroy(getName()); - bridge2 = bridge; } if (bridge2) bridge2->close(); // Outside of lock, avoid deadlock. } // Called in a broker connection thread when the bridge is created. // Note: called with the Link lock held. -void QueueReplicator::initializeBridge(Bridge& bridge, SessionHandler& sessionHandler) { +void QueueReplicator::initializeBridge(Bridge& bridge, SessionHandler& sessionHandler_) { Mutex::ScopedLock l(lock); - if (destroyed) return; // Already destroyed - AMQP_ServerProxy peer(sessionHandler.out); + if (!queue) return; // Already destroyed + sessionHandler = &sessionHandler_; + AMQP_ServerProxy peer(sessionHandler->out); const qmf::org::apache::qpid::broker::ArgsLinkBridge& args(bridge.getArgs()); FieldTable arguments; arguments.setInt(ReplicatingSubscription::QPID_REPLICATING_SUBSCRIPTION, 1); @@ -224,44 +233,57 @@ template <class T> T decodeContent(Message& m) { } } -void QueueReplicator::dequeue(const ReplicationIdSet& dequeues, Mutex::ScopedLock&) { - QPID_LOG(trace, logPrefix << "Dequeue " << dequeues); +void QueueReplicator::dequeueEvent(const string& data, Mutex::ScopedLock&) { + DequeueEvent e; + decodeStr(data, e); + QPID_LOG(trace, logPrefix << "Dequeue " << e.ids); //TODO: should be able to optimise the following - for (ReplicationIdSet::iterator i = dequeues.begin(); i != dequeues.end(); ++i) { + for (ReplicationIdSet::iterator i = e.ids.begin(); i != e.ids.end(); ++i) { PositionMap::iterator j = positions.find(*i); if (j != positions.end()) queue->dequeueMessageAt(j->second); } } // Called in connection thread of the queues bridge to primary. -void QueueReplicator::route(Deliverable& msg) +void QueueReplicator::route(Deliverable& deliverable) { try { Mutex::ScopedLock l(lock); - if (destroyed) return; - const std::string& key = msg.getMessage().getRoutingKey(); - if (!isEventKey(key)) { // Replicated message + if (!queue) return; // Already destroyed + broker::Message& message(deliverable.getMessage()); + string key(message.getRoutingKey()); + if (!isEventKey(message.getRoutingKey())) { ReplicationId id = nextId++; maxId = std::max(maxId, id); - msg.getMessage().setReplicationId(id); - msg.deliverTo(queue); + message.setReplicationId(id); + deliver(message); QueuePosition position = queue->getPosition(); positions[id] = position; QPID_LOG(trace, logPrefix << "Enqueued " << LogMessageId(*queue,position,id)); } - else if (key == DEQUEUE_EVENT_KEY) { - dequeue(decodeContent<ReplicationIdSet>(msg.getMessage()), l); - } - else if (key == ID_EVENT_KEY) { - nextId = decodeContent<ReplicationId>(msg.getMessage()); + else { + DispatchMap::iterator i = dispatch.find(key); + if (i == dispatch.end()) { + QPID_LOG(info, logPrefix << "Ignoring unknown event: " << key); + } + else { + (i->second)(message.getContent(), l); + } } - // Ignore unknown event keys, may be introduced in later versions. } catch (const std::exception& e) { haBroker.shutdown(QPID_MSG(logPrefix << "Replication failed: " << e.what())); } } +void QueueReplicator::deliver(const broker::Message& m) { + queue->deliver(m); +} + +void QueueReplicator::idEvent(const string& data, Mutex::ScopedLock&) { + nextId = decodeStr<IdEvent>(data).id; +} + ReplicationId QueueReplicator::getMaxId() { Mutex::ScopedLock l(lock); return maxId; @@ -273,4 +295,5 @@ bool QueueReplicator::unbind(boost::shared_ptr<Queue>, const std::string&, const bool QueueReplicator::isBound(boost::shared_ptr<Queue>, const std::string* const, const FieldTable* const) { return false; } std::string QueueReplicator::getType() const { return TYPE_NAME; } + }} // namespace qpid::broker diff --git a/qpid/cpp/src/qpid/ha/QueueReplicator.h b/qpid/cpp/src/qpid/ha/QueueReplicator.h index 811ddba256..01abc88843 100644 --- a/qpid/cpp/src/qpid/ha/QueueReplicator.h +++ b/qpid/cpp/src/qpid/ha/QueueReplicator.h @@ -26,6 +26,7 @@ #include "hash.h" #include "qpid/broker/Exchange.h" #include <boost/enable_shared_from_this.hpp> +#include <boost/function.hpp> #include <iosfwd> namespace qpid { @@ -56,30 +57,24 @@ class QueueReplicator : public broker::Exchange, public boost::enable_shared_from_this<QueueReplicator> { public: - static const std::string DEQUEUE_EVENT_KEY; - static const std::string ID_EVENT_KEY; static const std::string QPID_SYNC_FREQUENCY; + static const std::string REPLICATOR_PREFIX; static std::string replicatorName(const std::string& queueName); static bool isReplicatorName(const std::string&); - /** Test if a string is an event key */ - static bool isEventKey(const std::string key); - QueueReplicator(HaBroker&, boost::shared_ptr<broker::Queue> q, boost::shared_ptr<broker::Link> l); ~QueueReplicator(); - void activate(); // Must be called immediately after constructor. + void activate(); // Must be called immediately after constructor. + void disconnect(); // Called when we are disconnected from the primary. std::string getType() const; - bool bind(boost::shared_ptr<broker::Queue - >, const std::string&, const framing::FieldTable*); - bool unbind(boost::shared_ptr<broker::Queue>, const std::string&, const framing::FieldTable*); + void route(broker::Deliverable&); - bool isBound(boost::shared_ptr<broker::Queue>, const std::string* const, const framing::FieldTable* const); // Set if the queue has ever been subscribed to, used for auto-delete cleanup. void setSubscribed() { subscribed = true; } @@ -89,27 +84,44 @@ class QueueReplicator : public broker::Exchange, ReplicationId getMaxId(); - private: - typedef qpid::sys::unordered_map<ReplicationId, QueuePosition, TrivialHasher<int32_t> > PositionMap; + // No-op unused Exchange virtual functions. + bool bind(boost::shared_ptr<broker::Queue>, const std::string&, const framing::FieldTable*); + bool unbind(boost::shared_ptr<broker::Queue>, const std::string&, const framing::FieldTable*); + bool isBound(boost::shared_ptr<broker::Queue>, const std::string* const, const framing::FieldTable* const); + + protected: + typedef boost::function<void(const std::string&, sys::Mutex::ScopedLock&)> DispatchFn; + typedef qpid::sys::unordered_map<std::string, DispatchFn> DispatchMap; + + virtual void deliver(const broker::Message&); + virtual void destroy(); // Called when the queue is destroyed. + sys::Mutex lock; + HaBroker& haBroker; + const BrokerInfo brokerInfo; + DispatchMap dispatch; + boost::shared_ptr<broker::Link> link; + boost::shared_ptr<broker::Bridge> bridge; + boost::shared_ptr<broker::Queue> queue; + broker::SessionHandler* sessionHandler; + + private: + typedef qpid::sys::unordered_map< + ReplicationId, QueuePosition, Hasher<ReplicationId> > PositionMap; class ErrorListener; class QueueObserver; void initializeBridge(broker::Bridge& bridge, broker::SessionHandler& sessionHandler); - void destroy(); // Called when the queue is destroyed. - void dequeue(const ReplicationIdSet&, sys::Mutex::ScopedLock&); - HaBroker& haBroker; + // Dispatch functions + void dequeueEvent(const std::string& data, sys::Mutex::ScopedLock&); + void idEvent(const std::string& data, sys::Mutex::ScopedLock&); + std::string logPrefix; std::string bridgeName; - sys::Mutex lock; - boost::shared_ptr<broker::Queue> queue; - boost::shared_ptr<broker::Link> link; - boost::shared_ptr<broker::Bridge> bridge; - BrokerInfo brokerInfo; + bool subscribed; const Settings& settings; - bool destroyed; PositionMap positions; ReplicationIdSet idSet; // Set of replicationIds on the queue. ReplicationId nextId; // ID for next message to arrive. diff --git a/qpid/cpp/src/qpid/ha/QueueSnapshots.h b/qpid/cpp/src/qpid/ha/QueueSnapshots.h index 258c406954..d067b983d1 100644 --- a/qpid/cpp/src/qpid/ha/QueueSnapshots.h +++ b/qpid/cpp/src/qpid/ha/QueueSnapshots.h @@ -27,7 +27,7 @@ #include "hash.h" #include "qpid/assert.h" -#include "qpid/broker/ConfigurationObserver.h" +#include "qpid/broker/BrokerObserver.h" #include "qpid/broker/Queue.h" #include "qpid/sys/Mutex.h" @@ -37,10 +37,10 @@ namespace qpid { namespace ha { /** - * ConfigurationObserver that maintains a map of the QueueSnapshot for each queue. + * BrokerObserver that maintains a map of the QueueSnapshot for each queue. * THREAD SAFE. */ -class QueueSnapshots : public broker::ConfigurationObserver +class QueueSnapshots : public broker::BrokerObserver { public: boost::shared_ptr<QueueSnapshot> get(const boost::shared_ptr<broker::Queue>& q) const { @@ -49,7 +49,7 @@ class QueueSnapshots : public broker::ConfigurationObserver return i != snapshots.end() ? i->second : boost::shared_ptr<QueueSnapshot>(); } - // ConfigurationObserver overrides. + // BrokerObserver overrides. void queueCreate(const boost::shared_ptr<broker::Queue>& q) { sys::Mutex::ScopedLock l(lock); boost::shared_ptr<QueueSnapshot> observer(new QueueSnapshot); @@ -69,7 +69,7 @@ class QueueSnapshots : public broker::ConfigurationObserver private: typedef qpid::sys::unordered_map<boost::shared_ptr<broker::Queue>, boost::shared_ptr<QueueSnapshot>, - SharedPtrHasher<broker::Queue> + Hasher<boost::shared_ptr<broker::Queue> > > SnapshotMap; SnapshotMap snapshots; mutable sys::Mutex lock; diff --git a/qpid/cpp/src/qpid/ha/RemoteBackup.cpp b/qpid/cpp/src/qpid/ha/RemoteBackup.cpp index c37d44fa08..0993c6ea39 100644 --- a/qpid/cpp/src/qpid/ha/RemoteBackup.cpp +++ b/qpid/cpp/src/qpid/ha/RemoteBackup.cpp @@ -20,6 +20,7 @@ */ #include "RemoteBackup.h" #include "QueueGuard.h" +#include "TxReplicator.h" #include "qpid/broker/Broker.h" #include "qpid/broker/Connection.h" #include "qpid/broker/Queue.h" @@ -108,13 +109,13 @@ void RemoteBackup::ready(const QueuePtr& q) { QPID_LOG(debug, logPrefix << "Caught up on queue: " << q->getName() ); } -// Called via ConfigurationObserver::queueCreate and from catchupQueue +// Called via BrokerObserver::queueCreate and from catchupQueue void RemoteBackup::queueCreate(const QueuePtr& q) { if (replicationTest.getLevel(*q) == ALL) guards[q].reset(new QueueGuard(*q, brokerInfo)); } -// Called via ConfigurationObserver +// Called via BrokerObserver void RemoteBackup::queueDestroy(const QueuePtr& q) { catchupQueues.erase(q); GuardMap::iterator i = guards.find(q); diff --git a/qpid/cpp/src/qpid/ha/RemoteBackup.h b/qpid/cpp/src/qpid/ha/RemoteBackup.h index e2c5032820..b9e2e1a496 100644 --- a/qpid/cpp/src/qpid/ha/RemoteBackup.h +++ b/qpid/cpp/src/qpid/ha/RemoteBackup.h @@ -71,10 +71,10 @@ class RemoteBackup */ void ready(const QueuePtr& queue); - /** Called via ConfigurationObserver */ + /** Called via BrokerObserver */ void queueCreate(const QueuePtr&); - /** Called via ConfigurationObserver. Note: may set isReady() */ + /** Called via BrokerObserver. Note: may set isReady() */ void queueDestroy(const QueuePtr&); /**@return true when all catch-up queues for this backup are ready. */ @@ -96,8 +96,10 @@ class RemoteBackup void startCatchup() { started = true; } private: - typedef qpid::sys::unordered_map<QueuePtr, GuardPtr, - SharedPtrHasher<broker::Queue> > GuardMap; + typedef qpid::sys::unordered_map< + QueuePtr, GuardPtr, Hasher<boost::shared_ptr<broker::Queue> > + > GuardMap; + typedef std::set<QueuePtr> QueueSet; std::string logPrefix; diff --git a/qpid/cpp/src/qpid/ha/ReplicatingSubscription.cpp b/qpid/cpp/src/qpid/ha/ReplicatingSubscription.cpp index 1ede47ed60..cdfe9dd888 100644 --- a/qpid/cpp/src/qpid/ha/ReplicatingSubscription.cpp +++ b/qpid/cpp/src/qpid/ha/ReplicatingSubscription.cpp @@ -19,7 +19,7 @@ * */ -#include "makeMessage.h" +#include "Event.h" #include "IdSetter.h" #include "QueueGuard.h" #include "QueueReplicator.h" @@ -111,7 +111,8 @@ ReplicatingSubscription::ReplicatingSubscription( ) : ConsumerImpl(parent, name, queue, ack, REPLICATOR, exclusive, tag, resumeId, resumeTtl, arguments), position(0), ready(false), cancelled(false), - haBroker(hb) + haBroker(hb), + primary(boost::dynamic_pointer_cast<Primary>(haBroker.getRole())) { try { FieldTable ft; @@ -137,7 +138,7 @@ ReplicatingSubscription::ReplicatingSubscription( } // If there's already a guard (we are in failover) use it, else create one. - if (Primary::get()) guard = Primary::get()->getGuard(queue, info); + if (primary) guard = primary->getGuard(queue, info); if (!guard) guard.reset(new QueueGuard(*queue, info)); // NOTE: Once the observer is attached we can have concurrent @@ -148,20 +149,19 @@ ReplicatingSubscription::ReplicatingSubscription( // between the snapshot and attaching the observer. observer.reset(new QueueObserver(*this)); queue->addObserver(observer); - ReplicationIdSet primary = haBroker.getQueueSnapshots()->get(queue)->snapshot(); + ReplicationIdSet primaryIds = haBroker.getQueueSnapshots()->get(queue)->snapshot(); std::string backupStr = arguments.getAsString(ReplicatingSubscription::QPID_ID_SET); - ReplicationIdSet backup; - if (!backupStr.empty()) backup = decodeStr<ReplicationIdSet>(backupStr); + ReplicationIdSet backupIds; + if (!backupStr.empty()) backupIds = decodeStr<ReplicationIdSet>(backupStr); // Initial dequeues are messages on backup but not on primary. - ReplicationIdSet initDequeues = backup - primary; + ReplicationIdSet initDequeues = backupIds - primaryIds; QueuePosition front,back; queue->getRange(front, back, broker::REPLICATOR); // Outside lock, getRange locks queue { sys::Mutex::ScopedLock l(lock); // Concurrent calls to dequeued() dequeues += initDequeues; // Messages on backup that are not on primary. - skip = backup - initDequeues; // Messages already on the backup. - + skip = backupIds - initDequeues; // Messages already on the backup. // Queue front is moving but we know this subscriptions will start at a // position >= front so if front is safe then position must be. position = front; @@ -189,6 +189,7 @@ ReplicatingSubscription::~ReplicatingSubscription() {} // void ReplicatingSubscription::initialize() { try { + if (primary) primary->addReplica(*this); Mutex::ScopedLock l(lock); // Note dequeued() can be called concurrently. // Send initial dequeues to the backup. // There must be a shared_ptr(this) when sending. @@ -216,9 +217,8 @@ bool ReplicatingSubscription::deliver( try { bool result = false; if (skip.contains(id)) { + QPID_LOG(trace, logPrefix << "Skip " << LogMessageId(*getQueue(), m)); skip -= id; - QPID_LOG(trace, logPrefix << "On backup, skip " << - LogMessageId(*getQueue(), m)); guard->complete(id); // This will never be acknowledged. notify(); result = true; @@ -238,16 +238,13 @@ bool ReplicatingSubscription::deliver( } } -/** - *@param position: must be <= last position seen by subscription. - */ void ReplicatingSubscription::checkReady(sys::Mutex::ScopedLock& l) { if (!ready && isGuarded(l) && unready.empty()) { ready = true; sys::Mutex::ScopedUnlock u(lock); // Notify Primary that a subscription is ready. QPID_LOG(debug, logPrefix << "Caught up"); - if (Primary::get()) Primary::get()->readyReplica(*this); + if (primary) primary->readyReplica(*this); } } @@ -260,6 +257,7 @@ void ReplicatingSubscription::cancel() cancelled = true; } QPID_LOG(debug, logPrefix << "Cancelled"); + if (primary) primary->removeReplica(*this); getQueue()->removeObserver(observer); guard->cancel(); ConsumerImpl::cancel(); @@ -285,9 +283,7 @@ void ReplicatingSubscription::sendDequeueEvent(Mutex::ScopedLock& l) { if (dequeues.empty()) return; QPID_LOG(trace, logPrefix << "Sending dequeues " << dequeues); - string buffer = encodeStr(dequeues); - dequeues.clear(); - sendEvent(QueueReplicator::DEQUEUE_EVENT_KEY, buffer, l); + sendEvent(DequeueEvent(dequeues), l); } // Called after the message has been removed @@ -307,23 +303,16 @@ void ReplicatingSubscription::dequeued(ReplicationId id) // Called with lock held. Called in subscription's connection thread. void ReplicatingSubscription::sendIdEvent(ReplicationId pos, Mutex::ScopedLock& l) { - sendEvent(QueueReplicator::ID_EVENT_KEY, encodeStr(pos), l); + sendEvent(IdEvent(pos), l); } -void ReplicatingSubscription::sendEvent(const std::string& key, - const std::string& buffer, - Mutex::ScopedLock&) +void ReplicatingSubscription::sendEvent(const Event& event, Mutex::ScopedLock&) { Mutex::ScopedUnlock u(lock); - broker::Message message = makeMessage(buffer); - MessageTransfer& transfer = MessageTransfer::get(message); - DeliveryProperties* props = - transfer.getFrames().getHeaders()->get<DeliveryProperties>(true); - props->setRoutingKey(key); // Send the event directly to the base consumer implementation. The dummy // consumer prevents acknowledgements being handled, which is what we want // for events - ConsumerImpl::deliver(QueueCursor(), message, boost::shared_ptr<Consumer>()); + ConsumerImpl::deliver(QueueCursor(), event.message(), boost::shared_ptr<Consumer>()); } // Called in subscription's connection thread. @@ -342,4 +331,9 @@ bool ReplicatingSubscription::doDispatch() } } +void ReplicatingSubscription::addSkip(const ReplicationIdSet& ids) { + Mutex::ScopedLock l(lock); + skip += ids; +} + }} // namespace qpid::ha diff --git a/qpid/cpp/src/qpid/ha/ReplicatingSubscription.h b/qpid/cpp/src/qpid/ha/ReplicatingSubscription.h index c202089e91..71993bcb12 100644 --- a/qpid/cpp/src/qpid/ha/ReplicatingSubscription.h +++ b/qpid/cpp/src/qpid/ha/ReplicatingSubscription.h @@ -25,7 +25,6 @@ #include "BrokerInfo.h" #include "qpid/broker/SemanticState.h" #include "qpid/broker/ConsumerFactory.h" -#include "qpid/types/Uuid.h" #include <iosfwd> namespace qpid { @@ -44,6 +43,8 @@ class Buffer; namespace ha { class QueueGuard; class HaBroker; +class Event; +class Primary; /** * A susbcription that replicates to a remote backup. @@ -118,6 +119,9 @@ class ReplicatingSubscription : public broker::SemanticState::ConsumerImpl BrokerInfo getBrokerInfo() const { return info; } + /** Skip replicating enqueue of of ids. */ + void addSkip(const ReplicationIdSet& ids); + protected: bool doDispatch(); @@ -128,7 +132,7 @@ class ReplicatingSubscription : public broker::SemanticState::ConsumerImpl std::string logPrefix; QueuePosition position; ReplicationIdSet dequeues; // Dequeues to be sent in next dequeue event. - ReplicationIdSet skip; // Messages already on backup will be skipped. + ReplicationIdSet skip; // Skip enqueues: messages already on backup and tx enqueues. ReplicationIdSet unready; // Unguarded, replicated and un-acknowledged. bool ready; bool cancelled; @@ -136,12 +140,13 @@ class ReplicatingSubscription : public broker::SemanticState::ConsumerImpl boost::shared_ptr<QueueGuard> guard; HaBroker& haBroker; boost::shared_ptr<QueueObserver> observer; + boost::shared_ptr<Primary> primary; bool isGuarded(sys::Mutex::ScopedLock&); void dequeued(ReplicationId); void sendDequeueEvent(sys::Mutex::ScopedLock&); void sendIdEvent(ReplicationId, sys::Mutex::ScopedLock&); - void sendEvent(const std::string& key, const std::string& data, sys::Mutex::ScopedLock&); + void sendEvent(const Event&, sys::Mutex::ScopedLock&); void checkReady(sys::Mutex::ScopedLock&); friend class Factory; }; diff --git a/qpid/cpp/src/qpid/ha/ReplicationTest.h b/qpid/cpp/src/qpid/ha/ReplicationTest.h index 7d44d82a21..c157385ce6 100644 --- a/qpid/cpp/src/qpid/ha/ReplicationTest.h +++ b/qpid/cpp/src/qpid/ha/ReplicationTest.h @@ -41,6 +41,13 @@ namespace ha { /** * Test whether something is replicated, taking into account the * default replication level. + * + * The primary uses a ReplicationTest with default based on configuration + * settings, and marks objects to be replicated with an explict replication + * argument. + * + * The backup uses a default of NONE, so it always accepts what the primary has + * marked on the object. */ class ReplicationTest { diff --git a/qpid/cpp/src/qpid/ha/StatusCheck.cpp b/qpid/cpp/src/qpid/ha/StatusCheck.cpp index d73f2cf8b5..fdc256d5a2 100644 --- a/qpid/cpp/src/qpid/ha/StatusCheck.cpp +++ b/qpid/cpp/src/qpid/ha/StatusCheck.cpp @@ -20,6 +20,8 @@ */ #include "StatusCheck.h" #include "ConnectionObserver.h" +#include "HaBroker.h" +#include "qpid/broker/Broker.h" #include "qpid/log/Statement.h" #include "qpid/messaging/Address.h" #include "qpid/messaging/Connection.h" @@ -41,27 +43,32 @@ const string HA_BROKER = "org.apache.qpid.ha:habroker:ha-broker"; class StatusCheckThread : public sys::Runnable { public: - StatusCheckThread(StatusCheck& sc, const qpid::Address& addr, const BrokerInfo& self) - : url(addr), statusCheck(sc), brokerInfo(self) {} + StatusCheckThread(StatusCheck& sc, const qpid::Address& addr) + : url(addr), statusCheck(sc) {} void run(); private: Url url; StatusCheck& statusCheck; - BrokerInfo brokerInfo; }; void StatusCheckThread::run() { - QPID_LOG(debug, statusCheck.logPrefix << "Checking status of " << url); + string logPrefix("Status check " + url.str() + ": "); Connection c; try { + // Check for self connections Variant::Map options, clientProperties; - clientProperties = brokerInfo.asMap(); // Detect self connections. clientProperties[ConnectionObserver::ADMIN_TAG] = 1; // Allow connection to backups. clientProperties[ConnectionObserver::ADDRESS_TAG] = url.str(); - clientProperties[ConnectionObserver::BACKUP_TAG] = brokerInfo.asMap(); + clientProperties[ConnectionObserver::BACKUP_TAG] = statusCheck.haBroker.getBrokerInfo().asMap(); + // Set connection options + Settings settings(statusCheck.haBroker.getSettings()); + if (settings.username.size()) options["username"] = settings.username; + if (settings.password.size()) options["password"] = settings.password; + if (settings.mechanism.size()) options["sasl_mechanisms"] = settings.mechanism; options["client-properties"] = clientProperties; - options["heartbeat"] = statusCheck.linkHeartbeatInterval/sys::TIME_SEC; + sys::Duration heartbeat(statusCheck.haBroker.getBroker().getOptions().linkHeartbeatInterval); + options["heartbeat"] = heartbeat/sys::TIME_SEC; c = Connection(url.str(), options); c.open(); @@ -81,7 +88,7 @@ void StatusCheckThread::run() { content["_object_id"] = oid; encode(content, request); s.send(request); - messaging::Duration timeout(statusCheck.linkHeartbeatInterval/sys::TIME_MSEC); + messaging::Duration timeout(heartbeat/sys::TIME_MSEC); Message response = r.fetch(timeout); session.acknowledge(); Variant::List contentIn; @@ -89,29 +96,24 @@ void StatusCheckThread::run() { if (contentIn.size() == 1) { Variant::Map details = contentIn.front().asMap()["_values"].asMap(); string status = details["status"].getString(); + QPID_LOG(debug, logPrefix << status); if (status != "joining") { statusCheck.setPromote(false); - QPID_LOG(info, statusCheck.logPrefix << "Status of " << url << " is " - << status << ", this broker will refuse promotion."); + QPID_LOG(info, logPrefix << "Joining established cluster"); } - QPID_LOG(debug, statusCheck.logPrefix << "Status of " << url << ": " << status); } + else + QPID_LOG(error, logPrefix << "Invalid response " << response.getContent()) } catch(const exception& error) { - QPID_LOG(info, statusCheck.logPrefix << "Checking status of " << url << ": " << error.what()); - } - try { c.close(); } - catch(const exception&) { - QPID_LOG(warning, statusCheck.logPrefix << "Error closing status check connection to " << url); - } - try { c.close(); } - catch(const exception&) { - QPID_LOG(warning, "Error closing status check connection to " << url); + // Its not an error to fail to connect to self. + if (statusCheck.haBroker.getBrokerInfo().getAddress() != url[0]) + QPID_LOG(warning, logPrefix << error.what()); } + try { c.close(); } catch(...) {} delete this; } -StatusCheck::StatusCheck(const string& lp, sys::Duration lh, const BrokerInfo& self) - : logPrefix(lp), promote(true), linkHeartbeatInterval(lh), brokerInfo(self) +StatusCheck::StatusCheck(HaBroker& hb) : promote(true), haBroker(hb) {} StatusCheck::~StatusCheck() { @@ -122,7 +124,7 @@ StatusCheck::~StatusCheck() { void StatusCheck::setUrl(const Url& url) { Mutex::ScopedLock l(lock); for (size_t i = 0; i < url.size(); ++i) - threads.push_back(Thread(new StatusCheckThread(*this, url[i], brokerInfo))); + threads.push_back(Thread(new StatusCheckThread(*this, url[i]))); } bool StatusCheck::canPromote() { diff --git a/qpid/cpp/src/qpid/ha/StatusCheck.h b/qpid/cpp/src/qpid/ha/StatusCheck.h index 65ad3cefcf..8896969f55 100644 --- a/qpid/cpp/src/qpid/ha/StatusCheck.h +++ b/qpid/cpp/src/qpid/ha/StatusCheck.h @@ -23,6 +23,7 @@ */ #include "BrokerInfo.h" +#include "Settings.h" #include "qpid/Url.h" #include "qpid/sys/Thread.h" #include "qpid/sys/Mutex.h" @@ -33,6 +34,8 @@ namespace qpid { namespace ha { +class HaBroker; + // TODO aconway 2012-12-21: This solution is incomplete. It will only protect // against bad promotion if there are READY brokers when this broker starts. // It will not help the situation where brokers became READY after this one starts. @@ -51,7 +54,7 @@ namespace ha { class StatusCheck { public: - StatusCheck(const std::string& logPrefix, sys::Duration linkHeartbeatInterval, const BrokerInfo& self); + StatusCheck(HaBroker&); ~StatusCheck(); void setUrl(const Url&); bool canPromote(); @@ -59,12 +62,11 @@ class StatusCheck private: void setPromote(bool p); - std::string logPrefix; sys::Mutex lock; std::vector<sys::Thread> threads; bool promote; - sys::Duration linkHeartbeatInterval; - BrokerInfo brokerInfo; + HaBroker& haBroker; + friend class StatusCheckThread; }; }} // namespace qpid::ha diff --git a/qpid/cpp/src/qpid/ha/TxReplicator.cpp b/qpid/cpp/src/qpid/ha/TxReplicator.cpp new file mode 100644 index 0000000000..63301a92f5 --- /dev/null +++ b/qpid/cpp/src/qpid/ha/TxReplicator.cpp @@ -0,0 +1,247 @@ +/* + * + * 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 "TxReplicator.h" +#include "Role.h" +#include "Backup.h" +#include "BrokerReplicator.h" +#include "Event.h" +#include "HaBroker.h" +#include "types.h" +#include "qpid/broker/Broker.h" +#include "qpid/broker/Link.h" +#include "qpid/broker/QueueRegistry.h" +#include "qpid/broker/Queue.h" +#include "qpid/broker/SessionHandler.h" +#include "qpid/broker/TxBuffer.h" +#include "qpid/broker/TxAccept.h" +#include "qpid/broker/amqp_0_10/Connection.h" +#include "qpid/broker/DeliverableMessage.h" +#include "qpid/framing/BufferTypes.h" +#include "qpid/log/Statement.h" +#include <boost/shared_ptr.hpp> +#include <boost/bind.hpp> +#include "qpid/broker/amqp_0_10/MessageTransfer.h" +#include "qpid/framing/MessageTransferBody.h" + +namespace qpid { +namespace ha { + +using namespace std; +using namespace qpid::broker; +using namespace qpid::framing; +using qpid::broker::amqp_0_10::MessageTransfer; +using qpid::types::Uuid; + +namespace { +const string QPID_HA(QPID_HA_PREFIX); +const string TYPE_NAME(QPID_HA+"tx-replicator"); +const string PREFIX(TRANSACTION_REPLICATOR_PREFIX); + +} // namespace + + + +bool TxReplicator::isTxQueue(const string& q) { + return startsWith(q, PREFIX); +} + +string TxReplicator::getTxId(const string& q) { + assert(isTxQueue(q)); + return q.substr(PREFIX.size()); +} + +string TxReplicator::getType() const { return TYPE_NAME; } + +TxReplicator::TxReplicator( + HaBroker& hb, + const boost::shared_ptr<broker::Queue>& txQueue, + const boost::shared_ptr<broker::Link>& link) : + QueueReplicator(hb, txQueue, link), + txBuffer(new broker::TxBuffer), + store(hb.getBroker().hasStore() ? &hb.getBroker().getStore() : 0), + channel(link->nextChannel()), + complete(false), ignore(false), + dequeueState(hb.getBroker().getQueues()) +{ + string id(getTxId(txQueue->getName())); + string shortId = id.substr(0, 8); + logPrefix = "Backup of transaction "+shortId+": "; + QPID_LOG(debug, logPrefix << "Started TX " << id); + if (!store) throw Exception(QPID_MSG(logPrefix << "No message store loaded.")); + + // Dispatch transaction events. + dispatch[TxEnqueueEvent::KEY] = + boost::bind(&TxReplicator::enqueue, this, _1, _2); + dispatch[TxDequeueEvent::KEY] = + boost::bind(&TxReplicator::dequeue, this, _1, _2); + dispatch[TxPrepareEvent::KEY] = + boost::bind(&TxReplicator::prepare, this, _1, _2); + dispatch[TxCommitEvent::KEY] = + boost::bind(&TxReplicator::commit, this, _1, _2); + dispatch[TxRollbackEvent::KEY] = + boost::bind(&TxReplicator::rollback, this, _1, _2); + dispatch[TxMembersEvent::KEY] = + boost::bind(&TxReplicator::members, this, _1, _2); +} + +TxReplicator::~TxReplicator() { + link->returnChannel(channel); +} + +// Send a message to the primary tx. +void TxReplicator::sendMessage(const broker::Message& msg, sys::Mutex::ScopedLock&) { + assert(sessionHandler); + const MessageTransfer& transfer(MessageTransfer::get(msg)); + for (FrameSet::const_iterator i = transfer.getFrames().begin(); + i != transfer.getFrames().end(); + ++i) + { + sessionHandler->out.handle(const_cast<AMQFrame&>(*i)); + } +} + +void TxReplicator::route(broker::Deliverable& deliverable) { + if (!ignore) QueueReplicator::route(deliverable); +} + +void TxReplicator::deliver(const broker::Message& m_) { + sys::Mutex::ScopedLock l(lock); + // Deliver message to the target queue, not the tx-queue. + broker::Message m(m_); + m.setReplicationId(enq.id); // Use replicated id. + boost::shared_ptr<broker::Queue> queue = + haBroker.getBroker().getQueues().get(enq.queue); + QPID_LOG(trace, logPrefix << "Deliver " << LogMessageId(*queue, m)); + DeliverableMessage dm(m, txBuffer.get()); + dm.deliverTo(queue); +} + +void TxReplicator::enqueue(const string& data, sys::Mutex::ScopedLock&) { + sys::Mutex::ScopedLock l(lock); + TxEnqueueEvent e; + decodeStr(data, e); + QPID_LOG(trace, logPrefix << "Enqueue: " << e); + enq = e; +} + +void TxReplicator::dequeue(const string& data, sys::Mutex::ScopedLock&) { + sys::Mutex::ScopedLock l(lock); + TxDequeueEvent e; + decodeStr(data, e); + QPID_LOG(trace, logPrefix << "Dequeue: " << e); + // NOTE: Backup does not see transactional dequeues until the transaction is + // prepared, then they are all receieved before the prepare event. + // We collect the events here so we can do a single scan of the queue in prepare. + dequeueState.add(e); +} + +void TxReplicator::DequeueState::add(const TxDequeueEvent& event) { + events[event.queue] += event.id; +} + +// Use this function as a seek() predicate to find the dequeued messages. +bool TxReplicator::DequeueState::addRecord( + const broker::Message& m, const boost::shared_ptr<Queue>& queue, + const ReplicationIdSet& rids) +{ + if (rids.contains(m.getReplicationId())) { + DeliveryRecord dr(cursor, m.getSequence(), m.getReplicationId(), queue, + string() /*tag*/, + boost::shared_ptr<Consumer>(), + true /*acquired*/, + false /*accepted*/, + false /*credit.isWindowMode()*/, + 0 /*credit*/); + // Generate record ids, unique within this transaction. + dr.setId(nextId++); + records.push_back(dr); + recordIds += dr.getId(); + } + return false; +} + +void TxReplicator::DequeueState::addRecords(const EventMap::value_type& entry) { + // Process all the dequeues for a single queue, in one pass of seek() + boost::shared_ptr<broker::Queue> q = queues.get(entry.first); + q->seek(cursor, boost::bind(&TxReplicator::DequeueState::addRecord, + this, _1, q, entry.second)); +} + +boost::shared_ptr<TxAccept> TxReplicator::DequeueState::makeAccept() { + for_each(events.begin(), events.end(), + boost::bind(&TxReplicator::DequeueState::addRecords, this, _1)); + return boost::shared_ptr<TxAccept>( + new TxAccept(boost::cref(recordIds), boost::ref(records))); +} + +void TxReplicator::prepare(const string&, sys::Mutex::ScopedLock& l) { + txBuffer->enlist(dequeueState.makeAccept()); + context = store->begin(); + if (txBuffer->prepare(context.get())) { + QPID_LOG(debug, logPrefix << "Prepared OK"); + sendMessage(TxPrepareOkEvent(haBroker.getSystemId()).message(queue->getName()), l); + } else { + QPID_LOG(debug, logPrefix << "Prepare failed"); + sendMessage(TxPrepareFailEvent(haBroker.getSystemId()).message(queue->getName()), l); + } +} + +void TxReplicator::commit(const string&, sys::Mutex::ScopedLock& l) { + QPID_LOG(debug, logPrefix << "Commit"); + if (context.get()) store->commit(*context); + txBuffer->commit(); + end(l); +} + +void TxReplicator::rollback(const string&, sys::Mutex::ScopedLock& l) { + QPID_LOG(debug, logPrefix << "Rollback"); + if (context.get()) store->abort(*context); + txBuffer->rollback(); + end(l); +} + +void TxReplicator::members(const string& data, sys::Mutex::ScopedLock&) { + TxMembersEvent e; + decodeStr(data, e); + QPID_LOG(debug, logPrefix << "Members: " << e.members); + if (!e.members.count(haBroker.getMembership().getSelf().getSystemId())) { + QPID_LOG(info, logPrefix << "Not participating in transaction"); + ignore = true; + } +} + +void TxReplicator::end(sys::Mutex::ScopedLock&) { + complete = true; + if (!getQueue()) return; // Already destroyed + // Destroy will cancel the subscription to the primary tx-queue which + // informs the primary that we have completed the transaction. + destroy(); +} + +void TxReplicator::destroy() { + QueueReplicator::destroy(); + sys::Mutex::ScopedLock l(lock); + if (!ignore && !complete) rollback(string(), l); +} + +}} // namespace qpid::ha diff --git a/qpid/cpp/src/qpid/ha/TxReplicator.h b/qpid/cpp/src/qpid/ha/TxReplicator.h new file mode 100644 index 0000000000..214b2a8a5f --- /dev/null +++ b/qpid/cpp/src/qpid/ha/TxReplicator.h @@ -0,0 +1,131 @@ +#ifndef QPID_HA_TRANSACTIONREPLICATOR_H +#define QPID_HA_TRANSACTIONREPLICATOR_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 "QueueReplicator.h" +#include "Event.h" +#include "qpid/broker/DeliveryRecord.h" +#include "qpid/broker/TransactionalStore.h" +#include "qpid/sys/Mutex.h" + +namespace qpid { + +namespace broker { +class TxBuffer; +class TxAccept; +class DtxBuffer; +class Broker; +class MessageStore; +class Deliverable; +} + +namespace ha { +class BrokerReplicator; + +/** + * Exchange created on a backup broker to replicate a transaction on the primary. + * + * Subscribes to a tx-queue like a normal queue but puts replicated messages and + * transaction events into a local TxBuffer. + * + * THREAD SAFE: Called in different connection threads. + */ +class TxReplicator : public QueueReplicator { + public: + typedef boost::shared_ptr<broker::Queue> QueuePtr; + typedef boost::shared_ptr<broker::Link> LinkPtr; + + static bool isTxQueue(const std::string& queue); + static std::string getTxId(const std::string& queue); + + TxReplicator(HaBroker&, const QueuePtr& txQueue, const LinkPtr& link); + ~TxReplicator(); + + std::string getType() const; + + // QueueReplicator overrides + void route(broker::Deliverable& deliverable); + void destroy(); + + protected: + + void deliver(const broker::Message&); + + private: + + typedef void (TxReplicator::*DispatchFunction)( + const std::string&, sys::Mutex::ScopedLock&); + typedef qpid::sys::unordered_map<std::string, DispatchFunction> DispatchMap; + typedef qpid::sys::unordered_map<std::string, ReplicationIdSet> DequeueMap; + + void sendMessage(const broker::Message&, sys::Mutex::ScopedLock&); + void enqueue(const std::string& data, sys::Mutex::ScopedLock&); + void dequeue(const std::string& data, sys::Mutex::ScopedLock&); + void prepare(const std::string& data, sys::Mutex::ScopedLock&); + void commit(const std::string& data, sys::Mutex::ScopedLock&); + void rollback(const std::string& data, sys::Mutex::ScopedLock&); + void members(const std::string& data, sys::Mutex::ScopedLock&); + void end(sys::Mutex::ScopedLock&); + + std::string logPrefix; + TxEnqueueEvent enq; // Enqueue data for next deliver. + boost::shared_ptr<broker::TxBuffer> txBuffer; + broker::MessageStore* store; + std::auto_ptr<broker::TransactionContext> context; + framing::ChannelId channel; // Channel to send prepare-complete. + bool complete, ignore; + + // Class to process dequeues and create DeliveryRecords to populate a + // TxAccept. + class DequeueState { + public: + DequeueState(broker::QueueRegistry& qr) : queues(qr) {} + void add(const TxDequeueEvent&); + boost::shared_ptr<broker::TxAccept> makeAccept(); + + private: + // Delivery record IDs are command IDs from the session. + // On a backup we will just fake these Ids. + typedef framing::SequenceNumber Id; + typedef framing::SequenceSet IdSet; + typedef qpid::sys::unordered_map<std::string, ReplicationIdSet> EventMap; + + bool addRecord(const broker::Message& m, + const boost::shared_ptr<broker::Queue>&, + const ReplicationIdSet& ); + void addRecords(const DequeueMap::value_type& entry); + + broker::QueueRegistry& queues; + EventMap events; + broker::DeliveryRecords records; + broker::QueueCursor cursor; + framing::SequenceNumber nextId; + IdSet recordIds; + }; + DequeueState dequeueState; +}; + + +}} // namespace qpid::ha + +#endif /*!QPID_HA_TRANSACTIONREPLICATOR_H*/ diff --git a/qpid/cpp/src/qpid/ha/hash.h b/qpid/cpp/src/qpid/ha/hash.h index a513673cce..8a7f3c00fe 100644 --- a/qpid/cpp/src/qpid/ha/hash.h +++ b/qpid/cpp/src/qpid/ha/hash.h @@ -22,19 +22,48 @@ * */ +#include "qpid/types/Uuid.h" #include <boost/shared_ptr.hpp> +#include <utility> namespace qpid { namespace ha { -template<class T> struct TrivialHasher { - size_t operator()(T value) const { return static_cast<size_t>(value); } -}; +// TODO aconway 2013-08-06: would like to use boost::hash or std::hash here +// but not available/working on some older compilers. +// Add overloads as needed. + +inline std::size_t hashValue(bool v) { return static_cast<std::size_t>(v); } +inline std::size_t hashValue(char v) { return static_cast<std::size_t>(v); } +inline std::size_t hashValue(unsigned char v) { return static_cast<std::size_t>(v); } +inline std::size_t hashValue(signed char v) { return static_cast<std::size_t>(v); } +inline std::size_t hashValue(short v) { return static_cast<std::size_t>(v); } +inline std::size_t hashValue(unsigned short v) { return static_cast<std::size_t>(v); } +inline std::size_t hashValue(int v) { return static_cast<std::size_t>(v); } +inline std::size_t hashValue(unsigned int v) { return static_cast<std::size_t>(v); } +inline std::size_t hashValue(long v) { return static_cast<std::size_t>(v); } +inline std::size_t hashValue(unsigned long v) { return static_cast<std::size_t>(v); } + +inline std::size_t hashValue(const types::Uuid& v) { return v.hash(); } + +template <class T> inline std::size_t hashValue(T* v) { + std::size_t x = static_cast<std::size_t>(reinterpret_cast<std::ptrdiff_t>(v)); + return x + (x >> 3); +} + +template <class T> inline void hashCombine(std::size_t& seed, const T& v) { + seed ^= hashValue(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); +} + +template <class T, class U> inline size_t hashValue(const std::pair<T,U>& v) { + std::size_t seed = 0; + hashCombine(seed, v.first); + hashCombine(seed, v.second); + return seed; +} -template<class T> struct SharedPtrHasher { - size_t operator()(const boost::shared_ptr<T>& ptr) const { - return reinterpret_cast<size_t>(ptr.get()); - } +template<class T> struct Hasher { + size_t operator()(const T& v) const { return hashValue(v); } }; }} // namespace qpid::ha diff --git a/qpid/cpp/src/qpid/ha/makeMessage.h b/qpid/cpp/src/qpid/ha/makeMessage.h deleted file mode 100644 index 4427cdd948..0000000000 --- a/qpid/cpp/src/qpid/ha/makeMessage.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef QPID_HA_MAKEMESSAGE_H -#define QPID_HA_MAKEMESSAGE_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 "qpid/broker/Message.h" -#include "qpid/framing/Buffer.h" -#include <string> - -/** Utilities for creating messages used by HA internally. */ - -namespace qpid { -namespace framing { -class Buffer; -} -namespace ha { - -/** - * Create internal messages used by HA components. - */ -broker::Message makeMessage( - const framing::Buffer& content, - const std::string& destination=std::string() -); - -broker::Message makeMessage(const std::string& content, - const std::string& destination=std::string()); - -/** Encode value as a string. */ -template <class T> std::string encodeStr(const T& value) { - std::string encoded(value.encodedSize(), '\0'); - framing::Buffer buffer(&encoded[0], encoded.size()); - value.encode(buffer); - return encoded; -} - -/** Decode value from a string. */ -template <class T> T decodeStr(const std::string& encoded) { - framing::Buffer buffer(const_cast<char*>(&encoded[0]), encoded.size()); - T value; - value.decode(buffer); - return value; -} - -}} // namespace qpid::ha - -#endif /*!QPID_HA_MAKEMESSAGE_H*/ diff --git a/qpid/cpp/src/qpid/ha/types.cpp b/qpid/cpp/src/qpid/ha/types.cpp index 2246355339..c02ae33470 100644 --- a/qpid/cpp/src/qpid/ha/types.cpp +++ b/qpid/cpp/src/qpid/ha/types.cpp @@ -37,6 +37,14 @@ using namespace std; const string QPID_REPLICATE("qpid.replicate"); const string QPID_HA_UUID("qpid.ha-uuid"); +const char* QPID_HA_PREFIX = "qpid.ha-"; +const char* QUEUE_REPLICATOR_PREFIX = "qpid.ha-q:"; +const char* TRANSACTION_REPLICATOR_PREFIX = "qpid.ha-tx:"; + +bool startsWith(const string& name, const string& prefix) { + return name.compare(0, prefix.size(), prefix) == 0; +} + string EnumBase::str() const { assert(value < count); return names[value]; @@ -79,9 +87,11 @@ istream& operator>>(istream& i, EnumBase& e) { return i; } -ostream& operator<<(ostream& o, const IdSet& ids) { +ostream& operator<<(ostream& o, const UuidSet& ids) { ostream_iterator<qpid::types::Uuid> out(o, " "); + o << "{ "; copy(ids.begin(), ids.end(), out); + o << "}"; return o; } @@ -98,6 +108,24 @@ std::ostream& operator<<(std::ostream& o, const LogMessageId& m) { return o << m.queue << "[" << m.position << "]=" << m.replicationId; } +void UuidSet::encode(framing::Buffer& b) const { + b.putLong(size()); + for (const_iterator i = begin(); i != end(); ++i) + b.putRawData(i->data(), i->size()); +} + +void UuidSet::decode(framing::Buffer& b) { + size_t n = b.getLong(); + for ( ; n > 0; --n) { + types::Uuid id; + b.getRawData(const_cast<unsigned char*>(id.data()), id.size()); + insert(id); + } +} + +size_t UuidSet::encodedSize() const { + return sizeof(uint32_t) + size()*16; +} }} // namespace qpid::ha diff --git a/qpid/cpp/src/qpid/ha/types.h b/qpid/cpp/src/qpid/ha/types.h index 9a7e97c66d..92157d411b 100644 --- a/qpid/cpp/src/qpid/ha/types.h +++ b/qpid/cpp/src/qpid/ha/types.h @@ -105,14 +105,26 @@ inline bool isPrimary(BrokerStatus s) { inline bool isBackup(BrokerStatus s) { return !isPrimary(s); } -// String constants. +// String constants, defined as char* to avoid initialization order problems. extern const std::string QPID_REPLICATE; extern const std::string QPID_HA_UUID; -/** Define IdSet type, not a typedef so we can overload operator << */ -class IdSet : public std::set<types::Uuid> {}; +// Strings used as prefixes, defined as char* to avoid link order problems. +extern const char* QPID_HA_PREFIX; +extern const char* QUEUE_REPLICATOR_PREFIX; +extern const char* TRANSACTION_REPLICATOR_PREFIX; -std::ostream& operator<<(std::ostream& o, const IdSet& ids); +bool startsWith(const std::string& name, const std::string& prefix); + +/** Define IdSet type, not a typedef so we can overload operator << and add encoding.*/ +class UuidSet : public std::set<types::Uuid> { + public: + void encode(framing::Buffer&) const; + void decode(framing::Buffer&); + size_t encodedSize() const; +}; + +std::ostream& operator<<(std::ostream& o, const UuidSet& ids); // Use type names to distinguish Positions from Replication Ids typedef framing::SequenceNumber QueuePosition; @@ -132,5 +144,8 @@ struct LogMessageId { }; std::ostream& operator<<(std::ostream&, const LogMessageId&); +/** Return short version of human-readable UUID. */ +inline std::string shortStr(const types::Uuid& uuid) { return uuid.str().substr(0,8); } + }} // qpid::ha #endif /*!QPID_HA_ENUM_H*/ diff --git a/qpid/cpp/src/qpid/legacystore/MessageStoreImpl.cpp b/qpid/cpp/src/qpid/legacystore/MessageStoreImpl.cpp index 3b42c7bd5d..7863940534 100644 --- a/qpid/cpp/src/qpid/legacystore/MessageStoreImpl.cpp +++ b/qpid/cpp/src/qpid/legacystore/MessageStoreImpl.cpp @@ -21,6 +21,7 @@ #include "qpid/legacystore/MessageStoreImpl.h" +#include "db-inc.h" #include "qpid/broker/QueueSettings.h" #include "qpid/legacystore/BindingDbt.h" #include "qpid/legacystore/BufferValue.h" @@ -31,7 +32,6 @@ #include "qmf/org/apache/qpid/legacystore/Package.h" #include "qpid/legacystore/StoreException.h" #include <dirent.h> -#include <db.h> #define MAX_AIO_SLEEPS 100000 // tot: ~1 sec #define AIO_SLEEP_TIME_US 10 // 0.01 ms @@ -448,6 +448,8 @@ void MessageStoreImpl::closeDbs() MessageStoreImpl::~MessageStoreImpl() { + if (mgmtObject.get() != 0) + mgmtObject->debugStats("destroying"); finalize(); try { closeDbs(); diff --git a/qpid/cpp/src/qpid/legacystore/jrnl/jcfg.h b/qpid/cpp/src/qpid/legacystore/jrnl/jcfg.h index 0a0d0df28d..01d92ee985 100644 --- a/qpid/cpp/src/qpid/legacystore/jrnl/jcfg.h +++ b/qpid/cpp/src/qpid/legacystore/jrnl/jcfg.h @@ -33,13 +33,13 @@ #ifndef QPID_LEGACYSTORE_JRNL_JCFG_H #define QPID_LEGACYSTORE_JRNL_JCFG_H -#if defined(__i386__) /* little endian, 32 bits */ +#if defined(__i386__) || (__arm__) /* little endian, 32 bits */ #define JRNL_LITTLE_ENDIAN #define JRNL_32_BIT #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__) || (__arm64__) /* little endian, 64 bits */ #define JRNL_LITTLE_ENDIAN #define JRNL_64_BIT #elif defined(__powerpc64__) || defined(__s390x__) /* big endian, 64 bits */ diff --git a/qpid/cpp/src/qpid/log/Logger.cpp b/qpid/cpp/src/qpid/log/Logger.cpp index 16b2f56049..8242acc87e 100644 --- a/qpid/cpp/src/qpid/log/Logger.cpp +++ b/qpid/cpp/src/qpid/log/Logger.cpp @@ -24,6 +24,7 @@ #include "qpid/sys/Time.h" #include "qpid/DisableExceptionLogging.h" +#include "boost/version.hpp" #if (BOOST_VERSION >= 104000) #include <boost/serialization/singleton.hpp> #else diff --git a/qpid/cpp/include/qpid/log/Logger.h b/qpid/cpp/src/qpid/log/Logger.h index 8c4beb0785..8c4beb0785 100644 --- a/qpid/cpp/include/qpid/log/Logger.h +++ b/qpid/cpp/src/qpid/log/Logger.h diff --git a/qpid/cpp/include/qpid/log/Options.h b/qpid/cpp/src/qpid/log/Options.h index 42a8fb40fe..42a8fb40fe 100644 --- a/qpid/cpp/include/qpid/log/Options.h +++ b/qpid/cpp/src/qpid/log/Options.h diff --git a/qpid/cpp/include/qpid/log/Selector.h b/qpid/cpp/src/qpid/log/Selector.h index 1d025e9646..1d025e9646 100644 --- a/qpid/cpp/include/qpid/log/Selector.h +++ b/qpid/cpp/src/qpid/log/Selector.h diff --git a/qpid/cpp/include/qpid/log/SinkOptions.h b/qpid/cpp/src/qpid/log/SinkOptions.h index 7ec2cfbc17..7ec2cfbc17 100644 --- a/qpid/cpp/include/qpid/log/SinkOptions.h +++ b/qpid/cpp/src/qpid/log/SinkOptions.h diff --git a/qpid/cpp/include/qpid/log/Statement.h b/qpid/cpp/src/qpid/log/Statement.h index e928e19f22..e928e19f22 100644 --- a/qpid/cpp/include/qpid/log/Statement.h +++ b/qpid/cpp/src/qpid/log/Statement.h diff --git a/qpid/cpp/include/qpid/management/Args.h b/qpid/cpp/src/qpid/management/Args.h index 5d1cb7e01d..5d1cb7e01d 100644 --- a/qpid/cpp/include/qpid/management/Args.h +++ b/qpid/cpp/src/qpid/management/Args.h diff --git a/qpid/cpp/include/qpid/management/Buffer.h b/qpid/cpp/src/qpid/management/Buffer.h index 1ac52bf276..1ac52bf276 100644 --- a/qpid/cpp/include/qpid/management/Buffer.h +++ b/qpid/cpp/src/qpid/management/Buffer.h diff --git a/qpid/cpp/include/qpid/management/ConnectionSettings.h b/qpid/cpp/src/qpid/management/ConnectionSettings.h index b631ffa658..b631ffa658 100644 --- a/qpid/cpp/include/qpid/management/ConnectionSettings.h +++ b/qpid/cpp/src/qpid/management/ConnectionSettings.h diff --git a/qpid/cpp/include/qpid/management/Manageable.h b/qpid/cpp/src/qpid/management/Manageable.h index ede5c29e43..ede5c29e43 100644 --- a/qpid/cpp/include/qpid/management/Manageable.h +++ b/qpid/cpp/src/qpid/management/Manageable.h diff --git a/qpid/cpp/src/qpid/management/ManagementAgent.cpp b/qpid/cpp/src/qpid/management/ManagementAgent.cpp index 5f653939ec..d80dd6e6a3 100644 --- a/qpid/cpp/src/qpid/management/ManagementAgent.cpp +++ b/qpid/cpp/src/qpid/management/ManagementAgent.cpp @@ -39,6 +39,7 @@ #include "qpid/sys/PollableQueue.h" #include "qpid/broker/Connection.h" #include "qpid/broker/AclModule.h" +#include "qpid/broker/Protocol.h" #include "qpid/types/Variant.h" #include "qpid/types/Uuid.h" #include "qpid/framing/List.h" @@ -169,7 +170,7 @@ ManagementAgent::RemoteAgent::~RemoteAgent () } ManagementAgent::ManagementAgent (const bool qmfV1, const bool qmfV2) : - threadPoolSize(1), publish(true), interval(10), broker(0), timer(0), + threadPoolSize(1), publish(true), interval(10), broker(0), timer(0), protocols(0), startTime(sys::now()), suppressed(false), disallowAllV1Methods(false), vendorNameKey(defaultVendorName), productNameKey(defaultProductName), @@ -221,6 +222,7 @@ void ManagementAgent::configure(const string& _dataDir, bool _publish, uint16_t timer = &broker->getTimer(); timer->add(new Periodic(boost::bind(&ManagementAgent::periodicProcessing, this), timer, interval)); + protocols = &broker->getProtocolRegistry(); // Get from file or generate and save to file. if (dataDir.empty()) { @@ -2132,9 +2134,9 @@ bool ManagementAgent::authorizeAgentMessage(Message& msg) uint32_t bufferLen = inBuffer.getPosition(); inBuffer.reset(); - qpid::broker::amqp_0_10::MessageTransfer& transfer(qpid::broker::amqp_0_10::MessageTransfer::get(msg)); + boost::intrusive_ptr<const qpid::broker::amqp_0_10::MessageTransfer> transfer = protocols->translate(msg); const framing::MessageProperties* p = - transfer.getFrames().getHeaders()->get<framing::MessageProperties>(); + transfer ? transfer->getFrames().getHeaders()->get<framing::MessageProperties>() : 0; const framing::FieldTable *headers = p ? &p->getApplicationHeaders() : 0; @@ -2229,9 +2231,9 @@ bool ManagementAgent::authorizeAgentMessage(Message& msg) // authorization failed, send reply if replyTo present - qpid::broker::amqp_0_10::MessageTransfer& transfer(qpid::broker::amqp_0_10::MessageTransfer::get(msg)); + boost::intrusive_ptr<const qpid::broker::amqp_0_10::MessageTransfer> transfer = protocols->translate(msg); const framing::MessageProperties* p = - transfer.getFrames().getHeaders()->get<framing::MessageProperties>(); + transfer ? transfer->getFrames().getHeaders()->get<framing::MessageProperties>() : 0; if (p && p->hasReplyTo()) { const framing::ReplyTo& rt = p->getReplyTo(); string rte = rt.getExchange(); @@ -2266,9 +2268,10 @@ void ManagementAgent::dispatchAgentCommand(Message& msg, bool viaLocal) { string rte; string rtk; - qpid::broker::amqp_0_10::MessageTransfer& transfer(qpid::broker::amqp_0_10::MessageTransfer::get(msg)); - const framing::MessageProperties* p = - transfer.getFrames().getHeaders()->get<framing::MessageProperties>(); + + boost::intrusive_ptr<const qpid::broker::amqp_0_10::MessageTransfer> transfer = protocols->translate(msg); + const framing::MessageProperties* p = transfer ? + transfer->getFrames().getHeaders()->get<framing::MessageProperties>() : 0; if (p && p->hasReplyTo()) { const framing::ReplyTo& rt = p->getReplyTo(); rte = rt.getExchange(); diff --git a/qpid/cpp/src/qpid/management/ManagementAgent.h b/qpid/cpp/src/qpid/management/ManagementAgent.h index d2869a705f..c2eb5d4a31 100644 --- a/qpid/cpp/src/qpid/management/ManagementAgent.h +++ b/qpid/cpp/src/qpid/management/ManagementAgent.h @@ -44,6 +44,7 @@ namespace qpid { namespace broker { class Connection; +class ProtocolRegistry; } namespace sys { class Timer; @@ -256,6 +257,7 @@ private: uint16_t interval; qpid::broker::Broker* broker; qpid::sys::Timer* timer; + qpid::broker::ProtocolRegistry* protocols; uint16_t bootSequence; uint32_t nextObjectId; uint32_t brokerBank; diff --git a/qpid/cpp/include/qpid/management/ManagementEvent.h b/qpid/cpp/src/qpid/management/ManagementEvent.h index e80175096f..e80175096f 100644 --- a/qpid/cpp/include/qpid/management/ManagementEvent.h +++ b/qpid/cpp/src/qpid/management/ManagementEvent.h diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/src/qpid/management/ManagementObject.h index 93fbec7bc7..93fbec7bc7 100644 --- a/qpid/cpp/include/qpid/management/ManagementObject.h +++ b/qpid/cpp/src/qpid/management/ManagementObject.h diff --git a/qpid/cpp/include/qpid/management/Mutex.h b/qpid/cpp/src/qpid/management/Mutex.h index 67ae04bae9..67ae04bae9 100644 --- a/qpid/cpp/include/qpid/management/Mutex.h +++ b/qpid/cpp/src/qpid/management/Mutex.h diff --git a/qpid/cpp/src/qpid/messaging/Connection.cpp b/qpid/cpp/src/qpid/messaging/Connection.cpp index fde931038b..71618d1057 100644 --- a/qpid/cpp/src/qpid/messaging/Connection.cpp +++ b/qpid/cpp/src/qpid/messaging/Connection.cpp @@ -68,7 +68,7 @@ Connection::Connection(const std::string& url, const Variant::Map& options) Connection::Connection() { Variant::Map options; - std::string url = "amqp:tcp:127.0.0.1:5672"; + std::string url = "127.0.0.1:5672"; PI::ctor(*this, new qpid::client::amqp0_10::ConnectionImpl(url, options)); } @@ -90,4 +90,18 @@ std::string Connection::getAuthenticatedUsername() { return impl->getAuthenticatedUsername(); } + +void Connection::reconnect(const std::string& url) +{ + impl->reconnect(url); +} +void Connection::reconnect() +{ + impl->reconnect(); +} +std::string Connection::getUrl() const +{ + return impl->getUrl(); +} + }} // namespace qpid::messaging diff --git a/qpid/cpp/src/qpid/messaging/ConnectionImpl.h b/qpid/cpp/src/qpid/messaging/ConnectionImpl.h index 1e11d9a6d5..92c6d91b10 100644 --- a/qpid/cpp/src/qpid/messaging/ConnectionImpl.h +++ b/qpid/cpp/src/qpid/messaging/ConnectionImpl.h @@ -45,6 +45,9 @@ class ConnectionImpl : public virtual qpid::RefCounted virtual Session getSession(const std::string& name) const = 0; virtual void setOption(const std::string& name, const qpid::types::Variant& value) = 0; virtual std::string getAuthenticatedUsername() = 0; + virtual void reconnect(const std::string& url) = 0; + virtual void reconnect() = 0; + virtual std::string getUrl() const = 0; private: }; }} // namespace qpid::messaging diff --git a/qpid/cpp/src/qpid/messaging/ConnectionOptions.cpp b/qpid/cpp/src/qpid/messaging/ConnectionOptions.cpp index 746666a79c..e534920876 100644 --- a/qpid/cpp/src/qpid/messaging/ConnectionOptions.cpp +++ b/qpid/cpp/src/qpid/messaging/ConnectionOptions.cpp @@ -52,7 +52,7 @@ void merge(const qpid::types::Variant::List& from, std::vector<std::string>& to) ConnectionOptions::ConnectionOptions(const std::map<std::string, qpid::types::Variant>& options) : replaceUrls(false), reconnect(false), timeout(FOREVER), limit(-1), minReconnectInterval(0.001), maxReconnectInterval(2), - retries(0), reconnectOnLimitExceeded(true) + retries(0), reconnectOnLimitExceeded(true), nestAnnotations(false) { for (qpid::types::Variant::Map::const_iterator i = options.begin(); i != options.end(); ++i) { set(i->first, i->second); @@ -115,6 +115,8 @@ void ConnectionOptions::set(const std::string& name, const qpid::types::Variant& reconnectOnLimitExceeded = value; } else if (name == "container-id" || name == "container_id") { identifier = value.asString(); + } else if (name == "nest-annotations" || name == "nest_annotations") { + nestAnnotations = value; } else { throw qpid::messaging::MessagingException(QPID_MSG("Invalid option: " << name << " not recognised")); } diff --git a/qpid/cpp/src/qpid/messaging/ConnectionOptions.h b/qpid/cpp/src/qpid/messaging/ConnectionOptions.h index 7a701fce65..5942592d78 100644 --- a/qpid/cpp/src/qpid/messaging/ConnectionOptions.h +++ b/qpid/cpp/src/qpid/messaging/ConnectionOptions.h @@ -21,6 +21,8 @@ * under the License. * */ +#include "qpid/messaging/ImportExport.h" + #include "qpid/client/ConnectionSettings.h" #include <map> #include <vector> @@ -43,9 +45,10 @@ struct ConnectionOptions : qpid::client::ConnectionSettings int32_t retries; bool reconnectOnLimitExceeded; std::string identifier; + bool nestAnnotations; - ConnectionOptions(const std::map<std::string, qpid::types::Variant>&); - void set(const std::string& name, const qpid::types::Variant& value); + QPID_MESSAGING_EXTERN ConnectionOptions(const std::map<std::string, qpid::types::Variant>&); + QPID_MESSAGING_EXTERN void set(const std::string& name, const qpid::types::Variant& value); }; }} // namespace qpid::messaging diff --git a/qpid/cpp/src/qpid/messaging/Message.cpp b/qpid/cpp/src/qpid/messaging/Message.cpp index 0f03bc8ca3..62ee93b6c2 100644 --- a/qpid/cpp/src/qpid/messaging/Message.cpp +++ b/qpid/cpp/src/qpid/messaging/Message.cpp @@ -31,6 +31,10 @@ using namespace qpid::types; Message::Message(const std::string& bytes) : impl(new MessageImpl(bytes)) {} Message::Message(const char* bytes, size_t count) : impl(new MessageImpl(bytes, count)) {} +Message::Message(qpid::types::Variant& c) : impl(new MessageImpl(std::string())) +{ + setContentObject(c); +} Message::Message(const Message& m) : impl(new MessageImpl(*m.impl)) {} Message::~Message() { delete impl; } @@ -69,12 +73,20 @@ void Message::setRedelivered(bool redelivered) { impl->setRedelivered(redelivere const Variant::Map& Message::getProperties() const { return impl->getHeaders(); } Variant::Map& Message::getProperties() { return impl->getHeaders(); } +void Message::setProperties(const Variant::Map& p) { getProperties() = p; } void Message::setProperty(const std::string& k, const qpid::types::Variant& v) { impl->setHeader(k,v); } void Message::setContent(const std::string& c) { impl->setBytes(c); } void Message::setContent(const char* chars, size_t count) { impl->setBytes(chars, count); } std::string Message::getContent() const { return impl->getBytes(); } +void Message::setContentBytes(const std::string& c) { impl->setBytes(c); } +std::string Message::getContentBytes() const { return impl->getBytes(); } + +qpid::types::Variant& Message::getContentObject() { return impl->getContent(); } +void Message::setContentObject(const qpid::types::Variant& c) { impl->getContent() = c; } +const qpid::types::Variant& Message::getContentObject() const { return impl->getContent(); } + const char* Message::getContentPtr() const { return impl->getBytes().data(); diff --git a/qpid/cpp/src/qpid/messaging/MessageImpl.cpp b/qpid/cpp/src/qpid/messaging/MessageImpl.cpp index fc9bc5dfa1..e9232804d8 100644 --- a/qpid/cpp/src/qpid/messaging/MessageImpl.cpp +++ b/qpid/cpp/src/qpid/messaging/MessageImpl.cpp @@ -7,9 +7,9 @@ * 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 @@ -30,21 +30,44 @@ const std::string EMPTY_STRING = ""; using namespace qpid::types; -MessageImpl::MessageImpl(const std::string& c) : +MessageImpl::MessageImpl(const std::string& c) : priority(0), ttl(0), durable(false), redelivered(false), bytes(c), + contentDecoded(false), internalId(0) {} -MessageImpl::MessageImpl(const char* chars, size_t count) : +MessageImpl::MessageImpl(const char* chars, size_t count) : priority(0), ttl(0), durable (false), redelivered(false), bytes(chars, count), + contentDecoded(false), internalId(0) {} +void MessageImpl::clear() +{ + replyTo = Address(); + subject = std::string(); + contentType = std::string(); + messageId = std::string(); + userId= std::string(); + correlationId = std::string(); + priority = 0; + ttl = 0; + durable = false; + redelivered = false; + headers = qpid::types::Variant::Map(); + + bytes = std::string(); + content = qpid::types::Variant(); + contentDecoded = false; + encoded = boost::shared_ptr<const qpid::messaging::amqp::EncodedMessage>(); + internalId = 0; +} + void MessageImpl::setReplyTo(const Address& d) { replyTo = d; @@ -167,21 +190,35 @@ void MessageImpl::setBytes(const char* chars, size_t count) bytes.assign(chars, count); updated(); } -void MessageImpl::appendBytes(const char* chars, size_t count) -{ - bytes.append(chars, count); - updated(); -} const std::string& MessageImpl::getBytes() const { - if (!bytes.size() && encoded) encoded->getBody(bytes); - return bytes; + if (encoded && !contentDecoded) { + encoded->getBody(bytes, content); + contentDecoded = true; + } + if (bytes.empty() && !content.isVoid()) return content.getString(); + else return bytes; } std::string& MessageImpl::getBytes() { - if (!bytes.size() && encoded) encoded->getBody(bytes); updated();//have to assume body may be edited, invalidating our message - return bytes; + if (bytes.empty() && !content.isVoid()) return content.getString(); + else return bytes; +} + +qpid::types::Variant& MessageImpl::getContent() +{ + updated();//have to assume content may be edited, invalidating our message + return content; +} + +const qpid::types::Variant& MessageImpl::getContent() const +{ + if (encoded && !contentDecoded) { + encoded->getBody(bytes, content); + contentDecoded = true; + } + return content; } void MessageImpl::setInternalId(qpid::framing::SequenceNumber i) { internalId = i; } @@ -197,7 +234,10 @@ void MessageImpl::updated() if (!userId.size() && encoded) encoded->getUserId(userId); if (!correlationId.size() && encoded) encoded->getCorrelationId(correlationId); if (!headers.size() && encoded) encoded->populate(headers); - if (!bytes.size() && encoded) encoded->getBody(bytes); + if (encoded && !contentDecoded) { + encoded->getBody(bytes, content); + contentDecoded = true; + } encoded.reset(); } @@ -210,5 +250,4 @@ const MessageImpl& MessageImplAccess::get(const Message& msg) { return *msg.impl; } - }} // namespace qpid::messaging diff --git a/qpid/cpp/src/qpid/messaging/MessageImpl.h b/qpid/cpp/src/qpid/messaging/MessageImpl.h index 915c790153..647972de16 100644 --- a/qpid/cpp/src/qpid/messaging/MessageImpl.h +++ b/qpid/cpp/src/qpid/messaging/MessageImpl.h @@ -10,9 +10,9 @@ * 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 @@ -21,6 +21,9 @@ * under the License. * */ + +#include "qpid/messaging/ImportExport.h" + #include "qpid/messaging/Address.h" #include "qpid/types/Variant.h" #include "qpid/framing/SequenceNumber.h" @@ -47,6 +50,8 @@ class MessageImpl mutable qpid::types::Variant::Map headers; mutable std::string bytes; + mutable qpid::types::Variant content; + mutable bool contentDecoded; boost::shared_ptr<const qpid::messaging::amqp::EncodedMessage> encoded; qpid::framing::SequenceNumber internalId; @@ -56,43 +61,45 @@ class MessageImpl MessageImpl(const std::string& c); MessageImpl(const char* chars, size_t count); + void clear(); void setReplyTo(const Address& d); - const Address& getReplyTo() const; + QPID_MESSAGING_EXTERN const Address& getReplyTo() const; void setSubject(const std::string& s); - const std::string& getSubject() const; + QPID_MESSAGING_EXTERN const std::string& getSubject() const; void setContentType(const std::string& s); - const std::string& getContentType() const; + QPID_MESSAGING_EXTERN const std::string& getContentType() const; void setMessageId(const std::string&); - const std::string& getMessageId() const; + QPID_MESSAGING_EXTERN const std::string& getMessageId() const; void setUserId(const std::string& ); - const std::string& getUserId() const; + QPID_MESSAGING_EXTERN const std::string& getUserId() const; void setCorrelationId(const std::string& ); - const std::string& getCorrelationId() const; + QPID_MESSAGING_EXTERN const std::string& getCorrelationId() const; void setPriority(uint8_t); - uint8_t getPriority() const; + QPID_MESSAGING_EXTERN uint8_t getPriority() const; void setTtl(uint64_t); - uint64_t getTtl() const; + QPID_MESSAGING_EXTERN uint64_t getTtl() const; void setDurable(bool); - bool isDurable() const; + QPID_MESSAGING_EXTERN bool isDurable() const; void setRedelivered(bool); - bool isRedelivered() const; + QPID_MESSAGING_EXTERN bool isRedelivered() const; - const qpid::types::Variant::Map& getHeaders() const; + QPID_MESSAGING_EXTERN const qpid::types::Variant::Map& getHeaders() const; qpid::types::Variant::Map& getHeaders(); void setHeader(const std::string& key, const qpid::types::Variant& val); void setBytes(const std::string& bytes); void setBytes(const char* chars, size_t count); - void appendBytes(const char* chars, size_t count); - const std::string& getBytes() const; + QPID_MESSAGING_EXTERN const std::string& getBytes() const; std::string& getBytes(); + qpid::types::Variant& getContent(); + QPID_MESSAGING_EXTERN const qpid::types::Variant& getContent() const; - void setInternalId(qpid::framing::SequenceNumber id); - qpid::framing::SequenceNumber getInternalId(); + QPID_MESSAGING_EXTERN void setInternalId(qpid::framing::SequenceNumber id); + QPID_MESSAGING_EXTERN qpid::framing::SequenceNumber getInternalId(); void setEncoded(boost::shared_ptr<const qpid::messaging::amqp::EncodedMessage> e) { encoded = e; } boost::shared_ptr<const qpid::messaging::amqp::EncodedMessage> getEncoded() const { return encoded; } }; @@ -106,8 +113,8 @@ class Message; */ struct MessageImplAccess { - static MessageImpl& get(Message&); - static const MessageImpl& get(const Message&); + QPID_MESSAGING_EXTERN static MessageImpl& get(Message&); + QPID_MESSAGING_EXTERN static const MessageImpl& get(const Message&); }; }} // namespace qpid::messaging diff --git a/qpid/cpp/src/qpid/messaging/ProtocolRegistry.h b/qpid/cpp/src/qpid/messaging/ProtocolRegistry.h index bcb62248a5..25e8bd4ec8 100644 --- a/qpid/cpp/src/qpid/messaging/ProtocolRegistry.h +++ b/qpid/cpp/src/qpid/messaging/ProtocolRegistry.h @@ -21,6 +21,9 @@ * under the License. * */ + +#include "qpid/messaging/ImportExport.h" + #include "qpid/types/Variant.h" namespace qpid { @@ -34,7 +37,7 @@ class ProtocolRegistry public: typedef ConnectionImpl* Factory(const std::string& url, const qpid::types::Variant::Map& options); static ConnectionImpl* create(const std::string& url, const qpid::types::Variant::Map& options); - static void add(const std::string& name, Factory* factory); + QPID_MESSAGING_EXTERN static void add(const std::string& name, Factory* factory); private: }; }} // namespace qpid::messaging diff --git a/qpid/cpp/src/qpid/messaging/Receiver.cpp b/qpid/cpp/src/qpid/messaging/Receiver.cpp index c45ebd6760..f60e5f55b3 100644 --- a/qpid/cpp/src/qpid/messaging/Receiver.cpp +++ b/qpid/cpp/src/qpid/messaging/Receiver.cpp @@ -21,6 +21,7 @@ #include "qpid/messaging/Receiver.h" #include "qpid/messaging/Address.h" #include "qpid/messaging/Message.h" +#include "qpid/messaging/MessageImpl.h" #include "qpid/messaging/ReceiverImpl.h" #include "qpid/messaging/Session.h" #include "qpid/messaging/PrivateImplRef.h" @@ -36,7 +37,11 @@ Receiver::~Receiver() { PI::dtor(*this); } Receiver& Receiver::operator=(const Receiver& s) { return PI::assign(*this, s); } bool Receiver::get(Message& message, Duration timeout) { return impl->get(message, timeout); } Message Receiver::get(Duration timeout) { return impl->get(timeout); } -bool Receiver::fetch(Message& message, Duration timeout) { return impl->fetch(message, timeout); } +bool Receiver::fetch(Message& message, Duration timeout) +{ + MessageImplAccess::get(message).clear(); + return impl->fetch(message, timeout); +} Message Receiver::fetch(Duration timeout) { return impl->fetch(timeout); } void Receiver::setCapacity(uint32_t c) { impl->setCapacity(c); } uint32_t Receiver::getCapacity() { return impl->getCapacity(); } diff --git a/qpid/cpp/src/qpid/messaging/amqp/AddressHelper.cpp b/qpid/cpp/src/qpid/messaging/amqp/AddressHelper.cpp index 9ecb46d872..beac50cdac 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/AddressHelper.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/AddressHelper.cpp @@ -57,6 +57,7 @@ const std::string PROPERTIES("properties"); const std::string MODE("mode"); const std::string BROWSE("browse"); const std::string CONSUME("consume"); +const std::string TIMEOUT("timeout"); const std::string TYPE("type"); const std::string TOPIC("topic"); @@ -69,6 +70,14 @@ const std::string FILTER("filter"); const std::string DESCRIPTOR("descriptor"); const std::string VALUE("value"); const std::string SUBJECT_FILTER("subject-filter"); +const std::string SOURCE("sender-source"); +const std::string TARGET("receiver-target"); + +//reliability options: +const std::string UNRELIABLE("unreliable"); +const std::string AT_MOST_ONCE("at-most-once"); +const std::string AT_LEAST_ONCE("at-least-once"); +const std::string EXACTLY_ONCE("exactly-once"); //distribution modes: const std::string MOVE("move"); @@ -83,12 +92,11 @@ const std::string DELETE_IF_EMPTY("delete-if-empty"); const std::string DELETE_IF_UNUSED_AND_EMPTY("delete-if-unused-and-empty"); const std::string CREATE_ON_DEMAND("create-on-demand"); -const std::string DUMMY("."); - const std::string X_DECLARE("x-declare"); const std::string X_BINDINGS("x-bindings"); const std::string X_SUBSCRIBE("x-subscribe"); const std::string ARGUMENTS("arguments"); +const std::string EXCHANGE_TYPE("exchange-type"); const std::vector<std::string> RECEIVER_MODES = boost::assign::list_of<std::string>(ALWAYS) (RECEIVER); const std::vector<std::string> SENDER_MODES = boost::assign::list_of<std::string>(ALWAYS) (SENDER); @@ -144,6 +152,16 @@ bool test(const Variant::Map& options, const std::string& name) } } +template <typename T> T get(const Variant::Map& options, const std::string& name, T defaultValue) +{ + Variant::Map::const_iterator j = options.find(name); + if (j == options.end()) { + return defaultValue; + } else { + return j->second; + } +} + bool bind(const Variant::Map& options, const std::string& name, std::string& variable) { Variant::Map::const_iterator j = options.find(name); @@ -208,6 +226,18 @@ void flatten(Variant::Map& base, const std::string& nested) base.erase(i); } } +bool replace(Variant::Map& map, const std::string& original, const std::string& desired) +{ + Variant::Map::iterator i = map.find(original); + if (i != map.end()) { + map[desired] = i->second; + map.erase(original); + return true; + } else { + return false; + } +} + void write(pn_data_t* data, const Variant& value); void write(pn_data_t* data, const Variant::Map& map) @@ -260,6 +290,8 @@ void write(pn_data_t* data, const Variant& value) break; } } +const uint32_t DEFAULT_DURABLE_TIMEOUT(15*60);//15 minutes +const uint32_t DEFAULT_TIMEOUT(0); } AddressHelper::AddressHelper(const Address& address) : @@ -268,6 +300,7 @@ AddressHelper::AddressHelper(const Address& address) : type(address.getType()), durableNode(false), durableLink(false), + timeout(0), browse(false) { verifier.verify(address); @@ -279,13 +312,14 @@ AddressHelper::AddressHelper(const Address& address) : bind(address, LINK, link); bind(node, PROPERTIES, properties); bind(node, CAPABILITIES, capabilities); + bind(link, RELIABILITY, reliability); durableNode = test(node, DURABLE); durableLink = test(link, DURABLE); + timeout = get(link, TIMEOUT, durableLink ? DEFAULT_DURABLE_TIMEOUT : DEFAULT_TIMEOUT); std::string mode; if (bind(address, MODE, mode)) { if (mode == BROWSE) { browse = true; - throw qpid::messaging::AddressError("Browse mode not yet supported over AMQP 1.0."); } else if (mode != CONSUME) { throw qpid::messaging::AddressError("Invalid value for mode; must be 'browse' or 'consume'."); } @@ -310,6 +344,7 @@ AddressHelper::AddressHelper(const Address& address) : Variant::Map::iterator i = node.find(X_DECLARE); if (i != node.end()) { Variant::Map x_declare = i->second.asMap(); + replace(x_declare, TYPE, EXCHANGE_TYPE); flatten(x_declare, ARGUMENTS); add(properties, x_declare); node.erase(i); @@ -391,16 +426,23 @@ void AddressHelper::checkAssertion(pn_terminus_t* terminus, CheckMode mode) QPID_LOG(debug, "checking assertions: " << capabilities); //ensure all desired capabilities have been offered std::set<std::string> desired; - if (type.size()) desired.insert(type); - if (durableNode) desired.insert(DURABLE); for (Variant::List::const_iterator i = capabilities.begin(); i != capabilities.end(); ++i) { - desired.insert(i->asString()); + if (*i != CREATE_ON_DEMAND) desired.insert(i->asString()); } pn_data_t* data = pn_terminus_capabilities(terminus); - while (pn_data_next(data)) { - pn_bytes_t c = pn_data_get_symbol(data); - std::string s(c.start, c.size); - desired.erase(s); + if (pn_data_next(data)) { + pn_type_t type = pn_data_type(data); + if (type == PN_ARRAY) { + pn_data_enter(data); + while (pn_data_next(data)) { + desired.erase(convert(pn_data_get_symbol(data))); + } + pn_data_exit(data); + } else if (type == PN_SYMBOL) { + desired.erase(convert(pn_data_get_symbol(data))); + } else { + QPID_LOG(error, "Skipping capabilities field of type " << pn_type_name(type)); + } } if (desired.size()) { @@ -492,6 +534,11 @@ bool AddressHelper::enabled(const std::string& policy, CheckMode mode) const return result; } +bool AddressHelper::isUnreliable() const +{ + return reliability == AT_MOST_ONCE || reliability == UNRELIABLE; +} + const qpid::types::Variant::Map& AddressHelper::getNodeProperties() const { return node; @@ -501,12 +548,32 @@ const qpid::types::Variant::Map& AddressHelper::getLinkProperties() const return link; } -void AddressHelper::configure(pn_terminus_t* terminus, CheckMode mode) +bool AddressHelper::getLinkSource(std::string& out) const +{ + return getLinkOption(SOURCE, out); +} + +bool AddressHelper::getLinkTarget(std::string& out) const +{ + return getLinkOption(TARGET, out); +} + +bool AddressHelper::getLinkOption(const std::string& name, std::string& out) const +{ + qpid::types::Variant::Map::const_iterator i = link.find(name); + if (i != link.end()) { + out = i->second.asString(); + return true; + } else { + return false; + } +} + +void AddressHelper::configure(pn_link_t* link, pn_terminus_t* terminus, CheckMode mode) { bool createOnDemand(false); if (isTemporary) { //application expects a name to be generated - pn_terminus_set_address(terminus, DUMMY.c_str());//workaround for PROTON-277 pn_terminus_set_dynamic(terminus, true); setNodeProperties(terminus); } else { @@ -517,43 +584,57 @@ void AddressHelper::configure(pn_terminus_t* terminus, CheckMode mode) createOnDemand = true; } } + setCapabilities(terminus, createOnDemand); if (durableLink) { pn_terminus_set_durability(terminus, PN_DELIVERIES); } - if (mode == FOR_RECEIVER && browse) { - //when PROTON-139 is resolved, set the required delivery-mode - } - //set filter(s): - if (mode == FOR_RECEIVER && !filters.empty()) { - pn_data_t* filter = pn_terminus_filter(terminus); - pn_data_put_map(filter); - pn_data_enter(filter); - for (std::vector<Filter>::const_iterator i = filters.begin(); i != filters.end(); ++i) { - pn_data_put_symbol(filter, convert(i->name)); - pn_data_put_described(filter); + if (mode == FOR_RECEIVER) { + if (timeout) pn_terminus_set_timeout(terminus, timeout); + if (browse) { + pn_terminus_set_distribution_mode(terminus, PN_DIST_MODE_COPY); + } + //set filter(s): + if (!filters.empty()) { + pn_data_t* filter = pn_terminus_filter(terminus); + pn_data_put_map(filter); pn_data_enter(filter); - if (i->descriptorSymbol.size()) { - pn_data_put_symbol(filter, convert(i->descriptorSymbol)); - } else { - pn_data_put_ulong(filter, i->descriptorCode); + for (std::vector<Filter>::const_iterator i = filters.begin(); i != filters.end(); ++i) { + pn_data_put_symbol(filter, convert(i->name)); + pn_data_put_described(filter); + pn_data_enter(filter); + if (i->descriptorSymbol.size()) { + pn_data_put_symbol(filter, convert(i->descriptorSymbol)); + } else { + pn_data_put_ulong(filter, i->descriptorCode); + } + write(filter, i->value); + pn_data_exit(filter); } - write(filter, i->value); pn_data_exit(filter); } - pn_data_exit(filter); } - + if (isUnreliable()) { + pn_link_set_snd_settle_mode(link, PN_SND_SETTLED); + } } void AddressHelper::setCapabilities(pn_terminus_t* terminus, bool create) { + if (create) capabilities.push_back(CREATE_ON_DEMAND); + if (!type.empty()) capabilities.push_back(type); + if (durableNode) capabilities.push_back(DURABLE); + pn_data_t* data = pn_terminus_capabilities(terminus); - if (create) pn_data_put_symbol(data, convert(CREATE_ON_DEMAND)); - if (type.size()) pn_data_put_symbol(data, convert(type)); - if (durableNode) pn_data_put_symbol(data, convert(DURABLE)); - for (qpid::types::Variant::List::const_iterator i = capabilities.begin(); i != capabilities.end(); ++i) { - pn_data_put_symbol(data, convert(i->asString())); + if (capabilities.size() == 1) { + pn_data_put_symbol(data, convert(capabilities.front().asString())); + } else if (capabilities.size() > 1) { + pn_data_put_array(data, false, PN_SYMBOL); + pn_data_enter(data); + for (qpid::types::Variant::List::const_iterator i = capabilities.begin(); i != capabilities.end(); ++i) { + pn_data_put_symbol(data, convert(i->asString())); + } + pn_data_exit(data); } } std::string AddressHelper::getLinkName(const Address& address) @@ -632,6 +713,9 @@ Verifier::Verifier() link[NAME] = true; link[DURABLE] = true; link[RELIABILITY] = true; + link[TIMEOUT] = true; + link[SOURCE] = true; + link[TARGET] = true; link[X_SUBSCRIBE] = true; link[X_DECLARE] = true; link[X_BINDINGS] = true; diff --git a/qpid/cpp/src/qpid/messaging/amqp/AddressHelper.h b/qpid/cpp/src/qpid/messaging/amqp/AddressHelper.h index 4608981a69..3ee58cad8d 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/AddressHelper.h +++ b/qpid/cpp/src/qpid/messaging/amqp/AddressHelper.h @@ -24,6 +24,7 @@ #include "qpid/types/Variant.h" #include <vector> +struct pn_link_t; struct pn_terminus_t; namespace qpid { @@ -36,10 +37,13 @@ class AddressHelper enum CheckMode {FOR_RECEIVER, FOR_SENDER}; AddressHelper(const Address& address); - void configure(pn_terminus_t* terminus, CheckMode mode); + void configure(pn_link_t* link, pn_terminus_t* terminus, CheckMode mode); void checkAssertion(pn_terminus_t* terminus, CheckMode mode); + bool isUnreliable() const; const qpid::types::Variant::Map& getNodeProperties() const; + bool getLinkSource(std::string& out) const; + bool getLinkTarget(std::string& out) const; const qpid::types::Variant::Map& getLinkProperties() const; static std::string getLinkName(const Address& address); private: @@ -66,8 +70,10 @@ class AddressHelper qpid::types::Variant::List capabilities; std::string name; std::string type; + std::string reliability; bool durableNode; bool durableLink; + uint32_t timeout; bool browse; std::vector<Filter> filters; @@ -82,6 +88,7 @@ class AddressHelper void addFilters(const qpid::types::Variant::List&); void confirmFilter(const std::string& descriptor); void confirmFilter(uint64_t descriptor); + bool getLinkOption(const std::string& name, std::string& out) const; }; }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp index 72bba608d1..dba5cb1e1c 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp @@ -45,18 +45,17 @@ namespace qpid { namespace messaging { namespace amqp { -ConnectionContext::ConnectionContext(const std::string& u, const qpid::types::Variant::Map& o) +ConnectionContext::ConnectionContext(const std::string& url, const qpid::types::Variant::Map& o) : qpid::messaging::ConnectionOptions(o), - url(u, protocol.empty() ? qpid::Address::TCP : protocol), engine(pn_transport()), connection(pn_connection()), //note: disabled read/write of header as now handled by engine writeHeader(false), readHeader(false), haveOutput(false), - state(DISCONNECTED), - codecSwitch(*this) + state(DISCONNECTED) { + urls.insert(urls.begin(), url); if (pn_transport_bind(engine, connection)) { //error } @@ -77,84 +76,28 @@ ConnectionContext::~ConnectionContext() pn_connection_free(connection); } -namespace { -const std::string COLON(":"); -} -void ConnectionContext::open() -{ - qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); - if (state != DISCONNECTED) throw qpid::messaging::ConnectionError("Connection was already opened!"); - if (!driver) driver = DriverImpl::getDefault(); - if (url.getUser().size()) username = url.getUser(); - if (url.getPass().size()) password = url.getPass(); - - for (Url::const_iterator i = url.begin(); state != CONNECTED && i != url.end(); ++i) { - transport = driver->getTransport(i->protocol, *this); - std::stringstream port; - port << i->port; - id = i->host + COLON + port.str(); - if (useSasl()) { - sasl = std::auto_ptr<Sasl>(new Sasl(id, *this, i->host)); - } - state = CONNECTING; - try { - QPID_LOG(debug, id << " Connecting ..."); - transport->connect(i->host, port.str()); - } catch (const std::exception& e) { - QPID_LOG(info, id << " Error while connecting: " << e.what()); - } - while (state == CONNECTING) { - lock.wait(); - } - if (state == DISCONNECTED) { - QPID_LOG(debug, id << " Failed to connect"); - transport = boost::shared_ptr<Transport>(); - } else { - QPID_LOG(debug, id << " Connected"); - } - } - - if (state != CONNECTED) throw qpid::messaging::TransportFailure(QPID_MSG("Could not connect to " << url)); - - if (sasl.get()) { - wakeupDriver(); - while (!sasl->authenticated()) { - QPID_LOG(debug, id << " Waiting to be authenticated..."); - wait(); - } - QPID_LOG(debug, id << " Authenticated"); - } - - QPID_LOG(debug, id << " Opening..."); - setProperties(); - pn_connection_open(connection); - wakeupDriver(); //want to write - while (pn_connection_state(connection) & PN_REMOTE_UNINIT) { - wait(); - } - if (!(pn_connection_state(connection) & PN_REMOTE_ACTIVE)) { - throw qpid::messaging::ConnectionError("Failed to open connection"); - } - QPID_LOG(debug, id << " Opened"); -} - bool ConnectionContext::isOpen() const { qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); - return pn_connection_state(connection) & (PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE); + return state == CONNECTED && pn_connection_state(connection) & (PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE); } void ConnectionContext::endSession(boost::shared_ptr<SessionContext> ssn) { qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); - //wait for outstanding sends to settle - while (!ssn->settled()) { - QPID_LOG(debug, "Waiting for sends to settle before closing"); - wait(ssn);//wait until message has been confirmed + if (pn_session_state(ssn->session) & PN_REMOTE_ACTIVE) { + //wait for outstanding sends to settle + while (!ssn->settled()) { + QPID_LOG(debug, "Waiting for sends to settle before closing"); + wait(ssn);//wait until message has been confirmed + } + } + + if (pn_session_state(ssn->session) & PN_REMOTE_ACTIVE) { + pn_session_close(ssn->session); } + sessions.erase(ssn->getName()); - pn_session_close(ssn->session); - //TODO: need to destroy session and remove context from map wakeupDriver(); } @@ -260,6 +203,7 @@ bool ConnectionContext::get(boost::shared_ptr<SessionContext> ssn, boost::shared if (current) { qpid::messaging::MessageImpl& impl = MessageImplAccess::get(message); boost::shared_ptr<EncodedMessage> encoded(new EncodedMessage(pn_delivery_pending(current))); + encoded->setNestAnnotationsOption(nestAnnotations); ssize_t read = pn_link_recv(lnk->receiver, encoded->getData(), encoded->getSize()); if (read < 0) throw qpid::messaging::MessagingException("Failed to read message"); encoded->trim((size_t) read); @@ -290,55 +234,61 @@ void ConnectionContext::acknowledge(boost::shared_ptr<SessionContext> ssn, qpid: wakeupDriver(); } +void ConnectionContext::detach(boost::shared_ptr<SessionContext> ssn, boost::shared_ptr<SenderContext> lnk) +{ + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); + if (pn_link_state(lnk->sender) & PN_LOCAL_ACTIVE) { + lnk->close(); + } + wakeupDriver(); + while (pn_link_state(lnk->sender) & PN_REMOTE_ACTIVE) { + wait(); + } + ssn->removeSender(lnk->getName()); +} + +void ConnectionContext::detach(boost::shared_ptr<SessionContext> ssn, boost::shared_ptr<ReceiverContext> lnk) +{ + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); + if (pn_link_state(lnk->receiver) & PN_LOCAL_ACTIVE) { + lnk->close(); + } + wakeupDriver(); + while (pn_link_state(lnk->receiver) & PN_REMOTE_ACTIVE) { + wait(); + } + ssn->removeReceiver(lnk->getName()); +} void ConnectionContext::attach(boost::shared_ptr<SessionContext> ssn, boost::shared_ptr<SenderContext> lnk) { + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); lnk->configure(); - attach(ssn->session, (pn_link_t*) lnk->sender); - pn_terminus_t* t = pn_link_remote_target(lnk->sender); - if (!pn_terminus_get_address(t)) { - std::string msg("No such target : "); - msg += lnk->getTarget(); - QPID_LOG(debug, msg); - throw qpid::messaging::NotFound(msg); - } else if (AddressImpl::isTemporary(lnk->address)) { - lnk->address.setName(pn_terminus_get_address(t)); - QPID_LOG(debug, "Dynamic target name set to " << lnk->address.getName()); - } - lnk->verify(t); + attach(ssn, lnk->sender); checkClosed(ssn, lnk); + lnk->verify(); QPID_LOG(debug, "Attach succeeded to " << lnk->getTarget()); } void ConnectionContext::attach(boost::shared_ptr<SessionContext> ssn, boost::shared_ptr<ReceiverContext> lnk) { + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); lnk->configure(); - attach(ssn->session, lnk->receiver, lnk->capacity); - pn_terminus_t* s = pn_link_remote_source(lnk->receiver); - if (!pn_terminus_get_address(s)) { - std::string msg("No such source : "); - msg += lnk->getSource(); - QPID_LOG(debug, msg); - throw qpid::messaging::NotFound(msg); - } else if (AddressImpl::isTemporary(lnk->address)) { - lnk->address.setName(pn_terminus_get_address(s)); - QPID_LOG(debug, "Dynamic source name set to " << lnk->address.getName()); - } - lnk->verify(s); + attach(ssn, lnk->receiver, lnk->capacity); checkClosed(ssn, lnk); + lnk->verify(); QPID_LOG(debug, "Attach succeeded from " << lnk->getSource()); } -void ConnectionContext::attach(pn_session_t* /*session*/, pn_link_t* link, int credit) +void ConnectionContext::attach(boost::shared_ptr<SessionContext> ssn, pn_link_t* link, int credit) { - qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); pn_link_open(link); QPID_LOG(debug, "Link attach sent for " << link << ", state=" << pn_link_state(link)); if (credit) pn_link_flow(link, credit); wakeupDriver(); while (pn_link_state(link) & PN_REMOTE_UNINIT) { QPID_LOG(debug, "Waiting for confirmation of link attach for " << link << ", state=" << pn_link_state(link) << "..."); - wait(); + wait(ssn); } } @@ -347,12 +297,12 @@ void ConnectionContext::send(boost::shared_ptr<SessionContext> ssn, boost::share qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); checkClosed(ssn); SenderContext::Delivery* delivery(0); - while (!(delivery = snd->send(message))) { + while (!snd->send(message, &delivery)) { QPID_LOG(debug, "Waiting for capacity..."); wait(ssn, snd);//wait for capacity } wakeupDriver(); - if (sync) { + if (sync && delivery) { while (!delivery->accepted()) { QPID_LOG(debug, "Waiting for confirmation..."); wait(ssn, snd);//wait until message has been confirmed @@ -427,10 +377,32 @@ pn_state_t REQUIRES_CLOSE = PN_LOCAL_ACTIVE | PN_REMOTE_CLOSED; pn_state_t IS_CLOSED = PN_LOCAL_CLOSED | PN_REMOTE_CLOSED; } +void ConnectionContext::reset() +{ + pn_transport_free(engine); + pn_connection_free(connection); + + engine = pn_transport(); + connection = pn_connection(); + pn_connection_set_container(connection, identifier.c_str()); + bool enableTrace(false); + QPID_LOG_TEST_CAT(trace, protocol, enableTrace); + if (enableTrace) pn_transport_trace(engine, PN_TRACE_FRM); + for (SessionMap::iterator i = sessions.begin(); i != sessions.end(); ++i) { + i->second->reset(connection); + } + pn_transport_bind(engine, connection); +} + void ConnectionContext::check() { if (state == DISCONNECTED) { - throw qpid::messaging::TransportFailure("Disconnected"); + if (ConnectionOptions::reconnect) { + reset(); + autoconnect(); + } else { + throw qpid::messaging::TransportFailure("Disconnected (reconnect disabled)"); + } } if ((pn_connection_state(connection) & REQUIRES_CLOSE) == REQUIRES_CLOSE) { pn_connection_close(connection); @@ -480,9 +452,17 @@ void ConnectionContext::waitUntil(boost::shared_ptr<SessionContext> ssn, boost:: } void ConnectionContext::checkClosed(boost::shared_ptr<SessionContext> ssn) { + check(); if ((pn_session_state(ssn->session) & REQUIRES_CLOSE) == REQUIRES_CLOSE) { + pn_condition_t* error = pn_session_remote_condition(ssn->session); + std::stringstream text; + if (pn_condition_is_set(error)) { + text << "Session ended by peer with " << pn_condition_get_name(error) << ": " << pn_condition_get_description(error); + } else { + text << "Session ended by peer"; + } pn_session_close(ssn->session); - throw qpid::messaging::SessionError("Session ended by peer"); + throw qpid::messaging::SessionError(text.str()); } else if ((pn_session_state(ssn->session) & IS_CLOSED) == IS_CLOSED) { throw qpid::messaging::SessionError("Session has ended"); } @@ -513,6 +493,31 @@ void ConnectionContext::checkClosed(boost::shared_ptr<SessionContext> ssn, pn_li throw qpid::messaging::LinkError("Link is not attached"); } } + +void ConnectionContext::restartSession(boost::shared_ptr<SessionContext> s) +{ + pn_session_open(s->session); + wakeupDriver(); + while (pn_session_state(s->session) & PN_REMOTE_UNINIT) { + wait(); + } + + for (SessionContext::SenderMap::iterator i = s->senders.begin(); i != s->senders.end(); ++i) { + QPID_LOG(debug, id << " reattaching sender " << i->first); + attach(s, i->second->sender); + i->second->verify(); + QPID_LOG(debug, id << " sender " << i->first << " reattached"); + i->second->resend(); + } + for (SessionContext::ReceiverMap::iterator i = s->receivers.begin(); i != s->receivers.end(); ++i) { + QPID_LOG(debug, id << " reattaching receiver " << i->first); + attach(s, i->second->receiver, i->second->capacity); + i->second->verify(); + QPID_LOG(debug, id << " receiver " << i->first << " reattached"); + } + wakeupDriver(); +} + boost::shared_ptr<SessionContext> ConnectionContext::newSession(bool transactional, const std::string& n) { qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); @@ -521,13 +526,14 @@ boost::shared_ptr<SessionContext> ConnectionContext::newSession(bool transaction SessionMap::const_iterator i = sessions.find(name); if (i == sessions.end()) { boost::shared_ptr<SessionContext> s(new SessionContext(connection)); + s->setName(name); s->session = pn_session(connection); pn_session_open(s->session); - sessions[name] = s; wakeupDriver(); while (pn_session_state(s->session) & PN_REMOTE_UNINIT) { wait(); } + sessions[name] = s; return s; } else { throw qpid::messaging::KeyError(std::string("Session already exists: ") + name); @@ -554,7 +560,7 @@ std::string ConnectionContext::getAuthenticatedUsername() return sasl.get() ? sasl->getAuthenticatedUsername() : std::string(); } -std::size_t ConnectionContext::decode(const char* buffer, std::size_t size) +std::size_t ConnectionContext::decodePlain(const char* buffer, std::size_t size) { qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); QPID_LOG(trace, id << " decode(" << size << ")"); @@ -584,7 +590,7 @@ std::size_t ConnectionContext::decode(const char* buffer, std::size_t size) } } -std::size_t ConnectionContext::encode(char* buffer, std::size_t size) +std::size_t ConnectionContext::encodePlain(char* buffer, std::size_t size) { qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); QPID_LOG(trace, id << " encode(" << size << ")"); @@ -611,7 +617,7 @@ std::size_t ConnectionContext::encode(char* buffer, std::size_t size) return 0; } } -bool ConnectionContext::canEncode() +bool ConnectionContext::canEncodePlain() { qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); return haveOutput && state == CONNECTED; @@ -685,47 +691,46 @@ bool ConnectionContext::useSasl() qpid::sys::Codec& ConnectionContext::getCodec() { - return codecSwitch; + return *this; } -ConnectionContext::CodecSwitch::CodecSwitch(ConnectionContext& p) : parent(p) {} -std::size_t ConnectionContext::CodecSwitch::decode(const char* buffer, std::size_t size) +std::size_t ConnectionContext::decode(const char* buffer, std::size_t size) { - qpid::sys::ScopedLock<qpid::sys::Monitor> l(parent.lock); + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); size_t decoded = 0; - if (parent.sasl.get() && !parent.sasl->authenticated()) { - decoded = parent.sasl->decode(buffer, size); - if (!parent.sasl->authenticated()) return decoded; + if (sasl.get() && !sasl->authenticated()) { + decoded = sasl->decode(buffer, size); + if (!sasl->authenticated()) return decoded; } if (decoded < size) { - if (parent.sasl.get() && parent.sasl->getSecurityLayer()) decoded += parent.sasl->getSecurityLayer()->decode(buffer+decoded, size-decoded); - else decoded += parent.decode(buffer+decoded, size-decoded); + if (sasl.get() && sasl->getSecurityLayer()) decoded += sasl->getSecurityLayer()->decode(buffer+decoded, size-decoded); + else decoded += decodePlain(buffer+decoded, size-decoded); } return decoded; } -std::size_t ConnectionContext::CodecSwitch::encode(char* buffer, std::size_t size) +std::size_t ConnectionContext::encode(char* buffer, std::size_t size) { - qpid::sys::ScopedLock<qpid::sys::Monitor> l(parent.lock); + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); size_t encoded = 0; - if (parent.sasl.get() && parent.sasl->canEncode()) { - encoded += parent.sasl->encode(buffer, size); - if (!parent.sasl->authenticated()) return encoded; + if (sasl.get() && sasl->canEncode()) { + encoded += sasl->encode(buffer, size); + if (!sasl->authenticated()) return encoded; } if (encoded < size) { - if (parent.sasl.get() && parent.sasl->getSecurityLayer()) encoded += parent.sasl->getSecurityLayer()->encode(buffer+encoded, size-encoded); - else encoded += parent.encode(buffer+encoded, size-encoded); + if (sasl.get() && sasl->getSecurityLayer()) encoded += sasl->getSecurityLayer()->encode(buffer+encoded, size-encoded); + else encoded += encodePlain(buffer+encoded, size-encoded); } return encoded; } -bool ConnectionContext::CodecSwitch::canEncode() +bool ConnectionContext::canEncode() { - qpid::sys::ScopedLock<qpid::sys::Monitor> l(parent.lock); - if (parent.sasl.get()) { - if (parent.sasl->canEncode()) return true; - else if (!parent.sasl->authenticated()) return false; - else if (parent.sasl->getSecurityLayer()) return parent.sasl->getSecurityLayer()->canEncode(); + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); + if (sasl.get()) { + if (sasl->canEncode()) return true; + else if (!sasl->authenticated()) return false; + else if (sasl->getSecurityLayer()) return sasl->getSecurityLayer()->canEncode(); } - return parent.canEncode(); + return canEncodePlain(); } namespace { @@ -742,10 +747,6 @@ pn_bytes_t convert(const std::string& s) } void ConnectionContext::setProperties() { - /** - * Enable when proton 0.5 is released and qpidc has been updated - * to use it - * pn_data_t* data = pn_connection_properties(connection); pn_data_put_map(data); pn_data_enter(data); @@ -760,7 +761,206 @@ void ConnectionContext::setProperties() pn_data_put_symbol(data, convert(CLIENT_PPID)); pn_data_put_int(data, sys::SystemInfo::getParentProcessId()); pn_data_exit(data); - **/ } +const qpid::sys::SecuritySettings* ConnectionContext::getTransportSecuritySettings() +{ + return transport ? transport->getSecuritySettings() : 0; +} + +void ConnectionContext::open() +{ + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); + if (state != DISCONNECTED) throw qpid::messaging::ConnectionError("Connection was already opened!"); + if (!driver) driver = DriverImpl::getDefault(); + + autoconnect(); +} + + +namespace { +std::string asString(const std::vector<std::string>& v) { + std::stringstream os; + os << "["; + for(std::vector<std::string>::const_iterator i = v.begin(); i != v.end(); ++i ) { + if (i != v.begin()) os << ", "; + os << *i; + } + os << "]"; + return os.str(); +} +double FOREVER(std::numeric_limits<double>::max()); +bool expired(const sys::AbsTime& start, double timeout) +{ + if (timeout == 0) return true; + if (timeout == FOREVER) return false; + qpid::sys::Duration used(start, qpid::sys::now()); + qpid::sys::Duration allowed((int64_t)(timeout*qpid::sys::TIME_SEC)); + return allowed < used; +} +const std::string COLON(":"); +} + +void ConnectionContext::autoconnect() +{ + qpid::sys::AbsTime started(qpid::sys::now()); + QPID_LOG(debug, "Starting connection, urls=" << asString(urls)); + for (double i = minReconnectInterval; !tryConnect(); i = std::min(i*2, maxReconnectInterval)) { + if (!ConnectionOptions::reconnect) { + throw qpid::messaging::TransportFailure("Failed to connect (reconnect disabled)"); + } + if (limit >= 0 && retries++ >= limit) { + throw qpid::messaging::TransportFailure("Failed to connect within reconnect limit"); + } + if (expired(started, timeout)) { + throw qpid::messaging::TransportFailure("Failed to connect within reconnect timeout"); + } + QPID_LOG(debug, "Connection retry in " << i*1000*1000 << " microseconds, urls=" + << asString(urls)); + qpid::sys::usleep(int64_t(i*1000*1000)); // Sleep in microseconds. + } + retries = 0; +} + +bool ConnectionContext::tryConnect() +{ + for (std::vector<std::string>::const_iterator i = urls.begin(); i != urls.end(); ++i) { + try { + QPID_LOG(info, "Trying to connect to " << *i << "..."); + if (tryConnect(qpid::Url(*i, protocol.empty() ? qpid::Address::TCP : protocol))) { + return true; + } + } catch (const qpid::messaging::TransportFailure& e) { + QPID_LOG(info, "Failed to connect to " << *i << ": " << e.what()); + } + } + return false; +} + +void ConnectionContext::reconnect(const std::string& url) +{ + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); + if (state != DISCONNECTED) throw qpid::messaging::ConnectionError("Connection was already opened!"); + if (!driver) driver = DriverImpl::getDefault(); + reset(); + if (!tryConnect(qpid::Url(url, protocol.empty() ? qpid::Address::TCP : protocol))) { + throw qpid::messaging::TransportFailure("Failed to connect"); + } +} + +void ConnectionContext::reconnect() +{ + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); + if (state != DISCONNECTED) throw qpid::messaging::ConnectionError("Connection was already opened!"); + if (!driver) driver = DriverImpl::getDefault(); + reset(); + if (!tryConnect()) { + throw qpid::messaging::TransportFailure("Failed to reconnect"); + } +} + +bool ConnectionContext::tryConnect(const Url& url) +{ + if (url.getUser().size()) username = url.getUser(); + if (url.getPass().size()) password = url.getPass(); + + for (Url::const_iterator i = url.begin(); i != url.end(); ++i) { + if (tryConnect(*i)) { + QPID_LOG(info, "Connected to " << *i); + setCurrentUrl(*i); + if (sasl.get()) { + wakeupDriver(); + while (!sasl->authenticated()) { + QPID_LOG(debug, id << " Waiting to be authenticated..."); + wait(); + } + QPID_LOG(debug, id << " Authenticated"); + } + + QPID_LOG(debug, id << " Opening..."); + setProperties(); + pn_connection_open(connection); + wakeupDriver(); //want to write + while (pn_connection_state(connection) & PN_REMOTE_UNINIT) { + wait(); + } + if (!(pn_connection_state(connection) & PN_REMOTE_ACTIVE)) { + throw qpid::messaging::ConnectionError("Failed to open connection"); + } + QPID_LOG(debug, id << " Opened"); + + return restartSessions(); + } + } + return false; +} + +void ConnectionContext::setCurrentUrl(const qpid::Address& a) +{ + std::stringstream u; + u << a; + currentUrl = u.str(); +} + +std::string ConnectionContext::getUrl() const +{ + qpid::sys::ScopedLock<qpid::sys::Monitor> l(lock); + if (state == CONNECTED) { + return currentUrl; + } else { + return std::string(); + } +} + + +bool ConnectionContext::tryConnect(const qpid::Address& address) +{ + transport = driver->getTransport(address.protocol, *this); + std::stringstream port; + port << address.port; + id = address.host + COLON + port.str(); + if (useSasl()) { + sasl = std::auto_ptr<Sasl>(new Sasl(id, *this, address.host)); + } + state = CONNECTING; + try { + QPID_LOG(debug, id << " Connecting ..."); + transport->connect(address.host, port.str()); + bool waiting(true); + while (waiting) { + switch (state) { + case CONNECTED: + QPID_LOG(debug, id << " Connected"); + return true; + case CONNECTING: + lock.wait(); + break; + case DISCONNECTED: + waiting = false; + QPID_LOG(debug, id << " Failed to connect"); + break; + } + } + } catch (const std::exception& e) { + QPID_LOG(info, id << " Error while connecting: " << e.what()); + state = DISCONNECTED; + } + transport = boost::shared_ptr<Transport>(); + return false; +} + +bool ConnectionContext::restartSessions() +{ + try { + for (SessionMap::iterator i = sessions.begin(); i != sessions.end(); ++i) { + restartSession(i->second); + } + return true; + } catch (const qpid::TransportFailure& e) { + QPID_LOG(debug, "Connection Failed to re-initialize sessions: " << e.what()); + return false; + } +} + + }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h index 37d73ea456..2fdba7a3b2 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h +++ b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.h @@ -44,6 +44,9 @@ namespace qpid { namespace framing { class ProtocolVersion; } +namespace sys { +struct SecuritySettings; +} namespace messaging { class Duration; class Message; @@ -72,6 +75,8 @@ class ConnectionContext : public qpid::sys::ConnectionCodec, public qpid::messag void endSession(boost::shared_ptr<SessionContext>); void attach(boost::shared_ptr<SessionContext>, boost::shared_ptr<SenderContext>); void attach(boost::shared_ptr<SessionContext>, boost::shared_ptr<ReceiverContext>); + void detach(boost::shared_ptr<SessionContext>, boost::shared_ptr<SenderContext>); + void detach(boost::shared_ptr<SessionContext>, boost::shared_ptr<ReceiverContext>); void send(boost::shared_ptr<SessionContext>, boost::shared_ptr<SenderContext> ctxt, const qpid::messaging::Message& message, bool sync); bool fetch(boost::shared_ptr<SessionContext> ssn, boost::shared_ptr<ReceiverContext> lnk, qpid::messaging::Message& message, qpid::messaging::Duration timeout); bool get(boost::shared_ptr<SessionContext> ssn, boost::shared_ptr<ReceiverContext> lnk, qpid::messaging::Message& message, qpid::messaging::Duration timeout); @@ -101,10 +106,13 @@ class ConnectionContext : public qpid::sys::ConnectionCodec, public qpid::messag framing::ProtocolVersion getVersion() const; //additionally, Transport needs: void opened();//signal successful connection + void reconnect(const std::string& url); + void reconnect(); + std::string getUrl() const; + const qpid::sys::SecuritySettings* getTransportSecuritySettings(); private: typedef std::map<std::string, boost::shared_ptr<SessionContext> > SessionMap; - qpid::Url url; boost::shared_ptr<DriverImpl> driver; boost::shared_ptr<Transport> transport; @@ -117,23 +125,13 @@ class ConnectionContext : public qpid::sys::ConnectionCodec, public qpid::messag bool readHeader; bool haveOutput; std::string id; + std::string currentUrl; enum { DISCONNECTED, CONNECTING, CONNECTED } state; std::auto_ptr<Sasl> sasl; - class CodecSwitch : public qpid::sys::Codec - { - public: - CodecSwitch(ConnectionContext&); - std::size_t decode(const char* buffer, std::size_t size); - std::size_t encode(char* buffer, std::size_t size); - bool canEncode(); - private: - ConnectionContext& parent; - }; - CodecSwitch codecSwitch; void check(); void wait(); @@ -149,7 +147,19 @@ class ConnectionContext : public qpid::sys::ConnectionCodec, public qpid::messag void checkClosed(boost::shared_ptr<SessionContext>, boost::shared_ptr<SenderContext>); void checkClosed(boost::shared_ptr<SessionContext>, pn_link_t*); void wakeupDriver(); - void attach(pn_session_t*, pn_link_t*, int credit=0); + void attach(boost::shared_ptr<SessionContext>, pn_link_t*, int credit=0); + void autoconnect(); + bool tryConnect(); + bool tryConnect(const qpid::Url& url); + bool tryConnect(const qpid::Address& address); + void reset(); + bool restartSessions(); + void restartSession(boost::shared_ptr<SessionContext>); + void setCurrentUrl(const qpid::Address&); + + std::size_t decodePlain(const char* buffer, std::size_t size); + std::size_t encodePlain(char* buffer, std::size_t size); + bool canEncodePlain(); std::size_t readProtocolHeader(const char* buffer, std::size_t size); std::size_t writeProtocolHeader(char* buffer, std::size_t size); diff --git a/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp b/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp index 0c4ec2bfcb..c1ab108a61 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp @@ -81,4 +81,17 @@ std::string ConnectionHandle::getAuthenticatedUsername() return connection->getAuthenticatedUsername(); } +void ConnectionHandle::reconnect(const std::string& url) +{ + connection->reconnect(url); +} +void ConnectionHandle::reconnect() +{ + connection->reconnect(); +} +std::string ConnectionHandle::getUrl() const +{ + return connection->getUrl(); +} + }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.h b/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.h index d1eb27f6de..0238313f93 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.h +++ b/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.h @@ -49,6 +49,9 @@ class ConnectionHandle : public qpid::messaging::ConnectionImpl Session getSession(const std::string& name) const; void setOption(const std::string& name, const qpid::types::Variant& value); std::string getAuthenticatedUsername(); + void reconnect(const std::string& url); + void reconnect(); + std::string getUrl() const; private: boost::shared_ptr<ConnectionContext> connection; }; diff --git a/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.cpp b/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.cpp index b4e0819980..266060c117 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.cpp @@ -22,26 +22,31 @@ #include "qpid/messaging/Address.h" #include "qpid/messaging/MessageImpl.h" #include "qpid/amqp/Decoder.h" +#include "qpid/amqp/DataBuilder.h" +#include "qpid/amqp/ListBuilder.h" +#include "qpid/amqp/MapBuilder.h" +#include "qpid/amqp/typecodes.h" +#include "qpid/types/encodings.h" +#include "qpid/log/Statement.h" #include <boost/lexical_cast.hpp> #include <string.h> namespace qpid { namespace messaging { namespace amqp { - using namespace qpid::amqp; -EncodedMessage::EncodedMessage(size_t s) : size(s), data(size ? new char[size] : 0) +EncodedMessage::EncodedMessage(size_t s) : size(s), data(size ? new char[size] : 0), nestAnnotations(false) { init(); } -EncodedMessage::EncodedMessage() : size(0), data(0) +EncodedMessage::EncodedMessage() : size(0), data(0), nestAnnotations(false) { init(); } -EncodedMessage::EncodedMessage(const EncodedMessage& other) : size(other.size), data(size ? new char[size] : 0) +EncodedMessage::EncodedMessage(const EncodedMessage& other) : size(other.size), data(size ? new char[size] : 0), nestAnnotations(false) { init(); } @@ -105,6 +110,8 @@ void EncodedMessage::init(qpid::messaging::MessageImpl& impl) } } +void EncodedMessage::setNestAnnotationsOption(bool b) { nestAnnotations = b; } + void EncodedMessage::populate(qpid::types::Variant::Map& map) const { //decode application properties @@ -139,14 +146,20 @@ void EncodedMessage::populate(qpid::types::Variant::Map& map) const } //add in any annotations if (deliveryAnnotations) { - qpid::types::Variant::Map& annotations = map["x-amqp-delivery-annotations"].asMap(); qpid::amqp::Decoder decoder(deliveryAnnotations.data, deliveryAnnotations.size); - decoder.readMap(annotations); + if (nestAnnotations) { + map["x-amqp-delivery-annotations"] = decoder.readMap(); + } else { + decoder.readMap(map); + } } if (messageAnnotations) { - qpid::types::Variant::Map& annotations = map["x-amqp-message-annotations"].asMap(); qpid::amqp::Decoder decoder(messageAnnotations.data, messageAnnotations.size); - decoder.readMap(annotations); + if (nestAnnotations) { + map["x-amqp-message-annotations"] = decoder.readMap(); + } else { + decoder.readMap(map); + } } } qpid::amqp::CharSequence EncodedMessage::getBareMessage() const @@ -178,9 +191,38 @@ void EncodedMessage::getCorrelationId(std::string& s) const { correlationId.assign(s); } -void EncodedMessage::getBody(std::string& s) const +void EncodedMessage::getBody(std::string& raw, qpid::types::Variant& c) const { - s.assign(body.data, body.size); + if (!content.isVoid()) { + c = content;//integer types, floats, bool etc + //TODO: populate raw data? + } else { + if (bodyType.empty() + || bodyType == qpid::amqp::typecodes::BINARY_NAME + || bodyType == qpid::types::encodings::UTF8 + || bodyType == qpid::types::encodings::ASCII) + { + c = std::string(body.data, body.size); + c.setEncoding(bodyType); + } else if (bodyType == qpid::amqp::typecodes::LIST_NAME) { + qpid::amqp::ListBuilder builder; + qpid::amqp::Decoder decoder(body.data, body.size); + decoder.read(builder); + c = builder.getList(); + raw.assign(body.data, body.size); + } else if (bodyType == qpid::amqp::typecodes::MAP_NAME) { + qpid::amqp::DataBuilder builder = qpid::amqp::DataBuilder(qpid::types::Variant::Map()); + qpid::amqp::Decoder decoder(body.data, body.size); + decoder.read(builder); + c = builder.getValue().asMap(); + raw.assign(body.data, body.size); + } else if (bodyType == qpid::amqp::typecodes::UUID_NAME) { + if (body.size == qpid::types::Uuid::SIZE) c = qpid::types::Uuid(body.data); + raw.assign(body.data, body.size); + } else if (bodyType == qpid::amqp::typecodes::ARRAY_NAME) { + raw.assign(body.data, body.size); + } + } } qpid::amqp::CharSequence EncodedMessage::getBody() const @@ -216,6 +258,7 @@ bool EncodedMessage::hasHeaderChanged(const qpid::messaging::MessageImpl& msg) c } + EncodedMessage::InitialScan::InitialScan(EncodedMessage& e, qpid::messaging::MessageImpl& m) : em(e), mi(m) { //set up defaults as needed: @@ -249,15 +292,35 @@ void EncodedMessage::InitialScan::onGroupId(const qpid::amqp::CharSequence& v) { void EncodedMessage::InitialScan::onGroupSequence(uint32_t i) { em.groupSequence = i; } void EncodedMessage::InitialScan::onReplyToGroupId(const qpid::amqp::CharSequence& v) { em.replyToGroupId = v; } -void EncodedMessage::InitialScan::onApplicationProperties(const qpid::amqp::CharSequence& v) { em.applicationProperties = v; } -void EncodedMessage::InitialScan::onDeliveryAnnotations(const qpid::amqp::CharSequence& v) { em.deliveryAnnotations = v; } -void EncodedMessage::InitialScan::onMessageAnnotations(const qpid::amqp::CharSequence& v) { em.messageAnnotations = v; } -void EncodedMessage::InitialScan::onBody(const qpid::amqp::CharSequence& v, const qpid::amqp::Descriptor&) +void EncodedMessage::InitialScan::onApplicationProperties(const qpid::amqp::CharSequence& v, const qpid::amqp::CharSequence&) { em.applicationProperties = v; } +void EncodedMessage::InitialScan::onDeliveryAnnotations(const qpid::amqp::CharSequence& v, const qpid::amqp::CharSequence&) { em.deliveryAnnotations = v; } +void EncodedMessage::InitialScan::onMessageAnnotations(const qpid::amqp::CharSequence& v, const qpid::amqp::CharSequence&) { em.messageAnnotations = v; } + +void EncodedMessage::InitialScan::onData(const qpid::amqp::CharSequence& v) +{ + em.body = v; +} +void EncodedMessage::InitialScan::onAmqpSequence(const qpid::amqp::CharSequence& v) { - //TODO: how to communicate the type, i.e. descriptor? em.body = v; + em.bodyType = qpid::amqp::typecodes::LIST_NAME; } -void EncodedMessage::InitialScan::onBody(const qpid::types::Variant&, const qpid::amqp::Descriptor&) {} -void EncodedMessage::InitialScan::onFooter(const qpid::amqp::CharSequence& v) { em.footer = v; } +void EncodedMessage::InitialScan::onAmqpValue(const qpid::amqp::CharSequence& v, const std::string& type) +{ + em.body = v; + if (type == qpid::amqp::typecodes::STRING_NAME) { + em.bodyType = qpid::types::encodings::UTF8; + } else if (type == qpid::amqp::typecodes::SYMBOL_NAME) { + em.bodyType = qpid::types::encodings::ASCII; + } else { + em.bodyType = type; + } +} +void EncodedMessage::InitialScan::onAmqpValue(const qpid::types::Variant& v) +{ + em.content = v; +} + +void EncodedMessage::InitialScan::onFooter(const qpid::amqp::CharSequence& v, const qpid::amqp::CharSequence&) { em.footer = v; } }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.h b/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.h index 09a9d948d5..16a43aecea 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.h +++ b/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.h @@ -21,6 +21,9 @@ * under the License. * */ + +#include "qpid/messaging/ImportExport.h" + #include "qpid/amqp/CharSequence.h" #include "qpid/amqp/MessageId.h" #include "qpid/amqp/MessageReader.h" @@ -71,34 +74,36 @@ namespace amqp { class EncodedMessage { public: - EncodedMessage(); - EncodedMessage(size_t); - EncodedMessage(const EncodedMessage&); - ~EncodedMessage(); + QPID_MESSAGING_EXTERN EncodedMessage(); + QPID_MESSAGING_EXTERN EncodedMessage(size_t); + QPID_MESSAGING_EXTERN EncodedMessage(const EncodedMessage&); + QPID_MESSAGING_EXTERN ~EncodedMessage(); - size_t getSize() const; - char* getData(); - const char* getData() const; - void trim(size_t); - void resize(size_t); + QPID_MESSAGING_EXTERN size_t getSize() const; + QPID_MESSAGING_EXTERN char* getData(); + QPID_MESSAGING_EXTERN const char* getData() const; + QPID_MESSAGING_EXTERN void trim(size_t); + QPID_MESSAGING_EXTERN void resize(size_t); + QPID_MESSAGING_EXTERN void setNestAnnotationsOption(bool); void getReplyTo(qpid::messaging::Address&) const; void getSubject(std::string&) const; void getContentType(std::string&) const; void getMessageId(std::string&) const; void getUserId(std::string&) const; void getCorrelationId(std::string&) const; - - void init(qpid::messaging::MessageImpl&); void populate(qpid::types::Variant::Map&) const; - void getBody(std::string&) const; - qpid::amqp::CharSequence getBareMessage() const; + void getBody(std::string&, qpid::types::Variant&) const; + + QPID_MESSAGING_EXTERN void init(qpid::messaging::MessageImpl&); + QPID_MESSAGING_EXTERN qpid::amqp::CharSequence getBareMessage() const; qpid::amqp::CharSequence getBody() const; - bool hasHeaderChanged(const qpid::messaging::MessageImpl&) const; + QPID_MESSAGING_EXTERN bool hasHeaderChanged(const qpid::messaging::MessageImpl&) const; private: size_t size; char* data; + bool nestAnnotations; class InitialScan : public qpid::amqp::MessageReader { @@ -127,12 +132,16 @@ class EncodedMessage void onGroupSequence(uint32_t); void onReplyToGroupId(const qpid::amqp::CharSequence&); - void onApplicationProperties(const qpid::amqp::CharSequence&); - void onDeliveryAnnotations(const qpid::amqp::CharSequence&); - void onMessageAnnotations(const qpid::amqp::CharSequence&); - void onBody(const qpid::amqp::CharSequence&, const qpid::amqp::Descriptor&); - void onBody(const qpid::types::Variant&, const qpid::amqp::Descriptor&); - void onFooter(const qpid::amqp::CharSequence&); + void onApplicationProperties(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence&); + void onDeliveryAnnotations(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence&); + void onMessageAnnotations(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence&); + + void onData(const qpid::amqp::CharSequence&); + void onAmqpSequence(const qpid::amqp::CharSequence&); + void onAmqpValue(const qpid::amqp::CharSequence&, const std::string& type); + void onAmqpValue(const qpid::types::Variant&); + + void onFooter(const qpid::amqp::CharSequence&, const qpid::amqp::CharSequence&); private: EncodedMessage& em; qpid::messaging::MessageImpl& mi; @@ -164,7 +173,11 @@ class EncodedMessage qpid::amqp::CharSequence replyToGroupId; //application-properties: qpid::amqp::CharSequence applicationProperties; + //application data: qpid::amqp::CharSequence body; + std::string bodyType; + qpid::types::Variant content; + //footer: qpid::amqp::CharSequence footer; diff --git a/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.cpp b/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.cpp index 081a0ae78b..473c120e27 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.cpp @@ -89,8 +89,18 @@ const std::string& ReceiverContext::getSource() const { return address.getName(); } -void ReceiverContext::verify(pn_terminus_t* source) +void ReceiverContext::verify() { + pn_terminus_t* source = pn_link_remote_source(receiver); + if (!pn_terminus_get_address(source)) { + std::string msg("No such source : "); + msg += getSource(); + QPID_LOG(debug, msg); + throw qpid::messaging::NotFound(msg); + } else if (AddressImpl::isTemporary(address)) { + address.setName(pn_terminus_get_address(source)); + QPID_LOG(debug, "Dynamic source name set to " << address.getName()); + } helper.checkAssertion(source, AddressHelper::FOR_RECEIVER); } void ReceiverContext::configure() @@ -99,7 +109,13 @@ void ReceiverContext::configure() } void ReceiverContext::configure(pn_terminus_t* source) { - helper.configure(source, AddressHelper::FOR_RECEIVER); + helper.configure(receiver, source, AddressHelper::FOR_RECEIVER); + std::string option; + if (helper.getLinkTarget(option)) { + pn_terminus_set_address(pn_link_target(receiver), option.c_str()); + } else { + pn_terminus_set_address(pn_link_target(receiver), pn_terminus_get_address(pn_link_source(receiver))); + } } Address ReceiverContext::getAddress() const @@ -112,6 +128,10 @@ bool ReceiverContext::isClosed() const return false;//TODO } - +void ReceiverContext::reset(pn_session_t* session) +{ + receiver = pn_receiver(session, name.c_str()); + configure(); +} }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.h b/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.h index 79049d9263..fb8ea0d336 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.h +++ b/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.h @@ -46,6 +46,7 @@ class ReceiverContext public: ReceiverContext(pn_session_t* session, const std::string& name, const qpid::messaging::Address& source); ~ReceiverContext(); + void reset(pn_session_t* session); void setCapacity(uint32_t); uint32_t getCapacity(); uint32_t getAvailable(); @@ -56,7 +57,7 @@ class ReceiverContext const std::string& getSource() const; bool isClosed() const; void configure(); - void verify(pn_terminus_t*); + void verify(); Address getAddress() const; private: friend class ConnectionContext; diff --git a/qpid/cpp/src/qpid/messaging/amqp/ReceiverHandle.cpp b/qpid/cpp/src/qpid/messaging/amqp/ReceiverHandle.cpp index c601d05ed0..177f47896b 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ReceiverHandle.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/ReceiverHandle.cpp @@ -84,7 +84,7 @@ uint32_t ReceiverHandle::getUnsettled() void ReceiverHandle::close() { - session->closeReceiver(getName()); + connection->detach(session, receiver); } const std::string& ReceiverHandle::getName() const diff --git a/qpid/cpp/src/qpid/messaging/amqp/Sasl.cpp b/qpid/cpp/src/qpid/messaging/amqp/Sasl.cpp index 40f469cdcf..4b21f7b0d2 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/Sasl.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/Sasl.cpp @@ -93,7 +93,7 @@ void Sasl::mechanisms(const std::string& offered) mechanisms = offered; } - if (sasl->start(mechanisms, response)) { + if (sasl->start(mechanisms, response, context.getTransportSecuritySettings())) { init(sasl->getMechanism(), &response, hostname.size() ? &hostname : 0); } else { init(sasl->getMechanism(), 0, hostname.size() ? &hostname : 0); diff --git a/qpid/cpp/src/qpid/messaging/amqp/SenderContext.cpp b/qpid/cpp/src/qpid/messaging/amqp/SenderContext.cpp index d4a5ca4292..94851da273 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/SenderContext.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/SenderContext.cpp @@ -42,7 +42,7 @@ SenderContext::SenderContext(pn_session_t* session, const std::string& n, const : name(n), address(a), helper(address), - sender(pn_sender(session, n.c_str())), capacity(1000) {} + sender(pn_sender(session, n.c_str())), capacity(1000), unreliable(helper.isUnreliable()) {} SenderContext::~SenderContext() { @@ -67,7 +67,7 @@ uint32_t SenderContext::getCapacity() uint32_t SenderContext::getUnsettled() { - return processUnsettled(); + return processUnsettled(true/*always allow retrieval of unsettled count, even if link has failed*/); } const std::string& SenderContext::getName() const @@ -80,16 +80,26 @@ const std::string& SenderContext::getTarget() const return address.getName(); } -SenderContext::Delivery* SenderContext::send(const qpid::messaging::Message& message) +bool SenderContext::send(const qpid::messaging::Message& message, SenderContext::Delivery** out) { - if (processUnsettled() < capacity && pn_link_credit(sender)) { - deliveries.push_back(Delivery(nextId++)); - Delivery& delivery = deliveries.back(); - delivery.encode(MessageImplAccess::get(message), address); - delivery.send(sender); - return &delivery; + resend();//if there are any messages needing to be resent at the front of the queue, send them first + if (processUnsettled(false) < capacity && pn_link_credit(sender)) { + if (unreliable) { + Delivery delivery(nextId++); + delivery.encode(MessageImplAccess::get(message), address); + delivery.send(sender, unreliable); + *out = 0; + return true; + } else { + deliveries.push_back(Delivery(nextId++)); + Delivery& delivery = deliveries.back(); + delivery.encode(MessageImplAccess::get(message), address); + delivery.send(sender, unreliable); + *out = &delivery; + return true; + } } else { - return 0; + return false; } } @@ -108,11 +118,13 @@ void SenderContext::check() } } -uint32_t SenderContext::processUnsettled() +uint32_t SenderContext::processUnsettled(bool silent) { - check(); + if (!silent) { + check(); + } //remove messages from front of deque once peer has confirmed receipt - while (!deliveries.empty() && deliveries.front().delivered()) { + while (!deliveries.empty() && deliveries.front().delivered() && !(pn_link_state(sender) & PN_REMOTE_CLOSED)) { deliveries.front().settle(); deliveries.pop_front(); } @@ -122,6 +134,7 @@ namespace { const std::string X_AMQP("x-amqp-"); const std::string X_AMQP_FIRST_ACQUIRER("x-amqp-first-acquirer"); const std::string X_AMQP_DELIVERY_COUNT("x-amqp-delivery-count"); +const std::string X_AMQP_0_10_APP_ID("x-amqp-0-10.app-id"); class HeaderAdapter : public qpid::amqp::MessageEncoder::Header { @@ -341,7 +354,7 @@ class ApplicationPropertiesAdapter : public qpid::amqp::MessageEncoder::Applicat { for (qpid::types::Variant::Map::const_iterator i = headers.begin(); i != headers.end(); ++i) { //strip out values with special keys as they are sent in standard fields - if (!startsWith(i->first, X_AMQP)) { + if (!startsWith(i->first, X_AMQP) || i->first == X_AMQP_0_10_APP_ID) { qpid::amqp::CharSequence key(convert(i->first)); switch (i->second.getType()) { case qpid::types::VAR_VOID: @@ -413,7 +426,12 @@ bool changedSubject(const qpid::messaging::MessageImpl& msg, const qpid::messagi } -SenderContext::Delivery::Delivery(int32_t i) : id(i), token(0) {} +SenderContext::Delivery::Delivery(int32_t i) : id(i), token(0), presettled(false) {} + +void SenderContext::Delivery::reset() +{ + token = 0; +} void SenderContext::Delivery::encode(const qpid::messaging::MessageImpl& msg, const qpid::messaging::Address& address) { @@ -440,7 +458,15 @@ void SenderContext::Delivery::encode(const qpid::messaging::MessageImpl& msg, co PropertiesAdapter properties(msg, address.getSubject()); ApplicationPropertiesAdapter applicationProperties(msg.getHeaders()); //compute size: - encoded.resize(qpid::amqp::MessageEncoder::getEncodedSize(header, properties, applicationProperties, msg.getBytes())); + size_t contentSize = qpid::amqp::MessageEncoder::getEncodedSize(header) + + qpid::amqp::MessageEncoder::getEncodedSize(properties) + + qpid::amqp::MessageEncoder::getEncodedSize(applicationProperties); + if (msg.getContent().isVoid()) { + contentSize += qpid::amqp::MessageEncoder::getEncodedSizeForContent(msg.getBytes()); + } else { + contentSize += qpid::amqp::MessageEncoder::getEncodedSizeForValue(msg.getContent()) + 3/*descriptor*/; + } + encoded.resize(contentSize); QPID_LOG(debug, "Sending message, buffer is " << encoded.getSize() << " bytes") qpid::amqp::MessageEncoder encoder(encoded.getData(), encoded.getSize()); //write header: @@ -451,7 +477,12 @@ void SenderContext::Delivery::encode(const qpid::messaging::MessageImpl& msg, co //write application-properties encoder.writeApplicationProperties(applicationProperties); //write body - if (msg.getBytes().size()) encoder.writeBinary(msg.getBytes(), &qpid::amqp::message::DATA);//structured content not yet directly supported + if (!msg.getContent().isVoid()) { + //write as AmqpValue + encoder.writeValue(msg.getContent(), &qpid::amqp::message::AMQP_VALUE); + } else if (msg.getBytes().size()) { + encoder.writeBinary(msg.getBytes(), &qpid::amqp::message::DATA);//structured content not yet directly supported + } if (encoder.getPosition() < encoded.getSize()) { QPID_LOG(debug, "Trimming buffer from " << encoded.getSize() << " to " << encoder.getPosition()); encoded.trim(encoder.getPosition()); @@ -459,19 +490,27 @@ void SenderContext::Delivery::encode(const qpid::messaging::MessageImpl& msg, co //write footer (no annotations yet supported) } } -void SenderContext::Delivery::send(pn_link_t* sender) +void SenderContext::Delivery::send(pn_link_t* sender, bool unreliable) { pn_delivery_tag_t tag; tag.size = sizeof(id); tag.bytes = reinterpret_cast<const char*>(&id); token = pn_delivery(sender, tag); pn_link_send(sender, encoded.getData(), encoded.getSize()); + if (unreliable) { + pn_delivery_settle(token); + presettled = true; + } pn_link_advance(sender); } +bool SenderContext::Delivery::sent() const +{ + return presettled || token; +} bool SenderContext::Delivery::delivered() { - if (pn_delivery_remote_state(token) || pn_delivery_settled(token)) { + if (presettled || (token && (pn_delivery_remote_state(token) || pn_delivery_settled(token)))) { //TODO: need a better means for signalling outcomes other than accepted if (rejected()) { QPID_LOG(warning, "delivery " << id << " was rejected by peer"); @@ -495,8 +534,19 @@ void SenderContext::Delivery::settle() { pn_delivery_settle(token); } -void SenderContext::verify(pn_terminus_t* target) +void SenderContext::verify() { + pn_terminus_t* target = pn_link_remote_target(sender); + if (!pn_terminus_get_address(target)) { + std::string msg("No such target : "); + msg += getTarget(); + QPID_LOG(debug, msg); + throw qpid::messaging::NotFound(msg); + } else if (AddressImpl::isTemporary(address)) { + address.setName(pn_terminus_get_address(target)); + QPID_LOG(debug, "Dynamic target name set to " << address.getName()); + } + helper.checkAssertion(target, AddressHelper::FOR_SENDER); } void SenderContext::configure() @@ -505,12 +555,18 @@ void SenderContext::configure() } void SenderContext::configure(pn_terminus_t* target) { - helper.configure(target, AddressHelper::FOR_SENDER); + helper.configure(sender, target, AddressHelper::FOR_SENDER); + std::string option; + if (helper.getLinkSource(option)) { + pn_terminus_set_address(pn_link_source(sender), option.c_str()); + } else { + pn_terminus_set_address(pn_link_source(sender), pn_terminus_get_address(pn_link_target(sender))); + } } bool SenderContext::settled() { - return processUnsettled() == 0; + return processUnsettled(false) == 0; } Address SenderContext::getAddress() const @@ -518,4 +574,22 @@ Address SenderContext::getAddress() const return address; } + +void SenderContext::reset(pn_session_t* session) +{ + sender = pn_sender(session, name.c_str()); + configure(); + + for (Deliveries::iterator i = deliveries.begin(); i != deliveries.end(); ++i) { + i->reset(); + } +} + +void SenderContext::resend() +{ + for (Deliveries::iterator i = deliveries.begin(); i != deliveries.end() && pn_link_credit(sender) && !i->sent(); ++i) { + i->send(sender, false/*only resend reliable transfers*/); + } +} + }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/SenderContext.h b/qpid/cpp/src/qpid/messaging/amqp/SenderContext.h index e389cd2e35..27ffa1e81b 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/SenderContext.h +++ b/qpid/cpp/src/qpid/messaging/amqp/SenderContext.h @@ -52,28 +52,32 @@ class SenderContext public: Delivery(int32_t id); void encode(const qpid::messaging::MessageImpl& message, const qpid::messaging::Address&); - void send(pn_link_t*); + void send(pn_link_t*, bool unreliable); bool delivered(); bool accepted(); bool rejected(); void settle(); + void reset(); + bool sent() const; private: int32_t id; pn_delivery_t* token; EncodedMessage encoded; + bool presettled; }; SenderContext(pn_session_t* session, const std::string& name, const qpid::messaging::Address& target); ~SenderContext(); + void reset(pn_session_t* session); void close(); void setCapacity(uint32_t); uint32_t getCapacity(); uint32_t getUnsettled(); const std::string& getName() const; const std::string& getTarget() const; - Delivery* send(const qpid::messaging::Message& message); + bool send(const qpid::messaging::Message& message, Delivery**); void configure(); - void verify(pn_terminus_t*); + void verify(); void check(); bool settled(); Address getAddress() const; @@ -88,9 +92,11 @@ class SenderContext int32_t nextId; Deliveries deliveries; uint32_t capacity; + bool unreliable; - uint32_t processUnsettled(); + uint32_t processUnsettled(bool silent); void configure(pn_terminus_t*); + void resend(); }; }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/SenderHandle.cpp b/qpid/cpp/src/qpid/messaging/amqp/SenderHandle.cpp index cda8c032aa..367db701cb 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/SenderHandle.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/SenderHandle.cpp @@ -44,7 +44,7 @@ void SenderHandle::send(const Message& message, bool sync) void SenderHandle::close() { - session->closeSender(getName()); + connection->detach(session, sender); } void SenderHandle::setCapacity(uint32_t capacity) diff --git a/qpid/cpp/src/qpid/messaging/amqp/SessionContext.cpp b/qpid/cpp/src/qpid/messaging/amqp/SessionContext.cpp index 9815721fa0..8f2a7d15d8 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/SessionContext.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/SessionContext.cpp @@ -79,14 +79,14 @@ boost::shared_ptr<ReceiverContext> SessionContext::getReceiver(const std::string } } -void SessionContext::closeReceiver(const std::string&) +void SessionContext::removeReceiver(const std::string& n) { - + receivers.erase(n); } -void SessionContext::closeSender(const std::string&) +void SessionContext::removeSender(const std::string& n) { - + senders.erase(n); } boost::shared_ptr<ReceiverContext> SessionContext::nextReceiver(qpid::messaging::Duration /*timeout*/) @@ -153,4 +153,25 @@ bool SessionContext::settled() } return result; } + +void SessionContext::setName(const std::string& n) +{ + name = n; +} +std::string SessionContext::getName() const +{ + return name; +} + +void SessionContext::reset(pn_connection_t* connection) +{ + session = pn_session(connection); + unacked.clear(); + for (SessionContext::SenderMap::iterator i = senders.begin(); i != senders.end(); ++i) { + i->second->reset(session); + } + for (SessionContext::ReceiverMap::iterator i = receivers.begin(); i != receivers.end(); ++i) { + i->second->reset(session); + } +} }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/SessionContext.h b/qpid/cpp/src/qpid/messaging/amqp/SessionContext.h index eca30a0e97..5d68f6d8de 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/SessionContext.h +++ b/qpid/cpp/src/qpid/messaging/amqp/SessionContext.h @@ -50,16 +50,19 @@ class SessionContext public: SessionContext(pn_connection_t*); ~SessionContext(); + void reset(pn_connection_t*); boost::shared_ptr<SenderContext> createSender(const qpid::messaging::Address& address); boost::shared_ptr<ReceiverContext> createReceiver(const qpid::messaging::Address& address); boost::shared_ptr<SenderContext> getSender(const std::string& name) const; boost::shared_ptr<ReceiverContext> getReceiver(const std::string& name) const; - void closeReceiver(const std::string&); - void closeSender(const std::string&); + void removeReceiver(const std::string&); + void removeSender(const std::string&); boost::shared_ptr<ReceiverContext> nextReceiver(qpid::messaging::Duration timeout); uint32_t getReceivable(); uint32_t getUnsettledAcks(); bool settled(); + void setName(const std::string&); + std::string getName() const; private: friend class ConnectionContext; typedef std::map<std::string, boost::shared_ptr<SenderContext> > SenderMap; @@ -70,6 +73,7 @@ class SessionContext ReceiverMap receivers; DeliveryMap unacked; qpid::framing::SequenceNumber next; + std::string name; qpid::framing::SequenceNumber record(pn_delivery_t*); void acknowledge(); diff --git a/qpid/cpp/src/qpid/messaging/amqp/SessionHandle.cpp b/qpid/cpp/src/qpid/messaging/amqp/SessionHandle.cpp index bf79771ca4..45635e4ced 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/SessionHandle.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/SessionHandle.cpp @@ -84,15 +84,25 @@ void SessionHandle::sync(bool /*block*/) qpid::messaging::Sender SessionHandle::createSender(const qpid::messaging::Address& address) { boost::shared_ptr<SenderContext> sender = session->createSender(address); - connection->attach(session, sender); - return qpid::messaging::Sender(new SenderHandle(connection, session, sender)); + try { + connection->attach(session, sender); + return qpid::messaging::Sender(new SenderHandle(connection, session, sender)); + } catch (...) { + session->removeSender(sender->getName()); + throw; + } } qpid::messaging::Receiver SessionHandle::createReceiver(const qpid::messaging::Address& address) { boost::shared_ptr<ReceiverContext> receiver = session->createReceiver(address); - connection->attach(session, receiver); - return qpid::messaging::Receiver(new ReceiverHandle(connection, session, receiver)); + try { + connection->attach(session, receiver); + return qpid::messaging::Receiver(new ReceiverHandle(connection, session, receiver)); + } catch (...) { + session->removeReceiver(receiver->getName()); + throw; + } } bool SessionHandle::nextReceiver(Receiver& receiver, Duration timeout) diff --git a/qpid/cpp/src/qpid/messaging/amqp/SslTransport.cpp b/qpid/cpp/src/qpid/messaging/amqp/SslTransport.cpp index ea2375cb26..a62a553d90 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/SslTransport.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/SslTransport.cpp @@ -157,4 +157,11 @@ void SslTransport::activateOutput() if (aio) aio->notifyPendingWrite(); } +const qpid::sys::SecuritySettings* SslTransport::getSecuritySettings() +{ + securitySettings.ssf = socket.getKeyLen(); + securitySettings.authid = "dummy";//set to non-empty string to enable external authentication + return &securitySettings; +} + }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/SslTransport.h b/qpid/cpp/src/qpid/messaging/amqp/SslTransport.h index aad82c2c2a..2972be4fac 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/SslTransport.h +++ b/qpid/cpp/src/qpid/messaging/amqp/SslTransport.h @@ -23,6 +23,7 @@ */ #include "qpid/messaging/amqp/Transport.h" #include "qpid/sys/Mutex.h" +#include "qpid/sys/SecuritySettings.h" #include "qpid/sys/ssl/SslSocket.h" #include <boost/shared_ptr.hpp> @@ -50,6 +51,7 @@ class SslTransport : public Transport void abort(); void connectionEstablished() {}; void close(); + const qpid::sys::SecuritySettings* getSecuritySettings(); private: qpid::sys::ssl::SslSocket socket; @@ -59,6 +61,7 @@ class SslTransport : public Transport boost::shared_ptr<qpid::sys::Poller> poller; bool closed; std::string id; + qpid::sys::SecuritySettings securitySettings; void connected(const qpid::sys::Socket&); void failed(const std::string& msg); diff --git a/qpid/cpp/src/qpid/messaging/amqp/TcpTransport.cpp b/qpid/cpp/src/qpid/messaging/amqp/TcpTransport.cpp index 98022d634c..c0a9560c6f 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/TcpTransport.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/TcpTransport.cpp @@ -159,4 +159,8 @@ void TcpTransport::activateOutput() if (aio) aio->notifyPendingWrite(); } +const qpid::sys::SecuritySettings* TcpTransport::getSecuritySettings() +{ + return 0; +} }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/TcpTransport.h b/qpid/cpp/src/qpid/messaging/amqp/TcpTransport.h index d7adf64f3e..406791417c 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/TcpTransport.h +++ b/qpid/cpp/src/qpid/messaging/amqp/TcpTransport.h @@ -50,6 +50,7 @@ class TcpTransport : public Transport void abort(); void connectionEstablished() {}; void close(); + const qpid::sys::SecuritySettings* getSecuritySettings(); private: boost::scoped_ptr<qpid::sys::Socket> socket; diff --git a/qpid/cpp/src/qpid/messaging/amqp/Transport.h b/qpid/cpp/src/qpid/messaging/amqp/Transport.h index ee021f645b..159916f9ae 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/Transport.h +++ b/qpid/cpp/src/qpid/messaging/amqp/Transport.h @@ -21,12 +21,14 @@ * under the License. * */ +#include "qpid/CommonImportExport.h" #include "qpid/sys/OutputControl.h" #include <boost/shared_ptr.hpp> namespace qpid { namespace sys { class Poller; +struct SecuritySettings; } namespace messaging { namespace amqp { @@ -38,10 +40,11 @@ class Transport : public qpid::sys::OutputControl virtual ~Transport() {} virtual void connect(const std::string& host, const std::string& port) = 0; virtual void close() = 0; + virtual const qpid::sys::SecuritySettings* getSecuritySettings() = 0; typedef Transport* Factory(TransportContext&, boost::shared_ptr<qpid::sys::Poller>); - static Transport* create(const std::string& name, TransportContext&, boost::shared_ptr<qpid::sys::Poller>); - static void add(const std::string& name, Factory* factory); + QPID_COMMON_EXTERN static Transport* create(const std::string& name, TransportContext&, boost::shared_ptr<qpid::sys::Poller>); + QPID_COMMON_EXTERN static void add(const std::string& name, Factory* factory); }; }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/store/CMakeLists.txt b/qpid/cpp/src/qpid/store/CMakeLists.txt index 31623f8e84..094ae9d5d0 100644 --- a/qpid/cpp/src/qpid/store/CMakeLists.txt +++ b/qpid/cpp/src/qpid/store/CMakeLists.txt @@ -32,7 +32,7 @@ set (store_SOURCES MessageStorePlugin.cpp ) add_library (store MODULE ${store_SOURCES}) -target_link_libraries (store qpidbroker ${Boost_PROGRAM_OPTIONS_LIBRARY}) +target_link_libraries (store qpidbroker qpidcommon ${Boost_PROGRAM_OPTIONS_LIBRARY}) if (CMAKE_COMPILER_IS_GNUCXX) set (GCC_CATCH_UNDEFINED "-Wl,--no-undefined") # gcc on SunOS uses native linker whose "-z defs" is too fussy diff --git a/qpid/cpp/src/qpid/store/ms-clfs/MSSqlClfsProvider.cpp b/qpid/cpp/src/qpid/store/ms-clfs/MSSqlClfsProvider.cpp index 90785263d3..512e71230b 100644 --- a/qpid/cpp/src/qpid/store/ms-clfs/MSSqlClfsProvider.cpp +++ b/qpid/cpp/src/qpid/store/ms-clfs/MSSqlClfsProvider.cpp @@ -34,7 +34,6 @@ #include <qpid/store/StorageProvider.h> #include <qpid/sys/Mutex.h> #include <boost/foreach.hpp> -#include <boost/make_shared.hpp> // From ms-sql... #include "BlobAdapter.h" @@ -356,7 +355,7 @@ MSSqlClfsProvider::finalizeMe() MSSqlClfsProvider::MSSqlClfsProvider() : options("MS SQL/CLFS Provider options") { - transactions = boost::make_shared<TransactionLog>(); + transactions.reset(new TransactionLog()); } MSSqlClfsProvider::~MSSqlClfsProvider() diff --git a/qpid/cpp/include/qpid/sys/Condition.h b/qpid/cpp/src/qpid/sys/Condition.h index 9be4b357fe..9be4b357fe 100644 --- a/qpid/cpp/include/qpid/sys/Condition.h +++ b/qpid/cpp/src/qpid/sys/Condition.h diff --git a/qpid/cpp/include/qpid/sys/ExceptionHolder.h b/qpid/cpp/src/qpid/sys/ExceptionHolder.h index 4bc934cf75..4bc934cf75 100644 --- a/qpid/cpp/include/qpid/sys/ExceptionHolder.h +++ b/qpid/cpp/src/qpid/sys/ExceptionHolder.h diff --git a/qpid/cpp/include/qpid/sys/IOHandle.h b/qpid/cpp/src/qpid/sys/IOHandle.h index 06ae65f879..06ae65f879 100644 --- a/qpid/cpp/include/qpid/sys/IOHandle.h +++ b/qpid/cpp/src/qpid/sys/IOHandle.h diff --git a/qpid/cpp/include/qpid/sys/Monitor.h b/qpid/cpp/src/qpid/sys/Monitor.h index 123bf92dcb..123bf92dcb 100644 --- a/qpid/cpp/include/qpid/sys/Monitor.h +++ b/qpid/cpp/src/qpid/sys/Monitor.h diff --git a/qpid/cpp/include/qpid/sys/Mutex.h b/qpid/cpp/src/qpid/sys/Mutex.h index e718586a39..e718586a39 100644 --- a/qpid/cpp/include/qpid/sys/Mutex.h +++ b/qpid/cpp/src/qpid/sys/Mutex.h diff --git a/qpid/cpp/include/qpid/sys/Runnable.h b/qpid/cpp/src/qpid/sys/Runnable.h index fed7663cb6..fed7663cb6 100644 --- a/qpid/cpp/include/qpid/sys/Runnable.h +++ b/qpid/cpp/src/qpid/sys/Runnable.h diff --git a/qpid/cpp/include/qpid/sys/StrError.h b/qpid/cpp/src/qpid/sys/StrError.h index 36489dd0fc..36489dd0fc 100644 --- a/qpid/cpp/include/qpid/sys/StrError.h +++ b/qpid/cpp/src/qpid/sys/StrError.h diff --git a/qpid/cpp/include/qpid/sys/SystemInfo.h b/qpid/cpp/src/qpid/sys/SystemInfo.h index 1b5720a5f0..1b5720a5f0 100644 --- a/qpid/cpp/include/qpid/sys/SystemInfo.h +++ b/qpid/cpp/src/qpid/sys/SystemInfo.h diff --git a/qpid/cpp/include/qpid/sys/Thread.h b/qpid/cpp/src/qpid/sys/Thread.h index f556612908..f556612908 100644 --- a/qpid/cpp/include/qpid/sys/Thread.h +++ b/qpid/cpp/src/qpid/sys/Thread.h diff --git a/qpid/cpp/include/qpid/sys/Time.h b/qpid/cpp/src/qpid/sys/Time.h index 2ccff92e7c..2ccff92e7c 100644 --- a/qpid/cpp/include/qpid/sys/Time.h +++ b/qpid/cpp/src/qpid/sys/Time.h diff --git a/qpid/cpp/include/qpid/sys/posix/Condition.h b/qpid/cpp/src/qpid/sys/posix/Condition.h index 36e7557ffd..36e7557ffd 100644 --- a/qpid/cpp/include/qpid/sys/posix/Condition.h +++ b/qpid/cpp/src/qpid/sys/posix/Condition.h diff --git a/qpid/cpp/include/qpid/sys/posix/Mutex.h b/qpid/cpp/src/qpid/sys/posix/Mutex.h index e2b21b5a56..e2b21b5a56 100644 --- a/qpid/cpp/include/qpid/sys/posix/Mutex.h +++ b/qpid/cpp/src/qpid/sys/posix/Mutex.h diff --git a/qpid/cpp/include/qpid/sys/posix/PrivatePosix.h b/qpid/cpp/src/qpid/sys/posix/PrivatePosix.h index 0f59fe3176..0f59fe3176 100644 --- a/qpid/cpp/include/qpid/sys/posix/PrivatePosix.h +++ b/qpid/cpp/src/qpid/sys/posix/PrivatePosix.h diff --git a/qpid/cpp/include/qpid/sys/posix/Time.h b/qpid/cpp/src/qpid/sys/posix/Time.h index 62d734c816..62d734c816 100755 --- a/qpid/cpp/include/qpid/sys/posix/Time.h +++ b/qpid/cpp/src/qpid/sys/posix/Time.h diff --git a/qpid/cpp/include/qpid/sys/posix/check.h b/qpid/cpp/src/qpid/sys/posix/check.h index 1bfe5d6d78..1bfe5d6d78 100644 --- a/qpid/cpp/include/qpid/sys/posix/check.h +++ b/qpid/cpp/src/qpid/sys/posix/check.h diff --git a/qpid/cpp/include/qpid/sys/windows/Condition.h b/qpid/cpp/src/qpid/sys/windows/Condition.h index cd5aebbf09..cd5aebbf09 100755 --- a/qpid/cpp/include/qpid/sys/windows/Condition.h +++ b/qpid/cpp/src/qpid/sys/windows/Condition.h diff --git a/qpid/cpp/include/qpid/sys/windows/Mutex.h b/qpid/cpp/src/qpid/sys/windows/Mutex.h index 5dcc69e836..5dcc69e836 100755 --- a/qpid/cpp/include/qpid/sys/windows/Mutex.h +++ b/qpid/cpp/src/qpid/sys/windows/Mutex.h diff --git a/qpid/cpp/include/qpid/sys/windows/Time.h b/qpid/cpp/src/qpid/sys/windows/Time.h index 2987b1c8b2..2987b1c8b2 100644 --- a/qpid/cpp/include/qpid/sys/windows/Time.h +++ b/qpid/cpp/src/qpid/sys/windows/Time.h diff --git a/qpid/cpp/include/qpid/sys/windows/check.h b/qpid/cpp/src/qpid/sys/windows/check.h index 2a8e439bed..2a8e439bed 100755 --- a/qpid/cpp/include/qpid/sys/windows/check.h +++ b/qpid/cpp/src/qpid/sys/windows/check.h diff --git a/qpid/cpp/src/qpid/types/Uuid.cpp b/qpid/cpp/src/qpid/types/Uuid.cpp index 1d6fbf430a..875e5925a9 100644 --- a/qpid/cpp/src/qpid/types/Uuid.cpp +++ b/qpid/cpp/src/qpid/types/Uuid.cpp @@ -52,6 +52,11 @@ Uuid::Uuid(const unsigned char* uuid) ::memcpy(bytes, uuid, Uuid::SIZE); } +Uuid::Uuid(const char* uuid) +{ + ::memcpy(bytes, uuid, Uuid::SIZE); +} + Uuid& Uuid::operator=(const Uuid& other) { if (this == &other) return *this; diff --git a/qpid/cpp/src/qpid/types/Variant.cpp b/qpid/cpp/src/qpid/types/Variant.cpp index 7a5f36851a..292bb5ef09 100644 --- a/qpid/cpp/src/qpid/types/Variant.cpp +++ b/qpid/cpp/src/qpid/types/Variant.cpp @@ -36,6 +36,7 @@ const std::string PREFIX("invalid conversion: "); } InvalidConversion::InvalidConversion(const std::string& msg) : Exception(PREFIX + msg) {} +InvalidConversion::~InvalidConversion() throw() {} class VariantImpl { diff --git a/qpid/cpp/src/qpid/types/encodings.h b/qpid/cpp/src/qpid/types/encodings.h new file mode 100644 index 0000000000..827b6964b9 --- /dev/null +++ b/qpid/cpp/src/qpid/types/encodings.h @@ -0,0 +1,33 @@ +#ifndef QPID_TYPES_ENCODINGS_H +#define QPID_TYPES_ENCODINGS_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. + * + */ +namespace qpid { +namespace types { +namespace encodings { +const std::string BINARY("binary"); +const std::string UTF8("utf8"); +const std::string ASCII("ascii"); +} +}} // namespace qpid::types + +#endif /*!QPID_TYPES_ENCODINGS_H*/ diff --git a/qpid/cpp/src/qpid/xml/XmlExchange.cpp b/qpid/cpp/src/qpid/xml/XmlExchange.cpp index 29ab859591..3802ec5f7f 100644 --- a/qpid/cpp/src/qpid/xml/XmlExchange.cpp +++ b/qpid/cpp/src/qpid/xml/XmlExchange.cpp @@ -372,6 +372,8 @@ bool XmlExchange::isBound(Queue::shared_ptr queue, const std::string* const bind XmlExchange::~XmlExchange() { + if (mgmtExchange != 0) + mgmtExchange->debugStats("destroying"); bindingsMap.clear(); } diff --git a/qpid/cpp/src/rdma.cmake b/qpid/cpp/src/rdma.cmake index 8c019020f1..7c0ec66bf9 100644 --- a/qpid/cpp/src/rdma.cmake +++ b/qpid/cpp/src/rdma.cmake @@ -78,7 +78,7 @@ if (BUILD_RDMA) COMPONENT ${QPID_COMPONENT_COMMON}) add_library (rdma MODULE qpid/sys/RdmaIOPlugin.cpp) - target_link_libraries (rdma qpidbroker rdmawrap) + target_link_libraries (rdma qpidbroker qpidcommon rdmawrap) set_target_properties (rdma PROPERTIES COMPILE_DEFINITIONS _IN_QPID_BROKER LINK_FLAGS "${CATCH_UNDEFINED}" @@ -94,7 +94,7 @@ if (BUILD_RDMA) COMPONENT ${QPID_COMPONENT_BROKER}) add_library (rdmaconnector MODULE qpid/client/RdmaConnector.cpp) - target_link_libraries (rdmaconnector qpidclient rdmawrap) + target_link_libraries (rdmaconnector qpidclient qpidcommon rdmawrap) set_target_properties (rdmaconnector PROPERTIES LINK_FLAGS "${CATCH_UNDEFINED}" PREFIX "") diff --git a/qpid/cpp/src/ssl.mk b/qpid/cpp/src/ssl.mk deleted file mode 100644 index 9a92c7abc7..0000000000 --- a/qpid/cpp/src/ssl.mk +++ /dev/null @@ -1,47 +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. -# -# -# Makefile fragment, conditionally included in Makefile.am -# -libqpidcommon_la_SOURCES += \ - qpid/sys/ssl/check.h \ - qpid/sys/ssl/check.cpp \ - qpid/sys/ssl/util.h \ - qpid/sys/ssl/util.cpp \ - qpid/sys/ssl/SslSocket.h \ - qpid/sys/ssl/SslSocket.cpp - -libqpidcommon_la_LIBADD += -lnss3 -lssl3 -lnspr4 -libqpidcommon_la_CXXFLAGS += $(SSL_CFLAGS) - -libqpidbroker_la_SOURCES += \ - qpid/sys/SslPlugin.cpp - -libqpidbroker_la_CXXFLAGS += $(SSL_CFLAGS) - -libqpidclient_la_SOURCES += \ - qpid/client/SslConnector.cpp - -libqpidclient_la_CXXFLAGS += $(SSL_CFLAGS) - -if HAVE_PROTON -libqpidclient_la_SOURCES += \ - qpid/messaging/amqp/SslTransport.cpp \ - qpid/messaging/amqp/SslTransport.h -endif #HAVE_PROTON diff --git a/qpid/cpp/src/tests/BrokerFixture.h b/qpid/cpp/src/tests/BrokerFixture.h index bc23867ee1..b7b0f9d34b 100644 --- a/qpid/cpp/src/tests/BrokerFixture.h +++ b/qpid/cpp/src/tests/BrokerFixture.h @@ -42,11 +42,45 @@ namespace tests { struct BrokerFixture : private boost::noncopyable { typedef qpid::broker::Broker Broker; typedef boost::intrusive_ptr<Broker> BrokerPtr; + typedef std::vector<std::string> Args; BrokerPtr broker; + uint16_t port; qpid::sys::Thread brokerThread; - BrokerFixture(Broker::Options opts=Broker::Options(), bool enableMgmt=false) { + BrokerFixture(const Args& args=Args(), const Broker::Options& opts=Broker::Options(), + bool isExternalPort_=false, uint16_t externalPort_=0) + { + init(args, opts, isExternalPort_, externalPort_); + } + + BrokerFixture(const Broker::Options& opts, + bool isExternalPort_=false, uint16_t externalPort_=0) + { + init(Args(), opts, isExternalPort_, externalPort_); + } + + void shutdownBroker() { + if (broker) { + broker->shutdown(); + brokerThread.join(); + broker = BrokerPtr(); + } + } + + ~BrokerFixture() { shutdownBroker(); } + + /** Open a connection to the broker. */ + void open(qpid::client::Connection& c) { + c.open("localhost", getPort()); + } + + uint16_t getPort() { return port; } + + private: + void init(const Args& args, Broker::Options opts, + bool isExternalPort=false, uint16_t externalPort=0) + { // Keep the tests quiet unless logging env. vars have been set by user. if (!::getenv("QPID_LOG_ENABLE") && !::getenv("QPID_TRACE")) { qpid::log::Options logOpts; @@ -55,38 +89,28 @@ struct BrokerFixture : private boost::noncopyable { logOpts.selectors.push_back("error+"); qpid::log::Logger::instance().configure(logOpts); } + // Default options, may be over-ridden when we parse args. opts.port=0; opts.listenInterfaces.push_back("127.0.0.1"); - // Management doesn't play well with multiple in-process brokers. - opts.enableMgmt=enableMgmt; opts.workerThreads=1; opts.dataDir=""; opts.auth=false; + + // Argument parsing + std::vector<const char*> argv(args.size()); + std::transform(args.begin(), args.end(), argv.begin(), + boost::bind(&std::string::c_str, _1)); + Plugin::addOptions(opts); + opts.parse(argv.size(), &argv[0]); broker = Broker::create(opts); // TODO aconway 2007-12-05: At one point BrokerFixture // tests could hang in Connection ctor if the following // line is removed. This may not be an issue anymore. broker->accept(); - broker->getPort(qpid::broker::Broker::TCP_TRANSPORT); + if (isExternalPort) port = externalPort; + else port = broker->getPort(qpid::broker::Broker::TCP_TRANSPORT); brokerThread = qpid::sys::Thread(*broker); }; - - void shutdownBroker() { - if (broker) { - broker->shutdown(); - brokerThread.join(); - broker = BrokerPtr(); - } - } - - ~BrokerFixture() { shutdownBroker(); } - - /** Open a connection to the broker. */ - void open(qpid::client::Connection& c) { - c.open("localhost", broker->getPort(qpid::broker::Broker::TCP_TRANSPORT)); - } - - uint16_t getPort() { return broker->getPort(qpid::broker::Broker::TCP_TRANSPORT); } }; /** Connection that opens in its constructor */ @@ -125,8 +149,8 @@ template <class ConnectionType, class SessionType=qpid::client::Session> struct SessionFixtureT : BrokerFixture, ClientT<ConnectionType,SessionType> { SessionFixtureT(Broker::Options opts=Broker::Options()) : - BrokerFixture(opts), - ClientT<ConnectionType,SessionType>(broker->getPort(qpid::broker::Broker::TCP_TRANSPORT)) + BrokerFixture(BrokerFixture::Args(), opts), + ClientT<ConnectionType,SessionType>(getPort()) {} }; diff --git a/qpid/cpp/src/tests/BrokerMgmtAgent.cpp b/qpid/cpp/src/tests/BrokerMgmtAgent.cpp index 29c3faf809..bad7e768a6 100644 --- a/qpid/cpp/src/tests/BrokerMgmtAgent.cpp +++ b/qpid/cpp/src/tests/BrokerMgmtAgent.cpp @@ -63,6 +63,7 @@ class AgentFixture qpid::broker::Broker::Options opts = qpid::broker::Broker::Options()) { opts.enableMgmt=true; + opts.qmf1Support=!qmfV2; opts.qmf2Support=qmfV2; opts.mgmtPubInterval=pubInterval; mFix = new MessagingFixture(opts, true); diff --git a/qpid/cpp/src/tests/CMakeLists.txt b/qpid/cpp/src/tests/CMakeLists.txt index 4763bc0b80..281464e65a 100644 --- a/qpid/cpp/src/tests/CMakeLists.txt +++ b/qpid/cpp/src/tests/CMakeLists.txt @@ -108,7 +108,6 @@ set(all_unit_tests ClientMessage ClientMessageTest ClientSessionTest - ConsoleTest DeliveryRecordTest DtxWorkRecordTest exception_test @@ -147,6 +146,7 @@ set(all_unit_tests TimerTest TopicExchangeTest TxBufferTest + TransactionObserverTest Url Uuid Variant @@ -171,7 +171,7 @@ add_executable (unit_test unit_test ${actual_unit_tests} ${platform_test_additions}) target_link_libraries (unit_test ${qpid_test_boost_libs} - qpidmessaging qpidbroker qmfconsole) + qpidmessaging qpidtypes qpidbroker qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") set_target_properties (unit_test PROPERTIES COMPILE_DEFINITIONS _IN_QPID_BROKER) remember_location(unit_test) @@ -191,105 +191,104 @@ endif (BUILD_SASL) # Other test programs # add_executable (qpid-perftest qpid-perftest.cpp ${platform_test_additions}) -target_link_libraries (qpid-perftest qpidclient) +target_link_libraries (qpid-perftest qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #qpid_perftest_SOURCES=qpid-perftest.cpp test_tools.h TestOptions.h ConnectionOptions.h remember_location(qpid-perftest) add_executable (qpid-txtest qpid-txtest.cpp ${platform_test_additions}) -target_link_libraries (qpid-txtest qpidclient) +target_link_libraries (qpid-txtest qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #qpid_txtest_SOURCES=qpid-txtest.cpp TestOptions.h ConnectionOptions.h remember_location(qpid-txtest) add_executable (qpid-latency-test qpid-latency-test.cpp ${platform_test_additions}) -target_link_libraries (qpid-latency-test qpidclient) +target_link_libraries (qpid-latency-test qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #qpid_latencytest_SOURCES=qpid-latency-test.cpp TestOptions.h ConnectionOptions.h remember_location(qpid-latency-test) add_executable (echotest echotest.cpp ${platform_test_additions}) -target_link_libraries (echotest qpidclient) +target_link_libraries (echotest qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #echotest_SOURCES=echotest.cpp TestOptions.h ConnectionOptions.h remember_location(echotest) add_executable (qpid-client-test qpid-client-test.cpp ${platform_test_additions}) -target_link_libraries (qpid-client-test qpidclient) +target_link_libraries (qpid-client-test qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #qpid_client_test_SOURCES=qpid-client-test.cpp TestOptions.h ConnectionOptions.h remember_location(qpid-client-test) add_executable (qpid-topic-listener qpid-topic-listener.cpp ${platform_test_additions}) -target_link_libraries (qpid-topic-listener qpidclient) +target_link_libraries (qpid-topic-listener qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #qpid_topic_listener_SOURCES=qpid-topic-listener.cpp TestOptions.h ConnectionOptions.h remember_location(qpid-topic-listener) add_executable (qpid-topic-publisher qpid-topic-publisher.cpp ${platform_test_additions}) -target_link_libraries (qpid-topic-publisher qpidclient) +target_link_libraries (qpid-topic-publisher qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #qpid_topic_publisher_SOURCES=qpid-topic-publisher.cpp TestOptions.h ConnectionOptions.h remember_location(qpid-topic-publisher) add_executable (publish publish.cpp ${platform_test_additions}) -target_link_libraries (publish qpidclient) +target_link_libraries (publish qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #publish_SOURCES=publish.cpp TestOptions.h ConnectionOptions.h remember_location(publish) add_executable (consume consume.cpp ${platform_test_additions}) -target_link_libraries (consume qpidclient) +target_link_libraries (consume qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #consume_SOURCES=consume.cpp TestOptions.h ConnectionOptions.h remember_location(consume) add_executable (header_test header_test.cpp ${platform_test_additions}) -target_link_libraries (header_test qpidclient) +target_link_libraries (header_test qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #header_test_SOURCES=header_test.cpp TestOptions.h ConnectionOptions.h remember_location(header_test) add_executable (declare_queues declare_queues.cpp ${platform_test_additions}) -target_link_libraries (declare_queues qpidclient) +target_link_libraries (declare_queues qpidclient qpidcommon) remember_location(declare_queues) add_executable (replaying_sender replaying_sender.cpp ${platform_test_additions}) -target_link_libraries (replaying_sender qpidclient) +target_link_libraries (replaying_sender qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") remember_location(replaying_sender) add_executable (resuming_receiver resuming_receiver.cpp ${platform_test_additions}) -target_link_libraries (resuming_receiver qpidclient) +target_link_libraries (resuming_receiver qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") remember_location(resuming_receiver) add_executable (txshift txshift.cpp ${platform_test_additions}) -target_link_libraries (txshift qpidclient) +target_link_libraries (txshift qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #txshift_SOURCES=txshift.cpp TestOptions.h ConnectionOptions.h remember_location(txshift) add_executable (txjob txjob.cpp ${platform_test_additions}) -target_link_libraries (txjob qpidclient) +target_link_libraries (txjob qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") #txjob_SOURCES=txjob.cpp TestOptions.h ConnectionOptions.h remember_location(txjob) add_executable (receiver receiver.cpp ${platform_test_additions}) -target_link_libraries (receiver qpidclient) -#receiver_SOURCES=receiver.cpp TestOptions.h ConnectionOptions.h +target_link_libraries (receiver qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") remember_location(receiver) +# This is bizarre - using both messaging and client libraries add_executable (sender sender.cpp Statistics.cpp ${platform_test_additions}) -target_link_libraries (sender qpidmessaging) -#sender_SOURCES=sender.cpp TestOptions.h ConnectionOptions.h +target_link_libraries (sender qpidmessaging qpidtypes qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") remember_location(sender) add_executable (qpid-receive qpid-receive.cpp Statistics.cpp ${platform_test_additions}) -target_link_libraries (qpid-receive qpidmessaging) +target_link_libraries (qpid-receive qpidmessaging qpidtypes qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") remember_location(qpid-receive) add_executable (qpid-send qpid-send.cpp Statistics.cpp ${platform_test_additions}) -target_link_libraries (qpid-send qpidmessaging) +target_link_libraries (qpid-send qpidmessaging qpidtypes qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") remember_location(qpid-send) add_executable (qpid-ping qpid-ping.cpp ${platform_test_additions}) -target_link_libraries (qpid-ping qpidclient) +target_link_libraries (qpid-ping qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") remember_location(qpid-ping) add_executable (datagen datagen.cpp ${platform_test_additions}) -target_link_libraries (datagen qpidclient) +target_link_libraries (datagen qpidclient qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") remember_location(datagen) add_executable (msg_group_test msg_group_test.cpp ${platform_test_additions}) -target_link_libraries (msg_group_test qpidmessaging) +target_link_libraries (msg_group_test qpidmessaging qpidtypes qpidcommon "${Boost_PROGRAM_OPTIONS_LIBRARY}") remember_location(msg_group_test) if (BUILD_SASL) @@ -357,6 +356,7 @@ if (PYTHON_EXECUTABLE) if (BUILD_AMQP) add_test (interlink_tests ${test_wrap} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/interlink_tests.py) endif (BUILD_AMQP) + add_test (swig_python_tests ${test_wrap} ${CMAKE_CURRENT_SOURCE_DIR}/swig_python_tests${test_script_suffix}) endif (PYTHON_EXECUTABLE) add_test (ipv6_test ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/ipv6_test${test_script_suffix}) add_test (federation_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_federation_tests${test_script_suffix}) @@ -378,24 +378,7 @@ add_test (queue_redirect ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_queue_redirect add_library(test_store MODULE test_store.cpp) target_link_libraries (test_store qpidbroker qpidcommon) -set_target_properties (test_store PROPERTIES - COMPILE_DEFINITIONS _IN_QPID_BROKER - PREFIX "") +set_target_properties (test_store PROPERTIES PREFIX "" COMPILE_DEFINITIONS _IN_QPID_BROKER) add_library (dlclose_noop MODULE dlclose_noop.c) -#libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir) - -#CLEANFILES+=valgrind.out *.log *.vglog* dummy_test $(unit_wrappers) -# -## Longer running stability tests, not run by default check: target. -## Not run under valgrind, too slow -#LONG_TESTS=fanout_perftest shared_perftest multiq_perftest topic_perftest -#EXTRA_DIST+=$(LONG_TESTS) run_perftest -#check-long: -# $(MAKE) check TESTS="start_broker $(LONG_TESTS) stop_broker" VALGRIND= - -# -# legacystore -# -# add_subdirectory(legacystore) diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 2da96bf30c..2236882eed 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -37,6 +37,7 @@ #include <boost/lexical_cast.hpp> #include <boost/bind.hpp> #include <boost/ptr_container/ptr_vector.hpp> +#include <boost/format.hpp> #include <vector> diff --git a/qpid/cpp/src/tests/ConsoleTest.cpp b/qpid/cpp/src/tests/ConsoleTest.cpp deleted file mode 100644 index 107472ed9e..0000000000 --- a/qpid/cpp/src/tests/ConsoleTest.cpp +++ /dev/null @@ -1,46 +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. - * - */ - -#include "qpid/console/Package.h" -#include "qpid/console/ClassKey.h" -#include "unit_test.h" - -namespace qpid { -namespace tests { - -QPID_AUTO_TEST_SUITE(ConsoleTestSuite) - -using namespace qpid::framing; -using namespace qpid::console; - -QPID_AUTO_TEST_CASE(testClassKey) { - uint8_t hash[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; - ClassKey k("com.redhat.test", "class", hash); - - BOOST_CHECK_EQUAL(k.getPackageName(), "com.redhat.test"); - BOOST_CHECK_EQUAL(k.getClassName(), "class"); - BOOST_CHECK_EQUAL(k.getHashString(), "00010203-04050607-08090a0b-0c0d0e0f"); - BOOST_CHECK_EQUAL(k.str(), "com.redhat.test:class(00010203-04050607-08090a0b-0c0d0e0f)"); -} - -QPID_AUTO_TEST_SUITE_END() - -}} // namespace qpid::tests diff --git a/qpid/cpp/src/tests/Makefile.am b/qpid/cpp/src/tests/Makefile.am deleted file mode 100644 index 808d9f9731..0000000000 --- a/qpid/cpp/src/tests/Makefile.am +++ /dev/null @@ -1,410 +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. -# - -AM_CXXFLAGS = $(WARNING_CFLAGS) -DBOOST_TEST_DYN_LINK -D_IN_QPID_BROKER -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_builddir)/src -PUBLIC_INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include # Use public API only -QMF_GEN=$(top_srcdir)/managementgen/qmf-gen - -abs_builddir=@abs_builddir@ -abs_srcdir=@abs_srcdir@ - -extra_libs = -lib_client = $(abs_builddir)/../libqpidclient.la -lib_messaging = $(abs_builddir)/../libqpidmessaging.la -lib_types = $(abs_builddir)/../libqpidtypes.la -lib_common = $(abs_builddir)/../libqpidcommon.la -lib_broker = $(abs_builddir)/../libqpidbroker.la -lib_console = $(abs_builddir)/../libqmfconsole.la -lib_qmf2 = $(abs_builddir)/../libqmf2.la -# lib_amqp_0_10 = $(abs_builddir)/../libqpidamqp_0_10.la - -# -# Initialize variables that are incremented with += -# -check_PROGRAMS= -check_LTLIBRARIES= -TESTS= -EXTRA_DIST= -CLEANFILES= -LONG_TESTS= -CLEAN_LOCAL= - -# -# Destination for intalled programs and tests defined here -# -qpidexecdir = $(libexecdir)/qpid -qpidexec_PROGRAMS = -qpidexec_SCRIPTS = -qpidexectestdir = $(qpidexecdir)/tests -qpidexectest_PROGRAMS = -qpidexectest_SCRIPTS = -tmoduledir = $(libdir)/qpid/tests -tmodule_LTLIBRARIES= - -# -# Unit test program -# -# Unit tests are built as a single program to reduce valgrind overhead -# when running the tests. If you want to build a subset of the tests do -# rm -f unit_test; make unit_test unit_test_OBJECTS="unit_test.o SelectedTest.o" -# - -TESTS+=unit_test -check_PROGRAMS+=unit_test -unit_test_LDADD=-lboost_unit_test_framework -lpthread \ - $(lib_messaging) $(lib_broker) $(lib_console) $(lib_qmf2) - -unit_test_SOURCES= unit_test.cpp unit_test.h \ - MessagingSessionTests.cpp \ - MessagingThreadTests.cpp \ - MessagingFixture.h \ - ClientSessionTest.cpp \ - BrokerFixture.h \ - exception_test.cpp \ - RefCounted.cpp \ - SessionState.cpp logging.cpp \ - AsyncCompletion.cpp \ - Url.cpp Uuid.cpp \ - Shlib.cpp FieldValue.cpp FieldTable.cpp Array.cpp \ - QueueOptionsTest.cpp \ - InlineAllocator.cpp \ - InlineVector.cpp \ - SequenceSet.cpp \ - StringUtils.cpp \ - RangeSet.cpp \ - AtomicValue.cpp \ - QueueTest.cpp \ - AccumulatedAckTest.cpp \ - DtxWorkRecordTest.cpp \ - DeliveryRecordTest.cpp \ - ExchangeTest.cpp \ - HeadersExchangeTest.cpp \ - MessageTest.cpp \ - QueueDepth.cpp \ - QueueRegistryTest.cpp \ - QueuePolicyTest.cpp \ - QueueFlowLimitTest.cpp \ - FramingTest.cpp \ - HeaderTest.cpp \ - SequenceNumberTest.cpp \ - TimerTest.cpp \ - TopicExchangeTest.cpp \ - TxBufferTest.cpp \ - ConnectionOptions.h \ - ManagementTest.cpp \ - MessageReplayTracker.cpp \ - ConsoleTest.cpp \ - ProxyTest.cpp \ - RetryList.cpp \ - FrameDecoder.cpp \ - ClientMessageTest.cpp \ - PollableCondition.cpp \ - Variant.cpp \ - Address.cpp \ - ClientMessage.cpp \ - Qmf2.cpp \ - BrokerOptions.cpp \ - Selector.cpp \ - SystemInfo.cpp - -if HAVE_XML -unit_test_SOURCES+= XmlClientSessionTest.cpp -endif - -TESTLIBFLAGS = -module -rpath $(abs_builddir) - -check_LTLIBRARIES += libshlibtest.la -libshlibtest_la_LDFLAGS = $(TESTLIBFLAGS) -libshlibtest_la_SOURCES = shlibtest.cpp - -tmodule_LTLIBRARIES += test_store.la -test_store_la_SOURCES = test_store.cpp -test_store_la_LIBADD = $(lib_broker) -test_store_la_LDFLAGS = -module - -include sasl.mk -if SSL -include ssl.mk -endif - -# Test programs that are installed and therefore built as part of make, not make check - -qpidexectest_SCRIPTS += qpid-cpp-benchmark qpid-cluster-benchmark install_env.sh qpidt -EXTRA_DIST += qpid-cpp-benchmark qpid-cluster-benchmark install_env.sh qpidt - -qpidexectest_PROGRAMS += receiver -receiver_SOURCES = \ - receiver.cpp \ - TestOptions.h \ - ConnectionOptions.h -receiver_LDADD = $(lib_client) -lboost_program_options $(lib_common) - -qpidexectest_PROGRAMS += sender -sender_SOURCES = \ - sender.cpp \ - TestOptions.h \ - ConnectionOptions.h \ - Statistics.cpp -sender_LDADD = $(lib_messaging) -lboost_program_options $(lib_common) $(lib_types) $(lib_client) - -qpidexectest_PROGRAMS += qpid-receive -qpid_receive_SOURCES = \ - qpid-receive.cpp \ - TestOptions.h \ - ConnectionOptions.h \ - Statistics.h \ - Statistics.cpp -qpid_receive_LDADD = $(lib_messaging) -lboost_program_options $(lib_common) $(lib_types) - -qpidexectest_PROGRAMS += qpid-send -qpid_send_SOURCES = \ - qpid-send.cpp \ - TestOptions.h \ - ConnectionOptions.h \ - Statistics.h \ - Statistics.cpp -qpid_send_LDADD = $(lib_messaging) -lboost_program_options $(lib_common) $(lib_types) - -qpidexectest_PROGRAMS+=qpid-perftest -qpid_perftest_SOURCES=qpid-perftest.cpp test_tools.h TestOptions.h ConnectionOptions.h -qpid_perftest_INCLUDES=$(PUBLIC_INCLUDES) -qpid_perftest_LDADD=$(lib_client) -lboost_program_options $(lib_common) - -qpidexectest_PROGRAMS+=qpid-txtest -qpid_txtest_INCLUDES=$(PUBLIC_INCLUDES) -qpid_txtest_SOURCES=qpid-txtest.cpp TestOptions.h ConnectionOptions.h -qpid_txtest_LDADD=$(lib_client) -lboost_program_options $(lib_common) - -qpidexectest_PROGRAMS+=qpid-latency-test -qpid_latency_test_INCLUDES=$(PUBLIC_INCLUDES) -qpid_latency_test_SOURCES=qpid-latency-test.cpp TestOptions.h ConnectionOptions.h -qpid_latency_test_LDADD=$(lib_client) -lboost_program_options $(lib_common) - -qpidexectest_PROGRAMS+=qpid-client-test -qpid_client_test_INCLUDES=$(PUBLIC_INCLUDES) -qpid_client_test_SOURCES=qpid-client-test.cpp TestOptions.h ConnectionOptions.h -qpid_client_test_LDADD=$(lib_client) -lboost_program_options $(lib_common) - -qpidexectest_PROGRAMS+=qpid-topic-listener -qpid_topic_listener_INCLUDES=$(PUBLIC_INCLUDES) -qpid_topic_listener_SOURCES=qpid-topic-listener.cpp TestOptions.h ConnectionOptions.h -qpid_topic_listener_LDADD=$(lib_client) -lboost_program_options $(lib_common) - -qpidexectest_PROGRAMS+=qpid-topic-publisher -qpid_topic_publisher_INCLUDES=$(PUBLIC_INCLUDES) -qpid_topic_publisher_SOURCES=qpid-topic-publisher.cpp TestOptions.h ConnectionOptions.h -qpid_topic_publisher_LDADD=$(lib_client) -lboost_program_options $(lib_common) - -qpidexectest_PROGRAMS+=qpid-ping -qpid_ping_INCLUDES=$(PUBLIC_INCLUDES) -qpid_ping_SOURCES=qpid-ping.cpp test_tools.h TestOptions.h ConnectionOptions.h -qpid_ping_LDADD=$(lib_client) -lboost_program_options $(lib_common) - -# -# Other test programs -# - -check_PROGRAMS+=echotest -echotest_INCLUDES=$(PUBLIC_INCLUDES) -echotest_SOURCES=echotest.cpp TestOptions.h ConnectionOptions.h -echotest_LDADD=$(lib_client) - -check_PROGRAMS+=publish -publish_INCLUDES=$(PUBLIC_INCLUDES) -publish_SOURCES=publish.cpp TestOptions.h ConnectionOptions.h -publish_LDADD=$(lib_client) - -check_PROGRAMS+=consume -consume_INCLUDES=$(PUBLIC_INCLUDES) -consume_SOURCES=consume.cpp TestOptions.h ConnectionOptions.h -consume_LDADD=$(lib_client) - -check_PROGRAMS+=header_test -header_test_INCLUDES=$(PUBLIC_INCLUDES) -header_test_SOURCES=header_test.cpp TestOptions.h ConnectionOptions.h -header_test_LDADD=$(lib_client) - -check_PROGRAMS+=declare_queues -declare_queues_INCLUDES=$(PUBLIC_INCLUDES) -declare_queues_SOURCES=declare_queues.cpp -declare_queues_LDADD=$(lib_client) - -check_PROGRAMS+=replaying_sender -replaying_sender_INCLUDES=$(PUBLIC_INCLUDES) -replaying_sender_SOURCES=replaying_sender.cpp -replaying_sender_LDADD=$(lib_client) - -check_PROGRAMS+=resuming_receiver -resuming_receiver_INCLUDES=$(PUBLIC_INCLUDES) -resuming_receiver_SOURCES=resuming_receiver.cpp -resuming_receiver_LDADD=$(lib_client) - -check_PROGRAMS+=txshift -txshift_INCLUDES=$(PUBLIC_INCLUDES) -txshift_SOURCES=txshift.cpp TestOptions.h ConnectionOptions.h -txshift_LDADD=$(lib_client) - -check_PROGRAMS+=txjob -txjob_INCLUDES=$(PUBLIC_INCLUDES) -txjob_SOURCES=txjob.cpp TestOptions.h ConnectionOptions.h -txjob_LDADD=$(lib_client) - -check_PROGRAMS+=PollerTest -PollerTest_SOURCES=PollerTest.cpp -PollerTest_LDADD=$(lib_common) $(lib_client) $(SOCKLIBS) - -check_PROGRAMS+=DispatcherTest -DispatcherTest_SOURCES=DispatcherTest.cpp -DispatcherTest_LDADD=$(lib_common) $(lib_client) $(SOCKLIBS) - -check_PROGRAMS+=datagen -datagen_SOURCES=datagen.cpp -datagen_LDADD=$(lib_common) $(lib_client) - -check_PROGRAMS+=qpid-stream -qpid_stream_INCLUDES=$(PUBLIC_INCLUDES) -qpid_stream_SOURCES=qpid-stream.cpp -qpid_stream_LDADD=$(lib_messaging) - -check_PROGRAMS+=msg_group_test -msg_group_test_INCLUDES=$(PUBLIC_INCLUDES) -msg_group_test_SOURCES=msg_group_test.cpp -msg_group_test_LDADD=$(lib_messaging) - -TESTS_ENVIRONMENT = \ - VALGRIND=$(VALGRIND) \ - LIBTOOL="$(LIBTOOL)" \ - QPID_DATA_DIR= \ - $(srcdir)/run_test - -system_tests = qpid-client-test quick_perftest quick_topictest run_header_test quick_txtest \ - run_msg_group_tests -TESTS += start_broker $(system_tests) python_tests stop_broker \ - run_ha_tests run_interlink_tests run_federation_tests run_federation_sys_tests \ - run_acl_tests run_cli_tests dynamic_log_level_test \ - dynamic_log_hires_timestamp run_queue_flow_limit_tests ipv6_test - -EXTRA_DIST += \ - run_test vg_check \ - run-unit-tests start_broker python_tests stop_broker \ - quick_topictest \ - quick_perftest \ - quick_txtest \ - topictest \ - run_header_test \ - header_test.py \ - ssl_test \ - ping_broker \ - config.null \ - run_federation_tests \ - run_federation_sys_tests \ - run_long_federation_sys_tests \ - run_cli_tests \ - run_acl_tests \ - .valgrind.supp \ - MessageUtils.h \ - TestMessageStore.h \ - TxMocks.h \ - run_perftest \ - ring_queue_test \ - run_ring_queue_test \ - run_paged_queue_tests \ - dynamic_log_level_test \ - dynamic_log_hires_timestamp \ - qpid-ctrl \ - CMakeLists.txt \ - windows/DisableWin32ErrorWindows.cpp \ - background.ps1 \ - find_prog.ps1 \ - python_tests.ps1 \ - quick_topictest.ps1 \ - run_federation_tests.ps1 \ - run_header_test.ps1 \ - run_test.ps1 \ - start_broker.ps1 \ - stop_broker.ps1 \ - topictest.ps1 \ - run_queue_flow_limit_tests \ - run_msg_group_tests \ - ipv6_test \ - run_ha_tests \ - ha_test.py \ - ha_tests.py \ - run_interlink_tests \ - interlink_tests.py \ - brokertest.py \ - test_env.ps1.in - -check_LTLIBRARIES += libdlclose_noop.la -libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir) -libdlclose_noop_la_SOURCES = dlclose_noop.c - -CLEANFILES+=valgrind.out *.log *.vglog* dummy_test qpidd.port $(unit_wrappers) - -# Longer running stability tests, not run by default check: target. -# Not run under valgrind, too slow - -LONG_TESTS+=start_broker \ - fanout_perftest shared_perftest multiq_perftest topic_perftest run_ring_queue_test run_paged_queue_tests\ - run_msg_group_tests_soak \ - stop_broker \ - run_long_federation_sys_tests - -EXTRA_DIST+= \ - fanout_perftest \ - shared_perftest \ - multiq_perftest \ - topic_perftest \ - sasl_test_setup.sh \ - run_msg_group_tests_soak \ - qpidd-empty.conf \ - qpidd-p0 - -check-long: - $(MAKE) check TESTS="$(LONG_TESTS)" VALGRIND= - -# Things that should be built before the check target runs. -check-am: python_prep test_env.sh install_env.sh sasl_config - -PYTHON_SRC_DIR=$(abs_srcdir)/../../../python -PYTHON_BLD_DIR=$(abs_builddir)/python - -# Generate python client as part of the all-am target so it gets built before tests. -all-am: python_prep - -python_prep: - if test -d $(PYTHON_SRC_DIR); \ - then cd $(PYTHON_SRC_DIR) && python $(PYTHON_SRC_DIR)/setup.py install \ - --prefix=$(PYTHON_BLD_DIR) --install-lib=$(PYTHON_BLD_DIR) \ - --install-scripts=$(PYTHON_BLD_DIR)/commands; \ - else echo "WARNING: python client not built, missing $(PYTHON_SRC_DIR)"; fi - -sasl_config: sasl_test_setup.sh - sh $(srcdir)/sasl_test_setup.sh - touch sasl_config - -CLEAN_LOCAL += sasl_config - -clean-local: - rm -rf $(CLEAN_LOCAL) - -include testagent.mk -include brokermgmt.mk - diff --git a/qpid/cpp/src/tests/ManagementTest.cpp b/qpid/cpp/src/tests/ManagementTest.cpp index 8944c084c0..98ef591fae 100644 --- a/qpid/cpp/src/tests/ManagementTest.cpp +++ b/qpid/cpp/src/tests/ManagementTest.cpp @@ -21,7 +21,6 @@ #include "qpid/management/ManagementObject.h" #include "qpid/framing/Buffer.h" -#include "qpid/console/ObjectId.h" #include "unit_test.h" namespace qpid { @@ -93,32 +92,6 @@ QPID_AUTO_TEST_CASE(testObjectIdCreate) { BOOST_CHECK_EQUAL(oid.getV2Key(), "an-object-name"); } -QPID_AUTO_TEST_CASE(testConsoleObjectId) { - qpid::console::ObjectId oid1, oid2; - - oid1.setValue(1, 2); - oid2.setValue(3, 4); - - BOOST_CHECK(oid1 < oid2); - BOOST_CHECK(oid1 <= oid2); - BOOST_CHECK(oid2 > oid1); - BOOST_CHECK(oid2 >= oid1); - BOOST_CHECK(oid1 != oid2); - BOOST_CHECK(oid1 == oid1); - - oid1.setValue(3, 6); - oid2.setValue(3, 4); - - BOOST_CHECK(oid1 > oid2); - BOOST_CHECK(oid1 >= oid2); - BOOST_CHECK(oid2 < oid1); - BOOST_CHECK(oid2 <= oid1); - BOOST_CHECK(oid1 != oid2); - - oid2.setValue(3, 6); - BOOST_CHECK(oid1 == oid2); -} - QPID_AUTO_TEST_SUITE_END() }} // namespace qpid::tests diff --git a/qpid/cpp/src/tests/MessageReplayTracker.cpp b/qpid/cpp/src/tests/MessageReplayTracker.cpp index e35f673683..c0778247f0 100644 --- a/qpid/cpp/src/tests/MessageReplayTracker.cpp +++ b/qpid/cpp/src/tests/MessageReplayTracker.cpp @@ -23,6 +23,8 @@ #include "qpid/client/MessageReplayTracker.h" #include "qpid/sys/Time.h" +#include <boost/format.hpp> + namespace qpid { namespace tests { diff --git a/qpid/cpp/src/tests/MessagingFixture.h b/qpid/cpp/src/tests/MessagingFixture.h index 2312a87e9d..1d70d4cfa6 100644 --- a/qpid/cpp/src/tests/MessagingFixture.h +++ b/qpid/cpp/src/tests/MessagingFixture.h @@ -35,6 +35,8 @@ #include "qpid/messaging/Message.h" #include "qpid/types/Variant.h" +#include <boost/format.hpp> + namespace qpid { namespace tests { @@ -115,6 +117,7 @@ struct MessagingFixture : public BrokerFixture (boost::format("amqp:tcp:localhost:%1%") % (port)).str()); connection.open(); return connection; + } /** Open a connection to the broker. */ @@ -231,9 +234,10 @@ inline void receive(messaging::Receiver& receiver, uint count = 1, uint start = class MethodInvoker { public: - MethodInvoker(messaging::Session& session) : replyTo("#; {create:always, node:{x-declare:{auto-delete:true}}}"), - sender(session.createSender("qmf.default.direct/broker")), - receiver(session.createReceiver(replyTo)) {} + MethodInvoker(messaging::Session session) : + replyTo("#; {create:always, node:{x-declare:{auto-delete:true}}}"), + sender(session.createSender("qmf.default.direct/broker")), + receiver(session.createReceiver(replyTo)) {} void createExchange(const std::string& name, const std::string& type, bool durable=false) { @@ -292,11 +296,14 @@ class MethodInvoker methodRequest("delete", params); } - void methodRequest(const std::string& method, const Variant::Map& inParams, Variant::Map* outParams = 0) + void methodRequest( + const std::string& method, + const Variant::Map& inParams, Variant::Map* outParams = 0, + const std::string& objectName="org.apache.qpid.broker:broker:amqp-broker") { Variant::Map content; Variant::Map objectId; - objectId["_object_name"] = "org.apache.qpid.broker:broker:amqp-broker"; + objectId["_object_name"] = objectName;; content["_object_id"] = objectId; content["_method_name"] = method; content["_arguments"] = inParams; diff --git a/qpid/cpp/src/tests/MessagingSessionTests.cpp b/qpid/cpp/src/tests/MessagingSessionTests.cpp index b388f2c13a..5cc595c56f 100644 --- a/qpid/cpp/src/tests/MessagingSessionTests.cpp +++ b/qpid/cpp/src/tests/MessagingSessionTests.cpp @@ -1289,6 +1289,95 @@ QPID_AUTO_TEST_CASE(testSimpleRequestResponse) BOOST_CHECK_EQUAL(m.getSubject(), original.getSubject()); } +QPID_AUTO_TEST_CASE(testSelfDestructQueue) +{ + MessagingFixture fix; + Session other = fix.connection.createSession(); + Receiver r1 = other.createReceiver("amq.fanout; {link:{reliability:at-least-once, x-declare:{arguments:{qpid.max_count:10,qpid.policy_type:self-destruct}}}}"); + Receiver r2 = fix.session.createReceiver("amq.fanout"); + //send request + Sender s = fix.session.createSender("amq.fanout"); + for (uint i = 0; i < 20; ++i) { + s.send(Message((boost::format("MSG_%1%") % (i+1)).str())); + } + try { + ScopedSuppressLogging sl; + for (uint i = 0; i < 20; ++i) { + r1.fetch(Duration::SECOND); + } + BOOST_FAIL("Expected exception."); + } catch (const qpid::messaging::MessagingException&) { + } + + for (uint i = 0; i < 20; ++i) { + BOOST_CHECK_EQUAL(r2.fetch(Duration::SECOND).getContent(), (boost::format("MSG_%1%") % (i+1)).str()); + } +} + +QPID_AUTO_TEST_CASE(testReroutingRingQueue) +{ + MessagingFixture fix; + Receiver r1 = fix.session.createReceiver("my-queue; {create:always, node:{x-declare:{alternate-exchange:amq.fanout, auto-delete:True, arguments:{qpid.max_count:10,qpid.policy_type:ring}}}}"); + Receiver r2 = fix.session.createReceiver("amq.fanout"); + + Sender s = fix.session.createSender("my-queue"); + for (uint i = 0; i < 20; ++i) { + s.send(Message((boost::format("MSG_%1%") % (i+1)).str())); + } + for (uint i = 10; i < 20; ++i) { + BOOST_CHECK_EQUAL(r1.fetch(Duration::SECOND).getContent(), (boost::format("MSG_%1%") % (i+1)).str()); + } + for (uint i = 0; i < 10; ++i) { + BOOST_CHECK_EQUAL(r2.fetch(Duration::SECOND).getContent(), (boost::format("MSG_%1%") % (i+1)).str()); + } +} + +QPID_AUTO_TEST_CASE(testReleaseOnPriorityQueue) +{ + MessagingFixture fix; + std::string queue("queue; {create:always, node:{x-declare:{auto-delete:True, arguments:{qpid.priorities:10}}}}"); + std::string text("my message"); + Sender sender = fix.session.createSender(queue); + sender.send(Message(text)); + Receiver receiver = fix.session.createReceiver(queue); + Message msg; + for (uint i = 0; i < 10; ++i) { + if (receiver.fetch(msg, Duration::SECOND)) { + BOOST_CHECK_EQUAL(msg.getContent(), text); + fix.session.release(msg); + } else { + BOOST_FAIL("Released message not redelivered as expected."); + } + } + fix.session.acknowledge(); +} + +QPID_AUTO_TEST_CASE(testRollbackWithFullPrefetch) +{ + QueueFixture fix; + std::string first("first"); + std::string second("second"); + Sender sender = fix.session.createSender(fix.queue); + for (uint i = 0; i < 10; ++i) { + sender.send(Message((boost::format("MSG_%1%") % (i+1)).str())); + } + Session txsession = fix.connection.createTransactionalSession(); + Receiver receiver = txsession.createReceiver(fix.queue); + receiver.setCapacity(9); + Message msg; + for (uint i = 0; i < 10; ++i) { + if (receiver.fetch(msg, Duration::SECOND)) { + BOOST_CHECK_EQUAL(msg.getContent(), std::string("MSG_1")); + txsession.rollback(); + } else { + BOOST_FAIL("Released message not redelivered as expected."); + break; + } + } + txsession.acknowledge(); + txsession.commit(); +} + QPID_AUTO_TEST_SUITE_END() }} // namespace qpid::tests diff --git a/qpid/cpp/src/tests/QueuePolicyTest.cpp b/qpid/cpp/src/tests/QueuePolicyTest.cpp index 00e964602a..ce1b0addea 100644 --- a/qpid/cpp/src/tests/QueuePolicyTest.cpp +++ b/qpid/cpp/src/tests/QueuePolicyTest.cpp @@ -28,6 +28,8 @@ #include "qpid/framing/reply_exceptions.h" #include "BrokerFixture.h" +#include <boost/format.hpp> + using namespace qpid::broker; using namespace qpid::client; using namespace qpid::framing; diff --git a/qpid/cpp/src/tests/Shlib.cpp b/qpid/cpp/src/tests/Shlib.cpp index d8ad4c14d8..7f01323e3c 100644 --- a/qpid/cpp/src/tests/Shlib.cpp +++ b/qpid/cpp/src/tests/Shlib.cpp @@ -35,13 +35,7 @@ typedef void (*CallMe)(int*); QPID_AUTO_TEST_CASE(testShlib) { - // The CMake-based build passes in the shared lib suffix; if it's not - // there, this is a Linux/UNIX libtool-based build. -#if defined (QPID_SHLIB_PREFIX) && defined (QPID_SHLIB_SUFFIX) Shlib sh("./" QPID_SHLIB_PREFIX "shlibtest" QPID_SHLIB_POSTFIX QPID_SHLIB_SUFFIX); -#else - Shlib sh(".libs/libshlibtest.so"); -#endif // Double cast to avoid ISO warning. CallMe callMe=sh.getSymbol<CallMe>("callMe"); BOOST_REQUIRE(callMe != 0); @@ -59,11 +53,7 @@ QPID_AUTO_TEST_CASE(testShlib) { QPID_AUTO_TEST_CASE(testAutoShlib) { int unloaded = 0; { -#if defined (QPID_SHLIB_PREFIX) && defined (QPID_SHLIB_SUFFIX) AutoShlib sh("./" QPID_SHLIB_PREFIX "shlibtest" QPID_SHLIB_POSTFIX QPID_SHLIB_SUFFIX); -#else - AutoShlib sh(".libs/libshlibtest.so"); -#endif CallMe callMe=sh.getSymbol<CallMe>("callMe"); BOOST_REQUIRE(callMe != 0); callMe(&unloaded); diff --git a/qpid/cpp/src/tests/TransactionObserverTest.cpp b/qpid/cpp/src/tests/TransactionObserverTest.cpp new file mode 100644 index 0000000000..fd1c331ae7 --- /dev/null +++ b/qpid/cpp/src/tests/TransactionObserverTest.cpp @@ -0,0 +1,144 @@ +/* + * + * 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 "unit_test.h" +#include "test_tools.h" +#include "MessagingFixture.h" +#include "qpid/broker/BrokerObserver.h" +#include "qpid/broker/TransactionObserver.h" +#include "qpid/broker/TxBuffer.h" +#include "qpid/broker/Queue.h" +#include "qpid/ha/types.h" + +#include <boost/bind.hpp> +#include <boost/function.hpp> +#include <boost/lexical_cast.hpp> +#include <iostream> +#include <vector> + +namespace qpid { +namespace tests { + +using framing::SequenceSet; +using messaging::Message; +using boost::shared_ptr; + +using namespace boost::assign; +using namespace boost; +using namespace broker; +using namespace std; +using namespace messaging; +using namespace types; + +QPID_AUTO_TEST_SUITE(TransactionalObserverTest) + +Message msg(string content) { return Message(content); } + +struct MockTransactionObserver : public TransactionObserver { + bool prep; + vector<string> events; + + MockTransactionObserver(bool prep_=true) : prep(prep_) {} + + void record(const string& e) { events.push_back(e); } + + void enqueue(const shared_ptr<Queue>& q, const broker::Message& m) { + record("enqueue "+q->getName()+" "+m.getContent()); + } + void dequeue(const Queue::shared_ptr& q, SequenceNumber p, SequenceNumber r) { + record("dequeue "+q->getName()+" "+ + lexical_cast<string>(p)+" "+lexical_cast<string>(r)); + } + bool prepare() { record("prepare"); return prep; } + void commit() { record("commit"); } + void rollback() {record("rollback"); } +}; + +struct MockBrokerObserver : public BrokerObserver { + bool prep; + shared_ptr<MockTransactionObserver> tx; + + MockBrokerObserver(bool prep_=true) : prep(prep_) {} + + void startTx(const shared_ptr<TxBuffer>& buffer) { + tx.reset(new MockTransactionObserver(prep)); + buffer->setObserver(tx); + } +}; + +Session simpleTxTransaction(MessagingFixture& fix) { + fix.session.createSender("q1;{create:always}").send(msg("foo")); // Not in TX + // Transaction with 1 enqueue and 1 dequeue. + Session txSession = fix.connection.createTransactionalSession(); + BOOST_CHECK_EQUAL("foo", txSession.createReceiver("q1").fetch().getContent()); + txSession.acknowledge(); + txSession.createSender("q2;{create:always}").send(msg("bar")); + return txSession; +} + +QPID_AUTO_TEST_CASE(tesTxtCommit) { + MessagingFixture fix; + shared_ptr<MockBrokerObserver> brokerObserver(new MockBrokerObserver); + fix.broker->getBrokerObservers().add(brokerObserver); + Session txSession = simpleTxTransaction(fix); + txSession.commit(); + // Note on ordering: observers see enqueues as they happen, but dequeues just + // before prepare. + BOOST_CHECK_EQUAL( + list_of<string>("enqueue q2 bar")("dequeue q1 1 0")("prepare")("commit"), + brokerObserver->tx->events + ); +} + +QPID_AUTO_TEST_CASE(testTxFail) { + MessagingFixture fix; + shared_ptr<MockBrokerObserver> brokerObserver(new MockBrokerObserver(false)); + fix.broker->getBrokerObservers().add(brokerObserver); + Session txSession = simpleTxTransaction(fix); + try { + txSession.commit(); + BOOST_FAIL("Expected exception"); + } catch(...) {} + + BOOST_CHECK_EQUAL( + list_of<string>("enqueue q2 bar")("dequeue q1 1 0")("prepare")("rollback"), + brokerObserver->tx->events + ); +} + +QPID_AUTO_TEST_CASE(testTxRollback) { + MessagingFixture fix; + shared_ptr<MockBrokerObserver> brokerObserver(new MockBrokerObserver(false)); + fix.broker->getBrokerObservers().add(brokerObserver); + Session txSession = simpleTxTransaction(fix); + txSession.rollback(); + // Note: The dequeue does not appear here. This is because TxAccepts + // (i.e. dequeues) are not enlisted until SemanticState::commit and are + // never enlisted if the transaction is rolled back. + BOOST_CHECK_EQUAL( + list_of<string>("enqueue q2 bar")("rollback"), + brokerObserver->tx->events + ); +} + +QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests diff --git a/qpid/cpp/src/tests/TxMocks.h b/qpid/cpp/src/tests/TxMocks.h index bf21104f70..8b54e7484b 100644 --- a/qpid/cpp/src/tests/TxMocks.h +++ b/qpid/cpp/src/tests/TxMocks.h @@ -103,6 +103,9 @@ public: if(!debugName.empty()) std::cout << std::endl << "MockTxOp[" << debugName << "]::rollback()" << std::endl; actual.push_back(ROLLBACK); } + + void callObserver(const boost::shared_ptr<TransactionObserver>&) {} + MockTxOp& expectPrepare(){ expected.push_back(PREPARE); return *this; diff --git a/qpid/cpp/src/tests/brokermgmt.mk b/qpid/cpp/src/tests/brokermgmt.mk deleted file mode 100644 index cf9a47200c..0000000000 --- a/qpid/cpp/src/tests/brokermgmt.mk +++ /dev/null @@ -1,44 +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. -# - -# Build a unit test for the broker's internal management agent. - -BROKERMGMT_GEN_SRC= \ - brokermgmt_gen/qmf/org/apache/qpid/broker/mgmt/test/Package.cpp \ - brokermgmt_gen/qmf/org/apache/qpid/broker/mgmt/test/Package.h \ - brokermgmt_gen/qmf/org/apache/qpid/broker/mgmt/test/TestObject.h \ - brokermgmt_gen/qmf/org/apache/qpid/broker/mgmt/test/TestObject.cpp - -$(BROKERMGMT_GEN_SRC): brokermgmt_gen.timestamp - -if GENERATE -BROKERMGMT_DEPS=../mgen.timestamp -endif # GENERATE -brokermgmt_gen.timestamp: BrokerMgmtAgent.xml ${BROKERMGMT_DEPS} - $(QMF_GEN) -b -o brokermgmt_gen/qmf $(srcdir)/BrokerMgmtAgent.xml - touch $@ - -BrokerMgmtAgent.$(OBJEXT): $(BROKERMGMT_GEN_SRC) - -CLEANFILES+=$(BROKERMGMT_GEN_SRC) brokermgmt_gen.timestamp - -unit_test_SOURCES+=BrokerMgmtAgent.cpp ${BROKERMGMT_GEN_SRC} -INCLUDES+= -Ibrokermgmt_gen - -EXTRA_DIST+=BrokerMgmtAgent.xml diff --git a/qpid/cpp/src/tests/brokertest.py b/qpid/cpp/src/tests/brokertest.py index 15372b312d..2786454399 100644 --- a/qpid/cpp/src/tests/brokertest.py +++ b/qpid/cpp/src/tests/brokertest.py @@ -78,7 +78,7 @@ def error_line(filename, n=1): except: return "" return ":\n" + "".join(result) -def retry(function, timeout=10, delay=.01, max_delay=1): +def retry(function, timeout=10, delay=.001, max_delay=1): """Call function until it returns a true value or timeout expires. Double the delay for each retry up to max_delay. Returns what function returns if true, None if timeout expires.""" @@ -141,7 +141,7 @@ class Popen(subprocess.Popen): finally: f.close() log.debug("Started process %s: %s" % (self.pname, " ".join(self.cmd))) - def __str__(self): return "Popen<%s>"%(self.pname) + def __repr__(self): return "Popen<%s>"%(self.pname) def outfile(self, ext): return "%s.%s" % (self.pname, ext) @@ -242,16 +242,12 @@ class Broker(Popen): _broker_count = 0 _log_count = 0 - def __str__(self): return "Broker<%s %s :%d>"%(self.log, self.pname, self.port()) - - def find_log(self): - self.log = "%03d:%s.log" % (Broker._log_count, self.name) - Broker._log_count += 1 + def __repr__(self): return "<Broker:%s:%d>"%(self.log, self.port()) def get_log(self): return os.path.abspath(self.log) - def __init__(self, test, args=[], name=None, expect=EXPECT_RUNNING, port=0, log_level=None, wait=None, show_cmd=False): + def __init__(self, test, args=[], test_store=False, name=None, expect=EXPECT_RUNNING, port=0, log_level=None, wait=None, show_cmd=False): """Start a broker daemon. name determines the data-dir and log file names.""" @@ -273,11 +269,18 @@ class Broker(Popen): else: self.name = "broker%d" % Broker._broker_count Broker._broker_count += 1 - self.find_log() + + self.log = "%03d:%s.log" % (Broker._log_count, self.name) + self.store_log = "%03d:%s.store.log" % (Broker._log_count, self.name) + Broker._log_count += 1 + cmd += ["--log-to-file", self.log] cmd += ["--log-to-stderr=no"] cmd += ["--log-enable=%s"%(log_level or "info+") ] + if test_store: cmd += ["--load-module", BrokerTest.test_store_lib, + "--test-store-events", self.store_log] + self.datadir = self.name cmd += ["--data-dir", self.datadir] if show_cmd: print cmd @@ -285,7 +288,6 @@ class Broker(Popen): test.cleanup_stop(self) self._host = "127.0.0.1" log.debug("Started broker %s (%s, %s)" % (self.name, self.pname, self.log)) - self._log_ready = False def startQmf(self, handler=None): self.qmf_session = qmf.console.Session(handler) @@ -363,29 +365,21 @@ class Broker(Popen): def host_port(self): return "%s:%s" % (self.host(), self.port()) - def log_contains(self, str, timeout=1): - """Wait for str to appear in the log file up to timeout. Return true if found""" - return retry(lambda: find_in_file(str, self.log), timeout) - - def log_ready(self): - """Return true if the log file exists and contains a broker ready message""" - if not self._log_ready: - self._log_ready = find_in_file("notice Broker running", self.log) - return self._log_ready - def ready(self, timeout=30, **kwargs): """Wait till broker is ready to serve clients""" - # First make sure the broker is listening by checking the log. - if not retry(self.log_ready, timeout=timeout): - raise Exception( - "Timed out waiting for broker %s%s"%(self.name, error_line(self.log,5))) - # Create a connection and a session. - try: - c = self.connect(**kwargs) - try: c.session() - finally: c.close() - except Exception,e: raise RethrownException( - "Broker %s not responding: (%s)%s"%(self.name,e,error_line(self.log, 5))) + deadline = time.time()+timeout + while True: + try: + c = self.connect(timeout=timeout, **kwargs) + try: + c.session() + return # All good + finally: c.close() + except Exception,e: # Retry up to timeout + if time.time() > deadline: + raise RethrownException( + "Broker %s not responding: (%s)%s"%( + self.name,e,error_line(self.log, 5))) def browse(session, queue, timeout=0, transform=lambda m: m.content): """Return a list with the contents of each message on queue.""" @@ -407,7 +401,7 @@ def assert_browse(session, queue, expect_contents, timeout=0, transform=lambda m if msg: msg = "%s: %r != %r"%(msg, expect_contents, actual_contents) assert expect_contents == actual_contents, msg -def assert_browse_retry(session, queue, expect_contents, timeout=1, delay=.01, transform=lambda m:m.content, msg="browse failed"): +def assert_browse_retry(session, queue, expect_contents, timeout=1, delay=.001, transform=lambda m:m.content, msg="browse failed"): """Wait up to timeout for contents of queue to match expect_contents""" test = lambda: browse(session, queue, 0, transform=transform) == expect_contents retry(test, timeout, delay) @@ -421,6 +415,10 @@ class BrokerTest(TestCase): Provides a well-known working directory for each test. """ + def __init__(self, *args, **kwargs): + self.longMessage = True # Enable long messages for assert*(..., msg=xxx) + TestCase.__init__(self, *args, **kwargs) + # Environment settings. qpidd_exec = os.path.abspath(checkenv("QPIDD_EXEC")) ha_lib = os.getenv("HA_LIB") @@ -480,7 +478,7 @@ class BrokerTest(TestCase): def assert_browse(self, *args, **kwargs): assert_browse(*args, **kwargs) def assert_browse_retry(self, *args, **kwargs): assert_browse_retry(*args, **kwargs) -def join(thread, timeout=10): +def join(thread, timeout=30): thread.join(timeout) if thread.isAlive(): raise Exception("Timed out joining thread %s"%thread) diff --git a/qpid/cpp/src/tests/cli_tests.py b/qpid/cpp/src/tests/cli_tests.py index dceafc5427..eee9bc648c 100755 --- a/qpid/cpp/src/tests/cli_tests.py +++ b/qpid/cpp/src/tests/cli_tests.py @@ -69,47 +69,39 @@ class CliTests(TestBase010): self.startBrokerAccess() queue1 = self.makeQueue("test_queue_params1", "--limit-policy none") queue2 = self.makeQueue("test_queue_params2", "--limit-policy reject") - queue3 = self.makeQueue("test_queue_params3", "--limit-policy flow-to-disk") - queue4 = self.makeQueue("test_queue_params4", "--limit-policy ring") - queue5 = self.makeQueue("test_queue_params5", "--limit-policy ring-strict") + queue3 = self.makeQueue("test_queue_params3", "--limit-policy ring") LIMIT = "qpid.policy_type" assert LIMIT not in queue1.arguments self.assertEqual(queue2.arguments[LIMIT], "reject") - self.assertEqual(queue3.arguments[LIMIT], "flow_to_disk") - self.assertEqual(queue4.arguments[LIMIT], "ring") - self.assertEqual(queue5.arguments[LIMIT], "ring_strict") + self.assertEqual(queue3.arguments[LIMIT], "ring") - queue6 = self.makeQueue("test_queue_params6", "--lvq-key lkey") + queue4 = self.makeQueue("test_queue_params4", "--lvq-key lkey") LVQKEY = "qpid.last_value_queue_key" - assert LVQKEY not in queue5.arguments - assert LVQKEY in queue6.arguments - assert queue6.arguments[LVQKEY] == "lkey" + assert LVQKEY not in queue3.arguments + assert LVQKEY in queue4.arguments + assert queue4.arguments[LVQKEY] == "lkey" def test_queue_params_api(self): self.startBrokerAccess() queue1 = self.makeQueue("test_queue_params_api1", "--limit-policy none", True) queue2 = self.makeQueue("test_queue_params_api2", "--limit-policy reject", True) - queue3 = self.makeQueue("test_queue_params_api3", "--limit-policy flow-to-disk", True) - queue4 = self.makeQueue("test_queue_params_api4", "--limit-policy ring", True) - queue5 = self.makeQueue("test_queue_params_api5", "--limit-policy ring-strict", True) + queue3 = self.makeQueue("test_queue_params_api3", "--limit-policy ring", True) LIMIT = "qpid.policy_type" assert LIMIT not in queue1.arguments self.assertEqual(queue2.arguments[LIMIT], "reject") - self.assertEqual(queue3.arguments[LIMIT], "flow_to_disk") - self.assertEqual(queue4.arguments[LIMIT], "ring") - self.assertEqual(queue5.arguments[LIMIT], "ring_strict") + self.assertEqual(queue3.arguments[LIMIT], "ring") - queue6 = self.makeQueue("test_queue_params_api6", "--lvq-key lkey") + queue4 = self.makeQueue("test_queue_params_api4", "--lvq-key lkey") LVQKEY = "qpid.last_value_queue_key" - assert LVQKEY not in queue5.arguments - assert LVQKEY in queue6.arguments - assert queue6.arguments[LVQKEY] == "lkey" + assert LVQKEY not in queue3.arguments + assert LVQKEY in queue4.arguments + assert queue4.arguments[LVQKEY] == "lkey" def test_qpid_config(self): diff --git a/qpid/cpp/src/tests/failing-amqp0-10-python-tests b/qpid/cpp/src/tests/failing-amqp0-10-python-tests new file mode 100644 index 0000000000..cb742a25e5 --- /dev/null +++ b/qpid/cpp/src/tests/failing-amqp0-10-python-tests @@ -0,0 +1,7 @@ +#The following four tests fail the because pure python client excludes +#the node type for queues from the reply-to address, weheras the swigged +#client does not (as that prevents it resolving the node on every send) +qpid.tests.messaging.message.MessageEchoTests.testReplyTo +qpid.tests.messaging.message.MessageEchoTests.testReplyToQueue +qpid.tests.messaging.message.MessageEchoTests.testReplyToQueueSubject +qpid.tests.messaging.message.MessageEchoTests.testProperties diff --git a/qpid/cpp/src/tests/failing-amqp1.0-python-tests b/qpid/cpp/src/tests/failing-amqp1.0-python-tests new file mode 100644 index 0000000000..2cae7b6306 --- /dev/null +++ b/qpid/cpp/src/tests/failing-amqp1.0-python-tests @@ -0,0 +1,2 @@ +qpid_tests.broker_0_10.new_api.GeneralTests.test_qpid_3481_acquired_to_alt_exchange_2_consumers +qpid_tests.broker_0_10.new_api.GeneralTests.test_qpid_3481_acquired_to_alt_exchange diff --git a/qpid/cpp/src/tests/ha_test.py b/qpid/cpp/src/tests/ha_test.py index f2fc50054f..3b5874875a 100755 --- a/qpid/cpp/src/tests/ha_test.py +++ b/qpid/cpp/src/tests/ha_test.py @@ -48,6 +48,24 @@ class QmfAgent(object): address, client_properties={"qpid.ha-admin":1}, **kwargs) self._agent = BrokerAgent(self._connection) + def queues(self): + return [q.values['name'] for q in self._agent.getAllQueues()] + + def repsub_queue(self, sub): + """If QMF subscription sub is a replicating subscription return + the name of the replicated queue, else return None""" + session_name = self.getSession(sub.sessionRef).name + m = re.search("qpid.ha-q:(.*)\.", session_name) + return m and m.group(1) + + def repsub_queues(self): + """Return queue names for all replicating subscriptions""" + return filter(None, [self.repsub_queue(s) for s in self.getAllSubscriptions()]) + + def tx_queues(self): + """Return names of all tx-queues""" + return [q for q in self.queues() if q.startswith("qpid.ha-tx")] + def __getattr__(self, name): a = getattr(self._agent, name) return a @@ -101,6 +119,9 @@ class HaBroker(Broker): """Start a broker with HA enabled @param client_cred: (user, password, mechanism) for admin clients started by the HaBroker. """ + + heartbeat=2 + def __init__(self, test, ha_port=None, args=[], brokers_url=None, ha_cluster=True, ha_replicate="all", client_credentials=None, **kwargs): assert BrokerTest.ha_lib, "Cannot locate HA plug-in" @@ -112,7 +133,7 @@ class HaBroker(Broker): "--link-maintenance-interval=0.1", # Heartbeat and negotiate time are needed so that a broker wont # stall on an address that doesn't currently have a broker running. - "--link-heartbeat-interval=1", + "--link-heartbeat-interval=%s"%(HaBroker.heartbeat), "--max-negotiate-time=1000", "--ha-cluster=%s"%ha_cluster] if ha_replicate is not None: @@ -139,15 +160,18 @@ acl allow all all self.client_credentials = client_credentials self.ha_port = ha_port - def __str__(self): return Broker.__str__(self) + def __repr__(self): return "<HaBroker:%s:%d>"%(self.log, self.port()) def qpid_ha(self, args): - cred = self.client_credentials - url = self.host_port() - if cred: - url =cred.add_user(url) - args = args + ["--sasl-mechanism", cred.mechanism] - self.qpid_ha_script.main_except(["", "-b", url]+args) + try: + cred = self.client_credentials + url = self.host_port() + if cred: + url =cred.add_user(url) + args = args + ["--sasl-mechanism", cred.mechanism] + self.qpid_ha_script.main_except(["", "-b", url]+args) + except Exception, e: + raise Exception("Error in qpid_ha -b %s %s: %s"%(url, args,e)) def promote(self): self.ready(); self.qpid_ha(["promote"]) def set_public_url(self, url): self.qpid_ha(["set", "--public-url", url]) @@ -221,6 +245,12 @@ acl allow all all def wait_backup(self, address): self.wait_address(address) + def browse(self, queue, timeout=0, transform=lambda m: m.content): + c = self.connect_admin() + try: + return browse(c.session(), queue, timeout, transform) + finally: c.close() + def assert_browse(self, queue, expected, **kwargs): """Verify queue contents by browsing.""" bs = self.connect().session() @@ -247,8 +277,10 @@ acl allow all all try: return self.connect() except ConnectionError: return None - def ready(self): - return Broker.ready(self, client_properties={"qpid.ha-admin":1}) + def ready(self, *args, **kwargs): + if not 'client_properties' in kwargs: kwargs['client_properties'] = {} + kwargs['client_properties']['qpid.ha-admin'] = True + return Broker.ready(self, *args, **kwargs) def kill(self, final=True): if final: self.ha_port.stop() @@ -259,16 +291,19 @@ acl allow all all class HaCluster(object): _cluster_count = 0 - def __init__(self, test, n, promote=True, wait=True, args=[], **kwargs): + def __init__(self, test, n, promote=True, wait=True, args=[], s_args=[], **kwargs): """Start a cluster of n brokers. @test: The test being run @n: start n brokers @promote: promote self[0] to primary @wait: wait for primary active and backups ready. Ignored if promote=False + @args: args for all brokers in the cluster. + @s_args: args for specific brokers: s_args[i] for broker i. """ self.test = test - self.args = args + self.args = copy(args) + self.s_args = copy(s_args) self.kwargs = kwargs self._ports = [HaPort(test) for i in xrange(n)] self._set_url() @@ -288,10 +323,13 @@ class HaCluster(object): self.broker_id += 1 return name - def _ha_broker(self, ha_port, name): + def _ha_broker(self, i, name): + args = self.args + if i < len(self.s_args): args += self.s_args[i] + ha_port = self._ports[i] b = HaBroker(ha_port.test, ha_port, brokers_url=self.url, name=name, - args=self.args, **self.kwargs) - b.ready() + args=args, **self.kwargs) + b.ready(timeout=5) return b def start(self): @@ -302,7 +340,7 @@ class HaCluster(object): self._ports.append(HaPort(self.test)) self._set_url() self._update_urls() - b = self._ha_broker(self._ports[i], self.next_name()) + b = self._ha_broker(i, self.next_name()) self._brokers.append(b) return b @@ -328,7 +366,7 @@ class HaCluster(object): a separate log file: foo.n.log""" if self._ports[i].stopped: raise Exception("Restart after final kill: %s"%(self)) b = self._brokers[i] - self._brokers[i] = self._ha_broker(self._ports[i], b.name) + self._brokers[i] = self._ha_broker(i, b.name) self._brokers[i].ready() def bounce(self, i, promote_next=True): diff --git a/qpid/cpp/src/tests/ha_tests.py b/qpid/cpp/src/tests/ha_tests.py index 293712fe80..6941a2b545 100755 --- a/qpid/cpp/src/tests/ha_tests.py +++ b/qpid/cpp/src/tests/ha_tests.py @@ -20,7 +20,7 @@ import os, signal, sys, time, imp, re, subprocess, glob, random, logging, shutil, math, unittest import traceback -from qpid.messaging import Message, SessionError, NotFound, ConnectionError, ReceiverError, Connection, Timeout, Disposition, REJECTED, Empty +from qpid.messaging import Message, SessionError, NotFound, ConnectionError, ReceiverError, Connection, Timeout, Disposition, REJECTED, Empty, ServerError from qpid.datatypes import uuid4, UUID from brokertest import * from ha_test import * @@ -37,6 +37,7 @@ def grep(filename, regexp): class HaBrokerTest(BrokerTest): """Base class for HA broker tests""" + def assert_log_no_errors(self, broker): log = broker.get_log() if grep(log, re.compile("] error|] critical")): @@ -219,7 +220,8 @@ class ReplicationTests(HaBrokerTest): backup.connect_admin().close() # Test discovery: should connect to primary after reject by backup - c = backup.connect(reconnect_urls=[primary.host_port(), backup.host_port()], reconnect=True) + c = backup.connect(reconnect_urls=[primary.host_port(), backup.host_port()], + reconnect=True) s = c.session() sender = s.sender("q;{create:always}") backup.wait_backup("q") @@ -561,9 +563,9 @@ class ReplicationTests(HaBrokerTest): return acl=os.path.join(os.getcwd(), "policy.acl") aclf=file(acl,"w") - # Verify that replication works with auth=yes and HA user has at least the following - # privileges: + # Minimum set of privileges required for the HA user. aclf.write(""" +# HA user acl allow zag@QPID access queue acl allow zag@QPID create queue acl allow zag@QPID consume queue @@ -575,6 +577,9 @@ acl allow zag@QPID publish exchange acl allow zag@QPID delete exchange acl allow zag@QPID access method acl allow zag@QPID create link +# Normal user +acl allow zig@QPID all all + acl deny all all """) aclf.close() @@ -585,14 +590,16 @@ acl deny all all "--ha-username=zag", "--ha-password=zag", "--ha-mechanism=PLAIN" ], client_credentials=Credentials("zag", "zag", "PLAIN")) - s0 = cluster[0].connect(username="zag", password="zag").session(); - s0.receiver("q;{create:always}") - s0.receiver("ex;{create:always,node:{type:topic,x-declare:{type:'fanout'},x-bindings:[{exchange:'ex',queue:'q'}]}}") - cluster[1].wait_backup("q") - cluster[1].wait_backup("ex") - s1 = cluster[1].connect_admin().session(); # Uses Credentials above. - s1.sender("ex").send("foo"); - self.assertEqual(s1.receiver("q").fetch().content, "foo") + c = cluster[0].connect(username="zig", password="zig") + s0 = c.session(); + s0.sender("q;{create:always}") + s0.sender("ex;{create:always,node:{type:topic,x-declare:{type:'fanout'},x-bindings:[{exchange:'ex',queue:'q'}]}}") + s0.sender("ex").send("foo"); + s1 = c.session(transactional=True) + s1.sender("ex").send("foo-tx"); + cluster[1].assert_browse_backup("q", ["foo"]) + s1.commit() + cluster[1].assert_browse_backup("q", ["foo", "foo-tx"]) def test_alternate_exchange(self): """Verify that alternate-exchange on exchanges and queues is propagated @@ -927,20 +934,22 @@ class LongTests(HaBrokerTest): if d: return float(d)*60 else: return 3 # Default is to be quick - # FIXME aconway 2013-06-27: skip this test pending a fix for - # https://issues.apache.org/jira/browse/QPID-4944 - def skip_test_failover_send_receive(self): + def test_failover_send_receive(self): """Test failover with continuous send-receive""" brokers = HaCluster(self, 3) # Start sender and receiver threads n = 10 - senders = [NumberedSender(brokers[0], url=brokers.url, - max_depth=1024, failover_updates=False, - queue="test%s"%(i)) for i in xrange(n)] - receivers = [NumberedReceiver(brokers[0], url=brokers.url, sender=senders[i], - failover_updates=False, - queue="test%s"%(i)) for i in xrange(n)] + senders = [ + NumberedSender( + brokers[0], url=brokers.url,max_depth=50, failover_updates=False, + queue="test%s"%(i), args=["--capacity=10"]) for i in xrange(n)] + + receivers = [ + NumberedReceiver( + brokers[0], url=brokers.url, sender=senders[i],failover_updates=False, + queue="test%s"%(i), args=["--capacity=10"]) for i in xrange(n)] + for r in receivers: r.start() for s in senders: s.start() @@ -991,7 +1000,7 @@ class LongTests(HaBrokerTest): finally: for s in senders: s.stop() for r in receivers: r.stop() - dead = filter(lambda i: not brokers[i].is_running(), xrange(3)) + dead = filter(lambda b: not b.is_running(), brokers) if dead: raise Exception("Brokers not running: %s"%dead) def test_qmf_order(self): @@ -1200,7 +1209,7 @@ class ConfigurationTests(HaBrokerTest): cluster[0].set_brokers_url(cluster.url+",xxx:1234") self.assertRaises(Empty, r.fetch, 0) # Not updated for brokers URL -class StoreTests(BrokerTest): +class StoreTests(HaBrokerTest): """Test for HA with persistence.""" def check_skip(self): @@ -1248,7 +1257,7 @@ class StoreTests(BrokerTest): doing catch-up from the primary.""" if self.check_skip(): return cluster = HaCluster(self, 2) - sn = cluster[0].connect(heartbeat=1).session() + sn = cluster[0].connect(heartbeat=HaBroker.heartbeat).session() s1 = sn.sender("q1;{create:always,node:{durable:true}}") for m in ["foo","bar"]: s1.send(Message(m, durable=True)) s2 = sn.sender("q2;{create:always,node:{durable:true}}") @@ -1259,7 +1268,7 @@ class StoreTests(BrokerTest): cluster[1].assert_browse_backup("q2", ["hello"]) # Make changes that the backup doesn't see cluster.kill(1, promote_next=False, final=False) - r1 = cluster[0].connect(heartbeat=1).session().receiver("q1") + r1 = cluster[0].connect(heartbeat=HaBroker.heartbeat).session().receiver("q1") for m in ["foo", "bar"]: self.assertEqual(r1.fetch().content, m) r1.session.acknowledge() for m in ["x","y","z"]: s1.send(Message(m, durable=True)) @@ -1278,7 +1287,7 @@ class StoreTests(BrokerTest): cluster[0].assert_browse("q1", ["x","y","z"]) cluster[1].assert_browse_backup("q1", ["x","y","z"]) - sn = cluster[0].connect(heartbeat=1).session() # FIXME aconway 2012-09-25: should fail over! + sn = cluster[0].connect(heartbeat=HaBroker.heartbeat).session() sn.sender("ex/k1").send("boo") cluster[0].assert_browse_backup("q1", ["x","y","z", "boo"]) cluster[1].assert_browse_backup("q1", ["x","y","z", "boo"]) @@ -1287,6 +1296,185 @@ class StoreTests(BrokerTest): cluster[0].assert_browse("q2", ["hello", "end"]) cluster[1].assert_browse_backup("q2", ["hello", "end"]) +def open_read(name): + try: + f = open(name) + return f.read() + finally: f.close() + +class TransactionTests(HaBrokerTest): + + load_store=["--load-module", BrokerTest.test_store_lib] + + def tx_simple_setup(self, broker): + """Start a transaction, remove messages from queue a, add messages to queue b""" + c = broker.connect() + # Send messages to a, no transaction. + sa = c.session().sender("a;{create:always,node:{durable:true}}") + tx_msgs = ["x","y","z"] + for m in tx_msgs: sa.send(Message(content=m, durable=True)) + + # Receive messages from a, in transaction. + tx = c.session(transactional=True) + txr = tx.receiver("a") + tx_msgs2 = [txr.fetch(1).content for i in xrange(3)] + self.assertEqual(tx_msgs, tx_msgs2) + + # Send messages to b, transactional, mixed with non-transactional. + sb = c.session().sender("b;{create:always,node:{durable:true}}") + txs = tx.sender("b") + msgs = [str(i) for i in xrange(3)] + for tx_m,m in zip(tx_msgs2, msgs): + txs.send(tx_m); + sb.send(m) + return tx + + def tx_subscriptions(self, broker): + """Return list of queue names for tx subscriptions""" + return [q for q in broker.agent().repsub_queues() + if q.startswith("qpid.ha-tx")] + + def test_tx_simple_commit(self): + cluster = HaCluster(self, 2, test_store=True) + tx = self.tx_simple_setup(cluster[0]) + tx.sync() + tx_queues = cluster[0].agent().tx_queues() + + # NOTE: backup does not process transactional dequeues until prepare + cluster[1].assert_browse_backup("a", ["x","y","z"]) + cluster[1].assert_browse_backup("b", ['0', '1', '2']) + + tx.acknowledge() + tx.commit() + tx.sync() + + for b in cluster: self.assert_simple_commit_outcome(b, tx_queues) + + def assert_tx_cleanup(self, b, tx_queues): + """Verify that there are no transaction artifacts + (exchanges, queues, subscriptions) on b.""" + + self.assertEqual(0, len(b.agent().tx_queues()), msg=b) + self.assertEqual(0, len(self.tx_subscriptions(b)), msg=b) + + # TX exchanges don't show up in management so test for existence by name. + s = b.connect_admin().session() + try: + for q in tx_queues: + try: + s.sender("%s;{node:{type:topic}}"%q) + self.fail("Found tx exchange %s on %s "%(q,b)) + except NotFound: pass + finally: s.connection.close() + + def assert_simple_commit_outcome(self, b, tx_queues): + b.assert_browse_backup("a", [], msg=b) + b.assert_browse_backup("b", ['0', '1', '2', 'x', 'y', 'z'], msg=b) + # Check for expected actions on the store + expect = """<enqueue a x> +<enqueue a y> +<enqueue a z> +<begin tx 1> +<dequeue a x tx=1> +<dequeue a y tx=1> +<dequeue a z tx=1> +<commit tx=1> +""" + self.assertEqual(expect, open_read(b.store_log), msg=b) + self.assert_tx_cleanup(b, tx_queues) + + def test_tx_simple_rollback(self): + cluster = HaCluster(self, 2, test_store=True) + tx = self.tx_simple_setup(cluster[0]) + tx.sync() + tx_queues = cluster[0].agent().tx_queues() + tx.acknowledge() + tx.rollback() + for b in cluster: self.assert_simple_rollback_outcome(b, tx_queues) + + def assert_simple_rollback_outcome(self, b, tx_queues): + b.assert_browse_backup("a", ["x","y","z"], msg=b) + b.assert_browse_backup("b", ['0', '1', '2'], msg=b) + # Check for expected actions on the store + expect = """<enqueue a x> +<enqueue a y> +<enqueue a z> +""" + self.assertEqual(open_read(b.store_log), expect, msg=b) + self.assert_tx_cleanup(b, tx_queues) + + def test_tx_simple_failover(self): + cluster = HaCluster(self, 3, test_store=True) + tx = self.tx_simple_setup(cluster[0]) + tx.sync() + tx_queues = cluster[0].agent().tx_queues() + tx.acknowledge() + cluster.bounce(0) # Should cause roll-back + cluster[0].wait_status("ready") # Restarted. + cluster[1].wait_status("active") # Promoted. + cluster[2].wait_status("ready") # Failed over. + for b in cluster: self.assert_simple_rollback_outcome(b, tx_queues) + + def test_tx_no_backups(self): + """Test the special case of a TX where there are no backups""" + + # Test commit + cluster = HaCluster(self, 1, test_store=True) + tx = self.tx_simple_setup(cluster[0]) + tx.acknowledge() + tx.commit() + tx.sync() + tx_queues = cluster[0].agent().tx_queues() + self.assert_simple_commit_outcome(cluster[0], tx_queues) + + # Test rollback + cluster = HaCluster(self, 1, test_store=True) + tx = self.tx_simple_setup(cluster[0]) + tx.sync() + tx_queues = cluster[0].agent().tx_queues() + tx.acknowledge() + tx.rollback() + tx.sync() + self.assert_simple_rollback_outcome(cluster[0], tx_queues) + + + def test_tx_backup_fail(self): + cluster = HaCluster( + self, 2, test_store=True, s_args=[[],["--test-store-throw=bang"]]) + c = cluster[0].connect() + tx = c.session(transactional=True) + s = tx.sender("q;{create:always,node:{durable:true}}") + for m in ["foo","bang","bar"]: s.send(Message(m, durable=True)) + self.assertRaises(ServerError, tx.commit) + for b in cluster: b.assert_browse_backup("q", []) + self.assertEqual(open_read(cluster[0].store_log), "<begin tx 1>\n<abort tx=1>\n") + self.assertEqual(open_read(cluster[1].store_log), "<begin tx 1>\n<enqueue q foo tx=1>\n<enqueue q bang tx=1>\n<abort tx=1>\n") + + def test_tx_join_leave(self): + """Test cluster members joining/leaving cluster. + Also check that tx-queues are cleaned up at end of transaction.""" + + cluster = HaCluster(self, 3) + + # Leaving + tx = cluster[0].connect().session(transactional=True) + s = tx.sender("q;{create:always}") + s.send("a", sync=True) + self.assertEqual([1,1,1], [len(b.agent().tx_queues()) for b in cluster]) + cluster[1].kill(final=False) + s.send("b") + self.assertRaises(ServerError, tx.commit) + self.assertEqual([[],[]], [b.agent().tx_queues() for b in [cluster[0],cluster[2]]]) + + # Joining + tx = cluster[0].connect().session(transactional=True) + s = tx.sender("q;{create:always}") + s.send("foo") + cluster.restart(1) + tx.commit() + # The new member is not in the tx but receives the results normal replication. + for b in cluster: b.assert_browse_backup("q", ["foo"], msg=b) + if __name__ == "__main__": outdir = "ha_tests.tmp" shutil.rmtree(outdir, True) diff --git a/qpid/cpp/src/tests/interlink_tests.py b/qpid/cpp/src/tests/interlink_tests.py index 129283ac24..608d4ac890 100755 --- a/qpid/cpp/src/tests/interlink_tests.py +++ b/qpid/cpp/src/tests/interlink_tests.py @@ -22,6 +22,7 @@ import os, signal, sys, time, imp, re, subprocess, glob, random, logging, shutil import traceback from qpid.messaging import Message, SessionError, NotFound, ConnectionError, ReceiverError, Connection, Timeout, Disposition, REJECTED, Empty from brokertest import * +from ha_test import HaPort from threading import Thread, Lock, Condition from logging import getLogger, WARN, ERROR, DEBUG, INFO from qpidtoollibs import BrokerAgent, BrokerObject @@ -46,7 +47,8 @@ class AmqpBrokerTest(BrokerTest): def setUp(self): BrokerTest.setUp(self) os.putenv("QPID_LOAD_MODULE", BrokerTest.amqpc_lib) - self.broker = self.amqp_broker() + self.port_holder = HaPort(self) + self.broker = self.amqp_broker(port_holder=self.port_holder) self.default_config = Config(self.broker) self.agent = BrokerAgent(self.broker.connect()) @@ -126,6 +128,9 @@ class AmqpBrokerTest(BrokerTest): def test_translate2(self): self.send_and_receive(send_config=Config(self.broker, version="amqp0-10")) + def test_translate_with_large_routingkey(self): + self.send_and_receive(send_config=Config(self.broker, address="amq.topic/a.%s" % ("x" * 256), version="amqp1.0"), recv_config=Config(self.broker, address="amq.topic/a.*", version="amqp0-10"), wait_for_receiver=True) + def send_and_receive_empty(self, send_config=None, recv_config=None): sconfig = send_config or self.default_config rconfig = recv_config or self.default_config @@ -218,16 +223,22 @@ class AmqpBrokerTest(BrokerTest): assert len(domains) == 1 assert domains[0].name == "BrokerB" - def test_incoming_link(self): + def incoming_link(self, mechanism): brokerB = self.amqp_broker() agentB = BrokerAgent(brokerB.connect()) self.agent.create("queue", "q") agentB.create("queue", "q") - self.agent.create("domain", "BrokerB", {"url":brokerB.host_port(), "sasl_mechanisms":"NONE"}) + self.agent.create("domain", "BrokerB", {"url":brokerB.host_port(), "sasl_mechanisms":mechanism}) self.agent.create("incoming", "Link1", {"domain":"BrokerB","source":"q","target":"q"}) #send to brokerB, receive from brokerA self.send_and_receive(send_config=Config(brokerB)) + def test_incoming_link_anonymous(self): + self.incoming_link("ANONYMOUS") + + def test_incoming_link_nosasl(self): + self.incoming_link("NONE") + def test_outgoing_link(self): brokerB = self.amqp_broker() agentB = BrokerAgent(brokerB.connect()) @@ -246,14 +257,73 @@ class AmqpBrokerTest(BrokerTest): #send to q on broker B through brokerA self.send_and_receive(send_config=Config(self.broker, address="q@BrokerB"), recv_config=Config(brokerB)) + def test_reconnect(self): + receiver_cmd = ["qpid-receive", + "--broker", self.broker.host_port(), + "--address=amq.fanout", + "--connection-options={protocol:amqp1.0, reconnect:True,container_id:receiver}", + "--timeout=10", "--print-content=true", "--print-headers=false" + ] + receiver = self.popen(receiver_cmd, stdout=PIPE) + + sender_cmd = ["qpid-send", + "--broker", self.broker.host_port(), + "--address=amq.fanout", + "--connection-options={protocol:amqp1.0,reconnect:True,container_id:sender}", + "--content-stdin", "--send-eos=1" + ] + sender = self.popen(sender_cmd, stdin=PIPE) + sender._set_cloexec_flag(sender.stdin) #required for older python, see http://bugs.python.org/issue4112 + + + batch1 = ["message-%s" % (i+1) for i in range(10000)] + for m in batch1: + sender.stdin.write(m + "\n") + sender.stdin.flush() + + self.broker.kill() + self.broker = self.amqp_broker(port_holder=self.port_holder) + + batch2 = ["message-%s" % (i+1) for i in range(10000, 20000)] + for m in batch2: + sender.stdin.write(m + "\n") + sender.stdin.flush() + + sender.stdin.close() + + last = None + m = receiver.stdout.readline().rstrip() + while len(m): + last = m + m = receiver.stdout.readline().rstrip() + assert last == "message-20000", (last) + """ Create and return a broker with AMQP 1.0 support """ def amqp_broker(self): assert BrokerTest.amqp_lib, "Cannot locate AMQP 1.0 plug-in" + self.port_holder = HaPort(self) #reserve port args = ["--load-module", BrokerTest.amqp_lib, - "--max-negotiate-time=600000", + "--socket-fd=%s" % self.port_holder.fileno, + "--listen-disable=tcp", "--log-enable=trace+:Protocol", "--log-enable=info+"] - return BrokerTest.broker(self, args) + return BrokerTest.broker(self, args, port=self.port_holder.port) + + def amqp_broker(self, port_holder=None): + assert BrokerTest.amqp_lib, "Cannot locate AMQP 1.0 plug-in" + if port_holder: + args = ["--load-module", BrokerTest.amqp_lib, + "--socket-fd=%s" % port_holder.fileno, + "--listen-disable=tcp", + "--log-enable=trace+:Protocol", + "--log-enable=info+"] + return BrokerTest.broker(self, args, port=port_holder.port) + else: + args = ["--load-module", BrokerTest.amqp_lib, + "--log-enable=trace+:Protocol", + "--log-enable=info+"] + return BrokerTest.broker(self, args) + if __name__ == "__main__": shutil.rmtree("brokertest.tmp", True) diff --git a/qpid/cpp/src/tests/qpid-cluster-lag.py b/qpid/cpp/src/tests/qpid-cluster-lag.py deleted file mode 100755 index 5b24353241..0000000000 --- a/qpid/cpp/src/tests/qpid-cluster-lag.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/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. -# - -"""%prog [options] broker... -Check for brokers that lag behind other brokers in a cluster.""" - -import os, os.path, sys, socket, time, re -from qpid.messaging import * -from optparse import OptionParser -from threading import Thread - -class Browser(Thread): - def __init__(self, broker, queue, timeout): - Thread.__init__(self) - self.broker = broker - self.queue = queue - self.timeout = timeout - self.error = None - self.time = None - - def run(self): - try: - self.connection = Connection(self.broker) - self.connection.open() - self.session = self.connection.session() - self.receiver = self.session.receiver("%s;{mode:browse}"%self.queue) - self.msg = self.receiver.fetch(timeout=self.timeout) - self.time = time.time() - if (self.msg.content != self.queue): - raise Exception("Wrong message content, expected '%s' found '%s'"% - (self.queue, self.msg.content)) - except Empty: - self.error = "No message on queue %s"%self.queue - except Exception, e: - self.error = "Error: %s"%e - -def main(argv): - op = OptionParser(usage=__doc__) - op.add_option("--timeout", type="float", default=None, metavar="TIMEOUT", - help="Give up after TIMEOUT milliseconds, default never timeout") - (opts, args) = op.parse_args(argv) - if (len(args) <= 1): op.error("No brokers were specified") - brokers = args[1:] - - # Put a message on a uniquely named queue. - queue = "%s:%s:%s"%(os.path.basename(args[0]), socket.gethostname(), os.getpid()) - connection = Connection(brokers[0]) - connection.open() - session = connection.session() - sender = session.sender( - "%s;{create:always,delete:always,node:{durable:False}}"%queue) - sender.send(Message(content=queue)) - start = time.time() - # Browse for the message on each broker - if opts.timeout: opts.timeout - threads = [Browser(b, queue, opts.timeout) for b in brokers] - for t in threads: t.start() - delays=[] - - for t in threads: - t.join() - if t.error: - delay=t.error - else: - delay = t.time-start - delays.append([delay, t.broker]) - print "%s: %s"%(t.broker,delay) - if delays: - delays.sort() - print "lag: %s (%s-%s)"%(delays[-1][0] - delays[0][0], delays[-1][1], delays[0][1]) - # Clean up - sender.close() - session.close() - connection.close() - -if __name__ == "__main__": sys.exit(main(sys.argv)) diff --git a/qpid/cpp/src/tests/qpid-receive.cpp b/qpid/cpp/src/tests/qpid-receive.cpp index 510e9be42c..ab26d3d9b5 100644 --- a/qpid/cpp/src/tests/qpid-receive.cpp +++ b/qpid/cpp/src/tests/qpid-receive.cpp @@ -69,11 +69,12 @@ struct Options : public qpid::Options string readyAddress; uint receiveRate; std::string replyto; + bool noReplies; Options(const std::string& argv0=std::string()) : qpid::Options("Options"), help(false), - url("amqp:tcp:127.0.0.1"), + url("127.0.0.1"), timeout(0), forever(false), messages(0), @@ -91,7 +92,8 @@ struct Options : public qpid::Options reportTotal(false), reportEvery(0), reportHeader(true), - receiveRate(0) + receiveRate(0), + noReplies(false) { addOptions() ("broker,b", qpid::optValue(url, "URL"), "url of broker to connect to") @@ -116,6 +118,7 @@ struct Options : public qpid::Options ("ready-address", qpid::optValue(readyAddress, "ADDRESS"), "send a message to this address when ready to receive") ("receive-rate", qpid::optValue(receiveRate,"N"), "Receive at rate of N messages/second. 0 means receive as fast as possible.") ("reply-to", qpid::optValue(replyto, "REPLY-TO"), "specify reply-to address on response messages") + ("ignore-reply-to", qpid::optValue(noReplies), "Do not send replies even if reply-to is set") ("help", qpid::optValue(help), "print this usage statement"); add(log); } @@ -222,6 +225,7 @@ int main(int argc, char ** argv) if (opts.printHeaders) { if (msg.getSubject().size()) std::cout << "Subject: " << msg.getSubject() << std::endl; if (msg.getReplyTo()) std::cout << "ReplyTo: " << msg.getReplyTo() << std::endl; + if (msg.getMessageId().size()) std::cout << "MessageId: " << msg.getMessageId() << std::endl; if (msg.getCorrelationId().size()) std::cout << "CorrelationId: " << msg.getCorrelationId() << std::endl; if (msg.getUserId().size()) std::cout << "UserId: " << msg.getUserId() << std::endl; if (msg.getTtl().getMilliseconds()) std::cout << "TTL: " << msg.getTtl().getMilliseconds() << std::endl; @@ -231,8 +235,10 @@ int main(int argc, char ** argv) std::cout << "Properties: " << msg.getProperties() << std::endl; std::cout << std::endl; } - if (opts.printContent) - std::cout << msg.getContent() << std::endl;//TODO: handle map or list messages + if (opts.printContent) { + if (!msg.getContentObject().isVoid()) std::cout << msg.getContentObject() << std::endl; + else std::cout << msg.getContent() << std::endl; + } if (opts.messages && count >= opts.messages) done = true; } } @@ -245,7 +251,7 @@ int main(int argc, char ** argv) } else if (opts.ackFrequency && (count % opts.ackFrequency == 0)) { session.acknowledge(); } - if (msg.getReplyTo()) { // Echo message back to reply-to address. + if (msg.getReplyTo() && !opts.noReplies) { // Echo message back to reply-to address. Sender& s = replyTo[msg.getReplyTo().str()]; if (s.isNull()) { s = session.createSender(msg.getReplyTo()); @@ -260,8 +266,6 @@ int main(int argc, char ** argv) int64_t delay = qpid::sys::Duration(qpid::sys::now(), waitTill); if (delay > 0) qpid::sys::usleep(delay/qpid::sys::TIME_USEC); } - // Clear out message properties & content for next iteration. - msg = Message(); // TODO aconway 2010-12-01: should be done by fetch } if (opts.reportTotal) reporter.report(); if (opts.tx) { diff --git a/qpid/cpp/src/tests/qpid-send.cpp b/qpid/cpp/src/tests/qpid-send.cpp index c3bba31e3b..f912b84e8e 100644 --- a/qpid/cpp/src/tests/qpid-send.cpp +++ b/qpid/cpp/src/tests/qpid-send.cpp @@ -96,7 +96,7 @@ struct Options : public qpid::Options Options(const std::string& argv0=std::string()) : qpid::Options("Options"), help(false), - url("amqp:tcp:127.0.0.1"), + url("127.0.0.1"), messages(1), sendEos(0), durable(false), @@ -262,9 +262,8 @@ class MapContentGenerator : public ContentGenerator { public: MapContentGenerator(const Options& opt) : opts(opt) {} virtual bool setContent(Message& msg) { - Variant::Map map; - opts.setEntries(map); - encode(map, msg); + msg.getContentObject() = qpid::types::Variant::Map(); + opts.setEntries(msg.getContentObject().asMap()); return true; } private: @@ -371,6 +370,7 @@ int main(int argc, char ** argv) msg.setReplyTo(Address(opts.replyto)); } if (!opts.userid.empty()) msg.setUserId(opts.userid); + if (!opts.id.empty()) msg.setMessageId(opts.id); if (!opts.correlationid.empty()) msg.setCorrelationId(opts.correlationid); opts.setProperties(msg); uint sent = 0; diff --git a/qpid/cpp/src/tests/qpidd_qmfv2_tests.py b/qpid/cpp/src/tests/qpidd_qmfv2_tests.py index 36fbe4b438..55497ccc03 100755 --- a/qpid/cpp/src/tests/qpidd_qmfv2_tests.py +++ b/qpid/cpp/src/tests/qpidd_qmfv2_tests.py @@ -39,20 +39,25 @@ class ConsoleTest(BrokerTest): def setUp(self): BrokerTest.setUp(self) - args = ["--mgmt-qmf1=no", - "--mgmt-pub-interval=%d" % self.PUB_INTERVAL] + + def _startBroker(self, QMFv1=False ): + self._broker_is_v1 = QMFv1 + if self._broker_is_v1: + args = ["--mgmt-qmf1=yes", "--mgmt-qmf2=no"] + else: + args = ["--mgmt-qmf1=no", "--mgmt-qmf2=yes"] + + args.append("--mgmt-pub-interval=%d" % self.PUB_INTERVAL) self.broker = BrokerTest.broker(self, args) - def _startQmfV2(self, broker, console=None): + + def _myStartQmf(self, broker, console=None): # I manually set up the QMF session here rather than call the startQmf # method from BrokerTest as I can guarantee the console library is used # (assuming BrokerTest's implementation of startQmf could change) self.qmf_session = qmf.console.Session(console) self.qmf_broker = self.qmf_session.addBroker("%s:%s" % (broker.host(), broker.port())) - self.assertEqual(self.qmf_broker.getBrokerAgent().isV2, True, - "Expected broker agent to support QMF V2") - def _create_queue( self, q_name, args={} ): broker = self.qmf_session.getObjects(_class="broker")[0] @@ -60,11 +65,11 @@ class ConsoleTest(BrokerTest): self.assertEqual(result.status, 0, result) - def test_method_call(self): + def _test_method_call(self): """ Verify method calls work, and check the behavior of getObjects() call """ - self._startQmfV2( self.broker ) + self._myStartQmf( self.broker ) self._create_queue( "fleabag", {"auto-delete":True} ) qObj = None @@ -76,12 +81,16 @@ class ConsoleTest(BrokerTest): self.assertNotEqual(qObj, None, "Failed to get queue object") #print qObj - def test_unsolicited_updates(self): + def _test_unsolicited_updates(self): """ Verify that the Console callbacks work """ class Handler(qmf.console.Console): def __init__(self): + self.v1_oids = 0 + self.v1_events = 0 + self.v2_oids = 0 + self.v2_events = 0 self.broker_info = [] self.broker_conn = [] self.newpackage = [] @@ -109,28 +118,38 @@ class ConsoleTest(BrokerTest): def event(self, broker, event): #print "EVENT %s" % event self.events.append(event) - def objectProps(self, broker, record): - #print "ObjProps %s" % record - assert len(record.getProperties()), "objectProps() invoked with no properties?" + if event.isV2: + self.v2_events += 1 + else: + self.v1_events += 1 + + def heartbeat(self, agent, timestamp): + #print "Heartbeat %s" % agent + self.heartbeats.append( (agent, timestamp) ) + + # generic handler for objectProps and objectStats + def _handle_obj_update(self, record): oid = record.getObjectId() + if oid.isV2: + self.v2_oids += 1 + else: + self.v1_oids += 1 + if oid not in self.updates: self.updates[oid] = record else: self.updates[oid].mergeUpdate( record ) + + def objectProps(self, broker, record): + assert len(record.getProperties()), "objectProps() invoked with no properties?" + self._handle_obj_update(record) + def objectStats(self, broker, record): - #print "ObjStats %s" % record assert len(record.getStatistics()), "objectStats() invoked with no properties?" - oid = record.getObjectId() - if oid not in self.updates: - self.updates[oid] = record - else: - self.updates[oid].mergeUpdate( record ) - def heartbeat(self, agent, timestamp): - #print "Heartbeat %s" % agent - self.heartbeats.append( (agent, timestamp) ) + self._handle_obj_update(record) handler = Handler() - self._startQmfV2( self.broker, handler ) + self._myStartQmf( self.broker, handler ) # this should force objectProps, queueDeclare Event callbacks self._create_queue( "fleabag", {"auto-delete":True} ) # this should force objectStats callback @@ -163,7 +182,15 @@ class ConsoleTest(BrokerTest): break assert msgs == 3, "msgDepth statistics not accurate!" - def test_async_method(self): + # verify that the published objects were of the correct QMF version + if self._broker_is_v1: + assert handler.v1_oids and handler.v2_oids == 0, "QMFv2 updates received while in V1-only mode!" + assert handler.v1_events and handler.v2_events == 0, "QMFv2 events received while in V1-only mode!" + else: + assert handler.v2_oids and handler.v1_oids == 0, "QMFv1 updates received while in V2-only mode!" + assert handler.v2_events and handler.v1_events == 0, "QMFv1 events received while in V2-only mode!" + + def _test_async_method(self): class Handler (qmf.console.Console): def __init__(self): self.cv = Condition() @@ -207,12 +234,40 @@ class ConsoleTest(BrokerTest): return "fail (lost=%d, mismatch=%d, spurious=%d)" % (lost, mismatched, spurious) handler = Handler() - self._startQmfV2(self.broker, handler) + self._myStartQmf(self.broker, handler) broker = self.qmf_session.getObjects(_class="broker")[0] handler.request(broker, 20) sleep(1) self.assertEqual(handler.check(), "pass") + def test_method_call(self): + self._startBroker() + self._test_method_call() + + def test_unsolicited_updates(self): + self._startBroker() + self._test_unsolicited_updates() + + def test_async_method(self): + self._startBroker() + self._test_async_method() + + # For now, include "QMFv1 only" tests. Once QMFv1 is deprecated, these can + # be removed + + def test_method_call_v1(self): + self._startBroker(QMFv1=True) + self._test_method_call() + + def test_unsolicited_updates_v1(self): + self._startBroker(QMFv1=True) + self._test_unsolicited_updates() + + def test_async_method_v1(self): + self._startBroker(QMFv1=True) + self._test_async_method() + + if __name__ == "__main__": shutil.rmtree("brokertest.tmp", True) diff --git a/qpid/cpp/src/tests/qpidt b/qpid/cpp/src/tests/qpidt index 5bdfb6eefd..92df9efc8d 100755 --- a/qpid/cpp/src/tests/qpidt +++ b/qpid/cpp/src/tests/qpidt @@ -117,7 +117,7 @@ class Manager: if k == "name": name = v elif v: - if isinstance(v, dict) and v["_object_name"]: + if isinstance(v, dict) and "_object_name" in v: v = v["_object_name"] details += "%s=%s " %(k,v) print "%-25s %s" % (name, details) diff --git a/qpid/cpp/src/tests/queue_flow_limit_tests.py b/qpid/cpp/src/tests/queue_flow_limit_tests.py index c7361a629e..83e31e979b 100644 --- a/qpid/cpp/src/tests/queue_flow_limit_tests.py +++ b/qpid/cpp/src/tests/queue_flow_limit_tests.py @@ -27,6 +27,8 @@ from os import environ, popen class QueueFlowLimitTests(TestBase010): + _timeout = 100 + def __getattr__(self, name): if name == "assertGreater": return lambda a, b: self.failUnless(a > b) @@ -156,7 +158,7 @@ class QueueFlowLimitTests(TestBase010): totalMsgs = 1213 + 797 + 331 # wait until flow control is active - deadline = time() + 10 + deadline = time() + self._timeout while (not self.qmf.getObjects(_objectId=oid)[0].flowStopped) and \ time() < deadline: pass @@ -209,7 +211,7 @@ class QueueFlowLimitTests(TestBase010): totalMsgs = 1699 + 1129 + 881 # wait until flow control is active - deadline = time() + 10 + deadline = time() + self._timeout while (not self.qmf.getObjects(_objectId=oid)[0].flowStopped) and \ time() < deadline: pass @@ -255,7 +257,7 @@ class QueueFlowLimitTests(TestBase010): # fill up the queue, waiting until flow control is active sndr1 = self._start_qpid_send(testq.mgmt.name, count=testq.sendCount, content=testq.content) - deadline = time() + 10 + deadline = time() + self._timeout while (not testq.mgmt.flowStopped) and time() < deadline: testq.mgmt.update() @@ -357,7 +359,7 @@ class QueueFlowLimitTests(TestBase010): sender = BlockedSender(self, "kill-q", count=100) # wait for flow control - deadline = time() + 10 + deadline = time() + self._timeout while (not q.flowStopped) and time() < deadline: q.update() diff --git a/qpid/cpp/src/tests/rsynchosts b/qpid/cpp/src/tests/rsynchosts index 4f19c3b22a..81c9699ac3 100755 --- a/qpid/cpp/src/tests/rsynchosts +++ b/qpid/cpp/src/tests/rsynchosts @@ -27,13 +27,21 @@ abspath() { } usage() { - echo "Usage: $(basename $0) file [file...] + echo "Usage: $(basename $0) [-l user] file [file...] Synchronize the contents of each file or directory to the same absolute path on each host in \$HOSTS. " exit 1 } +while getopts "l:" opt; do + case $opt in + l) RSYNC_USER="$OPTARG@" ;; + *) usage ;; + esac +done +shift `expr $OPTIND - 1` + test "$*" || usage for f in $*; do FILES="$FILES $(abspath $f)" || exit 1; done @@ -42,7 +50,7 @@ OK_FILE=`mktemp` # Will be deleted if anything goes wrong. trap "rm -f $OK_FILE" EXIT for h in $HOSTS; do - rsync -aRO --delete $FILES $h:/ || { echo "rsync to $h failed"; rm -f $OK_FILE; } & + rsync -vaRO --delete $FILES $RSYNC_USER$h:/ || { echo "rsync to $h failed"; rm -f $OK_FILE; } & done wait test -f $OK_FILE diff --git a/qpid/cpp/src/tests/run-unit-tests b/qpid/cpp/src/tests/run-unit-tests deleted file mode 100755 index 5337a3dc22..0000000000 --- a/qpid/cpp/src/tests/run-unit-tests +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -# -# 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. -# - -# -# Library names (without path or .so) and CppUnit test paths can be -# specified on the command line or in env var UNIT_TESTS. For example: -# -# Selected test classes: -# ./run-unit-tests ValueTest ClientChannelTest -# -# Individual test method -# ./run-unit-tests ValueTest :ValueTest::testStringValueEquals -# -# Build and run selected tests: -# make check TESTS=run-unit-tests UNIT_TESTS=ClientChannelTest -# - -for u in $* $UNIT_TESTS ; do - case $u in - :*) TEST_ARGS="$TEST_ARGS $u" ;; # A test path. - *) TEST_ARGS="$TEST_ARGS .libs/$u.so" ;; # A test library. - esac -done -test -z "$TEST_ARGS" && TEST_ARGS=".libs/*Test.so" - -test -z "$srcdir" && srcdir=. - -# libdlclose_noop prevents unloading symbols needed for valgrind output. -export LD_PRELOAD=.libs/libdlclose_noop.so -source $srcdir/run_test DllPlugInTester -c -b $TEST_ARGS diff --git a/qpid/cpp/src/tests/run_cli_tests b/qpid/cpp/src/tests/run_cli_tests index a7f55d58b7..e9590080a1 100755 --- a/qpid/cpp/src/tests/run_cli_tests +++ b/qpid/cpp/src/tests/run_cli_tests @@ -44,8 +44,8 @@ start_brokers() { # look like they're xml related. # if we start supporting xml on windows, it will need something similar # here - if [ -f ../.libs/xml.so ] ; then - xargs="--load-module ../.libs/xml.so" + if [ -f ../xml.so ] ; then + xargs="--load-module ../xml.so" if [ ! -f test.xquery ] ; then create_test_xquery fi diff --git a/qpid/cpp/src/tests/run_federation_tests b/qpid/cpp/src/tests/run_federation_tests index 09219141ef..bf33f96ebd 100755 --- a/qpid/cpp/src/tests/run_federation_tests +++ b/qpid/cpp/src/tests/run_federation_tests @@ -25,7 +25,7 @@ source ./test_env.sh #set -x trap stop_brokers INT TERM QUIT -if [ -f ../.libs/xml.so ] ; then +if [ -f ../xml.so ] ; then MODULES="--load-module xml" # Load the XML exchange and run XML exchange federation tests SKIPTESTS= else diff --git a/qpid/cpp/src/tests/run_msg_group_tests.ps1 b/qpid/cpp/src/tests/run_msg_group_tests.ps1 new file mode 100644 index 0000000000..e9cee0a5a0 --- /dev/null +++ b/qpid/cpp/src/tests/run_msg_group_tests.ps1 @@ -0,0 +1,71 @@ +# +# 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. +# + +# Simple test of encode/decode of a double in application headers +# TODO: this should be expanded to cover a wider set of types and go +# in both directions + +$srcdir = Split-Path $myInvocation.InvocationName +$PYTHON_DIR = "$srcdir\..\..\..\python" +if (!(Test-Path $PYTHON_DIR -pathType Container)) { + "Skipping msg_group test as python libs not found" + exit 0 +} + +. .\test_env.ps1 + +if (Test-Path qpidd.port) { + set-item -path env:QPID_PORT -value (get-content -path qpidd.port -totalcount 1) +} + +# Test runs from the tests directory but the test executables are in a +# subdirectory based on the build type. Look around for it before trying +# to start it. +. $srcdir\find_prog.ps1 .\msg_group_test.exe +if (!(Test-Path $prog)) { + "Cannot locate msg_group_test.exe" + exit 1 +} + +$QUEUE_NAME="group-queue" +$GROUP_KEY="My-Group-Id" +$BROKER_URL="localhost:$env:QPID_PORT" + +$tests=@("python $QPID_CONFIG_EXEC -b $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups", + "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 3 --ack-frequency 7 --randomize-group-size --interleave 3", + "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 7 --ack-frequency 7 --randomize-group-size", + "python $QPID_CONFIG_EXEC -b $BROKER_URL add queue ${QUEUE_NAME}-two --group-header=${GROUP_KEY} --shared-groups", + "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 7 --ack-frequency 3 --randomize-group-size", + "$prog -b $BROKER_URL -a ${QUEUE_NAME}-two --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 3 --ack-frequency 7 --randomize-group-size --interleave 5", + "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 59 --group-size 5 --receivers 2 --senders 3 --capacity 1 --ack-frequency 3 --randomize-group-size", + "python $QPID_CONFIG_EXEC -b $BROKER_URL del queue ${QUEUE_NAME}-two --force", + "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 59 --group-size 3 --receivers 2 --senders 3 --capacity 1 --ack-frequency 1 --randomize-group-size", + "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 211 --group-size 13 --receivers 2 --senders 3 --capacity 47 --ack-frequency 79 --interleave 53", + "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10000 --group-size 1 --receivers 0 --senders 1", + "$prog -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10000 --receivers 5 --senders 0", + "python $QPID_CONFIG_EXEC -b $BROKER_URL del queue $QUEUE_NAME --force") + +foreach ($cmd in $tests) +{ + Invoke-Expression "$cmd" | Write-Output + $ret = $LASTEXITCODE + if ($ret -ne 0) {Write-Host "FAILED message group test. Failed command: $cmd" + break} +} +exit $ret diff --git a/qpid/cpp/src/tests/sasl.mk b/qpid/cpp/src/tests/sasl.mk deleted file mode 100644 index 8c31192635..0000000000 --- a/qpid/cpp/src/tests/sasl.mk +++ /dev/null @@ -1,44 +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. -# - -# Test that are only relevant if SASL is enabled. -if HAVE_SASL - -# Note: sasl_version is not a test -- it is a tool used by tests. -check_PROGRAMS+=sasl_version -sasl_version_SOURCES=sasl_version.cpp -sasl_version_LDADD=$(lib_client) - -TESTS += sasl_fed - sasl_fed_ex_dynamic - sasl_fed_ex_link - sasl_fed_ex_queue - sasl_fed_ex_route - sasl_no_dir - -EXTRA_DIST += sasl_fed \ - sasl_fed_ex \ - sasl_fed_ex_dynamic \ - sasl_fed_ex_link \ - sasl_fed_ex_queue \ - sasl_fed_ex_route \ - sasl_no_dir - - -endif # HAVE_SASL diff --git a/qpid/cpp/src/tests/ssl.mk b/qpid/cpp/src/tests/ssl.mk deleted file mode 100644 index 1544dc5e71..0000000000 --- a/qpid/cpp/src/tests/ssl.mk +++ /dev/null @@ -1,22 +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. -# - -TESTS+=ssl_test -EXTRA_DIST+=ssl_test -CLEAN_LOCAL += test_cert_dir cert.password diff --git a/qpid/cpp/src/tests/swig_python_tests b/qpid/cpp/src/tests/swig_python_tests new file mode 100755 index 0000000000..6f862ffa2d --- /dev/null +++ b/qpid/cpp/src/tests/swig_python_tests @@ -0,0 +1,62 @@ +#!/bin/bash + +# +# 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. +# + +# Run the python tests. +source ./test_env.sh +trap stop_broker INT TERM QUIT + +if [[ -a $AMQP_LIB ]] ; then + echo "Found AMQP support: $AMQP_LIB" + MODULES="--load-module $AMQP_LIB" +fi + +fail() { + echo "FAIL swigged python tests: $1"; exit 1; +} +skip() { + echo "SKIPPED swigged python tests: $1"; exit 0; +} + +start_broker() { + QPID_PORT=$($QPIDD_EXEC --daemon --port 0 --interface 127.0.0.1 --no-data-dir $MODULES --auth no) || fail "Could not start broker" +} + +stop_broker() { + $QPIDD_EXEC -q --port $QPID_PORT +} + +test -d $PYTHON_DIR || skip "no python dir" +test -f $PYTHONSWIGMODULE || skip "no swigged python client" + +start_broker +echo "Running swigged python tests using broker on port $QPID_PORT" + +export PYTHONPATH=$PYTHONPATH:$PYTHONPATH_SWIG +$QPID_PYTHON_TEST -m qpid.tests.messaging.message -m qpid_tests.broker_0_10.priority -m qpid_tests.broker_0_10.lvq -m qpid_tests.broker_0_10.new_api -b localhost:$QPID_PORT -I $srcdir/failing-amqp0-10-python-tests || FAILED=1 +if [[ -a $AMQPC_LIB ]] ; then + export QPID_LOAD_MODULE=$AMQPC_LIB + $QPID_PYTHON_TEST --define="protocol_version=amqp1.0" -m qpid_tests.broker_1_0 -m qpid_tests.broker_0_10.new_api -b localhost:$QPID_PORT -I $srcdir/failing-amqp1.0-python-tests || FAILED=1 +fi +stop_broker +if [[ $FAILED -eq 1 ]]; then + fail "" +fi + diff --git a/qpid/cpp/src/tests/test_env.ps1.in b/qpid/cpp/src/tests/test_env.ps1.in index 5fa3a0ac31..12373b5b35 100644 --- a/qpid/cpp/src/tests/test_env.ps1.in +++ b/qpid/cpp/src/tests/test_env.ps1.in @@ -41,7 +41,6 @@ $PYTHON_COMMANDS="$QPID_TOOLS\src\py" $env:PYTHONPATH="$srcdir;$PYTHON_DIR;$PYTHON_COMMANDS;$QPID_TESTS_PY;$QPID_TOOLS_LIBS;$QMF_LIB;$env:PYTHONPATH" $QPID_CONFIG_EXEC="$PYTHON_COMMANDS\qpid-config" $QPID_ROUTE_EXEC="$PYTHON_COMMANDS\qpid-route" -$QPID_CLUSTER_EXEC="$PYTHON_COMMANDS\qpid-cluster" $QPID_HA_TOOL_EXEC="$PYTHON_COMMANDS\qpid-ha-tool" # Executables diff --git a/qpid/cpp/src/tests/test_env.sh.in b/qpid/cpp/src/tests/test_env.sh.in index bafdacf944..486034ca3b 100644 --- a/qpid/cpp/src/tests/test_env.sh.in +++ b/qpid/cpp/src/tests/test_env.sh.in @@ -25,6 +25,8 @@ builddir=`absdir @abs_builddir@` top_srcdir=`absdir @abs_top_srcdir@` top_builddir=`absdir @abs_top_builddir@` moduledir=$top_builddir/src@builddir_lib_suffix@ +pythonswigdir=$top_builddir/bindings/qpid/python/ +pythonswiglibdir=$top_builddir/bindings/qpid/python@builddir_lib_suffix@ testmoduledir=$builddir@builddir_lib_suffix@ export QPID_INSTALL_PREFIX=@prefix@ @@ -44,7 +46,8 @@ export PYTHONPATH=$srcdir:$PYTHON_DIR:$PYTHON_COMMANDS:$QPID_TESTS_PY:$QMF_LIB:$ export QPID_CONFIG_EXEC=$PYTHON_COMMANDS/qpid-config export QPID_ROUTE_EXEC=$PYTHON_COMMANDS/qpid-route export QPID_HA_EXEC=$PYTHON_COMMANDS/qpid-ha - +export PYTHONPATH_SWIG=$pythonswigdir:$pythonswiglibdir +export PYTHONSWIGMODULE=$pythonswigdir/qpid_messaging.py # Executables export QPIDD_EXEC=$top_builddir/src/qpidd @@ -78,5 +81,5 @@ if [ ! -e "$HOME" ]; then fi # Options for boost test framework -export BOOST_TEST_SHOW_PROGRESS=yes -export BOOST_TEST_CATCH_SYSTEM_ERRORS=no +test -z "$BOOST_TEST_SHOW_PROGRESS" && export BOOST_TEST_SHOW_PROGRESS=yes +test -z "$BOOST_TEST_CATCH_SYSTEM_ERRORS" && export BOOST_TEST_CATCH_SYSTEM_ERRORS=no diff --git a/qpid/cpp/src/tests/test_store.cpp b/qpid/cpp/src/tests/test_store.cpp index eac4deda2d..e299161c68 100644 --- a/qpid/cpp/src/tests/test_store.cpp +++ b/qpid/cpp/src/tests/test_store.cpp @@ -40,14 +40,19 @@ #include "qpid/sys/Thread.h" #include "qpid/Plugin.h" #include "qpid/Options.h" +#include "qpid/RefCounted.h" +#include "qpid/Msg.h" #include <boost/cast.hpp> #include <boost/lexical_cast.hpp> #include <memory> +#include <ostream> #include <fstream> +#include <sstream> -using namespace qpid; -using namespace broker; using namespace std; +using namespace boost; +using namespace qpid; +using namespace qpid::broker; using namespace qpid::sys; namespace qpid { @@ -57,11 +62,19 @@ struct TestStoreOptions : public Options { string name; string dump; + string events; + vector<string> throwMsg; // Throw exception if message content matches. TestStoreOptions() : Options("Test Store Options") { addOptions() - ("test-store-name", optValue(name, "NAME"), "Name of test store instance.") - ("test-store-dump", optValue(dump, "FILE"), "File to dump enqueued messages.") + ("test-store-name", optValue(name, "NAME"), + "Name of test store instance.") + ("test-store-dump", optValue(dump, "FILE"), + "File to dump enqueued messages.") + ("test-store-events", optValue(events, "FILE"), + "File to log events, 1 line per event.") + ("test-store-throw", optValue(throwMsg, "CONTENT"), + "Throw exception if message content matches.") ; } }; @@ -82,24 +95,76 @@ class TestStore : public NullMessageStore { TestStore(const TestStoreOptions& opts, Broker& broker_) : options(opts), name(opts.name), broker(broker_) { - QPID_LOG(info, "TestStore name=" << name << " dump=" << options.dump); - if (!options.dump.empty()) + QPID_LOG(info, "TestStore name=" << name + << " dump=" << options.dump + << " events=" << options.events + << " throw messages =" << options.throwMsg.size()); + + if (!options.dump.empty()) dump.reset(new ofstream(options.dump.c_str())); + if (!options.events.empty()) + events.reset(new ofstream(options.events.c_str())); } ~TestStore() { for_each(threads.begin(), threads.end(), boost::bind(&Thread::join, _1)); } - virtual bool isNull() const { return false; } - - void enqueue(TransactionContext* , + // Dummy transaction context. + struct TxContext : public TPCTransactionContext { + static int nextId; + string id; + TxContext() : id(lexical_cast<string>(nextId++)) {} + TxContext(string xid) : id(xid) {} + }; + + static string getId(const TransactionContext& tx) { + const TxContext* tc = dynamic_cast<const TxContext*>(&tx); + assert(tc); + return tc->id; + } + + + bool isNull() const { return false; } + + void log(const string& msg) { + QPID_LOG(info, "test_store: " << msg); + if (events.get()) *events << msg << endl << std::flush; + } + + auto_ptr<TransactionContext> begin() { + auto_ptr<TxContext> tx(new TxContext()); + log(Msg() << "<begin tx " << tx->id << ">"); + return auto_ptr<TransactionContext>(tx); + } + + auto_ptr<TPCTransactionContext> begin(const std::string& xid) { + auto_ptr<TxContext> tx(new TxContext(xid)); + log(Msg() << "<begin tx " << tx->id << ">"); + return auto_ptr<TPCTransactionContext>(tx); + } + + string getContent(const intrusive_ptr<PersistableMessage>& msg) { + intrusive_ptr<broker::Message::Encoding> enc( + dynamic_pointer_cast<broker::Message::Encoding>(msg)); + return enc->getContent(); + } + + void enqueue(TransactionContext* tx, const boost::intrusive_ptr<PersistableMessage>& pmsg, - const PersistableQueue& ) + const PersistableQueue& queue) { - qpid::broker::amqp_0_10::MessageTransfer* msg = dynamic_cast<qpid::broker::amqp_0_10::MessageTransfer*>(pmsg.get()); + QPID_LOG(debug, "TestStore enqueue " << queue.getName()); + qpid::broker::amqp_0_10::MessageTransfer* msg = + dynamic_cast<qpid::broker::amqp_0_10::MessageTransfer*>(pmsg.get()); assert(msg); + ostringstream o; + o << "<enqueue " << queue.getName() << " " << getContent(msg); + if (tx) o << " tx=" << getId(*tx); + o << ">"; + log(o.str()); + // Dump the message if there is a dump file. if (dump.get()) { msg->getFrames().getMethod()->print(*dump); @@ -113,7 +178,11 @@ class TestStore : public NullMessageStore { string data = msg->getFrames().getContent(); size_t i = string::npos; size_t j = string::npos; - if (strncmp(data.c_str(), TEST_STORE_DO.c_str(), strlen(TEST_STORE_DO.c_str())) == 0 + const vector<string>& throwMsg(options.throwMsg); + if (find(throwMsg.begin(), throwMsg.end(), data) != throwMsg.end()) { + throw Exception(QPID_MSG("TestStore " << name << " throwing exception for: " << data)); + } + else if (strncmp(data.c_str(), TEST_STORE_DO.c_str(), strlen(TEST_STORE_DO.c_str())) == 0 && (i = data.find(name+"[")) != string::npos && (j = data.find("]", i)) != string::npos) { @@ -144,6 +213,31 @@ class TestStore : public NullMessageStore { msg->enqueueComplete(); } + void dequeue(TransactionContext* tx, + const boost::intrusive_ptr<PersistableMessage>& msg, + const PersistableQueue& queue) + { + QPID_LOG(debug, "TestStore dequeue " << queue.getName()); + ostringstream o; + o<< "<dequeue " << queue.getName() << " " << getContent(msg); + if (tx) o << " tx=" << getId(*tx); + o << ">"; + log(o.str()); + } + + void prepare(TPCTransactionContext& txn) { + log(Msg() << "<prepare tx=" << getId(txn) << ">"); + } + + void commit(TransactionContext& txn) { + log(Msg() << "<commit tx=" << getId(txn) << ">"); + } + + void abort(TransactionContext& txn) { + log(Msg() << "<abort tx=" << getId(txn) << ">"); + } + + private: static const string TEST_STORE_DO, EXCEPTION, EXIT_PROCESS, ASYNC; TestStoreOptions options; @@ -151,8 +245,11 @@ class TestStore : public NullMessageStore { Broker& broker; vector<Thread> threads; std::auto_ptr<ofstream> dump; + std::auto_ptr<ofstream> events; }; +int TestStore::TxContext::nextId(1); + const string TestStore::TEST_STORE_DO = "TEST_STORE_DO: "; const string TestStore::EXCEPTION = "exception"; const string TestStore::EXIT_PROCESS = "exit_process"; diff --git a/qpid/cpp/src/tests/test_tools.h b/qpid/cpp/src/tests/test_tools.h index de672f938a..7950a36913 100644 --- a/qpid/cpp/src/tests/test_tools.h +++ b/qpid/cpp/src/tests/test_tools.h @@ -23,7 +23,6 @@ #include <limits.h> // Include before boost/test headers. #include <boost/test/test_tools.hpp> #include <boost/assign/list_of.hpp> -#include <boost/assign/list_of.hpp> #include <vector> #include <set> #include <ostream> diff --git a/qpid/cpp/src/tests/testagent.cpp b/qpid/cpp/src/tests/testagent.cpp deleted file mode 100644 index e6010a8e00..0000000000 --- a/qpid/cpp/src/tests/testagent.cpp +++ /dev/null @@ -1,208 +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. - * - */ - -#include <qpid/management/Manageable.h> -#include <qpid/management/ManagementObject.h> -#include <qpid/agent/ManagementAgent.h> -#include <qpid/sys/Mutex.h> -#include <qpid/sys/Time.h> -#include "qmf/org/apache/qpid/agent/example/Parent.h" -#include "qmf/org/apache/qpid/agent/example/Child.h" -#include "qmf/org/apache/qpid/agent/example/ArgsParentCreate_child.h" -#include "qmf/org/apache/qpid/agent/example/EventChildCreated.h" -#include "qmf/org/apache/qpid/agent/example/Package.h" - -#include <signal.h> -#include <cstdlib> -#include <iostream> - -#include <sstream> - -namespace qpid { -namespace tests { - -static bool running = true; - -using std::string; -using qpid::management::ManagementAgent; -using qpid::management::ManagementObject; -using qpid::management::Manageable; -using qpid::management::Args; -using qpid::sys::Mutex; -namespace _qmf = qmf::org::apache::qpid::agent::example; - -class ChildClass; - -//============================================================== -// CoreClass is the operational class that corresponds to the -// "Parent" class in the management schema. -//============================================================== -class CoreClass : public Manageable -{ - string name; - ManagementAgent* agent; - _qmf::Parent* mgmtObject; - std::vector<ChildClass*> children; - Mutex vectorLock; - -public: - - CoreClass(ManagementAgent* agent, string _name); - ~CoreClass() { mgmtObject->resourceDestroy(); } - - ManagementObject* GetManagementObject(void) const - { return mgmtObject; } - - void doLoop(); - status_t ManagementMethod (uint32_t methodId, Args& args, string& text); -}; - -class ChildClass : public Manageable -{ - string name; - _qmf::Child* mgmtObject; - -public: - - ChildClass(ManagementAgent* agent, CoreClass* parent, string name); - ~ChildClass() { mgmtObject->resourceDestroy(); } - - ManagementObject* GetManagementObject(void) const - { return mgmtObject; } - - void doWork() - { - mgmtObject->inc_count(2); - } -}; - -CoreClass::CoreClass(ManagementAgent* _agent, string _name) : name(_name), agent(_agent) -{ - static uint64_t persistId = 0x111222333444555LL; - mgmtObject = new _qmf::Parent(agent, this, name); - - agent->addObject(mgmtObject, persistId++); - mgmtObject->set_state("IDLE"); -} - -void CoreClass::doLoop() -{ - // Periodically bump a counter to provide a changing statistical value - while (running) { - qpid::sys::sleep(1); - mgmtObject->inc_count(); - mgmtObject->set_state("IN_LOOP"); - - { - Mutex::ScopedLock _lock(vectorLock); - - for (std::vector<ChildClass*>::iterator iter = children.begin(); - iter != children.end(); - iter++) { - (*iter)->doWork(); - } - } - } -} - -Manageable::status_t CoreClass::ManagementMethod(uint32_t methodId, Args& args, string& /*text*/) -{ - Mutex::ScopedLock _lock(vectorLock); - - switch (methodId) { - case _qmf::Parent::METHOD_CREATE_CHILD: - _qmf::ArgsParentCreate_child& ioArgs = (_qmf::ArgsParentCreate_child&) args; - - ChildClass *child = new ChildClass(agent, this, ioArgs.i_name); - ioArgs.o_childRef = child->GetManagementObject()->getObjectId(); - - children.push_back(child); - - agent->raiseEvent(_qmf::EventChildCreated(ioArgs.i_name)); - - return STATUS_OK; - } - - return STATUS_NOT_IMPLEMENTED; -} - -ChildClass::ChildClass(ManagementAgent* agent, CoreClass* parent, string name) -{ - mgmtObject = new _qmf::Child(agent, this, parent, name); - - agent->addObject(mgmtObject); -} - - -//============================================================== -// Main program -//============================================================== - -ManagementAgent::Singleton* singleton; - -void shutdown(int) -{ - running = false; -} - -int main_int(int argc, char** argv) -{ - singleton = new ManagementAgent::Singleton(); - const char* host = argc>1 ? argv[1] : "127.0.0.1"; - int port = argc>2 ? atoi(argv[2]) : 5672; - - signal(SIGINT, shutdown); - - // Create the qmf management agent - ManagementAgent* agent = singleton->getInstance(); - - // Register the Qmf_example schema with the agent - _qmf::Package packageInit(agent); - - // Start the agent. It will attempt to make a connection to the - // management broker - agent->init(host, port, 5, false, ".magentdata"); - - // Allocate some core objects - CoreClass core1(agent, "Example Core Object #1"); - CoreClass core2(agent, "Example Core Object #2"); - CoreClass core3(agent, "Example Core Object #3"); - - core1.doLoop(); - - // done, cleanup and exit - delete singleton; - - return 0; -} - -}} // namespace qpid::tests - -int main(int argc, char** argv) -{ - try { - return qpid::tests::main_int(argc, argv); - } catch(std::exception& e) { - std::cerr << "Top Level Exception: " << e.what() << std::endl; - return 1; - } -} - diff --git a/qpid/cpp/src/tests/testagent.mk b/qpid/cpp/src/tests/testagent.mk deleted file mode 100644 index 0492f3e3bb..0000000000 --- a/qpid/cpp/src/tests/testagent.mk +++ /dev/null @@ -1,51 +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. -# - -# Build a simple qmf agent for test purposes. - -TESTAGENT_GEN_SRC= \ - testagent_gen/qmf/org/apache/qpid/agent/example/Parent.h \ - testagent_gen/qmf/org/apache/qpid/agent/example/Child.h \ - testagent_gen/qmf/org/apache/qpid/agent/example/Parent.cpp \ - testagent_gen/qmf/org/apache/qpid/agent/example/Child.cpp \ - testagent_gen/qmf/org/apache/qpid/agent/example/ArgsParentCreate_child.h \ - testagent_gen/qmf/org/apache/qpid/agent/example/EventChildCreated.h \ - testagent_gen/qmf/org/apache/qpid/agent/example/EventChildDestroyed.h \ - testagent_gen/qmf/org/apache/qpid/agent/example/EventChildCreated.cpp \ - testagent_gen/qmf/org/apache/qpid/agent/example/EventChildDestroyed.cpp \ - testagent_gen/qmf/org/apache/qpid/agent/example/Package.h \ - testagent_gen/qmf/org/apache/qpid/agent/example/Package.cpp - -$(TESTAGENT_GEN_SRC): testagent_gen.timestamp -if GENERATE -TESTAGENT_DEPS=../mgen.timestamp -endif # GENERATE -testagent_gen.timestamp: testagent.xml ${TESTAGENT_DEPS} - $(QMF_GEN) -o testagent_gen/qmf $(srcdir)/testagent.xml - touch $@ - -CLEANFILES+=$(TESTAGENT_GEN_SRC) testagent_gen.timestamp - -testagent-testagent.$(OBJEXT): $(TESTAGENT_GEN_SRC) -qpidexectest_PROGRAMS+=testagent -testagent_CXXFLAGS=$(CXXFLAGS) -Itestagent_gen -testagent_SOURCES=testagent.cpp $(TESTAGENT_GEN_SRC) -testagent_LDADD=$(top_builddir)/src/libqmf.la $(top_builddir)/src/libqpidcommon.la $(top_builddir)/src/libqpidtypes.la $(top_builddir)/src/libqpidclient.la - -EXTRA_DIST+=testagent.xml diff --git a/qpid/cpp/src/tests/testagent.xml b/qpid/cpp/src/tests/testagent.xml deleted file mode 100644 index 0b1436f999..0000000000 --- a/qpid/cpp/src/tests/testagent.xml +++ /dev/null @@ -1,64 +0,0 @@ -<schema package="org.apache.qpid.agent.example"> - -<!-- - 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. ---> - - <!-- - =============================================================== - Parent - =============================================================== - --> - <class name="Parent"> - - This class represents a parent object - - <property name="name" type="lstr" access="RC" index="y"/> - - <statistic name="state" type="sstr" desc="Operational state of the link"/> - <statistic name="count" type="count64" unit="tick" desc="Counter that increases monotonically"/> - - <method name="create_child" desc="Create child object"> - <arg name="name" dir="I" type="lstr"/> - <arg name="childRef" dir="O" type="objId"/> - </method> - </class> - - - <!-- - =============================================================== - Child - =============================================================== - --> - <class name="Child"> - <property name="ParentRef" type="objId" references="Parent" access="RC" index="y" parentRef="y"/> - <property name="name" type="lstr" access="RC" index="y"/> - - <statistic name="count" type="count64" unit="tick" desc="Counter that increases monotonically"/> - - <method name="delete"/> - </class> - - <eventArguments> - <arg name="childName" type="lstr"/> - </eventArguments> - - <event name="ChildCreated" args="childName"/> - <event name="ChildDestroyed" args="childName"/> -</schema> - diff --git a/qpid/cpp/src/xml.mk b/qpid/cpp/src/xml.mk deleted file mode 100644 index 9376cfd54a..0000000000 --- a/qpid/cpp/src/xml.mk +++ /dev/null @@ -1,29 +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. -# -dmoduleexec_LTLIBRARIES += xml.la - -xml_la_SOURCES = \ - qpid/xml/XmlExchange.cpp \ - qpid/xml/XmlExchange.h \ - qpid/xml/XmlExchangePlugin.cpp - -xml_la_LIBADD = -lxerces-c -lxqilla libqpidbroker.la -xml_la_CXXFLAGS = $(AM_CXXFLAGS) -D_IN_QPID_BROKER -xml_la_LDFLAGS = $(PLUGINLDFLAGS) - |
