xapian-core  1.4.27
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 
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 }
41 
44  const string & file)
45 {
46  string args = get_writable_database_args(name, file);
47 
48 #ifdef HAVE_VALGRIND
49  if (RUNNING_ON_VALGRIND) {
50  args.insert(0, XAPIAN_PROGSRV" ");
51  return Xapian::Remote::open_writable("./runsrv", args);
52  }
53 #endif
55 }
56 
59 {
60 #ifdef HAVE_VALGRIND
61  if (RUNNING_ON_VALGRIND) {
62  args.insert(0, XAPIAN_PROGSRV" ");
63  return Xapian::Remote::open_writable("./runsrv", args);
64  }
65 #endif
67 }
68 
70 BackendManagerRemoteProg::get_remote_database(const vector<string> & files,
71  unsigned int timeout)
72 {
73  string args = get_remote_database_args(files, timeout);
74 
75 #ifdef HAVE_VALGRIND
76  if (RUNNING_ON_VALGRIND) {
77  args.insert(0, XAPIAN_PROGSRV" ");
78  return Xapian::Remote::open("./runsrv", args);
79  }
80 #endif
82 }
83 
86 {
87  string args = get_remote_database_args(path, 300000);
88 
89 #ifdef HAVE_VALGRIND
90  if (RUNNING_ON_VALGRIND) {
91  args.insert(0, XAPIAN_PROGSRV" ");
92  return Xapian::Remote::open("./runsrv", args);
93  }
94 #endif
96 }
97 
100 {
101  string args = get_writable_database_as_database_args();
102 
103 #ifdef HAVE_VALGRIND
104  if (RUNNING_ON_VALGRIND) {
105  args.insert(0, XAPIAN_PROGSRV" ");
106  return Xapian::Remote::open("./runsrv", args);
107  }
108 #endif
109  return Xapian::Remote::open(XAPIAN_PROGSRV, args);
110 }
111 
114 {
115  string args = get_writable_database_again_args();
116 
117 #ifdef HAVE_VALGRIND
118  if (RUNNING_ON_VALGRIND) {
119  args.insert(0, XAPIAN_PROGSRV" ");
120  return Xapian::Remote::open_writable("./runsrv", args);
121  }
122 #endif
124 }
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:789
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...
Xapian::Database get_writable_database_as_database()
Create a Database object for the last opened WritableDatabase.