-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrunner.cpp
More file actions
75 lines (51 loc) · 1.76 KB
/
Copy pathrunner.cpp
File metadata and controls
75 lines (51 loc) · 1.76 KB
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
#include "distrib/node.h"
#include <cstdlib>
static Node *instance;
void handle_signal(int signal) {
instance->handle_signal(signal);
}
int main(int argc, char * argv[]) {
IndexReadHandler rh;
rh.ReadIndex("./log/chunks/53");
rh.Find("query");
// setup sigpipe handler
struct sigaction sa;
sa.sa_handler = SIG_IGN;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(SIGPIPE, &sa, nullptr);
signal(SIGINT, handle_signal); // Register the signal handler for SIGINT
const char * numNodesStr = std::getenv("NUM_NODES");
if (numNodesStr == nullptr) {
std::cerr << "NUM_NODES environment variable not set." << std::endl;
return 1;
}
const char * idStr = std::getenv("NODE_ID");
if (idStr == nullptr) {
std::cerr << "NODE_ID environment variable not set." << std::endl;
return 1;
}
if (atoi(idStr) > atoi(numNodesStr)) {
std::cerr << "NODE_ID too high!" << std::endl;
return 1;
}
const int numNodes = atoi(numNodesStr);
for (size_t i = 0; i < numNodes; i++) {
if (std::getenv(("NODE_IP" + std::to_string(i)).c_str()) == nullptr) {
std::cerr << "NODE_IP environment variable is not set for node: " << i << std::endl;
return 1;
}
}
const int id = atoi(idStr);
Node node(id, numNodes);
instance = &node;
string seedlist = "./log/frontier/initlist";
string bf = "./log/frontier/bloomfilter.bin";
if (argc > 1)
seedlist = argv[1];
if (argc == 3)
bf = argv[2];
if (argc > 4)
std::cerr << "Too many arguments. Format: ./search [path to seedlist] [path to bloomfilter]" << std::endl;
instance->start(seedlist.c_str(), bf.c_str());
}