xapian-core  2.0.0
databasereplicator.cc
Go to the documentation of this file.
1 
4 /* Copyright 2008 Lemur Consulting Ltd
5  * Copyright 2009,2010,2011,2012 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, see
19  * <https://www.gnu.org/licenses/>.
20  */
21 
22 #include <config.h>
23 
24 #include "databasereplicator.h"
25 
26 #include "xapian/error.h"
27 #include "xapian/version.h" // For XAPIAN_HAS_XXX_BACKEND.
28 
29 #include "debuglog.h"
30 #include "filetests.h"
31 
32 #if defined XAPIAN_HAS_GLASS_BACKEND && defined XAPIAN_HAS_REMOTE_BACKEND
34 #endif
35 
36 using namespace std;
37 
38 namespace Xapian {
39 
40 DatabaseReplicator::~DatabaseReplicator()
41 {
42 }
43 
45 DatabaseReplicator::open(const string & path)
46 {
47  LOGCALL_STATIC(DB, DatabaseReplicator *, "DatabaseReplicator::open", path);
48 
49 #ifdef XAPIAN_HAS_GLASS_BACKEND
50  if (file_exists(path + "/iamglass")) {
51 # ifdef XAPIAN_HAS_REMOTE_BACKEND
52  return new GlassDatabaseReplicator(path);
53 # else
54  throw FeatureUnavailableError("Replication disabled");
55 # endif
56  }
57 #endif
58 
59  // FIXME: Replication of honey databases.
60 
61  if (file_exists(path + "/iamchert")) {
62  throw FeatureUnavailableError("Chert backend no longer supported");
63  }
64 
65  if (file_exists(path + "/iamflint")) {
66  throw FeatureUnavailableError("Flint backend no longer supported");
67  }
68 
69  if (file_exists(path + "/iambrass")) {
70  throw FeatureUnavailableError("Brass backend no longer supported");
71  }
72 
73  throw DatabaseOpeningError("Couldn't detect type of database: " + path);
74 }
75 
76 }
DatabaseOpeningError indicates failure to open a database.
Definition: error.h:569
Base class for database replicator objects.
Indicates an attempt to use a feature which is unavailable.
Definition: error.h:707
Class to manage replication of databases.
Debug logging macros.
#define LOGCALL_STATIC(CATEGORY, TYPE, FUNC, PARAMS)
Definition: debuglog.h:482
Hierarchy of classes which Xapian can throw as exceptions.
Utility functions for testing files.
bool file_exists(const char *path)
Test if a file exists.
Definition: filetests.h:40
Support for glass database replication.
Database open(std::string_view host, unsigned int port, unsigned timeout=10000, unsigned connect_timeout=10000)
Construct a Database object for read-only access to a remote database accessed via a TCP connection.
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:82
Define preprocessor symbols for the library version.