|
|
Choosing A Webhost: |
CVS update of carob (include/Connection.hpp src/Connection.cpp): msg#00034db.carob.cvs
Date: Friday, February 10, 2006 @ 09:49:49 Author: gilles Path: /cvsroot/carob/carob Modified: include/Connection.hpp (1.54 -> 1.55) src/Connection.cpp (1.60 -> 1.61) Remember controller we are connected to (so reconnect() can suspect the controller) Implemented full reconnect ------------------------+ include/Connection.hpp | 4 ++ src/Connection.cpp | 70 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 18 deletions(-) Index: carob/include/Connection.hpp diff -u carob/include/Connection.hpp:1.54 carob/include/Connection.hpp:1.55 --- carob/include/Connection.hpp:1.54 Thu Feb 9 15:50:12 2006 +++ carob/include/Connection.hpp Fri Feb 10 09:49:49 2006 @@ -403,6 +403,8 @@ AbstractControllerConnectPolicy* connect_policy_ptr; /** The parameters of this connection */ ConnectionParameters parameters; + /** The controller we are connected to */ + ControllerInfo connected_controller; /** * List of pointers to the [parameter]statements created by this connection. * Kept in order to destroy them when closing connection @@ -542,7 +544,7 @@ * * @throw //TODO */ - void reconnect() throw (UnexpectedException); + void reconnect() throw (NoMoreControllerException, UnexpectedException); /** * Forbids Connection creation that would lead to unexpected state. * A connection is either created, ie. connected to a controller or destroyed Index: carob/src/Connection.cpp diff -u carob/src/Connection.cpp:1.60 carob/src/Connection.cpp:1.61 --- carob/src/Connection.cpp:1.60 Thu Feb 9 15:50:12 2006 +++ carob/src/Connection.cpp Fri Feb 10 09:49:49 2006 @@ -110,12 +110,12 @@ userPassSend = false; if (connect_policy_ptr == NULL) throw DriverException(L"Connection policy error. Aborting."); - ControllerInfo controller = connect_policy_ptr->getController(); + connected_controller = connect_policy_ptr->getController(); if (isInfoEnabled()) { wstring msg = L"Authenticating with controller " - + controller.getHostName() + L":" - + toWString(static_cast<int>(controller.getHostPort())); + + connected_controller.getHostName() + L":" + + toWString(static_cast<int>(connected_controller.getHostPort())); if (isInfoEnabled()) logInfo(fctName, msg); } @@ -123,8 +123,8 @@ { //Here is the connection protocol... // 1. connect to the controller - driverSocketPtr = new DriverSocket(controller.getHostName(), - controller.getHostPort()); + driverSocketPtr = new DriverSocket(connected_controller.getHostName(), + connected_controller.getHostPort()); // 2. sent the Protocol version information *driverSocketPtr<<ProtocolVersion; protocolVersionSend = true; @@ -141,8 +141,8 @@ catch (ConnectionException connExcpt) { wstring msg = L"Unable to connect to controller on " - + controller.getHostName() - + L":" + toWString(static_cast<int>(controller.getHostPort())) + + connected_controller.getHostName() + + L":" + toWString(static_cast<int>(connected_controller.getHostPort())) + L" (" + connExcpt.description() + L")."; if (isErrorEnabled()) logError(fctName, msg); @@ -151,8 +151,8 @@ } catch (SocketIOException sockIOExcpt) { - wstring msg = L"Could not authentify to " + controller.getHostName() - + L":" + toWString(static_cast<int>(controller.getHostPort())); + wstring msg = L"Could not authentify to " + connected_controller.getHostName() + + L":" + toWString(static_cast<int>(connected_controller.getHostPort())); if (!protocolVersionSend) { msg+=L". Error while sending protocol version (" @@ -947,7 +947,7 @@ return results; } -void Connection::reconnect() throw (UnexpectedException) +void Connection::reconnect() throw (NoMoreControllerException, UnexpectedException) { wstring fctName(L"Connection::reconnect"); //Wait until other methods/Commands are done @@ -955,9 +955,35 @@ // close everything close(); - // try to reconnect to the same controller + + // try to reconnect to the same controller if it has never been suspected of + // failure before + if (!connect_policy_ptr->isSuspectedOfFailure(connected_controller)) + { + try + { + if (initConnection() && finalizeConnect()) + { + if (isInfoEnabled()) + logInfo(fctName, L"Connection succeded"); + isClosed = false; + } + } + catch (...) + { + //Do some clean up: we are in constructor so if we throw an exception, the + //destructor will never be called... + delete driverSocketPtr; driverSocketPtr = NULL; + delete connect_policy_ptr; connect_policy_ptr = NULL; + } + } + if (isClosed) + { + connect_policy_ptr->suspectControllerOfFailure(connected_controller); + } try { + connected_controller = connect_policy_ptr->getController(); if (initConnection() && finalizeConnect()) { if (isInfoEnabled()) @@ -965,14 +991,24 @@ isClosed = false; } } - catch (...) + catch (AuthenticationException ae) + { + // Should not happen, this probably mean an inconsistency in controller + // configuration but safely ignore (see below) + wstring msg = L"Warning! Authentication exception received on connection retry, controller configuration might be inconsistent"; + if (isWarningEnabled()) + logWarning(fctName, msg); + throw DriverException(msg+ae.description()); + } + catch (ConnectionException ce) { - //Do some clean up: we are in constructor so if we throw an exception, the - //destructor will never be called... - delete driverSocketPtr; driverSocketPtr = NULL; - delete connect_policy_ptr; connect_policy_ptr = NULL; + // Should not happen, this probably mean an inconsistency in controller + // configuration but safely ignore (see below) + wstring msg = L"Warning! Connection exception received on connection retry, controller configuration might be inconsistent"; + if (isWarningEnabled()) + logWarning(fctName, msg); + throw DriverException(msg+ce.description()); } - }
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of odbsequoia/src (abstract_item.hpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of carob/src (Connection.cpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob (include/Connection.hpp src/Connection.cpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of carob (include/Connection.hpp src/Connection.cpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|