-
Notifications
You must be signed in to change notification settings - Fork 19
/
arranger.h
80 lines (59 loc) · 1.92 KB
/
arranger.h
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
/**
* Copyright (c) 2021 OceanBase
* OceanBase Migration Service LogProxy is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#pragma once
#include <unordered_map>
#include <mutex>
#include "common.h"
#include "source_meta.h"
#include "client_meta.h"
#include "oblog_config.h"
namespace oceanbase {
namespace logproxy {
class Arranger {
OMS_SINGLETON(Arranger);
OMS_AVOID_COPY(Arranger);
public:
int init();
int run_foreground();
private:
void on_close(const Peer&);
EventResult on_handshake(const Peer&, const Message&);
int resolve(OblogConfig&, std::string& errmsg);
int auth(const OblogConfig&, std::string& errmsg);
int check_quota();
/*!
* @brief
* @param oblog_config
* @param errmsg
* @return Does the clog checkpoint meet the requirements?
*/
int check_clog(const OblogConfig& oblog_config, std::string& errmsg);
int create(ClientMeta&, OblogConfig&);
void response_error(const Peer&, MessageVersion version, ErrorCode code, const std::string&);
int close_client_force(const ClientMeta& client, const std::string& msg = "");
void close_by_pid(int pid, const ClientMeta& client);
void gc_pid_routine();
private:
/**
* <ClientId, sink_peer>
*/
std::unordered_map<std::string, ClientMeta> _client_peers;
std::string _localhost;
std::string _localip;
Comm _accepter;
};
// class SysMetric;
// extern SysMetric g_metric;
// class ProcessGroupMetric;
// extern ProcessGroupMetric g_proc_metric;
} // namespace logproxy
} // namespace oceanbase