コード例 #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 TestFSNamespaceClearLeases()
        {
            Configuration conf    = new HdfsConfiguration();
            FilePath      nameDir = new FilePath(MiniDFSCluster.GetBaseDirectory(), "name");

            conf.Set(DFSConfigKeys.DfsNamenodeNameDirKey, nameDir.GetAbsolutePath());
            NameNode.InitMetrics(conf, HdfsServerConstants.NamenodeRole.Namenode);
            DFSTestUtil.FormatNameNode(conf);
            FSNamesystem fsn      = FSNamesystem.LoadFromDisk(conf);
            LeaseManager leaseMan = fsn.GetLeaseManager();

            leaseMan.AddLease("client1", "importantFile");
            NUnit.Framework.Assert.AreEqual(1, leaseMan.CountLease());
            fsn.Clear();
            leaseMan = fsn.GetLeaseManager();
            NUnit.Framework.Assert.AreEqual(0, leaseMan.CountLease());
        }
コード例 #3
0
        /// <summary>
        /// Check that even if LeaseManager.checkLease is not able to relinquish
        /// leases, the Namenode does't enter an infinite loop while holding the FSN
        /// write lock and thus become unresponsive
        /// </summary>
        public virtual void TestCheckLeaseNotInfiniteLoop()
        {
            FSDirectory  dir = Org.Mockito.Mockito.Mock <FSDirectory>();
            FSNamesystem fsn = Org.Mockito.Mockito.Mock <FSNamesystem>();

            Org.Mockito.Mockito.When(fsn.IsRunning()).ThenReturn(true);
            Org.Mockito.Mockito.When(fsn.HasWriteLock()).ThenReturn(true);
            Org.Mockito.Mockito.When(fsn.GetFSDirectory()).ThenReturn(dir);
            LeaseManager lm = new LeaseManager(fsn);

            //Make sure the leases we are going to add exceed the hard limit
            lm.SetLeasePeriod(0, 0);
            //Add some leases to the LeaseManager
            lm.AddLease("holder1", "src1");
            lm.AddLease("holder2", "src2");
            lm.AddLease("holder3", "src3");
            NUnit.Framework.Assert.AreEqual(lm.GetNumSortedLeases(), 3);
            //Initiate a call to checkLease. This should exit within the test timeout
            lm.CheckLeases();
        }
コード例 #4
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"));
        }
コード例 #5
0
 internal Monitor(LeaseManager _enclosing)
 {
     this._enclosing = _enclosing;
 }
コード例 #6
0
 /// <summary>Only LeaseManager object can create a lease</summary>
 private Lease(LeaseManager _enclosing, string holder)
 {
     this._enclosing = _enclosing;
     this.holder     = holder;
     this.Renew();
 }