Loading...
Searching...
No Matches
resdb_config.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
22#include "common/proto/signature_info.pb.h"
23#include "platform/proto/replica_info.pb.h"
24
25namespace resdb {
26
27// TODO read from a proto json file.
29 public:
30 ResDBConfig(const std::vector<ReplicaInfo>& replicas,
31 const ReplicaInfo& self_info,
32 ResConfigData config_data = ResConfigData());
33
34 ResDBConfig(const std::vector<ReplicaInfo>& replicas,
35 const ReplicaInfo& self_info, const KeyInfo& private_key,
36 const CertificateInfo& public_key_cert_info);
37
38 ResDBConfig(const ResConfigData& config_data, const ReplicaInfo& self_info,
39 const KeyInfo& private_key,
40 const CertificateInfo& public_key_cert_info);
41
42 void SetConfigData(const ResConfigData& config_data);
43
44 // Get the private key.
45 KeyInfo GetPrivateKey() const;
46
47 // Get the public key with its certificate.
48 CertificateInfo GetPublicKeyCertificateInfo() const;
49
50 // Each replica infomation, including the binding urls(or ip,port).
51 const std::vector<ReplicaInfo>& GetReplicaInfos() const;
52
53 ResConfigData GetConfigData() const;
54
55 // The current replica infomation, including the binding urls(or ip,port).
56 const ReplicaInfo& GetSelfInfo() const;
57 // The total number of replicas.
58 size_t GetReplicaNum() const;
59 // The minimum number of messages that replicas have to receive after jumping
60 // to the next status.. 2f+1
61 int GetMinDataReceiveNum() const;
62 // The max malicious replicas to be tolerated (the number of f).
63 size_t GetMaxMaliciousReplicaNum() const;
64 // const int GetMaxMaliciousNum() const;
65 // The minimum number of messages that client has to receive from the
66 // replicas.
67 int GetMinClientReceiveNum() const;
68
70
71 // The timeout microseconds to process a client request.
72 // Default value is 3s.
73 void SetClientTimeoutMs(int timeout_ms);
74 int GetClientTimeoutMs() const;
75
76 // CheckPoint Window
77 int GetCheckPointWaterMark() const;
78 void SetCheckPointWaterMark(int water_mark);
79
80 // Logging
81 std::string GetCheckPointLoggingPath() const;
82 void SetCheckPointLoggingPath(const std::string& path);
83
84 // Checkpoint flag
85 void EnableCheckPoint(bool is_enable);
87
88 // HeartBeat
89 bool HeartBeatEnabled();
90 void SetHeartBeatEnabled(bool enable_heartbeat);
91
92 // Signature Verifier
94 void SetSignatureVerifierEnabled(bool enable_sv);
95
96 // Performance setting
98 void RunningPerformance(bool);
99
100 bool IsTestMode() const;
101 void SetTestMode(bool);
102
103 // The maximun transactions being processed.
104 uint32_t GetMaxProcessTxn() const;
105 void SetMaxProcessTxn(uint32_t num);
106
107 uint32_t GetMaxClientComplaintNum() const;
108
109 uint32_t ClientBatchWaitTimeMS() const;
110 void SetClientBatchWaitTimeMS(uint32_t wait_time_ms);
111
112 uint32_t ClientBatchNum() const;
113 void SetClientBatchNum(uint32_t num);
114
115 uint32_t GetWorkerNum() const;
116 uint32_t GetInputWorkerNum() const;
117 uint32_t GetOutputWorkerNum() const;
118 uint32_t GetTcpBatchNum() const;
119
120 // ViewChange Timeout
121 uint32_t GetViewchangeCommitTimeout() const;
122 void SetViewchangeCommitTimeout(uint64_t timeout_ms);
123
124 private:
125 ResConfigData config_data_;
126 std::vector<ReplicaInfo> replicas_;
127 ReplicaInfo self_info_;
128 const KeyInfo private_key_;
129 const CertificateInfo public_key_cert_info_;
130 int client_timeout_ms_ = 3000000;
131 std::string checkpoint_logging_path_;
132 int checkpoint_water_mark_ = 5;
133 bool is_enable_checkpoint_ = false;
134 bool hb_enabled_ = true;
135 bool signature_verifier_enabled_ = true;
136 bool is_performance_running_ = false;
137 bool is_test_mode_ = false;
138 uint32_t max_process_txn_ = 2048;
139 uint32_t client_batch_wait_time_ms_ = 100; // milliseconds, 0.1s
140 uint32_t client_batch_num_ = 100;
141 uint64_t viewchange_commit_timeout_ms_ =
142 60000; // default 60s to change viewchange
143
144 uint32_t worker_num_ = 64;
145 uint32_t input_worker_num_ = 1;
146 uint32_t output_worker_num_ = 1;
147};
148
149} // namespace resdb
uint32_t GetOutputWorkerNum() const
void SetClientBatchNum(uint32_t num)
void SetViewchangeCommitTimeout(uint64_t timeout_ms)
void SetCheckPointWaterMark(int water_mark)
void SetMaxProcessTxn(uint32_t num)
uint32_t GetWorkerNum() const
int GetMinDataReceiveNum() const
int GetMinClientReceiveNum() const
uint32_t GetInputWorkerNum() const
size_t GetReplicaNum() const
ResConfigData GetConfigData() const
int GetCheckPointWaterMark() const
bool IsTestMode() const
uint32_t GetMaxProcessTxn() const
uint32_t GetTcpBatchNum() const
void SetClientTimeoutMs(int timeout_ms)
void SetSignatureVerifierEnabled(bool enable_sv)
size_t GetMaxMaliciousReplicaNum() const
int GetMinCheckpointReceiveNum() const
void SetClientBatchWaitTimeMS(uint32_t wait_time_ms)
uint32_t ClientBatchNum() const
CertificateInfo GetPublicKeyCertificateInfo() const
const ReplicaInfo & GetSelfInfo() const
void SetHeartBeatEnabled(bool enable_heartbeat)
void SetCheckPointLoggingPath(const std::string &path)
void RunningPerformance(bool)
std::string GetCheckPointLoggingPath() const
void SetConfigData(const ResConfigData &config_data)
void EnableCheckPoint(bool is_enable)
uint32_t ClientBatchWaitTimeMS() const
int GetClientTimeoutMs() const
const std::vector< ReplicaInfo > & GetReplicaInfos() const
uint32_t GetMaxClientComplaintNum() const
KeyInfo GetPrivateKey() const
uint32_t GetViewchangeCommitTimeout() const