xapian-core
1.4.26
|
Remote backend server base class. More...
#include <remoteserver.h>
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, const std::string &message) |
Send a message to the client. More... | |
void | send_message (reply_type type, const std::string &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_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_openmetadatakeylist (const std::string &message) |
void | msg_setmetadata_ (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_deletedocumentterm (const std::string &message) |
void | msg_replacedocument (const std::string &message) |
void | msg_cancel (const std::string &message) |
void | msg_setmetadata (const std::string &message) |
void | msg_addspelling (const std::string &message) |
Private Member Functions inherited from RemoteConnection | |
RemoteConnection (int fdin_, int fdout_, const std::string &context_=std::string()) | |
Constructor. More... | |
bool | ready_to_read () const |
See if there is data available to read. 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, const std::string &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... | |
Private Attributes | |
Xapian::Database * | db |
The database we're using. More... | |
Xapian::WritableDatabase * | wdb |
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 60 of file remoteserver.cc.
References 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 116 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 653 of file remoteserver.cc.
References Xapian::WritableDatabase::add_document(), encode_length(), REPLY_ADDDOCUMENT, send_message(), throw_read_only(), unserialise_document(), and wdb.
Referenced by run().
|
private |
Definition at line 783 of file remoteserver.cc.
References msg_addspelling_(), REPLY_DONE, and send_message().
Referenced by run().
|
private |
Definition at line 790 of file remoteserver.cc.
References Xapian::WritableDatabase::add_spelling(), decode_length(), throw_read_only(), and wdb.
Referenced by msg_addspelling(), and run().
|
private |
Definition at line 246 of file remoteserver.cc.
References Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), common_prefix_length(), db, encode_length(), REPLY_ALLTERMS, REPLY_DONE, and send_message().
Referenced by run().
|
private |
Definition at line 634 of file remoteserver.cc.
References msg_cancel_(), REPLY_DONE, and send_message().
Referenced by run().
|
private |
Definition at line 641 of file remoteserver.cc.
References Xapian::WritableDatabase::begin_transaction(), Xapian::WritableDatabase::cancel_transaction(), throw_read_only(), and wdb.
Referenced by msg_cancel(), and run().
|
private |
Definition at line 562 of file remoteserver.cc.
References db, encode_length(), Xapian::Database::get_collection_freq(), REPLY_COLLFREQ, and send_message().
Referenced by run().
|
private |
Definition at line 623 of file remoteserver.cc.
References Xapian::WritableDatabase::commit(), REPLY_DONE, send_message(), throw_read_only(), and wdb.
Referenced by run().
|
private |
Definition at line 664 of file remoteserver.cc.
References decode_length(), Xapian::WritableDatabase::delete_document(), REPLY_DONE, send_message(), throw_read_only(), and wdb.
Referenced by run().
|
private |
Definition at line 680 of file remoteserver.cc.
References msg_deletedocumentterm_(), REPLY_DONE, and send_message().
Referenced by run().
|
private |
Definition at line 687 of file remoteserver.cc.
References Xapian::WritableDatabase::delete_document(), throw_read_only(), and wdb.
Referenced by msg_deletedocumentterm(), and run().
|
private |
Definition at line 603 of file remoteserver.cc.
References db, decode_length(), encode_length(), Xapian::Database::get_doclength(), REPLY_DOCLENGTH, and send_message().
Referenced by run().
|
private |
Definition at line 527 of file remoteserver.cc.
References db, decode_length(), encode_length(), Xapian::Document::get_data(), Xapian::Database::get_document(), REPLY_DOCDATA, REPLY_DONE, REPLY_VALUE, send_message(), Xapian::Document::values_begin(), and Xapian::Document::values_end().
Referenced by run().
|
private |
Definition at line 574 of file remoteserver.cc.
References db, encode_length(), Xapian::Database::get_collection_freq(), Xapian::Database::get_termfreq(), REPLY_FREQS, and send_message().
Referenced by run().
|
private |
Definition at line 735 of file remoteserver.cc.
References db, Xapian::Database::get_metadata(), REPLY_METADATA, and send_message().
Referenced by run().
|
private |
Definition at line 548 of file remoteserver.cc.
References db, Xapian::Database::keep_alive(), REPLY_DONE, and send_message().
Referenced by run().
|
private |
Definition at line 741 of file remoteserver.cc.
References common_prefix_length(), db, Xapian::Database::metadata_keys_begin(), Xapian::Database::metadata_keys_end(), REPLY_DONE, REPLY_METADATAKEYLIST, and send_message().
Referenced by run().
|
private |
Definition at line 292 of file remoteserver.cc.
References db, decode_length(), encode_length(), Xapian::Database::positionlist_begin(), Xapian::Database::positionlist_end(), REPLY_DONE, REPLY_POSITIONLIST, and send_message().
Referenced by run().
|
private |
Definition at line 313 of file remoteserver.cc.
References db, encode_length(), Xapian::Database::get_collection_freq(), Xapian::Database::get_termfreq(), Xapian::Database::postlist_begin(), Xapian::Database::postlist_end(), REPLY_DONE, REPLY_POSTLISTITEM, REPLY_POSTLISTSTART, and send_message().
Referenced by run().
|
private |
Definition at line 393 of file remoteserver.cc.
References active_timeout, Xapian::BAD_VALUENO, db, decode_length(), decode_length_and_check(), encode_length(), Xapian::Registry::get_match_spy(), get_message(), Xapian::Registry::get_weighting_scheme(), Xapian::MSet::internal, MSG_GETMSET, query(), reg, Xapian::MatchSpy::release(), REPLY_RESULTS, REPLY_STATS, send_message(), serialise_mset(), serialise_stats(), Xapian::MatchSpy::unserialise(), Xapian::Weight::unserialise(), Xapian::Query::unserialise(), unserialise_double(), unserialise_rset(), and unserialise_stats().
Referenced by run().
|
private |
Definition at line 802 of file remoteserver.cc.
References decode_length(), Xapian::WritableDatabase::remove_spelling(), throw_read_only(), and wdb.
Referenced by run().
|
private |
Definition at line 362 of file remoteserver.cc.
References db, msg_update(), Xapian::Database::reopen(), REPLY_DONE, and send_message().
Referenced by run().
|
private |
Definition at line 696 of file remoteserver.cc.
References msg_replacedocument_(), REPLY_DONE, and send_message().
Referenced by run().
|
private |
Definition at line 703 of file remoteserver.cc.
References decode_length(), Xapian::WritableDatabase::replace_document(), throw_read_only(), unserialise_document(), and wdb.
Referenced by msg_replacedocument(), and run().
|
private |
Definition at line 717 of file remoteserver.cc.
References decode_length_and_check(), encode_length(), Xapian::WritableDatabase::replace_document(), REPLY_ADDDOCUMENT, send_message(), throw_read_only(), unserialise_document(), and wdb.
Referenced by run().
|
private |
Definition at line 761 of file remoteserver.cc.
References msg_setmetadata_(), REPLY_DONE, and send_message().
Referenced by run().
|
private |
Definition at line 768 of file remoteserver.cc.
References decode_length_and_check(), Xapian::WritableDatabase::set_metadata(), throw_read_only(), and wdb.
Referenced by msg_setmetadata(), and run().
|
private |
Definition at line 556 of file remoteserver.cc.
References db, REPLY_TERMDOESNTEXIST, REPLY_TERMEXISTS, send_message(), and Xapian::Database::term_exists().
Referenced by run().
|
private |
Definition at line 568 of file remoteserver.cc.
References db, encode_length(), Xapian::Database::get_termfreq(), REPLY_TERMFREQ, and send_message().
Referenced by run().
|
private |
Definition at line 267 of file remoteserver.cc.
References common_prefix_length(), db, decode_length(), encode_length(), Xapian::Database::get_doclength(), REPLY_DOCLENGTH, REPLY_DONE, REPLY_TERMLIST, send_message(), Xapian::Database::termlist_begin(), and Xapian::Database::termlist_end().
Referenced by run().
|
private |
Definition at line 613 of file remoteserver.cc.
References db, decode_length(), encode_length(), Xapian::Database::get_unique_terms(), REPLY_UNIQUETERMS, and send_message().
Referenced by run().
|
private |
Definition at line 372 of file remoteserver.cc.
References db, encode_length(), 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(), 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 582 of file remoteserver.cc.
References db, decode_length(), encode_length(), Xapian::Database::get_value_freq(), Xapian::Database::get_value_lower_bound(), Xapian::Database::get_value_upper_bound(), REPLY_VALUESTATS, and send_message().
Referenced by run().
|
private |
Definition at line 338 of file remoteserver.cc.
References RemoteConnection::context, db, Xapian::DB_OPEN, decode_length(), msg_update(), throw_read_only(), 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 155 of file remoteserver.cc.
References get_message(), idle_timeout, msg_adddocument(), msg_addspelling(), msg_addspelling_(), msg_allterms(), msg_cancel(), msg_cancel_(), msg_collfreq(), msg_commit(), msg_deletedocument(), msg_deletedocumentterm(), msg_deletedocumentterm_(), msg_doclength(), msg_document(), msg_freqs(), msg_getmetadata(), msg_keepalive(), msg_openmetadatakeylist(), msg_positionlist(), msg_postlist(), msg_query(), msg_removespelling(), msg_reopen(), msg_replacedocument(), msg_replacedocument_(), msg_replacedocumentterm(), msg_setmetadata(), msg_setmetadata_(), msg_termexists(), msg_termfreq(), msg_termlist(), msg_uniqueterms(), msg_update(), msg_valuestats(), 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 145 of file remoteserver.cc.
References active_timeout, RealTime::end_time(), and RemoteConnection::send_message().
Referenced by msg_adddocument(), msg_addspelling(), msg_allterms(), msg_cancel(), msg_collfreq(), msg_commit(), msg_deletedocument(), msg_deletedocumentterm(), msg_doclength(), msg_document(), msg_freqs(), msg_getmetadata(), msg_keepalive(), msg_openmetadatakeylist(), msg_positionlist(), msg_postlist(), msg_query(), msg_reopen(), msg_replacedocument(), msg_replacedocumentterm(), msg_setmetadata(), msg_termexists(), msg_termfreq(), msg_termlist(), msg_uniqueterms(), msg_update(), msg_valuestats(), RemoteServer(), and run().
|
inlineprivate |
Send a message to the client, with specific end_time.
Definition at line 80 of file remoteserver.h.
References RemoteConnection::send_message().
|
inline |
Set the registry used for (un)serialisation.
Definition at line 218 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_openmetadatakeylist(), msg_positionlist(), msg_postlist(), msg_query(), msg_reopen(), msg_termexists(), msg_termfreq(), msg_termlist(), msg_uniqueterms(), msg_update(), msg_valuestats(), 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_cancel_(), msg_commit(), msg_deletedocument(), msg_deletedocumentterm_(), msg_removespelling(), 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().