xapian-core
1.4.26
|
Internal implementation of DatabaseReplica. More...
Public Member Functions | |
Internal (const string &path_) | |
Open a new DatabaseReplica::Internal for the specified path. More... | |
~Internal () | |
Destructor. More... | |
string | get_revision_info () const |
Get a string describing the current revision of the replica. More... | |
void | set_read_fd (int fd) |
Set the file descriptor to read changesets from. More... | |
bool | apply_next_changeset (ReplicationInfo *info, double reader_close_time) |
Read and apply the next changeset. More... | |
string | get_description () const |
Return a string describing this object. More... | |
Public Member Functions inherited from Xapian::Internal::intrusive_base | |
intrusive_base () | |
Construct with no references. More... | |
Private Member Functions | |
void | operator= (const Internal &) |
Don't allow assignment. More... | |
Internal (const Internal &) | |
Don't allow copying. More... | |
void | update_stub_database () const |
Update the stub database which points to a single database. More... | |
void | remove_offline_db () |
Delete the offline database. More... | |
void | apply_db_copy (double end_time) |
Apply a set of DB copy messages from the connection. More... | |
void | check_message_type (int type, int expected) const |
Check that a message type is as expected. More... | |
bool | possibly_make_offline_live () |
Check if the offline database has reached the required version. More... | |
string | get_replica_path (int id) const |
Private Attributes | |
string | path |
The path to the replica directory. More... | |
int | live_id |
The id of the currently live database in the replica (0 or 1). More... | |
WritableDatabase | live_db |
The live database being replicated. More... | |
bool | have_offline_db |
Do we have an offline database currently? More... | |
bool | need_copy_next |
Flag to indicate that the only valid operation next is a full copy. More... | |
string | offline_revision |
The revision that the secondary database has been updated to. More... | |
string | offline_uuid |
The UUID of the secondary database. More... | |
string | offline_needed_revision |
The revision that the secondary database must reach before it can be made live. More... | |
double | last_live_changeset_time |
The time at which a changeset was last applied to the live database. More... | |
RemoteConnection * | conn |
The remote connection we're using. More... | |
Additional Inherited Members | |
Public Attributes inherited from Xapian::Internal::intrusive_base | |
unsigned | _refs |
Reference count. More... | |
Internal implementation of DatabaseReplica.
Definition at line 123 of file replication.cc.
|
private |
Don't allow copying.
|
explicit |
Open a new DatabaseReplica::Internal for the specified path.
Definition at line 300 of file replication.cc.
References Xapian::DB_BACKEND_STUB, Xapian::DB_CREATE, Xapian::DB_OPEN, dir_exists(), Xapian::DatabaseReplica::Internal::get_replica_path(), Xapian::DatabaseReplica::Internal::live_db, Xapian::DatabaseReplica::Internal::live_id, LOGCALL_CTOR, Xapian::DatabaseReplica::Internal::path, and Xapian::DatabaseReplica::Internal::update_stub_database().
|
inline |
Destructor.
Definition at line 216 of file replication.cc.
|
private |
Apply a set of DB copy messages from the connection.
Definition at line 377 of file replication.cc.
References Xapian::DatabaseReplica::Internal::check_message_type(), Xapian::DatabaseReplica::Internal::conn, decode_length_and_check(), RemoteConnection::get_message(), Xapian::DatabaseReplica::Internal::get_replica_path(), Xapian::DatabaseReplica::Internal::have_offline_db, Xapian::DatabaseReplica::Internal::last_live_changeset_time, Xapian::DatabaseReplica::Internal::live_id, Xapian::DatabaseReplica::Internal::need_copy_next, Xapian::DatabaseReplica::Internal::offline_needed_revision, Xapian::DatabaseReplica::Internal::offline_revision, Xapian::DatabaseReplica::Internal::offline_uuid, RemoteConnection::receive_file(), removedir(), REPL_REPLY_DB_FILEDATA, REPL_REPLY_DB_FILENAME, REPL_REPLY_DB_FOOTER, REPL_REPLY_DB_HEADER, REPL_REPLY_FAIL, RemoteConnection::sniff_next_message_type(), and throw_connection_closed_unexpectedly().
Referenced by Xapian::DatabaseReplica::Internal::apply_next_changeset().
bool Xapian::DatabaseReplica::Internal::apply_next_changeset | ( | ReplicationInfo * | info, |
double | reader_close_time | ||
) |
Read and apply the next changeset.
Definition at line 497 of file replication.cc.
References Xapian::DatabaseReplica::Internal::apply_db_copy(), Xapian::ReplicationInfo::changed, Xapian::ReplicationInfo::changeset_count, Xapian::DatabaseReplica::Internal::check_message_type(), Xapian::DatabaseReplica::Internal::conn, Xapian::DB_OPEN, Xapian::ReplicationInfo::fullcopy_count, RemoteConnection::get_message(), Xapian::DatabaseReplica::Internal::get_replica_path(), Xapian::DatabaseReplica::Internal::have_offline_db, Xapian::DatabaseReplica::Internal::last_live_changeset_time, Xapian::DatabaseReplica::Internal::live_db, Xapian::DatabaseReplica::Internal::live_id, LOGCALL, Xapian::DatabaseReplica::Internal::need_copy_next, RealTime::now(), Xapian::DatabaseReplica::Internal::offline_revision, Xapian::DatabaseReplica::Internal::offline_uuid, Xapian::InMemory::open(), Xapian::DatabaseReplica::Internal::possibly_make_offline_live(), Xapian::DatabaseReplica::Internal::remove_offline_db(), REPL_REPLY_CHANGESET, REPL_REPLY_DB_HEADER, REPL_REPLY_END_OF_CHANGES, REPL_REPLY_FAIL, RETURN, RealTime::sleep(), RemoteConnection::sniff_next_message_type(), Xapian::Internal::str(), and throw_connection_closed_unexpectedly().
Referenced by Xapian::DatabaseReplica::apply_next_changeset().
|
private |
Check that a message type is as expected.
Throws a NetworkError if the type is not the expected one.
Definition at line 439 of file replication.cc.
References Xapian::Internal::str(), and throw_connection_closed_unexpectedly().
Referenced by Xapian::DatabaseReplica::Internal::apply_db_copy(), and Xapian::DatabaseReplica::Internal::apply_next_changeset().
|
inline |
Return a string describing this object.
Definition at line 229 of file replication.cc.
|
inlineprivate |
Definition at line 204 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::apply_db_copy(), Xapian::DatabaseReplica::Internal::apply_next_changeset(), Xapian::DatabaseReplica::Internal::get_revision_info(), Xapian::DatabaseReplica::Internal::Internal(), Xapian::DatabaseReplica::Internal::possibly_make_offline_live(), and Xapian::DatabaseReplica::Internal::remove_offline_db().
string Xapian::DatabaseReplica::Internal::get_revision_info | ( | ) | const |
Get a string describing the current revision of the replica.
Definition at line 351 of file replication.cc.
References Xapian::DB_OPEN, encode_length(), Xapian::DatabaseReplica::Internal::get_replica_path(), Xapian::DatabaseReplica::Internal::live_db, Xapian::DatabaseReplica::Internal::live_id, LOGCALL, RETURN, and Xapian::Database::size().
Referenced by Xapian::DatabaseReplica::get_revision_info().
|
private |
Don't allow assignment.
|
private |
Check if the offline database has reached the required version.
If so, make it live, and remove the old live database.
Definition at line 453 of file replication.cc.
References Xapian::DB_OPEN, Xapian::DatabaseReplica::Internal::get_replica_path(), Xapian::DatabaseReplica::Internal::live_db, Xapian::DatabaseReplica::Internal::live_id, Xapian::DatabaseReplica::Internal::offline_needed_revision, Xapian::DatabaseReplica::Internal::offline_revision, Xapian::DatabaseReplica::Internal::offline_uuid, Xapian::InMemory::open(), Xapian::DatabaseReplica::Internal::remove_offline_db(), and Xapian::DatabaseReplica::Internal::update_stub_database().
Referenced by Xapian::DatabaseReplica::Internal::apply_next_changeset().
|
private |
Delete the offline database.
Definition at line 369 of file replication.cc.
References Xapian::DatabaseReplica::Internal::get_replica_path(), Xapian::DatabaseReplica::Internal::have_offline_db, Xapian::DatabaseReplica::Internal::live_id, and removedir().
Referenced by Xapian::DatabaseReplica::Internal::apply_next_changeset(), and Xapian::DatabaseReplica::Internal::possibly_make_offline_live().
void Xapian::DatabaseReplica::Internal::set_read_fd | ( | int | fd | ) |
Set the file descriptor to read changesets from.
Definition at line 489 of file replication.cc.
References Xapian::DatabaseReplica::Internal::conn.
|
private |
Update the stub database which points to a single database.
The stub database file is created at a separate path, and then atomically moved into place to replace the old stub database. This should allow searches to continue uninterrupted.
Definition at line 282 of file replication.cc.
References io_tmp_rename(), and REPLICA_STUB_BANNER.
Referenced by Xapian::DatabaseReplica::Internal::Internal(), and Xapian::DatabaseReplica::Internal::possibly_make_offline_live().
|
private |
The remote connection we're using.
Definition at line 173 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::apply_db_copy(), Xapian::DatabaseReplica::Internal::apply_next_changeset(), and Xapian::DatabaseReplica::Internal::set_read_fd().
|
private |
Do we have an offline database currently?
The offline database is a new copy of the database we're bringing up to the required revision, which can't yet be made live.
Definition at line 147 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::apply_db_copy(), Xapian::DatabaseReplica::Internal::apply_next_changeset(), and Xapian::DatabaseReplica::Internal::remove_offline_db().
|
private |
The time at which a changeset was last applied to the live database.
Set to 0 if no changeset applied to the live database so far.
Definition at line 170 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::apply_db_copy(), and Xapian::DatabaseReplica::Internal::apply_next_changeset().
|
mutableprivate |
The live database being replicated.
This needs to be mutable because it is sometimes lazily opened.
Definition at line 140 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::apply_next_changeset(), Xapian::DatabaseReplica::Internal::get_revision_info(), Xapian::DatabaseReplica::Internal::Internal(), and Xapian::DatabaseReplica::Internal::possibly_make_offline_live().
|
private |
The id of the currently live database in the replica (0 or 1).
Definition at line 134 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::apply_db_copy(), Xapian::DatabaseReplica::Internal::apply_next_changeset(), Xapian::DatabaseReplica::Internal::get_revision_info(), Xapian::DatabaseReplica::Internal::Internal(), Xapian::DatabaseReplica::Internal::possibly_make_offline_live(), and Xapian::DatabaseReplica::Internal::remove_offline_db().
|
private |
Flag to indicate that the only valid operation next is a full copy.
Definition at line 151 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::apply_db_copy(), and Xapian::DatabaseReplica::Internal::apply_next_changeset().
|
private |
The revision that the secondary database must reach before it can be made live.
Definition at line 164 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::apply_db_copy(), and Xapian::DatabaseReplica::Internal::possibly_make_offline_live().
|
private |
The revision that the secondary database has been updated to.
Definition at line 155 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::apply_db_copy(), Xapian::DatabaseReplica::Internal::apply_next_changeset(), and Xapian::DatabaseReplica::Internal::possibly_make_offline_live().
|
private |
The UUID of the secondary database.
Definition at line 159 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::apply_db_copy(), Xapian::DatabaseReplica::Internal::apply_next_changeset(), and Xapian::DatabaseReplica::Internal::possibly_make_offline_live().
|
private |
The path to the replica directory.
Definition at line 131 of file replication.cc.
Referenced by Xapian::DatabaseReplica::Internal::Internal().