|
||||||||||
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 int |
leaseCheckFrequency
|
protected int |
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 TreeSet<org.apache.hadoop.hbase.Leases.Lease> |
sortedLeases
|
protected AtomicBoolean |
stop
|
Constructor Summary | |
---|---|
Leases(int leasePeriod,
int 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 |
void |
setName(String name)
|
void |
start()
Starts the lease monitor |
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 int leasePeriod
protected final int 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 AtomicBoolean stop
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 start()
public void setName(String name)
name
- Set name on the lease checking daemon thread.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)
holderId
- id of lease holderresourceId
- id of resource being leasedprotected 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 |