[3/5] qpid-proton git commit: PROTON-1592: [python] tx_recv.py raises exception.
PROTON-1592: [python] tx_recv.py raises exception. Fixed the example: starting a transactional internally opens a sending link for transactional commands. The example was coded on the assumption that the only link being opened was its own receiver link, which is incorrect. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/198664fc Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/198664fc Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/198664fc Branch: refs/heads/master Commit: 198664fc8e0273d4eab9f6d6f73df20114080a8c Parents: 1bb1897 Author: Alan ConwayAuthored: Tue Oct 10 13:07:20 2017 -0400 Committer: Alan Conway Committed: Wed Oct 11 22:04:42 2017 -0400 -- examples/python/tx_recv.py | 6 ++ 1 file changed, 6 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/198664fc/examples/python/tx_recv.py -- diff --git a/examples/python/tx_recv.py b/examples/python/tx_recv.py index 4baddcf..7c0b7cc 100755 --- a/examples/python/tx_recv.py +++ b/examples/python/tx_recv.py @@ -40,6 +40,12 @@ class TxRecv(MessagingHandler, TransactionHandler): self.container.declare_transaction(self.conn, handler=self) self.transaction = None +def on_link_opened(self, event): +# NOTE: a transactional client opens an internal sender link for transaction commands, +# which we want to ignore. +if event.receiver: +event.receiver.drain_mode = True + def on_message(self, event): print(event.message.body) self.transaction.accept(event.delivery) - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[4/5] qpid-proton git commit: PROTON-1517: C++ consistent linkage for listen_handler
PROTON-1517: C++ consistent linkage for listen_handler Make it all non-inline, consistent with message_handler. Fixes ASAN runtime warnings caused by duplicate vtables. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1d2d7919 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1d2d7919 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1d2d7919 Branch: refs/heads/master Commit: 1d2d791921bea582b27778bf0b5ebb1853c7e95a Parents: 31d5ba0 Author: Alan ConwayAuthored: Tue Oct 10 18:42:01 2017 -0400 Committer: Alan Conway Committed: Wed Oct 11 22:04:42 2017 -0400 -- .../bindings/cpp/include/proton/listen_handler.hpp| 14 -- .../bindings/cpp/include/proton/messaging_handler.hpp | 2 +- proton-c/bindings/cpp/src/listener.cpp| 9 - 3 files changed, 17 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1d2d7919/proton-c/bindings/cpp/include/proton/listen_handler.hpp -- diff --git a/proton-c/bindings/cpp/include/proton/listen_handler.hpp b/proton-c/bindings/cpp/include/proton/listen_handler.hpp index 3e18475..d19be3f 100644 --- a/proton-c/bindings/cpp/include/proton/listen_handler.hpp +++ b/proton-c/bindings/cpp/include/proton/listen_handler.hpp @@ -23,6 +23,8 @@ */ #include "./fwd.hpp" +#include "./internal/export.hpp" +#include /// @file /// @copybrief proton::listen_handler @@ -34,12 +36,12 @@ namespace proton { /// /// Implement this interface and pass to proton::container::listen() /// to be notified of new connections. -class listen_handler { +class PN_CPP_CLASS_EXTERN listen_handler { public: -virtual ~listen_handler() {} +PN_CPP_EXTERN virtual ~listen_handler(); /// Called when the listener is opened successfully. -virtual void on_open(listener&) {} +PN_CPP_EXTERN virtual void on_open(listener&); /// Called for each accepted connection. /// @@ -47,14 +49,14 @@ class listen_handler { /// the connection. messaging_handler::on_connection_open() will be called with /// the proton::connection, it can call connection::open() to accept or /// connection::close() to reject the connection. -virtual connection_options on_accept(listener&)= 0; +PN_CPP_EXTERN virtual connection_options on_accept(listener&)= 0; /// Called if there is a listening error, with an error message. /// close() will also be called. -virtual void on_error(listener&, const std::string&) {} +PN_CPP_EXTERN virtual void on_error(listener&, const std::string&); /// Called when this listen_handler is no longer needed, and can be deleted. -virtual void on_close(listener&) {} +PN_CPP_EXTERN virtual void on_close(listener&); }; } // proton http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1d2d7919/proton-c/bindings/cpp/include/proton/messaging_handler.hpp -- diff --git a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp index e777d7d..938d3ff 100644 --- a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp +++ b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp @@ -80,7 +80,7 @@ PN_CPP_CLASS_EXTERN messaging_handler { /// The underlying network transport is open PN_CPP_EXTERN virtual void on_transport_open(transport ); - + /// The underlying network transport has closed. PN_CPP_EXTERN virtual void on_transport_close(transport ); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1d2d7919/proton-c/bindings/cpp/src/listener.cpp -- diff --git a/proton-c/bindings/cpp/src/listener.cpp b/proton-c/bindings/cpp/src/listener.cpp index 2e38076..646cfe1 100644 --- a/proton-c/bindings/cpp/src/listener.cpp +++ b/proton-c/bindings/cpp/src/listener.cpp @@ -17,7 +17,9 @@ * under the License. */ +#include "proton/connection_options.hpp" #include "proton/listener.hpp" +#include "proton/listen_handler.hpp" #include @@ -32,7 +34,12 @@ listener::listener(const listener& l) : listener_(l.listener_) {} listener::~listener() {} listener& listener::operator=(const listener& l) { listener_ = l.listener_; return *this; } -// FIXME aconway 2017-10-06: should be a no-op if already closed +// FIXME aconway 2017-10-06: should be a no-op if already closed - there is a race here. void listener::stop() { if (listener_) pn_listener_close(listener_); } +listen_handler::~listen_handler() {} +void listen_handler::on_open(listener&) {} +connection_options
[2/5] qpid-proton git commit: PROTON-1618: c++ container: unambiguous listen success/fail indicator
PROTON-1618: c++ container: unambiguous listen success/fail indicator Added listener_handler::on_open() to indicate a successful listen. After a call to container::listen(): - on success, call listener_handler::on_open() before any call to listener_handler::on_accept() - on failure, call listener_handler::on_error() followed by listener_handler::on_close() An application can tell from the first event received (on_open() vs. on_close()) if the listen call succeeded or failed. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/31d5ba09 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/31d5ba09 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/31d5ba09 Branch: refs/heads/master Commit: 31d5ba096aa850e49b0f2475a3c1ef9f171f9a3c Parents: d0b641b Author: Alan ConwayAuthored: Tue Oct 10 16:24:28 2017 -0400 Committer: Alan Conway Committed: Wed Oct 11 22:04:42 2017 -0400 -- .../bindings/cpp/include/proton/container.hpp | 12 ++- .../cpp/include/proton/listen_handler.hpp | 3 + proton-c/bindings/cpp/src/container_test.cpp| 89 .../cpp/src/proactor_container_impl.cpp | 10 ++- 4 files changed, 74 insertions(+), 40 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31d5ba09/proton-c/bindings/cpp/include/proton/container.hpp -- diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp index d30e45a..fe3857d 100644 --- a/proton-c/bindings/cpp/include/proton/container.hpp +++ b/proton-c/bindings/cpp/include/proton/container.hpp @@ -120,12 +120,16 @@ class PN_CPP_CLASS_EXTERN container { /// Listen for new connections on `listen_url`. /// -/// listen_handler::on_accept is called for each incoming connection to determine +/// If the listener opens successfully, listen_handler::on_open() is called. +/// If it fails to open, listen_handler::on_error() then listen_handler::close() +/// are called. +/// +/// listen_handler::on_accept() is called for each incoming connection to determine /// the @ref connection_options to use, including the @ref messaging_handler. /// -/// **Thread safety** - Calls to `listen_handler` methods -/// are serialized for this listener, but handlers attached to -/// separate listeners can be safely called concurrently. +/// **Thread safety** - Calls to `listen_handler` methods are serialized for +/// this listener, but handlers attached to separate listeners may be called +/// concurrently. PN_CPP_EXTERN listener listen(const std::string& listen_url, listen_handler& handler); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31d5ba09/proton-c/bindings/cpp/include/proton/listen_handler.hpp -- diff --git a/proton-c/bindings/cpp/include/proton/listen_handler.hpp b/proton-c/bindings/cpp/include/proton/listen_handler.hpp index 4ce20e9..3e18475 100644 --- a/proton-c/bindings/cpp/include/proton/listen_handler.hpp +++ b/proton-c/bindings/cpp/include/proton/listen_handler.hpp @@ -38,6 +38,9 @@ class listen_handler { public: virtual ~listen_handler() {} +/// Called when the listener is opened successfully. +virtual void on_open(listener&) {} + /// Called for each accepted connection. /// /// Returns connection_options to apply, including a proton::messaging_handler for http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31d5ba09/proton-c/bindings/cpp/src/container_test.cpp -- diff --git a/proton-c/bindings/cpp/src/container_test.cpp b/proton-c/bindings/cpp/src/container_test.cpp index c2b1609..3b0c86f 100644 --- a/proton-c/bindings/cpp/src/container_test.cpp +++ b/proton-c/bindings/cpp/src/container_test.cpp @@ -35,20 +35,21 @@ namespace { -static std::string int2string(int n) { -std::ostringstream strm; -strm << n; -return strm.str(); +static std::string make_url(const std::string host, int port) { +std::ostringstream url; +url << "amqp://" << host << ":" << port; +return url.str(); } -int listen_on_random_port(proton::container& c, proton::listener& l) { -int port; +int listen_on_random_port(proton::container& c, proton::listener& l, proton::listen_handler* lh=0) { +int port = 0; // I'm going to hell for this: std::srand((unsigned int)time(0)); while (true) { port = 2 + (std::rand() % 3); +std::string url = make_url("", port); try { -
[5/5] qpid-proton git commit: PROTON-1618: c proactor: unambiguous listen success/fail indicator
PROTON-1618: c proactor: unambiguous listen success/fail indicator Changed the use of events in all 3 proactor implementations as follows: After a call to pn_proactor_listen(): - on success, dispatch PN_LISTENER_OPEN before any PN_PROACTOR_ACCEPT - on failure, set the pn_listener_condition() and dispatch PN_LISTENER_CLOSE An application can tell from the first event received (OPEN vs. CLOSE) if the OS listen call succeeded or failed. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d0b641b7 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d0b641b7 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d0b641b7 Branch: refs/heads/master Commit: d0b641b75eb235d9959bab2792c0264522396321 Parents: 198664f Author: Alan ConwayAuthored: Tue Oct 10 14:19:53 2017 -0400 Committer: Alan Conway Committed: Wed Oct 11 22:04:42 2017 -0400 -- proton-c/include/proton/proactor.h | 7 --- proton-c/src/proactor/epoll.c | 4 ++-- proton-c/src/proactor/libuv.c | 4 ++-- proton-c/src/proactor/win_iocp.c | 5 ++--- proton-c/src/tests/proactor.c | 3 --- 5 files changed, 10 insertions(+), 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d0b641b7/proton-c/include/proton/proactor.h -- diff --git a/proton-c/include/proton/proactor.h b/proton-c/include/proton/proactor.h index 414883a..52d3891 100644 --- a/proton-c/include/proton/proactor.h +++ b/proton-c/include/proton/proactor.h @@ -122,11 +122,12 @@ PNP_EXTERN void pn_proactor_connect(pn_proactor_t *proactor, pn_connection_t *co * Start listening for incoming connections. * * pn_proactor_wait() will return a @ref PN_LISTENER_OPEN event when the - * listener is ready to accept connections, or if the listen operation fails. - * If the listen operation failed, then pn_listener_condition() will be set. + * listener is ready to accept connections, or a PN_LISTENER_CLOSE if the listen + * operation fails. If the listen failed, pn_listener_condition() will be set. * * When the listener is closed by pn_listener_close(), or because of an error, a - * PN_LISTENER_CLOSE event will be returned and pn_listener_condition() will be set. + * PN_LISTENER_CLOSE event will be returned and pn_listener_condition() will be set + * for an error. * * @note Thread-safe * http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d0b641b7/proton-c/src/proactor/epoll.c -- diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c index d739ab1..3cec04c 100644 --- a/proton-c/src/proactor/epoll.c +++ b/proton-c/src/proactor/epoll.c @@ -1401,8 +1401,6 @@ void pn_proactor_listen(pn_proactor_t *p, pn_listener_t *l, const char *addr, in if (addrinfo) { freeaddrinfo(addrinfo); } - /* Always put an OPEN event for symmetry, even if we immediately close with err */ - pn_collector_put(l->collector, pn_listener__class(), l, PN_LISTENER_OPEN); bool notify = wake(>context); if (l->psockets_size == 0) { /* All failed, create dummy socket with an error */ @@ -1414,6 +1412,8 @@ void pn_proactor_listen(pn_proactor_t *p, pn_listener_t *l, const char *addr, in } else { psocket_error(l->psockets, errno, "listen on"); } + } else { +pn_collector_put(l->collector, pn_listener__class(), l, PN_LISTENER_OPEN); } proactor_add(>context); unlock(>context.mutex); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d0b641b7/proton-c/src/proactor/libuv.c -- diff --git a/proton-c/src/proactor/libuv.c b/proton-c/src/proactor/libuv.c index 5effbfe..4088b07 100644 --- a/proton-c/src/proactor/libuv.c +++ b/proton-c/src/proactor/libuv.c @@ -641,9 +641,9 @@ static void leader_listen_lh(pn_listener_t *l) { } if (err) { listener_error_lh(l, err, "listening on"); + } else { +pn_collector_put(l->collector, pn_listener__class(), l, PN_LISTENER_OPEN); } - /* Always put an OPEN event for symmetry, even if we have an error. */ - pn_collector_put(l->collector, pn_listener__class(), l, PN_LISTENER_OPEN); } void pn_listener_free(pn_listener_t *l) { http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d0b641b7/proton-c/src/proactor/win_iocp.c -- diff --git a/proton-c/src/proactor/win_iocp.c b/proton-c/src/proactor/win_iocp.c index 9a27ae6..09d39cf 100644 --- a/proton-c/src/proactor/win_iocp.c +++ b/proton-c/src/proactor/win_iocp.c @@ -2810,9 +2810,6 @@ void pn_proactor_listen(pn_proactor_t *p, pn_listener_t *l, const char *addr, in if
[1/5] qpid-proton git commit: PROTON-1618: c++ tests use test_port.h for listen ports
Repository: qpid-proton Updated Branches: refs/heads/master 1bb1897fe -> 485cdbd3f PROTON-1618: c++ tests use test_port.h for listen ports POSIX: Use bind(0) with SO_REUSEADDR and hold the socket to acquire a port that can safely be used for listen() Windows: Use bind(0) to pick a port, but close the socket immediately. In theory another process could steal the port between bind() and listen(), but in practice this seems to be very unlikely. The previous randomize-and-retry approach makes it hard to test the sequence of events for listen(), since the random retry may cause multiple listen errors even when it is finally successful. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/485cdbd3 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/485cdbd3 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/485cdbd3 Branch: refs/heads/master Commit: 485cdbd3f680772e081ca05fbda97c0f271c676e Parents: 1d2d791 Author: Alan ConwayAuthored: Wed Oct 11 09:47:33 2017 -0400 Committer: Alan Conway Committed: Wed Oct 11 22:04:42 2017 -0400 -- proton-c/bindings/cpp/src/container_test.cpp | 49 proton-c/src/tests/proactor.c| 96 +-- proton-c/src/tests/test_port.h | 138 ++ 3 files changed, 168 insertions(+), 115 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/485cdbd3/proton-c/bindings/cpp/src/container_test.cpp -- diff --git a/proton-c/bindings/cpp/src/container_test.cpp b/proton-c/bindings/cpp/src/container_test.cpp index 3b0c86f..c9657b9 100644 --- a/proton-c/bindings/cpp/src/container_test.cpp +++ b/proton-c/bindings/cpp/src/container_test.cpp @@ -19,6 +19,10 @@ #include "test_bits.hpp" +extern "C" { +#include "../../../../src/tests/test_port.h" +} + #include "proton/connection.hpp" #include "proton/connection_options.hpp" #include "proton/container.hpp" @@ -35,28 +39,23 @@ namespace { -static std::string make_url(const std::string host, int port) { +std::string make_url(const std::string& host, int port) { std::ostringstream url; url << "amqp://" << host << ":" << port; return url.str(); } -int listen_on_random_port(proton::container& c, proton::listener& l, proton::listen_handler* lh=0) { -int port = 0; -// I'm going to hell for this: -std::srand((unsigned int)time(0)); -while (true) { -port = 2 + (std::rand() % 3); -std::string url = make_url("", port); -try { -l = lh ? c.listen(url, *lh) : c.listen(url); -break; -} catch (...) { -// keep trying -} -} -return port; -} +// C++ Wrapper for C test port. +// Binds to a port with REUSEADDR set so that the port is protected from +// other processes and can safely be used for listening. +class listen_port { +::test_port_t tp; + public: +listen_port() { tp = ::test_port(""); } // NOTE: assign tp, don't initialize - Windows. +~listen_port() { ::test_port_close(); } +int port() const { return tp.port; } +std::string url(const std::string& host="") const { return make_url(host, tp.port); } +}; struct test_listen_handler : public proton::listen_handler { bool on_open_, on_accept_, on_close_; @@ -92,6 +91,7 @@ class test_handler : public proton::messaging_handler { std::string peer_vhost; std::string peer_container_id; +listen_port port; proton::listener listener; test_listen_handler listen_handler; @@ -100,8 +100,8 @@ class test_handler : public proton::messaging_handler { {} void on_container_start(proton::container ) PN_CPP_OVERRIDE { -int port = listen_on_random_port(c, listener, _handler); -proton::connection conn = c.connect(make_url(host, port), opts); +listener = c.listen(port.url(), listen_handler); +proton::connection conn = c.connect(port.url(host), opts); } void on_connection_open(proton::connection ) PN_CPP_OVERRIDE { @@ -183,13 +183,14 @@ int test_container_bad_address() { } class stop_tester : public proton::messaging_handler { +listen_port port; proton::listener listener; // Set up a listener which would block forever void on_container_start(proton::container& c) PN_CPP_OVERRIDE { ASSERT(state==0); -int port = listen_on_random_port(c, listener); -c.connect(make_url("", port)); +listener = c.listen(port.url()); +c.connect(port.url()); c.auto_stop(false); state = 1; } @@ -231,17 +232,17 @@ int test_container_stop() { struct hang_tester : public proton::messaging_handler {
qpid-proton git commit: PROTON-1556: work around for C++ binding ssl_domain self assignment bug
Repository: qpid-proton Updated Branches: refs/heads/master 937e505e7 -> 1bb1897fe PROTON-1556: work around for C++ binding ssl_domain self assignment bug Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1bb1897f Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1bb1897f Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1bb1897f Branch: refs/heads/master Commit: 1bb1897fecbf50f818adc5fe26667a121bad220a Parents: 937e505 Author: Clifford JansenAuthored: Wed Oct 11 17:53:36 2017 -0700 Committer: Clifford Jansen Committed: Wed Oct 11 17:53:36 2017 -0700 -- proton-c/bindings/cpp/src/ssl_domain.cpp | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1bb1897f/proton-c/bindings/cpp/src/ssl_domain.cpp -- diff --git a/proton-c/bindings/cpp/src/ssl_domain.cpp b/proton-c/bindings/cpp/src/ssl_domain.cpp index bb95bec..143ff5a 100644 --- a/proton-c/bindings/cpp/src/ssl_domain.cpp +++ b/proton-c/bindings/cpp/src/ssl_domain.cpp @@ -28,6 +28,7 @@ namespace proton { /// TODO: This whole class isn't really needed as pn_ssl_domain_t is already refcounted, with shared ownership for all pn_ssl_t objects /// that hold one +/// cjansen: but note it is not a PN_CLASS object and two pn_ssl_domain_free() from the app will cause a free while still in use. class ssl_domain_impl { public: ssl_domain_impl(bool is_server) : refcount_(1), pn_domain_(pn_ssl_domain(is_server ? PN_SSL_MODE_SERVER : PN_SSL_MODE_CLIENT)) { @@ -56,6 +57,7 @@ ssl_domain::ssl_domain(const ssl_domain ) : impl_(x.impl_), server_type_(x.ser } ssl_domain& internal::ssl_domain::operator=(const ssl_domain) { +if ( == this) return *this; if (impl_) impl_->decref(); impl_ = x.impl_; server_type_ = x.server_type_; - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
qpid-dispatch git commit: DISPATCH-834 Add ansible playbook
Repository: qpid-dispatch Updated Branches: refs/heads/config-read-write 91df5a675 -> 06f5f1201 DISPATCH-834 Add ansible playbook Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/06f5f120 Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/06f5f120 Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/06f5f120 Branch: refs/heads/config-read-write Commit: 06f5f1201fbd95d59b1929448eceef5f602e2d20 Parents: 91df5a6 Author: Ernest AllenAuthored: Wed Oct 11 08:33:20 2017 -0400 Committer: Ernest Allen Committed: Wed Oct 11 08:33:20 2017 -0400 -- .../config/deployments/install_dispatch.yaml| 52 1 file changed, 52 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/06f5f120/console/config/deployments/install_dispatch.yaml -- diff --git a/console/config/deployments/install_dispatch.yaml b/console/config/deployments/install_dispatch.yaml new file mode 100644 index 000..0ff4107 --- /dev/null +++ b/console/config/deployments/install_dispatch.yaml @@ -0,0 +1,52 @@ +--- +- + hosts: deploy_routers + become: true + + tasks: +- name: install Dispatch Router + block: +- name: install Dispatch Router + dnf: pkg={{item}} state=installed + with_items: +- qpid-dispatch-router +- qpid-dispatch-tools + +- name: handle console + block: +- name: prepare to install console + file: +path: /usr/local/share/qpid-dispatch +state: directory +- name: install console + synchronize: +src: ../../stand-alone +dest: /usr/local/share/qpid-dispatch +archive: no +recursive: yes +delete: yes + when: create_console + +- name: create directories + file: +path: '{{ item }}' +state: directory + with_items: +- /var/log/qdrouterd +- /usr/local/etc/qpid-dispatch + + when: ansible_os_family == "RedHat" + +- name: Copying router configs + copy: +src: '../topologies/{{topology}}/{{item}}.conf' +dest: /usr/local/etc/qpid-dispatch + with_items: '{{ nodes }}' + +- name: stop running routers + action: shell pkill -f qdrouterd + ignore_errors: True + +- name: start routers + shell: "sleep 1 ; qdrouterd --config /usr/local/etc/qpid-dispatch/{{ item }}.conf -d ; sleep 1" + with_items: "{{ nodes }}" - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
qpid-dispatch git commit: DISPATCH-834 Added ability to deploy to multiple machines
Repository: qpid-dispatch Updated Branches: refs/heads/config-read-write f163d38ee -> 91df5a675 DISPATCH-834 Added ability to deploy to multiple machines Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/91df5a67 Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/91df5a67 Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/91df5a67 Branch: refs/heads/config-read-write Commit: 91df5a6754b1c5778cf758c47bb0b4d271f9734d Parents: f163d38 Author: Ernest AllenAuthored: Wed Oct 11 08:30:39 2017 -0400 Committer: Ernest Allen Committed: Wed Oct 11 08:30:39 2017 -0400 -- console/config/config.py | 189 ++ console/config/css/mock.css | 10 ++ console/config/html/qdrTopology.html | 30 - console/config/js/qdrTopology.js | 151 console/config/mock/section.py | 5 + 5 files changed, 311 insertions(+), 74 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/91df5a67/console/config/config.py -- diff --git a/console/config/config.py b/console/config/config.py index 193b4ad..d17bc34 100755 --- a/console/config/config.py +++ b/console/config/config.py @@ -29,8 +29,12 @@ import SimpleHTTPServer import SocketServer import json import cStringIO +import yaml +import threading +import subprocess import pdb +from distutils.spawn import find_executable def id_generator(size=6, chars=string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) @@ -38,7 +42,7 @@ def id_generator(size=6, chars=string.ascii_uppercase + string.digits): get_class = lambda x: globals()[x] sectionKeys = {"log": "module", "sslProfile": "name", "connector": "port", "listener": "port"} -# borrowed from qpid-dispatch/python/qpid_dispatch_internal/management/config.py +# modified from qpid-dispatch/python/qpid_dispatch_internal/management/config.py def _parse(lines): """Parse config file format into a section list""" begin = re.compile(r'([\w-]+)[ \t]*{') # WORD { @@ -50,7 +54,10 @@ def _parse(lines): """Do substitutions to make line json-friendly""" line = line.strip() if line.startswith("#"): -return "" +if line.startswith("#deploy_host:"): +line = line[1:] +else: +return "" # 'pattern:' is a special snowflake. It allows '#' characters in # its value, so they cannot be treated as comment delimiters if line.split(':')[0].strip().lower() == "pattern": @@ -92,7 +99,9 @@ class Manager(object): def __init__(self, topology, verbose): self.topology = topology self.verbose = verbose -self.base = "topologies/" +self.topo_base = "topologies/" +self.deploy_base = "deployments/" +self.state = None def operation(self, op, request): m = op.replace("-", "_") @@ -105,6 +114,85 @@ class Manager(object): print "Got request " + op return method(request) +def ANSIBLE_INSTALLED(self, request): +if self.verbose: +print "Ansible is", "installed" if find_executable("ansible") else "not installed" +return "installed" if find_executable("ansible") else "" + +# if the node has listeners, and one of them has an http:'true' +def has_console(self, node): +#n = False +#return node.get('listeners') and any([n or h.get('http') for l, h in node.get('listeners').iteritems()]) + +listeners = node.get('listeners') +if listeners: +for k, listener in listeners.iteritems(): +if listener.get('http'): +return True + +return False + +def DEPLOY(self, request): +nodes = request["nodes"] +topology = request["topology"] + +self.PUBLISH(request, deploy=True) + +inventory = {'deploy_routers': + {'vars': {'topology': topology}, + 'hosts': {} +} +} +hosts = inventory['deploy_routers']['hosts'] + +#pdb.set_trace() +for node in nodes: +if node['cls'] == 'router': +host = node['host'] +if not host in hosts: +hosts[host] = {'nodes': [], 'create_console': False} +# if any of the nodes for this host has a console, set create_console for this host to true +hosts[host]['create_console'] = (hosts[host]['create_console'] or self.has_console(node)) +hosts[host]['nodes'].append(node['name']) +# local hosts