HBASE-9250 Make sure lease time isn't ever negative.
Sometimes nextLease.getDelay can return a negative number. Trying to sleep for a negative time thows an uncaught exception bringing down the whole regionserver. git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1514899 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ec67046424
commit
0a31b4bd8a
|
@ -56,6 +56,7 @@ import java.io.IOException;
|
|||
@InterfaceAudience.Private
|
||||
public class Leases extends HasThread {
|
||||
private static final Log LOG = LogFactory.getLog(Leases.class.getName());
|
||||
public static final int MIN_WAIT_TIME = 100;
|
||||
private final Map<String, Lease> leases = new ConcurrentHashMap<String, Lease>();
|
||||
|
||||
protected final int leaseCheckFrequency;
|
||||
|
@ -87,7 +88,10 @@ public class Leases extends HasThread {
|
|||
if (nextLease != null) {
|
||||
toWait = nextLease.getDelay(TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
toWait = Math.min(leaseCheckFrequency, toWait);
|
||||
toWait = Math.max(MIN_WAIT_TIME, toWait);
|
||||
|
||||
Thread.sleep(toWait);
|
||||
} catch (InterruptedException e) {
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue