ddc
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
CDDCServer Class Reference

#include <Server.h>

Inheritance diagram for CDDCServer:
Inheritance graph
[legend]
Collaboration diagram for CDDCServer:
Collaboration graph
[legend]

Public Member Functions

 CDDCServer ()
 
virtual ~CDDCServer ()
 
virtual void Shutdown (bool quiet=false)
 
virtual void SetOptions (const CDDCServerOptions &Options)
 
virtual void StartClientThreads ()
 
virtual CDDCServerWorkerClone (void) const
 
virtual void WorkerCloneInit (const CDDCServer *Parent, size_t WorkerId)
 
virtual void WorkerCloneFree (void)
 
bool UseClientThreads (void) const
 
virtual void RunThread ()
 
virtual void HandleClientConnection (int &rConnectedSocket)
 
virtual string ProcessSocketString (const string &SocketInput, int &rConnectedSocket)
 
virtual void handle__get_first_hits (string &Result, const char *Query, int TimeOut, size_t ResultLimit, const string &ReqPath, const NavHint &Hint)
 
virtual void handle__get_hit_strings (string &Result, const char *ResultType, size_t StartHitNo, size_t ResultLimit)
 
virtual void handle__run_query (string &Result, const char *CorpusName, const char *Query, const char *ResultType, size_t StartHitNo, size_t ResultLimit, int TimeOut, const string &ReqPath, const NavHint &Hint)
 
virtual void handle__expand_terms (string &Result, const string &pipeline, const string &terms, int timeout, const string &corpus)
 
virtual void handle__status (string &Result, int timeout=10, bool verbose=false)
 
virtual void handle__info (string &Result, int timeout=10, bool verbose=false)
 
virtual void handle__reload (string &Result, int depth=0)
 
virtual void handle__clear_cache (string &Result, int depth=0)
 
virtual void handle__nodes (string &Result, int depth=-1)
 
virtual void handle__get_first_hits (string &Result, const char *Query, int TimeOut, size_t ResultLimit)
 
virtual void handle__run_query (string &Result, const char *CorpusName, const char *Query, const char *ResultType, size_t StartHitNo, size_t ResultLimit, int TimeOut)
 
virtual void handle__get_paradigm (string &Result, const char *Word, int iLemmatizeOnly, int iLang)
 
virtual void handle__close_socket (string &Result, int &rConnectedSocket)
 
virtual void handle__version (string &Result)
 
virtual void handle__vstatus (string &Result, int timeout=10)
 
virtual void handle__vinfo (string &Result, int timeout=10)
 
void method_not_implemented (const char *methodName)
 
virtual size_t residentMemorySize (void) const
 
virtual size_t totalMemorySize (void) const
 
void findPathHint (const string &ReqStr, size_t StartPos, size_t &PathPos, size_t &HintPos)
 
- Public Member Functions inherited from CHost
 CHost ()
 
virtual ~CHost ()
 
bool ReadFromString (string S)
 
virtual void CreateListener ()
 
void CopyAddressParametersFrom (const CHost &X)
 
bool CloseListenSocket (int timeout=0)
 
int CreateAndConnectSocket (string &strError) const
 
string GetAddressStr () const
 
const string & GetLocalPathOfIndex () const
 
const CSocketAddrSocketAddr () const
 
const string & HostAddr () const
 
const int Port () const
 
bool InitEmbedded (const CHost &)
 
void InitShortName ()
 
bool IsListening () const
 
bool GetRequest (int &rConnectedSocket, int TimeOut, string &Request)
 
void SendResponse (int &rConnectedSocket, const string &Result)
 
void HandleSocketError (int &rConnectedSocket, const string &ErrorStr="ERROR", const string &Where="CHost::HandleSocketError()")
 
void HandleClientRequest (int &rConnectedSocket, int TimeOut)
 
virtual bool Close (int &rConnectedSocket, bool linger=false, int timeout=5)
 
virtual void ClientError (int code=-1, const string &msg="")
 
virtual void ClientError (int code, const string &msg, int &clientSocket)
 

Public Attributes

DDCVersionT m_VersionCompat
 
time_t m_tStarted
 
CDDCServerStats m_ServerStats
 
CDDCServerStats m_SessionStats
 
bool m_bLogRequests
 
set< string > m_noLogCommands
 
string m_FQHostName
 
size_t m_nWorkers
 
size_t m_ThreadQueueSize
 
double m_SlowQueryTimeout
 
size_t m_WorkerId
 
class CDDCServerThreadPoolm_ThreadPool
 
- Public Attributes inherited from CHost
string m_CorpusName
 full node label, including optional "server:" prefix More...
 
string m_ShortName
 short node label, without optional "server:" prefix More...
 

Static Public Attributes

static const char * AdditionalHitDelimiter = "\x01"
 
static const size_t MaxSubhostsSize = 256
 

Additional Inherited Members

- Protected Member Functions inherited from CHost
int CreateSocket (bool bBind, string &strError) const
 
bool CheckValidAddr () const
 
void StopListening ()
 
- Protected Attributes inherited from CHost
CSocketAddr m_SockAddr
 socket address (tcp or UNIX); formerly m_HostAddr, m_Port, m_SocketPath More...
 
bool m_bExpectMore
 moo: whether to expect more requests from current client More...
 
bool m_bRespond
 moo: whether current request has a real (possibly empty) response More...
 
bool m_bLogFinish
 moo: whether to log connection completion More...
 
string m_LocalPath
 path to local project-file (ddc_local_corpora.cfg) or label of parent branch node (ddc_server.cfg) More...
 
uint32_t m_maxReceiveBytes
 maximum receivable packet length (default=0: no limit) More...
 
mode_t m_UnixSocketPerms
 permissions mask for unix socket (defualt=0: OS-default = 0777&~umask()) More...
 

Detailed Description

abstract base class class for DDC server nodes

Constructor & Destructor Documentation

◆ CDDCServer()

CDDCServer::CDDCServer ( )

default constructor

References m_FQHostName, and m_tStarted.

Referenced by WorkerClone().

Here is the caller graph for this function:

◆ ~CDDCServer()

virtual CDDCServer::~CDDCServer ( )
inlinevirtual

default destructor

References SetOptions(), Shutdown(), and StartClientThreads().

Here is the call graph for this function:

Member Function Documentation

◆ Shutdown()

void CDDCServer::Shutdown ( bool  quiet = false)
virtual

close any open socket(s) this server administers, called on termination signal

References CHost::CloseListenSocket(), ddcLogDebug, ddcLogInfo, Format(), CHost::m_CorpusName, m_ThreadPool, m_WorkerId, and CDDCServerThreadPool::stop().

Referenced by ~CDDCServer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOptions()

void CDDCServer::SetOptions ( const CDDCServerOptions Options)
virtual

◆ StartClientThreads()

void CDDCServer::StartClientThreads ( )
virtual

initialize the client-thread pool (requires pthread support)

References ddcLogInfo, m_nWorkers, m_ThreadPool, m_ThreadQueueSize, and CDDCServerThreadPool::start().

Referenced by RunThread(), and ~CDDCServer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WorkerClone()

virtual CDDCServer* CDDCServer::WorkerClone ( void  ) const
inlinevirtual

create a minimal (uninitialized) copy of this object (and any subordinate data) for use by a worker thread

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References CDDCServer(), WorkerCloneFree(), and WorkerCloneInit().

Referenced by CDDCServerThread::CDDCServerThread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WorkerCloneInit()

void CDDCServer::WorkerCloneInit ( const CDDCServer Parent,
size_t  WorkerId 
)
virtual

initialize a newly created worker-clone (and any subordinate data)

  • called on newly created worker-clone objects by default WorkerClone() implementation
  • recommended for derived classes
    Parameters
    Parentparent server from which settings are to be cloned
    WorkerIdlocal id of this worker-clone (== CDDCServerThread.m_ThreadId)

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References m_ThreadPool, m_WorkerId, and CHost::StopListening().

Referenced by CDDCServerThread::CDDCServerThread(), WorkerClone(), CDDCLeafServer::WorkerCloneInit(), and CDDCBranchServer::WorkerCloneInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WorkerCloneFree()

void CDDCServer::WorkerCloneFree ( void  )
virtual

perform local cleanup of a worker clone prior to deletion; default implementation just calls Shutdown()

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

Referenced by WorkerClone(), CDDCLeafServer::WorkerCloneFree(), CDDCBranchServer::WorkerCloneFree(), and CDDCServerThread::~CDDCServerThread().

Here is the caller graph for this function:

◆ UseClientThreads()

bool CDDCServer::UseClientThreads ( void  ) const
inline

is this server configured and ready to use client threads?

References handle__clear_cache(), handle__close_socket(), handle__expand_terms(), handle__get_first_hits(), handle__get_hit_strings(), handle__get_paradigm(), handle__info(), handle__nodes(), handle__reload(), handle__run_query(), handle__status(), handle__version(), handle__vinfo(), handle__vstatus(), HandleClientConnection(), ProcessSocketString(), RunThread(), and SOCKET.

Referenced by HandleClientConnection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RunThread()

void CDDCServer::RunThread ( )
virtual

CHost API: main accept - process - respond loop; called in its own thread

Reimplemented from CHost.

References CHost::RunThread(), and StartClientThreads().

Referenced by UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleClientConnection()

void CDDCServer::HandleClientConnection ( int &  rConnectedSocket)
virtual

CHost API: handle a new client connection (top-level): override

Reimplemented from CHost.

References ddcThreadQueue< T >::add(), CDDCServerStats::clear(), ddcLogTrace, Format(), CHost::HandleClientConnection(), CDDCServerThreadPool::m_Queue, m_ServerStats, m_SessionStats, m_ThreadPool, SocketPeer(), and UseClientThreads().

Referenced by CDDCServerThread::run(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessSocketString()

string CDDCServer::ProcessSocketString ( const string &  SocketInput,
int &  rConnectedSocket 
)
virtual

◆ handle__get_first_hits() [1/2]

void CDDCServer::handle__get_first_hits ( string &  Result,
const char *  Query,
int  TimeOut,
size_t  ResultLimit,
const string &  ReqPath,
const NavHint Hint 
)
virtual

request handler: get_first_hits: required (leaf)

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References CHost::m_bExpectMore, and method_not_implemented().

Referenced by handle__get_first_hits(), ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__get_hit_strings()

void CDDCServer::handle__get_hit_strings ( string &  Result,
const char *  ResultType,
size_t  StartHitNo,
size_t  ResultLimit 
)
virtual

request handler: get_hit_strings: required (leaf)

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References method_not_implemented().

Referenced by ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__run_query() [1/2]

void CDDCServer::handle__run_query ( string &  Result,
const char *  CorpusName,
const char *  Query,
const char *  ResultType,
size_t  StartHitNo,
size_t  ResultLimit,
int  TimeOut,
const string &  ReqPath,
const NavHint Hint 
)
virtual

request handler: run_query: required (branch)

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References method_not_implemented().

Referenced by handle__run_query(), ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__expand_terms()

void CDDCServer::handle__expand_terms ( string &  Result,
const string &  pipeline,
const string &  terms,
int  timeout,
const string &  corpus 
)
virtual

request handler: expand_terms: required (leaf|branch)

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References method_not_implemented().

Referenced by ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__status()

void CDDCServer::handle__status ( string &  Result,
int  timeout = 10,
bool  verbose = false 
)
virtual

request handler: status: required (leaf|branch)

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References method_not_implemented().

Referenced by handle__vstatus(), ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__info()

void CDDCServer::handle__info ( string &  Result,
int  timeout = 10,
bool  verbose = false 
)
virtual

request handler: info: required (leaf|branch)

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References method_not_implemented().

Referenced by handle__vinfo(), ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__reload()

void CDDCServer::handle__reload ( string &  Result,
int  depth = 0 
)
virtual

request handler: reload: required (leaf|branch)

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References method_not_implemented().

Referenced by ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__clear_cache()

void CDDCServer::handle__clear_cache ( string &  Result,
int  depth = 0 
)
virtual

request handler: clear_cache: required (leaf|branch)

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References method_not_implemented().

Referenced by ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__nodes()

void CDDCServer::handle__nodes ( string &  Result,
int  depth = -1 
)
virtual

request handler: nodes: required (leaf|branch; since v2.2.8)

Reimplemented in CDDCBranchServer, and CDDCLeafServer.

References method_not_implemented().

Referenced by ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__get_first_hits() [2/2]

void CDDCServer::handle__get_first_hits ( string &  Result,
const char *  Query,
int  TimeOut,
size_t  ResultLimit 
)
virtual

request handler: get_first_hits, 3-argument form (no path or hint)

References handle__get_first_hits().

Here is the call graph for this function:

◆ handle__run_query() [2/2]

void CDDCServer::handle__run_query ( string &  Result,
const char *  CorpusName,
const char *  Query,
const char *  ResultType,
size_t  StartHitNo,
size_t  ResultLimit,
int  TimeOut 
)
virtual

request handler: get_first_hits, 7-argument form (no path or hint)

References handle__run_query().

Here is the call graph for this function:

◆ handle__get_paradigm()

void CDDCServer::handle__get_paradigm ( string &  Result,
const char *  Word,
int  iLemmatizeOnly,
int  iLang 
)
virtual

request handler: get_paradigm: optional (leaf|branch)

References GetParadigm(), and Lemmatize().

Referenced by ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__close_socket()

void CDDCServer::handle__close_socket ( string &  Result,
int &  rConnectedSocket 
)
virtual

request handler: close_socket: optional (leaf|branch)

Reimplemented in CDDCBranchServer.

References CHost::Close(), and CHost::m_bRespond.

Referenced by ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__version()

void CDDCServer::handle__version ( string &  Result)
virtual

request handler: close_socket: optional (leaf|branch)

References PACKAGE_VERSION.

Referenced by ProcessSocketString(), and UseClientThreads().

Here is the caller graph for this function:

◆ handle__vstatus()

void CDDCServer::handle__vstatus ( string &  Result,
int  timeout = 10 
)
virtual

request handler: vstatus: optional (leaf|branch): default wraps handle__status(Result,timeout,true)

References handle__status().

Referenced by ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle__vinfo()

void CDDCServer::handle__vinfo ( string &  Result,
int  timeout = 10 
)
virtual

request handler: vinfo: optional (leaf|branch): default wraps handle__info(Result,timeout,true)

References handle__info().

Referenced by ProcessSocketString(), and UseClientThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ method_not_implemented()

void CDDCServer::method_not_implemented ( const char *  methodName)
inline

◆ residentMemorySize()

size_t CDDCServer::residentMemorySize ( void  ) const
virtual

get resident memory size of server process in kb using /proc/self/statm

Deprecated:
prefer totalMemorySize()

References DDCProcessMemoryStatus::VmRSS.

Referenced by method_not_implemented().

Here is the caller graph for this function:

◆ totalMemorySize()

size_t CDDCServer::totalMemorySize ( void  ) const
virtual

get total memory size of server process in kb using /proc/self/statm

References DDCProcessMemoryStatus::VmSize.

Referenced by method_not_implemented().

Here is the caller graph for this function:

◆ findPathHint()

void CDDCServer::findPathHint ( const string &  ReqStr,
size_t  StartPos,
size_t &  PathPos,
size_t &  HintPos 
)

find offsets of server-path and navigation hint from ReqStr starting at StartPos

Referenced by method_not_implemented(), and ProcessSocketString().

Here is the caller graph for this function:

Member Data Documentation

◆ AdditionalHitDelimiter

const char * CDDCServer::AdditionalHitDelimiter = "\x01"
static

additional hit delimiter; overrides CConcHolder.m_AdditionalHitDelimiter , also used for branch server hit-tokenization; default is "\x01"

Referenced by CDDCBranchServer::GetHitContexts(), CDDCBranchServer::handle__get_hit_strings(), and CDDCLeafServer::LoadHolder().

◆ MaxSubhostsSize

const size_t CDDCServer::MaxSubhostsSize = 256
static

maximum number of subcorpora per branch server

◆ m_VersionCompat

DDCVersionT CDDCServer::m_VersionCompat

◆ m_tStarted

time_t CDDCServer::m_tStarted

timestamp of server initialization

Referenced by CDDCServer(), and CDDCLeafServer::handle__status().

◆ m_ServerStats

CDDCServerStats CDDCServer::m_ServerStats

server-wide administrative statistics (number of requests, etc)

Referenced by CDDCLeafServer::handle__status(), HandleClientConnection(), and CDDCServerThread::run().

◆ m_SessionStats

CDDCServerStats CDDCServer::m_SessionStats

session-local administrative statistics

Referenced by HandleClientConnection(), ProcessSocketString(), and CDDCServerThread::run().

◆ m_bLogRequests

bool CDDCServer::m_bLogRequests

Referenced by ProcessSocketString().

◆ m_noLogCommands

set<string> CDDCServer::m_noLogCommands

Referenced by ProcessSocketString().

◆ m_FQHostName

string CDDCServer::m_FQHostName

◆ m_nWorkers

size_t CDDCServer::m_nWorkers

number of client-thread workers for thread pool (default=0: serial mode)

Referenced by CDDCLeafServer::handle__status(), SetOptions(), and StartClientThreads().

◆ m_ThreadQueueSize

size_t CDDCServer::m_ThreadQueueSize

maximum number of pending client connections the thread-pool queue (min=1: use tcp queueing only; default=DDC_DEFAULT_THREAD_QUEUE_SIZE)

Referenced by SetOptions(), and StartClientThreads().

◆ m_SlowQueryTimeout

double CDDCServer::m_SlowQueryTimeout

upper-bound in seconds for "slow" queries

  • any query taking longer than this will be logged
  • set to zero or less to suppress slow-query log messages
  • default=10

Referenced by ProcessSocketString(), and SetOptions().

◆ m_WorkerId

size_t CDDCServer::m_WorkerId

worker thread-id for worker clones

Referenced by CDDCLeafServer::handle__run_query(), CDDCServerThread::run(), Shutdown(), and WorkerCloneInit().

◆ m_ThreadPool

class CDDCServerThreadPool* CDDCServer::m_ThreadPool

client-thread pool (requires pthread)

Referenced by HandleClientConnection(), CDDCServerThread::run(), Shutdown(), StartClientThreads(), and WorkerCloneInit().


The documentation for this class was generated from the following files: