-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
146 lines (126 loc) · 6.42 KB
/
main.cpp
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//
// Created by 周慰星 on 11/8/22.
//
#include "epoch/epoch_manager.h"
#include "worker/worker_epoch_manager.h"
#include "worker/worker_epoch_merge.h"
#include "worker/worker_message.h"
#include "worker/worker_storage.h"
#include "leveldb_server/leveldb_server.h"
#include "storage/tikv.h"
#include "test/test.h"
#include "workload/multi_model_workload.h"
#include "workload/worker.h"
#include <glog/logging.h>
#include <iostream>
#include <thread>
#include <future>
using namespace std;
namespace Taas {
int main() {
Context ctx;
FLAGS_log_dir = "/tmp";
FLAGS_alsologtostderr = true;
google::InitGoogleLogging("Taas-sharding");
LOG(INFO) << "System Start\n";
auto res = ctx.taasContext.Print();
LOG(INFO) << res;
printf("%s\n", res.c_str());
std::vector<std::unique_ptr<std::thread>> threads;
int cnt = 0;
if(ctx.taasContext.server_type == ServerMode::Taas) { ///TaaS servers
EpochManager epochManager;
Taas::EpochManager::ctx = ctx;
threads.push_back(std::make_unique<std::thread>(WorkerForPhysicalThreadMain, ctx)); cnt++;
threads.push_back(std::make_unique<std::thread>(WorkerForLogicalThreadMain, ctx)); cnt++;
threads.push_back(std::make_unique<std::thread>(WorkerForLogicalRedoLogPushDownCheckThreadMain, ctx)); cnt++;
for(int i = 0; i < (int)ctx.taasContext.kEpochTxnThreadNum; i ++) {///handle client txn
threads.push_back(std::make_unique<std::thread>(WorkerFroMessageThreadMain, ctx, i)); cnt++;///txn message
}
for(int i = 0; i < (int)ctx.taasContext.kEpochMessageThreadNum; i ++) {/// handle remote server message
threads.push_back(std::make_unique<std::thread>(WorkerFroMessageEpochThreadMain, ctx, i)); cnt++;///epoch message
}
for(int i = 0; i < (int)ctx.taasContext.kMergeThreadNum; i ++) {
threads.push_back(std::make_unique<std::thread>(WorkerFroMergeThreadMain, ctx, i)); cnt++;///merge & commit
}
threads.push_back(std::make_unique<std::thread>(WorkerForClientListenThreadMain, ctx)); cnt++;///client
threads.push_back(std::make_unique<std::thread>(WorkerForClientSendThreadMain, ctx)); cnt++;
if(ctx.taasContext.kTxnNodeNum > 1) {
threads.push_back(std::make_unique<std::thread>(WorkerForServerListenThreadMain, ctx)); cnt++;
threads.push_back(std::make_unique<std::thread>(WorkerForServerListenThreadMain_Epoch, ctx)); cnt++;
threads.push_back(std::make_unique<std::thread>(WorkerForServerSendThreadMain, ctx)); cnt++;
threads.push_back(std::make_unique<std::thread>(WorkerForServerSendPUBThreadMain, ctx)); cnt++;
}
///Storage
// threads.push_back(std::make_unique<std::thread>(WorkerForStorageSendMOTThreadMain, ctx)); cnt++;
// threads.push_back(std::make_unique<std::thread>(WorkerForStorageSendNebulaThreadMain, ctx)); cnt++;
if(ctx.storageContext.is_mot_enable) {
for(int i = 0; i < (int)ctx.storageContext.kMOTThreadNum; i ++) {
threads.push_back(std::make_unique<std::thread>(WorkerFroMOTStorageThreadMain, ctx, i)); cnt++;///mot push down
}
for(int i = 0; i < (int)ctx.storageContext.kMOTThreadNum; i ++) {
threads.push_back(std::make_unique<std::thread>(WorkerFroNebulaStorageThreadMain, ctx, i)); cnt++;///nebula push down
}
}
if(ctx.storageContext.is_tikv_enable) {
TiKV::tikv_client_ptr = new tikv_client::TransactionClient({ctx.storageContext.kTiKVIP});
for(int i = 0; i < (int)ctx.storageContext.kTikvThreadNum; i ++) {
threads.push_back(std::make_unique<std::thread>(WorkerFroTiKVStorageThreadMain, ctx, i)); cnt++;///tikv push down
}
}
if(ctx.storageContext.is_leveldb_enable) {
threads.push_back(std::make_unique<std::thread>(LevelDBServer,ctx));
for(int i = 0; i < (int)ctx.storageContext.kLeveldbThreadNum; i ++) {
threads.push_back(std::make_unique<std::thread>(WorkerFroLevelDBStorageThreadMain, ctx, i)); cnt++;///tikv push down
}
}
if(ctx.storageContext.is_hbase_enable) {
for(int i = 0; i < (int)ctx.storageContext.kHbaseTxnThreadNum; i ++) {
threads.push_back(std::make_unique<std::thread>(WorkerFroHBaseStorageThreadMain, ctx, i)); cnt++;///tikv push down
}
}
// for(int i = 0; i < 1; i ++) {
for(int i = 0; i < (int)ctx.taasContext.kTestClientNum; i ++) {
if(ctx.storageContext.is_leveldb_enable) {
LOG(INFO) << "LevelDBClient inserting";
threads.push_back(std::make_unique<std::thread>(LevelDBClient, ctx, i));
cnt++;
}
else {
threads.push_back(std::make_unique<std::thread>(Client, ctx, i));
cnt++;
}
}
}
else if(ctx.taasContext.server_type == ServerMode::LevelDB) { ///leveldb server
EpochManager epochManager;
Taas::EpochManager::ctx = ctx;
LevelDBServer(ctx);
}
else if(ctx.taasContext.server_type == ServerMode::HBase) { ///hbase server
//do nothing
}
else if(ctx.taasContext.server_type == ServerMode::MultiModelClient) { ///hbase server
workload::main();
}
if(ctx.taasContext.kDurationTime_us != 0) {
while(!test_start.load()) usleep(sleep_time);
usleep(ctx.taasContext.kDurationTime_us);
EpochManager::SetTimerStop(true);
}
// else {
// std::signal(SIGINT, signalHandler);
// }
for(auto &i : threads) {
i->join();
}
google::ShutdownGoogleLogging();
std::cout << "============================================================================" << std::endl;
std::cout << "===================== END =====================" << std::endl;
std::cout << "============================================================================" << std::endl;
return 0;
}
}
int main() {
Taas::main();
}