Class LeaseRenewer
java.lang.Object
org.apache.hadoop.hdfs.client.impl.LeaseRenewer
Used by DFSClient for renewing
file-being-written leases on the namenode.
When a file is opened for write (create or append),
namenode stores a file lease for recording the identity of the writer.
The writer (i.e. the DFSClient) is required to renew the lease periodically.
When the lease is not renewed before it expires,
the namenode considers the writer as failed and then it may either let
another writer to obtain the lease or close the file.
This class also provides the following functionality:
-
It maintains a map from (namenode, user) pairs to lease renewers.
The same
LeaseRenewerinstance is used for renewing lease for all theDFSClientto the same namenode and the same user. -
Each renewer maintains a list of
DFSClient. Periodically the leases for all the clients are renewed. A client is removed from the list when the client is closed. -
A thread per namenode per user is used by the
LeaseRenewerto renew the leases.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidcloseClient(DFSClient dfsc) Close the given client.static LeaseRenewergetInstance(String authority, org.apache.hadoop.security.UserGroupInformation ugi, DFSClient dfsc) Get aLeaseRenewerinstancevoidbooleanisEmpty()Does this renewer have nothing to renew?booleanbooleanstatic voidremove(LeaseRenewer renewer) Remove the given renewer from the Factory.static voidsetLeaseRenewerGraceDefault(long leaseRenewerGraceDefault) voidsetRenewalTime(long renewal) Used for testing only.toString()
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Method Details
-
getInstance
public static LeaseRenewer getInstance(String authority, org.apache.hadoop.security.UserGroupInformation ugi, DFSClient dfsc) Get aLeaseRenewerinstance -
remove
Remove the given renewer from the Factory. Subsequent call will receive newLeaseRenewerinstance.- Parameters:
renewer- Instance to be cleared from Factory
-
setRenewalTime
@VisibleForTesting public void setRenewalTime(long renewal) Used for testing only. -
isRunning
@VisibleForTesting public boolean isRunning() -
isEmpty
public boolean isEmpty()Does this renewer have nothing to renew? -
put
-
closeClient
Close the given client. -
interruptAndJoin
- Throws:
InterruptedException
-
toString
-
setLeaseRenewerGraceDefault
@VisibleForTesting public static void setLeaseRenewerGraceDefault(long leaseRenewerGraceDefault)
-