empiredan commented on code in PR #1759:
URL:
https://github.com/apache/incubator-pegasus/pull/1759#discussion_r1426167637
##########
src/replica/mutation_log.cpp:
##########
@@ -895,14 +735,8 @@ decree mutation_log::max_gced_decree_no_lock(gpid gpid)
const
void mutation_log::check_valid_start_offset(gpid gpid, int64_t
valid_start_offset) const
{
zauto_lock l(_lock);
- if (_is_private) {
- CHECK_EQ(valid_start_offset, _private_log_info.valid_start_offset);
- } else {
- auto it = _shared_log_info_map.find(gpid);
- if (it != _shared_log_info_map.end()) {
- CHECK_EQ(valid_start_offset, it->second.valid_start_offset);
- }
- }
+ CHECK(_is_private, "");
Review Comment:
```suggestion
CHECK_TRUE(_is_private);
```
##########
src/replica/mutation_log.cpp:
##########
@@ -759,14 +606,11 @@ error_code mutation_log::create_new_log_file()
// write file header into pending buffer
size_t header_len = 0;
binary_writer temp_writer;
- if (_is_private) {
- replica_log_info_map ds;
- ds[_private_gpid] =
- replica_log_info(_private_log_info.max_decree,
_private_log_info.valid_start_offset);
- header_len = logf->write_file_header(temp_writer, ds);
- } else {
- header_len = logf->write_file_header(temp_writer,
_shared_log_info_map);
- }
+ CHECK(_is_private, "");
Review Comment:
```suggestion
CHECK_TRUE(_is_private);
```
##########
src/replica/mutation_log.cpp:
##########
@@ -989,53 +823,29 @@ error_code mutation_log::reset_from(const std::string
&dir,
void mutation_log::set_valid_start_offset_on_open(gpid gpid, int64_t
valid_start_offset)
{
zauto_lock l(_lock);
- if (_is_private) {
- CHECK_EQ(gpid, _private_gpid);
- _private_log_info.valid_start_offset = valid_start_offset;
- } else {
- _shared_log_info_map[gpid] = replica_log_info(0, valid_start_offset);
- }
+ CHECK(_is_private, "");
Review Comment:
```suggestion
CHECK_TRUE(_is_private);
```
##########
src/replica/mutation_log.cpp:
##########
@@ -1044,20 +854,10 @@ void mutation_log::update_max_decree(gpid gpid, decree d)
void mutation_log::update_max_decree_no_lock(gpid gpid, decree d)
{
- if (!_is_private) {
- auto it = _shared_log_info_map.find(gpid);
- if (it != _shared_log_info_map.end()) {
- if (it->second.max_decree < d) {
- it->second.max_decree = d;
- }
- } else {
- CHECK(false, "replica has not been registered in the log before");
- }
- } else {
- CHECK_EQ(gpid, _private_gpid);
- if (d > _private_log_info.max_decree) {
- _private_log_info.max_decree = d;
- }
+ CHECK(_is_private, "");
Review Comment:
```suggestion
CHECK_TRUE(_is_private);
```
##########
src/replica/mutation_log.cpp:
##########
@@ -852,13 +696,9 @@ std::pair<log_file_ptr, int64_t>
mutation_log::mark_new_offset(size_t size,
decree mutation_log::max_decree(gpid gpid) const
{
zauto_lock l(_lock);
- if (_is_private) {
- CHECK_EQ(gpid, _private_gpid);
- return _private_log_info.max_decree;
- } else {
- const auto &it = _shared_log_info_map.find(gpid);
- return it != _shared_log_info_map.end() ? it->second.max_decree : 0;
- }
+ CHECK(_is_private, "");
Review Comment:
```suggestion
CHECK_TRUE(_is_private);
```
##########
src/replica/mutation_log.cpp:
##########
@@ -989,53 +823,29 @@ error_code mutation_log::reset_from(const std::string
&dir,
void mutation_log::set_valid_start_offset_on_open(gpid gpid, int64_t
valid_start_offset)
{
zauto_lock l(_lock);
- if (_is_private) {
- CHECK_EQ(gpid, _private_gpid);
- _private_log_info.valid_start_offset = valid_start_offset;
- } else {
- _shared_log_info_map[gpid] = replica_log_info(0, valid_start_offset);
- }
+ CHECK(_is_private, "");
+ CHECK_EQ(gpid, _private_gpid);
+ _private_log_info.valid_start_offset = valid_start_offset;
}
int64_t mutation_log::on_partition_reset(gpid gpid, decree max_decree)
{
zauto_lock l(_lock);
- if (_is_private) {
- CHECK_EQ(_private_gpid, gpid);
- replica_log_info old_info = _private_log_info;
- _private_log_info.max_decree = max_decree;
- _private_log_info.valid_start_offset = _global_end_offset;
- LOG_WARNING("replica {} has changed private log max_decree from {} to
{}, "
- "valid_start_offset from {} to {}",
- gpid,
- old_info.max_decree,
- _private_log_info.max_decree,
- old_info.valid_start_offset,
- _private_log_info.valid_start_offset);
- } else {
- replica_log_info info(max_decree, _global_end_offset);
- auto it =
_shared_log_info_map.insert(replica_log_info_map::value_type(gpid, info));
- if (!it.second) {
- LOG_WARNING("replica {} has changed shared log max_decree from {}
to {}, "
- "valid_start_offset from {} to {} ",
- gpid,
- it.first->second.max_decree,
- info.max_decree,
- it.first->second.valid_start_offset,
- info.valid_start_offset);
- _shared_log_info_map[gpid] = info;
- }
- }
+ CHECK(_is_private, "");
Review Comment:
```suggestion
CHECK_TRUE(_is_private);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]