### Question:
LeaseManager { synchronized void removeLeaseWithPrefixPath(String prefix) { for(Map.Entry<String, Lease> entry : findLeaseWithPrefixPath(prefix, sortedLeasesByPath).entrySet()) { if (LOG.isDebugEnabled()) { LOG.debug(LeaseManager.class.getSimpleName() + ".removeLeaseWithPrefixPath: entry=" + entry); } removeLease(entry.getValue(), entry.getKey()); } } LeaseManager(FSNamesystem fsnamesystem); Lease getLeaseByPath(String src); synchronized int countLease(); void setLeasePeriod(long softLimit, long hardLimit); @Override synchronized String toString(); static final Log LOG; }### Answer:
@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")); }