コード例 #1
0
        public virtual void TestEditLogFileNotExistsWhenReadingMetadata()
        {
            URI                      uri  = BKJMUtil.CreateJournalURI("/hdfsjournal-editlogfile");
            NamespaceInfo            nsi  = NewNSInfo();
            BookKeeperJournalManager bkjm = new BookKeeperJournalManager(conf, uri, nsi);

            bkjm.Format(nsi);
            try
            {
                // start new inprogress log segment with txid=1
                // and write transactions till txid=50
                string zkpath1 = StartAndFinalizeLogSegment(bkjm, 1, 50);
                // start new inprogress log segment with txid=51
                // and write transactions till txid=100
                string zkpath2 = StartAndFinalizeLogSegment(bkjm, 51, 100);
                // read the metadata from ZK. Here simulating the situation
                // when reading,the edit log metadata can be removed by purger thread.
                ZooKeeper zkspy = Org.Mockito.Mockito.Spy(BKJMUtil.ConnectZooKeeper());
                bkjm.SetZooKeeper(zkspy);
                Org.Mockito.Mockito.DoThrow(new KeeperException.NoNodeException(zkpath2 + " doesn't exists"
                                                                                )).When(zkspy).GetData(zkpath2, false, null);
                IList <EditLogLedgerMetadata> ledgerList = bkjm.GetLedgerList(false);
                NUnit.Framework.Assert.AreEqual("List contains the metadata of non exists path.",
                                                1, ledgerList.Count);
                NUnit.Framework.Assert.AreEqual("LogLedgerMetadata contains wrong zk paths.", zkpath1
                                                , ledgerList[0].GetZkPath());
            }
            finally
            {
                bkjm.Close();
            }
        }