NCBI C++ ToolKit
|
Search Toolkit Book for CDBLB_ServiceMapper
CDBLBServerNamePolicy. More...
#include <connect/ext/ncbi_dblb_svcmapper.hpp>
Public Member Functions | |
CDBLB_ServiceMapper (const IRegistry *registry=NULL) | |
virtual | ~CDBLB_ServiceMapper (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 | GetServersList (const string &service, list< string > *serv_list) const |
Get list of all servers for the given service disregarding any exclusions. More... | |
virtual void | GetServerOptions (const string &service, TOptions *options) |
Get an annotated list of all servers for the given service. More... | |
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 bool | RecordServer (I_ConnectionExtra &extra) 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 IDBServiceMapper | |
virtual | ~IDBServiceMapper (void) |
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 |
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... | |
Protected Member Functions inherited from CConnIniter | |
CConnIniter (void) | |
Private Types | |
typedef map< string, pair< TSERV_Type, time_t > > | TLBEmptyMap |
typedef map< string, pair< double, TSvrRef > > | TPreferenceMap |
Private Member Functions | |
TSvrRef | x_GetServer (const string &service) |
bool | x_IsEmpty (const string &service, TSERV_Type promiscuity, time_t now) |
Private Attributes | |
TLBEmptyMap | m_LBEmptyMap |
TPreferenceMap | m_PreferenceMap |
int | m_EmptyTTL |
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 |
CDBLBServerNamePolicy.
Definition at line 51 of file ncbi_dblb_svcmapper.hpp.
|
private |
Definition at line 78 of file ncbi_dblb_svcmapper.hpp.
|
private |
Definition at line 79 of file ncbi_dblb_svcmapper.hpp.
Definition at line 71 of file ncbi_dblb_svcmapper.cpp.
References ConfigureFromRegistry(), and registry.
Referenced by Factory().
|
virtual |
Definition at line 77 of file ncbi_dblb_svcmapper.cpp.
Implements IDBServiceMapper.
Definition at line 89 of file ncbi_dblb_svcmapper.cpp.
References ConfigureFromRegistry(), IDBServiceMapper::m_Mtx, and registry.
Definition at line 98 of file ncbi_dblb_svcmapper.cpp.
References CTempString::empty(), IRegistry::EnumerateEntries(), NStr::fSplit_MergeDelimiters, IRegistry::Get(), CNcbiApplicationAPI::GetConfig(), CSocketAPI::gethostbyname(), IRegistry::GetInt(), CNcbiApplicationAPI::InstanceGuard(), m_EmptyTTL, registry, SetPreference(), NStr::SplitInTwo(), NStr::StringToDouble(), and NStr::StringToNumeric().
Referenced by CDBLB_ServiceMapper(), and Configure().
|
static |
Definition at line 490 of file ncbi_dblb_svcmapper.cpp.
References CDBLB_ServiceMapper(), and registry.
Referenced by MakeCDBUniversalMapper().
|
virtual |
Reimplemented from IDBServiceMapper.
Definition at line 82 of file ncbi_dblb_svcmapper.cpp.
References CDBServiceMapperTraits< T >::GetName().
Map a service to a server.
Implements IDBServiceMapper.
Definition at line 167 of file ncbi_dblb_svcmapper.cpp.
References IDBServiceMapper::m_Mtx, and x_GetServer().
Referenced by init_common().
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 267 of file ncbi_dblb_svcmapper.cpp.
References _TRACE, SSERV_Info::algo, ConnNetInfo_Create(), ConnNetInfo_Destroy(), map_checker< Container >::end(), map_checker< Container >::find(), free(), fSERV_Promiscuous, fSERV_ReverseDns, fSERV_Standalone, CDBServerOption::fState_Excluded, CDBServerOption::fState_Normal, CDBServerOption::fState_Penalized, CDBServer::GetExpireTime(), CDBServer::GetHost(), CDBServer::GetName(), CDBServer::GetPort(), HINFO_Status(), SSERV_Info::host, CSocketAPI::HostPortToString(), LBSM_CalculateStatus(), m_EmptyTTL, IDBServiceMapper::m_ExcludeMap, m_LBEmptyMap, IDBServiceMapper::m_Mtx, m_PreferenceMap, max(), n, NCBI_TIME_INFINITE, CRef< C, Locker >::NotEmpty(), NULL, SSERV_Info::port, SSERV_Info::rate, SERV_Close(), SERV_GetNextInfoEx(), SERV_MINIMAL_RATE, SERV_NameOfInfo(), SERV_Open(), state::state(), SLBSM_HostLoad::status, SLBSM_HostLoad::statusBLAST, SSERV_Info::time, x_GetServer(), and x_IsEmpty().
|
virtual |
Get list of all servers for the given service disregarding any exclusions.
Reimplemented from IDBServiceMapper.
Definition at line 228 of file ncbi_dblb_svcmapper.cpp.
References ConnNetInfo_Create(), ConnNetInfo_Destroy(), fSERV_IncludeDown, fSERV_Standalone, SSERV_Info::host, NCBI_TIME_INFINITE, CSocketAPI::ntoa(), NULL, SSERV_Info::port, SERV_Close(), SERV_GetNextInfo(), SERV_Open(), SSERV_Info::time, and NStr::UIntToString().
|
virtual |
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.
Reimplemented from IDBServiceMapper.
Definition at line 452 of file ncbi_dblb_svcmapper.cpp.
References eNH_HostByteOrder, eNH_NetworkByteOrder, fSOCK_KeepOnClose, I_ConnectionExtra::GetLowLevelHandle(), CSocketAPI::HostPortToString(), NULL, SOCK_Close(), SOCK_CreateOnTopEx(), SOCK_GetPeerAddress(), SOCK_GetRemotePort(), and IDBServiceMapper::x_RecordServer().
|
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 442 of file ncbi_dblb_svcmapper.cpp.
References IDBServiceMapper::m_Mtx, and m_PreferenceMap.
Referenced by ConfigureFromRegistry().
Definition at line 174 of file ncbi_dblb_svcmapper.cpp.
References _TRACE, set< Key, Compare >::begin(), DBLB_GetServer(), eDBLB_NoDNSEntry, CRef< C, Locker >::Empty(), set< Key, Compare >::end(), fDBLB_AllowFallbackToStandby, fSERV_IncludeInactive, CDBServer::GetHost(), CDBServer::GetPort(), SDBLB_Preference::host, SDBLB_ConnPoint::host, kEmptyStr, m_EmptyTTL, IDBServiceMapper::m_ExcludeMap, m_LBEmptyMap, m_PreferenceMap, NULL, SDBLB_Preference::port, SDBLB_ConnPoint::port, SDBLB_Preference::pref, SDBLB_ConnPoint::time, and x_IsEmpty().
Referenced by GetServer(), and GetServerOptions().
|
private |
Definition at line 134 of file ncbi_dblb_svcmapper.cpp.
References _TRACE, map_checker< Container >::end(), map_checker< Container >::erase(), set< Key, Compare >::erase(), ERASE_ITERATE, map_checker< Container >::find(), IDBServiceMapper::m_ExcludeMap, and m_LBEmptyMap.
Referenced by GetServerOptions(), and x_GetServer().
|
private |
Definition at line 83 of file ncbi_dblb_svcmapper.hpp.
Referenced by ConfigureFromRegistry(), GetServerOptions(), and x_GetServer().
|
private |
Definition at line 81 of file ncbi_dblb_svcmapper.hpp.
Referenced by GetServerOptions(), x_GetServer(), and x_IsEmpty().
|
private |
Definition at line 82 of file ncbi_dblb_svcmapper.hpp.
Referenced by GetServerOptions(), SetPreference(), and x_GetServer().