xapian-core
1.4.27
|
Access to a database replica, for applying replication to it. More...
#include <replication.h>
Classes | |
class | Internal |
Internal implementation of DatabaseReplica. More... | |
Public Member Functions | |
~DatabaseReplica () | |
Destructor. More... | |
DatabaseReplica (const std::string &path) | |
Open a DatabaseReplica for the database at the specified path. More... | |
std::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... | |
std::string | get_description () const |
Return a string describing this object. More... | |
Private Member Functions | |
DatabaseReplica (const DatabaseReplica &other) | |
No copying. More... | |
void | operator= (const DatabaseReplica &other) |
No assignment. More... | |
Private Attributes | |
Internal * | internal |
Internals. More... | |
Access to a database replica, for applying replication to it.
Warning: the replication interface is currently experimental, and is liable to change between releases without warning.
Definition at line 114 of file replication.h.
|
private |
No copying.
DatabaseReplica::~DatabaseReplica | ( | ) |
|
explicit |
Open a DatabaseReplica for the database at the specified path.
The path should either point to a database previously created by a DatabaseReplica, or to a path which doesn't yet exist.
The path should always be in a directory which exists.
If the specified path does not contain a database, a database will be created when an appropriate changeset is supplied to the replica.
path | The path to make the replica at. |
Definition at line 234 of file replication.cc.
References LOGCALL_CTOR.
bool DatabaseReplica::apply_next_changeset | ( | ReplicationInfo * | info, |
double | reader_close_time | ||
) |
Read and apply the next changeset.
If no changesets are found on the file descriptor, returns false immediately.
If any changesets are found on the file descriptor, exactly one of them is applied.
A common way to use this method is to call it repeatedly until it returns false, with an appropriate gap between each call.
Information beyond the end of the next changeset may be read from the file descriptor and cached in the DatabaseReplica object. Therefore, the file descriptor shouldn't be accessed by any other external code, since it will be in an indeterminate state.
Note that if this raises an exception (other than DatabaseCorruptError) the database will be left in a valid and consistent state. It may or may not be changed from its initial state, and may or may not be fully synchronised with the master database.
info | If non-NULL, the supplied structure will be updated to reflect the changes read from the file descriptor. |
reader_close_time | Wait at least this many seconds between applying changesets to allow active readers to finish. |
Definition at line 261 of file replication.cc.
References Xapian::DatabaseReplica::Internal::apply_next_changeset(), Xapian::ReplicationInfo::clear(), internal, LOGCALL, and RETURN.
Referenced by apply_changeset().
string DatabaseReplica::get_description | ( | ) | const |
Return a string describing this object.
Definition at line 271 of file replication.cc.
string DatabaseReplica::get_revision_info | ( | ) | const |
Get a string describing the current revision of the replica.
The revision information includes a unique identifier for the master database that the replica is of, as well as information about the exact revision of the master database that the replica represents. This information allows the master database to send the appropriate changeset to mirror whatever changes have been made on the master.
Definition at line 247 of file replication.cc.
References Xapian::DatabaseReplica::Internal::get_revision_info(), internal, LOGCALL, and RETURN.
Referenced by get_changeset().
|
private |
No assignment.
void DatabaseReplica::set_read_fd | ( | int | fd | ) |
Set the file descriptor to read changesets from.
This will be remembered in the DatabaseReplica, but the caller is still responsible for closing it after it is finished with.
fd | The file descriptor to read the changeset from. |
Definition at line 254 of file replication.cc.
References LOGCALL_VOID.
Referenced by apply_changeset().
|
private |
Internals.
Definition at line 116 of file replication.h.
Referenced by apply_next_changeset(), and get_revision_info().