Date: Friday, August 25, 2006 @ 19:56:56
Author: gilles
Path: /cvsroot/carob/carob
Added: include/ControllerPinger.hpp (1.1) src/ControllerPinger.cpp
(1.1)
Modified: include/ControllerPool.hpp (1.5 -> 1.6) src/Connection.cpp (1.84
-> 1.85) src/ControllerPool.cpp (1.5 -> 1.6)
test/10-Connection/TestControllerPool.cpp (1.2 -> 1.3)
Extracted suspected_controllers management into new singleton class
ControllerPinger
Fixed potential concurrent accesses on suspected_controllers list (put
suspected_controllers_CS library-wide instead of class-wide)
-------------------------------------------+
include/ControllerPinger.hpp | 97 ++++++++++++
include/ControllerPool.hpp | 39 -----
src/Connection.cpp | 16 +-
src/ControllerPinger.cpp | 214 ++++++++++++++++++++++++++++
src/ControllerPool.cpp | 169 ----------------------
test/10-Connection/TestControllerPool.cpp | 19 +-
6 files changed, 337 insertions(+), 217 deletions(-)
Index: carob/include/ControllerPinger.hpp
diff -u /dev/null carob/include/ControllerPinger.hpp:1.1
--- /dev/null Fri Aug 25 19:56:56 2006
+++ carob/include/ControllerPinger.hpp Fri Aug 25 19:56:56 2006
@@ -0,0 +1,97 @@
+/*
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005-2006 Continuent, Inc.
+ * Contact: [EMAIL PROTECTED]
+ *
+ * Licensed 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.
+ *
+ * Initial developer(s): Gilles Rayrat
+ * Contributor(s): Marc Herbert, Zsolt Simon
+ */
+
+#ifndef CONTROLLERPINGER_HPP_
+#define CONTROLLERPINGER_HPP_
+
+namespace CarobNS
+{
+
+class ControllerInfo;
+
+/**
+ * Singleton (library-wide) class that manages the list of controllers
suspected
+ * of failure.<br>
+ * Used by controller pools, provides 3 main functions: one for adding a
suspect
+ * in the list, one for knowing if a controller is already suspected, and on to
+ * update the list (ping the controllers to check if they are up again
+ */
+class ControllerPinger
+{
+public:
+ /**
+ * Singleton-access function: retrieves the existing or newly created
instance
+ * of the ControllerPinger
+ */
+ static ControllerPinger* getInstancePtr();
+ /**
+ * Adds the given controller to the list of suspects.<br>
+ * The given controllerInfo argument will be *copied* in the suspected
+ * controllers list, but this function will modify the given controller info
+ * by setting its failure_number field
+ * @param controllerInfoPrm the controller suspected of failure
+ */
+ void suspectControllerOfFailure(
+ ControllerInfo& controllerInfoPrm);
+ /**
+ * Returns true if the specified controller is suspected of failure.<br>
+ * @param controllerInfoPrm the controller to check
+ * @return true if the controller is in the suspect list
+ */
+ bool isSuspectedOfFailure(
+ const ControllerInfo& controllerInfoPrm);
+ /**
+ * Tries to connect to each suspected controller with a non-blocking connect
+ * and checks the connection state. In case of connection success, send the
+ * ping command and remove the controller from the suspect list.
+ */
+ void run();
+ /**
+ * Gives the number of controller failures since this process started
+ */
+ static int getNumberOfFailures();
+private:
+ // no suspected_controllers list here. As this vector is library-wide, it is
+ // declared in an anymous namespace in the .cpp
+
+ /** Unique instance of this class */
+ static ControllerPinger* unique_instance_ptr;
+ /**
+ * Number of milliseconds to wait for the controllers to respond to a ping
+ * connection attempt
+ */
+ static const int select_timeout = 20;
+ /** Prevent creation from the outside */
+ ControllerPinger() {};
+ /** Prevent destruction from the outside */
+ virtual ~ControllerPinger() {};
+ /**
+ * Removes the specified controller from the list of suspected controllers.
+ * If the given controller is not in the list, logs a warning and returns
+ * @param controller the controller to remove from the list
+ */
+ static void removeControllerFromSuspectList(
+ const ControllerInfo& controller);
+};
+
+} //namespace CarobNS
+
+#endif /*CONTROLLERPINGER_HPP_*/
Index: carob/include/ControllerPool.hpp
diff -u carob/include/ControllerPool.hpp:1.5
carob/include/ControllerPool.hpp:1.6
--- carob/include/ControllerPool.hpp:1.5 Fri Aug 25 15:53:09 2006
+++ carob/include/ControllerPool.hpp Fri Aug 25 19:56:56 2006
@@ -50,17 +50,10 @@
NoMoreControllerException(std::wstring s) : DriverException(s) {};
};
-
-
-
class ControllerInfo;
-class ControllerPoolManager;
-
/**
* Abstract class over each policy implementation, which is used by the driver
* to choose a controller to connect to.
- * Contains a library-wide static list of controllers suspected of failure (not
- * visible from outside this class)
*/
class AbstractControllerPool
{
@@ -75,7 +68,7 @@
AbstractControllerPool(const std::vector<ControllerInfo>& controllerList,
long retryIntervalInMs = 0) throw (DriverException, UnexpectedException);
/**
- * Kills the controller ping thread and clear lists
+ * Clears list of controllers
*/
virtual ~AbstractControllerPool();
/**
@@ -87,32 +80,6 @@
virtual ControllerInfo getController() throw (NoMoreControllerException,
UnexpectedException) = 0;
/**
- * Tries to connect to each suspected controller with a non-blocking connect
- * and checks the connection state. In case of connection success, send the
- * ping command and remove the controller from the suspect list.
- * @param select_timeout number of milliseconds to wait for the controllers
to
- * respond to a ping connection attempt (default is 20ms)
- */
- static void updateSuspectList(int select_timeout = 20);
- /**
- * 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
- */
- static bool isSuspectedOfFailure(
- const ControllerInfo& controllerInfo);
- /**
- * Adds the given controller to the list of suspects. Note that this function
- * modifies the given controller info by setting the failure_number field !
- * @param controllerInfo the controller suspected of failure
- */
- void suspectControllerOfFailure(
- ControllerInfo& controllerInfo);
- /**
- * Gives the number of controller failures since this process started
- */
- static int getNumberOfFailures();
- /**
* Tells the pool that a new connection is using it
*/
void addRef() { ref_counter++; }
@@ -129,9 +96,7 @@
/** list of valid controllers */
std::vector<ControllerInfo> controller_list;
/** class-wide mutex */
- CriticalSection policy_CS;
- /** mutex on suspected controllers */
- static CriticalSection suspected_controllers_CS;
+ CriticalSection pool_CS;
private:
/** references counter managed by controller pool manager */
int ref_counter;
Index: carob/src/Connection.cpp
diff -u carob/src/Connection.cpp:1.84 carob/src/Connection.cpp:1.85
--- carob/src/Connection.cpp:1.84 Thu Aug 24 11:48:48 2006
+++ carob/src/Connection.cpp Fri Aug 25 19:56:56 2006
@@ -19,16 +19,18 @@
* Contributor(s): Marc Herbert, Zsolt Simon
*/
-#include "Connection.hpp"
+#include "ControllerPool.hpp"
+#include "ControllerPinger.hpp"
#include "DriverSocket.hpp"
-#include "ConnectionParameters.hpp"
-#include "ControllerPool.hpp"
+#include "Connection.hpp"
#include "Statement.hpp"
#include "ParameterStatement.hpp"
#include "TypeTag.hpp"
#include "Request.hpp"
#include "RequestWithResultSetParameters.hpp"
+
+#include "ConnectionParameters.hpp"
#include "CarobException.hpp"
#include <string>
@@ -104,14 +106,14 @@
//Do some clean up
delete driverSocketPtr; driverSocketPtr = NULL;
//suspect failing controller and try next one
- controller_pool.suspectControllerOfFailure(connected_controller);
+
ControllerPinger::getInstancePtr()->suspectControllerOfFailure(connected_controller);
}
catch (ConnectionException ce)
{
//Do some clean up
delete driverSocketPtr; driverSocketPtr = NULL;
//suspect failing controller and try next one
- controller_pool.suspectControllerOfFailure(connected_controller);
+
ControllerPinger::getInstancePtr()->suspectControllerOfFailure(connected_controller);
}
catch (NoMoreControllerException nmce)
{
@@ -1245,7 +1247,7 @@
// try to reconnect to the same controller if it has never been suspected of
// failure before
- if (!controller_pool.isSuspectedOfFailure(connected_controller))
+ if
(!ControllerPinger::getInstancePtr()->isSuspectedOfFailure(connected_controller))
{
try
{
@@ -1265,7 +1267,7 @@
if (isDebugEnabled())
logDebug(fctName, L"Controller " +
static_cast<wstring>(connected_controller)
+ L" is still not responding, suspecting it of failure");
- controller_pool.suspectControllerOfFailure(connected_controller);
+
ControllerPinger::getInstancePtr()->suspectControllerOfFailure(connected_controller);
try
{
if (isDebugEnabled())
Index: carob/src/ControllerPinger.cpp
diff -u /dev/null carob/src/ControllerPinger.cpp:1.1
--- /dev/null Fri Aug 25 19:56:56 2006
+++ carob/src/ControllerPinger.cpp Fri Aug 25 19:56:56 2006
@@ -0,0 +1,214 @@
+/*
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005-2006 Continuent, Inc.
+ * Contact: [EMAIL PROTECTED]
+ *
+ * Licensed 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.
+ *
+ * Initial developer(s): Gilles Rayrat
+ * Contributor(s): Marc Herbert, Zsolt Simon
+ */
+
+#include "ControllerPinger.hpp"
+#include "ConnectionParameters.hpp"
+#include "JavaSocket.hpp"
+#include "Common.hpp"
+#include "Connection.hpp"
+
+#include <vector>
+
+// library-wide objects
+namespace
+{
+ /**
+ * List of controllers suspected of failure.<br>
+ * This list is library-wide, shared by all clients (with a synchronization
+ * on <code>suspected_controllers_CS</code>)
+ */
+ std::vector<CarobNS::ControllerInfo> suspected_controllers;
+ /** mutex on suspected controllers */
+ CarobNS::CriticalSection suspected_controllers_CS;
+ /** # of controllers that have fail since this process has been created */
+ int controller_failure_number = 0;
+};
+
+using namespace CarobNS;
+using std::wstring;
+/**
+ * Utility struct to associate a controller to its ping socket. Used by #run()
+ */
+typedef struct
+{
+ ControllerInfo controllerInfo;
+ JavaSocket* pingSocketPtr;
+} SuspectController;
+
+// init instance only once
+ControllerPinger* ControllerPinger::unique_instance_ptr = NULL;
+
+/* static */
+ControllerPinger* ControllerPinger::getInstancePtr()
+{
+ if (unique_instance_ptr == NULL)
+ unique_instance_ptr = new ControllerPinger();
+ return unique_instance_ptr;
+}
+
+void ControllerPinger::suspectControllerOfFailure(
+ ControllerInfo& controllerInfoPrm)
+{
+ wstring fctName(L"ControllerPinger::suspectControllerOfFailure");
+
+ // First check that the controller is not already in the list of suspects
+ if (isSuspectedOfFailure(controllerInfoPrm))
+ return;
+
+ LockScope scLs(&suspected_controllers_CS);
+ //just for reporting (in the future ?)
+ controller_failure_number++;
+ // Add the controller (a copy of the given controller info) to the list
+ suspected_controllers.push_back(controllerInfoPrm);
+ if (isDebugEnabled())
+ logDebug(fctName, L"Controller " + static_cast<wstring>(controllerInfoPrm)
+ + L" is now suspected of failure (list size="
+ + toUserString(suspected_controllers.size())+L")");
+}
+
+bool ControllerPinger::isSuspectedOfFailure(const ControllerInfo&
controllerInfoPrm)
+{
+ // This is a good place to do the ping on suspected controllers, we are
+ // called by most of the functions in this class
+ run();
+ // Just compare controller info with each item in the whole list
+ for (std::vector<ControllerInfo>::const_iterator iter =
suspected_controllers.begin();
+ iter != suspected_controllers.end(); iter++)
+ {
+ if (*iter == controllerInfoPrm)
+ return true;
+ }
+ return false;
+}
+
+void ControllerPinger::removeControllerFromSuspectList(
+ const ControllerInfo& controllerInfoPrm)
+{
+ wstring fctName(L"ControllerPinger::removeControllerFromSuspectList");
+ LockScope scLs(&suspected_controllers_CS);
+
+ for (std::vector<ControllerInfo>::iterator iter =
suspected_controllers.begin();
+ iter != suspected_controllers.end(); iter++)
+ {
+ if (*iter == controllerInfoPrm)
+ {
+ suspected_controllers.erase(iter);
+ if (isDebugEnabled())
+ {
+ logDebug(fctName, L"Controller " +
static_cast<wstring>(controllerInfoPrm)
+ + L" has been removed from suspect list (new list size="
+ + toUserString(suspected_controllers.size())+L")");
+ }
+ return;
+ }
+ }
+ if (isWarnEnabled())
+ {
+ logWarn(fctName, L"Controller " + static_cast<wstring>(controllerInfoPrm)
+ + L" is not (anymore?) in the suspect list");
+ }
+}
+
+void ControllerPinger::run()
+{
+ wstring fctName(L"ControllerPinger::run");
+ if (suspected_controllers.size() < 1)
+ return;
+
+ LockScope scLs(&suspected_controllers_CS);
+
+ // list of suspected controllers we can connect to
+ std::vector<SuspectController> suspected_and_connected_controllers;
+ //create set of fds for polling
+ fd_set writableControllers;
+ FD_ZERO(&writableControllers);
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = select_timeout;
+ // fdMax is *not* the number of fds, but the maximum value of created sockets
+ int fdMax = -1;
+ // return of polling function
+ int retVal = 0;
+ // Ping each controller and add the ping socket in the set of fds for polling
+ for (std::vector<ControllerInfo>::iterator iter =
suspected_controllers.begin();
+ iter != suspected_controllers.end(); iter++)
+ {
+ SuspectController sc;
+ try
+ {
+ if (isDebugEnabled())
+ logDebug(fctName, L"Creating ping socket to suspected controller...");
+ // creates and prepares a new socket for pinging the controller
+ sc.pingSocketPtr = new JavaSocket();
+ sc.pingSocketPtr->create(false); //create non blocking
+ sc.controllerInfo = *iter;
+ //connect socket and add it to the list of fds
+ if (sc.pingSocketPtr->connectTo(iter->getHostName(),
iter->getHostPort()))
+ {
+ // no exception => add the controller to the suspects we are connected
to
+ suspected_and_connected_controllers.push_back(sc);
+ // add its socket to the polling set
+ int sock = sc.pingSocketPtr->getFd();
+ if (sock > fdMax)
+ fdMax = sock;
+ FD_SET(sock, &writableControllers);
+ }
+ }
+ catch (...)
+ {
+ delete sc.pingSocketPtr;
+ }
+ }
+ retVal = select(fdMax+1, NULL, &writableControllers, NULL, &tv);
+ if (retVal == -1)
+ {
+ if (isErrorEnabled())
+ {
+ logError(fctName, L"Select returned error #"+toUserString(errno));
+ }
+ return;
+ }
+ // if (retVal == 0) => timeout, no controller up again, do nothing
+ // If controllers are found up again, let's remove them from the list of
+ // suspects
+ if (retVal > 0)
+ {
+ // iterates through controller list to find the ones that are up again
+ for (std::vector<SuspectController>::iterator iter =
suspected_and_connected_controllers.begin();
+ iter != suspected_and_connected_controllers.end(); iter++)
+ {
+ if (FD_ISSET(iter->pingSocketPtr->getFd(), &writableControllers))
+ {
+ // send ping command, upon wich controller closes its connection with
+ // the client that issued this ping
+ iter->pingSocketPtr->writeJavaInt(Ping);
+ removeControllerFromSuspectList(iter->controllerInfo);
+ }
+ delete iter->pingSocketPtr; //free the ping socket
+ }
+ }
+}
+
+/*static*/
+int ControllerPinger::getNumberOfFailures()
+{
+ return controller_failure_number;
+}
Index: carob/src/ControllerPool.cpp
diff -u carob/src/ControllerPool.cpp:1.5 carob/src/ControllerPool.cpp:1.6
--- carob/src/ControllerPool.cpp:1.5 Fri Aug 25 15:53:09 2006
+++ carob/src/ControllerPool.cpp Fri Aug 25 19:56:56 2006
@@ -21,6 +21,7 @@
#include "ControllerPool.hpp"
+#include "ControllerPinger.hpp"
#include "JavaSocket.hpp"
#include "Connection.hpp"
@@ -34,24 +35,6 @@
using namespace CarobNS;
-CriticalSection AbstractControllerPool::suspected_controllers_CS;
-
-typedef struct
-{
- ControllerInfo controllerInfo;
- JavaSocket* pingSocketPtr;
-} SuspectController;
-
-/** Utility typedef to have a short name for suspect_list content type */
-typedef std::vector<SuspectController> SuspectList;
-/** The list of suspected controllers (static => per process) */
-namespace
-{
- /** list of controllers suspected of failure */
- SuspectList suspected_controllers;
- /** # of controllers that have fail since this process has been created */
- int controller_failure_number = 0;
-};
/* Pool index less than operator */
bool ltPoolIndex::operator()(const PoolIndex& pi1, const PoolIndex& pi2) const
@@ -97,151 +80,9 @@
AbstractControllerPool::~AbstractControllerPool()
{
- for (SuspectList::iterator iter = suspected_controllers.begin();
- iter != suspected_controllers.end(); iter++)
- {
- delete (*iter).pingSocketPtr; //free the ping sockets
- }
- suspected_controllers.clear();
controller_list.clear();
}
-/*static*/
-void AbstractControllerPool::updateSuspectList(int select_timeout /* = 20 */)
-{
- wstring fctName(L"AbstractControllerPool::updateSuspectList");
- if (suspected_controllers.size() < 1)
- return;
-
- LockScope scLs(&suspected_controllers_CS);
- //create set of fds for polling
- fd_set writableControllers;
- FD_ZERO(&writableControllers);
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = select_timeout;
- // fdMax is *not* the number of fds, but the maximum value of created sockets
- int fdMax = -1;
- // return of polling function
- int retVal = 0;
- // Ping each controller and add the ping socket in the set of fds for polling
- for (SuspectList::iterator iter = suspected_controllers.begin();
- iter != suspected_controllers.end(); iter++)
- {
- try
- {
- //connect socket and add it to the list of fds
- if
((*iter).pingSocketPtr->connectTo((*iter).controllerInfo.getHostName(),
-
(*iter).controllerInfo.getHostPort()))
- {
- int sock = (*iter).pingSocketPtr->getFd();
- if (sock > fdMax)
- fdMax = sock;
- FD_SET(sock, &writableControllers);
- }
- }
- catch (...){}
- }
- retVal = select(fdMax+1, NULL, &writableControllers, NULL, &tv);
- if (retVal == -1)
- {
- if (isErrorEnabled())
- {
- logError(fctName, L"Select returned error #"+toUserString(errno));
- }
- return;
- }
- // if (retVal == 0) => timeout, no controller up again, do nothing
- // If controllers are found up again, let's remove them from the list of
- // suspects
- if (retVal > 0)
- {
- SuspectList::iterator iter = suspected_controllers.begin();
- // iterates through controller list to find those that are up again
- while (iter != suspected_controllers.end())
- {
- if (FD_ISSET((*iter).pingSocketPtr->getFd(), &writableControllers))
- {
- // send ping command, upon wich controller closes its connection with
- // the client that issued this ping
- (*iter).pingSocketPtr->writeJavaInt(Ping);
- delete (*iter).pingSocketPtr; //free the ping socket
- suspected_controllers.erase(iter);
- if (isDebugEnabled())
- {
- logDebug(fctName, L"Controller " +
static_cast<wstring>(iter->controllerInfo)
- + L" found up again. It has been removed from suspect list (new"
- + L" list size=" + toUserString(suspected_controllers.size()) +
L")");
- }
- }
- else
- {
- // increment iterator only if it has not been erase, because when the
- // erase() function returns, it makes the given iterator point to the
- // next element, immediatly following the one that has been removed
- iter++;
- }
- }
- }
-}
-
-/*static*/
-bool AbstractControllerPool::isSuspectedOfFailure(
- const ControllerInfo& controllerInfo)
-{
- // This is a good place to do the ping on suspected controllers, we are
- // called by most of the functions in this class
- updateSuspectList();
- // Just compare controller info with each item in the whole list
- for (SuspectList::const_iterator iter = suspected_controllers.begin();
- iter != suspected_controllers.end(); iter++)
- {
- if ((*iter).controllerInfo == controllerInfo)
- return true;
- }
- return false;
-}
-
-void AbstractControllerPool::suspectControllerOfFailure(
- ControllerInfo& controllerInfo)
-{
- wstring fctName(L"AbstractControllerPool::suspectControllerOfFailure");
-
- // First check that the controller is not already in the list of suspects
- if (isSuspectedOfFailure(controllerInfo))
- return;
-
- // Add it to the list
- for (size_t i = 0; i < controller_list.size(); i++)
- {
- if (controllerInfo == controller_list[i])
- {
- LockScope scLs(&suspected_controllers_CS);
- //just for reporting (in the future ?)
- controller_failure_number++;
- SuspectController newSuspect;
- newSuspect.controllerInfo = controllerInfo;
- if (isDebugEnabled())
- logDebug(fctName, L"Creating ping socket to suspected controller...");
- // creates and prepares a new socket for pinging the controller
- newSuspect.pingSocketPtr = new JavaSocket();
- newSuspect.pingSocketPtr->create(false); //create non blocking
- //add the controller and its socket to the list
- suspected_controllers.push_back(newSuspect);
- if (isDebugEnabled())
- logDebug(fctName, L"Controller " + static_cast<wstring>(controllerInfo)
- + L" is now suspected of failure (list size="
- + toUserString(suspected_controllers.size())+L")");
- return;
- }
- }
-}
-
-/*static*/
-int AbstractControllerPool::getNumberOfFailures()
-{
- return controller_failure_number;
-}
AbstractControllerPool::operator wstring() const
{
@@ -271,15 +112,15 @@
{
wstring fctName(L"RoundRobinControllerPool::getController");
- LockScope ls(&policy_CS);
+ LockScope ls(&pool_CS);
{
- LockScope scLs(&suspected_controllers_CS);
unsigned int testedControllers = 0; //unsigned because we compare it to
vector.size()
bool lastTestedControllerWasSuspect = false;
do
{
index = (index + 1) % controller_list.size();
- lastTestedControllerWasSuspect =
isSuspectedOfFailure(controller_list[index]);
+ lastTestedControllerWasSuspect =
+
ControllerPinger::getInstancePtr()->isSuspectedOfFailure(controller_list[index]);
testedControllers++;
}
while (lastTestedControllerWasSuspect
@@ -288,7 +129,7 @@
if (lastTestedControllerWasSuspect)
{
throw NoMoreControllerException(L"All "
- +
toUserString(suspected_controllers.size())
+ + toUserString(controller_list.size())
+ L" controllers down");
}
}
Index: carob/test/10-Connection/TestControllerPool.cpp
diff -u carob/test/10-Connection/TestControllerPool.cpp:1.2
carob/test/10-Connection/TestControllerPool.cpp:1.3
--- carob/test/10-Connection/TestControllerPool.cpp:1.2 Fri Aug 25 15:53:09 2006
+++ carob/test/10-Connection/TestControllerPool.cpp Fri Aug 25 19:56:56 2006
@@ -25,6 +25,7 @@
#include "../ConnectionSetup.hpp"
#include "ControllerPool.hpp"
+#include "ControllerPinger.hpp"
#include "Statement.hpp"
#include "Connection.hpp"
@@ -62,8 +63,8 @@
RoundRobinControllerPool cp(v);
CPPUNIT_ASSERT(cp.getController() == c1);
- cp.suspectControllerOfFailure(c2);
- cp.suspectControllerOfFailure(c4);
+ ControllerPinger::getInstancePtr()->suspectControllerOfFailure(c2);
+ ControllerPinger::getInstancePtr()->suspectControllerOfFailure(c4);
CPPUNIT_ASSERT(cp.getController() == c3);
CPPUNIT_ASSERT(cp.getController() == c1);
}
@@ -84,10 +85,10 @@
v.push_back(c4);
RoundRobinControllerPool cp(v);
- cp.suspectControllerOfFailure(c1);
- cp.suspectControllerOfFailure(c2);
- cp.suspectControllerOfFailure(c3);
- cp.suspectControllerOfFailure(c4);
+ ControllerPinger::getInstancePtr()->suspectControllerOfFailure(c1);
+ ControllerPinger::getInstancePtr()->suspectControllerOfFailure(c2);
+ ControllerPinger::getInstancePtr()->suspectControllerOfFailure(c3);
+ ControllerPinger::getInstancePtr()->suspectControllerOfFailure(c4);
try
{
@@ -123,11 +124,11 @@
v.push_back(c4);
RoundRobinControllerPool cp(v);
- cp.suspectControllerOfFailure(c1);
- cp.suspectControllerOfFailure(c2);
+ ControllerPinger::getInstancePtr()->suspectControllerOfFailure(c1);
+ ControllerPinger::getInstancePtr()->suspectControllerOfFailure(c2);
CPPUNIT_ASSERT(cp.getController() == c3);
CPPUNIT_ASSERT(cp.getController() == c4);
- cp.updateSuspectList();
+ ControllerPinger::getInstancePtr()->run();
CPPUNIT_ASSERT(cp.getController() == c1);
CPPUNIT_ASSERT(cp.getController() == c2);
}
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits