MCPcopy Create free account
hub / github.com/baidu/tera / PickRandomTabletOfMetaNode

Method PickRandomTabletOfMetaNode

src/load_balancer/action_generators.cc:502–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500}
501
502uint32_t MetaIsolateActionGenerator::PickRandomTabletOfMetaNode(
503 const std::shared_ptr<Cluster>& cluster, uint32_t source_node_index) {
504 uint32_t tablet_num = cluster->tablets_per_node_[source_node_index].size();
505 if (tablet_num < 2) {
506 return kInvalidTabletIndex;
507 }
508
509 while (true) {
510 uint32_t rand = Random::Rand(0, tablet_num);
511 uint32_t tablet_index = cluster->tablets_per_node_[source_node_index][rand];
512 if (!cluster->IsMetaTablet(tablet_index)) {
513 return tablet_index;
514 }
515 }
516}
517
518uint32_t MetaIsolateActionGenerator::PickLeastComplexLoadNode(
519 const std::shared_ptr<Cluster>& cluster, const std::vector<uint32_t>& sorted_node_index,

Callers 1

TEST_FFunction · 0.80

Calls 2

IsMetaTabletMethod · 0.80
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.64