Skip to content

Commit

Permalink
Merge pull request #93 from resilientdb/deploy
Browse files Browse the repository at this point in the history
Deploy
  • Loading branch information
cjcchen authored Oct 27, 2023
2 parents 5144638 + c05a9ee commit 3bfd032
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
3 changes: 3 additions & 0 deletions platform/config/resdb_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ ResDBConfig::ResDBConfig(const ResConfigData& config_data,
if (config_data_.tcp_batch_num() == 0) {
config_data_.set_tcp_batch_num(100);
}
if (!config_data_.has_recovery_enabled()) {
config_data_.set_recovery_enabled(true);
}
}

void ResDBConfig::SetConfigData(const ResConfigData& config_data) {
Expand Down
13 changes: 7 additions & 6 deletions platform/consensus/recovery/recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Recovery::Recovery(const ResDBConfig& config, CheckPoint* checkpoint,
}

LOG(INFO) << "file path:" << file_path_
<< " dir:" << std::filesystem::path(file_path_).parent_path();
<< " dir:" << std::filesystem::path(file_path_).parent_path();

recovery_ckpt_time_s_ = config_.GetConfigData().recovery_ckpt_time_s();
if (recovery_ckpt_time_s_ == 0) {
Expand All @@ -85,7 +85,7 @@ Recovery::Recovery(const ResDBConfig& config, CheckPoint* checkpoint,
Init();
}

void Recovery::Init(){
void Recovery::Init() {
GetLastFile();
SwitchFile(file_path_);

Expand Down Expand Up @@ -225,14 +225,15 @@ void Recovery::OpenFile(const std::string& path) {
}

int pos = lseek(fd_, 0, SEEK_END);
LOG(INFO) << "file path:" << path << " len:" << pos<<" fd:"<<fd_;
LOG(INFO) << "file path:" << path << " len:" << pos << " fd:" << fd_;

if (pos == 0) {
WriteSystemInfo();
}

lseek(fd_, 0, SEEK_END);
LOG(INFO) << "open file:" << path << " pos:" << lseek(fd_, 0, SEEK_CUR)<<" fd:"<<fd_;
LOG(INFO) << "open file:" << path << " pos:" << lseek(fd_, 0, SEEK_CUR)
<< " fd:" << fd_;
assert(fd_ >= 0);
}

Expand Down Expand Up @@ -465,7 +466,7 @@ void Recovery::ReadLogsFromFiles(
if (fd < 0) {
LOG(ERROR) << " open file fail:" << path;
}
LOG(INFO)<<"read logs:"<<path<<" pos:"<<lseek(fd, 0, SEEK_CUR);
LOG(INFO) << "read logs:" << path << " pos:" << lseek(fd, 0, SEEK_CUR);
assert(fd >= 0);

size_t data_len = 0;
Expand Down
9 changes: 9 additions & 0 deletions platform/networkstrate/async_acceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ void AsyncAcceptor::Session::StartRead() {
if (status_ == 0) {
// read len
recv_buffer_ = reinterpret_cast<char*>(&data_size_);
data_size_ = 0;
need_size_ = sizeof(data_size_);
current_idx_ = 0;
memset(recv_buffer_, 0, need_size_);
OnRead();
} else {
need_size_ = data_size_;
Expand All @@ -70,6 +72,7 @@ void AsyncAcceptor::Session::StartRead() {
delete recv_buffer_;
}
recv_buffer_ = new char[need_size_];
memset(recv_buffer_, 0, need_size_);
OnRead();
}
}
Expand All @@ -80,6 +83,12 @@ void AsyncAcceptor::Session::ReadDone() {
delete recv_buffer_;
} else {
data_size_ = *reinterpret_cast<size_t*>(recv_buffer_);
if (data_size_ > 1e6) {
LOG(ERROR) << "read data size:" << data_size_
<< " data size:" << sizeof(data_size_) << " close socket";
Close();
return;
}
}
status_ ^= 1;
recv_buffer_ = nullptr;
Expand Down
15 changes: 7 additions & 8 deletions service/kv/kv_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ int main(int argc, char** argv) {
char* private_key_file = argv[2];
char* cert_file = argv[3];

if (argc == 5){
std::string grafana_port = argv[4];
std::string grafana_address = "0.0.0.0:"+grafana_port;
if (argc == 5) {
std::string grafana_port = argv[4];
std::string grafana_address = "0.0.0.0:" + grafana_port;

auto monitor_port = Stats::GetGlobalStats(5);
monitor_port->SetPrometheus(grafana_address);
LOG(ERROR) << "monitoring prot:" << grafana_address;
auto monitor_port = Stats::GetGlobalStats(5);
monitor_port->SetPrometheus(grafana_address);
LOG(ERROR) << "monitoring prot:" << grafana_address;
}

std::unique_ptr<ResDBConfig> config =
Expand All @@ -86,7 +86,6 @@ int main(int argc, char** argv) {

auto server = GenerateResDBServer(
config_file, private_key_file, cert_file,
std::make_unique<KVExecutor>(NewState(cert_file, config_data)),
nullptr);
std::make_unique<KVExecutor>(NewState(cert_file, config_data)), nullptr);
server->Run();
}

0 comments on commit 3bfd032

Please sign in to comment.