Skip to content

Commit 7d5e886

Browse files
committed
Added a --num-commports argument to the wrench daemon
1 parent bbf053b commit 7d5e886

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

tools/wrench/wrench-daemon/include/SimulationLauncher.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class SimulationLauncher {
2323
~SimulationLauncher() = default;
2424

2525
void createSimulation(bool full_log,
26+
unsigned long num_commports,
2627
const std::string &platform_xml,
2728
const std::string &controller_host,
2829
int sleep_us);

tools/wrench/wrench-daemon/include/WRENCHDaemon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class WRENCHDaemon {
3434
public:
3535
WRENCHDaemon(bool simulation_logging,
3636
bool daemon_logging,
37+
unsigned long num_commports,
3738
int port_number,
3839
int fixed_simulation_port_number,
3940
const std::string &allowed_origin,
@@ -64,6 +65,7 @@ class WRENCHDaemon {
6465

6566
bool simulation_logging;
6667
bool daemon_logging;
68+
unsigned long num_commports;
6769
int port_number;
6870
int fixed_simulation_port_number;
6971
std::string allowed_origin;

tools/wrench/wrench-daemon/src/SimulationLauncher.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
* simple sets an error message variable and returns
2323
*
2424
* @param full_log: whether to show all simulation log
25+
* @param num_commports: the number of comm ports to use
2526
* @param platform_xml: XML platform description (an XML string - not a file path)
2627
* @param controller_host: hostname of the host that will run the execution_controller
2728
* @param sleep_us: number of microseconds to sleep at each iteration of the main loop
2829
*/
2930
void SimulationLauncher::createSimulation(bool full_log,
31+
unsigned long num_commports,
3032
const std::string &platform_xml,
3133
const std::string &controller_host,
3234
int sleep_us) {
@@ -35,11 +37,12 @@ void SimulationLauncher::createSimulation(bool full_log,
3537

3638
try {
3739
// Set up command-line arguments
38-
int argc = (full_log ? 2 : 1);
40+
int argc = (full_log ? 3 : 2);
3941
char **argv = (char **) calloc((size_t) argc, sizeof(char *));
4042
argv[0] = strdup("wrench-daemon-simulation");
41-
if (argc > 1) {
42-
argv[1] = strdup("--wrench-full-log");
43+
argv[1] = strdup(("--wrench-commport-pool-size=" + std::to_string(num_commports)).c_str());
44+
if (argc > 2) {
45+
argv[2] = strdup("--wrench-full-log");
4346
}
4447

4548
simulation = wrench::Simulation::createSimulation();

tools/wrench/wrench-daemon/src/WRENCHDaemon.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ std::vector<std::string> WRENCHDaemon::allowed_origins;
3636
* @brief Constructor
3737
* @param simulation_logging true if simulation logging should be printed
3838
* @param daemon_logging true if daemon logging should be printed
39+
* @param num_commports the number of commports to use
3940
* @param port_number port number on which to listen for 'start simulation' requests
4041
* @param simulation_port_number port number on which to listen for a new simulation (0 means: use a random port each time)
4142
* @param allowed_origin allowed origin for http connection
@@ -44,11 +45,13 @@ std::vector<std::string> WRENCHDaemon::allowed_origins;
4445
*/
4546
WRENCHDaemon::WRENCHDaemon(bool simulation_logging,
4647
bool daemon_logging,
48+
unsigned long num_commports,
4749
int port_number,
4850
int simulation_port_number,
4951
const std::string &allowed_origin,
5052
int sleep_us) : simulation_logging(simulation_logging),
5153
daemon_logging(daemon_logging),
54+
num_commports(num_commports),
5255
port_number(port_number),
5356
fixed_simulation_port_number(simulation_port_number),
5457
sleep_us(sleep_us) {
@@ -240,6 +243,7 @@ void WRENCHDaemon::startSimulation(const Request &req, Response &res) {
240243
auto simulation_thread = std::thread([simulation_launcher, this, body, &guard, &signal]() {
241244
// Create simulation
242245
simulation_launcher->createSimulation(this->simulation_logging,
246+
this->num_commports,
243247
body["platform_xml"],
244248
body["controller_hostname"],
245249
this->sleep_us);

tools/wrench/wrench-daemon/src/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ int main(int argc, char **argv) {
4343
"Show full simulation log during execution")
4444
("daemon-logging", po::bool_switch()->default_value(false),
4545
"Show full daemon log during execution")
46+
("num-commports", po::value<unsigned long>()->default_value(5000)->notifier(in(1, 100000, "port")),
47+
"The number of commports that the simulation can use")
4648
("port", po::value<int>()->default_value(8101)->notifier(in(1024, 49151, "port")),
4749
"A port number, between 1024 and 4951, on which this daemon will listen for 'start simulation' requests")
4850
("allow-origin", po::value<std::string>()->default_value(""),
@@ -69,6 +71,11 @@ int main(int argc, char **argv) {
6971
cerr << "Error: " << e.what() << "\n";
7072
exit(1);
7173
}
74+
75+
unsigned long num_commports = 5000;
76+
if (vm.count("num-commports")) {
77+
num_commports = vm["num-commports"].as<unsigned long>();
78+
}
7279

7380
int simulation_port = 0;
7481
if (vm.count("simulation-port")) {
@@ -78,6 +85,7 @@ int main(int argc, char **argv) {
7885
// Create and run the WRENCH daemon
7986
WRENCHDaemon daemon(vm["simulation-logging"].as<bool>(),
8087
vm["daemon-logging"].as<bool>(),
88+
num_commports,
8189
vm["port"].as<int>(),
8290
simulation_port,
8391
vm["allow-origin"].as<std::string>(),

0 commit comments

Comments
 (0)