Skip to content

Commit 24534fb

Browse files
committed
Added option to pass file containing Margo configuration to the provDB
1 parent c6be943 commit 24534fb

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

app/provdb_admin.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ struct ProvdbArgs{
133133
std::string db_write_dir;
134134
bool db_in_mem; //database is in-memory not written to disk, for testing
135135
std::string db_base_config;
136+
std::string db_margo_config;
136137

137-
ProvdbArgs(): engine("ofi+tcp"), autoshutdown(true), nshards(1), db_type("unqlite"), nthreads(1), db_commit_freq(10000), db_write_dir("."), db_in_mem(false), db_base_config(""){}
138+
ProvdbArgs(): engine("ofi+tcp"), autoshutdown(true), nshards(1), db_type("unqlite"), nthreads(1), db_commit_freq(10000), db_write_dir("."), db_in_mem(false), db_base_config(""), db_margo_config(""){}
138139
};
139140

140141

@@ -162,6 +163,7 @@ int main(int argc, char** argv) {
162163
addOptionalCommandLineArg(parser, db_write_dir, "Specify the directory in which the database shards will be written (default \".\")");
163164
addOptionalCommandLineArg(parser, db_in_mem, "Use an in-memory database rather than writing to disk (*unqlite backend only*) (default false)");
164165
addOptionalCommandLineArg(parser, db_base_config, "Provide the *absolute path* to a JSON file to use as the base configuration of the Sonata databases. The database path will be appended automatically (default \"\" - not used)");
166+
addOptionalCommandLineArg(parser, db_margo_config, "Provide the *absolute path* to a JSON file containing the Margo configuration (default \"\" - not used)");
165167

166168
if(argc-1 < parser.nMandatoryArgs() || (argc == 2 && std::string(argv[1]) == "-help")){
167169
parser.help(std::cout);
@@ -181,6 +183,7 @@ int main(int argc, char** argv) {
181183
eng_opt += std::string("://") + args.ip;
182184
}
183185

186+
//Get Sonata config
184187
nlohmann::json base_config;
185188
if(args.db_base_config.size() > 0){
186189
std::ifstream in(args.db_base_config);
@@ -190,13 +193,18 @@ int main(int argc, char** argv) {
190193

191194
progressStream << "ProvDB Admin: initializing thallium with address: " << eng_opt << std::endl;
192195

193-
//Disable loopback so that RPC calls from this process are forced to go through the net interface
194-
hg_init_info info;
195-
memset(&info, 0, sizeof(info));
196-
info.no_loopback = HG_TRUE;
196+
//Get Margo config
197+
std::string margo_config = stringize("{ \"rpc_thread_count\" : %d, \"use_progress_thread\" : true }", args.nthreads);
198+
if(args.db_margo_config.size() > 0){
199+
std::ifstream in(args.db_margo_config);
200+
if(in.fail()){ throw std::runtime_error("Failed to read Margo config file " + args.db_margo_config); }
201+
auto cfg = nlohmann::json::parse(in);
202+
margo_config = cfg.dump();
203+
}
204+
progressStream << "ProvDB Admin: Margo configuration " << margo_config << std::endl;
197205

198206
//Initialize provider engine
199-
tl::engine engine(eng_opt, THALLIUM_SERVER_MODE, true, args.nthreads, &info);
207+
tl::engine engine(eng_opt, THALLIUM_SERVER_MODE, margo_config);
200208
margo_id = engine.get_margo_instance();
201209

202210
#ifdef _PERF_METRIC

0 commit comments

Comments
 (0)