Skip to content

Commit 1585ec1

Browse files
committed
ADProvenanceDBengine now initializes the Thallium server with a json configuration rather than the basic constructor
Mercury authorization key can now optionally be passed to ADProvenanceDBengine Added cmdline options to pass Mercury authorization key to pserver, driver and provdb_commit run_services.sh and chimbuko_config.sh now allow passing extra arguments to provdb_commit
1 parent a9a1f88 commit 1585ec1

9 files changed

Lines changed: 49 additions & 9 deletions

File tree

app/driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ optionalArgsParser & getOptionalArgsParser(){
8888
addOptionalCommandLineArg(p, provdb_addr_dir, "Directory in which the provenance database outputs its address files. If empty (default) the provenance DB will not be used.");
8989
addOptionalCommandLineArg(p, nprovdb_shards, "Number of provenance database shards. Clients connect to shards round-robin by rank (default 1)");
9090
addOptionalCommandLineArg(p, nprovdb_instances, "Number of provenance database instances. Shards are divided uniformly over instances. (default 1)");
91+
addOptionalCommandLineArg(p, provdb_mercury_auth_key, "Set the Mercury authorization key for connection to the provDB (default \"\")");
9192
#endif
9293
#ifdef _PERF_METRIC
9394
addOptionalCommandLineArg(p, perf_outputpath, "Output path for AD performance monitoring data. If an empty string (default) no output is written.");

app/provdb_commit.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ struct Args{
4949
int ninstances;
5050
int nshards;
5151
int freq_ms;
52-
53-
Args(): addr_file_dir("."), instance(0), ninstances(1), nshards(1), freq_ms(30000){}
52+
std::string provdb_mercury_auth_key; //An authorization key for initializing Mercury (optional, default "")
53+
54+
Args(): addr_file_dir("."), instance(0), ninstances(1), nshards(1), freq_ms(30000), provdb_mercury_auth_key(""){}
5455
};
5556

5657

@@ -63,7 +64,8 @@ int main(int argc, char** argv){
6364
addOptionalCommandLineArg(parser, ninstances, "Specify the number of server instances (default 1)");
6465
addOptionalCommandLineArg(parser, nshards, "Specify the total number of database shards (default 1)");
6566
addOptionalCommandLineArg(parser, freq_ms, "Specify the frequency in ms at which commit is called (default 30000)");
66-
67+
addOptionalCommandLineArg(parser, provdb_mercury_auth_key, "Set the Mercury authorization key for connection to the provDB (default \"\")");
68+
6769
if(argc-1 < parser.nMandatoryArgs() || (argc == 2 && std::string(argv[1]) == "-help")){
6870
parser.help(std::cout);
6971
return 0;
@@ -78,6 +80,11 @@ int main(int argc, char** argv){
7880
return 0;
7981
}
8082

83+
if(args.provdb_mercury_auth_key != ""){
84+
CprogressStream << "setting Mercury authorization key to \"" << args.provdb_mercury_auth_key << "\"" << std::endl;
85+
ADProvenanceDBengine::setMercuryAuthorizationKey(args.provdb_mercury_auth_key);
86+
}
87+
8188
ProvDBsetup setup(args.nshards, args.ninstances);
8289
std::string addr = setup.getInstanceAddress(args.instance, args.addr_file_dir);
8390
int instance_shard_offset = setup.getShardOffsetInstance(args.instance);

app/pserver.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct pserverArgs{
5454

5555
#ifdef ENABLE_PROVDB
5656
std::string provdb_addr_dir;
57+
std::string provdb_mercury_auth_key; //An authorization key for initializing Mercury (optional, default "")
5758
#endif
5859

5960
std::string prov_outputpath;
@@ -63,7 +64,7 @@ struct pserverArgs{
6364
, max_pollcyc_msg(10), zmq_io_thr(1), autoshutdown(true)
6465
#endif
6566
#ifdef ENABLE_PROVDB
66-
, provdb_addr_dir("")
67+
, provdb_addr_dir(""), provdb_mercury_auth_key("")
6768
#endif
6869
{}
6970

@@ -88,6 +89,7 @@ struct pserverArgs{
8889
#endif
8990
#ifdef ENABLE_PROVDB
9091
addOptionalCommandLineArg(p, provdb_addr_dir, "The directory containing the address file written out by the provDB server. An empty string will disable the connection to the global DB. (default empty, disabled)");
92+
addOptionalCommandLineArg(p, provdb_mercury_auth_key, "Set the Mercury authorization key for connection to the provDB (default \"\")");
9193
#endif
9294
addOptionalCommandLineArg(p, prov_outputpath, "Output global provenance data to this directory. Can be used in place of or in conjunction with the provenance database. An empty string \"\" (default) disables this output");
9395
addOptionalCommandLineArg(p, model_update_freq, "The frequency in ms at which the global AD model is updated (default 1000ms)");
@@ -158,6 +160,11 @@ int main (int argc, char ** argv){
158160
PSstatSender stat_sender(args.stat_send_freq);
159161

160162
#ifdef ENABLE_PROVDB
163+
if(args.provdb_mercury_auth_key != ""){
164+
progressStream << "Pserver: setting Mercury authorization key to \"" << args.provdb_mercury_auth_key << "\"" << std::endl;
165+
ADProvenanceDBengine::setMercuryAuthorizationKey(args.provdb_mercury_auth_key);
166+
}
167+
161168
PSProvenanceDBclient provdb_client;
162169
#endif
163170

include/chimbuko/ad/ADProvenanceDBengine.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ namespace chimbuko{
1919
struct data_v{
2020
thallium::engine* m_eng;
2121
std::pair<std::string, int> m_protocol; /**< The protocol and mode (client/server)*/
22+
std::string m_mercury_auth_key; /**< Mercury authorization key (optional)*/
23+
2224
bool m_is_initialized;
23-
inline data_v(): m_eng(nullptr), m_protocol({"ofi+tcp;ofi_rxm", THALLIUM_CLIENT_MODE}), m_is_initialized(false){}
25+
inline data_v(): m_eng(nullptr), m_protocol({"ofi+tcp;ofi_rxm", THALLIUM_CLIENT_MODE}), m_mercury_auth_key(""), m_is_initialized(false){}
2426

2527
/**
2628
* @brief Initialize the engine (if not already initialized)
@@ -52,6 +54,13 @@ namespace chimbuko{
5254
data().m_protocol = {transport, mode};
5355
}
5456

57+
/**
58+
* @brief Set the Mercury authorization key. Must be done before the engine is created
59+
*/
60+
static inline void setMercuryAuthorizationKey(const std::string &to){
61+
data().m_mercury_auth_key = to;
62+
}
63+
5564
/**
5665
* @brief Get the protocol used to create the engine.
5766
*/

include/chimbuko/chimbuko.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ namespace chimbuko {
4545
std::string provdb_addr_dir; /**< Directory in which the provenance database writes its address files. If an empty string the provDB will not be used*/
4646
int nprovdb_shards; /**< Number of database shards*/
4747
int nprovdb_instances; /**< Number of instances of the provenance database server*/
48+
std::string provdb_mercury_auth_key; /**< An authorization key for initializing Mercury (optional, default "")*/
4849
#endif
4950
int prov_record_startstep; /**< If != -1, the IO step on which to start recording provenance information for anomalies */
5051
int prov_record_stopstep; /**< If != -1, the IO step on which to stop recording provenance information for anomalies */

scripts/launch/chimbuko_config.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ provdb_auto_interface=true #if true, the server will automatically choose its in
3636
#With "verbs" provider (used for infiniband, iWarp, etc) we need to also specify the domain, which can be found by running fi_info (on a compute node)
3737
provdb_domain= #only needed for verbs provider. If left blank it will be chosen automatically. <------------ ***SET ME (if using verbs)***
3838

39+
commit_extra_args="" #extra arguments for the committer
40+
3941
export FI_UNIVERSE_SIZE=1600 # Defines the expected number of provenance DB clients per instance <------------- *** SET ME (should be larger than the number of clients/instance)
4042
export FI_MR_CACHE_MAX_COUNT=0 # disable MR cache in libfabric; still problematic as of libfabric 1.10.1
4143
export FI_OFI_RXM_USE_SRX=1 # use shared recv context in RXM; should improve scalability

scripts/launch/run_services.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ if (( ${use_provdb} == 1 )); then
159159
echo "Instantiating committer"
160160
echo "==========================================="
161161
for((i=0;i<provdb_ninstances;i++)); do
162-
echo "Chimbuko services launching provDB committer ${i} of ${provdb_ninstances}"
163-
provdb_commit "${provdb_addr_dir}" -instance ${i} -ninstances ${provdb_ninstances} -nshards ${provdb_nshards} -freq_ms ${provdb_commit_freq} > ${log_dir}/committer_${i}.log 2>&1 &
162+
echo "Chimbuko services launching provDB committer ${i} of ${provdb_ninstances} using extra args \"${commit_extra_args}\""
163+
provdb_commit "${provdb_addr_dir}" -instance ${i} -ninstances ${provdb_ninstances} -nshards ${provdb_nshards} -freq_ms ${provdb_commit_freq} ${commit_extra_args} > ${log_dir}/committer_${i}.log 2>&1 &
164164
sleep 1
165165
done
166166
sleep 3

src/ad/ADProvenanceDBengine.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include<chimbuko/ad/ADProvenanceDBclient.hpp>
22
#include<chimbuko/verbose.hpp>
3+
#include <nlohmann/json.hpp>
34

45
#ifdef ENABLE_PROVDB
56

@@ -9,7 +10,14 @@ using namespace chimbuko;
910
void ADProvenanceDBengine::data_v::initialize(){
1011
if(!m_is_initialized){
1112
verboseStream << "ADProvenanceDBengine initializing Thallium engine" << std::endl;
12-
m_eng = new thallium::engine(m_protocol.first, m_protocol.second, true, -1); //3rd arg: use dedicated progress thread, 4th arg: use this thread for RPCs
13+
14+
nlohmann::json cfgj;
15+
cfgj["use_progress_thread"] = true;
16+
cfgj["rpc_thread_count"] = -1; //use this thread for RPCs
17+
if(m_mercury_auth_key != "") cfgj["mercury"]["auth_key"] = m_mercury_auth_key;
18+
std::string config = cfgj.dump();
19+
20+
m_eng = new thallium::engine(m_protocol.first, m_protocol.second, config.c_str());
1321
m_is_initialized = true;
1422
verboseStream << "ADProvenanceDBengine initialized Thallium engine" << std::endl;
1523
}

src/chimbuko.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ChimbukoParams::ChimbukoParams(): rank(-1234), //not set!
2121
hbos_use_global_threshold(true),
2222
hbos_max_bins(200),
2323
#ifdef ENABLE_PROVDB
24-
provdb_addr_dir(""), nprovdb_shards(1), nprovdb_instances(1),
24+
provdb_addr_dir(""), nprovdb_shards(1), nprovdb_instances(1), provdb_mercury_auth_key(""),
2525
#endif
2626
prov_outputpath(""),
2727
prov_record_startstep(-1),
@@ -281,6 +281,11 @@ void Chimbuko::init_counter(){
281281

282282
#ifdef ENABLE_PROVDB
283283
void Chimbuko::init_provdb(){
284+
if(m_params.provdb_mercury_auth_key != ""){
285+
headProgressStream(m_params.rank) << "driver rank " << m_params.rank << " setting Mercury authorization key to \"" << m_params.provdb_mercury_auth_key << "\"" << std::endl;
286+
ADProvenanceDBengine::setMercuryAuthorizationKey(m_params.provdb_mercury_auth_key);
287+
}
288+
284289
m_provdb_client = new ADProvenanceDBclient(m_params.rank);
285290
if(m_params.provdb_addr_dir.length() > 0){
286291
headProgressStream(m_params.rank) << "driver rank " << m_params.rank << " connecting to provenance database" << std::endl;

0 commit comments

Comments
 (0)