Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
#ifndef DGRIDD_CHILD_H
#define DGRIDD_CHILD_H
 
#include <sys/socket.h>
#include <arpa/inet.h>
#include <mutex>
 
#include "dgrid.h"
#include "dgrid_thread.h"
#include "dgrid_req_structs.h"
 
namespace DGrid {
 
class DGriddListener;
class DGriddNodeArbiter;
 
class DGriddChild: public DGriddThread
{
public:
    DGriddChild(DGriddListener* p);
    virtual ~DGriddChild();
 
    bool start(int connfd);
 
protected:
    virtual void run();
    bool receiveData();
    void processData(PacketType type, const std::vector<char>& data_buf);
    void processRequest(const Network_pkt_request* req, uint32_t dlen);
    virtual DGridResult processRequest(const RequestType req_type, const RequestSubType req_subtype, const std::vector<char>& payload,
        std::vector<char>& ret_data, std::string& err_details) = 0;
    bool checkAuth(const AuthData& auth_data, std::string& message);
 
    int connfd;
    bool    auth_done = false;
    DGriddListener* parent;
    bool    echo_rcvd;
    uint8_t echo_seq;
};
 
class DGriddDataChild: public DGriddChild
{
public:
    DGriddDataChild(DGriddListener* p);
    virtual ~DGriddDataChild();
 
protected:
    virtual DGridResult processRequest(const RequestType req_type, const RequestSubType req_subtype, const std::vector<char>& payload,
        std::vector<char>& ret_data, std::string& err_details);
 
public:
    static DGridResult processRequest_User(const RequestType req_type, const RequestSubType req_subtype, const std::vector<char>& payload,
        std::vector<char>& ret_data, std::string& err_details, DGriddNodeArbiter* node_arbiter = nullptr);
    static DGridResult processRequest_Stats(const RequestType req_type, const RequestSubType req_subtype, const std::vector<char>& payload,
        std::vector<char>& ret_data, std::string& err_details, DGriddNodeArbiter* node_arbiter = nullptr);
    static DGridResult processRequest_KeyValue(const RequestSubType req_subtype, const std::vector<char>& payload,
            std::vector<char>& ret_data, std::string& err_details);
    static DGridResult processRequest_TableCreate(const RequestSubType req_subtype, const std::vector<char>& payload,
            std::vector<char>& ret_data, std::string& err_details, DGriddNodeArbiter* node_arbiter = nullptr);
    static DGridResult processRequest_Table(const RequestType req_type, const RequestSubType req_subtype, const std::vector<char>& payload,
            std::vector<char>& ret_data, std::string& err_details, DGriddNodeArbiter* node_arbiter = nullptr);
    static DGridResult processRequest_TableCursor(const RequestType req_type, const RequestSubType req_subtype, const std::vector<char>& payload,
            std::vector<char>& ret_data, std::string& err_details, DGriddNodeArbiter* node_arbiter = nullptr);
    static DGridResult processRequest_TableMigration(const RequestSubType req_subtype, const std::vector<char>& payload,
            std::vector<char>& ret_data, std::string& err_details, DGriddNodeArbiter* node_arbiter = nullptr);
};
 
class DGriddNodeChild: public DGriddChild
{
public:
    DGriddNodeChild(DGriddListener* p);
    virtual ~DGriddNodeChild();
 
protected:
    virtual DGridResult processRequest(const RequestType req_type, const RequestSubType req_subtype, const std::vector<char>& payload,
        std::vector<char>& ret_data, std::string& err_details);
};
 
} // namespace DGrid
 
#endif // DGRIDD_CHILD_H