#include <replication.h>

Classes | |
| class | Internal |
| Internal implementation of DatabaseReplica. More... | |
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, double reader_close_time) |
| Read and apply the next changeset. | |
| void | close () |
| Close the DatabaseReplica. | |
| std::string | get_description () const |
| Return a string describing this object. | |
Private Attributes | |
| Xapian::Internal::RefCntPtr < Internal > | internal |
| Reference counted internals. | |
Warning: the replication interface is currently experimental, and is liable to change between releases without warning.
Definition at line 115 of file replication.h.
| DatabaseReplica::DatabaseReplica | ( | const DatabaseReplica & | other | ) |
Copying is allowed (and is cheap).
Definition at line 223 of file replication.cc.
References LOGCALL_CTOR.
| DatabaseReplica::DatabaseReplica | ( | ) |
Default constructor - for declaring an uninitialised replica.
Definition at line 236 of file replication.cc.
References LOGCALL_CTOR.
| DatabaseReplica::~DatabaseReplica | ( | ) |
| 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. |
Definition at line 242 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 272 of file replication.cc.
References Xapian::ReplicationInfo::clear(), internal, LOGCALL, and RETURN.
Referenced by apply_changeset().
| void 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.
Definition at line 284 of file replication.cc.
References LOGCALL.
Referenced by DEFINE_TESTCASE().
| string DatabaseReplica::get_description | ( | ) | const |
| 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 254 of file replication.cc.
References internal, LOGCALL, and RETURN.
Referenced by get_changeset().
| void DatabaseReplica::operator= | ( | const DatabaseReplica & | other | ) |
Assignment is allowed (and is cheap).
Definition at line 230 of file replication.cc.
References internal, and LOGCALL_VOID.
| 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 263 of file replication.cc.
References LOGCALL_VOID.
Referenced by apply_changeset().
Reference counted internals.
Definition at line 117 of file replication.h.
Referenced by apply_next_changeset(), get_revision_info(), and operator=().