LCOV - code coverage report
Current view: top level - backends - databasereplicator.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 1 1 100.0 %
Date: 2019-06-30 05:20:33 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /** @file databasereplicator.h
       2                 :            :  * @brief Class to manage replication of databases.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2008 Lemur Consulting Ltd
       5                 :            :  * Copyright (C) 2009,2010 Olly Betts
       6                 :            :  *
       7                 :            :  * This program is free software; you can redistribute it and/or
       8                 :            :  * modify it under the terms of the GNU General Public License as
       9                 :            :  * published by the Free Software Foundation; either version 2 of the
      10                 :            :  * License, or (at your option) any later version.
      11                 :            :  *
      12                 :            :  * This program is distributed in the hope that it will be useful,
      13                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :            :  * GNU General Public License for more details.
      16                 :            :  *
      17                 :            :  * You should have received a copy of the GNU General Public License
      18                 :            :  * along with this program; if not, write to the Free Software
      19                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      20                 :            :  * USA
      21                 :            :  */
      22                 :            : 
      23                 :            : #ifndef XAPIAN_INCLUDED_DATABASEREPLICATOR_H
      24                 :            : #define XAPIAN_INCLUDED_DATABASEREPLICATOR_H
      25                 :            : 
      26                 :            : #include <string>
      27                 :            : 
      28                 :            : #include "xapian/types.h"
      29                 :            : 
      30                 :            : class RemoteConnection;
      31                 :            : 
      32                 :            : namespace Xapian {
      33                 :            : 
      34                 :            : /** Base class for database replicator objects.
      35                 :            :  *
      36                 :            :  *  This is subclassed by each database backend which supports replication.
      37                 :            :  */
      38                 :            : class DatabaseReplicator {
      39                 :            :     /// Copies are not allowed.
      40                 :            :     DatabaseReplicator(const DatabaseReplicator &);
      41                 :            : 
      42                 :            :     /// Assignment is not allowed.
      43                 :            :     void operator=(const DatabaseReplicator &);
      44                 :            : 
      45                 :            :   protected:
      46                 :            :     /** Constructor to allow construction of subclasses from the open()
      47                 :            :      *  method.
      48                 :            :      */
      49                 :         77 :     DatabaseReplicator() { }
      50                 :            : 
      51                 :            :   public:
      52                 :            :     /** Destroy the replicator.
      53                 :            :      */
      54                 :            :     virtual ~DatabaseReplicator();
      55                 :            : 
      56                 :            :     /** Open a DatabaseReplicator for the given path.
      57                 :            :      *
      58                 :            :      *  The type of the database at the path is automatically detected.
      59                 :            :      */
      60                 :            :     static DatabaseReplicator * open(const std::string & path);
      61                 :            : 
      62                 :            :     /** Check if the revision of the database is at least that of a target.
      63                 :            :      *
      64                 :            :      *  @param rev The database revision.
      65                 :            :      *  @param target The target revision.
      66                 :            :      */
      67                 :            :     virtual bool check_revision_at_least(const std::string & rev,
      68                 :            :                                          const std::string & target) const = 0;
      69                 :            : 
      70                 :            :     /** Read and apply the next changeset.
      71                 :            :      *
      72                 :            :      *  @param conn The remote connection manager.
      73                 :            :      *
      74                 :            :      *  @param end_time The time to timeout at.
      75                 :            :      *
      76                 :            :      *  @param db_valid Whether the database is known to be valid at the
      77                 :            :      *  start of the changeset.  If this is true, some additional checks
      78                 :            :      *  are performed.
      79                 :            :      */
      80                 :            :     virtual std::string apply_changeset_from_conn(RemoteConnection & conn,
      81                 :            :                                                   double end_time,
      82                 :            :                                                   bool db_valid) const = 0;
      83                 :            : 
      84                 :            :     /** Get a UUID for the replica.
      85                 :            :      *
      86                 :            :      *  If the UUID cannot be read (for example, because the database is
      87                 :            :      *  not valid), this should return the empty string, rather than
      88                 :            :      *  raising an exception.
      89                 :            :      */
      90                 :            :     virtual std::string get_uuid() const = 0;
      91                 :            : };
      92                 :            : 
      93                 :            : }
      94                 :            : 
      95                 :            : #endif /* XAPIAN_INCLUDED_DATABASEREPLICATOR_H */

Generated by: LCOV version 1.11