NCBI C++ ToolKit
|
Search Toolkit Book for CDBUDRandomMapper
#include <dbapi/driver/dbapi_svc_mapper.hpp>
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... | |
CObject & | operator= (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 IDBServiceMapper * | Factory (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, bool > | TLBNameMap |
typedef map< string, TOptions > | TServiceMap |
typedef map< string, SPreferences > | TPreferenceMap |
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< Uint8 > | TCounter |
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, SDereferenceLess > | TSrvSet |
typedef map< string, TSrvSet > | TExcludeMap |
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 |
Definition at line 114 of file dbapi_svc_mapper.hpp.
|
private |
Definition at line 150 of file dbapi_svc_mapper.hpp.
|
private |
Definition at line 152 of file dbapi_svc_mapper.hpp.
|
private |
Definition at line 151 of file dbapi_svc_mapper.hpp.
Definition at line 320 of file dbapi_svc_mapper.cpp.
References ConfigureFromRegistry(), m_RandomEngine, and registry.
Referenced by Factory().
|
virtual |
Definition at line 327 of file dbapi_svc_mapper.cpp.
void CDBUDRandomMapper::Add | ( | const string & | service, |
const TSvrRef & | server, | ||
double | preference = 0.0 |
||
) |
Definition at line 423 of file dbapi_svc_mapper.cpp.
References _ASSERT, CRef< C, Locker >::Empty(), CDBServer::GetHost(), CDBServer::GetName(), CDBServer::GetPort(), m_FavoritesMap, m_ServerMap, option, and x_RecalculatePreferences().
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().
Implements IDBServiceMapper.
Definition at line 337 of file dbapi_svc_mapper.cpp.
References ConfigureFromRegistry(), IDBServiceMapper::m_Mtx, and registry.
Definition at line 345 of file dbapi_svc_mapper.cpp.
References map_checker< Container >::clear(), entries, IRegistry::EnumerateEntries(), NStr::fSplit_MergeDelimiters, CNcbiApplicationAPI::GetConfig(), IRegistry::GetString(), CNcbiApplication::Instance(), ITERATE, m_FavoritesMap, m_LBNameMap, m_PreferenceMap, m_ServerMap, make_server(), registry, NStr::Split(), and x_RecalculatePreferences().
Referenced by CDBUDRandomMapper(), and Configure().
Exclude a server from the mapping for a service.
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().
|
static |
Definition at line 539 of file dbapi_svc_mapper.cpp.
References CDBUDRandomMapper(), and registry.
|
virtual |
Reimplemented from IDBServiceMapper.
Definition at line 331 of file dbapi_svc_mapper.cpp.
References CDBServiceMapperTraits< T >::GetName().
Map a service to a server.
Implements IDBServiceMapper.
Definition at line 401 of file dbapi_svc_mapper.cpp.
References map_checker< Container >::end(), map_checker< Container >::find(), m_LBNameMap, IDBServiceMapper::m_Mtx, m_PreferenceMap, and m_RandomEngine.
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.
Reimplemented from IDBServiceMapper.
Definition at line 479 of file dbapi_svc_mapper.cpp.
References map_checker< Container >::end(), map_checker< Container >::find(), IDBServiceMapper::m_Mtx, m_PreferenceMap, and m_ServerMap.
|
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().
Definition at line 545 of file dbapi_svc_mapper.cpp.
References _ASSERT, CDBUDRandomMapper::SPreferences::distribution, map_checker< Container >::end(), map_checker< Container >::find(), m_FavoritesMap, m_PreferenceMap, m_ServerMap, REVERSE_ITERATE, CDBUDRandomMapper::SPreferences::servers, and weight.
Referenced by Add(), CleanExcluded(), ConfigureFromRegistry(), Exclude(), and SetPreference().
|
private |
Definition at line 156 of file dbapi_svc_mapper.hpp.
Referenced by Add(), ConfigureFromRegistry(), SetPreference(), and x_RecalculatePreferences().
|
private |
Definition at line 154 of file dbapi_svc_mapper.hpp.
Referenced by ConfigureFromRegistry(), and GetServer().
|
private |
Definition at line 157 of file dbapi_svc_mapper.hpp.
Referenced by ConfigureFromRegistry(), GetServer(), HasExclusions(), and x_RecalculatePreferences().
|
private |
Definition at line 158 of file dbapi_svc_mapper.hpp.
Referenced by CDBUDRandomMapper(), and GetServer().
|
private |
Definition at line 155 of file dbapi_svc_mapper.hpp.
Referenced by Add(), CleanExcluded(), ConfigureFromRegistry(), Exclude(), GetServerOptions(), HasExclusions(), SetPreference(), and x_RecalculatePreferences().