xapian-core  1.4.20
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, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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 
34 std::string
36 {
37  return "remoteprog_" + sub_manager->get_dbtype();
38 }
39 
41 BackendManagerRemoteProg::do_get_database(const vector<string> & files)
42 {
43  // Default to a long (5 minute) timeout so that tests won't fail just
44  // because the host is slow or busy.
46 }
47 
50  const string & file)
51 {
52  string args = get_writable_database_args(name, file);
53 
54 #ifdef HAVE_VALGRIND
55  if (RUNNING_ON_VALGRIND) {
56  args.insert(0, XAPIAN_PROGSRV" ");
57  return Xapian::Remote::open_writable("./runsrv", args);
58  }
59 #endif
61 }
62 
65 {
66 #ifdef HAVE_VALGRIND
67  if (RUNNING_ON_VALGRIND) {
68  args.insert(0, XAPIAN_PROGSRV" ");
69  return Xapian::Remote::open_writable("./runsrv", args);
70  }
71 #endif
73 }
74 
76 BackendManagerRemoteProg::get_remote_database(const vector<string> & files,
77  unsigned int timeout)
78 {
79  string args = get_remote_database_args(files, timeout);
80 
81 #ifdef HAVE_VALGRIND
82  if (RUNNING_ON_VALGRIND) {
83  args.insert(0, XAPIAN_PROGSRV" ");
84  return Xapian::Remote::open("./runsrv", args);
85  }
86 #endif
88 }
89 
92 {
93  string args = get_remote_database_args(path, 300000);
94 
95 #ifdef HAVE_VALGRIND
96  if (RUNNING_ON_VALGRIND) {
97  args.insert(0, XAPIAN_PROGSRV" ");
98  return Xapian::Remote::open("./runsrv", args);
99  }
100 #endif
101  return Xapian::Remote::open(XAPIAN_PROGSRV, args);
102 }
103 
106 {
107  string args = get_writable_database_as_database_args();
108 
109 #ifdef HAVE_VALGRIND
110  if (RUNNING_ON_VALGRIND) {
111  args.insert(0, XAPIAN_PROGSRV" ");
112  return Xapian::Remote::open("./runsrv", args);
113  }
114 #endif
115  return Xapian::Remote::open(XAPIAN_PROGSRV, args);
116 }
117 
120 {
121  string args = get_writable_database_again_args();
122 
123 #ifdef HAVE_VALGRIND
124  if (RUNNING_ON_VALGRIND) {
125  args.insert(0, XAPIAN_PROGSRV" ");
126  return Xapian::Remote::open_writable("./runsrv", args);
127  }
128 #endif
130 }
Xapian::Database get_database_by_path(const std::string &path)
Get RemoteProg Xapian::Database instance of database at path.
This class is used to access a database, or a group of databases.
Definition: database.h:68
unsigned timeout
A timeout value in milliseconds.
Definition: types.h:100
Xapian::WritableDatabase get_writable_database(const std::string &name, const std::string &file)
Create a RemoteProg Xapian::WritableDatabase object indexing a single file.
STL namespace.
#define XAPIAN_PROGSRV
Xapian::Database get_remote_database(const std::vector< std::string > &files, unsigned int timeout)
Create a RemoteProg Xapian::Database with the specified timeout.
BackendManager subclass for remoteprog databases.
This class provides read/write access to a database.
Definition: database.h:785
Database open(const std::string &host, unsigned int port, useconds_t timeout=10000, useconds_t connect_timeout=10000)
Construct a Database object for read-only access to a remote database accessed via a TCP connection...
Xapian::WritableDatabase get_writable_database_again()
Create a WritableDatabase object for the last opened WritableDatabase.
Public interfaces for the Xapian library.
Xapian::WritableDatabase get_remote_writable_database(std::string args)
Create a RemoteProg Xapian::WritableDatabase object with specified args.
Xapian::Database do_get_database(const std::vector< std::string > &files)
Create a Xapian::Database object indexing multiple files.
Definition: header.h:151
WritableDatabase open_writable(const std::string &host, unsigned int port, useconds_t timeout=0, useconds_t connect_timeout=10000, int flags=0)
Construct a WritableDatabase object for update access to a remote database accessed via a TCP connect...
std::string get_dbtype() const
Return a string representing the current database type.
Xapian::Database get_writable_database_as_database()
Create a Database object for the last opened WritableDatabase.