00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include "backendmanager_remoteprog.h"
00024
00025 #include <xapian.h>
00026
00027 #include "utils.h"
00028
00029 #ifdef HAVE_VALGRIND
00030 # include <valgrind/memcheck.h>
00031 #endif
00032
00033 using namespace std;
00034
00035 BackendManagerRemoteProg::~BackendManagerRemoteProg() { }
00036
00037 const char *
00038 BackendManagerRemoteProg::get_dbtype() const
00039 {
00040 return "remoteprog";
00041 }
00042
00043 Xapian::Database
00044 BackendManagerRemoteProg::get_database(const vector<string> & files)
00045 {
00046
00047
00048 return BackendManagerRemoteProg::get_remote_database(files, 300000);
00049 }
00050
00051 Xapian::Database
00052 BackendManagerRemoteProg::get_database(const string & file)
00053 {
00054 return BackendManagerRemoteProg::get_database(vector<string>(1, file));
00055 }
00056
00057 Xapian::WritableDatabase
00058 BackendManagerRemoteProg::get_writable_database(const string & name,
00059 const string & file)
00060 {
00061 last_wdb_name = name;
00062
00063 vector<string> files(1, file);
00064
00065
00066 string args = "-t300000 --writable ";
00067
00068 #ifdef XAPIAN_HAS_FLINT_BACKEND
00069 (void)getwritedb_flint(name, files);
00070 args += ".flint/";
00071 #else
00072 (void)getwritedb_quartz(name, files);
00073 args += ".quartz/";
00074 #endif
00075 args += name;
00076
00077 #ifdef HAVE_VALGRIND
00078 if (RUNNING_ON_VALGRIND) {
00079 args.insert(0, XAPIAN_PROGSRV" ");
00080 return Xapian::Remote::open_writable("./runsrv", args);
00081 }
00082 #endif
00083 return Xapian::Remote::open_writable(XAPIAN_PROGSRV, args);
00084 }
00085
00086 Xapian::Database
00087 BackendManagerRemoteProg::get_remote_database(const vector<string> & files,
00088 unsigned int timeout)
00089 {
00090 string args = "-t";
00091 args += om_tostring(timeout);
00092 args += ' ';
00093 #ifdef XAPIAN_HAS_FLINT_BACKEND
00094 args += createdb_flint(files);
00095 #else
00096 args += createdb_quartz(files);
00097 #endif
00098 #ifdef HAVE_VALGRIND
00099 if (RUNNING_ON_VALGRIND) {
00100 args.insert(0, XAPIAN_PROGSRV" ");
00101 return Xapian::Remote::open("./runsrv", args);
00102 }
00103 #endif
00104 return Xapian::Remote::open(XAPIAN_PROGSRV, args);
00105 }
00106
00107 Xapian::Database
00108 BackendManagerRemoteProg::get_writable_database_as_database()
00109 {
00110 string args = "-t300000 ";
00111 #ifdef XAPIAN_HAS_FLINT_BACKEND
00112 args += ".flint/";
00113 #else
00114 args += ".quartz/";
00115 #endif
00116 args += last_wdb_name;
00117
00118 #ifdef HAVE_VALGRIND
00119 if (RUNNING_ON_VALGRIND) {
00120 args.insert(0, XAPIAN_PROGSRV" ");
00121 return Xapian::Remote::open("./runsrv", args);
00122 }
00123 #endif
00124 return Xapian::Remote::open(XAPIAN_PROGSRV, args);
00125 }
00126
00127 Xapian::WritableDatabase
00128 BackendManagerRemoteProg::get_writable_database_again()
00129 {
00130 string args = "-t300000 --writable ";
00131 #ifdef XAPIAN_HAS_FLINT_BACKEND
00132 args += ".flint/";
00133 #else
00134 args += ".quartz/";
00135 #endif
00136 args += last_wdb_name;
00137
00138 #ifdef HAVE_VALGRIND
00139 if (RUNNING_ON_VALGRIND) {
00140 args.insert(0, XAPIAN_PROGSRV" ");
00141 return Xapian::Remote::open_writable("./runsrv", args);
00142 }
00143 #endif
00144 return Xapian::Remote::open_writable(XAPIAN_PROGSRV, args);
00145 }