xapian-core  1.4.25
Public Member Functions | Private Member Functions | Private Attributes | List of all members
RemoteServer Class Reference

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 &reg_)
 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::Databasedb
 The database we're using. More...
 
Xapian::WritableDatabasewdb
 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...
 

Detailed Description

Remote backend server base class.

Definition at line 36 of file remoteserver.h.

Constructor & Destructor Documentation

◆ RemoteServer() [1/2]

RemoteServer::RemoteServer ( const RemoteServer )
private

Don't allow copying.

◆ RemoteServer() [2/2]

RemoteServer::RemoteServer ( const std::vector< std::string > &  dbpaths,
int  fdin,
int  fdout,
double  active_timeout_,
double  idle_timeout_,
bool  writable = false 
)

Construct a RemoteServer.

Parameters
dbpathsThe paths to the Xapian databases to use.
fdinThe file descriptor to read from.
fdoutThe 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).
writableShould 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::~RemoteServer ( )

Destructor.

Definition at line 109 of file remoteserver.cc.

References db.

Member Function Documentation

◆ get_message()

message_type RemoteServer::get_message ( double  timeout,
std::string &  result,
message_type  required_type = MSG_MAX 
)
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().

◆ msg_adddocument()

void RemoteServer::msg_adddocument ( const std::string &  message)
private

◆ msg_addspelling()

void RemoteServer::msg_addspelling ( const std::string &  message)
private

Definition at line 783 of file remoteserver.cc.

References msg_addspelling_(), REPLY_DONE, and send_message().

Referenced by run().

◆ msg_addspelling_()

void RemoteServer::msg_addspelling_ ( const std::string &  message)
private

◆ msg_allterms()

void RemoteServer::msg_allterms ( const std::string &  message)
private

◆ msg_cancel()

void RemoteServer::msg_cancel ( const std::string &  message)
private

Definition at line 634 of file remoteserver.cc.

References msg_cancel_(), REPLY_DONE, and send_message().

Referenced by run().

◆ msg_cancel_()

void RemoteServer::msg_cancel_ ( const std::string &  message)
private

◆ msg_collfreq()

void RemoteServer::msg_collfreq ( const std::string &  message)
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().

◆ msg_commit()

void RemoteServer::msg_commit ( const std::string &  message)
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().

◆ msg_deletedocument()

void RemoteServer::msg_deletedocument ( const std::string &  message)
private

◆ msg_deletedocumentterm()

void RemoteServer::msg_deletedocumentterm ( const std::string &  message)
private

Definition at line 680 of file remoteserver.cc.

References msg_deletedocumentterm_(), REPLY_DONE, and send_message().

Referenced by run().

◆ msg_deletedocumentterm_()

void RemoteServer::msg_deletedocumentterm_ ( const std::string &  message)
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().

◆ msg_doclength()

void RemoteServer::msg_doclength ( const std::string &  message)
private

◆ msg_document()

void RemoteServer::msg_document ( const std::string &  message)
private

◆ msg_freqs()

void RemoteServer::msg_freqs ( const std::string &  message)
private

◆ msg_getmetadata()

void RemoteServer::msg_getmetadata ( const std::string &  message)
private

Definition at line 735 of file remoteserver.cc.

References db, Xapian::Database::get_metadata(), REPLY_METADATA, and send_message().

Referenced by run().

◆ msg_keepalive()

void RemoteServer::msg_keepalive ( const std::string &  message)
private

Definition at line 548 of file remoteserver.cc.

References db, Xapian::Database::keep_alive(), REPLY_DONE, and send_message().

Referenced by run().

◆ msg_openmetadatakeylist()

void RemoteServer::msg_openmetadatakeylist ( const std::string &  message)
private

◆ msg_positionlist()

void RemoteServer::msg_positionlist ( const std::string &  message)
private

◆ msg_postlist()

void RemoteServer::msg_postlist ( const std::string &  message)
private

◆ msg_query()

void RemoteServer::msg_query ( const std::string &  message)
private

◆ msg_removespelling()

void RemoteServer::msg_removespelling ( const std::string &  message)
private

Definition at line 802 of file remoteserver.cc.

References decode_length(), Xapian::WritableDatabase::remove_spelling(), throw_read_only(), and wdb.

Referenced by run().

◆ msg_reopen()

void RemoteServer::msg_reopen ( const std::string &  message)
private

Definition at line 362 of file remoteserver.cc.

References db, msg_update(), Xapian::Database::reopen(), REPLY_DONE, and send_message().

Referenced by run().

◆ msg_replacedocument()

void RemoteServer::msg_replacedocument ( const std::string &  message)
private

Definition at line 696 of file remoteserver.cc.

References msg_replacedocument_(), REPLY_DONE, and send_message().

Referenced by run().

◆ msg_replacedocument_()

void RemoteServer::msg_replacedocument_ ( const std::string &  message)
private

◆ msg_replacedocumentterm()

void RemoteServer::msg_replacedocumentterm ( const std::string &  message)
private

◆ msg_setmetadata()

void RemoteServer::msg_setmetadata ( const std::string &  message)
private

Definition at line 761 of file remoteserver.cc.

References msg_setmetadata_(), REPLY_DONE, and send_message().

Referenced by run().

◆ msg_setmetadata_()

void RemoteServer::msg_setmetadata_ ( const std::string &  message)
private

◆ msg_termexists()

void RemoteServer::msg_termexists ( const std::string &  message)
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().

◆ msg_termfreq()

void RemoteServer::msg_termfreq ( const std::string &  message)
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().

◆ msg_termlist()

void RemoteServer::msg_termlist ( const std::string &  message)
private

◆ msg_uniqueterms()

void RemoteServer::msg_uniqueterms ( const std::string &  message)
private

◆ msg_update()

void RemoteServer::msg_update ( const std::string &  message)
private

◆ msg_valuestats()

void RemoteServer::msg_valuestats ( const std::string &  message)
private

◆ msg_writeaccess()

void RemoteServer::msg_writeaccess ( const std::string &  message)
private

◆ operator=()

void RemoteServer::operator= ( const RemoteServer )
private

Don't allow assignment.

◆ run()

void RemoteServer::run ( )

◆ send_message() [1/2]

void RemoteServer::send_message ( reply_type  type,
const std::string &  message 
)
private

◆ send_message() [2/2]

void RemoteServer::send_message ( reply_type  type,
const std::string &  message,
double  end_time 
)
inlineprivate

Send a message to the client, with specific end_time.

Definition at line 80 of file remoteserver.h.

References RemoteConnection::send_message().

◆ set_registry()

void RemoteServer::set_registry ( const Xapian::Registry reg_)
inline

Set the registry used for (un)serialisation.

Definition at line 218 of file remoteserver.h.

Referenced by RemoteTcpServer::handle_one_connection().

Member Data Documentation

◆ active_timeout

double RemoteServer::active_timeout
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().

◆ db

Xapian::Database* RemoteServer::db
private

◆ idle_timeout

double RemoteServer::idle_timeout
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().

◆ reg

Xapian::Registry RemoteServer::reg
private

The registry, which allows unserialisation of user subclasses.

Definition at line 70 of file remoteserver.h.

Referenced by msg_query().

◆ wdb

Xapian::WritableDatabase* RemoteServer::wdb
private

◆ writable

bool RemoteServer::writable
private

Do we support writing?

Definition at line 53 of file remoteserver.h.

Referenced by msg_writeaccess().


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