Skip to content

Commit

Permalink
This commit provides additional functionality that is logically relat…
Browse files Browse the repository at this point in the history
…ed to the

earlier commit 923982c

Original commit message:

ENG-1333. Report errors in LoadBalancer.

Summary: Added more logging, added Result and Status to load balancer flow and bubble up error messages to RunLoadBalancer.

Test Plan: ybd --cxx_test catalog_manager-test_ent --gtest_filter TestLoadBalancerEnterprise.TestLoadBalancerAlgorithm

Reviewers: bogdan, bharat

Reviewed By: bharat

Subscribers: ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D5647
  • Loading branch information
rahuldesirazu authored and mbautin committed Jul 11, 2019
1 parent 37581f8 commit 9fafb14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions ent/src/yb/master/cluster_balance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ namespace enterprise {

Result<bool> ClusterLoadBalancer::HandleLeaderMoves(
TabletId* out_tablet_id, TabletServerId* out_from_ts, TabletServerId* out_to_ts) {
if (HandleLeaderLoadIfNonAffinitized(out_tablet_id, out_from_ts, out_to_ts)) {
if (VERIFY_RESULT(HandleLeaderLoadIfNonAffinitized(out_tablet_id, out_from_ts, out_to_ts))) {
RETURN_NOT_OK(MoveLeader(*out_tablet_id, *out_from_ts, *out_to_ts));
return true;
}

return super::HandleLeaderMoves(out_tablet_id, out_from_ts, out_to_ts);
}

Result<bool> ClusterLoadBalancer::AnalyzeTablets(const TableId& table_uuid) {
Status ClusterLoadBalancer::AnalyzeTablets(const TableId& table_uuid) {
ClusterLoadState* ent_state = GetEntState();
GetAllAffinitizedZones(&ent_state->affinitized_zones_);
return super::AnalyzeTablets(table_uuid);
Expand All @@ -35,7 +35,7 @@ void ClusterLoadBalancer::GetAllAffinitizedZones(AffinitizedZonesSet* affinitize
}
}

bool ClusterLoadBalancer::HandleLeaderLoadIfNonAffinitized(TabletId* moving_tablet_id,
Result<bool> ClusterLoadBalancer::HandleLeaderLoadIfNonAffinitized(TabletId* moving_tablet_id,
TabletServerId* from_ts,
TabletServerId* to_ts) {
// Similar to normal leader balancing, we double iterate from most loaded to least loaded
Expand Down Expand Up @@ -91,7 +91,7 @@ void ClusterLoadBalancer::PopulatePlacementInfo(TabletInfo* tablet, PlacementInf
}
}

bool ClusterLoadBalancer::UpdateTabletInfo(TabletInfo* tablet) {
Status ClusterLoadBalancer::UpdateTabletInfo(TabletInfo* tablet) {
const auto& table_id = tablet->table()->id();
// Set the placement information on a per-table basis, only once.
if (!state_->placement_by_table_.count(table_id)) {
Expand Down
8 changes: 4 additions & 4 deletions ent/src/yb/master/cluster_balance.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ class ClusterLoadBalancer : public yb::master::ClusterLoadBalancer {
Result<bool> HandleLeaderMoves(
TabletId* out_tablet_id, TabletServerId* out_from_ts, TabletServerId* out_to_ts) override;

Result<bool> AnalyzeTablets(const TableId& table_uuid) override;
CHECKED_STATUS AnalyzeTablets(const TableId& table_uuid) override;

virtual void GetAllAffinitizedZones(AffinitizedZonesSet* affinitized_zones) const;

// This function handles leader load from non-affinitized to affinitized nodes.
// If it can find a way to move leader load from a non-affinitized to affinitized node,
// returns true. Otherwise, returns false.
// returns true, if not returns false, if error is found, returns Status.
// This is called before normal leader load balancing.
bool HandleLeaderLoadIfNonAffinitized(
Result<bool> HandleLeaderLoadIfNonAffinitized(
TabletId* moving_tablet_id, TabletServerId* from_ts, TabletServerId* to_ts);

bool UpdateTabletInfo(TabletInfo* tablet) override;
CHECKED_STATUS UpdateTabletInfo(TabletInfo* tablet) override;

// Runs the load balancer once for the live and all read only clusters, in order
// of the cluster config.
Expand Down

0 comments on commit 9fafb14

Please sign in to comment.