diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2011-05-27 15:44:23 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2011-05-27 15:44:23 +0000 |
commit | 66765100f4257159622cefe57bed50125a5ad017 (patch) | |
tree | a88ee23bb194eb91f0ebb2d9b23ff423e3ea8e37 /cpp/include/qpid/client/FailoverManager.h | |
parent | 1aeaa7b16e5ce54f10c901d75c4d40f9f88b9db6 (diff) | |
parent | 88b98b2f4152ef59a671fad55a0d08338b6b78ca (diff) | |
download | qpid-python-rajith_jms_client.tar.gz |
Creating a branch for experimenting with some ideas for JMS client.rajith_jms_client
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/rajith_jms_client@1128369 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/include/qpid/client/FailoverManager.h')
-rw-r--r-- | cpp/include/qpid/client/FailoverManager.h | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/cpp/include/qpid/client/FailoverManager.h b/cpp/include/qpid/client/FailoverManager.h deleted file mode 100644 index d3a0dbc976..0000000000 --- a/cpp/include/qpid/client/FailoverManager.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef QPID_CLIENT_FAILOVERMANAGER_H -#define QPID_CLIENT_FAILOVERMANAGER_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/Exception.h" -#include "qpid/client/AsyncSession.h" -#include "qpid/client/ClientImportExport.h" -#include "qpid/client/Connection.h" -#include "qpid/client/ConnectionSettings.h" -#include "qpid/client/FailoverListener.h" -#include "qpid/sys/Monitor.h" -#include <vector> - -namespace qpid { -namespace client { - -struct CannotConnectException : qpid::Exception -{ - CannotConnectException(const std::string& m) : qpid::Exception(m) {} -}; - -/** - * Utility to manage failover. - */ -class QPID_CLIENT_CLASS_EXTERN FailoverManager -{ - public: - /** - * Interface to implement for doing work that can be resumed on - * failover - */ - struct Command - { - /** - * This method will be called with isRetry=false when the - * command is first executed. The session to use for the work - * will be passed to the implementing class. If the connection - * fails while the execute call is in progress, the - * FailoverManager controlling the execution will re-establish - * a connection, open a new session and call back to the - * Command implementations execute method with the new session - * and isRetry=true. - */ - virtual void execute(AsyncSession& session, bool isRetry) = 0; - virtual ~Command() {} - }; - - struct ReconnectionStrategy - { - /** - * This method is called by the FailoverManager prior to - * establishing a connection (or re-connection) and can be - * used if the application wishes to edit or re-order the list - * which will default to the list of known brokers for the - * last connection. - */ - virtual void editUrlList(std::vector<Url>& urls) = 0; - virtual ~ReconnectionStrategy() {} - }; - - /** - * Create a manager to control failover for a logical connection. - * - * @param settings the initial connection settings - * @param strategy optional stratgey callback allowing application - * to edit or reorder the list of urls to which reconnection is - * attempted - */ - QPID_CLIENT_EXTERN FailoverManager(const ConnectionSettings& settings, ReconnectionStrategy* strategy = 0); - /** - * Return the current connection if open or attept to reconnect to - * the specified list of urls. If no list is specified the list of - * known brokers from the last connection will be used. If no list - * is specified and this is the first connect attempt, the host - * and port from the initial settings will be used. - * - * If the full list is tried and all attempts fail, - * CannotConnectException is thrown. - */ - QPID_CLIENT_EXTERN Connection& connect(std::vector<Url> brokers = std::vector<Url>()); - /** - * Return the current connection whether open or not - */ - QPID_CLIENT_EXTERN Connection& getConnection(); - /** - * Close the current connection - */ - QPID_CLIENT_EXTERN void close(); - /** - * Reliably execute the specified command. This involves creating - * a session on which to carry out the work of the command, - * handling failover occuring while exeuting that command and - * re-starting the work. - * - * Multiple concurrent threads can call execute with different - * commands; each thread will be allocated its own - * session. FailoverManager will coordinate the different threads - * on failover to ensure they continue to use the same logical - * connection. - */ - QPID_CLIENT_EXTERN void execute(Command&); - private: - enum State {IDLE, CONNECTING, CANT_CONNECT}; - - qpid::sys::Monitor lock; - Connection connection; - std::auto_ptr<FailoverListener> failoverListener; - ConnectionSettings settings; - ReconnectionStrategy* strategy; - State state; - - void attempt(Connection&, ConnectionSettings settings, std::vector<Url> urls); - void attempt(Connection&, ConnectionSettings settings); -}; -}} // namespace qpid::client - -#endif /*!QPID_CLIENT_FAILOVERMANAGER_H*/ |