Public Member Functions | |
DatabaseReplica (const DatabaseReplica &other) | |
Copying is allowed (and is cheap). | |
void | operator= (const DatabaseReplica &other) |
Assignment is allowed (and is cheap). | |
DatabaseReplica () | |
Default constructor - for declaring an uninitialised replica. | |
~DatabaseReplica () | |
Destructor. | |
DatabaseReplica (const std::string &path) | |
Open a DatabaseReplica for the database at the specified path. | |
std::string | get_revision_info () const |
Get a string describing the current revision of the replica. | |
void | set_read_fd (int fd) |
Set the file descriptor to read changesets from. | |
bool | apply_next_changeset (ReplicationInfo *info) |
Read and apply the next changeset. | |
void | close () |
Close the DatabaseReplica. | |
std::string | get_description () const |
Return a string describing this object. |
Warning: the replication interface is currently experimental, and is liable to change between releases without warning.
Xapian::DatabaseReplica::DatabaseReplica | ( | const std::string & | path | ) |
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. |
bool Xapian::DatabaseReplica::apply_next_changeset | ( | ReplicationInfo * | info | ) |
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. |
void Xapian::DatabaseReplica::close | ( | ) |
Close the DatabaseReplica.
After this has been called, there will no longer be a write lock on the database created by the DatabaseReplica, and if any of the methods of this object which access the database are called, they will throw an InvalidOperationError.
std::string Xapian::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.
void Xapian::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. |