예제 #1
0
        /// <returns>
        /// the timestamp of the last renewal of the given lease,
        /// or -1 in the case that the lease doesn't exist.
        /// </returns>
        public static long GetLeaseRenewalTime(NameNode nn, string path)
        {
            LeaseManager lm = nn.GetNamesystem().leaseManager;

            LeaseManager.Lease l = lm.GetLeaseByPath(path);
            if (l == null)
            {
                return(-1);
            }
            return(l.GetLastUpdate());
        }
예제 #2
0
        public virtual void TestRemoveLeaseWithPrefixPath()
        {
            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");
            NUnit.Framework.Assert.IsNotNull(lm.GetLeaseByPath("/a/b"));
            NUnit.Framework.Assert.IsNotNull(lm.GetLeaseByPath("/a/c"));
            lm.RemoveLeaseWithPrefixPath("/a");
            NUnit.Framework.Assert.IsNull(lm.GetLeaseByPath("/a/b"));
            NUnit.Framework.Assert.IsNull(lm.GetLeaseByPath("/a/c"));
            lm.AddLease("holder1", "/a/b");
            lm.AddLease("holder2", "/a/c");
            lm.RemoveLeaseWithPrefixPath("/a/");
            NUnit.Framework.Assert.IsNull(lm.GetLeaseByPath("/a/b"));
            NUnit.Framework.Assert.IsNull(lm.GetLeaseByPath("/a/c"));
        }