Xapian::DatabaseReplica Class Reference

#include <replication.h>

List of all members.

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)
std::string get_revision_info () const
void set_read_fd (int fd)
bool apply_next_changeset (ReplicationInfo *info)
void close ()
std::string get_description () const
 Return a string describing this object.


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.


Constructor & Destructor Documentation

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

Copying is allowed (and is cheap).

Xapian::DatabaseReplica::DatabaseReplica (  ) 

Default constructor - for declaring an uninitialised replica.

Xapian::DatabaseReplica::~DatabaseReplica (  ) 

Destructor.

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.

Parameters:
path The path to make the replica at.


Member Function Documentation

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

Assignment is allowed (and is cheap).

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.

Parameters:
fd The file descriptor to read the changeset from.

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.

Parameters:
info If non-NULL, the supplied structure will be updated to reflect the changes read from the file descriptor.
Returns:
true if there are more changesets to apply on the file descriptor, false otherwise.

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_description (  )  const

Return a string describing this object.


The documentation for this class was generated from the following file:
Documentation for Xapian (version 1.1.1).
Generated on 10 Jun 2009 by Doxygen 1.5.2.