Skip to content

Commit

Permalink
Propagate config changes if balancer is a ConfigurationObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
bbeaudreault committed Feb 5, 2022
1 parent aa95b4a commit 03c3650
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.conf.ConfigurationObserver;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;

Expand Down Expand Up @@ -60,4 +61,13 @@ public boolean dispatch(final CallRunner callTask) throws InterruptedException {
}
return queue.offer(callTask);
}

@Override
public void onConfigurationChange(Configuration conf) {
super.onConfigurationChange(conf);

if (balancer instanceof ConfigurationObserver) {
((ConfigurationObserver) balancer).onConfigurationChange(conf);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.conf.ConfigurationObserver;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
import org.slf4j.Logger;
Expand Down Expand Up @@ -280,4 +281,18 @@ private static int calcNumWriters(final int count, final float readShare) {
private static int calcNumReaders(final int count, final float readShare) {
return count - calcNumWriters(count, readShare);
}

@Override
public void onConfigurationChange(Configuration conf) {
super.onConfigurationChange(conf);
propagateBalancerConfigChange(writeBalancer, conf);
propagateBalancerConfigChange(readBalancer, conf);
propagateBalancerConfigChange(scanBalancer, conf);
}

private void propagateBalancerConfigChange(QueueBalancer balancer, Configuration conf) {
if (balancer instanceof ConfigurationObserver) {
((ConfigurationObserver) balancer).onConfigurationChange(conf);
}
}
}

0 comments on commit 03c3650

Please sign in to comment.