From 4ce58d80a913e43486aefaf188ff7126363012d8 Mon Sep 17 00:00:00 2001 From: Wu Tao Date: Fri, 11 Sep 2020 18:39:26 +0800 Subject: [PATCH] refactor(backup): move common utils out to backup_utils (#623) --- src/common/backup_utils.cpp | 153 +++++++++++++++ src/common/backup_utils.h | 193 +++++++++++++++++++ src/common/replication_common.cpp | 128 ------------ src/common/replication_common.h | 164 ---------------- src/meta/meta_backup_service.cpp | 18 ++ src/meta/meta_backup_service.h | 17 ++ src/meta/server_state_restore.cpp | 2 +- src/replica/backup/cold_backup_context.cpp | 16 +- src/replica/backup/cold_backup_context.h | 8 +- src/replica/test/backup_block_service_mock.h | 1 + 10 files changed, 385 insertions(+), 315 deletions(-) create mode 100644 src/common/backup_utils.cpp create mode 100644 src/common/backup_utils.h diff --git a/src/common/backup_utils.cpp b/src/common/backup_utils.cpp new file mode 100644 index 0000000000..6ae9d50ed8 --- /dev/null +++ b/src/common/backup_utils.cpp @@ -0,0 +1,153 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "backup_utils.h" +#include "replica/backup/cold_backup_context.h" + +namespace dsn { +namespace replication { +const std::string cold_backup_constant::APP_METADATA("app_metadata"); +const std::string cold_backup_constant::APP_BACKUP_STATUS("app_backup_status"); +const std::string cold_backup_constant::CURRENT_CHECKPOINT("current_checkpoint"); +const std::string cold_backup_constant::BACKUP_METADATA("backup_metadata"); +const std::string cold_backup_constant::BACKUP_INFO("backup_info"); +const int32_t cold_backup_constant::PROGRESS_FINISHED = 1000; + +namespace cold_backup { + +std::string get_policy_path(const std::string &root, const std::string &policy_name) +{ + std::stringstream ss; + ss << root << "/" << policy_name; + return ss.str(); +} + +std::string +get_backup_path(const std::string &root, const std::string &policy_name, int64_t backup_id) +{ + std::stringstream ss; + ss << get_policy_path(root, policy_name) << "/" << backup_id; + return ss.str(); +} + +std::string get_app_backup_path(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + int32_t app_id, + int64_t backup_id) +{ + std::stringstream ss; + ss << get_backup_path(root, policy_name, backup_id) << "/" << app_name << "_" << app_id; + return ss.str(); +} + +std::string get_replica_backup_path(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + gpid pid, + int64_t backup_id) +{ + std::stringstream ss; + ss << get_policy_path(root, policy_name) << "/" << backup_id << "/" << app_name << "_" + << pid.get_app_id() << "/" << pid.get_partition_index(); + return ss.str(); +} + +std::string get_app_meta_backup_path(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + int32_t app_id, + int64_t backup_id) +{ + std::stringstream ss; + ss << get_policy_path(root, policy_name) << "/" << backup_id << "/" << app_name << "_" << app_id + << "/meta"; + return ss.str(); +} + +std::string get_app_metadata_file(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + int32_t app_id, + int64_t backup_id) +{ + std::stringstream ss; + ss << get_app_meta_backup_path(root, policy_name, app_name, app_id, backup_id) << "/" + << cold_backup_constant::APP_METADATA; + return ss.str(); +} + +std::string get_app_backup_status_file(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + int32_t app_id, + int64_t backup_id) +{ + std::stringstream ss; + ss << get_app_meta_backup_path(root, policy_name, app_name, app_id, backup_id) << "/" + << cold_backup_constant::APP_BACKUP_STATUS; + return ss.str(); +} + +std::string get_current_chkpt_file(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + gpid pid, + int64_t backup_id) +{ + std::stringstream ss; + ss << get_replica_backup_path(root, policy_name, app_name, pid, backup_id) << "/" + << cold_backup_constant::CURRENT_CHECKPOINT; + return ss.str(); +} + +std::string get_remote_chkpt_dirname() +{ + // here using server address as suffix of remote_chkpt_dirname + rpc_address local_address = dsn_primary_address(); + std::stringstream ss; + ss << "chkpt_" << local_address.ipv4_str() << "_" << local_address.port(); + return ss.str(); +} + +std::string get_remote_chkpt_dir(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + gpid pid, + int64_t backup_id) +{ + std::stringstream ss; + ss << get_replica_backup_path(root, policy_name, app_name, pid, backup_id) << "/" + << get_remote_chkpt_dirname(); + return ss.str(); +} + +std::string get_remote_chkpt_meta_file(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + gpid pid, + int64_t backup_id) +{ + std::stringstream ss; + ss << get_remote_chkpt_dir(root, policy_name, app_name, pid, backup_id) << "/" + << cold_backup_constant::BACKUP_METADATA; + return ss.str(); +} + +} // namespace cold_backup +} // namespace replication +} // namespace dsn diff --git a/src/common/backup_utils.h b/src/common/backup_utils.h new file mode 100644 index 0000000000..f063ddc2d1 --- /dev/null +++ b/src/common/backup_utils.h @@ -0,0 +1,193 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include +#include + +namespace dsn { +namespace replication { + +class cold_backup_constant +{ +public: + static const std::string APP_METADATA; + static const std::string APP_BACKUP_STATUS; + static const std::string CURRENT_CHECKPOINT; + static const std::string BACKUP_METADATA; + static const std::string BACKUP_INFO; + static const int32_t PROGRESS_FINISHED; +}; + +namespace cold_backup { + +// +// Attention: when compose the path on block service, we use appname_appid, because appname_appid +// can identify the case below: +// -- case: you create one app with name A and it's appid is 1, then after backup a time later, +// you drop the table, then create a new app with name A and with appid 3 +// using appname_appid, can idenfity the backup data is belong to which app + +// The directory structure on block service +// +// ////meta/app_metadata +// /meta/app_backup_status +// /partition_1/checkpoint@ip:port/***.sst +// /partition_1/checkpoint@ip:port/CURRENT +// /partition_1/checkpoint@ip:port/backup_metadata +// /partition_1/current_checkpoint +// ////meta/app_metadata +// /meta/app_backup_status +// /partition_1/checkpoint@ip:port/***.sst +// /partition_1/checkpoint@ip:port/CURRENT +// /partition_1/checkpoint@ip:port/backup_metadata +// /partition_1/current_checkpoint +// ///backup_info +// + +// +// the purpose of some file: +// 1, app_metadata : the metadata of the app, the same with the app's app_info +// 2, app_backup_status: the flag file, represent whether the app have finish backup, if this +// file exist on block filesystem, backup is finished, otherwise, app haven't finished +// backup, we ignore its context +// 3, backup_metadata : the file to statistic the information of a checkpoint, include all the +// file's name, size and md5 +// 4, current_checkpoint : specifing which checkpoint directory is valid +// 5, backup_info : recording the information of this backup +// + +// compose the path for policy on block service +// input: +// -- root: the prefix of path +// return: +// the path: / +std::string get_policy_path(const std::string &root, const std::string &policy_name); + +// compose the path for app on block service +// input: +// -- root: the prefix of path +// return: +// the path: // +std::string +get_backup_path(const std::string &root, const std::string &policy_name, int64_t backup_id); + +// compose the path for app on block service +// input: +// -- root: the prefix of path +// return: +// the path: /// +std::string get_app_backup_path(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + int32_t app_id, + int64_t backup_id); + +// compose the path for replica on block service +// input: +// -- root: the prefix of the path +// return: +// the path: //// +std::string get_replica_backup_path(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + gpid pid, + int64_t backup_id); + +// compose the path for meta on block service +// input: +// -- root: the prefix of the path +// return: +// the path: ////meta +std::string get_app_meta_backup_path(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + int32_t app_id, + int64_t backup_id); + +// compose the absolute path(AP) of app_metadata_file on block service +// input: +// -- prefix: the prefix of AP +// return: +// the AP of app meta data file: +// ////meta/app_metadata +std::string get_app_metadata_file(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + int32_t app_id, + int64_t backup_id); + +// compose the absolute path(AP) of app_backup_status file on block service +// input: +// -- prefix: the prefix of AP +// return: +// the AP of flag-file, which represent whether the app have finished backup: +// ////meta/app_backup_status +std::string get_app_backup_status_file(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + int32_t app_id, + int64_t backup_id); + +// compose the absolute path(AP) of current chekpoint file on block service +// input: +// -- root: the prefix of AP on block service +// -- pid: gpid of replica +// return: +// the AP of current checkpoint file: +// /////current_checkpoint +std::string get_current_chkpt_file(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + gpid pid, + int64_t backup_id); + +// compose the checkpoint directory name on block service +// return: +// checkpoint directory name: checkpoint@ +std::string get_remote_chkpt_dirname(); + +// compose the absolute path(AP) of checkpoint dir for replica on block service +// input: +// -- root: the prefix of the AP +// -- pid: gpid of replcia +// return: +// the AP of the checkpoint dir: +// /////checkpoint@ +std::string get_remote_chkpt_dir(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + gpid pid, + int64_t backup_id); + +// compose the absolute path(AP) of checkpoint meta for replica on block service +// input: +// -- root: the prefix of the AP +// -- pid: gpid of replcia +// return: +// the AP of the checkpoint file metadata: +// /////checkpoint@/backup_metadata +std::string get_remote_chkpt_meta_file(const std::string &root, + const std::string &policy_name, + const std::string &app_name, + gpid pid, + int64_t backup_id); + +} // namespace cold_backup +} // namespace replication +} // namespace dsn diff --git a/src/common/replication_common.cpp b/src/common/replication_common.cpp index 0dad8f0d7a..1e9a12cb4d 100644 --- a/src/common/replication_common.cpp +++ b/src/common/replication_common.cpp @@ -588,13 +588,6 @@ void replica_helper::load_meta_servers(/*out*/ std::vector &se dassert(servers.size() > 0, "no meta server specified in config [%s].%s", section, key); } -const std::string cold_backup_constant::APP_METADATA("app_metadata"); -const std::string cold_backup_constant::APP_BACKUP_STATUS("app_backup_status"); -const std::string cold_backup_constant::CURRENT_CHECKPOINT("current_checkpoint"); -const std::string cold_backup_constant::BACKUP_METADATA("backup_metadata"); -const std::string cold_backup_constant::BACKUP_INFO("backup_info"); -const int32_t cold_backup_constant::PROGRESS_FINISHED = 1000; - const std::string backup_restore_constant::FORCE_RESTORE("restore.force_restore"); const std::string backup_restore_constant::BLOCK_SERVICE_PROVIDER("restore.block_service_provider"); const std::string backup_restore_constant::CLUSTER_NAME("restore.cluster_name"); @@ -644,126 +637,5 @@ const std::string bulk_load_constant::BULK_LOAD_METADATA("bulk_load_metadata"); const std::string bulk_load_constant::BULK_LOAD_LOCAL_ROOT_DIR("bulk_load"); const int32_t bulk_load_constant::PROGRESS_FINISHED = 100; -namespace cold_backup { -std::string get_policy_path(const std::string &root, const std::string &policy_name) -{ - std::stringstream ss; - ss << root << "/" << policy_name; - return ss.str(); -} - -std::string -get_backup_path(const std::string &root, const std::string &policy_name, int64_t backup_id) -{ - std::stringstream ss; - ss << get_policy_path(root, policy_name) << "/" << backup_id; - return ss.str(); -} - -std::string get_app_backup_path(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - int32_t app_id, - int64_t backup_id) -{ - std::stringstream ss; - ss << get_backup_path(root, policy_name, backup_id) << "/" << app_name << "_" << app_id; - return ss.str(); -} - -std::string get_replica_backup_path(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - gpid pid, - int64_t backup_id) -{ - std::stringstream ss; - ss << get_policy_path(root, policy_name) << "/" << backup_id << "/" << app_name << "_" - << pid.get_app_id() << "/" << pid.get_partition_index(); - return ss.str(); -} - -std::string get_app_meta_backup_path(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - int32_t app_id, - int64_t backup_id) -{ - std::stringstream ss; - ss << get_policy_path(root, policy_name) << "/" << backup_id << "/" << app_name << "_" << app_id - << "/meta"; - return ss.str(); -} - -std::string get_app_metadata_file(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - int32_t app_id, - int64_t backup_id) -{ - std::stringstream ss; - ss << get_app_meta_backup_path(root, policy_name, app_name, app_id, backup_id) << "/" - << cold_backup_constant::APP_METADATA; - return ss.str(); -} - -std::string get_app_backup_status_file(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - int32_t app_id, - int64_t backup_id) -{ - std::stringstream ss; - ss << get_app_meta_backup_path(root, policy_name, app_name, app_id, backup_id) << "/" - << cold_backup_constant::APP_BACKUP_STATUS; - return ss.str(); -} - -std::string get_current_chkpt_file(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - gpid pid, - int64_t backup_id) -{ - std::stringstream ss; - ss << get_replica_backup_path(root, policy_name, app_name, pid, backup_id) << "/" - << cold_backup_constant::CURRENT_CHECKPOINT; - return ss.str(); -} - -std::string get_remote_chkpt_dirname() -{ - // here using server address as suffix of remote_chkpt_dirname - rpc_address local_address = dsn_primary_address(); - std::stringstream ss; - ss << "chkpt_" << local_address.ipv4_str() << "_" << local_address.port(); - return ss.str(); -} - -std::string get_remote_chkpt_dir(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - gpid pid, - int64_t backup_id) -{ - std::stringstream ss; - ss << get_replica_backup_path(root, policy_name, app_name, pid, backup_id) << "/" - << get_remote_chkpt_dirname(); - return ss.str(); -} - -std::string get_remote_chkpt_meta_file(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - gpid pid, - int64_t backup_id) -{ - std::stringstream ss; - ss << get_remote_chkpt_dir(root, policy_name, app_name, pid, backup_id) << "/" - << cold_backup_constant::BACKUP_METADATA; - return ss.str(); -} - -} // namespace cold_backup } // namespace replication } // namespace dsn diff --git a/src/common/replication_common.h b/src/common/replication_common.h index c5ae401931..3eda1b3d24 100644 --- a/src/common/replication_common.h +++ b/src/common/replication_common.h @@ -134,17 +134,6 @@ typedef rpc_holder register_chi extern const char *partition_status_to_string(partition_status::type status); -class cold_backup_constant -{ -public: - static const std::string APP_METADATA; - static const std::string APP_BACKUP_STATUS; - static const std::string CURRENT_CHECKPOINT; - static const std::string BACKUP_METADATA; - static const std::string BACKUP_INFO; - static const int32_t PROGRESS_FINISHED; -}; - class backup_restore_constant { public: @@ -169,158 +158,5 @@ class bulk_load_constant static const int32_t PROGRESS_FINISHED; }; -namespace cold_backup { -// -// Attention: when compose the path on block service, we use appname_appid, because appname_appid -// can identify the case below: -// -- case: you create one app with name A and it's appid is 1, then after backup a time later, -// you drop the table, then create a new app with name A and with appid 3 -// using appname_appid, can idenfity the backup data is belong to which app - -// The directory structure on block service -// -// ////meta/app_metadata -// /meta/app_backup_status -// /partition_1/checkpoint@ip:port/***.sst -// /partition_1/checkpoint@ip:port/CURRENT -// /partition_1/checkpoint@ip:port/backup_metadata -// /partition_1/current_checkpoint -// ////meta/app_metadata -// /meta/app_backup_status -// /partition_1/checkpoint@ip:port/***.sst -// /partition_1/checkpoint@ip:port/CURRENT -// /partition_1/checkpoint@ip:port/backup_metadata -// /partition_1/current_checkpoint -// ///backup_info -// - -// -// the purpose of some file: -// 1, app_metadata : the metadata of the app, the same with the app's app_info -// 2, app_backup_status: the flag file, represent whether the app have finish backup, if this -// file exist on block filesystem, backup is finished, otherwise, app haven't finished -// backup, we ignore its context -// 3, backup_metadata : the file to statistic the information of a checkpoint, include all the -// file's name, size and md5 -// 4, current_checkpoint : specifing which checkpoint directory is valid -// 5, backup_info : recording the information of this backup -// - -// compose the path for policy on block service -// input: -// -- root: the prefix of path -// return: -// the path: / -std::string get_policy_path(const std::string &root, const std::string &policy_name); - -// compose the path for app on block service -// input: -// -- root: the prefix of path -// return: -// the path: // -std::string -get_backup_path(const std::string &root, const std::string &policy_name, int64_t backup_id); - -// compose the path for app on block service -// input: -// -- root: the prefix of path -// return: -// the path: /// -std::string get_app_backup_path(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - int32_t app_id, - int64_t backup_id); - -// compose the path for replica on block service -// input: -// -- root: the prefix of the path -// return: -// the path: //// -std::string get_replica_backup_path(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - gpid pid, - int64_t backup_id); - -// compose the path for meta on block service -// input: -// -- root: the prefix of the path -// return: -// the path: ////meta -std::string get_app_meta_backup_path(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - int32_t app_id, - int64_t backup_id); - -// compose the absolute path(AP) of app_metadata_file on block service -// input: -// -- prefix: the prefix of AP -// return: -// the AP of app meta data file: -// ////meta/app_metadata -std::string get_app_metadata_file(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - int32_t app_id, - int64_t backup_id); - -// compose the absolute path(AP) of app_backup_status file on block service -// input: -// -- prefix: the prefix of AP -// return: -// the AP of flag-file, which represent whether the app have finished backup: -// ////meta/app_backup_status -std::string get_app_backup_status_file(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - int32_t app_id, - int64_t backup_id); - -// compose the absolute path(AP) of current chekpoint file on block service -// input: -// -- root: the prefix of AP on block service -// -- pid: gpid of replica -// return: -// the AP of current checkpoint file: -// /////current_checkpoint -std::string get_current_chkpt_file(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - gpid pid, - int64_t backup_id); - -// compose the checkpoint directory name on block service -// return: -// checkpoint directory name: checkpoint@ -std::string get_remote_chkpt_dirname(); - -// compose the absolute path(AP) of checkpoint dir for replica on block service -// input: -// -- root: the prefix of the AP -// -- pid: gpid of replcia -// return: -// the AP of the checkpoint dir: -// /////checkpoint@ -std::string get_remote_chkpt_dir(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - gpid pid, - int64_t backup_id); - -// compose the absolute path(AP) of checkpoint meta for replica on block service -// input: -// -- root: the prefix of the AP -// -- pid: gpid of replcia -// return: -// the AP of the checkpoint file metadata: -// /////checkpoint@/backup_metadata -std::string get_remote_chkpt_meta_file(const std::string &root, - const std::string &policy_name, - const std::string &app_name, - gpid pid, - int64_t backup_id); -} // namespace cold_backup } // namespace replication } // namespace dsn diff --git a/src/meta/meta_backup_service.cpp b/src/meta/meta_backup_service.cpp index 34e5f375bd..b449491f0a 100644 --- a/src/meta/meta_backup_service.cpp +++ b/src/meta/meta_backup_service.cpp @@ -1,3 +1,20 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + #include #include #include @@ -7,6 +24,7 @@ #include "meta_service.h" #include "server_state.h" #include "block_service/block_service_manager.h" +#include "common/backup_utils.h" namespace dsn { namespace replication { diff --git a/src/meta/meta_backup_service.h b/src/meta/meta_backup_service.h index c2662a0c12..243d1e79a2 100644 --- a/src/meta/meta_backup_service.h +++ b/src/meta/meta_backup_service.h @@ -1,3 +1,20 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + #pragma once #include diff --git a/src/meta/server_state_restore.cpp b/src/meta/server_state_restore.cpp index 14b8b4e5f0..eed63107ed 100644 --- a/src/meta/server_state_restore.cpp +++ b/src/meta/server_state_restore.cpp @@ -29,7 +29,7 @@ #include #include "block_service/block_service_manager.h" -#include "common/replication_common.h" +#include "common/backup_utils.h" #include "meta_service.h" #include "server_state.h" diff --git a/src/replica/backup/cold_backup_context.cpp b/src/replica/backup/cold_backup_context.cpp index 2343d53eba..4da49cf0e7 100644 --- a/src/replica/backup/cold_backup_context.cpp +++ b/src/replica/backup/cold_backup_context.cpp @@ -16,6 +16,7 @@ // under the License. #include "cold_backup_context.h" +#include "common/backup_utils.h" #include "replica/replica.h" #include "replica/replica_stub.h" #include "block_service/block_service_manager.h" @@ -136,21 +137,6 @@ bool cold_backup_context::complete_checkpoint() return false; } } - -bool cold_backup_context::pause_upload() -{ - int uploading = ColdBackupUploading; - if (_status.compare_exchange_strong(uploading, ColdBackupPaused)) { - if (_owner_replica != nullptr) { - _owner_replica->get_replica_stub() - ->_counter_cold_backup_recent_pause_count->increment(); - } - return true; - } else { - return false; - } -} - bool cold_backup_context::fail_upload(const char *failure_reason) { int uploading = ColdBackupUploading; diff --git a/src/replica/backup/cold_backup_context.h b/src/replica/backup/cold_backup_context.h index fec3028a12..4626b9453e 100644 --- a/src/replica/backup/cold_backup_context.h +++ b/src/replica/backup/cold_backup_context.h @@ -21,7 +21,7 @@ #include #include -#include "common/replication_common.h" +#include "common/backup_utils.h" class replication_service_test_app; @@ -209,12 +209,6 @@ class cold_backup_context : public ref_counter _status.compare_exchange_strong(paused, ColdBackupUploading); } - // pause uploading checkpoint to remote. - // ColdBackupUploading --> ColdBackupPaused - // Returns: - // - true if status is successfully changed to ColdBackupPaused. - bool pause_upload(); - // mark failed when uploading checkpoint to remote. // { ColdBackupUploading | ColdBackupPaused } --> ColdBackupFailed // Returns: diff --git a/src/replica/test/backup_block_service_mock.h b/src/replica/test/backup_block_service_mock.h index 4942db3d1a..54c682a8df 100644 --- a/src/replica/test/backup_block_service_mock.h +++ b/src/replica/test/backup_block_service_mock.h @@ -12,6 +12,7 @@ #include "replica/replica_context.h" #include "replication_service_test_app.h" #include "block_service/test/block_service_mock.h" +#include "common/backup_utils.h" using namespace ::dsn; using namespace ::dsn::dist::block_service;