Search in sources :

Example 6 with LeaseExpiredException

use of org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException in project lucene-solr by apache.

the class FSHDFSUtils method recoverLease.

/**
   * Try to recover the lease.
   * @return True if dfs#recoverLease came by true.
   */
static boolean recoverLease(final DistributedFileSystem dfs, final int nbAttempt, final Path p, final long startWaiting) throws FileNotFoundException {
    boolean recovered = false;
    try {
        recovered = dfs.recoverLease(p);
        log.info("recoverLease=" + recovered + ", " + getLogMessageDetail(nbAttempt, p, startWaiting));
    } catch (IOException e) {
        if (e instanceof LeaseExpiredException && e.getMessage().contains("File does not exist")) {
            // This exception comes out instead of FNFE, fix it
            throw new FileNotFoundException("The given transactionlog file wasn't found at " + p);
        } else if (e instanceof FileNotFoundException) {
            throw (FileNotFoundException) e;
        }
        log.warn(getLogMessageDetail(nbAttempt, p, startWaiting), e);
    }
    return recovered;
}
Also used : LeaseExpiredException(org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) InterruptedIOException(java.io.InterruptedIOException)

Aggregations

LeaseExpiredException (org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException)6 FileSystem (org.apache.hadoop.fs.FileSystem)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 Path (org.apache.hadoop.fs.Path)3 NamenodeProtocols (org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols)3 FileNotFoundException (java.io.FileNotFoundException)2 InterruptedIOException (java.io.InterruptedIOException)2 OutputStream (java.io.OutputStream)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)2 GenericTestUtils (org.apache.hadoop.test.GenericTestUtils)2 Configuration (org.apache.hadoop.conf.Configuration)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 ExtendedBlock (org.apache.hadoop.hdfs.protocol.ExtendedBlock)1