#include <ControllerPool.hpp>
Inheritance diagram for CarobNS::AbstractControllerPool:
Public Member Functions | |
AbstractControllerPool (const std::vector< ControllerInfo > &controllerList, int pingDelayInMs, int controllerTimeoutInMs) throw (DriverException, UnexpectedException) | |
Unique constructor. | |
virtual | ~AbstractControllerPool () |
Clears list of controllers. | |
virtual ControllerInfo | getController ()=0 throw (NoMoreControllerException, UnexpectedException) |
Gets a controller using the implementation specific policy. | |
int | numberOfAliveControllers () |
Gets the number of controllers still known to be alive. | |
DriverSocket * | newRegisteredSocket (const ControllerInfo &controller) throw (ConnectionException) |
Registers the given socket to the callback so it can kill this socket when the controller is detected as failed. | |
void | deleteRegisteredSocket (DriverSocket *socket) |
Unregisters the given socket from the callback so it can no more be killed or deleted. | |
void | forceControllerDown (const ControllerInfo &controller) |
Tell the watcher that a failure has been detected on the given controller. | |
void | controllerDown (const ControllerInfo &controller) |
Removes this controller from the list of alive ones. | |
void | controllerUp (const ControllerInfo &controller) |
Adds the specified controller to the list of alive ones. | |
void | setVdbDownOnController (const ControllerInfo &controller) |
Informs that the given controller's vdb is no more available. | |
bool | isVdbUpOnController (const ControllerInfo &controller) |
Tells if the given controller VDB is available. | |
CriticalSection & | getLock () |
Gets a reference to the lock object used in this class. | |
operator std::wstring () | |
Display useful info in a string. | |
Protected Member Functions | |
void | addRef () |
Tells the pool that a new connection is using it. | |
int | removeRef () |
Tells the pool that one of its 'user' (ie. | |
int | getRefCount () |
Retrieves the number of references left on this instance. | |
int64_t | getLastTimeZeroRef () |
Returns the last time the number of references was decreased to zero. | |
Protected Attributes | |
std::vector< ControllerAndVdbState > | alive_controllers |
Up-to-date list of controllers that respond to pings. | |
CriticalSection | pool_CS |
Mutex on alive controllers. | |
Friends | |
class | ControllerPoolManager |
CarobNS::AbstractControllerPool::AbstractControllerPool | ( | const std::vector< ControllerInfo > & | controllerList, | |
int | pingDelayInMs, | |||
int | controllerTimeoutInMs | |||
) | throw (DriverException, UnexpectedException) |
Unique constructor.
controllerList | the controller list on which the policy applies | |
pingDelayInMs | Interval in milliseconds between two pings of a controller | |
controllerTimeoutInMs | timeout in milliseconds after which a controller is considered as dead if it did not respond to pings |
void CarobNS::AbstractControllerPool::controllerDown | ( | const ControllerInfo & | controller | ) |
Removes this controller from the list of alive ones.
Warning: This function should never be called directly, only the callback should make us of this.
controller | the suspect controller |
void CarobNS::AbstractControllerPool::controllerUp | ( | const ControllerInfo & | controller | ) |
Adds the specified controller to the list of alive ones.
Warning: This function should never be called directly, only the callback should make us of this.
controller | the controller that came back |
void CarobNS::AbstractControllerPool::deleteRegisteredSocket | ( | DriverSocket * | socket | ) |
Unregisters the given socket from the callback so it can no more be killed or deleted.
To be used when socket creation or connection failed
socket | the socket to unregister |
void CarobNS::AbstractControllerPool::forceControllerDown | ( | const ControllerInfo & | controller | ) |
Tell the watcher that a failure has been detected on the given controller.
This function should be called when a connection error occurs on the given controller
controller | the controller suspected of failure |
virtual ControllerInfo CarobNS::AbstractControllerPool::getController | ( | ) | throw (NoMoreControllerException, UnexpectedException) [pure virtual] |
Gets a controller using the implementation specific policy.
ControllerInfo
of the selected controller NoMoreControllerException | if no controller in the controller list is reachable |
Implemented in CarobNS::RoundRobinControllerPool.
CriticalSection& CarobNS::AbstractControllerPool::getLock | ( | ) | [inline] |
Gets a reference to the lock object used in this class.
bool CarobNS::AbstractControllerPool::isVdbUpOnController | ( | const ControllerInfo & | controller | ) |
Tells if the given controller VDB is available.
controller | the controller to check for vdb state |
DriverSocket* CarobNS::AbstractControllerPool::newRegisteredSocket | ( | const ControllerInfo & | controller | ) | throw (ConnectionException) |
Registers the given socket to the callback so it can kill this socket when the controller is detected as failed.
controller | the controller to which the socket is connected |
int CarobNS::AbstractControllerPool::numberOfAliveControllers | ( | ) |
Gets the number of controllers still known to be alive.
int CarobNS::AbstractControllerPool::removeRef | ( | ) | [protected] |
Tells the pool that one of its 'user' (ie.
connection) doesn't use it anymore, and return the new number of references
void CarobNS::AbstractControllerPool::setVdbDownOnController | ( | const ControllerInfo & | controller | ) |
Informs that the given controller's vdb is no more available.
controller | the controller set vdb to down |