1 /** @file
2  * @brief Support for glass database replication
3  */
4 /* Copyright 2008 Lemur Consulting Ltd
5  * Copyright 2009,2010,2011,2014 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_GLASS_DATABASEREPLICATOR_H
24 #define XAPIAN_INCLUDED_GLASS_DATABASEREPLICATOR_H
25 
26 #include "backends/databasereplicator.h"
27 #include "glass_defs.h"
28 
29 class GlassDatabaseReplicator : public Xapian::DatabaseReplicator {
30     /** Path of database.
31      */
32     std::string db_dir;
33 
34     /** File descriptors for writing to each table.
35      *
36      *  The corresponding entry is -1 if that table is not yet opened.
37      */
38     mutable int fds[Glass::MAX_];
39 
40     /** Process a chunk which holds a version file.
41      */
42     void process_changeset_chunk_version(std::string & buf,
43 					 RemoteConnection & conn,
44 					 double end_time) const;
45 
46     /** Process a chunk which holds a list of changed blocks in the
47      *  database.
48      */
49     void process_changeset_chunk_blocks(Glass::table_type table,
50 					unsigned v,
51 					std::string & buf,
52 					RemoteConnection & conn,
53 					double end_time) const;
54 
55     void commit() const;
56 
57   public:
58     explicit GlassDatabaseReplicator(const std::string & db_dir_);
59 
60     ~GlassDatabaseReplicator();
61 
62     /** Virtual methods of DatabaseReplicator. */
63     //@{
64     bool check_revision_at_least(const std::string & rev,
65 				 const std::string & target) const;
66     std::string apply_changeset_from_conn(RemoteConnection & conn,
67 					  double end_time,
68 					  bool valid) const;
69     std::string get_uuid() const;
70     //@}
71 };
72 
73 #endif /* XAPIAN_INCLUDED_GLASS_DATABASEREPLICATOR_H */
74