diff options
author | Alan Conway <aconway@apache.org> | 2009-07-01 13:47:04 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2009-07-01 13:47:04 +0000 |
commit | 6f734e4aa938dccdc1c79e782908a0d1164ee526 (patch) | |
tree | 3177af16cacd4ea4d265f7c0c48c181c85512608 /cpp/src/qpid/cluster/RetractClient.cpp | |
parent | cc0cb6411e14e23d45304c3ae84069d59b29465a (diff) | |
download | qpid-python-6f734e4aa938dccdc1c79e782908a0d1164ee526.tar.gz |
Fix members joining cluster while cluster is handling client errors.
Previously cluster members could abort if a new member joins while
existing members are handling a client error.
Now if an update offer arrives while an error is in progress, the
offering broker retracts the offer and the newcomer must try again.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@790163 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/cluster/RetractClient.cpp')
-rw-r--r-- | cpp/src/qpid/cluster/RetractClient.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/cpp/src/qpid/cluster/RetractClient.cpp b/cpp/src/qpid/cluster/RetractClient.cpp new file mode 100644 index 0000000000..dfca7fdef4 --- /dev/null +++ b/cpp/src/qpid/cluster/RetractClient.cpp @@ -0,0 +1,61 @@ +/* + * + * 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 "RetractClient.h" +#include "UpdateClient.h" +#include "qpid/framing/ClusterConnectionRetractOfferBody.h" +#include "qpid/client/ConnectionAccess.h" +#include "qpid/client/ConnectionImpl.h" +#include "qpid/log/Statement.h" + +namespace qpid { +namespace cluster { + +using namespace framing; + +namespace { + +struct AutoClose { + client::Connection& connection; + AutoClose(client::Connection& c) : connection(c) {} + ~AutoClose() { connection.close(); } +}; +} + +RetractClient::RetractClient(const Url& u, const client::ConnectionSettings& cs) + : url(u), connectionSettings(cs) +{} + +RetractClient::~RetractClient() { delete this; } + + +void RetractClient::run() { + try { + client::Connection c = UpdateClient::catchUpConnection(); + c.open(url, connectionSettings); + AutoClose ac(c); + AMQFrame retract((ClusterConnectionRetractOfferBody())); + client::ConnectionAccess::getImpl(c)->handle(retract); + } catch (const std::exception& e) { + QPID_LOG(error, " while retracting retract to " << url << ": " << e.what()); + } +} + +}} // namespace qpid::cluster |