Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10 from LoveHeat/master
Browse files Browse the repository at this point in the history
meta_backup_service: fix wrong variable name
  • Loading branch information
LoveHeat authored Apr 12, 2018
2 parents 4f2d3f5 + e336f1e commit 675b8e7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions src/dist/replication/meta_server/meta_backup_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ void policy_context::start_backup_app_meta_unlocked(int32_t app_id)
dwarn("%s: can't encode app_info for app(%d), perhaps removed, treat it as backup finished",
_backup_sig.c_str(),
app_id);
auto iter = _progress.unfished_partitions_per_app.find(app_id);
dassert(iter != _progress.unfished_partitions_per_app.end(),
auto iter = _progress.unfinished_partitions_per_app.find(app_id);
dassert(iter != _progress.unfinished_partitions_per_app.end(),
"%s: can't find app(%d) in unfished_map",
_backup_sig.c_str(),
app_id);
Expand Down Expand Up @@ -120,8 +120,8 @@ void policy_context::start_backup_app_meta_unlocked(int32_t app_id)

void policy_context::start_backup_app_partitions_unlocked(int32_t app_id)
{
auto iter = _progress.unfished_partitions_per_app.find(app_id);
dassert(iter != _progress.unfished_partitions_per_app.end(),
auto iter = _progress.unfinished_partitions_per_app.find(app_id);
dassert(iter != _progress.unfinished_partitions_per_app.end(),
"%s: can't find app(%d) in unfinished apps",
_backup_sig.c_str(),
app_id);
Expand Down Expand Up @@ -371,10 +371,10 @@ bool policy_context::update_partition_progress_unlocked(gpid pid,
pid.get_app_id(),
pid.get_partition_index(),
source.to_string(),
_progress.unfished_partitions_per_app[pid.get_app_id()]);
_progress.unfinished_partitions_per_app[pid.get_app_id()]);

// let's update the progress-chain: partition => app => current_backup_instance
if (--_progress.unfished_partitions_per_app[pid.get_app_id()] == 0) {
if (--_progress.unfinished_partitions_per_app[pid.get_app_id()] == 0) {
dsn::task_ptr task_after_write_finish_flag =
tasking::create_task(LPC_DEFAULT_CALLBACK, nullptr, [this, pid]() {
zauto_lock l(_lock);
Expand Down Expand Up @@ -545,7 +545,7 @@ void policy_context::initialize_backup_progress_unlocked()
} else {
// NOTICE: only available apps have entry in
// unfinished_partitions_per_app & partition_progress & app_chkpt_size
_progress.unfished_partitions_per_app[app_id] = app->partition_count;
_progress.unfinished_partitions_per_app[app_id] = app->partition_count;
std::map<int, int64_t> partition_chkpt_size;
for (const partition_configuration &pc : app->partitions) {
_progress.partition_progress[pc.pid] = 0;
Expand Down Expand Up @@ -622,8 +622,8 @@ void policy_context::sync_backup_to_remote_storage_unlocked(const backup_info &b
void policy_context::continue_current_backup_unlocked()
{
for (const int32_t &app : _cur_backup.app_ids) {
if (_progress.unfished_partitions_per_app.find(app) !=
_progress.unfished_partitions_per_app.end()) {
if (_progress.unfinished_partitions_per_app.find(app) !=
_progress.unfinished_partitions_per_app.end()) {
start_backup_app_meta_unlocked(app);
} else {
dsn::task_ptr task_after_write_finish_flag =
Expand Down Expand Up @@ -724,7 +724,7 @@ void policy_context::issue_new_backup_unlocked()

prepare_current_backup_on_new_unlocked();
// if all apps are dropped, we don't issue a new backup
if (_progress.unfished_partitions_per_app.empty()) {
if (_progress.unfinished_partitions_per_app.empty()) {
// TODO: just ignore this backup and wait next backup
dwarn("%s: all apps have been dropped, ignore this backup and retry it later",
_backup_sig.c_str());
Expand Down
4 changes: 2 additions & 2 deletions src/dist/replication/meta_server/meta_backup_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ struct backup_progress
int32_t unfinished_apps;
std::map<gpid, int32_t> partition_progress;
std::map<gpid, dsn::task_ptr> backup_requests;
std::map<app_id, int32_t> unfished_partitions_per_app;
std::map<app_id, int32_t> unfinished_partitions_per_app;
// <app_id, <partition_id, checkpoint size>>
std::map<app_id, std::map<int, int64_t>> app_chkpt_size;
// if app is dropped when starting a new backup or under backuping, we just skip backup this app
Expand All @@ -185,7 +185,7 @@ struct backup_progress
unfinished_apps = 0;
partition_progress.clear();
backup_requests.clear();
unfished_partitions_per_app.clear();
unfinished_partitions_per_app.clear();
app_chkpt_size.clear();
is_app_skipped.clear();
}
Expand Down
12 changes: 6 additions & 6 deletions src/dist/replication/test/meta_test/unit_test/backup_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void meta_service_test_app::policy_context_test()
ASSERT_LE(time_before_backup, mp._cur_backup.backup_id);
ASSERT_EQ(p.app_ids, mp._cur_backup.app_ids);
ASSERT_NE(0, mp._cur_backup.start_time_ms);
ASSERT_TRUE(mp._progress.unfished_partitions_per_app.empty());
ASSERT_TRUE(mp._progress.unfinished_partitions_per_app.empty());
ASSERT_EQ(p.app_ids.size(), mp._progress.unfinished_apps);
ASSERT_LE(test_policy_name + std::string("@") + std::to_string(time_before_backup),
mp._backup_sig);
Expand Down Expand Up @@ -274,10 +274,10 @@ void meta_service_test_app::policy_context_test()
{
zauto_lock l(mp._lock);
ASSERT_EQ(p.app_ids.size(), mp._progress.unfinished_apps);
ASSERT_EQ(1, mp._progress.unfished_partitions_per_app.size());
ASSERT_EQ(info.app_id, mp._progress.unfished_partitions_per_app.begin()->first);
ASSERT_EQ(1, mp._progress.unfinished_partitions_per_app.size());
ASSERT_EQ(info.app_id, mp._progress.unfinished_partitions_per_app.begin()->first);
ASSERT_EQ(info.partition_count,
mp._progress.unfished_partitions_per_app.begin()->second);
mp._progress.unfinished_partitions_per_app.begin()->second);
ASSERT_EQ(info.partition_count, mp._progress.partition_progress.size());
}
}
Expand Down Expand Up @@ -330,7 +330,7 @@ void meta_service_test_app::policy_context_test()
ASSERT_EQ(p.app_ids, mp._cur_backup.app_ids);

// every time intialize backup, the progress will be reset
ASSERT_TRUE(mp._progress.unfished_partitions_per_app.empty());
ASSERT_TRUE(mp._progress.unfinished_partitions_per_app.empty());
ASSERT_TRUE(mp._progress.partition_progress.empty());
ASSERT_EQ(p.app_ids.size(), mp._progress.unfinished_apps);
ASSERT_LE(test_policy_name + "@" + std::to_string(start_time_ms_of_sixth_backup),
Expand Down Expand Up @@ -415,7 +415,7 @@ void meta_service_test_app::policy_context_test()
ASSERT_EQ(kv.first.get_app_id(), app->app_id);
ASSERT_EQ(kv.second, 1000);
}
for (const auto &kv : mp._progress.unfished_partitions_per_app) {
for (const auto &kv : mp._progress.unfinished_partitions_per_app) {
ASSERT_EQ(0, kv.second);
}
}
Expand Down

0 comments on commit 675b8e7

Please sign in to comment.