예제 #1
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());
        }
예제 #2
0
        public virtual void TestReset()
        {
            Configuration conf      = new Configuration();
            FSEditLog     fsEditLog = Org.Mockito.Mockito.Mock <FSEditLog>();
            FSImage       fsImage   = Org.Mockito.Mockito.Mock <FSImage>();

            Org.Mockito.Mockito.When(fsImage.GetEditLog()).ThenReturn(fsEditLog);
            FSNamesystem fsn = new FSNamesystem(conf, fsImage);

            fsn.ImageLoadComplete();
            NUnit.Framework.Assert.IsTrue(fsn.IsImageLoaded());
            fsn.Clear();
            NUnit.Framework.Assert.IsFalse(fsn.IsImageLoaded());
            INodeDirectory root = (INodeDirectory)fsn.GetFSDirectory().GetINode("/");

            NUnit.Framework.Assert.IsTrue(root.GetChildrenList(Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
                                                               .CurrentStateId).IsEmpty());
            fsn.ImageLoadComplete();
            NUnit.Framework.Assert.IsTrue(fsn.IsImageLoaded());
        }