Skip to content

Commit

Permalink
[fix][coordinator] Remove unused code.
Browse files Browse the repository at this point in the history
Signed-off-by: Ketor <d.ketor@gmail.com>
  • Loading branch information
ketor committed Oct 30, 2023
1 parent 9e97dee commit a957b1e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 373 deletions.
65 changes: 0 additions & 65 deletions src/coordinator/coordinator_control.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,19 +302,6 @@ bool CoordinatorControl::Recover() {
DINGO_LOG(INFO) << "Recover deleted_table_meta, count=" << kvs.size();
kvs.clear();

// 7.store_metrics map
if (!meta_reader_->Scan(store_metrics_meta_->Prefix(), kvs)) {
return false;
}
{
BAIDU_SCOPED_LOCK(store_metrics_map_mutex_);
if (!store_metrics_meta_->Recover(kvs)) {
return false;
}
}
DINGO_LOG(INFO) << "Recover store_metrics_meta, count=" << kvs.size();
kvs.clear();

// 8.table_metrics map
if (!meta_reader_->Scan(table_metrics_meta_->Prefix(), kvs)) {
return false;
Expand Down Expand Up @@ -419,42 +406,6 @@ bool CoordinatorControl::Recover() {
DINGO_LOG(INFO) << "Recover index_metrics_meta, count=" << kvs.size();
kvs.clear();

// // 14.lease map
// if (!meta_reader_->Scan(lease_meta_->Prefix(), kvs)) {
// return false;
// }
// {
// if (!lease_meta_->Recover(kvs)) {
// return false;
// }
// }
// DINGO_LOG(INFO) << "Recover lease_meta, count=" << kvs.size();
// kvs.clear();

// // 15.kv_index map
// if (!meta_reader_->Scan(kv_index_meta_->Prefix(), kvs)) {
// return false;
// }
// {
// if (!kv_index_meta_->Recover(kvs)) {
// return false;
// }
// }
// DINGO_LOG(INFO) << "Recover kv_index_meta, count=" << kvs.size();
// kvs.clear();

// // 16.kv_rev map
// if (!meta_reader_->Scan(kv_rev_meta_->Prefix(), kvs)) {
// return false;
// }
// {
// if (!kv_rev_meta_->Recover(kvs)) {
// return false;
// }
// }
// DINGO_LOG(INFO) << "Recover kv_rev_meta, count=" << kvs.size();
// kvs.clear();

// 50.table_index map
if (!meta_reader_->Scan(table_index_meta_->Prefix(), kvs)) {
return false;
Expand All @@ -469,16 +420,6 @@ bool CoordinatorControl::Recover() {
// build id_epoch, schema_name, table_name, index_name maps
BuildTempMaps();

// // build version_lease_to_key_map_temp_
// BuildLeaseToKeyMap();
// DINGO_LOG(INFO) << "Recover lease_to_key_map_temp, count=" << lease_to_key_map_temp_.size();

// std::map<std::string, pb::coordinator_internal::KvRevInternal> kv_rev_map;
// kv_rev_map_.GetRawMapCopy(kv_rev_map);
// for (auto& kv : kv_rev_map) {
// DINGO_LOG(INFO) << "kv_rev_map key=" << Helper::StringToHex(kv.first) << " value=" << kv.second.DebugString();
// }

return true;
}

Expand All @@ -497,12 +438,6 @@ bool CoordinatorControl::Init() {
GenerateRootSchemas(root_schema, meta_schema, dingo_schema, mysql_schema, information_schema);

// add the initial schemas to schema_map_
// schema_map_.insert(std::make_pair(pb::meta::ReservedSchemaIds::ROOT_SCHEMA, root_schema)); // raft_kv_put
// schema_map_.insert(std::make_pair(pb::meta::ReservedSchemaIds::META_SCHEMA, meta_schema)); // raft_kv_put
// schema_map_.insert(std::make_pair(pb::meta::ReservedSchemaIds::DINGO_SCHEMA, dingo_schema)); // raft_kv_put
// schema_map_.insert(std::make_pair(pb::meta::ReservedSchemaIds::MYSQL_SCHEMA, mysql_schema)); // raft_kv_put
// schema_map_.insert(
// std::make_pair(pb::meta::ReservedSchemaIds::INFORMATION_SCHEMA, information_schema)); // raft_kv_put
schema_map_.Put(pb::meta::ReservedSchemaIds::ROOT_SCHEMA, root_schema); // raft_kv_put
schema_map_.Put(pb::meta::ReservedSchemaIds::META_SCHEMA, meta_schema); // raft_kv_put
schema_map_.Put(pb::meta::ReservedSchemaIds::DINGO_SCHEMA, dingo_schema); // raft_kv_put
Expand Down
121 changes: 0 additions & 121 deletions src/coordinator/coordinator_control_coor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3126,95 +3126,6 @@ butil::Status CoordinatorControl::AddStoreOperation(const pb::coordinator::Store
return butil::Status::OK();
}

// UpdateRegionMap
// int64_t CoordinatorControl::UpdateRegionMap(std::vector<pb::common::Region>& regions,
// pb::coordinator_internal::MetaIncrement& meta_increment) {
// int64_t region_map_epoch = GetPresentId(pb::coordinator_internal::IdEpochType::EPOCH_REGION);

// bool need_to_get_next_epoch = false;
// {
// // BAIDU_SCOPED_LOCK(region_map_mutex_);
// for (const auto& region : regions) {
// pb::coordinator_internal::RegionInternal region_to_update;
// int ret = region_map_.Get(region.id(), region_to_update);
// if (ret > 0) {
// DINGO_LOG(INFO) << " update region to region_map in heartbeat, region_id=" << region.id();

// // if state not change, just update leader_store_id
// if (region_to_update.state() == region.state()) {
// continue;
// } else {
// // state not equal, need to update region data and apply raft
// DINGO_LOG(INFO) << "REGION STATUS CHANGE region_id = " << region.id()
// << " old status = " << region_to_update.state() << " new status = " << region.state();
// // maybe need to build a state machine here
// // if a region is set to DELETE, it will never be updated to
// // other normal state
// const auto& region_delete_state_name =
// dingodb::pb::common::RegionState_Name(pb::common::RegionState::REGION_DELETE);
// const auto& region_state_in_map = dingodb::pb::common::RegionState_Name(region_to_update.state());
// const auto& region_state_in_req = dingodb::pb::common::RegionState_Name(region.state());

// // if store want to update a region state from DELETE_* to other
// // NON DELETE_* state, it is illegal
// if (region_state_in_map.rfind(region_delete_state_name, 0) == 0 &&
// region_state_in_req.rfind(region_delete_state_name, 0) != 0) {
// DINGO_LOG(INFO) << "illegal intend to update region state from "
// "REGION_DELETE to "
// << region_state_in_req << " region_id=" << region.id();
// continue;
// }
// }

// // update meta_increment
// auto* region_increment = meta_increment.add_regions();
// region_increment->set_id(region.id());
// region_increment->set_op_type(::dingodb::pb::coordinator_internal::MetaIncrementOpType::UPDATE);

// auto* region_increment_region = region_increment->mutable_region();
// *region_increment_region = region;

// need_to_get_next_epoch = true;

// // on_apply
// // region_map_[region.id()] = region; // raft_kv_put
// // region_map_epoch++; // raft_kv_put
// } else if (region.id() == 0) {
// DINGO_LOG(INFO) << " found illegal null region in heartbeat, region_id=0"
// << " name=" << region.definition().name() << " leader_store_id=" <<
// region.leader_store_id()
// << " state=" << region.state();
// } else {
// DINGO_LOG(INFO) << " found illegal region in heartbeat, region_id=" << region.id()
// << " name=" << region.definition().name() << " leader_store_id=" <<
// region.leader_store_id()
// << " state=" << region.state();

// auto* region_increment = meta_increment.add_regions();
// region_increment->set_id(region.id());
// region_increment->set_op_type(::dingodb::pb::coordinator_internal::MetaIncrementOpType::CREATE);

// auto* region_increment_region = region_increment->mutable_region();
// *region_increment_region = region;
// region_increment_region->set_state(::dingodb::pb::common::RegionState::REGION_ILLEGAL);

// need_to_get_next_epoch = true;

// // region_map_.insert(std::make_pair(region.id(), region)); //
// // raft_kv_put
// }
// }
// }

// if (need_to_get_next_epoch) {
// region_map_epoch = GetNextId(pb::coordinator_internal::IdEpochType::EPOCH_REGION, meta_increment);
// }

// DINGO_LOG(INFO) << "UpdateRegionMapMulti epoch=" << region_map_epoch;

// return region_map_epoch;
// }

void CoordinatorControl::GetExecutorMap(pb::common::ExecutorMap& executor_map) {
int64_t executor_map_epoch = GetPresentId(pb::coordinator_internal::IdEpochType::EPOCH_EXECUTOR);
executor_map.set_epoch(executor_map_epoch);
Expand Down Expand Up @@ -3896,38 +3807,6 @@ int64_t CoordinatorControl::UpdateStoreMetrics(const pb::common::StoreMetrics& s
} else {
store_metrics_map_.insert(store_metrics.id(), store_metrics);
}

// if (store_metrics_map_.seek(store_metrics.id()) != nullptr) {
// DINGO_LOG(DEBUG) << "STORE METIRCS UPDATE store_metrics.id = " <<
// store_metrics.id();

// // update meta_increment
// auto* store_metrics_increment =
// meta_increment.add_store_metrics();
// store_metrics_increment->set_id(store_metrics.id());
// store_metrics_increment->set_op_type(::dingodb::pb::coordinator_internal::MetaIncrementOpType::UPDATE);

// auto* store_metrics_increment_store =
// store_metrics_increment->mutable_store_metrics();
// *store_metrics_increment_store = store_metrics;

// // set is_partial_region_metrics
// if (store_metrics.is_partial_region_metrics()) {
// store_metrics_increment->set_is_partial_region_metrics(store_metrics.is_partial_region_metrics());
// }
// } else {
// DINGO_LOG(INFO) << "NEED ADD NEW STORE store_metrics.id = " <<
// store_metrics.id();

// // update meta_increment
// auto* store_metrics_increment =
// meta_increment.add_store_metrics();
// store_metrics_increment->set_id(store_metrics.id());
// store_metrics_increment->set_op_type(::dingodb::pb::coordinator_internal::MetaIncrementOpType::CREATE);

// auto* store_metrics_increment_store =
// store_metrics_increment->mutable_store_metrics();
// }
}

// mbvar store
Expand Down
Loading

0 comments on commit a957b1e

Please sign in to comment.