-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cc
119 lines (92 loc) · 3.02 KB
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <unistd.h>
#include <cstdio>
#include <string_view>
#include "module.h"
#include "node_config.h"
#include "tcp_node.h"
#include "console.h"
#include "log.h"
#include "epoch.h"
#include "opts.h"
//extern std::atomic<uint64_t> tot_promise_routine_transported;
//extern std::atomic<uint64_t> tot_promise_routine_received;
void show_usage(const char *progname)
{
printf("Usage: %s -w workload -n node_name -c controller_ip -p cpu_count -s cpu_core_shift -m\n\n", progname);
puts("\t-w\tworkload name");
puts("\t-n\tnode name");
puts("\t-c\tcontroller IP address");
puts("\nSee opts.h for extented options.");
std::exit(-1);
}
namespace felis {
void ParseControllerAddress(std::string arg);
}
using namespace felis;
int main(int argc, char *argv[])
{
int opt;
std::string workload_name;
std::string node_name;
while ((opt = getopt(argc, argv, "w:n:c:X:")) != -1) {
switch (opt) {
case 'w':
workload_name = std::string(optarg);
break;
case 'n':
node_name = std::string(optarg);
break;
case 'c':
ParseControllerAddress(std::string(optarg));
break;
case 'X':
if (!Options::ParseExtentedOptions(std::string(optarg))) {
fprintf(stderr, "Ignoring extended argument %s\n", optarg);
std::exit(-1);
}
break;
default:
show_usage(argv[0]);
break;
}
}
NodeConfiguration::g_nr_threads = Options::kCpu.ToInt("4");
NodeConfiguration::g_data_migration = Options::kDataMigration;
if (Options::kEpochSize)
EpochClient::g_txn_per_epoch = Options::kEpochSize.ToInt();
Module<CoreModule>::ShowAllModules();
Module<WorkloadModule>::ShowAllModules();
puts("\n");
if (node_name == "") {
show_usage(argv[0]);
return -1;
}
if (workload_name == "") {
show_usage(argv[0]);
return -1;
}
auto &console = util::Instance<Console>();
console.set_server_node_name(node_name);
Module<CoreModule>::InitRequiredModules();
util::InstanceInit<NodeConfiguration>();
util::Instance<NodeConfiguration>().SetupNodeName(node_name);
util::InstanceInit<TcpNodeTransport>();
// init tables from the workload module
Module<WorkloadModule>::InitModule(workload_name);
auto client = EpochClient::g_workload_client;
logger->info("Generating Benchmarks...");
client->GenerateBenchmarks();
console.UpdateServerStatus(Console::ServerStatus::Listening);
logger->info("Ready. Waiting for run command from the controller.");
console.WaitForServerStatus(felis::Console::ServerStatus::Running);
abort_if(EpochClient::g_workload_client == nullptr,
"Workload Module did not setup the EpochClient properly");
printf("\n");
logger->info("Starting workload");
client->Start();
console.WaitForServerStatus(Console::ServerStatus::Exiting);
go::WaitThreadPool();
// std::this_thread::sleep_for(std::chrono::milliseconds(10000));
// logger->info("Total promise routine sent: {} received: {}", tot_promise_routine_transported, tot_promise_routine_received);
return 0;
}