You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-user@hadoop.apache.org by 周杰 <zh...@126.com> on 2011/09/24 07:36:20 UTC

A question about LeaseChecker

Dear:
    Hi,glad to meet you.
    I am a beginner of Hadoop.
Yestory I saw the HDFS-1840 ,which said:
In DFSClient, when there are files opened for write, a LeaseChecker thread is started for updating the leases periodically. However, it never terminates when when all writing files are closed.
But I am a little confused. why it never the leasechecker thread.


I have seen the source of LeaseChecker,and its run():
=================================================
  public void run() {
      while (clientRunning && !Thread.interrupted()) {
      ......
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ie) {
          return;
        }
      }
=================================================


that is to say ,when the clientRunning is false or we call its interrupted() ,the thread will exit the while loop and then terminate the thread.
Next,I have seen the DFSClient's  function close():
=================================================
 public synchronized void close() throws IOException {
    if(clientRunning) {
      leasechecker.close();
     clientRunning = false;
      try {
        leasechecker.interruptAndJoin();
      } catch (InterruptedException ie) {
      }
  
      // close connections to the namenode
      RPC.stopProxy(rpcNamenode);
    }
  }


==================================================


Obviously , if calling the close() ,the variable "clientRunning" will become false and  the leasechecker.interruptAndJoin() will call the daemon's  interrupted() , which means  that  the LeaseChecker will terminate  at last.
Besides ,when all the writing files are closed ,the FileSystem will call the DFSClient's close(),
so my question is why the HDFS-1840 says the LeaseChecker will never teminate ?


Best Regards,
jie