You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2018/04/05 17:24:42 UTC
hbase git commit: HBASE-20095 Redesign single instance pool in
CleanerChore - addendum simplifies onConfigurationChange
Repository: hbase
Updated Branches:
refs/heads/master 65e85c4f8 -> 8f6849ff0
HBASE-20095 Redesign single instance pool in CleanerChore - addendum simplifies onConfigurationChange
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8f6849ff
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8f6849ff
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8f6849ff
Branch: refs/heads/master
Commit: 8f6849ff02fa9e37aab9d7bcab5b8d7b8b37a89d
Parents: 65e85c4
Author: tedyu <yu...@gmail.com>
Authored: Thu Apr 5 10:24:37 2018 -0700
Committer: tedyu <yu...@gmail.com>
Committed: Thu Apr 5 10:24:37 2018 -0700
----------------------------------------------------------------------
.../hbase/master/cleaner/CleanerChore.java | 25 +++++++-------------
1 file changed, 9 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/8f6849ff/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
index 312bcce..396fbaf 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
@@ -89,37 +89,33 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
}
/**
- * Checks if pool can be updated immediately.
+ * Checks if pool can be updated. If so, mark for update later.
* @param conf configuration
- * @return true if pool can be updated immediately, false otherwise
*/
- synchronized boolean canUpdateImmediately(Configuration conf) {
+ synchronized void markUpdate(Configuration conf) {
int newSize = calculatePoolSize(conf.get(CHORE_POOL_SIZE, DEFAULT_CHORE_POOL_SIZE));
if (newSize == size) {
LOG.trace("Size from configuration is same as previous={}, no need to update.", newSize);
- return false;
+ return;
}
size = newSize;
- if (pool.getPoolSize() == 0) {
- // chore has no working thread.
- return true;
- }
// Chore is working, update it later.
reconfigNotification.set(true);
- return false;
}
/**
* Update pool with new size.
*/
synchronized void updatePool(long timeout) {
- while (cleanerLatch != 0) {
+ long stopTime = System.currentTimeMillis() + timeout;
+ while (cleanerLatch != 0 && timeout > 0) {
try {
wait(timeout);
+ timeout = stopTime - System.currentTimeMillis();
} catch (InterruptedException ie) {
- // It's ok to ignore
+ Thread.currentThread().interrupt();
+ break;
}
- break;
}
pool.shutdownNow();
LOG.info("Update chore's pool size from {} to {}", pool.getParallelism(), size);
@@ -243,10 +239,7 @@ public abstract class CleanerChore<T extends FileCleanerDelegate> extends Schedu
@Override
public void onConfigurationChange(Configuration conf) {
- if (POOL.canUpdateImmediately(conf)) {
- // Can immediately update, no need to wait.
- POOL.updatePool(0);
- }
+ POOL.markUpdate(conf);
}
/**