diff options
| author | Charles E. Rolke <chug@apache.org> | 2012-02-27 17:40:42 +0000 |
|---|---|---|
| committer | Charles E. Rolke <chug@apache.org> | 2012-02-27 17:40:42 +0000 |
| commit | c3a0c2ec78970005da38d524f38939cc7f2fb3a7 (patch) | |
| tree | e0efc6e350bc0867c5f114ca10fc7b48a3cfa033 /cpp | |
| parent | 879da6a01706268adbb75c42182027bde4a1d430 (diff) | |
| download | qpid-python-c3a0c2ec78970005da38d524f38939cc7f2fb3a7.tar.gz | |
Merge from trunk into branch
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/QPID-3799-acl@1294242 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
71 files changed, 832 insertions, 1262 deletions
diff --git a/cpp/bindings/qmf/tests/run_interop_tests b/cpp/bindings/qmf/tests/run_interop_tests index 83e7f2593b..c370f211af 100755 --- a/cpp/bindings/qmf/tests/run_interop_tests +++ b/cpp/bindings/qmf/tests/run_interop_tests @@ -24,6 +24,7 @@ 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 @@ -68,7 +69,7 @@ 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} + PYTHONPATH=${PYTHON_DIR}:${QMF_DIR_PY}:${MY_DIR}:${TOOLS_PY_DIR} export PYTHONPATH if test -d ${PYTHON_LIB_DIR} ; then diff --git a/cpp/bindings/qpid/Makefile.am b/cpp/bindings/qpid/Makefile.am index eaf45c2076..ae81696f27 100644 --- a/cpp/bindings/qpid/Makefile.am +++ b/cpp/bindings/qpid/Makefile.am @@ -35,7 +35,7 @@ if HAVE_PERL_DEVEL INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src -I$(top_builddir)/src -I$(PERL_INC) -EXTRA_DIST += perl/perl.i +EXTRA_DIST += perl/perl.i perl/CMakeLists.txt BUILT_SOURCES = perl/cqpid_perl.cpp SWIG_FLAGS = -w362,401 diff --git a/cpp/bindings/qpid/dotnet/Makefile.am b/cpp/bindings/qpid/dotnet/Makefile.am index f212a37bbe..82ae315578 100644 --- a/cpp/bindings/qpid/dotnet/Makefile.am +++ b/cpp/bindings/qpid/dotnet/Makefile.am @@ -80,7 +80,6 @@ EXTRA_DIST = configure-windows.ps1 \ 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 \ - extra_dist.txt \ Makefile.am \ msvc10/org.apache.qpid.messaging.sessionreceiver.sln \ msvc10/org.apache.qpid.messaging.sln \ @@ -93,7 +92,6 @@ EXTRA_DIST = configure-windows.ps1 \ src/AssemblyInfo.cpp \ src/Connection.cpp \ src/Connection.h \ - src/Duration.cpp \ src/Duration.h \ src/FailoverUpdates.cpp \ src/FailoverUpdates.h \ diff --git a/cpp/configure.ac b/cpp/configure.ac index 8729ace169..6ba5f62f0e 100644 --- a/cpp/configure.ac +++ b/cpp/configure.ac @@ -448,7 +448,7 @@ AC_ARG_WITH([poller], [AS_HELP_STRING([--with-poller], [The low level poller implementation: poll/solaris-ecf/epoll])], [case ${withval} in poll) - AC_CHECK_HEADERS([sys/poll.h],[poller=no],[AC_MSG_ERROR([Can't find poll.h header file for poll])]) + AC_CHECK_HEADERS([sys/poll.h],[poller=poll],[AC_MSG_ERROR([Can't find poll.h header file for poll])]) ;; solaris-ecf) AC_CHECK_HEADERS([port.h],[poller=solaris-ecf],[AC_MSG_ERROR([Can't find port.h header file for solaris-ecf])]) @@ -458,14 +458,17 @@ AC_ARG_WITH([poller], ;; esac], [ - AC_CHECK_HEADERS([sys/poll.h],[poller=no],) - AC_CHECK_HEADERS([port.h],[poller=solaris-ecf],) + # We check for poll first so that it is overridden + AC_CHECK_HEADERS([sys/poll.h],[poller=poll],) + # Not currently supported - WIP + #AC_CHECK_HEADERS([port.h],[poller=solaris-ecf],) AC_CHECK_HEADERS([sys/epoll.h],[poller=epoll],) ] ) -AM_CONDITIONAL([HAVE_ECF], [test x$poller = xsolaris-ecf]) -AM_CONDITIONAL([HAVE_EPOLL], [test x$poller = xepoll]) +AM_CONDITIONAL([USE_ECF], [test x$poller = xsolaris-ecf]) +AM_CONDITIONAL([USE_POLL], [test x$poller = xpoll]) +AM_CONDITIONAL([USE_EPOLL], [test x$poller = xepoll]) #Filter not implemented or invalid mechanisms if test $poller = xno; then @@ -480,6 +483,24 @@ case "$host" in esac AM_CONDITIONAL([SUNOS], [test x$arch = xsolaris]) +# Check whether we've got the header for dtrace static probes +AC_ARG_WITH([probes], + [AS_HELP_STRING([--with-probes], [Build with dtrace/systemtap static probes])], + [case ${withval} in + yes) + AC_CHECK_HEADERS([sys/sdt.h]) + ;; + no) + ;; + *) + AC_MSG_ERROR([Bad value for --with-probes: ${withval}]) + ;; + esac], + [ + AC_CHECK_HEADERS([sys/sdt.h]) + ] +) + # Check for some syslog capabilities not present in all systems AC_TRY_COMPILE([#include <sys/syslog.h>], [int v = LOG_AUTHPRIV;], diff --git a/cpp/include/qpid/framing/SequenceNumber.h b/cpp/include/qpid/framing/SequenceNumber.h index eed15a4b75..dd85d97a52 100644 --- a/cpp/include/qpid/framing/SequenceNumber.h +++ b/cpp/include/qpid/framing/SequenceNumber.h @@ -52,9 +52,9 @@ boost::equality_comparable< uint32_t getValue() const { return uint32_t(value); } operator uint32_t() const { return uint32_t(value); } - void encode(Buffer& buffer) const; - void decode(Buffer& buffer); - uint32_t encodedSize() const; + QPID_COMMON_EXTERN void encode(Buffer& buffer) const; + QPID_COMMON_EXTERN void decode(Buffer& buffer); + QPID_COMMON_EXTERN uint32_t encodedSize() const; template <class S> void serialize(S& s) { s(value); } diff --git a/cpp/include/qpid/framing/SequenceSet.h b/cpp/include/qpid/framing/SequenceSet.h index 0a78e418ba..827c8999b3 100644 --- a/cpp/include/qpid/framing/SequenceSet.h +++ b/cpp/include/qpid/framing/SequenceSet.h @@ -38,9 +38,9 @@ class QPID_COMMON_CLASS_EXTERN SequenceSet : public RangeSet<SequenceNumber> { SequenceSet(const SequenceNumber& start, const SequenceNumber finish) { add(start,finish); } - void encode(Buffer& buffer) const; - void decode(Buffer& buffer); - uint32_t encodedSize() const; + QPID_COMMON_EXTERN void encode(Buffer& buffer) const; + QPID_COMMON_EXTERN void decode(Buffer& buffer); + QPID_COMMON_EXTERN uint32_t encodedSize() const; QPID_COMMON_EXTERN bool contains(const SequenceNumber& s) const; QPID_COMMON_EXTERN void add(const SequenceNumber& s); diff --git a/cpp/include/qpid/types/Variant.h b/cpp/include/qpid/types/Variant.h index 3feba4a0ec..3493559777 100644 --- a/cpp/include/qpid/types/Variant.h +++ b/cpp/include/qpid/types/Variant.h @@ -60,9 +60,9 @@ enum VariantType { VAR_UUID }; -std::string getTypeName(VariantType type); +QPID_TYPES_EXTERN std::string getTypeName(VariantType type); -bool isIntegerType(VariantType type); +QPID_TYPES_EXTERN bool isIntegerType(VariantType type); class VariantImpl; diff --git a/cpp/managementgen/qmfgen/schema.py b/cpp/managementgen/qmfgen/schema.py index b8a1d26fb0..c48ae572d2 100755 --- a/cpp/managementgen/qmfgen/schema.py +++ b/cpp/managementgen/qmfgen/schema.py @@ -1471,7 +1471,7 @@ class SchemaClass: def genMethodIdDeclarations (self, stream, variables): number = 1 for method in self.methods: - stream.write (" static const uint32_t METHOD_" + method.getName().upper() +\ + stream.write (" QPID_BROKER_EXTERN static const uint32_t METHOD_" + method.getName().upper() +\ " = %d;\n" % number) number = number + 1 diff --git a/cpp/managementgen/qmfgen/templates/Class.h b/cpp/managementgen/qmfgen/templates/Class.h index 90f1b4dd4a..0527d53536 100644 --- a/cpp/managementgen/qmfgen/templates/Class.h +++ b/cpp/managementgen/qmfgen/templates/Class.h @@ -24,6 +24,7 @@ /*MGEN:Root.Disclaimer*/ #include "qpid/management/ManagementObject.h" +#include "qmf/BrokerImportExport.h" namespace qpid { namespace management { @@ -34,7 +35,7 @@ namespace qpid { namespace qmf { /*MGEN:Class.OpenNamespaces*/ -class /*MGEN:Class.NameCap*/ : public ::qpid::management::ManagementObject +QPID_BROKER_CLASS_EXTERN class /*MGEN:Class.NameCap*/ : public ::qpid::management::ManagementObject { private: @@ -72,25 +73,25 @@ class /*MGEN:Class.NameCap*/ : public ::qpid::management::ManagementObject void aggregatePerThreadStats(struct PerThreadStats*) const; /*MGEN:ENDIF*/ public: - static void writeSchema(std::string& schema); - void mapEncodeValues(::qpid::types::Variant::Map& map, - bool includeProperties=true, - bool includeStatistics=true); - void mapDecodeValues(const ::qpid::types::Variant::Map& map); - void doMethod(std::string& methodName, - const ::qpid::types::Variant::Map& inMap, - ::qpid::types::Variant::Map& outMap, - const std::string& userId); - std::string getKey() const; + QPID_BROKER_EXTERN static void writeSchema(std::string& schema); + QPID_BROKER_EXTERN void mapEncodeValues(::qpid::types::Variant::Map& map, + bool includeProperties=true, + bool includeStatistics=true); + QPID_BROKER_EXTERN void mapDecodeValues(const ::qpid::types::Variant::Map& map); + QPID_BROKER_EXTERN void doMethod(std::string& methodName, + const ::qpid::types::Variant::Map& inMap, + ::qpid::types::Variant::Map& outMap, + const std::string& userId); + QPID_BROKER_EXTERN std::string getKey() const; /*MGEN:IF(Root.GenQMFv1)*/ - uint32_t writePropertiesSize() const; - void readProperties(const std::string& buf); - void writeProperties(std::string& buf) const; - void writeStatistics(std::string& buf, bool skipHeaders = false); - void doMethod(std::string& methodName, - const std::string& inBuf, - std::string& outBuf, - const std::string& userId); + QPID_BROKER_EXTERN uint32_t writePropertiesSize() const; + QPID_BROKER_EXTERN void readProperties(const std::string& buf); + QPID_BROKER_EXTERN void writeProperties(std::string& buf) const; + QPID_BROKER_EXTERN void writeStatistics(std::string& buf, bool skipHeaders = false); + QPID_BROKER_EXTERN void doMethod(std::string& methodName, + const std::string& inBuf, + std::string& outBuf, + const std::string& userId); /*MGEN:ENDIF*/ writeSchemaCall_t getWriteSchemaCall() { return writeSchema; } @@ -100,13 +101,17 @@ class /*MGEN:Class.NameCap*/ : public ::qpid::management::ManagementObject bool hasInst() { return false; } /*MGEN:ENDIF*/ - /*MGEN:Class.NameCap*/(::qpid::management::ManagementAgent* agent, - ::qpid::management::Manageable* coreObject/*MGEN:Class.ParentArg*//*MGEN:Class.ConstructorArgs*/); - ~/*MGEN:Class.NameCap*/(); + QPID_BROKER_EXTERN /*MGEN:Class.NameCap*/( + ::qpid::management::ManagementAgent* agent, + ::qpid::management::Manageable* coreObject/*MGEN:Class.ParentArg*//*MGEN:Class.ConstructorArgs*/); + + QPID_BROKER_EXTERN ~/*MGEN:Class.NameCap*/(); /*MGEN:Class.SetGeneralReferenceDeclaration*/ - static void registerSelf(::qpid::management::ManagementAgent* agent); + QPID_BROKER_EXTERN static void registerSelf( + ::qpid::management::ManagementAgent* agent); + std::string& getPackageName() const { return packageName; } std::string& getClassName() const { return className; } uint8_t* getMd5Sum() const { return md5Sum; } diff --git a/cpp/managementgen/qmfgen/templates/Event.h b/cpp/managementgen/qmfgen/templates/Event.h index 5fa5f8e576..592ae08c73 100644 --- a/cpp/managementgen/qmfgen/templates/Event.h +++ b/cpp/managementgen/qmfgen/templates/Event.h @@ -24,11 +24,12 @@ /*MGEN:Root.Disclaimer*/ #include "qpid/management/ManagementEvent.h" +#include "qmf/BrokerImportExport.h" namespace qmf { /*MGEN:Event.OpenNamespaces*/ -class Event/*MGEN:Event.NameCap*/ : public ::qpid::management::ManagementEvent +QPID_BROKER_CLASS_EXTERN class Event/*MGEN:Event.NameCap*/ : public ::qpid::management::ManagementEvent { private: static void writeSchema (std::string& schema); @@ -41,18 +42,18 @@ class Event/*MGEN:Event.NameCap*/ : public ::qpid::management::ManagementEvent public: writeSchemaCall_t getWriteSchemaCall(void) { return writeSchema; } - Event/*MGEN:Event.NameCap*/(/*MGEN:Event.ConstructorArgs*/); - ~Event/*MGEN:Event.NameCap*/() {}; + QPID_BROKER_EXTERN Event/*MGEN:Event.NameCap*/(/*MGEN:Event.ConstructorArgs*/); + QPID_BROKER_EXTERN ~Event/*MGEN:Event.NameCap*/() {}; static void registerSelf(::qpid::management::ManagementAgent* agent); std::string& getPackageName() const { return packageName; } std::string& getEventName() const { return eventName; } uint8_t* getMd5Sum() const { return md5Sum; } uint8_t getSeverity() const { return /*MGEN:Event.Severity*/; } - void encode(std::string& buffer) const; - void mapEncode(::qpid::types::Variant::Map& map) const; + QPID_BROKER_EXTERN void encode(std::string& buffer) const; + QPID_BROKER_EXTERN void mapEncode(::qpid::types::Variant::Map& map) const; - static bool match(const std::string& evt, const std::string& pkg); + QPID_BROKER_EXTERN static bool match(const std::string& evt, const std::string& pkg); }; }/*MGEN:Event.CloseNamespaces*/ diff --git a/cpp/managementgen/qmfgen/templates/Package.h b/cpp/managementgen/qmfgen/templates/Package.h index 569c7cfb33..3a42f12f9d 100644 --- a/cpp/managementgen/qmfgen/templates/Package.h +++ b/cpp/managementgen/qmfgen/templates/Package.h @@ -24,6 +24,7 @@ /*MGEN:Root.Disclaimer*/ #include "qpid//*MGEN:Class.AgentHeaderLocation*//ManagementAgent.h" +#include "qmf/BrokerImportExport.h" namespace qmf { /*MGEN:Class.OpenNamespaces*/ @@ -31,8 +32,8 @@ namespace qmf { class Package { public: - Package (::qpid::management::ManagementAgent* agent); - ~Package () {} + QPID_BROKER_EXTERN Package (::qpid::management::ManagementAgent* agent); + QPID_BROKER_EXTERN ~Package () {} }; }/*MGEN:Class.CloseNamespaces*/ diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index e8e543b672..cfcdead883 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -477,6 +477,29 @@ else (NOT CLOCK_GETTIME_IN_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 if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) CHECK_LIBRARY_EXISTS (uuid uuid_compare "" HAVE_UUID) @@ -740,9 +763,18 @@ else (CMAKE_SYSTEM_NAME STREQUAL Windows) # POSIX (Non-Windows) platforms have a lot of overlap in sources; the only # major difference is the poller module. - if (CMAKE_SYSTEM_NAME STREQUAL Linux) + if (POLLER STREQUAL poll) + set (qpid_poller_module + qpid/sys/posix/PosixPoller.cpp + ) + elseif (POLLER STREQUAL epoll) set (qpid_poller_module qpid/sys/epoll/EpollPoller.cpp + ) + endif (POLLER STREQUAL poll) + + if (CMAKE_SYSTEM_NAME STREQUAL Linux) + set (qpid_system_module qpid/sys/posix/SystemInfo.cpp ) add_definitions(-pthread) @@ -754,13 +786,12 @@ else (CMAKE_SYSTEM_NAME STREQUAL Windows) set (qpidtypes_platform_SOURCES) set (qpidtypes_platform_LIBS - uuid - ${Boost_SYSTEM_LIBRARY} + uuid + ${Boost_SYSTEM_LIBRARY} ) if (CMAKE_SYSTEM_NAME STREQUAL SunOS) - set (qpid_poller_module - qpid/sys/posix/PosixPoller.cpp + set (qpid_system_module qpid/sys/solaris/SystemInfo.cpp ) # On Sun we want -lpthread -lthread as the 2nd last and last libs passed to linker @@ -789,6 +820,7 @@ else (CMAKE_SYSTEM_NAME STREQUAL Windows) qpid/sys/posix/Time.cpp qpid/SaslFactory.cpp + ${qpid_system_module} ${qpid_poller_module} ) set (qpidcommon_platform_LIBS diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index 4f733e985b..e03c88ec8b 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -102,15 +102,16 @@ $(srcdir)/rubygen.cmake: $(rgen_generator) $(specs) # Management generator. mgen_dir=$(top_srcdir)/managementgen -mgen_cmd=$(mgen_dir)/qmf-gen -m $(srcdir)/managementgen.mk \ - -c $(srcdir)/managementgen.cmake -q -b -o qmf \ - $(top_srcdir)/../specs/management-schema.xml \ +mgen_xml=$(top_srcdir)/../specs/management-schema.xml \ $(srcdir)/qpid/acl/management-schema.xml \ $(srcdir)/qpid/cluster/management-schema.xml \ $(srcdir)/qpid/ha/management-schema.xml +mgen_cmd=$(mgen_dir)/qmf-gen -m $(srcdir)/managementgen.mk \ + -c $(srcdir)/managementgen.cmake -q -b -o qmf \ + $(mgen_xml) $(srcdir)/managementgen.mk $(mgen_broker_cpp) $(dist_qpid_management_HEADERS): mgen.timestamp -mgen.timestamp: $(mgen_generator) +mgen.timestamp: $(mgen_generator) $(mgen_xml) $(mgen_cmd); touch $@ $(mgen_generator): @@ -183,11 +184,15 @@ nobase_include_HEADERS += \ ../include/qpid/sys/posix/Time.h \ ../include/qpid/sys/posix/check.h -if HAVE_EPOLL +if USE_EPOLL poller = qpid/sys/epoll/EpollPoller.cpp endif -if HAVE_ECF +if USE_POLL + poller = qpid/sys/posix/PosixPoller.cpp +endif + +if USE_ECF poller = qpid/sys/solaris/ECFPoller.cpp endif @@ -481,12 +486,14 @@ libqpidcommon_la_SOURCES += \ qpid/sys/Fork.h \ qpid/sys/LockFile.h \ qpid/sys/LockPtr.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/ProtocolFactory.h \ qpid/sys/Runnable.cpp \ qpid/sys/ScopedIncrement.h \ @@ -632,7 +639,6 @@ libqpidbroker_la_SOURCES = \ qpid/broker/QueuedMessage.h \ qpid/broker/QueueFlowLimit.h \ qpid/broker/QueueFlowLimit.cpp \ - qpid/broker/RateFlowcontrol.h \ qpid/broker/RecoverableConfig.h \ qpid/broker/RecoverableExchange.h \ qpid/broker/RecoverableMessage.h \ diff --git a/cpp/src/config.h.cmake b/cpp/src/config.h.cmake index 2bb84c6e47..f55f68afde 100644 --- a/cpp/src/config.h.cmake +++ b/cpp/src/config.h.cmake @@ -60,6 +60,7 @@ #cmakedefine HAVE_OPENAIS_CPG_H ${HAVE_OPENAIS_CPG_H} #cmakedefine HAVE_COROSYNC_CPG_H ${HAVE_COROSYNC_CPG_H} #cmakedefine HAVE_LIBCMAN_H ${HAVE_LIBCMAN_H} +#cmakedefine HAVE_SYS_SDT_H ${HAVE_SYS_SDT_H} #cmakedefine HAVE_LOG_AUTHPRIV #cmakedefine HAVE_LOG_FTP diff --git a/cpp/src/qmf.mk b/cpp/src/qmf.mk index 95d3d5c9b0..9b5df6c808 100644 --- a/cpp/src/qmf.mk +++ b/cpp/src/qmf.mk @@ -96,6 +96,7 @@ libqmf2_la_SOURCES = \ qmf/AgentSessionImpl.h \ qmf/AgentSubscription.cpp \ qmf/AgentSubscription.h \ + qmf/BrokerImportExport.h \ qmf/ConsoleEvent.cpp \ qmf/ConsoleEventImpl.h \ qmf/ConsoleSession.cpp \ diff --git a/cpp/src/qpid/sys/apr/APRPool.h b/cpp/src/qmf/BrokerImportExport.h index da7661fcfa..ee05788063 100644 --- a/cpp/src/qpid/sys/apr/APRPool.h +++ b/cpp/src/qmf/BrokerImportExport.h @@ -1,8 +1,7 @@ -#ifndef _APRPool_ -#define _APRPool_ +#ifndef QPID_BROKER_IMPORT_EXPORT_H +#define QPID_BROKER_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 @@ -10,41 +9,34 @@ * 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 <boost/noncopyable.hpp> -#include <apr_pools.h> - -namespace qpid { -namespace sys { -/** - * Singleton APR memory pool. - */ -class APRPool : private boost::noncopyable { - public: - APRPool(); - ~APRPool(); - - /** Get singleton instance */ - static apr_pool_t* get(); - - private: - apr_pool_t* pool; -}; - -}} - - - - -#endif /*!_APRPool_*/ +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +# if defined(BROKER_EXPORT) || defined (qpidbroker_EXPORTS) +# define QPID_BROKER_EXTERN __declspec(dllexport) +# else +# define QPID_BROKER_EXTERN __declspec(dllimport) +# endif +# ifdef _MSC_VER +# define QPID_BROKER_CLASS_EXTERN +# define QPID_BROKER_INLINE_EXTERN QPID_BROKER_EXTERN +# else +# define QPID_BROKER_CLASS_EXTERN QPID_BROKER_EXTERN +# define QPID_BROKER_INLINE_EXTERN +# endif +#else +# define QPID_BROKER_EXTERN +# define QPID_BROKER_CLASS_EXTERN +# define QPID_BROKER_INLINE_EXTERN +#endif + +#endif diff --git a/cpp/src/qpid/broker/Broker.h b/cpp/src/qpid/broker/Broker.h index b6eab894f3..a812c28b80 100644 --- a/cpp/src/qpid/broker/Broker.h +++ b/cpp/src/qpid/broker/Broker.h @@ -205,7 +205,7 @@ public: ConsumerFactories consumerFactories; public: - virtual ~Broker(); + QPID_BROKER_EXTERN virtual ~Broker(); QPID_BROKER_EXTERN Broker(const Options& configuration); static QPID_BROKER_EXTERN boost::intrusive_ptr<Broker> create(const Options& configuration); @@ -217,16 +217,16 @@ public: * port, which will be different if the configured port is * 0. */ - virtual uint16_t getPort(const std::string& name) const; + QPID_BROKER_EXTERN virtual uint16_t getPort(const std::string& name) const; /** * Run the broker. Implements Runnable::run() so the broker * can be run in a separate thread. */ - virtual void run(); + QPID_BROKER_EXTERN virtual void run(); /** Shut down the broker */ - virtual void shutdown(); + QPID_BROKER_EXTERN virtual void shutdown(); QPID_BROKER_EXTERN void setStore (boost::shared_ptr<MessageStore>& store); MessageStore& getStore() { return *store; } @@ -246,14 +246,14 @@ public: SessionManager& getSessionManager() { return sessionManager; } const std::string& getFederationTag() const { return federationTag; } - management::ManagementObject* GetManagementObject (void) const; - management::Manageable* GetVhostObject (void) const; - management::Manageable::status_t ManagementMethod (uint32_t methodId, - management::Args& args, - std::string& text); + QPID_BROKER_EXTERN management::ManagementObject* GetManagementObject() const; + QPID_BROKER_EXTERN management::Manageable* GetVhostObject() const; + QPID_BROKER_EXTERN management::Manageable::status_t ManagementMethod( + uint32_t methodId, management::Args& args, std::string& text); /** Add to the broker's protocolFactorys */ - void registerProtocolFactory(const std::string& name, boost::shared_ptr<sys::ProtocolFactory>); + QPID_BROKER_EXTERN void registerProtocolFactory( + const std::string& name, boost::shared_ptr<sys::ProtocolFactory>); /** Accept connections */ QPID_BROKER_EXTERN void accept(); @@ -271,15 +271,17 @@ public: /** Move messages from one queue to another. A zero quantity means to move all messages */ - uint32_t queueMoveMessages( const std::string& srcQueue, - const std::string& destQueue, - uint32_t qty, - const qpid::types::Variant::Map& filter); + QPID_BROKER_EXTERN uint32_t queueMoveMessages( + const std::string& srcQueue, + const std::string& destQueue, + uint32_t qty, + const qpid::types::Variant::Map& filter); - boost::shared_ptr<sys::ProtocolFactory> getProtocolFactory(const std::string& name = TCP_TRANSPORT) const; + QPID_BROKER_EXTERN boost::shared_ptr<sys::ProtocolFactory> getProtocolFactory( + const std::string& name = TCP_TRANSPORT) const; /** Expose poller so plugins can register their descriptors. */ - boost::shared_ptr<sys::Poller> getPoller(); + QPID_BROKER_EXTERN boost::shared_ptr<sys::Poller> getPoller(); boost::shared_ptr<sys::ConnectionCodec::Factory> getConnectionFactory() { return factory; } void setConnectionFactory(boost::shared_ptr<sys::ConnectionCodec::Factory> f) { factory = f; } @@ -289,7 +291,7 @@ public: /** Timer for tasks that must be synchronized if we are in a cluster */ sys::Timer& getClusterTimer() { return clusterTimer.get() ? *clusterTimer : timer; } - void setClusterTimer(std::auto_ptr<sys::Timer>); + QPID_BROKER_EXTERN void setClusterTimer(std::auto_ptr<sys::Timer>); boost::function<std::vector<Url> ()> getKnownBrokers; @@ -320,15 +322,14 @@ public: * context. *@return true if delivery of a message should be deferred. */ - boost::function<bool (const std::string& queue, - const boost::intrusive_ptr<Message>& msg)> deferDelivery; + boost::function<bool (const std::string& queue, const boost::intrusive_ptr<Message>& msg)> deferDelivery; bool isAuthenticating ( ) { return config.auth; } bool isTimestamping() { return config.timestampRcvMsgs; } typedef boost::function1<void, boost::shared_ptr<Queue> > QueueFunctor; - std::pair<boost::shared_ptr<Queue>, bool> createQueue( + QPID_BROKER_EXTERN std::pair<boost::shared_ptr<Queue>, bool> createQueue( const std::string& name, bool durable, bool autodelete, @@ -337,30 +338,39 @@ public: const qpid::framing::FieldTable& arguments, const std::string& userId, const std::string& connectionId); - void deleteQueue(const std::string& name, - const std::string& userId, - const std::string& connectionId, - QueueFunctor check = QueueFunctor()); - std::pair<Exchange::shared_ptr, bool> createExchange( + + QPID_BROKER_EXTERN void deleteQueue( + const std::string& name, + const std::string& userId, + const std::string& connectionId, + QueueFunctor check = QueueFunctor()); + + QPID_BROKER_EXTERN std::pair<Exchange::shared_ptr, bool> createExchange( const std::string& name, const std::string& type, bool durable, const std::string& alternateExchange, const qpid::framing::FieldTable& args, const std::string& userId, const std::string& connectionId); - void deleteExchange(const std::string& name, const std::string& userId, - const std::string& connectionId); - void bind(const std::string& queue, - const std::string& exchange, - const std::string& key, - const qpid::framing::FieldTable& arguments, - const std::string& userId, - const std::string& connectionId); - void unbind(const std::string& queue, - const std::string& exchange, - const std::string& key, - const std::string& userId, - const std::string& connectionId); + + QPID_BROKER_EXTERN void deleteExchange( + const std::string& name, const std::string& userId, + const std::string& connectionId); + + QPID_BROKER_EXTERN void bind( + const std::string& queue, + const std::string& exchange, + const std::string& key, + const qpid::framing::FieldTable& arguments, + const std::string& userId, + const std::string& connectionId); + + QPID_BROKER_EXTERN void unbind( + const std::string& queue, + const std::string& exchange, + const std::string& key, + const std::string& userId, + const std::string& connectionId); ConsumerFactories& getConsumerFactories() { return consumerFactories; } ConnectionObservers& getConnectionObservers() { return connectionObservers; } diff --git a/cpp/src/qpid/broker/ExchangeRegistry.h b/cpp/src/qpid/broker/ExchangeRegistry.h index 90ef81b49e..27b705fbe5 100644 --- a/cpp/src/qpid/broker/ExchangeRegistry.h +++ b/cpp/src/qpid/broker/ExchangeRegistry.h @@ -54,7 +54,7 @@ class ExchangeRegistry{ bool durable, const qpid::framing::FieldTable& args = framing::FieldTable()); QPID_BROKER_EXTERN void destroy(const std::string& name); - Exchange::shared_ptr getDefault(); + QPID_BROKER_EXTERN Exchange::shared_ptr getDefault(); /** * Find the named exchange. Return 0 if not found. @@ -75,7 +75,7 @@ class ExchangeRegistry{ /** Register an exchange instance. *@return true if registered, false if exchange with same name is already registered. */ - bool registerExchange(const Exchange::shared_ptr&); + QPID_BROKER_EXTERN bool registerExchange(const Exchange::shared_ptr&); QPID_BROKER_EXTERN void registerType(const std::string& type, FactoryFunction); @@ -85,7 +85,7 @@ class ExchangeRegistry{ for (ExchangeMap::const_iterator i = exchanges.begin(); i != exchanges.end(); ++i) f(i->second); } - + private: typedef std::map<std::string, Exchange::shared_ptr> ExchangeMap; typedef std::map<std::string, FactoryFunction > FunctionMap; diff --git a/cpp/src/qpid/broker/Link.h b/cpp/src/qpid/broker/Link.h index 4085c3bfcf..c7c8209db3 100644 --- a/cpp/src/qpid/broker/Link.h +++ b/cpp/src/qpid/broker/Link.h @@ -24,9 +24,11 @@ #include <boost/shared_ptr.hpp> #include "qpid/Url.h" +#include "qpid/broker/BrokerImportExport.h" #include "qpid/broker/MessageStore.h" #include "qpid/broker/PersistableConfig.h" #include "qpid/broker/Bridge.h" +#include "qpid/broker/BrokerImportExport.h" #include "qpid/sys/Mutex.h" #include "qpid/framing/FieldTable.h" #include "qpid/management/Manageable.h" @@ -94,6 +96,13 @@ class Link : public PersistableConfig, public management::Manageable { bool tryFailoverLH(); // Called during maintenance visit bool hideManagement() const; + void established(Connection*); // Called when connection is create + void opened(); // Called when connection is open (after create) + void closed(int, std::string); // Called when connection goes away + void reconnectLH(const Address&); //called by LinkRegistry + + friend class LinkRegistry; // to call established, opened, closed + public: typedef boost::shared_ptr<Link> shared_ptr; @@ -119,13 +128,9 @@ class Link : public PersistableConfig, public management::Manageable { uint nextChannel(); void add(Bridge::shared_ptr); void cancel(Bridge::shared_ptr); - void setUrl(const Url&); // Set URL for reconnection. - void established(Connection*); // Called when connection is create - void opened(); // Called when connection is open (after create) - void closed(int, std::string); // Called when connection goes away - void reconnectLH(const Address&); //called by LinkRegistry - void close(); // Close the link from within the broker. + QPID_BROKER_EXTERN void setUrl(const Url&); // Set URL for reconnection. + QPID_BROKER_EXTERN void close(); // Close the link from within the broker. std::string getAuthMechanism() { return authMechanism; } std::string getUsername() { return username; } diff --git a/cpp/src/qpid/broker/LinkRegistry.cpp b/cpp/src/qpid/broker/LinkRegistry.cpp index bb602bb953..c6c5a1ac05 100644 --- a/cpp/src/qpid/broker/LinkRegistry.cpp +++ b/cpp/src/qpid/broker/LinkRegistry.cpp @@ -25,7 +25,9 @@ #include <iostream> #include <boost/format.hpp> -using namespace qpid::broker; +namespace qpid { +namespace broker { + using namespace qpid::sys; using std::string; using std::pair; @@ -45,16 +47,15 @@ LinkRegistry::LinkRegistry () : { } -namespace { -struct ConnectionObserverImpl : public ConnectionObserver { +class LinkRegistryConnectionObserver : public ConnectionObserver { LinkRegistry& links; - ConnectionObserverImpl(LinkRegistry& l) : links(l) {} + public: + LinkRegistryConnectionObserver(LinkRegistry& l) : links(l) {} void connection(Connection& c) { links.notifyConnection(c.getMgmtId(), &c); } void opened(Connection& c) { links.notifyOpened(c.getMgmtId()); } void closed(Connection& c) { links.notifyClosed(c.getMgmtId()); } void forced(Connection& c, const string& text) { links.notifyConnectionForced(c.getMgmtId(), text); } }; -} LinkRegistry::LinkRegistry (Broker* _broker) : broker(_broker), @@ -62,7 +63,7 @@ LinkRegistry::LinkRegistry (Broker* _broker) : realm(broker->getOptions().realm) { broker->getConnectionObservers().add( - boost::shared_ptr<ConnectionObserver>(new ConnectionObserverImpl(*this))); + boost::shared_ptr<ConnectionObserver>(new LinkRegistryConnectionObserver(*this))); } LinkRegistry::~LinkRegistry() {} @@ -368,3 +369,4 @@ void LinkRegistry::eachBridge(boost::function<void(boost::shared_ptr<Bridge>)> f for (BridgeMap::iterator i = bridges.begin(); i != bridges.end(); ++i) f(i->second); } +}} // namespace qpid::broker diff --git a/cpp/src/qpid/broker/LinkRegistry.h b/cpp/src/qpid/broker/LinkRegistry.h index 753f6bfe9e..8e9d2f4b0d 100644 --- a/cpp/src/qpid/broker/LinkRegistry.h +++ b/cpp/src/qpid/broker/LinkRegistry.h @@ -23,6 +23,7 @@ */ #include <map> +#include "qpid/broker/BrokerImportExport.h" #include "qpid/broker/Bridge.h" #include "qpid/broker/MessageStore.h" #include "qpid/Address.h" @@ -56,43 +57,50 @@ namespace broker { static std::string createKey(const Address& address); static std::string createKey(const std::string& host, uint16_t port); + // Methods called by the connection observer. + void notifyConnection (const std::string& key, Connection* c); + void notifyOpened (const std::string& key); + void notifyClosed (const std::string& key); + void notifyConnectionForced (const std::string& key, const std::string& text); + friend class LinkRegistryConnectionObserver; + public: - LinkRegistry (); // Only used in store tests - LinkRegistry (Broker* _broker); - ~LinkRegistry(); - - std::pair<boost::shared_ptr<Link>, bool> - declare(const std::string& host, - uint16_t port, - const std::string& transport, - bool durable, - const std::string& authMechanism, - const std::string& username, - const std::string& password); - - std::pair<Bridge::shared_ptr, bool> - declare(const std::string& host, - uint16_t port, - bool durable, - const std::string& src, - const std::string& dest, - const std::string& key, - bool isQueue, - bool isLocal, - const std::string& id, - const std::string& excludes, - bool dynamic, - uint16_t sync, - Bridge::InitializeCallback=0 - ); - - void destroy(const std::string& host, const uint16_t port); - - void destroy(const std::string& host, - const uint16_t port, - const std::string& src, - const std::string& dest, - const std::string& key); + QPID_BROKER_EXTERN LinkRegistry (); // Only used in store tests + QPID_BROKER_EXTERN LinkRegistry (Broker* _broker); + QPID_BROKER_EXTERN ~LinkRegistry(); + + QPID_BROKER_EXTERN std::pair<boost::shared_ptr<Link>, bool> + declare(const std::string& host, + uint16_t port, + const std::string& transport, + bool durable, + const std::string& authMechanism, + const std::string& username, + const std::string& password); + + QPID_BROKER_EXTERN std::pair<Bridge::shared_ptr, bool> + declare(const std::string& host, + uint16_t port, + bool durable, + const std::string& src, + const std::string& dest, + const std::string& key, + bool isQueue, + bool isLocal, + const std::string& id, + const std::string& excludes, + bool dynamic, + uint16_t sync, + Bridge::InitializeCallback=0 + ); + + QPID_BROKER_EXTERN void destroy(const std::string& host, const uint16_t port); + + QPID_BROKER_EXTERN void destroy(const std::string& host, + const uint16_t port, + const std::string& src, + const std::string& dest, + const std::string& key); /** * Register the manageable parent for declared queues @@ -102,24 +110,20 @@ namespace broker { /** * Set the store to use. May only be called once. */ - void setStore (MessageStore*); + QPID_BROKER_EXTERN void setStore (MessageStore*); /** * Return the message store used. */ - MessageStore* getStore() const; + QPID_BROKER_EXTERN MessageStore* getStore() const; - void notifyConnection (const std::string& key, Connection* c); - void notifyOpened (const std::string& key); - void notifyClosed (const std::string& key); - void notifyConnectionForced (const std::string& key, const std::string& text); - std::string getAuthMechanism (const std::string& key); - std::string getAuthCredentials (const std::string& key); - std::string getAuthIdentity (const std::string& key); - std::string getUsername (const std::string& key); - std::string getPassword (const std::string& key); - std::string getHost (const std::string& key); - uint16_t getPort (const std::string& key); + QPID_BROKER_EXTERN std::string getAuthMechanism (const std::string& key); + QPID_BROKER_EXTERN std::string getAuthCredentials (const std::string& key); + QPID_BROKER_EXTERN std::string getAuthIdentity (const std::string& key); + QPID_BROKER_EXTERN std::string getUsername (const std::string& key); + QPID_BROKER_EXTERN std::string getPassword (const std::string& key); + QPID_BROKER_EXTERN std::string getHost (const std::string& key); + QPID_BROKER_EXTERN uint16_t getPort (const std::string& key); /** * Called by links failing over to new address @@ -132,13 +136,13 @@ namespace broker { * updated but links won't actually establish connections and * bridges won't therefore pull or push any messages. */ - void setPassive(bool); - bool isPassive() { return passive; } + QPID_BROKER_EXTERN void setPassive(bool); + QPID_BROKER_EXTERN bool isPassive() { return passive; } /** Iterate over each link in the registry. Used for cluster updates. */ - void eachLink(boost::function<void(boost::shared_ptr<Link>)> f); + QPID_BROKER_EXTERN void eachLink(boost::function<void(boost::shared_ptr<Link>)> f); /** Iterate over each bridge in the registry. Used for cluster updates. */ - void eachBridge(boost::function<void(boost::shared_ptr< Bridge>)> f); + QPID_BROKER_EXTERN void eachBridge(boost::function<void(boost::shared_ptr< Bridge>)> f); }; } } diff --git a/cpp/src/qpid/broker/Queue.h b/cpp/src/qpid/broker/Queue.h index e8573c17cc..66efe4eca3 100644 --- a/cpp/src/qpid/broker/Queue.h +++ b/cpp/src/qpid/broker/Queue.h @@ -235,8 +235,9 @@ class Queue : public boost::enable_shared_from_this<Queue>, /** * Bind self to specified exchange, and record that binding for unbinding on delete. */ - bool bind(boost::shared_ptr<Exchange> exchange, const std::string& key, - const qpid::framing::FieldTable& arguments=qpid::framing::FieldTable()); + QPID_BROKER_EXTERN bool bind( + boost::shared_ptr<Exchange> exchange, const std::string& key, + const qpid::framing::FieldTable& arguments=qpid::framing::FieldTable()); /** Acquire the message at the given position if it is available for acquire. Not to * be used by clients, but used by the broker for queue management. @@ -271,28 +272,29 @@ class Queue : public boost::enable_shared_from_this<Queue>, bool exclusive = false); QPID_BROKER_EXTERN void cancel(Consumer::shared_ptr c); - uint32_t purge(const uint32_t purge_request=0, //defaults to all messages + QPID_BROKER_EXTERN uint32_t purge(const uint32_t purge_request=0, //defaults to all messages boost::shared_ptr<Exchange> dest=boost::shared_ptr<Exchange>(), const ::qpid::types::Variant::Map *filter=0); QPID_BROKER_EXTERN void purgeExpired(sys::Duration); //move qty # of messages to destination Queue destq - uint32_t move(const Queue::shared_ptr destq, uint32_t qty, - const qpid::types::Variant::Map *filter=0); + QPID_BROKER_EXTERN uint32_t move( + const Queue::shared_ptr destq, uint32_t qty, + const qpid::types::Variant::Map *filter=0); QPID_BROKER_EXTERN uint32_t getMessageCount() const; QPID_BROKER_EXTERN uint32_t getEnqueueCompleteMessageCount() const; QPID_BROKER_EXTERN uint32_t getConsumerCount() const; inline const std::string& getName() const { return name; } - bool isExclusiveOwner(const OwnershipToken* const o) const; - void releaseExclusiveOwnership(); - bool setExclusiveOwner(const OwnershipToken* const o); - bool hasExclusiveConsumer() const; - bool hasExclusiveOwner() const; + QPID_BROKER_EXTERN bool isExclusiveOwner(const OwnershipToken* const o) const; + QPID_BROKER_EXTERN void releaseExclusiveOwnership(); + QPID_BROKER_EXTERN bool setExclusiveOwner(const OwnershipToken* const o); + QPID_BROKER_EXTERN bool hasExclusiveConsumer() const; + QPID_BROKER_EXTERN bool hasExclusiveOwner() const; inline bool isDurable() const { return store != 0; } inline const framing::FieldTable& getSettings() const { return settings; } inline bool isAutoDelete() const { return autodelete; } - bool canAutoDelete() const; + QPID_BROKER_EXTERN bool canAutoDelete() const; const QueueBindings& getBindings() const { return bindings; } /** @@ -301,8 +303,8 @@ class Queue : public boost::enable_shared_from_this<Queue>, QPID_BROKER_EXTERN void setLastNodeFailure(); QPID_BROKER_EXTERN void clearLastNodeFailure(); - bool enqueue(TransactionContext* ctxt, boost::intrusive_ptr<Message>& msg, bool suppressPolicyCheck = false); - void enqueueAborted(boost::intrusive_ptr<Message> msg); + QPID_BROKER_EXTERN bool enqueue(TransactionContext* ctxt, boost::intrusive_ptr<Message>& msg, bool suppressPolicyCheck = false); + QPID_BROKER_EXTERN void enqueueAborted(boost::intrusive_ptr<Message> msg); /** * dequeue from store (only done once messages is acknowledged) */ @@ -311,7 +313,7 @@ class Queue : public boost::enable_shared_from_this<Queue>, * Inform the queue that a previous transactional dequeue * committed. */ - void dequeueCommitted(const QueuedMessage& msg); + QPID_BROKER_EXTERN void dequeueCommitted(const QueuedMessage& msg); /** * Inform queue of messages that were enqueued, have since @@ -319,7 +321,7 @@ class Queue : public boost::enable_shared_from_this<Queue>, * thus are still logically on the queue) - used in * clustered broker. */ - void updateEnqueued(const QueuedMessage& msg); + QPID_BROKER_EXTERN void updateEnqueued(const QueuedMessage& msg); /** * Test whether the specified message (identified by its @@ -328,7 +330,7 @@ class Queue : public boost::enable_shared_from_this<Queue>, * have been delievered to a subscriber who has not yet * accepted it). */ - bool isEnqueued(const QueuedMessage& msg); + QPID_BROKER_EXTERN bool isEnqueued(const QueuedMessage& msg); /** * Acquires the next available (oldest) message @@ -338,17 +340,17 @@ class Queue : public boost::enable_shared_from_this<Queue>, /** Get the message at position pos, returns true if found and sets msg */ QPID_BROKER_EXTERN bool find(framing::SequenceNumber pos, QueuedMessage& msg ) const; - const QueuePolicy* getPolicy(); + QPID_BROKER_EXTERN const QueuePolicy* getPolicy(); - void setAlternateExchange(boost::shared_ptr<Exchange> exchange); - boost::shared_ptr<Exchange> getAlternateExchange(); - bool isLocal(boost::intrusive_ptr<Message>& msg); + QPID_BROKER_EXTERN void setAlternateExchange(boost::shared_ptr<Exchange> exchange); + QPID_BROKER_EXTERN boost::shared_ptr<Exchange> getAlternateExchange(); + QPID_BROKER_EXTERN bool isLocal(boost::intrusive_ptr<Message>& msg); //PersistableQueue support: - uint64_t getPersistenceId() const; - void setPersistenceId(uint64_t persistenceId) const; - void encode(framing::Buffer& buffer) const; - uint32_t encodedSize() const; + QPID_BROKER_EXTERN uint64_t getPersistenceId() const; + QPID_BROKER_EXTERN void setPersistenceId(uint64_t persistenceId) const; + QPID_BROKER_EXTERN void encode(framing::Buffer& buffer) const; + QPID_BROKER_EXTERN uint32_t encodedSize() const; /** * Restores a queue from encoded data (used in recovery) @@ -362,15 +364,15 @@ class Queue : public boost::enable_shared_from_this<Queue>, virtual void setExternalQueueStore(ExternalQueueStore* inst); // Increment the rejected-by-consumer counter. - void countRejected() const; - void countFlowedToDisk(uint64_t size) const; - void countLoadedFromDisk(uint64_t size) const; + QPID_BROKER_EXTERN void countRejected() const; + QPID_BROKER_EXTERN void countFlowedToDisk(uint64_t size) const; + QPID_BROKER_EXTERN void countLoadedFromDisk(uint64_t size) const; // Manageable entry points - management::ManagementObject* GetManagementObject (void) const; + QPID_BROKER_EXTERN management::ManagementObject* GetManagementObject (void) const; management::Manageable::status_t - ManagementMethod (uint32_t methodId, management::Args& args, std::string& text); - void query(::qpid::types::Variant::Map&) const; + QPID_BROKER_EXTERN ManagementMethod (uint32_t methodId, management::Args& args, std::string& text); + QPID_BROKER_EXTERN void query(::qpid::types::Variant::Map&) const; /** Apply f to each Message on the queue. */ template <class F> void eachMessage(F f) { @@ -396,31 +398,31 @@ class Queue : public boost::enable_shared_from_this<Queue>, /** return current position sequence number for the next message on the queue. */ QPID_BROKER_EXTERN framing::SequenceNumber getPosition(); - void addObserver(boost::shared_ptr<QueueObserver>); - void removeObserver(boost::shared_ptr<QueueObserver>); + QPID_BROKER_EXTERN void addObserver(boost::shared_ptr<QueueObserver>); + QPID_BROKER_EXTERN void removeObserver(boost::shared_ptr<QueueObserver>); QPID_BROKER_EXTERN void insertSequenceNumbers(const std::string& key); /** * Notify queue that recovery has completed. */ - void recoveryComplete(ExchangeRegistry& exchanges); + QPID_BROKER_EXTERN void recoveryComplete(ExchangeRegistry& exchanges); // For cluster update - QueueListeners& getListeners(); - Messages& getMessages(); - const Messages& getMessages() const; + QPID_BROKER_EXTERN QueueListeners& getListeners(); + QPID_BROKER_EXTERN Messages& getMessages(); + QPID_BROKER_EXTERN const Messages& getMessages() const; /** * Reserve space in policy for an enqueued message that * has been recovered in the prepared state (dtx only) */ - void recoverPrepared(boost::intrusive_ptr<Message>& msg); + QPID_BROKER_EXTERN void recoverPrepared(boost::intrusive_ptr<Message>& msg); - void flush(); + QPID_BROKER_EXTERN void flush(); - Broker* getBroker(); + QPID_BROKER_EXTERN Broker* getBroker(); uint32_t getDequeueSincePurge() { return dequeueSincePurge.get(); } - void setDequeueSincePurge(uint32_t value); + QPID_BROKER_EXTERN void setDequeueSincePurge(uint32_t value); }; } } diff --git a/cpp/src/qpid/broker/SemanticState.h b/cpp/src/qpid/broker/SemanticState.h index f7c9760821..e5e1d2da16 100644 --- a/cpp/src/qpid/broker/SemanticState.h +++ b/cpp/src/qpid/broker/SemanticState.h @@ -22,6 +22,7 @@ * */ +#include "qpid/broker/BrokerImportExport.h" #include "qpid/broker/Consumer.h" #include "qpid/broker/Credit.h" #include "qpid/broker/Deliverable.h" @@ -98,42 +99,44 @@ class SemanticState : private boost::noncopyable { bool haveCredit(); protected: - virtual bool doDispatch(); + QPID_BROKER_EXTERN virtual bool doDispatch(); size_t unacked() { return parent->unacked.size(); } public: typedef boost::shared_ptr<ConsumerImpl> shared_ptr; - ConsumerImpl(SemanticState* parent, - const std::string& name, boost::shared_ptr<Queue> queue, - bool ack, bool acquire, bool exclusive, - const std::string& tag, const std::string& resumeId, uint64_t resumeTtl, const framing::FieldTable& arguments); - virtual ~ConsumerImpl(); - OwnershipToken* getSession(); - virtual bool deliver(QueuedMessage& msg); - bool filter(boost::intrusive_ptr<Message> msg); - bool accept(boost::intrusive_ptr<Message> msg); - void cancel() {} - - void disableNotify(); - void enableNotify(); - void notify(); - bool isNotifyEnabled() const; - - void requestDispatch(); - - void setWindowMode(); - void setCreditMode(); - void addByteCredit(uint32_t value); - void addMessageCredit(uint32_t value); - void flush(); - void stop(); - void complete(DeliveryRecord&); + QPID_BROKER_EXTERN ConsumerImpl( + SemanticState* parent, + const std::string& name, boost::shared_ptr<Queue> queue, + bool ack, bool acquire, bool exclusive, + const std::string& tag, const std::string& resumeId, uint64_t resumeTtl, + const framing::FieldTable& arguments); + QPID_BROKER_EXTERN virtual ~ConsumerImpl(); + QPID_BROKER_EXTERN OwnershipToken* getSession(); + QPID_BROKER_EXTERN virtual bool deliver(QueuedMessage& msg); + QPID_BROKER_EXTERN bool filter(boost::intrusive_ptr<Message> msg); + QPID_BROKER_EXTERN bool accept(boost::intrusive_ptr<Message> msg); + QPID_BROKER_EXTERN void cancel() {} + + QPID_BROKER_EXTERN void disableNotify(); + QPID_BROKER_EXTERN void enableNotify(); + QPID_BROKER_EXTERN void notify(); + QPID_BROKER_EXTERN bool isNotifyEnabled() const; + + QPID_BROKER_EXTERN void requestDispatch(); + + QPID_BROKER_EXTERN void setWindowMode(); + QPID_BROKER_EXTERN void setCreditMode(); + QPID_BROKER_EXTERN void addByteCredit(uint32_t value); + QPID_BROKER_EXTERN void addMessageCredit(uint32_t value); + QPID_BROKER_EXTERN void flush(); + QPID_BROKER_EXTERN void stop(); + QPID_BROKER_EXTERN void complete(DeliveryRecord&); boost::shared_ptr<Queue> getQueue() const { return queue; } bool isBlocked() const { return blocked; } bool setBlocked(bool set) { std::swap(set, blocked); return set; } - bool doOutput(); + QPID_BROKER_EXTERN bool doOutput(); Credit& getCredit() { return credit; } const Credit& getCredit() const { return credit; } @@ -151,8 +154,11 @@ class SemanticState : private boost::noncopyable { void acknowledged(const broker::QueuedMessage&) {} // manageable entry points - management::ManagementObject* GetManagementObject (void) const; - management::Manageable::status_t ManagementMethod (uint32_t methodId, management::Args& args, std::string& text); + QPID_BROKER_EXTERN management::ManagementObject* + GetManagementObject(void) const; + + QPID_BROKER_EXTERN management::Manageable::status_t + ManagementMethod(uint32_t methodId, management::Args& args, std::string& text); }; typedef std::map<std::string, DtxBuffer::shared_ptr> DtxBufferMap; diff --git a/cpp/src/qpid/client/TCPConnector.cpp b/cpp/src/qpid/client/TCPConnector.cpp index 51eacf77e8..4660a41c07 100644 --- a/cpp/src/qpid/client/TCPConnector.cpp +++ b/cpp/src/qpid/client/TCPConnector.cpp @@ -97,7 +97,7 @@ void TCPConnector::connect(const std::string& host, const std::string& port) { boost::bind(&TCPConnector::connected, this, _1), boost::bind(&TCPConnector::connectFailed, this, _3)); closed = false; - identifier = str(format("[%1%]") % socket.getFullAddress()); + connector->start(poller); } @@ -120,6 +120,8 @@ void TCPConnector::start(sys::AsynchIO* aio_) { for (int i = 0; i < 4; i++) { aio->queueReadBuffer(new Buff(maxFrameSize)); } + + identifier = str(format("[%1%]") % socket.getFullAddress()); } void TCPConnector::initAmqp() { @@ -129,7 +131,7 @@ void TCPConnector::initAmqp() { void TCPConnector::connectFailed(const std::string& msg) { connector = 0; - QPID_LOG(warning, "Connect failed: " << msg << " " << identifier); + QPID_LOG(warning, "Connect failed: " << msg); socket.close(); if (!closed) closed = true; @@ -183,7 +185,7 @@ sys::ShutdownHandler* TCPConnector::getShutdownHandler() const { return shutdownHandler; } -const std::string& TCPConnector::getIdentifier() const { +const std::string& TCPConnector::getIdentifier() const { return identifier; } diff --git a/cpp/src/qpid/ha/Backup.cpp b/cpp/src/qpid/ha/Backup.cpp index 5acbfb9d5f..3d65e07202 100644 --- a/cpp/src/qpid/ha/Backup.cpp +++ b/cpp/src/qpid/ha/Backup.cpp @@ -52,7 +52,7 @@ Backup::Backup(broker::Broker& b, const Settings& s) : void Backup::initialize(const Url& url) { assert(!url.empty()); - QPID_LOG(notice, "Ha: Backup started: " << url); + QPID_LOG(notice, "HA: Backup started: " << url); string protocol = url[0].protocol.empty() ? "tcp" : url[0].protocol; // Declare the link std::pair<Link::shared_ptr, bool> result = broker.getLinks().declare( diff --git a/cpp/src/qpid/ha/BrokerReplicator.cpp b/cpp/src/qpid/ha/BrokerReplicator.cpp index a8f05c1fe3..75e4ed893d 100644 --- a/cpp/src/qpid/ha/BrokerReplicator.cpp +++ b/cpp/src/qpid/ha/BrokerReplicator.cpp @@ -266,6 +266,7 @@ void BrokerReplicator::route(Deliverable& msg, const string& /*key*/, const fram } void BrokerReplicator::doEventQueueDeclare(Variant::Map& values) { + QPID_LOG(debug, "HA: Backup queue declare event " << values); string name = values[QNAME].asString(); Variant::Map argsMap = asMapVoid(values[ARGS]); if (values[DISP] == CREATED && replicateLevel(argsMap)) { @@ -296,6 +297,7 @@ void BrokerReplicator::doEventQueueDeclare(Variant::Map& values) { } void BrokerReplicator::doEventQueueDelete(Variant::Map& values) { + QPID_LOG(debug, "HA: Backup queue delete event " << values); // The remote queue has already been deleted so replicator // sessions may be closed by a "queue deleted" exception. string name = values[QNAME].asString(); @@ -314,6 +316,7 @@ void BrokerReplicator::doEventQueueDelete(Variant::Map& values) { } void BrokerReplicator::doEventExchangeDeclare(Variant::Map& values) { + QPID_LOG(debug, "HA: Backup exchange declare event " << values); Variant::Map argsMap(asMapVoid(values[ARGS])); if (values[DISP] == CREATED && replicateLevel(argsMap)) { string name = values[EXNAME].asString(); @@ -338,6 +341,7 @@ void BrokerReplicator::doEventExchangeDeclare(Variant::Map& values) { } void BrokerReplicator::doEventExchangeDelete(Variant::Map& values) { + QPID_LOG(debug, "HA: Backup exchange delete event " << values); string name = values[EXNAME].asString(); try { boost::shared_ptr<Exchange> exchange = broker.getExchanges().find(name); @@ -352,6 +356,7 @@ void BrokerReplicator::doEventExchangeDelete(Variant::Map& values) { } void BrokerReplicator::doEventBind(Variant::Map& values) { + QPID_LOG(debug, "HA: Backup bind event " << values); boost::shared_ptr<Exchange> exchange = broker.getExchanges().find(values[EXNAME].asString()); boost::shared_ptr<Queue> queue = @@ -372,6 +377,7 @@ void BrokerReplicator::doEventBind(Variant::Map& values) { } void BrokerReplicator::doEventUnbind(Variant::Map& values) { + QPID_LOG(debug, "HA: Backup unbind event " << values); boost::shared_ptr<Exchange> exchange = broker.getExchanges().find(values[EXNAME].asString()); boost::shared_ptr<Queue> queue = @@ -392,6 +398,7 @@ void BrokerReplicator::doEventUnbind(Variant::Map& values) { } void BrokerReplicator::doResponseQueue(Variant::Map& values) { + QPID_LOG(debug, "HA: Backup queue response " << values); // FIXME aconway 2011-11-22: more flexible ways & defaults to indicate replication Variant::Map argsMap(asMapVoid(values[ARGUMENTS])); if (!replicateLevel(argsMap)) return; @@ -419,6 +426,7 @@ void BrokerReplicator::doResponseQueue(Variant::Map& values) { } void BrokerReplicator::doResponseExchange(Variant::Map& values) { + QPID_LOG(debug, "HA: Backup exchange response " << values); Variant::Map argsMap(asMapVoid(values[ARGUMENTS])); if (!replicateLevel(argsMap)) return; framing::FieldTable args; @@ -460,6 +468,7 @@ const std::string QUEUE_REF("queueRef"); } // namespace void BrokerReplicator::doResponseBind(Variant::Map& values) { + QPID_LOG(debug, "HA: Backup bind response " << values); std::string exName = getRefName(EXCHANGE_REF_PREFIX, values[EXCHANGE_REF]); std::string qName = getRefName(QUEUE_REF_PREFIX, values[QUEUE_REF]); boost::shared_ptr<Exchange> exchange = broker.getExchanges().find(exName); diff --git a/cpp/src/qpid/ha/HaBroker.cpp b/cpp/src/qpid/ha/HaBroker.cpp index 0d3bd51439..d92749abeb 100644 --- a/cpp/src/qpid/ha/HaBroker.cpp +++ b/cpp/src/qpid/ha/HaBroker.cpp @@ -27,8 +27,9 @@ #include "qpid/broker/Broker.h" #include "qpid/management/ManagementAgent.h" #include "qmf/org/apache/qpid/ha/Package.h" -#include "qmf/org/apache/qpid/ha/ArgsHaBrokerSetClientAddresses.h" -#include "qmf/org/apache/qpid/ha/ArgsHaBrokerSetBrokerAddresses.h" +#include "qmf/org/apache/qpid/ha/ArgsHaBrokerSetBrokers.h" +#include "qmf/org/apache/qpid/ha/ArgsHaBrokerSetPublicBrokers.h" +#include "qmf/org/apache/qpid/ha/ArgsHaBrokerSetExpectedBackups.h" #include "qpid/log/Statement.h" namespace qpid { @@ -88,18 +89,19 @@ Manageable::status_t HaBroker::ManagementMethod (uint32_t methodId, Args& args, } break; } - case _qmf::HaBroker::METHOD_SETCLIENTADDRESSES: { - setClientUrl( - Url(dynamic_cast<_qmf::ArgsHaBrokerSetClientAddresses&>(args). - i_clientAddresses), l); + case _qmf::HaBroker::METHOD_SETBROKERS: { + setBrokerUrl(Url(dynamic_cast<_qmf::ArgsHaBrokerSetBrokers&>(args).i_url), l); break; } - case _qmf::HaBroker::METHOD_SETBROKERADDRESSES: { - setBrokerUrl( - Url(dynamic_cast<_qmf::ArgsHaBrokerSetBrokerAddresses&>(args) - .i_brokerAddresses), l); + case _qmf::HaBroker::METHOD_SETPUBLICBROKERS: { + setClientUrl(Url(dynamic_cast<_qmf::ArgsHaBrokerSetPublicBrokers&>(args).i_url), l); break; } + case _qmf::HaBroker::METHOD_SETEXPECTEDBACKUPS: { + setExpectedBackups(dynamic_cast<_qmf::ArgsHaBrokerSetExpectedBackups&>(args).i_expectedBackups, l); + break; + } + default: return Manageable::STATUS_UNKNOWN_METHOD; } @@ -115,21 +117,27 @@ void HaBroker::setClientUrl(const Url& url, const sys::Mutex::ScopedLock& l) { void HaBroker::updateClientUrl(const sys::Mutex::ScopedLock&) { Url url = clientUrl.empty() ? brokerUrl : clientUrl; assert(!url.empty()); - mgmtObject->set_clientAddresses(url.str()); + mgmtObject->set_publicBrokers(url.str()); knownBrokers.clear(); knownBrokers.push_back(url); - QPID_LOG(debug, "HA: Setting client known-brokers to: " << url); + QPID_LOG(debug, "HA: Setting client URL to: " << url); } void HaBroker::setBrokerUrl(const Url& url, const sys::Mutex::ScopedLock& l) { if (url.empty()) throw Exception("Invalid empty URL for HA broker failover"); + QPID_LOG(debug, "HA: Setting broker URL to: " << url); brokerUrl = url; - mgmtObject->set_brokerAddresses(brokerUrl.str()); + mgmtObject->set_brokers(brokerUrl.str()); if (backup.get()) backup->setBrokerUrl(brokerUrl); // Updating broker URL also updates defaulted client URL: if (clientUrl.empty()) updateClientUrl(l); } +void HaBroker::setExpectedBackups(size_t n, const sys::Mutex::ScopedLock&) { + expectedBackups = n; + mgmtObject->set_expectedBackups(n); +} + std::vector<Url> HaBroker::getKnownBrokers() const { return knownBrokers; } diff --git a/cpp/src/qpid/ha/HaBroker.h b/cpp/src/qpid/ha/HaBroker.h index 835a47c749..4f4ee4c944 100644 --- a/cpp/src/qpid/ha/HaBroker.h +++ b/cpp/src/qpid/ha/HaBroker.h @@ -55,6 +55,7 @@ class HaBroker : public management::Manageable private: void setClientUrl(const Url&, const sys::Mutex::ScopedLock&); void setBrokerUrl(const Url&, const sys::Mutex::ScopedLock&); + void setExpectedBackups(size_t, const sys::Mutex::ScopedLock&); void updateClientUrl(const sys::Mutex::ScopedLock&); bool isPrimary(const sys::Mutex::ScopedLock&) { return !backup.get(); } std::vector<Url> getKnownBrokers() const; @@ -67,6 +68,7 @@ class HaBroker : public management::Manageable qmf::org::apache::qpid::ha::HaBroker* mgmtObject; Url clientUrl, brokerUrl; std::vector<Url> knownBrokers; + size_t expectedBackups; }; }} // namespace qpid::ha diff --git a/cpp/src/qpid/ha/HaPlugin.cpp b/cpp/src/qpid/ha/HaPlugin.cpp index fc9e48411d..b3080330fb 100644 --- a/cpp/src/qpid/ha/HaPlugin.cpp +++ b/cpp/src/qpid/ha/HaPlugin.cpp @@ -31,12 +31,20 @@ struct Options : public qpid::Options { Settings& settings; Options(Settings& s) : qpid::Options("HA Options"), settings(s) { addOptions() - ("ha-enable", optValue(settings.enabled, "yes|no"), "Enable High Availability features") - ("ha-client-url", optValue(settings.clientUrl,"URL"), "URL that clients use to connect and fail over.") - ("ha-broker-url", optValue(settings.brokerUrl,"URL"), "URL that backup brokers use to connect and fail over.") - ("ha-username", optValue(settings.username, "USER"), "Username for connections between brokers") - ("ha-password", optValue(settings.password, "PASS"), "Password for connections between brokers") - ("ha-mechanism", optValue(settings.mechanism, "MECH"), "Authentication mechanism for connections between brokers") + ("ha-cluster", optValue(settings.enabled, "yes|no"), + "Join a HA active/passive cluster.") + ("ha-brokers", optValue(settings.brokerUrl,"URL"), + "URL that backup brokers use to connect and fail over.") + ("ha-public-brokers", optValue(settings.clientUrl,"URL"), + "URL that clients use to connect and fail over, defaults to ha-brokers.") + ("ha-expected-backups", optValue(settings.expectedBackups, "N"), + "Number of backups expected to be active in the HA cluster.") + ("ha-username", optValue(settings.username, "USER"), + "Username for connections between HA brokers") + ("ha-password", optValue(settings.password, "PASS"), + "Password for connections between HA brokers") + ("ha-mechanism", optValue(settings.mechanism, "MECH"), + "Authentication mechanism for connections between HA brokers") ; } }; @@ -56,6 +64,7 @@ struct HaPlugin : public Plugin { void initialize(Plugin::Target& target) { broker::Broker* broker = dynamic_cast<broker::Broker*>(&target); if (broker && settings.enabled) { + QPID_LOG(notice, "HA: Enabled"); haBroker.reset(new ha::HaBroker(*broker, settings)); } else QPID_LOG(notice, "HA: Disabled"); diff --git a/cpp/src/qpid/ha/QueueReplicator.cpp b/cpp/src/qpid/ha/QueueReplicator.cpp index 0017cc82cd..7351a8d74d 100644 --- a/cpp/src/qpid/ha/QueueReplicator.cpp +++ b/cpp/src/qpid/ha/QueueReplicator.cpp @@ -31,7 +31,6 @@ #include "qpid/framing/FieldTable.h" #include "qpid/log/Statement.h" #include <boost/shared_ptr.hpp> -#include <sstream> namespace { const std::string QPID_REPLICATOR_("qpid.replicator-"); @@ -54,9 +53,7 @@ std::string QueueReplicator::replicatorName(const std::string& queueName) { QueueReplicator::QueueReplicator(boost::shared_ptr<Queue> q, boost::shared_ptr<Link> l) : Exchange(replicatorName(q->getName()), 0, q->getBroker()), queue(q), link(l) { - std::stringstream ss; - ss << "HA: Backup " << queue->getName() << ": "; - logPrefix = ss.str(); + logPrefix = "HA: Backup " + queue->getName() + ": "; QPID_LOG(info, logPrefix << "Created, settings: " << q->getSettings()); } @@ -155,9 +152,6 @@ void QueueReplicator::route(Deliverable& msg, const std::string& key, const Fiel QPID_LOG(trace, logPrefix << "Position moved from " << queue->getPosition() << " to " << position); assert(queue->getPosition() <= position); - //TODO aconway 2011-12-14: Optimize this? - for (SequenceNumber i = queue->getPosition(); i < position; ++i) - dequeue(i,l); queue->setPosition(position); } else { msg.deliverTo(queue); diff --git a/cpp/src/qpid/ha/ReplicatingSubscription.h b/cpp/src/qpid/ha/ReplicatingSubscription.h index e311f9505a..cbcb230bc1 100644 --- a/cpp/src/qpid/ha/ReplicatingSubscription.h +++ b/cpp/src/qpid/ha/ReplicatingSubscription.h @@ -33,7 +33,7 @@ namespace qpid { namespace broker { class Message; class Queue; -class QueuedMessage; +struct QueuedMessage; class OwnershipToken; } diff --git a/cpp/src/qpid/ha/Settings.h b/cpp/src/qpid/ha/Settings.h index 049c873b9f..52a64c8330 100644 --- a/cpp/src/qpid/ha/Settings.h +++ b/cpp/src/qpid/ha/Settings.h @@ -33,10 +33,11 @@ namespace ha { class Settings { public: - Settings() : enabled(false) {} + Settings() : enabled(false), expectedBackups(0) {} bool enabled; std::string clientUrl; std::string brokerUrl; + size_t expectedBackups; std::string username, password, mechanism; private: }; diff --git a/cpp/src/qpid/ha/management-schema.xml b/cpp/src/qpid/ha/management-schema.xml index fe4a14d111..05ed5f02ce 100644 --- a/cpp/src/qpid/ha/management-schema.xml +++ b/cpp/src/qpid/ha/management-schema.xml @@ -22,16 +22,30 @@ <!-- Monitor and control HA status of a broker. --> <class name="HaBroker"> <property name="name" type="sstr" access="RC" index="y" desc="Primary Key"/> + <property name="status" type="sstr" desc="HA status: primary or backup"/> - <property name="clientAddresses" type="sstr" desc="List of addresses used by clients to connect to the HA cluster."/> - <property name="brokerAddresses" type="sstr" desc="List of addresses used by HA brokers to connect to each other."/> + + <property name="brokers" type="sstr" + desc="Multiple-address URL used by HA brokers to connect to each other."/> + + <property name="publicBrokers" type="sstr" + desc="Multiple-address URL used by clients to connect to the HA brokers."/> + + <property name="expectedBackups" type="uint16" + desc="Number of HA backup brokers expected."/>> <method name="promote" desc="Promote a backup broker to primary."/> - <method name="setClientAddresses" desc="Set HA client addresses"> - <arg name="clientAddresses" type="sstr" dir="I"/> + + <method name="setBrokers" desc="Set URL for HA brokers to connect to each other."> + <arg name="url" type="sstr" dir="I"/> + </method> + + <method name="setPublicBrokers" desc="Set URL for clients to connect to HA brokers"> + <arg name="url" type="sstr" dir="I"/> </method> - <method name="setBrokerAddresses" desc="Set HA broker addresses"> - <arg name="brokerAddresses" type="sstr" dir="I"/> + + <method name="setExpectedBackups" desc="Set number of backups expected"> + <arg name="expectedBackups" type="uint16" dir="I"/> </method> </class> diff --git a/cpp/include/qpid/sys/MemStat.h b/cpp/src/qpid/sys/MemStat.h index d855786cd5..d855786cd5 100644 --- a/cpp/include/qpid/sys/MemStat.h +++ b/cpp/src/qpid/sys/MemStat.h diff --git a/cpp/src/qpid/sys/Probes.h b/cpp/src/qpid/sys/Probes.h new file mode 100644 index 0000000000..d30181c357 --- /dev/null +++ b/cpp/src/qpid/sys/Probes.h @@ -0,0 +1,65 @@ +#ifndef _sys_Probes +#define _sys_Probes +/* + * + * 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 "config.h" + +#ifdef HAVE_SYS_SDT_H +#include <sys/sdt.h> +#endif + +// Pragmatically it seems that Linux and Solaris versions of sdt.h which support +// user static probes define up to DTRACE_PROBE8, but FreeBSD 8 which doesn't +// support usdt only defines up to DTRACE_PROBE4 - FreeBSD 9 which does support usdt +// defines up to DTRACE_PROBE5. + +#ifdef DTRACE_PROBE5 +// Versions for Linux Systemtap/Solaris/FreeBSD 9 +#define QPID_PROBE(probe) DTRACE_PROBE(qpid, probe) +#define QPID_PROBE1(probe, p1) DTRACE_PROBE1(qpid, probe, p1) +#define QPID_PROBE2(probe, p1, p2) DTRACE_PROBE2(qpid, probe, p1, p2) +#define QPID_PROBE3(probe, p1, p2, p3) DTRACE_PROBE3(qpid, probe, p1, p2, p3) +#define QPID_PROBE4(probe, p1, p2, p3, p4) DTRACE_PROBE4(qpid, probe, p1, p2, p3, p4) +#define QPID_PROBE5(probe, p1, p2, p3, p4, p5) DTRACE_PROBE5(qpid, probe, p1, p2, p3, p4, p5) +#else +// FreeBSD 8 +#define QPID_PROBE(probe) +#define QPID_PROBE1(probe, p1) +#define QPID_PROBE2(probe, p1, p2) +#define QPID_PROBE3(probe, p1, p2, p3) +#define QPID_PROBE4(probe, p1, p2, p3, p4) +#define QPID_PROBE5(probe, p1, p2, p3, p4, p5) +#endif + +#ifdef DTRACE_PROBE8 +// Versions for Linux Systemtap +#define QPID_PROBE6(probe, p1, p2, p3, p4, p5, p6) DTRACE_PROBE6(qpid, probe, p1, p2, p3, p4, p5, p6) +#define QPID_PROBE7(probe, p1, p2, p3, p4, p5, p6, p7) DTRACE_PROBE7(qpid, probe, p1, p2, p3, p4, p5, p6, p7) +#define QPID_PROBE8(probe, p1, p2, p3, p4, p5, p6, p7, p8) DTRACE_PROBE8(qpid, probe, p1, p2, p3, p4, p5, p6, p7, p8) +#else +// Versions for Solaris/FreeBSD +#define QPID_PROBE6(probe, p1, p2, p3, p4, p5, p6) +#define QPID_PROBE7(probe, p1, p2, p3, p4, p5, p6, p7) +#define QPID_PROBE8(probe, p1, p2, p3, p4, p5, p6, p7, p8) +#endif + +#endif // _sys_Probes diff --git a/cpp/src/qpid/sys/apr/APRBase.cpp b/cpp/src/qpid/sys/apr/APRBase.cpp deleted file mode 100644 index 8bdba66bdc..0000000000 --- a/cpp/src/qpid/sys/apr/APRBase.cpp +++ /dev/null @@ -1,89 +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 <iostream> -#include "qpid/log/Statement.h" -#include "qpid/sys/apr/APRBase.h" - -using namespace qpid::sys; - -APRBase* APRBase::instance = 0; - -APRBase* APRBase::getInstance(){ - if(instance == 0){ - instance = new APRBase(); - } - return instance; -} - - -APRBase::APRBase() : count(0){ - apr_initialize(); - CHECK_APR_SUCCESS(apr_pool_create(&pool, 0)); - CHECK_APR_SUCCESS(apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_NESTED, pool)); -} - -APRBase::~APRBase(){ - CHECK_APR_SUCCESS(apr_thread_mutex_destroy(mutex)); - apr_pool_destroy(pool); - apr_terminate(); -} - -bool APRBase::_increment(){ - bool deleted(false); - CHECK_APR_SUCCESS(apr_thread_mutex_lock(mutex)); - if(this == instance){ - count++; - }else{ - deleted = true; - } - CHECK_APR_SUCCESS(apr_thread_mutex_unlock(mutex)); - return !deleted; -} - -void APRBase::_decrement(){ - APRBase* copy = 0; - CHECK_APR_SUCCESS(apr_thread_mutex_lock(mutex)); - if(--count == 0){ - copy = instance; - instance = 0; - } - CHECK_APR_SUCCESS(apr_thread_mutex_unlock(mutex)); - if(copy != 0){ - delete copy; - } -} - -void APRBase::increment(){ - int count = 0; - while(count++ < 2 && !getInstance()->_increment()) - QPID_LOG(warning, "APR initialization triggered concurrently with termination."); -} - -void APRBase::decrement(){ - getInstance()->_decrement(); -} - -std::string qpid::sys::get_desc(apr_status_t status){ - const int size = 50; - char tmp[size]; - return std::string(apr_strerror(status, tmp, size)); -} - diff --git a/cpp/src/qpid/sys/apr/APRBase.h b/cpp/src/qpid/sys/apr/APRBase.h deleted file mode 100644 index 7b5644a129..0000000000 --- a/cpp/src/qpid/sys/apr/APRBase.h +++ /dev/null @@ -1,74 +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 _APRBase_ -#define _APRBase_ - -#include <string> -#include <apr_thread_mutex.h> -#include <apr_errno.h> - -namespace qpid { -namespace sys { - - /** - * Use of APR libraries necessitates explicit init and terminate - * calls. Any class using APR libs should obtain the reference to - * this singleton and increment on construction, decrement on - * destruction. This class can then correctly initialise apr - * before the first use and terminate after the last use. - */ - class APRBase{ - static APRBase* instance; - apr_pool_t* pool; - apr_thread_mutex_t* mutex; - int count; - - APRBase(); - ~APRBase(); - static APRBase* getInstance(); - bool _increment(); - void _decrement(); - public: - static void increment(); - static void decrement(); - }; - - //this is also a convenient place for a helper function for error checking: - void check(apr_status_t status, const char* file, const int line); - std::string get_desc(apr_status_t status); - -#define CHECK_APR_SUCCESS(A) qpid::sys::check(A, __FILE__, __LINE__); - -} -} - -// Inlined as it is called *a lot* -void inline qpid::sys::check(apr_status_t status, const char* file, const int line){ - if (status != APR_SUCCESS){ - char tmp[256]; - throw Exception(QPID_MSG(apr_strerror(status, tmp, size))) - } -} - - - - -#endif diff --git a/cpp/src/qpid/sys/apr/APRPool.cpp b/cpp/src/qpid/sys/apr/APRPool.cpp deleted file mode 100644 index e221bfc2f1..0000000000 --- a/cpp/src/qpid/sys/apr/APRPool.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/sys/apr/APRPool.h" -#include "qpid/sys/apr/APRBase.h" -#include <boost/pool/detail/singleton.hpp> - -using namespace qpid::sys; - -APRPool::APRPool(){ - APRBase::increment(); - CHECK_APR_SUCCESS(apr_pool_create(&pool, NULL)); -} - -APRPool::~APRPool(){ - apr_pool_destroy(pool); - APRBase::decrement(); -} - -apr_pool_t* APRPool::get() { - return boost::details::pool::singleton_default<APRPool>::instance().pool; -} - diff --git a/cpp/src/qpid/sys/apr/Condition.h b/cpp/src/qpid/sys/apr/Condition.h deleted file mode 100644 index 66d465ca75..0000000000 --- a/cpp/src/qpid/sys/apr/Condition.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef _sys_apr_Condition_h -#define _sys_apr_Condition_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/sys/apr/APRPool.h" -#include "qpid/sys/Mutex.h" -#include "qpid/sys/Time.h" - -#include <sys/errno.h> -#include <boost/noncopyable.hpp> -#include <apr_thread_cond.h> - -namespace qpid { -namespace sys { - -/** - * A condition variable for thread synchronization. - */ -class Condition -{ - public: - inline Condition(); - inline ~Condition(); - inline void wait(Mutex&); - inline bool wait(Mutex&, const AbsTime& absoluteTime); - inline void notify(); - inline void notifyAll(); - - private: - apr_thread_cond_t* condition; -}; - - -Condition::Condition() { - CHECK_APR_SUCCESS(apr_thread_cond_create(&condition, APRPool::get())); -} - -Condition::~Condition() { - CHECK_APR_SUCCESS(apr_thread_cond_destroy(condition)); -} - -void Condition::wait(Mutex& mutex) { - CHECK_APR_SUCCESS(apr_thread_cond_wait(condition, mutex.mutex)); -} - -bool Condition::wait(Mutex& mutex, const AbsTime& absoluteTime){ - // APR uses microseconds. - apr_status_t status = - apr_thread_cond_timedwait( - condition, mutex.mutex, Duration(now(), absoluteTime)/TIME_USEC); - if(status != APR_TIMEUP) CHECK_APR_SUCCESS(status); - return status == 0; -} - -void Condition::notify(){ - CHECK_APR_SUCCESS(apr_thread_cond_signal(condition)); -} - -void Condition::notifyAll(){ - CHECK_APR_SUCCESS(apr_thread_cond_broadcast(condition)); -} - -}} -#endif /*!_sys_apr_Condition_h*/ diff --git a/cpp/src/qpid/sys/apr/Mutex.h b/cpp/src/qpid/sys/apr/Mutex.h deleted file mode 100644 index cb75f5b339..0000000000 --- a/cpp/src/qpid/sys/apr/Mutex.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef _sys_apr_Mutex_h -#define _sys_apr_Mutex_h - -/* - * - * Copyright (c) 2006 The Apache Software Foundation - * - * Licensed 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/apr/APRBase.h" -#include "qpid/sys/apr/APRPool.h" - -#include <boost/noncopyable.hpp> -#include <apr_thread_mutex.h> - -namespace qpid { -namespace sys { - -class Condition; - -/** - * Mutex lock. - */ -class Mutex : private boost::noncopyable { - public: - typedef ScopedLock<Mutex> ScopedLock; - typedef ScopedUnlock<Mutex> ScopedUnlock; - - inline Mutex(); - inline ~Mutex(); - inline void lock(); - inline void unlock(); - inline bool trylock(); - - protected: - apr_thread_mutex_t* mutex; - friend class Condition; -}; - -Mutex::Mutex() { - CHECK_APR_SUCCESS(apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_NESTED, APRPool::get())); -} - -Mutex::~Mutex(){ - CHECK_APR_SUCCESS(apr_thread_mutex_destroy(mutex)); -} - -void Mutex::lock() { - CHECK_APR_SUCCESS(apr_thread_mutex_lock(mutex)); -} -void Mutex::unlock() { - CHECK_APR_SUCCESS(apr_thread_mutex_unlock(mutex)); -} - -bool Mutex::trylock() { - return apr_thread_mutex_trylock(mutex) == 0; -} - - -/** - * RW lock. - */ -class RWlock : private boost::noncopyable { - friend class Condition; - -public: - typedef ScopedRlock<RWlock> ScopedRlock; - typedef ScopedWlock<RWlock> ScopedWlock; - - inline RWlock(); - inline ~RWlock(); - inline void wlock(); // will write-lock - inline void rlock(); // will read-lock - inline void unlock(); - inline bool trywlock(); // will write-try - inline bool tryrlock(); // will read-try - - protected: - apr_thread_mutex_t* mutex; -}; - -RWlock::RWlock() { - CHECK_APR_SUCCESS(apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_NESTED, APRPool::get())); -} - -RWlock::~RWlock(){ - CHECK_APR_SUCCESS(apr_thread_mutex_destroy(mutex)); -} - -void RWlock::wlock() { - CHECK_APR_SUCCESS(apr_thread_mutex_lock(mutex)); -} - -void RWlock::rlock() { - CHECK_APR_SUCCESS(apr_thread_mutex_lock(mutex)); -} - -void RWlock::unlock() { - CHECK_APR_SUCCESS(apr_thread_mutex_unlock(mutex)); -} - -bool RWlock::trywlock() { - return apr_thread_mutex_trylock(mutex) == 0; -} - -bool RWlock::tryrlock() { - return apr_thread_mutex_trylock(mutex) == 0; -} - - -}} -#endif /*!_sys_apr_Mutex_h*/ diff --git a/cpp/src/qpid/sys/apr/Shlib.cpp b/cpp/src/qpid/sys/apr/Shlib.cpp deleted file mode 100644 index b7ee13a03b..0000000000 --- a/cpp/src/qpid/sys/apr/Shlib.cpp +++ /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. - * - */ - -#include "qpid/sys/Shlib.h" -#include "qpid/sys/apr/APRBase.h" -#include "qpid/sys/apr/APRPool.h" -#include <apr_dso.h> - -namespace qpid { -namespace sys { - -void Shlib::load(const char* libname) { - apr_dso_handle_t* aprHandle; - CHECK_APR_SUCCESS( - apr_dso_load(&aprHandle, libname, APRPool::get())); - handle=aprHandle; -} - -void Shlib::unload() { - CHECK_APR_SUCCESS( - apr_dso_unload(static_cast<apr_dso_handle_t*>(handle))); -} - -void* Shlib::getSymbol(const char* name) { - apr_dso_handle_sym_t symbol; - CHECK_APR_SUCCESS(apr_dso_sym(&symbol, - static_cast<apr_dso_handle_t*>(handle), - name)); - return (void*) symbol; -} - -}} // namespace qpid::sys diff --git a/cpp/src/qpid/sys/apr/Socket.cpp b/cpp/src/qpid/sys/apr/Socket.cpp deleted file mode 100644 index d9024d11c1..0000000000 --- a/cpp/src/qpid/sys/apr/Socket.cpp +++ /dev/null @@ -1,114 +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/sys/Socket.h" - -#include "qpid/sys/apr/APRBase.h" -#include "qpid/sys/apr/APRPool.h" - -#include <apr_network_io.h> - -namespace qpid { -namespace sys { - -class SocketPrivate { -public: - SocketPrivate(apr_socket_t* s = 0) : - socket(s) - {} - - apr_socket_t* socket; -}; - -Socket::Socket() : - impl(new SocketPrivate) -{ - createTcp(); -} - -Socket::Socket(SocketPrivate* sp) : - impl(sp) -{} - -Socket::~Socket() { - delete impl; -} - -void Socket::createTcp() const { - apr_socket_t*& socket = impl->socket; - apr_socket_t* s; - CHECK_APR_SUCCESS( - apr_socket_create( - &s, APR_INET, SOCK_STREAM, APR_PROTO_TCP, - APRPool::get())); - socket = s; -} - -void Socket::setTimeout(const Duration& interval) const { - apr_socket_t*& socket = impl->socket; - apr_socket_timeout_set(socket, interval/TIME_USEC); -} - -void Socket::connect(const std::string& host, int port) const { - apr_socket_t*& socket = impl->socket; - apr_sockaddr_t* address; - CHECK_APR_SUCCESS( - apr_sockaddr_info_get( - &address, host.c_str(), APR_UNSPEC, port, APR_IPV4_ADDR_OK, - APRPool::get())); - CHECK_APR_SUCCESS(apr_socket_connect(socket, address)); -} - -void Socket::close() const { - apr_socket_t*& socket = impl->socket; - if (socket == 0) return; - CHECK_APR_SUCCESS(apr_socket_close(socket)); - socket = 0; -} - -ssize_t Socket::send(const void* data, size_t size) const -{ - apr_socket_t*& socket = impl->socket; - apr_size_t sent = size; - apr_status_t status = - apr_socket_send(socket, reinterpret_cast<const char*>(data), &sent); - if (APR_STATUS_IS_TIMEUP(status)) return SOCKET_TIMEOUT; - if (APR_STATUS_IS_EOF(status)) return SOCKET_EOF; - CHECK_APR_SUCCESS(status); - return sent; -} - -ssize_t Socket::recv(void* data, size_t size) const -{ - apr_socket_t*& socket = impl->socket; - apr_size_t received = size; - apr_status_t status = - apr_socket_recv(socket, reinterpret_cast<char*>(data), &received); - if (APR_STATUS_IS_TIMEUP(status)) - return SOCKET_TIMEOUT; - if (APR_STATUS_IS_EOF(status)) - return SOCKET_EOF; - CHECK_APR_SUCCESS(status); - return received; -} - -}} // namespace qpid::sys diff --git a/cpp/src/qpid/sys/apr/Thread.cpp b/cpp/src/qpid/sys/apr/Thread.cpp deleted file mode 100644 index b52d0e6ace..0000000000 --- a/cpp/src/qpid/sys/apr/Thread.cpp +++ /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. - * - */ - -#include "qpid/sys/apr/Thread.h" -#include "qpid/sys/Runnable.h" - -using namespace qpid::sys; -using qpid::sys::Runnable; - -void* APR_THREAD_FUNC Thread::runRunnable(apr_thread_t* thread, void *data) { - reinterpret_cast<Runnable*>(data)->run(); - CHECK_APR_SUCCESS(apr_thread_exit(thread, APR_SUCCESS)); - return NULL; -} - - diff --git a/cpp/src/qpid/sys/apr/Thread.h b/cpp/src/qpid/sys/apr/Thread.h deleted file mode 100644 index 6cc63db5c9..0000000000 --- a/cpp/src/qpid/sys/apr/Thread.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef _sys_apr_Thread_h -#define _sys_apr_Thread_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/sys/apr/APRPool.h" -#include "qpid/sys/apr/APRBase.h" - -#include <apr_thread_proc.h> -#include <apr_portable.h> - -namespace qpid { -namespace sys { - -class Runnable; - -class Thread -{ - public: - inline static Thread current(); - - /** ID of current thread for logging. - * Workaround for broken Thread::current() in APR - */ - inline static long logId(); - - inline static void yield(); - - inline Thread(); - inline explicit Thread(qpid::sys::Runnable*); - inline explicit Thread(qpid::sys::Runnable&); - - inline void join(); - - inline long id(); - - private: - static void* APR_THREAD_FUNC runRunnable(apr_thread_t* thread, void *data); - inline Thread(apr_thread_t* t); - apr_thread_t* thread; -}; - -Thread::Thread() : thread(0) {} - -Thread::Thread(Runnable* runnable) { - CHECK_APR_SUCCESS( - apr_thread_create(&thread, 0, runRunnable, runnable, APRPool::get())); -} - -Thread::Thread(Runnable& runnable) { - CHECK_APR_SUCCESS( - apr_thread_create(&thread, 0, runRunnable, &runnable, APRPool::get())); -} - -void Thread::join(){ - apr_status_t status; - if (thread != 0) - CHECK_APR_SUCCESS(apr_thread_join(&status, thread)); -} - -long Thread::id() { - return long(thread); -} - -/** ID of current thread for logging. - * Workaround for broken Thread::current() in APR - */ -long Thread::logId() { - return static_cast<long>(apr_os_thread_current()); -} - -Thread::Thread(apr_thread_t* t) : thread(t) {} - -Thread Thread::current(){ - apr_thread_t* thr; - apr_os_thread_t osthr = apr_os_thread_current(); - CHECK_APR_SUCCESS(apr_os_thread_put(&thr, &osthr, APRPool::get())); - return Thread(thr); -} - -void Thread::yield() -{ - apr_thread_yield(); -} - -}} -#endif /*!_sys_apr_Thread_h*/ diff --git a/cpp/src/qpid/sys/apr/Time.cpp b/cpp/src/qpid/sys/apr/Time.cpp deleted file mode 100644 index 34e740b144..0000000000 --- a/cpp/src/qpid/sys/apr/Time.cpp +++ /dev/null @@ -1,36 +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/sys/Time.h" - -#include <apr_time.h> - -namespace qpid { -namespace sys { - -AbsTime AbsTime::now() { - AbsTime time_now; - time_now.time_ns = apr_time_now() * TIME_USEC; - return time_now; -} - -}} - diff --git a/cpp/src/qpid/sys/posix/AsynchIO.cpp b/cpp/src/qpid/sys/posix/AsynchIO.cpp index a1c161b596..c25159985e 100644 --- a/cpp/src/qpid/sys/posix/AsynchIO.cpp +++ b/cpp/src/qpid/sys/posix/AsynchIO.cpp @@ -23,6 +23,7 @@ #include "qpid/sys/Socket.h" #include "qpid/sys/SocketAddress.h" #include "qpid/sys/Poller.h" +#include "qpid/sys/Probes.h" #include "qpid/sys/DispatchHandle.h" #include "qpid/sys/Time.h" #include "qpid/log/Statement.h" @@ -423,9 +424,12 @@ AsynchIO::BufferBase* AsynchIO::getQueuedBuffer() { void AsynchIO::readable(DispatchHandle& h) { if (readingStopped) { // We have been flow controlled. + QPID_PROBE1(asynchio_read_flowcontrolled, &h); return; } AbsTime readStartTime = AbsTime::now(); + size_t total = 0; + int readCalls = 0; do { // (Try to) get a buffer if (!bufferQueue.empty()) { @@ -436,23 +440,29 @@ void AsynchIO::readable(DispatchHandle& h) { errno = 0; int readCount = buff->byteCount-buff->dataCount; int rc = socket.read(buff->bytes + buff->dataCount, readCount); + int64_t duration = Duration(readStartTime, AbsTime::now()); + ++readCalls; if (rc > 0) { buff->dataCount += rc; threadReadTotal += rc; + total += rc; readCallback(*this, buff); if (readingStopped) { // We have been flow controlled. + QPID_PROBE4(asynchio_read_finished_flowcontrolled, &h, duration, total, readCalls); break; } if (rc != readCount) { // If we didn't fill the read buffer then time to stop reading + QPID_PROBE4(asynchio_read_finished_done, &h, duration, total, readCalls); break; } // Stop reading if we've overrun our timeslot - if (Duration(readStartTime, AbsTime::now()) > threadMaxIoTimeNs) { + if ( duration > threadMaxIoTimeNs) { + QPID_PROBE4(asynchio_read_finished_maxtime, &h, duration, total, readCalls); break; } @@ -461,6 +471,7 @@ void AsynchIO::readable(DispatchHandle& h) { bufferQueue.push_front(buff); assert(buff); + QPID_PROBE5(asynchio_read_finished_error, &h, duration, total, readCalls, errno); // Eof or other side has gone away if (rc == 0 || errno == ECONNRESET) { eofCallback(*this); @@ -486,6 +497,7 @@ void AsynchIO::readable(DispatchHandle& h) { // If we still have no buffers we can't do anything more if (bufferQueue.empty()) { h.unwatchRead(); + QPID_PROBE4(asynchio_read_finished_nobuffers, &h, Duration(readStartTime, AbsTime::now()), total, readCalls); break; } @@ -501,6 +513,8 @@ void AsynchIO::readable(DispatchHandle& h) { */ void AsynchIO::writeable(DispatchHandle& h) { AbsTime writeStartTime = AbsTime::now(); + size_t total = 0; + int writeCalls = 0; do { // See if we've got something to write if (!writeQueue.empty()) { @@ -510,14 +524,18 @@ void AsynchIO::writeable(DispatchHandle& h) { errno = 0; assert(buff->dataStart+buff->dataCount <= buff->byteCount); int rc = socket.write(buff->bytes+buff->dataStart, buff->dataCount); + int64_t duration = Duration(writeStartTime, AbsTime::now()); + ++writeCalls; if (rc >= 0) { threadWriteTotal += rc; + total += rc; // If we didn't write full buffer put rest back if (rc != buff->dataCount) { buff->dataStart += rc; buff->dataCount -= rc; writeQueue.push_back(buff); + QPID_PROBE4(asynchio_write_finished_done, &h, duration, total, writeCalls); break; } @@ -525,12 +543,15 @@ void AsynchIO::writeable(DispatchHandle& h) { queueReadBuffer(buff); // Stop writing if we've overrun our timeslot - if (Duration(writeStartTime, AbsTime::now()) > threadMaxIoTimeNs) { + if (duration > threadMaxIoTimeNs) { + QPID_PROBE4(asynchio_write_finished_maxtime, &h, duration, total, writeCalls); break; } } else { // Put buffer back writeQueue.push_back(buff); + QPID_PROBE5(asynchio_write_finished_error, &h, duration, total, writeCalls, errno); + if (errno == ECONNRESET || errno == EPIPE) { // Just stop watching for write here - we'll get a // disconnect callback soon enough @@ -548,9 +569,13 @@ void AsynchIO::writeable(DispatchHandle& h) { } } } else { + int64_t duration = Duration(writeStartTime, AbsTime::now()); + (void) duration; // force duration to be used if no probes are compiled + // If we're waiting to close the socket then can do it now as there is nothing to write if (queuedClose) { close(h); + QPID_PROBE4(asynchio_write_finished_closed, &h, duration, total, writeCalls); break; } // Fd is writable, but nothing to write @@ -567,6 +592,7 @@ void AsynchIO::writeable(DispatchHandle& h) { // desired rewatchWrite so we correct that here if (writePending) h.rewatchWrite(); + QPID_PROBE4(asynchio_write_finished_nodata, &h, duration, total, writeCalls); break; } } diff --git a/cpp/src/tests/CMakeLists.txt b/cpp/src/tests/CMakeLists.txt index 75ecffe866..79c82106cb 100644 --- a/cpp/src/tests/CMakeLists.txt +++ b/cpp/src/tests/CMakeLists.txt @@ -34,8 +34,14 @@ set (abs_builddir ${CMAKE_CURRENT_BINARY_DIR}) set (abs_top_srcdir ${CMAKE_SOURCE_DIR}) set (abs_top_builddir ${CMAKE_BINARY_DIR}) set (builddir_lib_suffix "") -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/test_env.sh.in - ${CMAKE_CURRENT_BINARY_DIR}/test_env.sh) + +if (CMAKE_SYSTEM_NAME STREQUAL Windows) + configure_file (${CMAKE_CURRENT_SOURCE_DIR}/test_env.ps1.in + ${CMAKE_CURRENT_BINARY_DIR}/test_env.ps1) +else (CMAKE_SYSTEM_NAME STREQUAL Windows) + configure_file (${CMAKE_CURRENT_SOURCE_DIR}/test_env.sh.in + ${CMAKE_CURRENT_BINARY_DIR}/test_env.sh) +endif (CMAKE_SYSTEM_NAME STREQUAL Windows) # If valgrind is selected in the configuration step, set up the path to it diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am index 325019fb22..a7f3bc1fbd 100644 --- a/cpp/src/tests/Makefile.am +++ b/cpp/src/tests/Makefile.am @@ -351,7 +351,8 @@ EXTRA_DIST += \ topictest.ps1 \ run_queue_flow_limit_tests \ run_msg_group_tests \ - ipv6_test + ipv6_test \ + ha_tests.py check_LTLIBRARIES += libdlclose_noop.la libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir) diff --git a/cpp/src/tests/acl.py b/cpp/src/tests/acl.py index 5db3bfe85a..5cc3b9c917 100755 --- a/cpp/src/tests/acl.py +++ b/cpp/src/tests/acl.py @@ -48,8 +48,12 @@ class ACLTests(TestBase010): return connection.session(str(uuid4())) def reload_acl(self): - acl = self.qmf.getObjects(_class="acl")[0] - return acl.reloadACLFile() + result = None + try: + self.broker_access.reloadAclFile() + except Exception, e: + result = str(e) + return result def get_acl_file(self): return ACLFile(self.config.defines.get("policy-file", "data_dir/policy.acl")) @@ -59,7 +63,7 @@ class ACLTests(TestBase010): aclf.write('acl allow all all\n') aclf.close() TestBase010.setUp(self) - self.startQmf() + self.startBrokerAccess() self.reload_acl() def tearDown(self): @@ -84,7 +88,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) session = self.get_session('bob','bob') @@ -111,7 +115,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) session = self.get_session('bob','bob') @@ -168,7 +172,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("Insufficient tokens for acl definition",0,len(result.text)) == -1): + if (result.find("Insufficient tokens for acl definition",0,len(result)) == -1): self.fail("ACL Reader should reject the acl file due to empty group name") def test_illegal_acl_formats(self): @@ -181,7 +185,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("Unknown ACL permission",0,len(result.text)) == -1): + if (result.find("Unknown ACL permission",0,len(result)) == -1): self.fail(result) def test_illegal_extension_lines(self): @@ -197,10 +201,10 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("contains an illegal extension",0,len(result.text)) == -1): + if (result.find("contains an illegal extension",0,len(result)) == -1): self.fail(result) - if (result.text.find("Non-continuation line must start with \"group\" or \"acl\"",0,len(result.text)) == -1): + if (result.find("Non-continuation line must start with \"group\" or \"acl\"",0,len(result)) == -1): self.fail(result) def test_illegal_extension_lines(self): @@ -216,7 +220,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("ACL format error",0,len(result.text)) != -1): + if (result): self.fail(result) def test_user_realm(self): @@ -231,7 +235,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("Username 'bob' must contain a realm",0,len(result.text)) == -1): + if (result.find("Username 'bob' must contain a realm",0,len(result)) == -1): self.fail(result) def test_allowed_chars_for_username(self): @@ -247,7 +251,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("ACL format error",0,len(result.text)) != -1): + if (result): self.fail(result) aclf = self.get_acl_file() @@ -256,7 +260,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("Username \"joe$H@EXAMPLE.com\" contains illegal characters",0,len(result.text)) == -1): + if (result.find("Username \"joe$H@EXAMPLE.com\" contains illegal characters",0,len(result)) == -1): self.fail(result) #===================================== @@ -276,7 +280,7 @@ class ACLTests(TestBase010): result = self.reload_acl() expected = "ding is not a valid value for 'policytype', possible values are one of" \ " { 'ring' 'ring_strict' 'flow_to_disk' 'reject' }"; - if (result.text != expected): + if (result.find(expected) == -1): self.fail(result) def test_illegal_queuemaxsize_upper_limit_spec(self): @@ -294,7 +298,7 @@ class ACLTests(TestBase010): result = self.reload_acl() expected = "-1 is not a valid value for 'queuemaxsizeupperlimit', " \ "values should be between 0 and 9223372036854775807"; - if (result.text != expected): + if (result.find(expected) == -1): self.fail(result) aclf = self.get_acl_file() @@ -305,7 +309,7 @@ class ACLTests(TestBase010): result = self.reload_acl() expected = "9223372036854775808 is not a valid value for 'queuemaxsizeupperlimit', " \ "values should be between 0 and 9223372036854775807"; - if (result.text != expected): + if (result.find(expected) == -1): self.fail(result) # @@ -351,7 +355,7 @@ class ACLTests(TestBase010): result = self.reload_acl() expected = "-1 is not a valid value for 'queuemaxcountupperlimit', " \ "values should be between 0 and 9223372036854775807"; - if (result.text != expected): + if (result.find(expected) == -1): self.fail(result) aclf = self.get_acl_file() @@ -362,7 +366,7 @@ class ACLTests(TestBase010): result = self.reload_acl() expected = "9223372036854775808 is not a valid value for 'queuemaxcountupperlimit', " \ "values should be between 0 and 9223372036854775807"; - if (result.text != expected): + if (result.find(expected) == -1): self.fail(result) # @@ -466,7 +470,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) session = self.get_session('bob','bob') @@ -573,7 +577,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) session = self.get_session('bob','bob') @@ -742,7 +746,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) session = self.get_session('bob','bob') @@ -873,7 +877,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) session = self.get_session('bob','bob') @@ -991,7 +995,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) bob = BrokerAdmin(self.config.broker, "bob", "bob") @@ -1030,7 +1034,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) session = self.get_session('bob','bob') @@ -1078,7 +1082,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) session = self.get_session('bob','bob') @@ -1123,7 +1127,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) session = self.get_session('bob','bob') @@ -1174,7 +1178,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) session = self.get_session('bob','bob') @@ -1242,7 +1246,7 @@ class ACLTests(TestBase010): aclf.close() result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): + if (result): self.fail(result) ts = None diff --git a/cpp/src/tests/cli_tests.py b/cpp/src/tests/cli_tests.py index 6c75927461..b9a7dda15c 100755 --- a/cpp/src/tests/cli_tests.py +++ b/cpp/src/tests/cli_tests.py @@ -22,7 +22,6 @@ import sys import os import imp from qpid.testlib import TestBase010 -# from brokertest import import_script, checkenv from qpid.datatypes import Message from qpid.queue import Empty from time import sleep @@ -61,14 +60,13 @@ class CliTests(TestBase010): ret = os.system(self.qpid_config_command(" add queue " + qname + " " + arguments)) self.assertEqual(ret, 0) - queues = self.qmf.getObjects(_class="queue") - for queue in queues: - if queue.name == qname: - return queue + queue = self.broker_access.getQueue(qname) + if queue: + return queue assert False def test_queue_params(self): - self.startQmf() + 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") @@ -82,29 +80,21 @@ class CliTests(TestBase010): self.assertEqual(queue4.arguments[LIMIT], "ring") self.assertEqual(queue5.arguments[LIMIT], "ring_strict") - queue6 = self.makeQueue("test_queue_params6", "--order fifo") - queue7 = self.makeQueue("test_queue_params7", "--order lvq") - queue8 = self.makeQueue("test_queue_params8", "--order lvq-no-browse") - - LVQ = "qpid.last_value_queue" - LVQNB = "qpid.last_value_queue_no_browse" + queue6 = self.makeQueue("test_queue_params6", "--lvq-key lkey") - assert LVQ not in queue6.arguments - assert LVQ in queue7.arguments - assert LVQ not in queue8.arguments - - assert LVQNB not in queue6.arguments - assert LVQNB not in queue7.arguments - assert LVQNB in queue8.arguments + LVQKEY = "qpid.last_value_queue_key" + assert LVQKEY not in queue5.arguments + assert LVQKEY in queue6.arguments + assert queue6.arguments[LVQKEY] == "lkey" def test_queue_params_api(self): - self.startQmf() - queue1 = self.makeQueue("test_queue_params1", "--limit-policy none", True) - queue2 = self.makeQueue("test_queue_params2", "--limit-policy reject", True) - queue3 = self.makeQueue("test_queue_params3", "--limit-policy flow-to-disk", True) - queue4 = self.makeQueue("test_queue_params4", "--limit-policy ring", True) - queue5 = self.makeQueue("test_queue_params5", "--limit-policy ring-strict", True) + 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) LIMIT = "qpid.policy_type" assert LIMIT not in queue1.arguments @@ -113,30 +103,22 @@ class CliTests(TestBase010): self.assertEqual(queue4.arguments[LIMIT], "ring") self.assertEqual(queue5.arguments[LIMIT], "ring_strict") - queue6 = self.makeQueue("test_queue_params6", "--order fifo", True) - queue7 = self.makeQueue("test_queue_params7", "--order lvq", True) - queue8 = self.makeQueue("test_queue_params8", "--order lvq-no-browse", True) - - LVQ = "qpid.last_value_queue" - LVQNB = "qpid.last_value_queue_no_browse" + queue6 = self.makeQueue("test_queue_params_api6", "--lvq-key lkey") - assert LVQ not in queue6.arguments - assert LVQ in queue7.arguments - assert LVQ not in queue8.arguments + LVQKEY = "qpid.last_value_queue_key" - assert LVQNB not in queue6.arguments - assert LVQNB not in queue7.arguments - assert LVQNB in queue8.arguments + assert LVQKEY not in queue5.arguments + assert LVQKEY in queue6.arguments + assert queue6.arguments[LVQKEY] == "lkey" def test_qpid_config(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); qname = "test_qpid_config" ret = os.system(self.qpid_config_command(" add queue " + qname)) self.assertEqual(ret, 0) - queues = qmf.getObjects(_class="queue") + queues = self.broker_access.getAllQueues() found = False for queue in queues: if queue.name == qname: @@ -146,7 +128,7 @@ class CliTests(TestBase010): ret = os.system(self.qpid_config_command(" del queue " + qname)) self.assertEqual(ret, 0) - queues = qmf.getObjects(_class="queue") + queues = self.broker_access.getAllQueues() found = False for queue in queues: if queue.name == qname: @@ -154,13 +136,12 @@ class CliTests(TestBase010): self.assertEqual(found, False) def test_qpid_config_api(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); qname = "test_qpid_config_api" ret = self.qpid_config_api(" add queue " + qname) self.assertEqual(ret, 0) - queues = qmf.getObjects(_class="queue") + queues = self.broker_access.getAllQueues() found = False for queue in queues: if queue.name == qname: @@ -170,7 +151,7 @@ class CliTests(TestBase010): ret = self.qpid_config_api(" del queue " + qname) self.assertEqual(ret, 0) - queues = qmf.getObjects(_class="queue") + queues = self.broker_access.getAllQueues() found = False for queue in queues: if queue.name == qname: @@ -179,25 +160,23 @@ class CliTests(TestBase010): def test_qpid_config_sasl_plain_expect_succeed(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); qname = "test_qpid_config_sasl_plain_expect_succeed" - cmd = " --sasl-mechanism PLAIN -a guest/guest@localhost:"+str(self.broker.port) + " add queue " + qname + cmd = " --sasl-mechanism PLAIN -b guest/guest@localhost:"+str(self.broker.port) + " add queue " + qname ret = self.qpid_config_api(cmd) self.assertEqual(ret, 0) def test_qpid_config_sasl_plain_expect_fail(self): """Fails because no user name and password is supplied""" - self.startQmf(); - qmf = self.qmf - qname = "test_qpid_config_sasl_plain_expect_succeed" - cmd = " --sasl-mechanism PLAIN -a localhost:"+str(self.broker.port) + " add queue " + qname + self.startBrokerAccess(); + qname = "test_qpid_config_sasl_plain_expect_fail" + cmd = " --sasl-mechanism PLAIN -b localhost:"+str(self.broker.port) + " add queue " + qname ret = self.qpid_config_api(cmd) assert ret != 0 # helpers for some of the test methods def helper_find_exchange(self, xchgname, typ, expected=True): - xchgs = self.qmf.getObjects(_class = "exchange") + xchgs = self.broker_access.getAllExchanges() found = False for xchg in xchgs: if xchg.name == xchgname: @@ -221,7 +200,7 @@ class CliTests(TestBase010): self.helper_find_exchange(xchgname, False, expected=False) def helper_find_queue(self, qname, expected=True): - queues = self.qmf.getObjects(_class="queue") + queues = self.broker_access.getAllQueues() found = False for queue in queues: if queue.name == qname: @@ -246,8 +225,7 @@ class CliTests(TestBase010): # test the bind-queue-to-header-exchange functionality def test_qpid_config_headers(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); qname = "test_qpid_config" xchgname = "test_xchg" @@ -277,8 +255,7 @@ class CliTests(TestBase010): def test_qpid_config_xml(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); qname = "test_qpid_config" xchgname = "test_xchg" @@ -306,13 +283,12 @@ class CliTests(TestBase010): self.helper_destroy_exchange(xchgname) def test_qpid_config_durable(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); qname = "test_qpid_config" ret = os.system(self.qpid_config_command(" add queue --durable " + qname)) self.assertEqual(ret, 0) - queues = qmf.getObjects(_class="queue") + queues = self.broker_access.getAllQueues() found = False for queue in queues: if queue.name == qname: @@ -322,7 +298,7 @@ class CliTests(TestBase010): ret = os.system(self.qpid_config_command(" del queue " + qname)) self.assertEqual(ret, 0) - queues = qmf.getObjects(_class="queue") + queues = self.broker_access.getAllQueues() found = False for queue in queues: if queue.name == qname: @@ -330,8 +306,7 @@ class CliTests(TestBase010): self.assertEqual(found, False) def test_qpid_config_altex(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); exName = "testalt" qName = "testqalt" altName = "amq.direct" @@ -339,7 +314,7 @@ class CliTests(TestBase010): ret = os.system(self.qpid_config_command(" add exchange topic %s --alternate-exchange=%s" % (exName, altName))) self.assertEqual(ret, 0) - exchanges = qmf.getObjects(_class="exchange") + exchanges = self.broker_access.getAllExchanges() found = False for exchange in exchanges: if exchange.name == altName: @@ -349,20 +324,20 @@ class CliTests(TestBase010): found = True if not exchange.altExchange: self.fail("Alternate exchange not set") - self.assertEqual(exchange._altExchange_.name, altName) + self.assertEqual(exchange.altExchange, altName) self.assertEqual(found, True) ret = os.system(self.qpid_config_command(" add queue %s --alternate-exchange=%s" % (qName, altName))) self.assertEqual(ret, 0) - queues = qmf.getObjects(_class="queue") + queues = self.broker_access.getAllQueues() found = False for queue in queues: if queue.name == qName: found = True if not queue.altExchange: self.fail("Alternate exchange not set") - self.assertEqual(queue._altExchange_.name, altName) + self.assertEqual(queue.altExchange, altName) self.assertEqual(found, True) def test_qpid_config_list_queues_arguments(self): @@ -371,8 +346,7 @@ class CliTests(TestBase010): actually a string (though still a valid value), it does not upset qpid-config """ - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); names = ["queue_capacity%s" % (i) for i in range(1, 6)] for name in names: @@ -386,15 +360,14 @@ class CliTests(TestBase010): assert name in queues, "%s not in %s" % (name, queues) def test_qpid_route(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); command = self.cli_dir() + "/qpid-route dynamic add guest/guest@localhost:%d %s:%d amq.topic" %\ (self.broker.port, self.remote_host(), self.remote_port()) ret = os.system(command) self.assertEqual(ret, 0) - links = qmf.getObjects(_class="link") + links = self.broker_access.getAllLinks() found = False for link in links: if link.port == self.remote_port(): @@ -402,8 +375,7 @@ class CliTests(TestBase010): self.assertEqual(found, True) def test_qpid_route_api(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); ret = self.qpid_route_api("dynamic add " + "guest/guest@localhost:"+str(self.broker.port) + " " @@ -412,7 +384,7 @@ class CliTests(TestBase010): self.assertEqual(ret, 0) - links = qmf.getObjects(_class="link") + links = self.broker_access.getAllLinks() found = False for link in links: if link.port == self.remote_port(): @@ -421,8 +393,7 @@ class CliTests(TestBase010): def test_qpid_route_api(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); ret = self.qpid_route_api("dynamic add " + " --client-sasl-mechanism PLAIN " @@ -432,7 +403,7 @@ class CliTests(TestBase010): self.assertEqual(ret, 0) - links = qmf.getObjects(_class="link") + links = self.broker_access.getAllLinks() found = False for link in links: if link.port == self.remote_port(): @@ -440,8 +411,7 @@ class CliTests(TestBase010): self.assertEqual(found, True) def test_qpid_route_api_expect_fail(self): - self.startQmf(); - qmf = self.qmf + self.startBrokerAccess(); ret = self.qpid_route_api("dynamic add " + " --client-sasl-mechanism PLAIN " @@ -463,11 +433,11 @@ class CliTests(TestBase010): return None def qpid_config_command(self, arg = ""): - return self.cli_dir() + "/qpid-config -a localhost:%d" % self.broker.port + " " + arg + return self.cli_dir() + "/qpid-config -b localhost:%d" % self.broker.port + " " + arg def qpid_config_api(self, arg = ""): script = import_script(checkenv("QPID_CONFIG_EXEC")) - broker = ["-a", "localhost:"+str(self.broker.port)] + broker = ["-b", "localhost:"+str(self.broker.port)] return script.main(broker + arg.split()) def qpid_route_api(self, arg = ""): diff --git a/cpp/src/tests/cluster_tests.py b/cpp/src/tests/cluster_tests.py index cbc3df4a6b..79df21aada 100755 --- a/cpp/src/tests/cluster_tests.py +++ b/cpp/src/tests/cluster_tests.py @@ -277,7 +277,7 @@ acl deny all all QMF-based tools - regression test for BZ615300.""" broker1 = self.cluster(1)[0] broker2 = self.cluster(1)[0] - qs = subprocess.Popen(["qpid-stat", "-e", broker1.host_port()], stdout=subprocess.PIPE) + qs = subprocess.Popen(["qpid-stat", "-e", "-b", broker1.host_port()], stdout=subprocess.PIPE) out = qs.communicate()[0] assert out.find("amq.failover") > 0 @@ -1160,7 +1160,7 @@ class LongTests(BrokerTest): def start_mclients(broker): """Start management clients that make multiple connections.""" - cmd = ["qpid-stat", "-b", "localhost:%s" %(broker.port())] + cmd = ["qpid-cluster", "-C", "localhost:%s" %(broker.port())] mclients.append(ClientLoop(broker, cmd)) endtime = time.time() + self.duration() diff --git a/cpp/src/tests/clustered_replication_test b/cpp/src/tests/clustered_replication_test index 4a57502f39..8c8522c2eb 100755 --- a/cpp/src/tests/clustered_replication_test +++ b/cpp/src/tests/clustered_replication_test @@ -65,8 +65,8 @@ if test -d $PYTHON_DIR; then #start first node of primary cluster and set up test queue echo Starting primary cluster PRIMARY1=$(with_ais_group $QPIDD_EXEC $GENERAL_OPTS $PRIMARY_OPTS --log-to-file repl.primary.1.tmp) || fail "Could not start PRIMARY1" - $PYTHON_COMMANDS/qpid-config -a "localhost:$PRIMARY1" add queue test-queue --generate-queue-events 2 - $PYTHON_COMMANDS/qpid-config -a "localhost:$PRIMARY1" add queue control-queue --generate-queue-events 1 + $PYTHON_COMMANDS/qpid-config -b "localhost:$PRIMARY1" add queue test-queue --generate-queue-events 2 + $PYTHON_COMMANDS/qpid-config -b "localhost:$PRIMARY1" add queue control-queue --generate-queue-events 1 #send 10 messages, consume 5 of them for i in `seq 1 10`; do echo Message$i; done | ./sender --port $PRIMARY1 @@ -81,9 +81,9 @@ if test -d $PYTHON_DIR; then DR1=$(with_ais_group $QPIDD_EXEC $GENERAL_OPTS $DR_OPTS --log-to-file repl.dr.1.tmp) || fail "Could not start DR1" DR2=$(with_ais_group $QPIDD_EXEC $GENERAL_OPTS $DR_OPTS --log-to-file repl.dr.2.tmp) || fail "Could not start DR2" - $PYTHON_COMMANDS/qpid-config -a "localhost:$DR1" add queue test-queue - $PYTHON_COMMANDS/qpid-config -a "localhost:$DR1" add queue control-queue - $PYTHON_COMMANDS/qpid-config -a "localhost:$DR1" add exchange replication REPLICATION_EXCHANGE + $PYTHON_COMMANDS/qpid-config -b "localhost:$DR1" add queue test-queue + $PYTHON_COMMANDS/qpid-config -b "localhost:$DR1" add queue control-queue + $PYTHON_COMMANDS/qpid-config -b "localhost:$DR1" add exchange replication REPLICATION_EXCHANGE $PYTHON_COMMANDS/qpid-route queue add localhost:$DR2 localhost:$PRIMARY2 REPLICATION_EXCHANGE REPLICATION_QUEUE || fail "Could not add route." #send more messages to primary diff --git a/cpp/src/tests/federated_cluster_test b/cpp/src/tests/federated_cluster_test index b32455259e..50b877e666 100755 --- a/cpp/src/tests/federated_cluster_test +++ b/cpp/src/tests/federated_cluster_test @@ -63,20 +63,20 @@ start_brokers() { setup() { #create exchange on both cluster and single broker - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add exchange direct test-exchange - $PYTHON_COMMANDS/qpid-config -a "localhost:$NODE_1" add exchange direct test-exchange + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add exchange direct test-exchange + $PYTHON_COMMANDS/qpid-config -b "localhost:$NODE_1" add exchange direct test-exchange #create dynamic routes for test exchange $PYTHON_COMMANDS/qpid-route dynamic add "localhost:$NODE_2" "localhost:$BROKER_A" test-exchange $PYTHON_COMMANDS/qpid-route dynamic add "localhost:$BROKER_A" "localhost:$NODE_2" test-exchange #create test queue on cluster and bind it to the test exchange - $PYTHON_COMMANDS/qpid-config -a "localhost:$NODE_1" add queue test-queue - $PYTHON_COMMANDS/qpid-config -a "localhost:$NODE_1" bind test-exchange test-queue to-cluster + $PYTHON_COMMANDS/qpid-config -b "localhost:$NODE_1" add queue test-queue + $PYTHON_COMMANDS/qpid-config -b "localhost:$NODE_1" bind test-exchange test-queue to-cluster #create test queue on single broker and bind it to the test exchange - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue test-queue - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" bind test-exchange test-queue from-cluster + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue test-queue + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" bind test-exchange test-queue from-cluster } run_test_pull_to_cluster_two_consumers() { diff --git a/cpp/src/tests/ha_tests.py b/cpp/src/tests/ha_tests.py index 97de0d1f77..264a636f29 100755 --- a/cpp/src/tests/ha_tests.py +++ b/cpp/src/tests/ha_tests.py @@ -18,8 +18,9 @@ # under the License. # -import os, signal, sys, time, imp, re, subprocess, glob, random, logging, shutil +import os, signal, sys, time, imp, re, subprocess, glob, random, logging, shutil, math from qpid.messaging import Message, NotFound, ConnectionError, Connection +from qpid.datatypes import uuid4 from brokertest import * from threading import Thread, Lock, Condition from logging import getLogger, WARN, ERROR, DEBUG @@ -33,21 +34,24 @@ class HaBroker(Broker): args=["--load-module", BrokerTest.ha_lib, # FIXME aconway 2012-02-13: workaround slow link failover. "--link-maintenace-interval=0.1", - "--ha-enable=yes"] - if broker_url: args += [ "--ha-broker-url", broker_url ] + "--ha-cluster=yes"] + if broker_url: args += [ "--ha-brokers", broker_url ] Broker.__init__(self, test, args, **kwargs) def promote(self): - assert os.system("qpid-ha-tool --promote %s"%(self.host_port())) == 0 + assert os.system("$QPID_HA_EXEC promote -b %s"%(self.host_port())) == 0 def set_client_url(self, url): assert os.system( - "qpid-ha-tool --client-addresses=%s %s"%(url,self.host_port())) == 0 + "$QPID_HA_EXEC set --public-brokers=%s -b %s"%(url,self.host_port())) == 0 def set_broker_url(self, url): assert os.system( - "qpid-ha-tool --broker-addresses=%s %s"%(url, self.host_port())) == 0 + "$QPID_HA_EXEC set --brokers=%s -b %s"%(url, self.host_port())) == 0 +def set_broker_urls(brokers): + url = ",".join([b.host_port() for b in brokers]) + for b in brokers: b.set_broker_url(url) class ShortTests(BrokerTest): """Short HA functionality tests.""" @@ -59,7 +63,7 @@ class ShortTests(BrokerTest): session.sender(address) return True except NotFound: return False - assert retry(check), "Timed out waiting for %s"%(address) + assert retry(check), "Timed out waiting for address %s"%(address) # Wait for address to become valid on a backup broker. def wait_backup(self, backup, address): @@ -109,7 +113,7 @@ class ShortTests(BrokerTest): s3 = p.sender(exchange(prefix+"e4", "messages", prefix+"q4")) s3.send(Message("7")) # Use old connection to unbind - us = primary.connect_old().session(str(qpid.datatypes.uuid4())) + us = primary.connect_old().session(str(uuid4())) us.exchange_unbind(exchange=prefix+"e4", binding_key="", queue=prefix+"q4") p.sender(prefix+"e4").send(Message("drop1")) # Should be dropped # Need a marker so we can wait till sync is done. @@ -298,6 +302,125 @@ class ShortTests(BrokerTest): self.assert_browse_backup(brokers[1], "q", ["a","b"]) for b in brokers[1:]: b.kill() + def test_lvq(self): + """Verify that we replicate to an LVQ correctly""" + primary = HaBroker(self, name="primary") + primary.promote() + backup = HaBroker(self, name="backup", broker_url=primary.host_port()) + s = primary.connect().session().sender("lvq; {create:always, node:{x-declare:{arguments:{'qpid.last_value_queue_key':lvq-key, 'qpid.replicate':messages}}}}") + def send(key,value): s.send(Message(content=value,properties={"lvq-key":key})) + for kv in [("a","a-1"),("b","b-1"),("a","a-2"),("a","a-3"),("c","c-1"),("c","c-2")]: + send(*kv) + self.assert_browse_backup(backup, "lvq", ["b-1", "a-3", "c-2"]) + send("b","b-2") + self.assert_browse_backup(backup, "lvq", ["a-3", "c-2", "b-2"]) + send("c","c-3") + self.assert_browse_backup(backup, "lvq", ["a-3", "b-2", "c-3"]) + send("d","d-1") + self.assert_browse_backup(backup, "lvq", ["a-3", "b-2", "c-3", "d-1"]) + + def test_ring(self): + primary = HaBroker(self, name="primary") + primary.promote() + backup = HaBroker(self, name="backup", broker_url=primary.host_port()) + s = primary.connect().session().sender("q; {create:always, node:{x-declare:{arguments:{'qpid.policy_type':ring, 'qpid.max_count':5, 'qpid.replicate':messages}}}}") + for i in range(10): s.send(Message(str(i))) + self.assert_browse_backup(backup, "q", [str(i) for i in range(5,10)]) + + def test_reject(self): + primary = HaBroker(self, name="primary") + primary.promote() + backup = HaBroker(self, name="backup", broker_url=primary.host_port()) + s = primary.connect().session().sender("q; {create:always, node:{x-declare:{arguments:{'qpid.policy_type':reject, 'qpid.max_count':5, 'qpid.replicate':messages}}}}") + try: + for i in range(10): s.send(Message(str(i)), sync=False) + except qpid.messaging.exceptions.TargetCapacityExceeded: pass + self.assert_browse_backup(backup, "q", [str(i) for i in range(0,5)]) + + def test_priority(self): + """Verify priority queues replicate correctly""" + primary = HaBroker(self, name="primary") + primary.promote() + backup = HaBroker(self, name="backup", broker_url=primary.host_port()) + session = primary.connect().session() + s = session.sender("priority-queue; {create:always, node:{x-declare:{arguments:{'qpid.priorities':10, 'qpid.replicate':messages}}}}") + priorities = [8,9,5,1,2,2,3,4,9,7,8,9,9,2] + for p in priorities: s.send(Message(priority=p)) + # Can't use browse_backup as browser sees messages in delivery order not priority. + self.wait_backup(backup, "priority-queue") + r = self.connect_admin(backup).session().receiver("priority-queue") + received = [r.fetch().priority for i in priorities] + self.assertEqual(sorted(priorities, reverse=True), received) + + def test_priority_fairshare(self): + """Verify priority queues replicate correctly""" + primary = HaBroker(self, name="primary") + primary.promote() + backup = HaBroker(self, name="backup", broker_url=primary.host_port()) + session = primary.connect().session() + levels = 8 + priorities = [4,5,3,7,8,8,2,8,2,8,8,16,6,6,6,6,6,6,8,3,5,8,3,5,5,3,3,8,8,3,7,3,7,7,7,8,8,8,2,3] + limits={7:0,6:4,5:3,4:2,3:2,2:2,1:2} + limit_policy = ",".join(["'qpid.fairshare':5"] + ["'qpid.fairshare-%s':%s"%(i[0],i[1]) for i in limits.iteritems()]) + s = session.sender("priority-queue; {create:always, node:{x-declare:{arguments:{'qpid.priorities':%s, %s, 'qpid.replicate':messages}}}}"%(levels,limit_policy)) + messages = [Message(content=str(uuid4()), priority = p) for p in priorities] + for m in messages: s.send(m) + self.wait_backup(backup, s.target) + r = self.connect_admin(backup).session().receiver("priority-queue") + received = [r.fetch().content for i in priorities] + sort = sorted(messages, key=lambda m: priority_level(m.priority, levels), reverse=True) + fair = [m.content for m in fairshare(sort, lambda l: limits.get(l,0), levels)] + self.assertEqual(received, fair) + + def test_priority_ring(self): + primary = HaBroker(self, name="primary") + primary.promote() + backup = HaBroker(self, name="backup", broker_url=primary.host_port()) + s = primary.connect().session().sender("q; {create:always, node:{x-declare:{arguments:{'qpid.policy_type':ring, 'qpid.max_count':5, 'qpid.priorities':10, 'qpid.replicate':messages}}}}") + priorities = [8,9,5,1,2,2,3,4,9,7,8,9,9,2] + for p in priorities: s.send(Message(priority=p)) + # FIXME aconway 2012-02-22: there is a bug in priority ring queues that allows a low + # priority message to displace a high one. The following commented-out assert_browse + # is for the correct result, the uncommented one is for the actualy buggy result. + # See https://issues.apache.org/jira/browse/QPID-3866 + # + # self.assert_browse_backup(backup, "q", sorted(priorities,reverse=True)[0:5], transform=lambda m: m.priority) + self.assert_browse_backup(backup, "q", [9,9,9,9,2], transform=lambda m: m.priority) + +def fairshare(msgs, limit, levels): + """ + Generator to return prioritised messages in expected order for a given fairshare limit + """ + count = 0 + last_priority = None + postponed = [] + while msgs or postponed: + if not msgs: + msgs = postponed + count = 0 + last_priority = None + postponed = [] + msg = msgs.pop(0) + if last_priority and priority_level(msg.priority, levels) == last_priority: + count += 1 + else: + last_priority = priority_level(msg.priority, levels) + count = 1 + l = limit(last_priority) + if (l and count > l): + postponed.append(msg) + else: + yield msg + return + +def priority_level(value, levels): + """ + Method to determine which of a distinct number of priority levels + a given value falls into. + """ + offset = 5-math.ceil(levels/2.0) + return min(max(value - offset, 0), levels-1) + class LongTests(BrokerTest): """Tests that can run for a long time if -DDURATION=<minutes> is set""" @@ -311,7 +434,7 @@ class LongTests(BrokerTest): """Test failover with continuous send-receive""" # FIXME aconway 2012-02-03: fails due to dropped messages, # known issue: sending messages to new primary before - # backups are ready. + # backups are ready. Enable when fixed. # Start a cluster, all members will be killed during the test. brokers = [ HaBroker(self, name=name, expect=EXPECT_EXIT_FAIL) @@ -352,4 +475,10 @@ class LongTests(BrokerTest): if __name__ == "__main__": shutil.rmtree("brokertest.tmp", True) - os.execvp("qpid-python-test", ["qpid-python-test", "-m", "ha_tests"] + sys.argv[1:]) + qpid_ha = os.getenv("QPID_HA_EXEC") + if qpid_ha and os.path.exists(qpid_ha): + os.execvp("qpid-python-test", + ["qpid-python-test", "-m", "ha_tests"] + sys.argv[1:]) + else: + print "Skipping ha_tests, qpid_ha not available" + diff --git a/cpp/src/tests/ipv6_test b/cpp/src/tests/ipv6_test index d75d50fd0a..8fa272d514 100755 --- a/cpp/src/tests/ipv6_test +++ b/cpp/src/tests/ipv6_test @@ -93,10 +93,10 @@ else BROKER1="[::1]:${PORTS[1]}" TEST_QUEUE=ipv6-fed-test - $QPID_CONFIG_EXEC -a $BROKER0 add queue $TEST_QUEUE - $QPID_CONFIG_EXEC -a $BROKER1 add queue $TEST_QUEUE + $QPID_CONFIG_EXEC -b $BROKER0 add queue $TEST_QUEUE + $QPID_CONFIG_EXEC -b $BROKER1 add queue $TEST_QUEUE $QPID_ROUTE_EXEC dynamic add $BROKER1 $BROKER0 amq.direct - $QPID_CONFIG_EXEC -a $BROKER1 bind amq.direct $TEST_QUEUE $TEST_QUEUE + $QPID_CONFIG_EXEC -b $BROKER1 bind amq.direct $TEST_QUEUE $TEST_QUEUE $QPID_ROUTE_EXEC route map $BROKER1 ./datagen --count 100 | tee rdata-in | diff --git a/cpp/src/tests/python_tests.ps1 b/cpp/src/tests/python_tests.ps1 index 9f8b9890c4..f7caa8f75a 100644 --- a/cpp/src/tests/python_tests.ps1 +++ b/cpp/src/tests/python_tests.ps1 @@ -26,8 +26,7 @@ if (!(Test-Path $PYTHON_DIR -pathType Container)) { exit 1 } -$PYTHON_TEST_DIR = "$srcdir\..\..\..\tests\src\py" -$QMF_LIB = "$srcdir\..\..\..\extras\qmf\src\py" +. .\test_env.ps1 if (Test-Path env:FAILING) { $fails = "-I $env:FAILING" @@ -39,7 +38,5 @@ else { $tests = "$args" } -#cd $PYTHON_DIR -$env:PYTHONPATH="$PYTHON_DIR;$PYTHON_TEST_DIR;$env:PYTHONPATH;$QMF_LIB" python $PYTHON_DIR/qpid-python-test -m qpid_tests.broker_0_10 -m qpid.tests -b localhost:$env:QPID_PORT $fails $tests exit $LASTEXITCODE diff --git a/cpp/src/tests/queue_flow_limit_tests.py b/cpp/src/tests/queue_flow_limit_tests.py index dec7cfb3af..d51b26a821 100644 --- a/cpp/src/tests/queue_flow_limit_tests.py +++ b/cpp/src/tests/queue_flow_limit_tests.py @@ -117,7 +117,7 @@ class QueueFlowLimitTests(TestBase010): tool = environ.get("QPID_CONFIG_EXEC") if tool: command = tool + \ - " --broker-addr=%s:%s " % (self.broker.host, self.broker.port) \ + " --broker=%s:%s " % (self.broker.host, self.broker.port) \ + "add queue test01 --flow-stop-count=999" \ + " --flow-resume-count=55 --flow-stop-size=5000000" \ + " --flow-resume-size=100000" diff --git a/cpp/src/tests/reliable_replication_test b/cpp/src/tests/reliable_replication_test index 1f1dac5f2d..c660f751e5 100755 --- a/cpp/src/tests/reliable_replication_test +++ b/cpp/src/tests/reliable_replication_test @@ -47,12 +47,12 @@ setup() { echo "Testing replication from port $BROKER_A to port $BROKER_B" - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add exchange replication replication $PYTHON_COMMANDS/qpid-route --ack 500 queue add "localhost:$BROKER_B" "localhost:$BROKER_A" replication replication #create test queue (only replicate enqueues for this test): - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-a --generate-queue-events 1 - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-a + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-a --generate-queue-events 1 + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-a } send() { diff --git a/cpp/src/tests/replication_test b/cpp/src/tests/replication_test index 8c37568875..f8b2136396 100755 --- a/cpp/src/tests/replication_test +++ b/cpp/src/tests/replication_test @@ -46,21 +46,21 @@ if test -d ${PYTHON_DIR} && test -f "$REPLICATING_LISTENER_LIB" && test -f "$REP BROKER_B=`cat qpidd.port` echo "Running replication test between localhost:$BROKER_A and localhost:$BROKER_B" - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add exchange replication replication $PYTHON_COMMANDS/qpid-route --ack 5 queue add "localhost:$BROKER_B" "localhost:$BROKER_A" replication replication #create test queues - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-a --generate-queue-events 2 - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-b --generate-queue-events 2 - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-c --generate-queue-events 1 - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-d --generate-queue-events 2 - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-e --generate-queue-events 1 + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-a --generate-queue-events 2 + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-b --generate-queue-events 2 + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-c --generate-queue-events 1 + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-d --generate-queue-events 2 + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-e --generate-queue-events 1 - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-a - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-b - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-c - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-e + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-a + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-b + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-c + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-e #queue-d deliberately not declared on DR; this error case should be handled #publish and consume from test queues on broker A: @@ -124,13 +124,13 @@ if test -d ${PYTHON_DIR} && test -f "$REPLICATING_LISTENER_LIB" && test -f "$REP $QPIDD_EXEC --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $REPLICATION_EXCHANGE_LIB --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd.port BROKER_B=`cat qpidd.port` - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add exchange replication replication $PYTHON_COMMANDS/qpid-route --ack 5 queue add "localhost:$BROKER_B" "localhost:$BROKER_A" replication replication - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-e --generate-queue-events 2 - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-e - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-d --generate-queue-events 1 - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-d + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-e --generate-queue-events 2 + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-e + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-d --generate-queue-events 1 + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-d i=1 while [ $i -le 10 ]; do @@ -152,8 +152,8 @@ if test -d ${PYTHON_DIR} && test -f "$REPLICATING_LISTENER_LIB" && test -f "$REP $QPIDD_EXEC --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $REPLICATION_EXCHANGE_LIB --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd.port BROKER_B=`cat qpidd.port` - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-e - $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-e + $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add exchange replication replication $PYTHON_COMMANDS/qpid-route --ack 5 queue add "localhost:$BROKER_B" "localhost:$BROKER_A" replication replication # now send another 15 i=11 diff --git a/cpp/src/tests/ring_queue_test b/cpp/src/tests/ring_queue_test index 553746eb49..271b46183e 100755 --- a/cpp/src/tests/ring_queue_test +++ b/cpp/src/tests/ring_queue_test @@ -28,7 +28,7 @@ MESSAGES=10000 SENDERS=1 RECEIVERS=1 CONCURRENT=0 -BROKER_URL="-a ${QPID_BROKER:-localhost}:${QPID_PORT:-5672}" +BROKER_URL="-b ${QPID_BROKER:-localhost}:${QPID_PORT:-5672}" setup() { if [[ $DURABLE -gt 0 ]]; then diff --git a/cpp/src/tests/run_acl_tests.ps1 b/cpp/src/tests/run_acl_tests.ps1 index 46e070477f..8279d87e54 100644 --- a/cpp/src/tests/run_acl_tests.ps1 +++ b/cpp/src/tests/run_acl_tests.ps1 @@ -20,15 +20,12 @@ # Run the acl tests. $srcdir = Split-Path $myInvocation.InvocationName -$PYTHON_DIR = "$srcdir\..\..\..\python" +. .\test_env.ps1 if (!(Test-Path $PYTHON_DIR -pathType Container)) { "Skipping acl tests as python libs not found" exit 1 } -$PYTHON_TEST_DIR = "$srcdir\..\..\..\tests\src\py" -$QMF_LIB = "$srcdir\..\..\..\extras\qmf\src\py" -$env:PYTHONPATH="$PYTHON_DIR;$srcdir;$PYTHON_TEST_DIR;$QMF_LIB" $Global:BROKER_EXE = "" Function start_broker($acl_options) diff --git a/cpp/src/tests/run_federation_tests.ps1 b/cpp/src/tests/run_federation_tests.ps1 index 35353a870f..803b3eef6f 100644 --- a/cpp/src/tests/run_federation_tests.ps1 +++ b/cpp/src/tests/run_federation_tests.ps1 @@ -26,8 +26,7 @@ if (!(Test-Path $PYTHON_DIR -pathType Container)) { exit 1 } -$PYTHON_TEST_DIR = "$srcdir\..\..\..\tests\src\py" -$QMF_LIB = "$srcdir\..\..\..\extras\qmf\src\py" +. .\test_env.ps1 # Test runs from the tests directory but the broker executable is one level # up, and most likely in a subdirectory from there based on what build type. diff --git a/cpp/src/tests/run_header_test.ps1 b/cpp/src/tests/run_header_test.ps1 index 7d3e43a30f..344fac9cf9 100644 --- a/cpp/src/tests/run_header_test.ps1 +++ b/cpp/src/tests/run_header_test.ps1 @@ -28,6 +28,8 @@ if (!(Test-Path $PYTHON_DIR -pathType Container)) { exit 0 } +. .\test_env.ps1 + if (Test-Path qpidd.port) { set-item -path env:QPID_PORT -value (get-content -path qpidd.port -totalcount 1) } @@ -42,6 +44,5 @@ if (!(Test-Path $prog)) { } Invoke-Expression "$prog -p $env:QPID_PORT" | Write-Output -$env:PYTHONPATH="$PYTHON_DIR;$env:PYTHONPATH" Invoke-Expression "python $srcdir/header_test.py localhost $env:QPID_PORT" | Write-Output exit $LASTEXITCODE diff --git a/cpp/src/tests/run_msg_group_tests b/cpp/src/tests/run_msg_group_tests index 5a6da546f3..4e82759866 100755 --- a/cpp/src/tests/run_msg_group_tests +++ b/cpp/src/tests/run_msg_group_tests @@ -44,19 +44,19 @@ run_test() { declare -i i=0 declare -a tests -tests=("qpid-config -a $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups" +tests=("qpid-config -b $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups" "msg_group_test -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" "msg_group_test -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" - "qpid-config -a $BROKER_URL add queue ${QUEUE_NAME}-two --group-header=${GROUP_KEY} --shared-groups" + "qpid-config -b $BROKER_URL add queue ${QUEUE_NAME}-two --group-header=${GROUP_KEY} --shared-groups" "msg_group_test -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" "msg_group_test -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" "msg_group_test -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" - "qpid-config -a $BROKER_URL del queue ${QUEUE_NAME}-two --force" + "qpid-config -b $BROKER_URL del queue ${QUEUE_NAME}-two --force" "msg_group_test -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" "msg_group_test -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" "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10000 --group-size 1 --receivers 0 --senders 1" "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10000 --receivers 5 --senders 0" - "qpid-config -a $BROKER_URL del queue $QUEUE_NAME --force") + "qpid-config -b $BROKER_URL del queue $QUEUE_NAME --force") while [ -n "${tests[i]}" ]; do run_test ${tests[i]} diff --git a/cpp/src/tests/run_msg_group_tests_soak b/cpp/src/tests/run_msg_group_tests_soak index 44995423cc..2ebbaf4efd 100755 --- a/cpp/src/tests/run_msg_group_tests_soak +++ b/cpp/src/tests/run_msg_group_tests_soak @@ -44,13 +44,13 @@ run_test() { declare -i i=0 declare -a tests -tests=("qpid-config -a $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups" +tests=("qpid-config -b $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups" "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10007 --receivers 3 --senders 5 --group-size 211 --randomize-group-size --capacity 47 --ack-frequency 97" "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10007 --receivers 3 --senders 5 --group-size 211 --randomize-group-size --capacity 79 --ack-frequency 79" "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10007 --receivers 3 --senders 5 --group-size 211 --randomize-group-size --capacity 97 --ack-frequency 47" "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 40000 --receivers 0 --senders 5 --group-size 13 --randomize-group-size" "msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 200000 --receivers 3 --senders 0 --capacity 23 --ack-frequency 7" - "qpid-config -a $BROKER_URL del queue $QUEUE_NAME --force") + "qpid-config -b $BROKER_URL del queue $QUEUE_NAME --force") while [ -n "${tests[i]}" ]; do run_test ${tests[i]} diff --git a/cpp/src/tests/run_store_tests.ps1 b/cpp/src/tests/run_store_tests.ps1 index b2f0b1ccd8..0683892393 100644 --- a/cpp/src/tests/run_store_tests.ps1 +++ b/cpp/src/tests/run_store_tests.ps1 @@ -30,14 +30,14 @@ if ($test_store -ne "MSSQL" -and $test_store -ne "MSSQL-CLFS") { } $srcdir = Split-Path $myInvocation.InvocationName -$PYTHON_DIR = "$srcdir\..\..\..\python" + +. .\test_env.ps1 + if (!(Test-Path $PYTHON_DIR -pathType Container)) { "Skipping store tests as python libs not found" exit 1 } -$QMF_LIB = "$srcdir\..\..\..\extras\qmf\src\py" - # Test runs from the tests directory but the broker executable is one level # up, and most likely in a subdirectory from there based on what build type. # Look around for it before trying to start it. @@ -97,7 +97,7 @@ set-item -path env:QPID_PORT -value (get-content -path qpidd-store.port -totalco Remove-Item qpidd-store.port $PYTHON_TEST_DIR = "$srcdir\..\..\..\tests\src\py\qpid_tests\broker_0_10" -$env:PYTHONPATH="$PYTHON_DIR;$PYTHON_TEST_DIR;$env:PYTHONPATH;$QMF_LIB" +$env:PYTHONPATH="$PYTHON_TEST_DIR;$srcdir;$env:PYTHONPATH" python $PYTHON_DIR/qpid-python-test -m dtx -m persistence -b localhost:$env:QPID_PORT $fails $tests $RETCODE=$LASTEXITCODE if ($RETCODE -ne 0) { @@ -111,7 +111,6 @@ Invoke-Expression "$prog --quit --port $env:QPID_PORT" | Write-Output # Test 2... store.py starts/stops/restarts its own brokers $tests = "*" -$env:PYTHONPATH="$PYTHON_DIR;$QMF_LIB;$srcdir" $env:QPIDD_EXEC="$prog" $env:STORE_LIB="$store_dir\store$suffix.dll" if ($test_store -eq "MSSQL") { diff --git a/cpp/src/tests/run_test.ps1 b/cpp/src/tests/run_test.ps1 index ca990bc057..872e1dddb1 100644 --- a/cpp/src/tests/run_test.ps1 +++ b/cpp/src/tests/run_test.ps1 @@ -20,8 +20,7 @@ $srcdir = Split-Path $myInvocation.InvocationName # Set up environment and run a test executable or script. -$env:QPID_DATA_DIR = "" -$env:BOOST_TEST_SHOW_PROGRESS = "yes" +. .\test_env.ps1 # The test exe is probably not in the current binary dir - it's usually # placed in a subdirectory based on the configuration built in Visual Studio. @@ -30,7 +29,7 @@ $env:BOOST_TEST_SHOW_PROGRESS = "yes" # one level up. $prog = $args[0] $is_script = $prog -match ".ps1$" -if (!$is_script) { +if (!$is_script -and !(Test-Path "$prog")) { . $srcdir\find_prog.ps1 $prog $args[0] = $prog $env:QPID_LIB_DIR = "..\$sub" diff --git a/cpp/src/tests/sasl_fed b/cpp/src/tests/sasl_fed index 884c44177c..9dc2dd46e2 100755 --- a/cpp/src/tests/sasl_fed +++ b/cpp/src/tests/sasl_fed @@ -90,23 +90,23 @@ EXCHANGE_NAME=sasl_fedex #-------------------------------------------------- #echo " add exchanges" #-------------------------------------------------- -$QPID_CONFIG_EXEC -a localhost:$broker_1_port add exchange direct $EXCHANGE_NAME -$QPID_CONFIG_EXEC -a localhost:$broker_2_port add exchange direct $EXCHANGE_NAME +$QPID_CONFIG_EXEC -b localhost:$broker_1_port add exchange direct $EXCHANGE_NAME +$QPID_CONFIG_EXEC -b localhost:$broker_2_port add exchange direct $EXCHANGE_NAME #-------------------------------------------------- #echo " add queues" #-------------------------------------------------- -$QPID_CONFIG_EXEC -a localhost:$broker_1_port add queue $QUEUE_NAME -$QPID_CONFIG_EXEC -a localhost:$broker_2_port add queue $QUEUE_NAME +$QPID_CONFIG_EXEC -b localhost:$broker_1_port add queue $QUEUE_NAME +$QPID_CONFIG_EXEC -b localhost:$broker_2_port add queue $QUEUE_NAME sleep 5 #-------------------------------------------------- #echo " create bindings" #-------------------------------------------------- -$QPID_CONFIG_EXEC -a localhost:$broker_1_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY -$QPID_CONFIG_EXEC -a localhost:$broker_2_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY +$QPID_CONFIG_EXEC -b localhost:$broker_1_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY +$QPID_CONFIG_EXEC -b localhost:$broker_2_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY sleep 5 @@ -130,13 +130,13 @@ sleep 5 #-------------------------------------------------- #echo " Examine Broker $broker_1_port" #-------------------------------------------------- -broker_1_message_count=`$PYTHON_COMMANDS/qpid-stat -q localhost:$broker_1_port | grep sasl_fed_queue | awk '{print $2}'` +broker_1_message_count=`$PYTHON_COMMANDS/qpid-stat -q -b localhost:$broker_1_port | grep sasl_fed_queue | awk '{print $2}'` #echo " " #-------------------------------------------------- #echo " Examine Broker $broker_2_port" #-------------------------------------------------- -broker_2_message_count=`$PYTHON_COMMANDS/qpid-stat -q localhost:$broker_2_port | grep sasl_fed_queue | awk '{print $2}'` +broker_2_message_count=`$PYTHON_COMMANDS/qpid-stat -q -b localhost:$broker_2_port | grep sasl_fed_queue | awk '{print $2}'` #echo " " #-------------------------------------------------- diff --git a/cpp/src/tests/sasl_fed_ex b/cpp/src/tests/sasl_fed_ex index 716a806874..cc5b310067 100755 --- a/cpp/src/tests/sasl_fed_ex +++ b/cpp/src/tests/sasl_fed_ex @@ -280,18 +280,18 @@ EXCHANGE_NAME=sasl_fedex print "add exchanges" -$QPID_CONFIG_EXEC -a localhost:${SRC_TCP_PORT} add exchange direct $EXCHANGE_NAME -$QPID_CONFIG_EXEC -a localhost:${DST_TCP_PORT} add exchange direct $EXCHANGE_NAME +$QPID_CONFIG_EXEC -b localhost:${SRC_TCP_PORT} add exchange direct $EXCHANGE_NAME +$QPID_CONFIG_EXEC -b localhost:${DST_TCP_PORT} add exchange direct $EXCHANGE_NAME print "add queues" -$QPID_CONFIG_EXEC -a localhost:${SRC_TCP_PORT} add queue $QUEUE_NAME -$QPID_CONFIG_EXEC -a localhost:${DST_TCP_PORT} add queue $QUEUE_NAME +$QPID_CONFIG_EXEC -b localhost:${SRC_TCP_PORT} add queue $QUEUE_NAME +$QPID_CONFIG_EXEC -b localhost:${DST_TCP_PORT} add queue $QUEUE_NAME print "create bindings" -$QPID_CONFIG_EXEC -a localhost:${SRC_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY -$QPID_CONFIG_EXEC -a localhost:${DST_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY +$QPID_CONFIG_EXEC -b localhost:${SRC_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY +$QPID_CONFIG_EXEC -b localhost:${DST_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY # diff --git a/cpp/src/tests/test_env.sh.in b/cpp/src/tests/test_env.sh.in index 0cd658bd80..5c07bcdc2e 100644 --- a/cpp/src/tests/test_env.sh.in +++ b/cpp/src/tests/test_env.sh.in @@ -44,6 +44,7 @@ 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_CLUSTER_EXEC=$PYTHON_COMMANDS/qpid-cluster +export QPID_HA_EXEC=$PYTHON_COMMANDS/qpid-ha # Executables export QPIDD_EXEC=$top_builddir/src/qpidd diff --git a/cpp/src/tests/testlib.py b/cpp/src/tests/testlib.py index fe57a84a81..71ad59e5c1 100644 --- a/cpp/src/tests/testlib.py +++ b/cpp/src/tests/testlib.py @@ -348,8 +348,8 @@ class TestBaseCluster(TestBase): def _qpidConfig(self, nodeNumber, clusterName, action): """Configure some aspect of a qpid broker using the qpid_config executable""" port = self.getNodeTuple(nodeNumber, clusterName)[self.PORT] - #print "%s -a localhost:%d %s" % (self._qpidConfigExec, port, action) - ret = os.spawnl(os.P_WAIT, self._qpidConfigExec, self._qpidConfigExec, "-a", "localhost:%d" % port, *action.split()) + #print "%s -b localhost:%d %s" % (self._qpidConfigExec, port, action) + ret = os.spawnl(os.P_WAIT, self._qpidConfigExec, self._qpidConfigExec, "-b", "localhost:%d" % port, *action.split()) if ret != 0: raise Exception("_qpidConfig(): cluster=\"%s\" nodeNumber=%d port=%d action=\"%s\" returned %d" % \ (clusterName, nodeNumber, port, action, ret)) |
