CarobNS::AbstractControllerPool Class Reference

Abstract class over each policy implementation, which is used by the driver to choose a controller to connect to. More...

#include <ControllerPool.hpp>

Inheritance diagram for CarobNS::AbstractControllerPool:

CarobNS::RoundRobinControllerPool List of all members.

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.
DriverSocketnewRegisteredSocket (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.
CriticalSectiongetLock ()
 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< ControllerAndVdbStatealive_controllers
 Up-to-date list of controllers that respond to pings.
CriticalSection pool_CS
 Mutex on alive controllers.

Friends

class ControllerPoolManager

Detailed Description

Abstract class over each policy implementation, which is used by the driver to choose a controller to connect to.


Constructor & Destructor Documentation

CarobNS::AbstractControllerPool::AbstractControllerPool ( const std::vector< ControllerInfo > &  controllerList,
int  pingDelayInMs,
int  controllerTimeoutInMs 
) throw (DriverException, UnexpectedException)

Unique constructor.

Parameters:
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


Member Function Documentation

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.

Parameters:
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.

Parameters:
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

Parameters:
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

Parameters:
controller the controller suspected of failure

virtual ControllerInfo CarobNS::AbstractControllerPool::getController (  )  throw (NoMoreControllerException, UnexpectedException) [pure virtual]

Gets a controller using the implementation specific policy.

Returns:
ControllerInfo of the selected controller
Exceptions:
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.

See also:
void Connection::initConnection()

bool CarobNS::AbstractControllerPool::isVdbUpOnController ( const ControllerInfo controller  ) 

Tells if the given controller VDB is available.


Parameters:
controller the controller to check for vdb state
Returns:
false if the lastVdbFailure associated to the given controller is not older than ??? milliseconds, true otherwise

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.

Parameters:
controller the controller to which the socket is connected
Returns:
the registered socket

int CarobNS::AbstractControllerPool::numberOfAliveControllers (  ) 

Gets the number of controllers still known to be alive.

Returns:
the number of alive controllers

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.

Parameters:
controller the controller set vdb to down


The documentation for this class was generated from the following file:
Generated on Fri Mar 9 17:40:20 2007 for Carob by  doxygen 1.4.7