|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.apache.hadoop.hbase.regionserver.Leases
public class Leases
Leases There are several server classes in HBase that need to track external clients that occasionally send heartbeats.
These external clients hold resources in the server class. Those resources need to be released if the external client fails to send a heartbeat after some interval of time passes.
The Leases class is a general reusable class for this kind of pattern. An instance of the Leases class will create a thread to do its dirty work. You should close() the instance if you want to clean up the thread properly.
NOTE: This class extends Thread rather than Chore because the sleep time can be interrupted when there is something to do, rather than the Chore sleep time which is invariant.
Nested Class Summary | |
---|---|
static class |
Leases.LeaseStillHeldException
Thrown if we are asked create a lease but lease on passed name already exists. |
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected Map<String,org.apache.hadoop.hbase.regionserver.Leases.Lease> |
leases
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
Leases(int leasePeriod,
int leaseCheckFrequency)
Creates a lease monitor |
Method Summary | |
---|---|
void |
addLease(org.apache.hadoop.hbase.regionserver.Leases.Lease lease)
Inserts lease. |
void |
cancelLease(String leaseName)
Client explicitly cancels a lease. |
void |
close()
Shut down this Leases instance. |
void |
closeAfterLeasesExpire()
Shuts down this lease instance when all outstanding leases expire. |
void |
createLease(String leaseName,
LeaseListener listener)
Obtain a lease |
void |
renewLease(String leaseName)
Renew a lease |
void |
run()
|
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Map<String,org.apache.hadoop.hbase.regionserver.Leases.Lease> leases
Constructor Detail |
---|
public Leases(int leasePeriod, int leaseCheckFrequency)
leasePeriod
- - length of time (milliseconds) that the lease is validleaseCheckFrequency
- - how often the lease should be checked
(milliseconds)Method Detail |
---|
public void run()
run
in interface Runnable
run
in class Thread
Thread.run()
public void closeAfterLeasesExpire()
close()
but rather than violently end all leases, waits
first on extant leases to finish. Use this method if the lease holders
could loose data, leak locks, etc. Presumes client has shutdown
allocation of new leases.
public void close()
public void createLease(String leaseName, LeaseListener listener) throws Leases.LeaseStillHeldException
leaseName
- name of the leaselistener
- listener that will process lease expirations
Leases.LeaseStillHeldException
public void addLease(org.apache.hadoop.hbase.regionserver.Leases.Lease lease) throws Leases.LeaseStillHeldException
lease
-
Leases.LeaseStillHeldException
public void renewLease(String leaseName) throws LeaseException
leaseName
- name of lease
LeaseException
public void cancelLease(String leaseName) throws LeaseException
leaseName
- name of lease
LeaseException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |