HBASE-1000 Sleeper.sleep does not go back to sleep when interrupted and no stop flag given.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@723589 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2987febc16
commit
4024f5f128
|
@ -99,6 +99,8 @@ Release 0.19.0 - Unreleased
|
|||
HBASE-1039 Compaction fails if bloomfilters are enabled
|
||||
HBASE-1027 Make global flusher check work with percentages rather than
|
||||
hard code memory sizes
|
||||
HBASE-1000 Sleeper.sleep does not go back to sleep when interrupted
|
||||
and no stop flag given.
|
||||
|
||||
IMPROVEMENTS
|
||||
HBASE-901 Add a limit to key length, check key and value length on client side
|
||||
|
|
|
@ -59,19 +59,21 @@ public abstract class Chore extends Thread {
|
|||
this.sleeper.sleep();
|
||||
}
|
||||
this.sleeper.sleep();
|
||||
while(!this.stop.get()) {
|
||||
while (!this.stop.get()) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
chore();
|
||||
this.sleeper.sleep(startTime);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Caught exception", e);
|
||||
if (this.stop.get()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
this.sleeper.sleep(startTime);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
LOG.fatal("Caught error. Starting shutdown.", t);
|
||||
this.stop.set(true);
|
||||
|
||||
} finally {
|
||||
LOG.info(getName() + " exiting");
|
||||
}
|
||||
|
@ -97,4 +99,4 @@ public abstract class Chore extends Thread {
|
|||
protected void sleep() {
|
||||
this.sleeper.sleep();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,11 +66,14 @@ public class Sleeper {
|
|||
LOG.warn("Calculated wait time > " + this.period +
|
||||
"; setting to this.period: " + System.currentTimeMillis() + ", " +
|
||||
startTime);
|
||||
waitTime = this.period;
|
||||
}
|
||||
if (waitTime > 0) {
|
||||
while (waitTime > 0) {
|
||||
long woke = -1;
|
||||
try {
|
||||
Thread.sleep(waitTime);
|
||||
long slept = System.currentTimeMillis() - now;
|
||||
woke = System.currentTimeMillis();
|
||||
long slept = woke - now;
|
||||
if (slept > (10 * this.period)) {
|
||||
LOG.warn("We slept " + slept + "ms, ten times longer than scheduled: " +
|
||||
this.period);
|
||||
|
@ -82,6 +85,9 @@ public class Sleeper {
|
|||
return;
|
||||
}
|
||||
}
|
||||
// Recalculate waitTime.
|
||||
woke = (woke == -1)? System.currentTimeMillis(): woke;
|
||||
waitTime = this.period - (woke - startTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue