ddc
|
#include <Server.h>
Public Member Functions | |
CDDCServer () | |
virtual | ~CDDCServer () |
virtual void | Shutdown (bool quiet=false) |
virtual void | SetOptions (const CDDCServerOptions &Options) |
virtual void | StartClientThreads () |
virtual CDDCServer * | WorkerClone (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 CSocketAddr & | SocketAddr () 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 CDDCServerThreadPool * | m_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... | |
abstract base class class for DDC server nodes
CDDCServer::CDDCServer | ( | ) |
default constructor
References m_FQHostName, and m_tStarted.
Referenced by WorkerClone().
|
inlinevirtual |
default destructor
References SetOptions(), Shutdown(), and StartClientThreads().
|
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().
|
virtual |
set server options
Reimplemented in CDDCBranchServer.
References DDCVersionT::current(), ddcLLUnknown, ddcLogInfo, ddcLogWarn, DDCVersionString(), Format(), CDDCServerOptions::m_LogLevel, CDDCServerOptions::m_nWorkers, m_nWorkers, CDDCServerOptions::m_SlowQueryTimeout, m_SlowQueryTimeout, CDDCServerOptions::m_ThreadQueueSize, m_ThreadQueueSize, CHost::m_UnixSocketPerms, CDDCServerOptions::m_UnixSocketPerms, m_VersionCompat, CDDCServerOptions::m_VersionCompat, SetLogLevel(), and DDCVersionT::str().
Referenced by LoadLocalCorpora(), CDDCBranchServer::SetOptions(), and ~CDDCServer().
|
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().
|
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().
|
virtual |
initialize a newly created worker-clone (and any subordinate data)
Parent | parent server from which settings are to be cloned |
WorkerId | local 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().
|
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().
|
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().
|
virtual |
CHost API: main accept - process - respond loop; called in its own thread
Reimplemented from CHost.
References CHost::RunThread(), and StartClientThreads().
Referenced by UseClientThreads().
|
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().
|
virtual |
CHost API: maintains m_Stats and calls appropriate handle__() methods
Reimplemented from CHost.
References DDCTimeAvg::Append(), DDCTimeAvg::AppendTotal(), CExpc::code(), DDC_STATIC_BUFLEN, ddcLLTrace, ddcLogError, ddcLogInfo, ddcLogLevel, ddcLogWarn, DDCTimeHiRes::Elapsed(), errNone, errOther, errParseError, findPathHint(), Format(), 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(), CHost::m_bExpectMore, m_bLogRequests, CHost::m_bRespond, CHost::m_CorpusName, CDDCServerStats::m_nErrors, CDDCServerStats::m_nExpand, m_noLogCommands, CDDCServerStats::m_nQueries, CDDCServerStats::m_nRequests, CDDCServerStats::m_nSlow, CDDCServerStats::m_qTimes, m_SessionStats, m_SlowQueryTimeout, CDDCServerStats::m_xTimes, DDCTimeHiRes::Now(), stringSplit(), and CExpc::what().
Referenced by UseClientThreads().
|
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().
|
virtual |
request handler: get_hit_strings: required (leaf)
Reimplemented in CDDCBranchServer, and CDDCLeafServer.
References method_not_implemented().
Referenced by ProcessSocketString(), and UseClientThreads().
|
virtual |
request handler: run_query: required (branch)
Reimplemented in CDDCBranchServer, and CDDCLeafServer.
References method_not_implemented().
Referenced by handle__run_query(), ProcessSocketString(), and UseClientThreads().
|
virtual |
request handler: expand_terms: required (leaf|branch)
Reimplemented in CDDCBranchServer, and CDDCLeafServer.
References method_not_implemented().
Referenced by ProcessSocketString(), and UseClientThreads().
|
virtual |
request handler: status: required (leaf|branch)
Reimplemented in CDDCBranchServer, and CDDCLeafServer.
References method_not_implemented().
Referenced by handle__vstatus(), ProcessSocketString(), and UseClientThreads().
|
virtual |
request handler: info: required (leaf|branch)
Reimplemented in CDDCBranchServer, and CDDCLeafServer.
References method_not_implemented().
Referenced by handle__vinfo(), ProcessSocketString(), and UseClientThreads().
|
virtual |
request handler: reload: required (leaf|branch)
Reimplemented in CDDCBranchServer, and CDDCLeafServer.
References method_not_implemented().
Referenced by ProcessSocketString(), and UseClientThreads().
|
virtual |
request handler: clear_cache: required (leaf|branch)
Reimplemented in CDDCBranchServer, and CDDCLeafServer.
References method_not_implemented().
Referenced by ProcessSocketString(), and UseClientThreads().
|
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().
|
virtual |
request handler: get_first_hits, 3-argument form (no path or hint)
References handle__get_first_hits().
|
virtual |
request handler: get_first_hits, 7-argument form (no path or hint)
References handle__run_query().
|
virtual |
request handler: get_paradigm: optional (leaf|branch)
References GetParadigm(), and Lemmatize().
Referenced by ProcessSocketString(), and UseClientThreads().
|
virtual |
request handler: close_socket: optional (leaf|branch)
Reimplemented in CDDCBranchServer.
References CHost::Close(), and CHost::m_bRespond.
Referenced by ProcessSocketString(), and UseClientThreads().
|
virtual |
request handler: close_socket: optional (leaf|branch)
References PACKAGE_VERSION.
Referenced by ProcessSocketString(), and UseClientThreads().
|
virtual |
request handler: vstatus: optional (leaf|branch): default wraps handle__status(Result,timeout,true)
References handle__status().
Referenced by ProcessSocketString(), and UseClientThreads().
|
virtual |
request handler: vinfo: optional (leaf|branch): default wraps handle__info(Result,timeout,true)
References handle__info().
Referenced by ProcessSocketString(), and UseClientThreads().
|
inline |
References errRuntime, findPathHint(), residentMemorySize(), and totalMemorySize().
Referenced by handle__clear_cache(), handle__expand_terms(), handle__get_first_hits(), handle__get_hit_strings(), handle__info(), handle__nodes(), handle__reload(), handle__run_query(), and handle__status().
|
virtual |
get resident memory size of server process in kb using /proc/self/statm
References DDCProcessMemoryStatus::VmRSS.
Referenced by method_not_implemented().
|
virtual |
get total memory size of server process in kb using /proc/self/statm
References DDCProcessMemoryStatus::VmSize.
Referenced by method_not_implemented().
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().
|
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().
|
static |
maximum number of subcorpora per branch server
DDCVersionT CDDCServer::m_VersionCompat |
compatibility mode
Referenced by CDDCLeafServer::handle__get_hit_strings(), CDDCLeafServer::handle__run_query(), CDDCLeafServer::handle__status(), and SetOptions().
time_t CDDCServer::m_tStarted |
timestamp of server initialization
Referenced by CDDCServer(), and CDDCLeafServer::handle__status().
CDDCServerStats CDDCServer::m_ServerStats |
server-wide administrative statistics (number of requests, etc)
Referenced by CDDCLeafServer::handle__status(), HandleClientConnection(), and CDDCServerThread::run().
CDDCServerStats CDDCServer::m_SessionStats |
session-local administrative statistics
Referenced by HandleClientConnection(), ProcessSocketString(), and CDDCServerThread::run().
bool CDDCServer::m_bLogRequests |
Referenced by ProcessSocketString().
set<string> CDDCServer::m_noLogCommands |
Referenced by ProcessSocketString().
string CDDCServer::m_FQHostName |
Referenced by CDDCServer(), and CDDCLeafServer::handle__status().
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().
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().
double CDDCServer::m_SlowQueryTimeout |
upper-bound in seconds for "slow" queries
Referenced by ProcessSocketString(), and SetOptions().
size_t CDDCServer::m_WorkerId |
worker thread-id for worker clones
Referenced by CDDCLeafServer::handle__run_query(), CDDCServerThread::run(), Shutdown(), and WorkerCloneInit().
class CDDCServerThreadPool* CDDCServer::m_ThreadPool |
client-thread pool (requires pthread)
Referenced by HandleClientConnection(), CDDCServerThread::run(), Shutdown(), StartClientThreads(), and WorkerCloneInit().