-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoordinator.cc
More file actions
66 lines (54 loc) · 1.39 KB
/
coordinator.cc
File metadata and controls
66 lines (54 loc) · 1.39 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
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <cassert>
#include <fcntl.h>
#include <fstream>
#include <filesystem>
#include <unistd.h>
#include <vector>
#include <iterator>
#include <algorithm>
#include <random>
#include <grpcpp/ext/proto_server_reflection_plugin.h>
#include <grpcpp/grpcpp.h>
#include <grpcpp/health_check_service_interface.h>
#include "query.grpc.pb.h"
#include "coordinator.hpp"
#include "query_server.hpp"
Coordinator::Coordinator(int n): n(n) {
this->nodes_ports(0);
this->numOfConnectedNodes=0;
this->port_num = "50000";
}
string Coordinator::getCPort() {
return this->port_num;
}
int Coordinator::getNumOfConnectedNodes(){
return numOfConnectedNodes;
}
vector<string> Coordinator::getVector(){
return nodes_ports;
}
void Coordinator::addNum() {
(this->numOfConnectedNodes)++;
}
void Coordinator::addToVector(string node_port){
nodes_ports.push_back(node_port);
}
void server_thread(Coordinator* coordinator) {
RunServer(NULL, coordinator);
}
/* int main(int argc, char** argv){
int n;
n = stoi(string(argv[1]));
Coordinator c1(n);
thread th1(server_thread, &c1);
while (n != c1.getNumOfConnectedNodes());
for(auto port1: c1.getVector()){
QueryClient query(grpc::CreateChannel(port1, grpc::InsecureChannelCredentials()));
query.SayStart("start");
}
return 0;
} */