Class LeaseRenewer

java.lang.Object
org.apache.hadoop.hdfs.client.impl.LeaseRenewer

@Private public class LeaseRenewer extends Object

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 LeaseRenewer instance is used for renewing lease for all the DFSClient to 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 LeaseRenewer to renew the leases.

  • 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 a LeaseRenewer instance
    • remove

      public static void remove(LeaseRenewer renewer)
      Remove the given renewer from the Factory. Subsequent call will receive new LeaseRenewer instance.
      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

      public boolean put(DFSClient dfsc)
    • closeClient

      public void closeClient(DFSClient dfsc)
      Close the given client.
    • interruptAndJoin

      public void interruptAndJoin() throws InterruptedException
      Throws:
      InterruptedException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setLeaseRenewerGraceDefault

      @VisibleForTesting public static void setLeaseRenewerGraceDefault(long leaseRenewerGraceDefault)