xapian-core  1.4.26
backendmanager_remote.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2006,2007,2008,2009,2011,2015 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 #include "backendmanager_remote.h"
24 
25 #include "backendmanager_glass.h"
26 #include <cstdlib>
27 #include <string>
28 #include "str.h"
29 
30 std::string
33 }
34 
37 {
38  return sub_manager->get_writable_database(name, std::string());
39 }
40 
41 std::string
43  const std::string & file)
44 {
45  // Default to a long (5 minute) timeout so that tests won't fail just
46  // because the host is slow or busy.
47  std::string args = "-t300000 --writable ";
48 
51 
52  return args;
53 }
54 
55 std::string
57  unsigned int timeout)
58 {
59  std::string args = "-t";
60  args += str(timeout);
61  args += " --writable ";
62  args += path;
63  return args;
64 }
65 
66 std::string
67 BackendManagerRemote::get_remote_database_args(const std::vector<std::string> & files,
68  unsigned int timeout)
69 {
70  std::string args = "-t";
71  args += str(timeout);
72  args += ' ';
73  args += sub_manager->get_database_path(files);
74  return args;
75 }
76 
77 std::string
79  unsigned int timeout)
80 {
81  std::string args = "-t";
82  args += str(timeout);
83  args += ' ';
84  args += path;
85  return args;
86 }
87 
88 std::string
90 {
91  std::string args = "-t300000 ";
93  return args;
94 }
95 
96 std::string
98 {
99  std::string args = "-t300000 --writable ";
101  return args;
102 }
Xapian::WritableDatabase get_generated_database(const std::string &name)
Get generated database.
unsigned timeout
A timeout value in milliseconds.
Definition: types.h:100
std::string get_database_path(const std::vector< std::string > &files)
Get the path of a database instance, if such a thing exists.
Convert types to std::string.
std::string get_writable_database_args(const std::string &name, const std::string &file)
Get the args for opening a remote database indexing a single file.
virtual std::string get_writable_database_path(const std::string &name)
Get the path of a writable database instance, if such a thing exists.
virtual Xapian::WritableDatabase get_writable_database(const std::string &name, const std::string &file)
Get a writable database instance.
std::string get_writable_database_again_args()
Get the args for opening the last opened WritableDatabase again.
BackendManager subclass for remote databases.
std::string get_writable_database_as_database_args()
Get the args for opening the last opened WritableDatabase.
This class provides read/write access to a database.
Definition: database.h:789
string str(int value)
Convert int to std::string.
Definition: str.cc:90
virtual std::string get_writable_database_path_again()
Get the path of the last opened WritableDatabase.
BackendManager subclass for glass databases.
BackendManager * sub_manager
std::string get_generated_database_path(const std::string &name)
Get generated database path from sub_manager.
Definition: header.h:151
std::string get_remote_database_args(const std::vector< std::string > &files, unsigned int timeout)
Get the args for opening a remote database with the specified timeout.