Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
72 lines (61 loc) · 2.41 KB
/
Copy pathmain.cpp
File metadata and controls
72 lines (61 loc) · 2.41 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
#include <unistd.h>
#include <cassert>
#include "algorithm/algorithm_scheduler.hpp"
#include "data_processor/data_tracker.hpp"
#include "scheduler/task_pool.hpp"
#include "scheduler/sched.hpp"
#include "scheduler/process_manager.hpp"
#include "socket/socket.hpp"
#include "sender_proc/sender.hpp"
#include "instance/instance_list.hpp"
#include "services/stats_engine.hpp"
#include "services/sqlite_database_access.hpp"
#include "include/logger.hpp"
#include "configs.hpp"
SqliteDatabaseAccess *sqliteDatabaseAccess;
DataBaseInstanceList instanceList;
StatisticsEngine statsEngine;
Configs globalConfigs;
SenderSink senderSink;
TaskPool taskPool;
Socket globalSocket;
std::map<std::string, AlgorithmPackage *> algorithmResultMap;
std::map<TableData *, int> cleanStageMap;
ProcessManager globalProcessManager;
int main()
{
std::string net[2] = {"0.0.0.0", "8080"};
std::string hostname, port;
int threadCount;
std::cout << "\033[1;97;49m---------------------------Start Menu--------------------------\033[0m" << std::endl;
std::cout << "\033[1;33;49mEnter Hostname: \033[0m";
std::cin >> hostname;
std::cout << "\033[1;33;49mEnter Port number: \033[0m";
std::cin >> port;
if(hostname.empty() || port.empty()){
std::cout << "\nFalling back to default port and hostname as given is incorrect" << std::endl;
} else {
net[0] = hostname;
net[1] = port;
}
assert(sqlite3_config(SQLITE_CONFIG_SERIALIZED) == SQLITE_OK);
sqliteDatabaseAccess = new SqliteDatabaseAccess();
sqliteDatabaseAccess->initDatabase();
std::cout <<"Inited database" << std::endl;
std::cout << "Inited task pool" << std::endl;
std::cout << "\033[1;33;49mEnter thread count (max:"<<MAX_THREAD - 1<<"): \033[0m";
std::cin >> threadCount;
globalConfigs = Configs(threadCount, hostname, port);
threadCount = (threadCount > MAX_THREAD || threadCount <= 0) ? 2 : threadCount;
init_sched(threadCount);
std::cout << "Inited " << threadCount << " Threads" << std::endl;
statsEngine = StatisticsEngine(threadCount, 10);
std::cout << "Inited Stats Engine" << std::endl;
globalSocket.init();
std::cout << "Inited and running sockets" << std::endl;
std::cout << "\033[1;97;49m---------------------------DEBUGGER START--------------------------\033[0m" << std::endl;
while(1){
}
std::cout << "All process shutdown successfully" <<std::endl;
return 0;
}