code: public static DirLock takeOwnershipIfStale(FileSystem fs, Path dirToLock, int lockTimeoutSec) {
      Path dirLockFile = getDirLockFile(dirToLock);
  
      long now =  System.currentTimeMillis();
      long expiryTime = now - (lockTimeoutSec*1000);
  
      try {
        long modTime = fs.getFileStatus(dirLockFile).getModificationTime();
        if(modTime <= expiryTime) {
          return takeOwnership(fs, dirLockFile);
        }
        return null;
      } catch (IOException e)  {
        return  null;
      }
    }
docs: if the lock on the directory is stale, take ownership