/** * Tries to start the lease recovery process for the current bucketPath * if the fileSystem is DistributedFileSystem. * Catches and logs the IOException. */ private synchronized void recoverLease() { if (bucketPath != null && fileSystem instanceof DistributedFileSystem) { try { LOG.debug("Starting lease recovery for {}", bucketPath); ((DistributedFileSystem) fileSystem).recoverLease(new Path(bucketPath)); } catch (IOException ex) { LOG.warn("Lease recovery failed for {}", bucketPath, ex); } } }
private static DirLock takeOwnership(FileSystem fs, Path dirLockFile) throws IOException { if (fs instanceof DistributedFileSystem) { if (!((DistributedFileSystem) fs).recoverLease(dirLockFile)) { LOG.warn("Unable to recover lease on dir lock file " + dirLockFile + " right now. Cannot transfer ownership. Will need to try later."); return null; } } // delete and recreate lock file if (fs.delete(dirLockFile, false)) { // returns false if somebody else already deleted it (to take ownership) FSDataOutputStream ostream = HdfsUtils.tryCreateFile(fs, dirLockFile); if (ostream != null) { ostream.close(); } return new DirLock(fs, dirLockFile); } return null; }
try { if (fs instanceof DistributedFileSystem) { if (!((DistributedFileSystem) fs).recoverLease(lockFile)) { LOG.warn( "Unable to recover lease on lock file {} right now. Cannot transfer ownership. Will need to try later. Spout = {}",
/** * Try to recover the lease. * @param dfs * @param nbAttempt * @param p * @param startWaiting * @return True if dfs#recoverLease came by true. * @throws FileNotFoundException */ 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((recovered? "Recovered lease, ": "Failed to recover lease, ") + 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 WAL wasn't found at " + p); } else if (e instanceof FileNotFoundException) { throw (FileNotFoundException)e; } LOG.warn(getLogMessageDetail(nbAttempt, p, startWaiting), e); } return recovered; }
if (dfs.recoverLease(new Path(path))) { LOG.warn("HDFS recoverLease-1 success for: {}", path); } else { if (dfs.recoverLease(new Path(path))) { LOG.warn("HDFS recoverLease-2 success for: {}", path); } else {
DistributedFileSystem dfs = (DistributedFileSystem) fs; LOG.debug("Trying to recover file lease {}", partPath); dfs.recoverLease(partPath); boolean isclosed = dfs.isFileClosed(partPath); StopWatch sw = new StopWatch();
DistributedFileSystem dfs = (DistributedFileSystem) fs; LOG.debug("Trying to recover file lease {}", partPath); dfs.recoverLease(partPath); boolean isclosed = dfs.isFileClosed(partPath); StopWatch sw = new StopWatch();
dfs.recoverLease(path);
/** * Test recover lease eventually succeeding. */ @Test public void testRecoverLease() throws IOException { HTU.getConfiguration().setInt("hbase.lease.recovery.dfs.timeout", 1000); CancelableProgressable reporter = Mockito.mock(CancelableProgressable.class); Mockito.when(reporter.progress()).thenReturn(true); DistributedFileSystem dfs = Mockito.mock(DistributedFileSystem.class); // Fail four times and pass on the fifth. Mockito.when(dfs.recoverLease(FILE)). thenReturn(false).thenReturn(false).thenReturn(false).thenReturn(false).thenReturn(true); assertTrue(this.fsHDFSUtils.recoverDFSFileLease(dfs, FILE, HTU.getConfiguration(), reporter)); Mockito.verify(dfs, Mockito.times(5)).recoverLease(FILE); // Make sure we waited at least hbase.lease.recovery.dfs.timeout * 3 (the first two // invocations will happen pretty fast... the we fall into the longer wait loop). assertTrue((EnvironmentEdgeManager.currentTime() - this.startTime) > (3 * HTU.getConfiguration().getInt("hbase.lease.recovery.dfs.timeout", 61000))); }
DistributedFileSystem dfs = (DistributedFileSystem) ns; try { if (!dfs.recoverLease(source)) { log.info("Waiting for file to be closed {}", source); return conf.getTimeInMillis(Property.MASTER_LEASE_RECOVERY_WAITING_PERIOD);
IOException ioe = null; try { recovered = dfs.recoverLease(new Path(pathStr)); } catch (FileNotFoundException e) { System.err.println("recoverLease got exception: " + e.getMessage());
@Override public Boolean next(final FileSystem fs, final Path p) throws IOException { if (fs instanceof DistributedFileSystem) { DistributedFileSystem myDfs = (DistributedFileSystem)fs; return myDfs.recoverLease(p); } throw new UnsupportedOperationException("Cannot recoverLease through" + " a symlink to a non-DistributedFileSystem: " + f + " -> " + p); } }.resolve(this, absF);
@Override public Boolean next(final FileSystem fs, final Path p) throws IOException { if (fs instanceof DistributedFileSystem) { DistributedFileSystem myDfs = (DistributedFileSystem)fs; return myDfs.recoverLease(p); } throw new UnsupportedOperationException("Cannot recoverLease through" + " a symlink to a non-DistributedFileSystem: " + f + " -> " + p); } }.resolve(this, absF);
@Override public Boolean next(final FileSystem fs, final Path p) throws IOException { if (fs instanceof DistributedFileSystem) { DistributedFileSystem myDfs = (DistributedFileSystem)fs; return myDfs.recoverLease(p); } throw new UnsupportedOperationException("Cannot recoverLease through" + " a symlink to a non-DistributedFileSystem: " + f + " -> " + p); } }.resolve(this, absF);
/** * Tries to start the lease recovery process for the current bucketPath * if the fileSystem is DistributedFileSystem. * Catches and logs the IOException. */ private synchronized void recoverLease() { if (bucketPath != null && fileSystem instanceof DistributedFileSystem) { try { LOG.debug("Starting lease recovery for {}", bucketPath); ((DistributedFileSystem) fileSystem).recoverLease(new Path(bucketPath)); } catch (IOException ex) { LOG.warn("Lease recovery failed for {}", bucketPath, ex); } } }
private void recoverLease(Path filepath, DistributedFileSystem dfs) throws Exception { if (dfs == null) { dfs = (DistributedFileSystem)getFSAsAnotherUser(conf); } while (!dfs.recoverLease(filepath)) { AppendTestUtil.LOG.info("sleep " + 5000 + "ms"); Thread.sleep(5000); } }
private static DirLock takeOwnership(FileSystem fs, Path dirLockFile) throws IOException { if(fs instanceof DistributedFileSystem) { if (!((DistributedFileSystem) fs).recoverLease(dirLockFile)) { LOG.warn("Unable to recover lease on dir lock file " + dirLockFile + " right now. Cannot transfer ownership. Will need to try later."); return null; } } // delete and recreate lock file if( fs.delete(dirLockFile, false) ) { // returns false if somebody else already deleted it (to take ownership) FSDataOutputStream ostream = HdfsUtils.tryCreateFile(fs, dirLockFile); if(ostream!=null) { ostream.close(); } return new DirLock(fs, dirLockFile); } return null; }
@Override public Boolean get() { boolean success; try { success = ((DistributedFileSystem)fsOtherUser) .recoverLease(testPath); } catch (IOException e) { throw new RuntimeException(e); } if (!success) { LOG.info("Waiting to recover lease successfully"); } return success; } }, 1000, 60000);
private void recoverLease(Path filepath, DistributedFileSystem dfs) throws Exception { if (dfs == null) { dfs = (DistributedFileSystem)getFSAsAnotherUser(conf); } while (!dfs.recoverLease(filepath)) { AppendTestUtil.LOG.info("sleep " + 5000 + "ms"); Thread.sleep(5000); } }
@Test(timeout=10000) public void testRecoverLease() throws IOException { Path dir = new Path(testBaseDir1()); Path file = new Path(testBaseDir1(), "file"); Path link = new Path(testBaseDir1(), "link"); wrapper.setWorkingDirectory(dir); createAndWriteFile(file); wrapper.createSymlink(file, link, false); // Attempt recoverLease through a symlink boolean closed = dfs.recoverLease(link); assertTrue("Expected recoverLease to return true", closed); }