xapian-core  2.0.0
backendmanager_remoteprog.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2008,2009 Olly Betts
5  * Copyright (C) 2008 Lemur Consulting Ltd
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 
25 
26 #include <xapian.h>
27 
28 #ifdef HAVE_VALGRIND
29 # include <valgrind/memcheck.h>
30 #endif
31 
32 using namespace std;
33 
35 BackendManagerRemoteProg::do_get_database(const vector<string> & files)
36 {
37  // Default to a long (5 minute) timeout so that tests won't fail just
38  // because the host is slow or busy.
40  nullptr);
41 }
42 
45  const string & file)
46 {
47  string args = get_writable_database_args(name, file);
48 
49 #ifdef HAVE_VALGRIND
50  if (RUNNING_ON_VALGRIND) {
51  args.insert(0, XAPIAN_PROGSRV" ");
52  return Xapian::Remote::open_writable("./runsrv", args);
53  }
54 #endif
56 }
57 
60 {
61 #ifdef HAVE_VALGRIND
62  if (RUNNING_ON_VALGRIND) {
63  args.insert(0, XAPIAN_PROGSRV" ");
64  return Xapian::Remote::open_writable("./runsrv", args);
65  }
66 #endif
68 }
69 
71 BackendManagerRemoteProg::get_remote_database(const vector<string> & files,
72  unsigned int timeout,
73  int* port_ptr)
74 {
75  string args = get_remote_database_args(files, timeout);
76 
77  // No port for remoteprog.
78  if (port_ptr) *port_ptr = 0;
79 
80 #ifdef HAVE_VALGRIND
81  if (RUNNING_ON_VALGRIND) {
82  args.insert(0, XAPIAN_PROGSRV" ");
83  return Xapian::Remote::open("./runsrv", args);
84  }
85 #endif
87 }
88 
91 {
92  string args = get_remote_database_args(path, 300000);
93 
94 #ifdef HAVE_VALGRIND
95  if (RUNNING_ON_VALGRIND) {
96  args.insert(0, XAPIAN_PROGSRV" ");
97  return Xapian::Remote::open("./runsrv", args);
98  }
99 #endif
100  return Xapian::Remote::open(XAPIAN_PROGSRV, args);
101 }
102 
105 {
106  string args = get_writable_database_as_database_args();
107 
108 #ifdef HAVE_VALGRIND
109  if (RUNNING_ON_VALGRIND) {
110  args.insert(0, XAPIAN_PROGSRV" ");
111  return Xapian::Remote::open("./runsrv", args);
112  }
113 #endif
114  return Xapian::Remote::open(XAPIAN_PROGSRV, args);
115 }
116 
119 {
120  string args = get_writable_database_again_args();
121 
122 #ifdef HAVE_VALGRIND
123  if (RUNNING_ON_VALGRIND) {
124  args.insert(0, XAPIAN_PROGSRV" ");
125  return Xapian::Remote::open_writable("./runsrv", args);
126  }
127 #endif
129 }
#define XAPIAN_PROGSRV
BackendManager subclass for remoteprog databases.
Xapian::WritableDatabase get_writable_database_again()
Create a WritableDatabase object for the last opened WritableDatabase.
Xapian::WritableDatabase get_remote_writable_database(std::string args)
Create a RemoteProg Xapian::WritableDatabase object with specified args.
Xapian::Database get_writable_database_as_database()
Create a Database object for the last opened WritableDatabase.
Xapian::Database get_remote_database(const std::vector< std::string > &files, unsigned int timeout, int *port_ptr)
Create a RemoteProg Xapian::Database with the specified timeout.
Xapian::WritableDatabase get_writable_database(const std::string &name, const std::string &file)
Create a RemoteProg Xapian::WritableDatabase object indexing a single file.
Xapian::Database get_database_by_path(const std::string &path)
Get RemoteProg Xapian::Database instance of database at path.
Xapian::Database do_get_database(const std::vector< std::string > &files)
Create a Xapian::Database object indexing multiple files.
An indexed database of documents.
Definition: database.h:75
This class provides read/write access to a database.
Definition: database.h:964
WritableDatabase open_writable(std::string_view host, unsigned int port, unsigned timeout=0, unsigned connect_timeout=10000, int flags=0)
Construct a WritableDatabase object for update access to a remote database accessed via a TCP connect...
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.
Definition: header.h:215
Public interfaces for the Xapian library.