xapian-core  1.4.19
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Xapian::DatabaseReplica Class Reference

Access to a database replica, for applying replication to it. More...

#include <replication.h>

+ Collaboration diagram for Xapian::DatabaseReplica:

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

Internalinternal
 Internals. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DatabaseReplica() [1/2]

Xapian::DatabaseReplica::DatabaseReplica ( const DatabaseReplica other)
private

No copying.

◆ ~DatabaseReplica()

DatabaseReplica::~DatabaseReplica ( )

Destructor.

Definition at line 240 of file replication.cc.

References LOGCALL_DTOR.

◆ DatabaseReplica() [2/2]

DatabaseReplica::DatabaseReplica ( const std::string &  path)
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.

Parameters
pathThe path to make the replica at.

Definition at line 234 of file replication.cc.

References LOGCALL_CTOR.

Member Function Documentation

◆ apply_next_changeset()

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.

Parameters
infoIf non-NULL, the supplied structure will be updated to reflect the changes read from the file descriptor.
reader_close_timeWait at least this many seconds between applying changesets to allow active readers to finish.
Returns
true if there are more changesets to apply on the file descriptor, false otherwise.

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().

◆ get_description()

string DatabaseReplica::get_description ( ) const

Return a string describing this object.

Definition at line 271 of file replication.cc.

◆ get_revision_info()

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().

◆ operator=()

void Xapian::DatabaseReplica::operator= ( const DatabaseReplica other)
private

No assignment.

◆ set_read_fd()

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.

Parameters
fdThe file descriptor to read the changeset from.

Definition at line 254 of file replication.cc.

References LOGCALL_VOID.

Referenced by apply_changeset().

Member Data Documentation

◆ internal

Internal* Xapian::DatabaseReplica::internal
private

Internals.

Definition at line 116 of file replication.h.

Referenced by apply_next_changeset(), and get_revision_info().


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