|
|
Choosing A Webhost: |
CVS update of carob (2 files): msg#00146db.carob.cvs
Date: Tuesday, January 24, 2006 @ 11:11:51 Author: gilles Path: /cvsroot/carob/carob Modified: include/ControllerConnectPolicy.hpp (1.1 -> 1.2) src/ControllerConnectPolicy.cpp (1.2 -> 1.3) Moved suspected_controllers as a static (shared) vector Removed all ping thread related stuff (we won't use a thread) Implemented suspectControllerOfFailure() Added logging in getController() -------------------------------------+ include/ControllerConnectPolicy.hpp | 17 +------ src/ControllerConnectPolicy.cpp | 75 ++++++++++++++++++++++++++-------- 2 files changed, 63 insertions(+), 29 deletions(-) Index: carob/include/ControllerConnectPolicy.hpp diff -u carob/include/ControllerConnectPolicy.hpp:1.1 carob/include/ControllerConnectPolicy.hpp:1.2 --- carob/include/ControllerConnectPolicy.hpp:1.1 Thu Jan 5 16:11:43 2006 +++ carob/include/ControllerConnectPolicy.hpp Tue Jan 24 11:11:51 2006 @@ -1,6 +1,6 @@ /* * Sequoia: Database clustering technology. - * Copyright (C) 2005 Emic Networks + * Copyright (C) 2005-2006 Continuent, Inc. * Contact: sequoia-NAAfj4rwCWAYtQj7fl1lsA@xxxxxxxxxxxxxxxx * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -67,21 +67,14 @@ * Gets the list of controllers supposed valid * @return the list of controllers */ - std::vector<ControllerInfo> getControllerList() const + std::vector<ControllerInfo> getControllerList() const { return controller_list; } /** - * Gets the list of suspected controllers - * @return the list of suspected controllers - */ - std::vector<ControllerInfo> getSuspectedControllers() const - { return suspected_controllers; } - - /** * Returns true if the specified controller is suspected of failure. * @param controllerInfo the controller to check * @return true if the controller is in the suspect list */ - bool isSuspectedOfFailure( + static bool isSuspectedOfFailure( const ControllerInfo& controllerInfo); /** * Adds the given controller to the list of suspects. @@ -100,14 +93,12 @@ std::vector<ControllerInfo> controller_list; /** list of suspected controllers */ // Could have been a hash_set as in java but hash_set class is gnu specific - std::vector<ControllerInfo> suspected_controllers; + static std::vector<ControllerInfo> suspected_controllers; /** class wide mutex */ CriticalSection policy_CS; /** mutex on supected controllers */ CriticalSection suspected_controllers_CS; private: - /** Interval between two connection attempts */ - long retry_interval_in_ms; }; /** Index: carob/src/ControllerConnectPolicy.cpp diff -u carob/src/ControllerConnectPolicy.cpp:1.2 carob/src/ControllerConnectPolicy.cpp:1.3 --- carob/src/ControllerConnectPolicy.cpp:1.2 Thu Jan 12 18:05:05 2006 +++ carob/src/ControllerConnectPolicy.cpp Tue Jan 24 11:11:51 2006 @@ -27,6 +27,9 @@ using namespace CarobNS; +// Static list of suspected controllers +std::vector<ControllerInfo> AbstractControllerConnectPolicy::suspected_controllers; + AbstractControllerConnectPolicy::AbstractControllerConnectPolicy( const std::vector<ControllerInfo>& controllerList, long retryIntervalInMs) throw (DriverException, UnexpectedException) @@ -35,23 +38,12 @@ throw DriverException( L"Invalid empty controller list in connect policy constructor"); controller_list = controllerList; - // TODO: do we really need to reserve this space ? - // suspected_controllers.reserve(controller_list.length()); - retry_interval_in_ms = retryIntervalInMs; + suspected_controllers.reserve(controller_list.size()); } AbstractControllerConnectPolicy::~AbstractControllerConnectPolicy() { controller_list.clear(); - suspected_controllers.clear(); - /* - // Kill controller ping thread - if (controllerPingThread != null) - synchronized (controllerPingThread) - { - controllerPingThread.notify(); - } - */ } bool AbstractControllerConnectPolicy::isSuspectedOfFailure( @@ -66,6 +58,56 @@ return false; } +void AbstractControllerConnectPolicy::suspectControllerOfFailure( + const ControllerInfo& controllerInfo) +{ + wstring fctName(L"AbstractControllerConnectPolicy::suspectControllerOfFailure"); + + // First check that the controller is not already in the list of suspects + if (isSuspectedOfFailure(controllerInfo)) + return; + + // Check that the controllerInfo is correct and add it to the list + for (size_t i = 0; i < controller_list.size(); i++) + { + ControllerInfo controller = controller_list[i]; + if (controller == controllerInfo) + { + LockScope scLs(&suspected_controllers_CS); + suspected_controllers.push_back(controllerInfo); + if (isDebugEnabled()) + logDebug(fctName, L"Controller " + (wstring)controllerInfo + + L" is now suspected of failure"); + return; + } + } +} + +void AbstractControllerConnectPolicy::removeControllerFromSuspectList( + const ControllerInfo& controller) +{ + wstring fctName(L"AbstractControllerConnectPolicy::removeControllerFromSuspectList"); + LockScope scLs(&suspected_controllers_CS); + for (std::vector<ControllerInfo>::iterator iter = suspected_controllers.begin(); + iter != suspected_controllers.end(); iter++) + { + if (*iter == controller) + { + suspected_controllers.erase(iter); + if (isDebugEnabled()) + { + logDebug(fctName, L"Controller " + (wstring)controller + + L" is removed from suspect list"); + } + break; + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +// ROUND ROBIN POLICY +//////////////////////////////////////////////////////////////////////////////// + RoundRobinConnectPolicy::RoundRobinConnectPolicy( const std::vector<ControllerInfo>& controllerList, long retryIntervalInMs) throw (DriverException, UnexpectedException) : @@ -77,6 +119,8 @@ ControllerInfo RoundRobinConnectPolicy::getController() throw (NoMoreControllerException, UnexpectedException) { + wstring fctName(L"RoundRobinConnectPolicy::getController"); + LockScope ls(&policy_CS); { LockScope scLs(&suspected_controllers_CS); @@ -90,10 +134,9 @@ } while (isSuspectedOfFailure(controller_list[index])); } -/*TODO: if (debugLevel == SequoiaUrl.DEBUG_LEVEL_DEBUG) - System.out.println("Selected controller[" + index + "]:" - + controllerList[index]); -*/ + if (isDebugEnabled()) + logDebug(fctName, L"Selected controller[" + toWString(index) + L"]:" + + (wstring)controller_list[index]); return controller_list[index]; }
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of carob (2 files), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of carob/test (CarobTestLauncher.cpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob (2 files), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of carob (2 files), 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.
|