NCBI C++ ToolKit
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CDBUDRandomMapper Class Reference

Search Toolkit Book for CDBUDRandomMapper

CDBUDRandomMapper. More...

#include <dbapi/driver/dbapi_svc_mapper.hpp>

+ Inheritance diagram for CDBUDRandomMapper:
+ Collaboration diagram for CDBUDRandomMapper:

Classes

struct  SPreferences
 

Public Member Functions

 CDBUDRandomMapper (const IRegistry *registry=NULL)
 
virtual ~CDBUDRandomMapper (void)
 
virtual string GetName (void) const
 
virtual void Configure (const IRegistry *registry=NULL)
 
virtual TSvrRef GetServer (const string &service)
 Map a service to a server. More...
 
virtual void Exclude (const string &service, const TSvrRef &server)
 Exclude a server from the mapping for a service. More...
 
virtual void CleanExcluded (const string &service)
 Clean the list of excluded servers for the given service. More...
 
virtual bool HasExclusions (const string &service) const
 
virtual void SetPreference (const string &service, const TSvrRef &preferred_server, double preference=100.0)
 Set up mapping preferences for a service preference - value between 0 and 100 (0 means *no particular preferances*, 100 means *do not choose, just use a given server*) preferred_server - preferred server. More...
 
virtual void GetServerOptions (const string &service, TOptions *options)
 Get an annotated list of all servers for the given service. More...
 
void Add (const string &service, const TSvrRef &server, double preference=0.0)
 
- Public Member Functions inherited from IDBServiceMapper
virtual ~IDBServiceMapper (void)
 
virtual void GetServersList (const string &, list< string > *serv_list) const
 Get list of all servers for the given service disregarding any exclusions. More...
 
virtual bool RecordServer (I_ConnectionExtra &) const
 Given a connection that succeeded even though this service mapper was unable to identify a good server beforehand, try to determine which server it actually reached on the basis of its low-level handle (if available); on success, pass the result to its x_RecordServer method to inform subsequent logging. More...
 
- Public Member Functions inherited from CObject
 CObject (void)
 Constructor. More...
 
 CObject (const CObject &src)
 Copy constructor. More...
 
virtual ~CObject (void)
 Destructor. More...
 
CObjectoperator= (const CObject &src) THROWS_NONE
 Assignment operator. More...
 
bool CanBeDeleted (void) const THROWS_NONE
 Check if object can be deleted. More...
 
bool IsAllocatedInPool (void) const THROWS_NONE
 Check if object is allocated in memory pool (not system heap) More...
 
bool Referenced (void) const THROWS_NONE
 Check if object is referenced. More...
 
bool ReferencedOnlyOnce (void) const THROWS_NONE
 Check if object is referenced only once. More...
 
void AddReference (void) const
 Add reference to object. More...
 
void RemoveReference (void) const
 Remove reference to object. More...
 
void ReleaseReference (void) const
 Remove reference without deleting object. More...
 
virtual void DoNotDeleteThisObject (void)
 Mark this object as not allocated in heap – do not delete this object. More...
 
virtual void DoDeleteThisObject (void)
 Mark this object as allocated in heap – object can be deleted. More...
 
void * operator new (size_t size)
 Define new operator for memory allocation. More...
 
void * operator new[] (size_t size)
 Define new[] operator for 'array' memory allocation. More...
 
void operator delete (void *ptr)
 Define delete operator for memory deallocation. More...
 
void operator delete[] (void *ptr)
 Define delete[] operator for memory deallocation. More...
 
void * operator new (size_t size, void *place)
 Define new operator. More...
 
void operator delete (void *ptr, void *place)
 Define delete operator. More...
 
void * operator new (size_t size, CObjectMemoryPool *place)
 Define new operator using memory pool. More...
 
void operator delete (void *ptr, CObjectMemoryPool *place)
 Define delete operator. More...
 
virtual void DebugDump (CDebugDumpContext ddc, unsigned int depth) const
 Define method for dumping debug information. More...
 
- Public Member Functions inherited from CDebugDumpable
 CDebugDumpable (void)
 
virtual ~CDebugDumpable (void)
 
void DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const
 
void DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const
 
void DumpToConsole (void) const
 

Static Public Member Functions

static IDBServiceMapperFactory (const IRegistry *registry)
 
- Static Public Member Functions inherited from CObject
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (void)
 Define method to throw null pointer exception. More...
 
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (const type_info &type)
 
static EAllocFillMode GetAllocFillMode (void)
 
static void SetAllocFillMode (EAllocFillMode mode)
 
static void SetAllocFillMode (const string &value)
 Set mode from configuration parameter value. More...
 
- Static Public Member Functions inherited from CDebugDumpable
static void EnableDebugDump (bool on)
 

Protected Member Functions

void ConfigureFromRegistry (const IRegistry *registry=NULL)
 
- Protected Member Functions inherited from CObject
virtual void DeleteThis (void)
 Virtual method "deleting" this object. More...
 

Private Types

typedef map< string, boolTLBNameMap
 
typedef map< string, TOptionsTServiceMap
 
typedef map< string, SPreferencesTPreferenceMap
 

Private Member Functions

void x_RecalculatePreferences (const string &service)
 

Private Attributes

TLBNameMap m_LBNameMap
 
TServiceMap m_ServerMap
 
TServiceMap m_FavoritesMap
 
TPreferenceMap m_PreferenceMap
 
default_random_engine m_RandomEngine
 

Additional Inherited Members

- Public Types inherited from IDBServiceMapper
typedef IDBServiceMapper *(* TFactory) (const IRegistry *registry)
 
typedef list< CRef< CDBServerOption > > TOptions
 
- Public Types inherited from CObject
enum  EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern }
 Control filling of newly allocated memory. More...
 
typedef CObjectCounterLocker TLockerType
 Default locker type for CRef. More...
 
typedef atomic< Uint8TCounter
 Counter type is CAtomiCounter. More...
 
typedef Uint8 TCount
 Alias for value type of counter. More...
 
- Static Public Attributes inherited from CObject
static const TCount eCounterBitsCanBeDeleted = 1 << 0
 Define possible object states. More...
 
static const TCount eCounterBitsInPlainHeap = 1 << 1
 Heap signature was found. More...
 
static const TCount eCounterBitsPlaceMask
 Mask for 'in heap' state flags. More...
 
static const int eCounterStep = 1 << 2
 Skip over the "in heap" bits. More...
 
static const TCount eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2)
 Minimal value for valid objects (reference counter is zero) Must be a single bit value. More...
 
static const TCount eCounterStateMask
 Valid object, and object in heap. More...
 
- Protected Types inherited from IDBServiceMapper
typedef set< TSvrRef, SDereferenceLessTSrvSet
 
typedef map< string, TSrvSetTExcludeMap
 
- Static Protected Member Functions inherited from IDBServiceMapper
static void x_RecordServer (I_ConnectionExtra &extra, CDBServer &server)
 
- Protected Attributes inherited from IDBServiceMapper
CFastMutex m_Mtx
 
TExcludeMap m_ExcludeMap
 

Detailed Description

CDBUDRandomMapper.

Definition at line 114 of file dbapi_svc_mapper.hpp.

Member Typedef Documentation

◆ TLBNameMap

Definition at line 150 of file dbapi_svc_mapper.hpp.

◆ TPreferenceMap

Definition at line 152 of file dbapi_svc_mapper.hpp.

◆ TServiceMap

Definition at line 151 of file dbapi_svc_mapper.hpp.

Constructor & Destructor Documentation

◆ CDBUDRandomMapper()

CDBUDRandomMapper::CDBUDRandomMapper ( const IRegistry registry = NULL)

Definition at line 320 of file dbapi_svc_mapper.cpp.

References ConfigureFromRegistry(), m_RandomEngine, and registry.

Referenced by Factory().

◆ ~CDBUDRandomMapper()

CDBUDRandomMapper::~CDBUDRandomMapper ( void  )
virtual

Definition at line 327 of file dbapi_svc_mapper.cpp.

Member Function Documentation

◆ Add()

void CDBUDRandomMapper::Add ( const string service,
const TSvrRef server,
double  preference = 0.0 
)

◆ CleanExcluded()

void CDBUDRandomMapper::CleanExcluded ( const string service)
virtual

Clean the list of excluded servers for the given service.

Reimplemented from IDBServiceMapper.

Definition at line 466 of file dbapi_svc_mapper.cpp.

References map_checker< Container >::end(), map_checker< Container >::find(), IDBServiceMapper::m_Mtx, m_ServerMap, and x_RecalculatePreferences().

◆ Configure()

void CDBUDRandomMapper::Configure ( const IRegistry registry = NULL)
virtual

Implements IDBServiceMapper.

Definition at line 337 of file dbapi_svc_mapper.cpp.

References ConfigureFromRegistry(), IDBServiceMapper::m_Mtx, and registry.

◆ ConfigureFromRegistry()

void CDBUDRandomMapper::ConfigureFromRegistry ( const IRegistry registry = NULL)
protected

◆ Exclude()

void CDBUDRandomMapper::Exclude ( const string service,
const TSvrRef server 
)
virtual

Exclude a server from the mapping for a service.

Note
Classes that override this method should either override GetServerOptions too or chain to the base implementation (and have CleanExcluded do the same!)

Reimplemented from IDBServiceMapper.

Definition at line 451 of file dbapi_svc_mapper.cpp.

References map_checker< Container >::end(), map_checker< Container >::find(), CDBServerOption::fState_Excluded, IDBServiceMapper::m_Mtx, m_ServerMap, and x_RecalculatePreferences().

◆ Factory()

IDBServiceMapper * CDBUDRandomMapper::Factory ( const IRegistry registry)
static

Definition at line 539 of file dbapi_svc_mapper.cpp.

References CDBUDRandomMapper(), and registry.

◆ GetName()

string CDBUDRandomMapper::GetName ( void  ) const
virtual

Reimplemented from IDBServiceMapper.

Definition at line 331 of file dbapi_svc_mapper.cpp.

References CDBServiceMapperTraits< T >::GetName().

◆ GetServer()

TSvrRef CDBUDRandomMapper::GetServer ( const string service)
virtual

◆ GetServerOptions()

void CDBUDRandomMapper::GetServerOptions ( const string service,
TOptions options 
)
virtual

Get an annotated list of all servers for the given service.

The default implementation just pads out the results of calling GetServersList, which predates this method and as such is likelier to be defined by derived classes.

Reimplemented from IDBServiceMapper.

Definition at line 527 of file dbapi_svc_mapper.cpp.

References map_checker< Container >::end(), map_checker< Container >::find(), IDBServiceMapper::m_Mtx, and m_ServerMap.

◆ HasExclusions()

bool CDBUDRandomMapper::HasExclusions ( const string service) const
virtual

◆ SetPreference()

void CDBUDRandomMapper::SetPreference ( const string service,
const TSvrRef preferred_server,
double  preference = 100.0 
)
virtual

Set up mapping preferences for a service preference - value between 0 and 100 (0 means *no particular preferances*, 100 means *do not choose, just use a given server*) preferred_server - preferred server.

Implements IDBServiceMapper.

Definition at line 498 of file dbapi_svc_mapper.cpp.

References map_checker< Container >::end(), map_checker< Container >::erase(), map_checker< Container >::find(), m_FavoritesMap, IDBServiceMapper::m_Mtx, m_ServerMap, max(), min(), and x_RecalculatePreferences().

◆ x_RecalculatePreferences()

void CDBUDRandomMapper::x_RecalculatePreferences ( const string service)
private

Member Data Documentation

◆ m_FavoritesMap

TServiceMap CDBUDRandomMapper::m_FavoritesMap
private

◆ m_LBNameMap

TLBNameMap CDBUDRandomMapper::m_LBNameMap
private

Definition at line 154 of file dbapi_svc_mapper.hpp.

Referenced by ConfigureFromRegistry(), and GetServer().

◆ m_PreferenceMap

TPreferenceMap CDBUDRandomMapper::m_PreferenceMap
private

◆ m_RandomEngine

default_random_engine CDBUDRandomMapper::m_RandomEngine
private

Definition at line 158 of file dbapi_svc_mapper.hpp.

Referenced by CDBUDRandomMapper(), and GetServer().

◆ m_ServerMap

TServiceMap CDBUDRandomMapper::m_ServerMap
private

The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:58:30 2024 by modify_doxy.py rev. 669887