NCBI C++ ToolKit
|
Search Toolkit Book for SNetServiceImpl
#include "netservice_api_impl.hpp"
(Private to src/connect/services
.)
Classes | |
struct | SRetry |
Public Types | |
enum | EServiceType { eServiceNotDefined , eLoadBalancedService , eSingleServerService } |
enum | EServerErrorHandling { eRethrowServerErrors , eRethrowAllServerErrors , eIgnoreServerErrors } |
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... | |
Public Member Functions | |
string | MakeAuthString () |
CNetServer::SExecResult | FindServerAndExec (const string &cmd, bool multiline_output) |
void | DiscoverServersIfNeeded () |
void | GetDiscoveredServers (CRef< SDiscoveredServers > &discovered_servers) |
bool | IsInService (CNetServer::TInstance server) |
void | IterateUntilExecOK (const string &cmd, bool multiline_output, CNetServer::SExecResult &exec_result, IServiceTraversal *service_traversal, EServerErrorHandling error_handling) |
SNetServiceIteratorImpl * | Iterate (CNetServer::TInstance priority_server) |
SDiscoveredServers * | AllocServerGroup (unsigned discovery_iteration) |
CNetServer | GetServer (SSocketAddress server_address) |
const string & | GetClientName () const |
unsigned | GetConnectionMaxRetries () const |
unsigned long | GetConnectionRetryDelay () const |
bool | IsLoadBalanced () const |
shared_ptr< void > | CreateRetryGuard (SRetry::EType type) |
virtual | ~SNetServiceImpl () |
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 |
Public Attributes | |
CRef< INetServerConnectionListener > | m_Listener |
CNetServerPool | m_ServerPool |
string | m_ServiceName |
EServiceType | m_ServiceType = eServiceNotDefined |
CFastMutex | m_DiscoveryMutex |
SDiscoveredServers * | m_DiscoveredServers = nullptr |
SDiscoveredServers * | m_ServerGroupPool = nullptr |
unsigned | m_LatestDiscoveryIteration = 0 |
CSimpleRebalanceStrategy | m_RebalanceStrategy |
atomic< size_t > | m_RoundRobin |
Private Member Functions | |
SNetServiceImpl (const string &api_name, const string &service_name, const string &client_name, INetServerConnectionListener *listener, CSynRegistry ®istry, const SRegSynonyms §ions) | |
SNetServiceImpl (SNetServerInPool *server, SNetServiceImpl *prototype) | |
SNetServiceImpl (const string &service_name, SNetServiceImpl *prototype) | |
void | Construct (SNetServerInPool *server) |
void | Construct () |
void | Init (CSynRegistry ®istry, SRegSynonyms §ions, const string &ns_client_name) |
Private Attributes | |
string | m_APIName |
string | m_ClientName |
bool | m_UseSmartRetries |
unsigned | m_ConnectionMaxRetries |
unsigned long | m_ConnectionRetryDelay |
shared_ptr< void > | m_NetInfo |
Additional Inherited Members | |
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 Member Functions inherited from CObject | |
virtual void | DeleteThis (void) |
Virtual method "deleting" this object. More... | |
Definition at line 276 of file netservice_api_impl.hpp.
Enumerator | |
---|---|
eRethrowServerErrors | |
eRethrowAllServerErrors | |
eIgnoreServerErrors |
Definition at line 327 of file netservice_api_impl.hpp.
Enumerator | |
---|---|
eServiceNotDefined | |
eLoadBalancedService | |
eSingleServerService |
Definition at line 278 of file netservice_api_impl.hpp.
|
private |
Definition at line 340 of file netservice_api.cpp.
|
private |
Definition at line 352 of file netservice_api.cpp.
References Construct().
|
private |
Definition at line 368 of file netservice_api.cpp.
References Construct().
|
virtual |
Definition at line 1226 of file netservice_api.cpp.
References m_DiscoveredServers, SDiscoveredServers::m_NextGroupInPool, m_ServerGroupPool, and NULL.
SDiscoveredServers * SNetServiceImpl::AllocServerGroup | ( | unsigned | discovery_iteration | ) |
Definition at line 687 of file netservice_api.cpp.
References SDiscoveredServers::m_NextGroupInPool, m_ServerGroupPool, NULL, and SDiscoveredServers::Reset().
Referenced by Construct(), and DiscoverServersIfNeeded().
|
static |
Definition at line 420 of file netservice_api.cpp.
References SNetServiceImpl().
|
static |
Definition at line 415 of file netservice_api.cpp.
References SNetServiceImpl().
Referenced by CNetService::Clone(), and SNetServiceMap::GetServiceByNameImpl().
|
private |
Definition at line 394 of file netservice_api.cpp.
References eLoadBalancedService, SNetServerPoolImpl::FindOrCreateServerImpl(), m_ServerPool, m_ServiceName, m_ServiceType, and SSocketAddress::Parse().
Referenced by Init(), and SNetServiceImpl().
|
private |
Definition at line 384 of file netservice_api.cpp.
References AllocServerGroup(), eSingleServerService, m_DiscoveredServers, SNetServerPoolImpl::m_ServerMutex, m_ServerPool, SDiscoveredServers::m_Servers, m_ServiceType, and SDiscoveredServers::m_SuppressedBegin.
|
static |
Definition at line 405 of file netservice_api.cpp.
References registry, CRef< C, Locker >::Release(), and SNetServiceImpl().
Referenced by CNetService::Create(), SNetCacheAPIImpl::SNetCacheAPIImpl(), SNetICacheClientImpl::SNetICacheClientImpl(), SNetScheduleAPIImpl::SNetScheduleAPIImpl(), and SNetStorageRPC::SNetStorageRPC().
shared_ptr< void > SNetServiceImpl::CreateRetryGuard | ( | SRetry::EType | type | ) |
Definition at line 1197 of file netservice_api.cpp.
References SNetServiceImpl::SRetry::eNoRetry, and SNetServiceImpl::SRetry::eNoRetryNoErrors.
void SNetServiceImpl::DiscoverServersIfNeeded | ( | ) |
Definition at line 919 of file netservice_api.cpp.
References AllocServerGroup(), SThrottleStats::Discover(), CServiceDiscovery::DiscoverImpl(), eLoadBalancedService, eServiceNotDefined, SNetServerPoolImpl::FindOrCreateServerImpl(), fSERV_IncludeReserved, fSERV_IncludeStandby, fSERV_IncludeSuppressed, fSERV_Standalone, LBSMD_PENALIZED_RATE_BOUNDARY, m_APIName, m_ConnectionRetryDelay, m_DiscoveredServers, SDiscoveredServers::m_DiscoveryIteration, m_LatestDiscoveryIteration, SNetServerPoolImpl::m_LBSMAffinity, m_NetInfo, m_RebalanceStrategy, SNetServerPoolImpl::m_ServerMutex, m_ServerPool, SDiscoveredServers::m_Servers, SDiscoveredServers::m_Service, m_ServiceName, m_ServiceType, SDiscoveredServers::m_SuppressedBegin, SNetServerInPool::m_ThrottleStats, NCBI_THROW_FMT, CSimpleRebalanceStrategy::NeedRebalance(), NULL, CSimpleRebalanceStrategy::OnResourceRequested(), CGuard< Resource, Lock, Unlock, ReportExceptions >::Release(), SDiscoveredServers::Reset(), and types.
Referenced by GetDiscoveredServers().
CNetServer::SExecResult SNetServiceImpl::FindServerAndExec | ( | const string & | cmd, |
bool | multiline_output | ||
) |
Definition at line 875 of file netservice_api.cpp.
References cmd, eIgnoreServerErrors, eLoadBalancedService, eSingleServerService, CNetServer::ExecWithRetry(), IterateUntilExecOK(), m_APIName, m_DiscoveredServers, m_ServerPool, SDiscoveredServers::m_Servers, m_ServiceType, NCBI_THROW_FMT, and SNetServerPoolImpl::ReturnServer().
Referenced by SNetCacheAPIImpl::ExecMirrorAware().
Definition at line 344 of file netservice_api_impl.hpp.
References m_ClientName.
Referenced by g_GetWorkerNodeInfo(), SGridWorkerNodeImpl::GetClientName(), SNetCacheAPIImpl::Init(), SNetScheduleAPIImpl::Init(), and SNetCacheAPIImpl::SNetCacheAPIImpl().
|
inline |
Definition at line 346 of file netservice_api_impl.hpp.
References m_ConnectionMaxRetries.
Referenced by SNetServerImpl::ConnectAndExec().
|
inline |
Definition at line 347 of file netservice_api_impl.hpp.
References m_ConnectionRetryDelay.
Referenced by SNetServerImpl::ConnectAndExec().
void SNetServiceImpl::GetDiscoveredServers | ( | CRef< SDiscoveredServers > & | discovered_servers | ) |
Definition at line 997 of file netservice_api.cpp.
References DiscoverServersIfNeeded(), m_DiscoveredServers, m_DiscoveryMutex, and SDiscoveredServers::m_Service.
Referenced by IsInService(), and Iterate().
CNetServer SNetServiceImpl::GetServer | ( | SSocketAddress | server_address | ) |
Definition at line 832 of file netservice_api.cpp.
References SNetServerPoolImpl::GetServer(), m_RebalanceStrategy, m_ServerPool, and CSimpleRebalanceStrategy::OnResourceRequested().
Referenced by SNetScheduleJobReaderImpl::CImpl::CheckEntry(), and SNetCacheAPIImpl::InitiateWriteCmd().
|
private |
Definition at line 597 of file netservice_api.cpp.
References CONNECTION_MAX_RETRIES, Construct(), NStr::FindNoCase(), IRegistry::Get(), CNcbiApplicationAPI::GetProgramDisplayName(), SNetServerPoolImpl::Init(), SNetServiceXSiteAPI::InitXSite(), CNcbiApplicationAPI::InstanceGuard(), kMilliSecondsPerSecond, m_APIName, m_ClientName, m_ConnectionMaxRetries, m_ConnectionRetryDelay, m_ServerPool, m_ServiceName, m_UseSmartRetries, NCBI_THROW_FMT, NPOS, registry, RETRY_DELAY_DEFAULT, and NStr::TruncateSpacesInPlace().
bool SNetServiceImpl::IsInService | ( | CNetServer::TInstance | server | ) |
Definition at line 1006 of file netservice_api.cpp.
References GetDiscoveredServers(), ITERATE, SNetServerImpl::m_ServerInPool, and SDiscoveredServers::m_Servers.
Referenced by SNetCacheAPIImpl::ExecMirrorAware(), and SNetServiceMap::IsAllowed().
|
inline |
Definition at line 348 of file netservice_api_impl.hpp.
References eLoadBalancedService, and m_ServiceType.
SNetServiceIteratorImpl * SNetServiceImpl::Iterate | ( | CNetServer::TInstance | priority_server | ) |
Definition at line 1277 of file netservice_api.cpp.
References GetDiscoveredServers(), ITERATE, SNetServerImpl::m_ServerInPool, SDiscoveredServers::m_Servers, m_ServiceName, and NCBI_THROW.
void SNetServiceImpl::IterateUntilExecOK | ( | const string & | cmd, |
bool | multiline_output, | ||
CNetServer::SExecResult & | exec_result, | ||
IServiceTraversal * | service_traversal, | ||
SNetServiceImpl::EServerErrorHandling | error_handling | ||
) |
Definition at line 1038 of file netservice_api.cpp.
References IServiceTraversal::BeginIteration(), cmd, SNetServerImpl::ConnectAndExec(), CNetCacheException::eBlobNotFound, CNetSrvConnException::eConnectionFailure, CNetSrvConnException::eReadTimeout, eRethrowAllServerErrors, eRethrowServerErrors, ERR_POST, CNetSrvConnException::eServerThrottle, CNetScheduleException::eSubmitsDisabled, CTimeout::GetAsMilliSeconds(), CException::GetErrCode(), CException::GetMsg(), CDeadline::GetRemainingTime(), CDeadline::IsInfinite(), SFailOnlyWarnings::IssueAndClear(), m_ConnectionMaxRetries, m_ConnectionRetryDelay, SNetServerPoolImpl::m_FirstServerTimeout, m_Listener, SNetServerPoolImpl::m_MaxTotalTime, m_ServerPool, m_ServiceName, m_UseSmartRetries, NCBI_THROW_FMT, IServiceTraversal::NextServer(), NULL, INetServerConnectionListener::OnWarning(), SleepMilliSec(), and Warning().
Referenced by SNetICacheClientImpl::ChooseServerAndExec(), SNetCacheAPIImpl::ExecMirrorAware(), and FindServerAndExec().
string SNetServiceImpl::MakeAuthString | ( | ) |
Definition at line 702 of file netservice_api.cpp.
References eLoadBalancedService, CNcbiApplicationAPI::GetProgramExecutablePath(), CNcbiApplicationAPI::InstanceGuard(), m_ClientName, m_ServerPool, m_ServiceName, m_ServiceType, SNetServerPoolImpl::m_UseOldStyleAuth, and NStr::PrintableString().
Referenced by SNetCacheAPIImpl::Init(), and SNetScheduleAPIImpl::MakeAuthString().
|
private |
Definition at line 370 of file netservice_api_impl.hpp.
Referenced by DiscoverServersIfNeeded(), FindServerAndExec(), and Init().
|
private |
Definition at line 371 of file netservice_api_impl.hpp.
Referenced by GetClientName(), Init(), and MakeAuthString().
|
private |
Definition at line 375 of file netservice_api_impl.hpp.
Referenced by GetConnectionMaxRetries(), Init(), and IterateUntilExecOK().
|
private |
Definition at line 376 of file netservice_api_impl.hpp.
Referenced by DiscoverServersIfNeeded(), GetConnectionRetryDelay(), Init(), and IterateUntilExecOK().
SDiscoveredServers* SNetServiceImpl::m_DiscoveredServers = nullptr |
Definition at line 363 of file netservice_api_impl.hpp.
Referenced by Construct(), SDiscoveredServers::DeleteThis(), DiscoverServersIfNeeded(), FindServerAndExec(), GetDiscoveredServers(), and ~SNetServiceImpl().
CFastMutex SNetServiceImpl::m_DiscoveryMutex |
Definition at line 362 of file netservice_api_impl.hpp.
Referenced by SDiscoveredServers::DeleteThis(), and GetDiscoveredServers().
unsigned SNetServiceImpl::m_LatestDiscoveryIteration = 0 |
Definition at line 365 of file netservice_api_impl.hpp.
Referenced by DiscoverServersIfNeeded().
CRef<INetServerConnectionListener> SNetServiceImpl::m_Listener |
Definition at line 355 of file netservice_api_impl.hpp.
Referenced by SThrottleStats::Adjust(), SThrottleStats::Check(), SNetServerInPool::Connect(), SNetServerImpl::ConnectAndExec(), SNetStorageRPC::Exchange(), SNetCacheAPIImpl::GetListener(), IterateUntilExecOK(), and SNetServerConnectionImpl::ReadCmdOutputLine().
|
private |
Definition at line 378 of file netservice_api_impl.hpp.
Referenced by DiscoverServersIfNeeded().
CSimpleRebalanceStrategy SNetServiceImpl::m_RebalanceStrategy |
Definition at line 366 of file netservice_api_impl.hpp.
Referenced by DiscoverServersIfNeeded(), SNetServiceIteratorImpl::GetServer(), and GetServer().
atomic<size_t> SNetServiceImpl::m_RoundRobin |
Definition at line 367 of file netservice_api_impl.hpp.
SDiscoveredServers* SNetServiceImpl::m_ServerGroupPool = nullptr |
Definition at line 364 of file netservice_api_impl.hpp.
Referenced by AllocServerGroup(), SDiscoveredServers::DeleteThis(), and ~SNetServiceImpl().
CNetServerPool SNetServiceImpl::m_ServerPool |
Definition at line 357 of file netservice_api_impl.hpp.
Referenced by Construct(), DiscoverServersIfNeeded(), FindServerAndExec(), GetServer(), SNetScheduleAPIImpl::GetServerByNode(), Init(), IterateUntilExecOK(), MakeAuthString(), CNetCacheWriter::TransmitImpl(), SNetScheduleAPIImpl::UpdateAuthString(), and SNetScheduleAPIImpl::UseOldStyleAuth().
string SNetServiceImpl::m_ServiceName |
Definition at line 359 of file netservice_api_impl.hpp.
Referenced by SNetServerInPool::Connect(), Construct(), DiscoverServersIfNeeded(), SNetScheduleAPIImpl::GetQueueParams(), SGridWorkerNodeImpl::GetServiceName(), Init(), Iterate(), IterateUntilExecOK(), and MakeAuthString().
EServiceType SNetServiceImpl::m_ServiceType = eServiceNotDefined |
Definition at line 360 of file netservice_api_impl.hpp.
Referenced by Construct(), DiscoverServersIfNeeded(), FindServerAndExec(), IsLoadBalanced(), and MakeAuthString().
|
private |
Definition at line 374 of file netservice_api_impl.hpp.
Referenced by Init(), and IterateUntilExecOK().