Index: hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (revision 1344525) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (working copy) @@ -116,6 +116,8 @@ private TimeoutMonitor timeoutMonitor; + private TimerUpdater timerUpdater; + private LoadBalancer balancer; /** @@ -161,6 +163,13 @@ new TreeMap>(); /** + * Contains the server which need to update timer, these servers will be + * handled by {@link TimerUpdater} + */ + private final ConcurrentSkipListSet serversInUpdatingTimer = + new ConcurrentSkipListSet(); + + /** * Region to server assignment map. * Contains the server a given region is currently assigned to. * This Map and {@link #servers} are tied. Always update this in tandem @@ -218,6 +227,10 @@ conf.getInt("hbase.master.assignment.timeoutmonitor.period", 10000), master, serverManager, conf.getInt("hbase.master.assignment.timeoutmonitor.timeout", 1800000)); + this.timerUpdater = new TimerUpdater(conf.getInt( + "hbase.master.assignment.timerupdater.period", 10000), master); + Threads.setDaemonThreadRunning(timerUpdater.getThread(), + master.getServerName() + ".timerUpdater"); this.zkTable = new ZKTable(this.master.getZooKeeper()); this.maximumAssignmentAttempts = this.master.getConfiguration().getInt("hbase.assignment.maximum.attempts", 10); @@ -1225,11 +1238,20 @@ } // Remove plan if one. clearRegionPlan(regionInfo); - // Update timers for all regions in transition going against this server. - updateTimers(sn); + // Add the server to serversInUpdatingTimer + addToServersInUpdatingTimer(sn); } /** + * Add the server to the set serversInUpdatingTimer, then {@link TimerUpdater} + * will update timers for this server in background + * @param sn + */ + private void addToServersInUpdatingTimer(final ServerName sn) { + this.serversInUpdatingTimer.add(sn); + } + + /** * Touch timers for all regions in transition that have the passed * sn in common. * Call this method whenever a server checks in. Doing so helps the case where @@ -2906,6 +2928,35 @@ } /** + * Update timers for all regions in transition going against the server in the + * serversInUpdatingTimer. + */ + public class TimerUpdater extends Chore { + + public TimerUpdater(final int period, final Stoppable stopper) { + super("AssignmentTimerUpdater", period, stopper); + } + + @Override + protected void chore() { + ServerName serverToUpdateTimer = null; + while (!serversInUpdatingTimer.isEmpty() && !stopper.isStopped()) { + if (serverToUpdateTimer == null) { + serverToUpdateTimer = serversInUpdatingTimer.first(); + } else { + serverToUpdateTimer = serversInUpdatingTimer + .higher(serverToUpdateTimer); + } + if (serverToUpdateTimer == null) { + break; + } + updateTimers(serverToUpdateTimer); + serversInUpdatingTimer.remove(serverToUpdateTimer); + } + } + } + + /** * Monitor to check for time outs on region transition operations */ public class TimeoutMonitor extends Chore { @@ -3449,6 +3500,7 @@ public void stop() { this.timeoutMonitor.interrupt(); + this.timerUpdater.interrupt(); } /**