Skip to content

Commit b7e7148

Browse files
yuhaijun999ketor
authored andcommitted
[feat][br] Allow dingo-store to be restore without an index document node.
1 parent f67ee64 commit b7e7148

File tree

8 files changed

+303
-176
lines changed

8 files changed

+303
-176
lines changed

dingo-store-proto

src/br/main.cc

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void InitLog(const std::string& log_dir) {
6767
google::SetStderrLogging(google::GLOG_FATAL);
6868
}
6969

70-
static butil::Status SetStoreInteraction() {
70+
static butil::Status SetStoreInteraction(const std::string& /*br_type*/, const std::string& /*br_backup_type*/) {
7171
dingodb::pb::coordinator::GetStoreMapRequest request;
7272
dingodb::pb::coordinator::GetStoreMapResponse response;
7373

@@ -104,7 +104,7 @@ static butil::Status SetStoreInteraction() {
104104
return butil::Status();
105105
}
106106

107-
static butil::Status SetIndexInteraction() {
107+
static butil::Status SetIndexInteraction(const std::string& br_type, const std::string& /*br_backup_type*/) {
108108
dingodb::pb::coordinator::GetStoreMapRequest request;
109109
dingodb::pb::coordinator::GetStoreMapResponse response;
110110

@@ -128,7 +128,8 @@ static butil::Status SetIndexInteraction() {
128128
}
129129

130130
if (addrs.empty()) {
131-
if (br::FLAGS_br_backup_index_must_be_exist) {
131+
if ((br_type == "backup" && br::FLAGS_br_backup_index_must_be_exist) ||
132+
(br_type == "restore" && br::FLAGS_br_restore_index_must_be_exist)) {
132133
std::string s = "Index store map is empty, but br_backup_index_must_be_exist is true";
133134
DINGO_LOG(ERROR) << s;
134135
return butil::Status(dingodb::pb::error::EINTERNAL, s);
@@ -150,7 +151,7 @@ static butil::Status SetIndexInteraction() {
150151
return butil::Status();
151152
}
152153

153-
static butil::Status SetDocumentInteraction() {
154+
static butil::Status SetDocumentInteraction(const std::string& br_type, const std::string& /*br_backup_type*/) {
154155
dingodb::pb::coordinator::GetStoreMapRequest request;
155156
dingodb::pb::coordinator::GetStoreMapResponse response;
156157

@@ -174,7 +175,8 @@ static butil::Status SetDocumentInteraction() {
174175
}
175176

176177
if (addrs.empty()) {
177-
if (br::FLAGS_br_backup_document_must_be_exist) {
178+
if ((br_type == "backup" && br::FLAGS_br_backup_document_must_be_exist) ||
179+
(br_type == "restore" && br::FLAGS_br_restore_document_must_be_exist)) {
178180
std::string s = "Document store map is empty, but br_backup_document_must_be_exist is true";
179181
DINGO_LOG(ERROR) << s;
180182
return butil::Status(dingodb::pb::error::EINTERNAL, s);
@@ -547,25 +549,24 @@ int main(int argc, char* argv[]) {
547549

548550
br::InteractionManager::GetInstance().SetCoordinatorInteraction(coordinator_interaction);
549551

550-
status = SetStoreInteraction();
552+
status = SetStoreInteraction(br::FLAGS_br_type, br::FLAGS_br_tool_type);
551553
if (!status.ok()) {
552554
DINGO_LOG(ERROR) << br::Utils::FormatStatusError(status);
553555
return -1;
554556
}
555557

556-
if (!br::FLAGS_just_store) {
557-
status = SetIndexInteraction();
558-
if (!status.ok()) {
559-
DINGO_LOG(ERROR) << br::Utils::FormatStatusError(status);
560-
return -1;
561-
}
558+
status = SetIndexInteraction(br::FLAGS_br_type, br::FLAGS_br_tool_type);
559+
if (!status.ok()) {
560+
DINGO_LOG(ERROR) << br::Utils::FormatStatusError(status);
561+
return -1;
562+
}
562563

563-
status = SetDocumentInteraction();
564-
if (!status.ok()) {
565-
DINGO_LOG(ERROR) << br::Utils::FormatStatusError(status);
566-
return -1;
567-
}
564+
status = SetDocumentInteraction(br::FLAGS_br_type, br::FLAGS_br_tool_type);
565+
if (!status.ok()) {
566+
DINGO_LOG(ERROR) << br::Utils::FormatStatusError(status);
567+
return -1;
568568
}
569+
569570
} // if (br::FLAGS_br_type == "backup" || br::FLAGS_br_type == "restore" || (br::FLAGS_br_type == "tool") &&
570571
// br::FLAGS_br_tool_type == "client")) {
571572

@@ -772,14 +773,24 @@ int main(int argc, char* argv[]) {
772773
<< br::InteractionManager::GetInstance().GetStoreInteraction()->GetAddrsAsString();
773774

774775
std::cout << "index url : "
775-
<< br::InteractionManager::GetInstance().GetIndexInteraction()->GetAddrsAsString() << std::endl;
776+
<< (br::InteractionManager::GetInstance().GetIndexInteraction() != nullptr
777+
? br::InteractionManager::GetInstance().GetIndexInteraction()->GetAddrsAsString()
778+
: "empty")
779+
<< std::endl;
776780
DINGO_LOG(INFO) << "index url : "
777-
<< br::InteractionManager::GetInstance().GetIndexInteraction()->GetAddrsAsString();
781+
<< (br::InteractionManager::GetInstance().GetIndexInteraction() != nullptr
782+
? br::InteractionManager::GetInstance().GetIndexInteraction()->GetAddrsAsString()
783+
: "empty");
778784

779785
std::cout << "document url : "
780-
<< br::InteractionManager::GetInstance().GetDocumentInteraction()->GetAddrsAsString() << std::endl;
786+
<< (br::InteractionManager::GetInstance().GetDocumentInteraction() != nullptr
787+
? br::InteractionManager::GetInstance().GetDocumentInteraction()->GetAddrsAsString()
788+
: "empty")
789+
<< std::endl;
781790
DINGO_LOG(INFO) << "document url : "
782-
<< br::InteractionManager::GetInstance().GetDocumentInteraction()->GetAddrsAsString();
791+
<< (br::InteractionManager::GetInstance().GetDocumentInteraction() != nullptr
792+
? br::InteractionManager::GetInstance().GetDocumentInteraction()->GetAddrsAsString()
793+
: "empty");
783794

784795
std::cout << "br type : " << params.br_type << std::endl;
785796
DINGO_LOG(INFO) << "br type : " << params.br_type;

src/br/parameter.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ DEFINE_string(br_client_method, "", "br client method. default empty");
115115
// br client method param1
116116
DEFINE_string(br_client_method_param1, "", "br client method param1. default empty");
117117

118-
DEFINE_bool(just_store, false, "just store server");
119-
120118
DEFINE_bool(br_backup_enable_get_job_list_check, true, "br backup enable get job list check. default true");
121119

122120
// br backup index must be exist
@@ -127,4 +125,12 @@ DEFINE_bool(br_backup_index_must_be_exist, true,
127125
DEFINE_bool(br_backup_document_must_be_exist, true,
128126
"br backup document must be exist. default true. if false, document region will not be backup.");
129127

128+
// br restore index must be exist
129+
DEFINE_bool(br_restore_index_must_be_exist, false,
130+
"br restore index must be exist. default false. if false, index region will not be restore.");
131+
132+
// br restore document must be exist
133+
DEFINE_bool(br_restore_document_must_be_exist, false,
134+
"br restore document must be exist. default false. if false, document region will not be restore.");
135+
130136
} // namespace br

src/br/parameter.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ DECLARE_string(br_client_method);
163163
// br client method param1
164164
DECLARE_string(br_client_method_param1);
165165

166-
DECLARE_bool(just_store);
167-
168166
DECLARE_bool(br_backup_enable_get_job_list_check);
169167

170168
// br backup index must be exist
@@ -173,6 +171,12 @@ DECLARE_bool(br_backup_index_must_be_exist);
173171
// br backup document must be exist
174172
DECLARE_bool(br_backup_document_must_be_exist);
175173

174+
// br restore index must be exist
175+
DECLARE_bool(br_restore_index_must_be_exist);
176+
177+
// br restore document must be exist
178+
DECLARE_bool(br_restore_document_must_be_exist);
179+
176180
} // namespace br
177181

178182
#endif // DINGODB_BR_PARAMETER_H_

0 commit comments

Comments
 (0)