|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.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.
Field Summary | |
---|---|
protected long |
leaseCheckFrequency
|
protected long |
leasePeriod
|
protected Map<org.apache.hadoop.hbase.Leases.LeaseName,org.apache.hadoop.hbase.Leases.Lease> |
leases
|
protected static org.apache.commons.logging.Log |
LOG
|
protected boolean |
running
|
protected TreeSet<org.apache.hadoop.hbase.Leases.Lease> |
sortedLeases
|
Constructor Summary | |
---|---|
Leases(long leasePeriod,
long leaseCheckFrequency)
Creates a lease |
Method Summary | |
---|---|
void |
cancelLease(long holderId,
long resourceId)
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(long holderId,
long resourceId,
LeaseListener listener)
Obtain a lease |
protected org.apache.hadoop.hbase.Leases.LeaseName |
createLeaseName(long hid,
long rid)
Create a lease id out of the holder and resource ids. |
void |
renewLease(long holderId,
long resourceId)
Renew a lease |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log LOG
protected final long leasePeriod
protected final long leaseCheckFrequency
protected final Map<org.apache.hadoop.hbase.Leases.LeaseName,org.apache.hadoop.hbase.Leases.Lease> leases
protected final TreeSet<org.apache.hadoop.hbase.Leases.Lease> sortedLeases
protected boolean running
Constructor Detail |
---|
public Leases(long leasePeriod, long leaseCheckFrequency)
leasePeriod
- - length of time (milliseconds) that the lease is validleaseCheckFrequency
- - how often the lease should be checked
(milliseconds)Method Detail |
---|
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(long holderId, long resourceId, LeaseListener listener)
holderId
- id of lease holderresourceId
- id of resource being leasedlistener
- listener that will process lease expirationspublic void renewLease(long holderId, long resourceId) throws IOException
holderId
- id of lease holderresourceId
- id of resource being leased
IOException
public void cancelLease(long holderId, long resourceId) throws IOException
holderId
- id of lease holderresourceId
- id of resource being leased
IOException
protected org.apache.hadoop.hbase.Leases.LeaseName createLeaseName(long hid, long rid)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |