Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
empiredan committed Dec 3, 2024
1 parent c93f286 commit 566789a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
11 changes: 10 additions & 1 deletion idl/duplication.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ namespace cpp dsn.replication
namespace go admin
namespace java org.apache.pegasus.replication

enum duplication_mode
{
FULL = 0,
INCREMENTAL,
}

// - INIT -> PREPARE
// - PREPARE -> APP
// - APP -> LOG
Expand Down Expand Up @@ -158,9 +164,12 @@ struct duplication_entry
// For versions < v2.6.0, this must be the same with source replica_count.
9:optional i32 remote_replica_count;

// TODO(wangdan)
10:optional duplication_mode mode;

// Used for listing duplications(client -> meta server).
// partition index => partition states.
10:optional map<i32, duplication_partition_state> partition_states;
11:optional map<i32, duplication_partition_state> partition_states;
}

// This request is sent from client to meta.
Expand Down
8 changes: 1 addition & 7 deletions src/meta/duplication/duplication_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,17 +293,11 @@ duplication_info_s_ptr duplication_info::decode_from_blob(dupid_t dup_id,
return dup;
}

void duplication_info::append_if_valid_for_query(
const app_state &app,
/*out*/ std::vector<duplication_entry> &entry_list) const
void duplication_info::append_as_entry(std::vector<duplication_entry> &entry_list) const
{
zauto_read_lock l(_lock);

entry_list.emplace_back(to_duplication_level_entry());
duplication_entry &ent = entry_list.back();
// the confirmed decree is not useful for displaying
// the overall state of duplication
// ent.__isset.progress = false;
}

} // namespace dsn::replication
4 changes: 2 additions & 2 deletions src/meta/duplication/duplication_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ class duplication_info

// duplication_query_rpc is handled in THREAD_POOL_META_SERVER,
// which is not thread safe for read.
void append_if_valid_for_query(const app_state &app,
/*out*/ std::vector<duplication_entry> &entry_list) const;
void append_as_entry(std::vector<duplication_entry> &entry_list) const;

duplication_entry to_duplication_level_entry() const
{
Expand Down Expand Up @@ -196,6 +195,7 @@ class duplication_info
duplication_partition_state partition_state;
partition_state.confirmed_decree = state.stored_decree;
partition_state.last_committed_decree = state.last_committed_decree;

entry.partition_states.emplace(partition_id, partition_state);
}

Expand Down
2 changes: 1 addition & 1 deletion src/meta/duplication/meta_duplication_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void meta_duplication_service::query_duplication_info(const duplication_query_re

response.appid = app->app_id;
for (const auto &[_, dup] : app->duplications) {
dup->append_if_valid_for_query(*app, response.entry_list);
dup->append_as_entry(response.entry_list);
}
}
}
Expand Down

0 comments on commit 566789a

Please sign in to comment.