| 535 | }; // ./tutorial -C $CLUSTER_FILE_PATH fdbStatusStresser |
| 536 | |
| 537 | int main(int argc, char* argv[]) { |
| 538 | bool isServer = false; |
| 539 | std::string port; |
| 540 | std::vector<std::function<Future<Void>()>> toRun; |
| 541 | // parse arguments |
| 542 | for (int i = 1; i < argc; ++i) { |
| 543 | std::string arg(argv[i]); |
| 544 | if (arg == "-p") { |
| 545 | isServer = true; |
| 546 | if (i + 1 >= argc) { |
| 547 | std::cout << "Expecting an argument after -p\n"; |
| 548 | return 1; |
| 549 | } |
| 550 | port = std::string(argv[++i]); |
| 551 | continue; |
| 552 | } else if (arg == "-s") { |
| 553 | if (i + 1 >= argc) { |
| 554 | std::cout << "Expecting an argument after -s\n"; |
| 555 | return 1; |
| 556 | } |
| 557 | serverAddress = NetworkAddress::parse(argv[++i]); |
| 558 | continue; |
| 559 | } else if (arg == "-C") { |
| 560 | clusterFile = argv[++i]; |
| 561 | std::cout << "Using cluster file " << clusterFile << std::endl; |
| 562 | continue; |
| 563 | } |
| 564 | auto actor = actors.find(arg); |
| 565 | if (actor == actors.end()) { |
| 566 | std::cout << format("Error: actor %s does not exist\n", arg.c_str()); |
| 567 | return 1; |
| 568 | } |
| 569 | toRun.push_back(actor->second); |
| 570 | } |
| 571 | platformInit(); |
| 572 | g_network = newNet2(TLSConfig(), false, true); |
| 573 | FlowTransport::createInstance(!isServer, 0, WLTOKEN_COUNT_IN_TUTORIAL); |
| 574 | NetworkAddress publicAddress = NetworkAddress::parse("0.0.0.0:0"); |
| 575 | if (isServer) { |
| 576 | publicAddress = NetworkAddress::parse("0.0.0.0:" + port); |
| 577 | } |
| 578 | // openTraceFile(publicAddress, TRACE_DEFAULT_ROLL_SIZE, |
| 579 | // TRACE_DEFAULT_MAX_LOGS_SIZE); |
| 580 | try { |
| 581 | if (isServer) { |
| 582 | auto listenError = FlowTransport::transport().bind(publicAddress, publicAddress); |
| 583 | if (listenError.isError()) { |
| 584 | listenError.get(); |
| 585 | } |
| 586 | } |
| 587 | } catch (Error& e) { |
| 588 | std::cout << format("Error while binding to address (%d): %s\n", e.code(), e.what()); |
| 589 | } |
| 590 | // now we start the actors |
| 591 | std::vector<Future<Void>> all; |
| 592 | all.reserve(toRun.size()); |
| 593 | for (auto& f : toRun) { |
| 594 | all.emplace_back(f()); |
nothing calls this directly
no test coverage detected