Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
JSON Configuration from command line
Browse files Browse the repository at this point in the history
Summary: Treadmill currently supports a configuration file.  But specifying the configuration blob directly from a flag would be more convenient, otherwise we would have to add new logic to write a file just to be read back in.

Reviewed By: mackorone

Differential Revision: D4335439

fbshipit-source-id: b679e3db69879cf59d69dc59475990aedf01ae27
  • Loading branch information
Louis Kruger authored and facebook-github-bot committed Dec 16, 2016
1 parent c7c88f4 commit a50f1a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Treadmill.cpp
Expand Up @@ -76,6 +76,12 @@ DEFINE_string(config_in_file,
"",
"Config filename to pass into the workload in JSON format.");

DEFINE_string(config_in_json,
"",
"Configuration string to be parsed as JSON for the workload. "
"If --config_in_file is also specified, "
"the configs are merged.");

// Config filename to export from the workload in JSON format
DEFINE_string(config_out_file,
"",
Expand Down
8 changes: 8 additions & 0 deletions Treadmill.h
Expand Up @@ -15,6 +15,7 @@
#include <vector>

#include <folly/futures/helpers.h>
#include <folly/json.h>
#include <folly/String.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
Expand Down Expand Up @@ -59,6 +60,9 @@ DECLARE_int32(max_outstanding_requests);
// Config filename to pass into the workload in JSON format
DECLARE_string(config_in_file);

// Config string to pass into the workload in JSON format
DECLARE_string(config_in_json);

// Config filename to export from the workload in JSON format
DECLARE_string(config_out_file);

Expand Down Expand Up @@ -103,6 +107,10 @@ int run(int argc, char* argv[]) {
if (FLAGS_config_in_file != "") {
config = readDynamicFromFile(FLAGS_config_in_file);
}
if (FLAGS_config_in_json != "") {
folly::dynamic config2 = folly::parseJson(FLAGS_config_in_json);
config.update(config2);
}
int cpu_affinity_list[FLAGS_number_of_workers];
std::fill_n(cpu_affinity_list, FLAGS_number_of_workers, -1);

Expand Down

0 comments on commit a50f1a4

Please sign in to comment.