static boolean hasLease(MiniDFSCluster cluster, Path src) { return NameNodeAdapter.getLeaseManager(cluster.getNamesystem() ).getLeaseByPath(src.toString()) != null; }
/** Set the softLimit and hardLimit of client lease periods. */ public static void setLeasePeriod(final FSNamesystem namesystem, long soft, long hard) { getLeaseManager(namesystem).setLeasePeriod(soft, hard); namesystem.leaseManager.triggerMonitorCheckNow(); }
static int countLease(MiniDFSCluster cluster) { return NameNodeAdapter.getLeaseManager(cluster.getNamesystem()).countLease(); }
static int leaseCount(MiniDFSCluster cluster) { return NameNodeAdapter.getLeaseManager(cluster.getNamesystem()).countLease(); }
NameNodeAdapter.getLeaseManager(cluster.getNamesystem()) .setLeasePeriod(LOW_SOFTLIMIT, LOW_HARDLIMIT); NameNodeAdapter.getLeaseManager(cluster.getNamesystem()) .setLeasePeriod(HdfsConstants.LEASE_SOFTLIMIT_PERIOD, HdfsConstants.LEASE_HARDLIMIT_PERIOD);
waitLeaseRecovery(cluster); LeaseManager lm = NameNodeAdapter.getLeaseManager(cluster.getNamesystem()); assertTrue("Found " + lm.countLease() + " lease, expected 1", lm.countLease() == 1); cluster.getNameNodeRpc().setSafeMode(
@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")); }