|
xapian-core
2.0.0
|
Remote backend server base class. More...
#include <remoteserver.h>
Inheritance diagram for RemoteServer:
Collaboration diagram for RemoteServer:Public Member Functions | |
| RemoteServer (const std::vector< std::string > &dbpaths, int fdin, int fdout, double active_timeout_, double idle_timeout_, bool writable=false) | |
| Construct a RemoteServer. More... | |
| ~RemoteServer () | |
| Destructor. More... | |
| void | run () |
| Repeatedly accept messages from the client and process them. More... | |
| void | set_registry (const Xapian::Registry ®_) |
| Set the registry used for (un)serialisation. More... | |
Private Member Functions | |
| void | operator= (const RemoteServer &) |
| Don't allow assignment. More... | |
| RemoteServer (const RemoteServer &) | |
| Don't allow copying. More... | |
| message_type | get_message (double timeout, std::string &result, message_type required_type=MSG_MAX) |
| Accept a message from the client. More... | |
| void | send_message (reply_type type, std::string_view message) |
| Send a message to the client. More... | |
| void | send_message (reply_type type, std::string_view message, double end_time) |
| Send a message to the client, with specific end_time. More... | |
| void | msg_allterms (const std::string &message) |
| void | msg_document (const std::string &message) |
| void | msg_termexists (const std::string &message) |
| void | msg_collfreq (const std::string &message) |
| void | msg_termfreq (const std::string &message) |
| void | msg_freqs (const std::string &message) |
| void | msg_valuestats (const std::string &message) |
| void | msg_keepalive (const std::string &message) |
| void | msg_doclength (const std::string &message) |
| void | msg_query (const std::string &message) |
| void | msg_termlist (const std::string &message) |
| void | msg_postlist (const std::string &message) |
| void | msg_positionlist (const std::string &message) |
| void | msg_positionlistcount (const std::string &message) |
| void | msg_writeaccess (const std::string &message) |
| void | msg_reopen (const std::string &message) |
| void | msg_update (const std::string &message) |
| void | msg_commit (const std::string &message) |
| void | msg_cancel (const std::string &message) |
| void | msg_adddocument (const std::string &message) |
| void | msg_deletedocument (const std::string &message) |
| void | msg_deletedocumentterm (const std::string &message) |
| void | msg_replacedocument (const std::string &message) |
| void | msg_replacedocumentterm (const std::string &message) |
| void | msg_getmetadata (const std::string &message) |
| void | msg_metadatakeylist (const std::string &message) |
| void | msg_setmetadata (const std::string &message) |
| void | msg_requestdocument (const std::string &message) |
| void | msg_addspelling (const std::string &message) |
| void | msg_removespelling (const std::string &message) |
| void | msg_uniqueterms (const std::string &message) |
| void | msg_wdfdocmax (const std::string &message) |
| void | msg_reconstructtext (const std::string &message) |
| void | msg_synonymtermlist (const std::string &message) |
| void | msg_synonymkeylist (const std::string &message) |
| void | msg_addsynonym (const std::string &message) |
| void | msg_removesynonym (const std::string &message) |
| void | msg_clearsynonyms (const std::string &message) |
Private Member Functions inherited from RemoteConnection | |
| RemoteConnection (int fdin_, int fdout_, const std::string &context_=std::string()) | |
| Constructor. More... | |
| int | get_read_fd () const |
| Return the underlying fd this remote connection reads from. More... | |
| int | sniff_next_message_type (double end_time) |
| Check what the next message type is. More... | |
| int | get_message (std::string &result, double end_time) |
| Read one message from fdin. More... | |
| int | get_message_chunked (double end_time) |
| Prepare to read one message from fdin in chunks. More... | |
| int | get_message_chunk (std::string &result, size_t at_least, double end_time) |
| Read a chunk of a message from fdin. More... | |
| int | receive_file (const std::string &file, double end_time) |
| Save the contents of a message as a file. More... | |
| void | send_message (char type, std::string_view s, double end_time) |
| Send a message. More... | |
| void | send_file (char type, int fd, double end_time) |
| Send the contents of a file as a message. More... | |
| void | shutdown () |
| Shutdown the connection. More... | |
| void | do_close () |
| Close the connection. More... | |
| const std::string & | get_context () const |
| Return the context to report with errors. More... | |
Private Attributes | |
| Xapian::Database * | db = nullptr |
| The database we're using. More... | |
| Xapian::WritableDatabase * | wdb = nullptr |
| The WritableDatabase we're using, or NULL if we're read-only. More... | |
| bool | writable |
| Do we support writing? More... | |
| double | active_timeout |
| Timeout for actions during a conversation. More... | |
| double | idle_timeout |
| Timeout while waiting for a new action from the client. More... | |
| Xapian::Registry | reg |
| The registry, which allows unserialisation of user subclasses. More... | |
Private Attributes inherited from RemoteConnection | |
| std::string | context |
| The context to report with errors. More... | |
Remote backend server base class.
Definition at line 36 of file remoteserver.h.
|
private |
Don't allow copying.
| RemoteServer::RemoteServer | ( | const std::vector< std::string > & | dbpaths, |
| int | fdin, | ||
| int | fdout, | ||
| double | active_timeout_, | ||
| double | idle_timeout_, | ||
| bool | writable = false |
||
| ) |
Construct a RemoteServer.
| dbpaths | The paths to the Xapian databases to use. |
| fdin | The file descriptor to read from. |
| fdout | The file descriptor to write to (fdin and fdout may be the same). |
| active_timeout_ | Timeout for actions during a conversation (specified in seconds). |
| idle_timeout_ | Timeout while waiting for a new action from the client (specified in seconds). |
| writable | Should the database be opened for writing? |
Definition at line 64 of file remoteserver.cc.
References Xapian::Database::add_database(), Assert, RemoteConnection::context, db, msg_update(), REPLY_EXCEPTION, send_message(), and serialise_error().
| RemoteServer::~RemoteServer | ( | ) |
|
private |
Accept a message from the client.
Definition at line 120 of file remoteserver.cc.
References RealTime::end_time(), RemoteConnection::get_message(), MSG_MAX, MSG_SHUTDOWN, Xapian::Internal::str(), and wdb.
Referenced by msg_query(), and run().
|
private |
Definition at line 844 of file remoteserver.cc.
References Xapian::WritableDatabase::add_document(), pack_uint_last(), REPLY_ADDDOCUMENT, send_message(), throw_read_only(), unserialise_document(), and wdb.
Referenced by run().
|
private |
Definition at line 979 of file remoteserver.cc.
References Xapian::WritableDatabase::add_spelling(), p, REPLY_DONE, send_message(), throw_read_only(), unpack_uint(), and wdb.
Referenced by run().
|
private |
Definition at line 1045 of file remoteserver.cc.
References Xapian::WritableDatabase::add_synonym(), p, REPLY_DONE, send_message(), term, throw_read_only(), unpack_string(), and wdb.
Referenced by run().
|
private |
Definition at line 323 of file remoteserver.cc.
References Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), common_prefix_length(), db, pack_uint(), REPLY_ALLTERMS, send_message(), and term.
Referenced by run().
|
private |
Definition at line 830 of file remoteserver.cc.
References Xapian::WritableDatabase::begin_transaction(), Xapian::WritableDatabase::cancel_transaction(), REPLY_DONE, send_message(), throw_read_only(), and wdb.
Referenced by run().
|
private |
Definition at line 1077 of file remoteserver.cc.
References Xapian::WritableDatabase::clear_synonyms(), REPLY_DONE, send_message(), throw_read_only(), and wdb.
Referenced by run().
|
private |
Definition at line 716 of file remoteserver.cc.
References db, Xapian::Database::get_collection_freq(), pack_uint_last(), REPLY_COLLFREQ, send_message(), and term.
Referenced by run().
|
private |
Definition at line 819 of file remoteserver.cc.
References Xapian::WritableDatabase::commit(), REPLY_DONE, send_message(), throw_read_only(), and wdb.
Referenced by run().
|
private |
Definition at line 857 of file remoteserver.cc.
References Xapian::WritableDatabase::delete_document(), p, REPLY_DONE, send_message(), throw_read_only(), unpack_uint_last(), and wdb.
Referenced by run().
|
private |
Definition at line 875 of file remoteserver.cc.
References Xapian::WritableDatabase::delete_document(), REPLY_DONE, send_message(), throw_read_only(), and wdb.
Referenced by run().
|
private |
Definition at line 758 of file remoteserver.cc.
References db, Xapian::Database::get_doclength(), p, pack_uint_last(), REPLY_DOCLENGTH, send_message(), and unpack_uint_last().
Referenced by run().
|
private |
Definition at line 677 of file remoteserver.cc.
References db, Xapian::Document::get_data(), Xapian::Database::get_document(), Xapian::ValueIterator::get_valueno(), p, pack_uint(), REPLY_DOCDATA, REPLY_DONE, REPLY_VALUE, send_message(), unpack_uint_last(), Xapian::Document::values_begin(), and Xapian::Document::values_end().
Referenced by run().
|
private |
Definition at line 732 of file remoteserver.cc.
References db, Xapian::Database::get_collection_freq(), Xapian::Database::get_termfreq(), pack_uint(), pack_uint_last(), REPLY_FREQS, send_message(), and term.
Referenced by run().
|
private |
Definition at line 923 of file remoteserver.cc.
References db, Xapian::Database::get_metadata(), REPLY_METADATA, and send_message().
Referenced by run().
|
private |
Definition at line 701 of file remoteserver.cc.
References db, Xapian::Database::keep_alive(), REPLY_DONE, and send_message().
Referenced by run().
|
private |
Definition at line 929 of file remoteserver.cc.
References common_prefix_length(), db, Xapian::Database::metadata_keys_begin(), Xapian::Database::metadata_keys_end(), pack_uint(), REPLY_METADATAKEYLIST, send_message(), and term.
Referenced by run().
|
private |
Definition at line 377 of file remoteserver.cc.
References db, p, pack_uint(), pos, Xapian::Database::positionlist_begin(), Xapian::Database::positionlist_end(), REPLY_POSITIONLIST, send_message(), term, unpack_uint(), and UNSIGNED_OVERFLOW_OK.
Referenced by run().
|
private |
Definition at line 400 of file remoteserver.cc.
References db, p, pack_uint_last(), Xapian::TermIterator::positionlist_count(), REPLY_POSITIONLISTCOUNT, send_message(), Xapian::TermIterator::skip_to(), term, Xapian::Database::termlist_begin(), Xapian::Database::termlist_end(), and unpack_uint().
Referenced by run().
|
private |
Definition at line 425 of file remoteserver.cc.
References db, Xapian::Database::get_termfreq(), pack_uint(), pack_uint_last(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), REPLY_POSTLIST, REPLY_POSTLISTHEADER, send_message(), and term.
Referenced by run().
|
private |
Definition at line 503 of file remoteserver.cc.
References active_timeout, Xapian::BAD_VALUENO, db, Xapian::Registry::get_key_maker(), Xapian::Registry::get_match_spy(), get_message(), Matcher::get_mset(), Xapian::Registry::get_weighting_scheme(), Xapian::MSet::internal, MSG_GETMSET, p, pack_string(), query(), reg, Xapian::Enquire::Internal::REL, Xapian::MatchSpy::release(), REPLY_RESULTS, REPLY_STATS, send_message(), serialise_stats(), unpack_bool(), unpack_string(), unpack_uint(), Xapian::Weight::unserialise(), Xapian::KeyMaker::unserialise(), Xapian::MatchSpy::unserialise(), Xapian::Query::unserialise(), unserialise_double(), unserialise_rset(), and unserialise_stats().
Referenced by run().
|
private |
Definition at line 800 of file remoteserver.cc.
References db, p, Xapian::Database::reconstruct_text(), REPLY_RECONSTRUCTTEXT, send_message(), and unpack_uint().
Referenced by run().
|
private |
Definition at line 995 of file remoteserver.cc.
References p, pack_uint_last(), Xapian::WritableDatabase::remove_spelling(), REPLY_REMOVESPELLING, send_message(), throw_read_only(), unpack_uint(), and wdb.
Referenced by run().
|
private |
Definition at line 1061 of file remoteserver.cc.
References p, Xapian::WritableDatabase::remove_synonym(), REPLY_DONE, send_message(), term, throw_read_only(), unpack_string(), and wdb.
Referenced by run().
|
private |
Definition at line 473 of file remoteserver.cc.
References db, msg_update(), Xapian::Database::reopen(), REPLY_DONE, and send_message().
Referenced by run().
|
private |
Definition at line 886 of file remoteserver.cc.
References p, Xapian::WritableDatabase::replace_document(), REPLY_DONE, send_message(), throw_read_only(), unpack_uint(), unserialise_document(), and wdb.
Referenced by run().
|
private |
Definition at line 904 of file remoteserver.cc.
References p, pack_uint_last(), Xapian::WritableDatabase::replace_document(), REPLY_ADDDOCUMENT, send_message(), throw_read_only(), unpack_string(), unserialise_document(), and wdb.
Referenced by run().
|
private |
Definition at line 965 of file remoteserver.cc.
References db, Xapian::Database::internal, p, REPLY_DONE, send_message(), and unpack_uint_last().
Referenced by run().
|
private |
Definition at line 948 of file remoteserver.cc.
References p, REPLY_DONE, send_message(), Xapian::WritableDatabase::set_metadata(), throw_read_only(), unpack_string(), and wdb.
Referenced by run().
|
private |
Definition at line 1028 of file remoteserver.cc.
References common_prefix_length(), db, pack_uint(), REPLY_SYNONYMKEYLIST, send_message(), Xapian::Database::synonym_keys_begin(), Xapian::Database::synonym_keys_end(), and term.
Referenced by run().
|
private |
Definition at line 1011 of file remoteserver.cc.
References common_prefix_length(), db, pack_uint(), REPLY_SYNONYMTERMLIST, send_message(), Xapian::Database::synonyms_begin(), Xapian::Database::synonyms_end(), and term.
Referenced by run().
|
private |
Definition at line 709 of file remoteserver.cc.
References db, REPLY_TERMDOESNTEXIST, REPLY_TERMEXISTS, send_message(), term, and Xapian::Database::term_exists().
Referenced by run().
|
private |
Definition at line 724 of file remoteserver.cc.
References db, Xapian::Database::get_termfreq(), pack_uint_last(), REPLY_TERMFREQ, send_message(), and term.
Referenced by run().
|
private |
Definition at line 343 of file remoteserver.cc.
References common_prefix_length(), db, Xapian::TermIterator::Internal::get_approx_size(), Xapian::Database::get_doclength(), Xapian::TermIterator::get_termfreq(), Xapian::TermIterator::get_wdf(), Xapian::TermIterator::internal, p, pack_uint(), pack_uint_last(), REPLY_TERMLIST, REPLY_TERMLISTHEADER, send_message(), term, Xapian::Database::termlist_begin(), Xapian::Database::termlist_end(), and unpack_uint_last().
Referenced by run().
|
private |
Definition at line 772 of file remoteserver.cc.
References db, Xapian::Database::get_unique_terms(), p, pack_uint_last(), REPLY_UNIQUETERMS, send_message(), and unpack_uint_last().
Referenced by run().
|
private |
Definition at line 483 of file remoteserver.cc.
References db, Xapian::Database::get_doccount(), Xapian::Database::get_doclength_lower_bound(), Xapian::Database::get_doclength_upper_bound(), Xapian::Database::get_lastdocid(), Xapian::Database::get_total_length(), Xapian::Database::get_uuid(), Xapian::Database::has_positions(), pack_bool(), pack_uint(), REPLY_UPDATE, send_message(), XAPIAN_REMOTE_PROTOCOL_MAJOR_VERSION, and XAPIAN_REMOTE_PROTOCOL_MINOR_VERSION.
Referenced by msg_reopen(), msg_writeaccess(), RemoteServer(), and run().
|
private |
Definition at line 741 of file remoteserver.cc.
References db, Xapian::Database::get_value_freq(), Xapian::Database::get_value_lower_bound(), Xapian::Database::get_value_upper_bound(), p, pack_string(), pack_uint(), REPLY_VALUESTATS, send_message(), and unpack_uint_last().
Referenced by run().
|
private |
Definition at line 786 of file remoteserver.cc.
References db, Xapian::Database::get_wdfdocmax(), p, pack_uint_last(), REPLY_WDFDOCMAX, send_message(), and unpack_uint_last().
Referenced by run().
|
private |
Definition at line 450 of file remoteserver.cc.
References db, Xapian::Database::lock(), msg_update(), p, throw_read_only(), unpack_uint_last(), wdb, and writable.
Referenced by run().
|
private |
Don't allow assignment.
| void RemoteServer::run | ( | ) |
Repeatedly accept messages from the client and process them.
The loop continues until either the connection is closed, or a non-Xapian exception is thrown.
Definition at line 159 of file remoteserver.cc.
References get_message(), idle_timeout, MSG_ADDDOCUMENT, msg_adddocument(), MSG_ADDSPELLING, msg_addspelling(), MSG_ADDSYNONYM, msg_addsynonym(), MSG_ALLTERMS, msg_allterms(), MSG_CANCEL, msg_cancel(), MSG_CLEARSYNONYMS, msg_clearsynonyms(), MSG_COLLFREQ, msg_collfreq(), MSG_COMMIT, msg_commit(), MSG_DELETEDOCUMENT, msg_deletedocument(), MSG_DELETEDOCUMENTTERM, msg_deletedocumentterm(), MSG_DOCLENGTH, msg_doclength(), MSG_DOCUMENT, msg_document(), MSG_FREQS, msg_freqs(), MSG_GETMETADATA, msg_getmetadata(), MSG_KEEPALIVE, msg_keepalive(), MSG_METADATAKEYLIST, msg_metadatakeylist(), MSG_POSITIONLIST, msg_positionlist(), MSG_POSITIONLISTCOUNT, msg_positionlistcount(), MSG_POSTLIST, msg_postlist(), MSG_QUERY, msg_query(), MSG_RECONSTRUCTTEXT, msg_reconstructtext(), MSG_REMOVESPELLING, msg_removespelling(), MSG_REMOVESYNONYM, msg_removesynonym(), MSG_REOPEN, msg_reopen(), MSG_REPLACEDOCUMENT, msg_replacedocument(), MSG_REPLACEDOCUMENTTERM, msg_replacedocumentterm(), MSG_REQUESTDOCUMENT, msg_requestdocument(), MSG_SETMETADATA, msg_setmetadata(), MSG_SYNONYMKEYLIST, msg_synonymkeylist(), MSG_SYNONYMTERMLIST, msg_synonymtermlist(), MSG_TERMEXISTS, msg_termexists(), MSG_TERMFREQ, msg_termfreq(), MSG_TERMLIST, msg_termlist(), MSG_UNIQUETERMS, msg_uniqueterms(), MSG_UPDATE, msg_update(), MSG_VALUESTATS, msg_valuestats(), MSG_WDFDOCMAX, msg_wdfdocmax(), MSG_WRITEACCESS, msg_writeaccess(), REPLY_EXCEPTION, send_message(), serialise_error(), and Xapian::Internal::str().
Referenced by RemoteTcpServer::handle_one_connection(), and main().
|
private |
Send a message to the client.
Definition at line 149 of file remoteserver.cc.
References active_timeout, RealTime::end_time(), and RemoteConnection::send_message().
Referenced by msg_adddocument(), msg_addspelling(), msg_addsynonym(), msg_allterms(), msg_cancel(), msg_clearsynonyms(), msg_collfreq(), msg_commit(), msg_deletedocument(), msg_deletedocumentterm(), msg_doclength(), msg_document(), msg_freqs(), msg_getmetadata(), msg_keepalive(), msg_metadatakeylist(), msg_positionlist(), msg_positionlistcount(), msg_postlist(), msg_query(), msg_reconstructtext(), msg_removespelling(), msg_removesynonym(), msg_reopen(), msg_replacedocument(), msg_replacedocumentterm(), msg_requestdocument(), msg_setmetadata(), msg_synonymkeylist(), msg_synonymtermlist(), msg_termexists(), msg_termfreq(), msg_termlist(), msg_uniqueterms(), msg_update(), msg_valuestats(), msg_wdfdocmax(), RemoteServer(), and run().
|
inlineprivate |
Send a message to the client, with specific end_time.
Definition at line 83 of file remoteserver.h.
References RealTime::end_time(), and RemoteConnection::send_message().
|
inline |
Set the registry used for (un)serialisation.
Definition at line 271 of file remoteserver.h.
Referenced by RemoteTcpServer::handle_one_connection().
|
private |
Timeout for actions during a conversation.
The timeout is specified in seconds. If the timeout is exceeded then a Xapian::NetworkTimeoutError is thrown.
Definition at line 60 of file remoteserver.h.
Referenced by msg_query(), and send_message().
|
private |
The database we're using.
If we're writable, this is the same as wdb.
Definition at line 47 of file remoteserver.h.
Referenced by msg_allterms(), msg_collfreq(), msg_doclength(), msg_document(), msg_freqs(), msg_getmetadata(), msg_keepalive(), msg_metadatakeylist(), msg_positionlist(), msg_positionlistcount(), msg_postlist(), msg_query(), msg_reconstructtext(), msg_reopen(), msg_requestdocument(), msg_synonymkeylist(), msg_synonymtermlist(), msg_termexists(), msg_termfreq(), msg_termlist(), msg_uniqueterms(), msg_update(), msg_valuestats(), msg_wdfdocmax(), msg_writeaccess(), RemoteServer(), and ~RemoteServer().
|
private |
Timeout while waiting for a new action from the client.
The timeout is specified in seconds. If the timeout is exceeded then a Xapian::NetworkTimeoutError is thrown.
Definition at line 67 of file remoteserver.h.
Referenced by run().
|
private |
The registry, which allows unserialisation of user subclasses.
Definition at line 70 of file remoteserver.h.
Referenced by msg_query().
|
private |
The WritableDatabase we're using, or NULL if we're read-only.
Definition at line 50 of file remoteserver.h.
Referenced by get_message(), msg_adddocument(), msg_addspelling(), msg_addsynonym(), msg_cancel(), msg_clearsynonyms(), msg_commit(), msg_deletedocument(), msg_deletedocumentterm(), msg_removespelling(), msg_removesynonym(), msg_replacedocument(), msg_replacedocumentterm(), msg_setmetadata(), and msg_writeaccess().
|
private |
Do we support writing?
Definition at line 53 of file remoteserver.h.
Referenced by msg_writeaccess().