@@ -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 ;
0 commit comments