From 3b80f903b6174b4346d7d7b537d783f628fe28d6 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 21 Sep 2007 15:13:52 +0000 Subject: Moved c++ over to using the same preview file for 0-10 work as java. Removed all channel class related code from broker as a result. Did the same for some python tests I missed earlier. Renamed ChannelAdapter to ChannelHandler. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@578167 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/configure.ac | 2 +- cpp/src/Makefile.am | 4 +- cpp/src/qpid/broker/Connection.h | 4 +- cpp/src/qpid/broker/ConnectionAdapter.cpp | 103 ------------------------------ cpp/src/qpid/broker/ConnectionAdapter.h | 89 -------------------------- cpp/src/qpid/broker/ConnectionHandler.cpp | 93 +++++++++++++++++++++++++++ cpp/src/qpid/broker/ConnectionHandler.h | 70 ++++++++++++++++++++ cpp/src/qpid/broker/SemanticHandler.cpp | 1 - cpp/src/qpid/broker/SessionHandler.cpp | 57 +---------------- cpp/src/qpid/broker/SessionHandler.h | 21 ------ cpp/src/tests/python_tests | 2 +- 11 files changed, 172 insertions(+), 274 deletions(-) delete mode 100644 cpp/src/qpid/broker/ConnectionAdapter.cpp delete mode 100644 cpp/src/qpid/broker/ConnectionAdapter.h create mode 100644 cpp/src/qpid/broker/ConnectionHandler.cpp create mode 100644 cpp/src/qpid/broker/ConnectionHandler.h (limited to 'cpp') diff --git a/cpp/configure.ac b/cpp/configure.ac index 7d990b48ac..1a81b8831e 100644 --- a/cpp/configure.ac +++ b/cpp/configure.ac @@ -120,7 +120,7 @@ test -n "$RUBY" && generate=yes test -z "$RUBY" && AC_MSG_ERROR([Missing ruby installation (try "yum install ruby").]) specdir=`pwd`/$srcdir/../specs -AMQP_XML=$specdir/amqp-transitional.0-10.xml +AMQP_XML=$specdir/amqp.0-10-preview.xml AC_SUBST(AMQP_XML) ls $AMQP_XML >/dev/null 2>&1 || generate=no diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index 7f25c194d4..cf7029dabc 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -157,7 +157,7 @@ libqpidbroker_la_SOURCES = \ qpid/broker/BrokerExchange.cpp \ qpid/broker/BrokerQueue.cpp \ qpid/broker/Connection.cpp \ - qpid/broker/ConnectionAdapter.cpp \ + qpid/broker/ConnectionHandler.cpp \ qpid/broker/ConnectionFactory.cpp \ qpid/broker/Daemon.cpp \ qpid/broker/DeliverableMessage.cpp \ @@ -268,7 +268,7 @@ nobase_include_HEADERS = \ qpid/broker/BrokerAdapter.h \ qpid/broker/BrokerSingleton.h \ qpid/broker/Connection.h \ - qpid/broker/ConnectionAdapter.h \ + qpid/broker/ConnectionHandler.h \ qpid/broker/ConnectionFactory.h \ qpid/broker/ConnectionToken.h \ qpid/broker/Daemon.h \ diff --git a/cpp/src/qpid/broker/Connection.h b/cpp/src/qpid/broker/Connection.h index 94651701dd..2723ac9acc 100644 --- a/cpp/src/qpid/broker/Connection.h +++ b/cpp/src/qpid/broker/Connection.h @@ -36,7 +36,7 @@ #include "Broker.h" #include "qpid/Exception.h" #include "Session.h" -#include "ConnectionAdapter.h" +#include "ConnectionHandler.h" #include "SessionHandler.h" #include @@ -95,7 +95,7 @@ class Connection : public sys::ConnectionInputHandler, uint16_t heartbeat; framing::AMQP_ClientProxy::Connection* client; uint64_t stagingThreshold; - ConnectionAdapter adapter; + ConnectionHandler adapter; }; }} diff --git a/cpp/src/qpid/broker/ConnectionAdapter.cpp b/cpp/src/qpid/broker/ConnectionAdapter.cpp deleted file mode 100644 index e33aeda8c7..0000000000 --- a/cpp/src/qpid/broker/ConnectionAdapter.cpp +++ /dev/null @@ -1,103 +0,0 @@ - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "ConnectionAdapter.h" -#include "Connection.h" -#include "qpid/framing/ConnectionStartBody.h" - -using namespace qpid; -using namespace qpid::broker; -using namespace qpid::framing; - -void ConnectionAdapter::init(const framing::ProtocolInitiation& header) { - FieldTable properties; - string mechanisms("PLAIN"); - string locales("en_US"); - handler->client.start(header.getMajor(), header.getMinor(), properties, mechanisms, locales); -} - -void ConnectionAdapter::close(ReplyCode code, const string& text, ClassId classId, MethodId methodId) -{ - handler->client.close(code, text, classId, methodId); -} - - -framing::AMQP_ServerOperations::ConnectionHandler* ConnectionAdapter::getConnectionHandler() -{ - return handler.get(); -} - -framing::ProtocolVersion ConnectionAdapter::getVersion() const -{ - return handler->connection.getVersion(); -} - -void ConnectionAdapter::handle(framing::AMQFrame& frame) -{ - AMQMethodBody* method=frame.getBody()->getMethod(); - try{ - method->invoke(*this); - }catch(ConnectionException& e){ - handler->client.close(e.code, e.toString(), method->amqpClassId(), method->amqpMethodId()); - }catch(std::exception& e){ - handler->client.close(541/*internal error*/, e.what(), method->amqpClassId(), method->amqpMethodId()); - } -} - -ConnectionAdapter::ConnectionAdapter(Connection& connection) : handler(new Handler(connection)) {} - -ConnectionAdapter::Handler:: Handler(Connection& c) : client(c.getOutput()), connection(c) {} - -void ConnectionAdapter::Handler::startOk(const FieldTable& /*clientProperties*/, - const string& /*mechanism*/, - const string& /*response*/, const string& /*locale*/) -{ - client.tune(framing::CHANNEL_MAX, connection.getFrameMax(), connection.getHeartbeat()); -} - -void ConnectionAdapter::Handler::secureOk(const string& /*response*/){} - -void ConnectionAdapter::Handler::tuneOk(uint16_t /*channelmax*/, - uint32_t framemax, uint16_t heartbeat) -{ - connection.setFrameMax(framemax); - connection.setHeartbeat(heartbeat); -} - -void ConnectionAdapter::Handler::open(const string& /*virtualHost*/, - const string& /*capabilities*/, bool /*insist*/) -{ - string knownhosts; - client.openOk(knownhosts); -} - - -void ConnectionAdapter::Handler::close(uint16_t /*replyCode*/, const string& /*replyText*/, - uint16_t /*classId*/, uint16_t /*methodId*/) -{ - client.closeOk(); - connection.getOutput().close(); -} - -void ConnectionAdapter::Handler::closeOk(){ - connection.getOutput().close(); -} diff --git a/cpp/src/qpid/broker/ConnectionAdapter.h b/cpp/src/qpid/broker/ConnectionAdapter.h deleted file mode 100644 index eb96575c9d..0000000000 --- a/cpp/src/qpid/broker/ConnectionAdapter.h +++ /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. - * - */ -#ifndef _ConnectionAdapter_ -#define _ConnectionAdapter_ - -#include -#include "qpid/framing/amqp_types.h" -#include "qpid/framing/AMQFrame.h" -#include "qpid/framing/AMQP_ServerOperations.h" -#include "qpid/framing/AMQP_ClientProxy.h" -#include "qpid/framing/FrameHandler.h" -#include "qpid/framing/ProtocolInitiation.h" -#include "qpid/framing/ProtocolVersion.h" -#include "qpid/Exception.h" - -namespace qpid { -namespace broker { - -class Connection; - -// TODO aconway 2007-09-18: Rename to ConnectionHandler -class ConnectionAdapter : public framing::FrameHandler, public framing::AMQP_ServerOperations -{ - struct Handler : public framing::AMQP_ServerOperations::ConnectionHandler - { - framing::AMQP_ClientProxy::Connection client; - Connection& connection; - - Handler(Connection& connection); - void startOk(const qpid::framing::FieldTable& clientProperties, - const std::string& mechanism, const std::string& response, - const std::string& locale); - void secureOk(const std::string& response); - void tuneOk(uint16_t channelMax, uint32_t frameMax, uint16_t heartbeat); - void open(const std::string& virtualHost, - const std::string& capabilities, bool insist); - void close(uint16_t replyCode, const std::string& replyText, - uint16_t classId, uint16_t methodId); - void closeOk(); - }; - std::auto_ptr handler; - public: - ConnectionAdapter(Connection& connection); - void init(const framing::ProtocolInitiation& header); - void close(framing::ReplyCode code, const std::string& text, framing::ClassId classId, framing::MethodId methodId); - void handle(framing::AMQFrame& frame); - - //AMQP_ServerOperations: - ConnectionHandler* getConnectionHandler(); - ChannelHandler* getChannelHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - BasicHandler* getBasicHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - ExchangeHandler* getExchangeHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - BindingHandler* getBindingHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - QueueHandler* getQueueHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - TxHandler* getTxHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - MessageHandler* getMessageHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - AccessHandler* getAccessHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - FileHandler* getFileHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - StreamHandler* getStreamHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - TunnelHandler* getTunnelHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - DtxCoordinationHandler* getDtxCoordinationHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - DtxDemarcationHandler* getDtxDemarcationHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - ExecutionHandler* getExecutionHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - SessionHandler* getSessionHandler() { throw ConnectionException(503, "Class can't be accessed over channel 0"); } - framing::ProtocolVersion getVersion() const; -}; - - -}} - -#endif diff --git a/cpp/src/qpid/broker/ConnectionHandler.cpp b/cpp/src/qpid/broker/ConnectionHandler.cpp new file mode 100644 index 0000000000..a769d05470 --- /dev/null +++ b/cpp/src/qpid/broker/ConnectionHandler.cpp @@ -0,0 +1,93 @@ + +/* + * + * 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 "ConnectionHandler.h" +#include "Connection.h" +#include "qpid/framing/ConnectionStartBody.h" + +using namespace qpid; +using namespace qpid::broker; +using namespace qpid::framing; + +void ConnectionHandler::init(const framing::ProtocolInitiation& header) { + FieldTable properties; + string mechanisms("PLAIN"); + string locales("en_US"); + handler->client.start(header.getMajor(), header.getMinor(), properties, mechanisms, locales); +} + +void ConnectionHandler::close(ReplyCode code, const string& text, ClassId classId, MethodId methodId) +{ + handler->client.close(code, text, classId, methodId); +} + +void ConnectionHandler::handle(framing::AMQFrame& frame) +{ + AMQMethodBody* method=frame.getBody()->getMethod(); + try{ + if (!method->invoke(handler.get())) + throw ConnectionException(503, "Class can't be accessed over channel 0"); + }catch(ConnectionException& e){ + handler->client.close(e.code, e.toString(), method->amqpClassId(), method->amqpMethodId()); + }catch(std::exception& e){ + handler->client.close(541/*internal error*/, e.what(), method->amqpClassId(), method->amqpMethodId()); + } +} + +ConnectionHandler::ConnectionHandler(Connection& connection) : handler(new Handler(connection)) {} + +ConnectionHandler::Handler:: Handler(Connection& c) : client(c.getOutput()), connection(c) {} + +void ConnectionHandler::Handler::startOk(const FieldTable& /*clientProperties*/, + const string& /*mechanism*/, + const string& /*response*/, const string& /*locale*/) +{ + client.tune(framing::CHANNEL_MAX, connection.getFrameMax(), connection.getHeartbeat()); +} + +void ConnectionHandler::Handler::secureOk(const string& /*response*/){} + +void ConnectionHandler::Handler::tuneOk(uint16_t /*channelmax*/, + uint32_t framemax, uint16_t heartbeat) +{ + connection.setFrameMax(framemax); + connection.setHeartbeat(heartbeat); +} + +void ConnectionHandler::Handler::open(const string& /*virtualHost*/, + const string& /*capabilities*/, bool /*insist*/) +{ + string knownhosts; + client.openOk(knownhosts); +} + + +void ConnectionHandler::Handler::close(uint16_t /*replyCode*/, const string& /*replyText*/, + uint16_t /*classId*/, uint16_t /*methodId*/) +{ + client.closeOk(); + connection.getOutput().close(); +} + +void ConnectionHandler::Handler::closeOk(){ + connection.getOutput().close(); +} diff --git a/cpp/src/qpid/broker/ConnectionHandler.h b/cpp/src/qpid/broker/ConnectionHandler.h new file mode 100644 index 0000000000..aa8c9366cd --- /dev/null +++ b/cpp/src/qpid/broker/ConnectionHandler.h @@ -0,0 +1,70 @@ +/* + * + * 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 _ConnectionAdapter_ +#define _ConnectionAdapter_ + +#include +#include "qpid/framing/amqp_types.h" +#include "qpid/framing/AMQFrame.h" +#include "qpid/framing/AMQP_ServerOperations.h" +#include "qpid/framing/AMQP_ClientProxy.h" +#include "qpid/framing/FrameHandler.h" +#include "qpid/framing/ProtocolInitiation.h" +#include "qpid/framing/ProtocolVersion.h" +#include "qpid/Exception.h" + +namespace qpid { +namespace broker { + +class Connection; + +// TODO aconway 2007-09-18: Rename to ConnectionHandler +class ConnectionHandler : public framing::FrameHandler +{ + struct Handler : public framing::AMQP_ServerOperations::ConnectionHandler + { + framing::AMQP_ClientProxy::Connection client; + Connection& connection; + + Handler(Connection& connection); + void startOk(const qpid::framing::FieldTable& clientProperties, + const std::string& mechanism, const std::string& response, + const std::string& locale); + void secureOk(const std::string& response); + void tuneOk(uint16_t channelMax, uint32_t frameMax, uint16_t heartbeat); + void open(const std::string& virtualHost, + const std::string& capabilities, bool insist); + void close(uint16_t replyCode, const std::string& replyText, + uint16_t classId, uint16_t methodId); + void closeOk(); + }; + std::auto_ptr handler; + public: + ConnectionHandler(Connection& connection); + void init(const framing::ProtocolInitiation& header); + void close(framing::ReplyCode code, const std::string& text, framing::ClassId classId, framing::MethodId methodId); + void handle(framing::AMQFrame& frame); +}; + + +}} + +#endif diff --git a/cpp/src/qpid/broker/SemanticHandler.cpp b/cpp/src/qpid/broker/SemanticHandler.cpp index fc878ca346..f8d76c3b5f 100644 --- a/cpp/src/qpid/broker/SemanticHandler.cpp +++ b/cpp/src/qpid/broker/SemanticHandler.cpp @@ -28,7 +28,6 @@ #include "Session.h" #include "qpid/framing/ExecutionCompleteBody.h" #include "qpid/framing/ExecutionResultBody.h" -#include "qpid/framing/ChannelOpenBody.h" #include "qpid/framing/InvocationVisitor.h" #include diff --git a/cpp/src/qpid/broker/SessionHandler.cpp b/cpp/src/qpid/broker/SessionHandler.cpp index e7ef6fdb87..01ce88059a 100644 --- a/cpp/src/qpid/broker/SessionHandler.cpp +++ b/cpp/src/qpid/broker/SessionHandler.cpp @@ -33,8 +33,7 @@ using namespace std; SessionHandler::SessionHandler(Connection& c, ChannelId ch) : InOutHandler(0, &c.getOutput()), connection(c), channel(ch), proxy(out), - ignoring(false), channelHandler(*this), - useChannelClose(false) {} + ignoring(false) {} SessionHandler::~SessionHandler() {} @@ -52,7 +51,7 @@ void SessionHandler::handleIn(AMQFrame& f) { // AMQMethodBody* m=f.getMethod(); try { - if (m && (m->invoke(this) || m->invoke(&channelHandler))) + if (m && m->invoke(this)) return; else if (session) session->in(f); @@ -62,12 +61,7 @@ void SessionHandler::handleIn(AMQFrame& f) { } catch(const ChannelException& e) { ignoring=true; // Ignore trailing frames sent by client. session.reset(); - // FIXME aconway 2007-09-19: Dual-mode hack. - if (useChannelClose) - getProxy().getChannel().close( - e.code, e.toString(), classId(m), methodId(m)); - else - getProxy().getSession().closed(e.code, e.toString()); + getProxy().getSession().closed(e.code, e.toString()); }catch(const ConnectionException& e){ connection.close(e.code, e.what(), classId(m), methodId(m)); }catch(const std::exception& e){ @@ -98,51 +92,6 @@ void SessionHandler::assertClosed(const char* method) { << getChannel())); } -void SessionHandler::ChannelMethods::open(const string& /*outOfBand*/){ - parent.useChannelClose=true; - parent.assertClosed("open"); - parent.session.reset(new Session(parent, 0)); - parent.getProxy().getChannel().openOk(); -} - -// FIXME aconway 2007-08-31: flow is no longer in the spec. -void SessionHandler::ChannelMethods::flow(bool active){ - parent.session->flow(active); - parent.getProxy().getChannel().flowOk(active); -} - -void SessionHandler::ChannelMethods::flowOk(bool /*active*/){} - -void SessionHandler::ChannelMethods::close(uint16_t replyCode, - const string& replyText, - uint16_t classId, uint16_t methodId) -{ - // FIXME aconway 2007-08-31: Extend constants.h to map codes & ids - // to text names. - QPID_LOG(warning, "Received channel.close("< session; bool ignoring; - ChannelMethods channelHandler; - bool useChannelClose; // FIXME aconway 2007-09-19: remove with channel. }; }} // namespace qpid::broker diff --git a/cpp/src/tests/python_tests b/cpp/src/tests/python_tests index 33d60fcf09..d9754ed0fb 100755 --- a/cpp/src/tests/python_tests +++ b/cpp/src/tests/python_tests @@ -1,7 +1,7 @@ #!/bin/sh # Run the python tests. if test -d ../../../python ; then - cd ../../../python && ./run-tests -v -s ../specs/amqp-transitional.0-10.xml -I cpp_failing_0-10.txt -b localhost:$QPID_PORT $PYTHON_TESTS + cd ../../../python && ./run-tests -v -s ../specs/amqp.0-10-preview.xml -I cpp_failing_0-10.txt -b localhost:$QPID_PORT $PYTHON_TESTS else echo Warning: python tests not found. fi -- cgit v1.2.1