static boolean hasLease(MiniDFSCluster cluster, Path src) { return cluster.getNamesystem().leaseManager.getLeaseByPath(src.toString()) != null; }
FileStatusExtended getFileInfoExtended(String src) throws IOException { Lease lease = leaseManager.getLeaseByPath(src); String leaseHolder = (lease == null) ? "" : lease.getHolder(); return getFileInfoExtended(src, leaseHolder); }
static boolean hasLease(MiniDFSCluster cluster, Path src) { return NameNodeAdapter.getLeaseManager(cluster.getNamesystem() ).getLeaseByPath(src.toString()) != null; }
private void checkForCorruptOpenFiles( FileStatus file, List<FileStatus> corruptFiles ) throws IOException { String filePath = file.getPath().toUri().getPath(); if (file.isDir()) { for (FileStatus fileStatus : nn.namesystem.dir.getListing(filePath)) { checkForCorruptOpenFiles(fileStatus, corruptFiles); } } else { LeaseManager.Lease lease = nn.getNamesystem().leaseManager.getLeaseByPath(filePath); // Condition: // 1. lease has expired hard limit // 2. the file is open for write // 3. the last block has 0 locations if (lease != null && lease.expiredHardLimit()) { LocatedBlocks blocks = nn.getNamesystem().getBlockLocations(filePath, 0, file.getLen()); List<LocatedBlock> locatedBlockList = blocks.getLocatedBlocks(); LocatedBlock lastBlock = locatedBlockList.get(locatedBlockList.size() - 1); if (blocks.isUnderConstruction() && lastBlock.getLocations().length == 0) { corruptFiles.add(file); } } } }
/** * @return the timestamp of the last renewal of the given lease, * or -1 in the case that the lease doesn't exist. */ public static long getLeaseRenewalTime(NameNode nn, String path) { LeaseManager lm = nn.getNamesystem().leaseManager; Lease l = lm.getLeaseByPath(path); if (l == null) { return -1; } return l.getLastUpdate(); }
public static String getLeaseHolderForPath(NameNode namenode, String path) { Lease l = namenode.getNamesystem().leaseManager.getLeaseByPath(path); return l == null? null: l.getHolder(); }
leaseManager.getLeaseByPath(fileINode.getFullPathName()).getHolder())) { String msg = block + "is being recovered by NameNode, ignoring the request from a client";
/** * Retrieves a list of random files with some information. * * @param maxFiles * the maximum number of files to return * @return the list of files */ public List<FileStatusExtended> getRandomFileStats(int maxFiles) { readLock(); try { List<FileStatusExtended> stats = new LinkedList<FileStatusExtended>(); for (INodeFile file : getRandomFiles(maxFiles)) { String path = file.getFullPathName(); FileStatus stat = createFileStatus(path, file); Lease lease = this.getFSNamesystem().leaseManager.getLeaseByPath(path); String holder = (lease == null) ? null : lease.getHolder(); stats.add(new FileStatusExtended(stat, file.getBlocks(), holder)); } return stats; } finally { readUnlock(); } }
@Test public void testRemoveLeaseWithPrefixPath() throws Exception { MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build(); cluster.waitActive(); LeaseManager lm = NameNodeAdapter.getLeaseManager(cluster.getNamesystem()); lm.addLease("holder1", "/a/b"); lm.addLease("holder2", "/a/c"); assertNotNull(lm.getLeaseByPath("/a/b")); assertNotNull(lm.getLeaseByPath("/a/c")); lm.removeLeaseWithPrefixPath("/a"); assertNull(lm.getLeaseByPath("/a/b")); assertNull(lm.getLeaseByPath("/a/c")); lm.addLease("holder1", "/a/b"); lm.addLease("holder2", "/a/c"); lm.removeLeaseWithPrefixPath("/a/"); assertNull(lm.getLeaseByPath("/a/b")); assertNull(lm.getLeaseByPath("/a/c")); }
Lease leaseFile = leaseManager.getLeaseByPath(src); if (leaseFile != null && leaseFile.equals(lease)) { throw new AlreadyBeingCreatedException(
Lease leaseFile = leaseManager.getLeaseByPath(src); if (leaseFile != null && leaseFile.equals(lease)) {
assertEquals(BlockUCState.UNDER_CONSTRUCTION, blks[0].getBlockUCState()); Lease lease = fsn.leaseManager.getLeaseByPath(file2.toString()); Assert.assertNotNull(lease); } finally {
Lease leaseFile = leaseManager.getLeaseByPath(src); if (leaseFile != null && leaseFile.equals(lease)) {
Assert.assertFalse("should not be UC", inode.isUnderConstruction()); Assert.assertNull("should not have a lease", cluster.getNamesystem() .getLeaseManager().getLeaseByPath(file.toString()));
Assert.assertFalse("should not be UC", inode.isUnderConstruction()); Assert.assertNull("should not have a lease", cluster.getNamesystem() .getLeaseManager().getLeaseByPath(file.toString()));
Assert.assertNotNull(inode); Assert.assertFalse("should not be UC", inode.isUnderConstruction()); Assert.assertNull("should not have a lease", cluster.getNamesystem().getLeaseManager().getLeaseByPath(file.toString()));
cluster.getNamesystem().leaseManager.getLeaseByPath(path)); } finally { if (cluster != null) {