Beispiel #1
0
        public virtual void TestNumberOfTransactionsWithGaps()
        {
            NamespaceInfo            nsi  = NewNSInfo();
            BookKeeperJournalManager bkjm = new BookKeeperJournalManager(conf, BKJMUtil.CreateJournalURI
                                                                             ("/hdfsjournal-gaps"), nsi);

            bkjm.Format(nsi);
            long txid = 1;

            for (long i = 0; i < 3; i++)
            {
                long start = txid;
                EditLogOutputStream @out = bkjm.StartLogSegment(start, NameNodeLayoutVersion.CurrentLayoutVersion
                                                                );
                for (long j = 1; j <= DefaultSegmentSize; j++)
                {
                    FSEditLogOp op = FSEditLogTestUtil.GetNoOpInstance();
                    op.SetTransactionId(txid++);
                    @out.Write(op);
                }
                @out.Close();
                bkjm.FinalizeLogSegment(start, txid - 1);
                NUnit.Framework.Assert.IsNotNull(zkc.Exists(bkjm.FinalizedLedgerZNode(start, txid
                                                                                      - 1), false));
            }
            zkc.Delete(bkjm.FinalizedLedgerZNode(DefaultSegmentSize + 1, DefaultSegmentSize *
                                                 2), -1);
            long numTrans = bkjm.GetNumberOfTransactions(1, true);

            NUnit.Framework.Assert.AreEqual(DefaultSegmentSize, numTrans);
            try
            {
                numTrans = bkjm.GetNumberOfTransactions(DefaultSegmentSize + 1, true);
                NUnit.Framework.Assert.Fail("Should have thrown corruption exception by this point"
                                            );
            }
            catch (JournalManager.CorruptionException)
            {
            }
            // if we get here, everything is going good
            numTrans = bkjm.GetNumberOfTransactions((DefaultSegmentSize * 2) + 1, true);
            NUnit.Framework.Assert.AreEqual(DefaultSegmentSize, numTrans);
        }
Beispiel #2
0
        public virtual void TestNumberOfTransactionsWithInprogressAtEnd()
        {
            NamespaceInfo            nsi  = NewNSInfo();
            BookKeeperJournalManager bkjm = new BookKeeperJournalManager(conf, BKJMUtil.CreateJournalURI
                                                                             ("/hdfsjournal-inprogressAtEnd"), nsi);

            bkjm.Format(nsi);
            long txid = 1;

            for (long i = 0; i < 3; i++)
            {
                long start = txid;
                EditLogOutputStream @out = bkjm.StartLogSegment(start, NameNodeLayoutVersion.CurrentLayoutVersion
                                                                );
                for (long j = 1; j <= DefaultSegmentSize; j++)
                {
                    FSEditLogOp op = FSEditLogTestUtil.GetNoOpInstance();
                    op.SetTransactionId(txid++);
                    @out.Write(op);
                }
                @out.Close();
                bkjm.FinalizeLogSegment(start, (txid - 1));
                NUnit.Framework.Assert.IsNotNull(zkc.Exists(bkjm.FinalizedLedgerZNode(start, (txid
                                                                                              - 1)), false));
            }
            long start_1 = txid;
            EditLogOutputStream out_1 = bkjm.StartLogSegment(start_1, NameNodeLayoutVersion.CurrentLayoutVersion
                                                             );

            for (long j_1 = 1; j_1 <= DefaultSegmentSize / 2; j_1++)
            {
                FSEditLogOp op = FSEditLogTestUtil.GetNoOpInstance();
                op.SetTransactionId(txid++);
                out_1.Write(op);
            }
            out_1.SetReadyToFlush();
            out_1.Flush();
            out_1.Abort();
            out_1.Close();
            long numTrans = bkjm.GetNumberOfTransactions(1, true);

            NUnit.Framework.Assert.AreEqual((txid - 1), numTrans);
        }
Beispiel #3
0
        public virtual void TestNumberOfTransactions()
        {
            NamespaceInfo            nsi  = NewNSInfo();
            BookKeeperJournalManager bkjm = new BookKeeperJournalManager(conf, BKJMUtil.CreateJournalURI
                                                                             ("/hdfsjournal-txncount"), nsi);

            bkjm.Format(nsi);
            EditLogOutputStream @out = bkjm.StartLogSegment(1, NameNodeLayoutVersion.CurrentLayoutVersion
                                                            );

            for (long i = 1; i <= 100; i++)
            {
                FSEditLogOp op = FSEditLogTestUtil.GetNoOpInstance();
                op.SetTransactionId(i);
                @out.Write(op);
            }
            @out.Close();
            bkjm.FinalizeLogSegment(1, 100);
            long numTrans = bkjm.GetNumberOfTransactions(1, true);

            NUnit.Framework.Assert.AreEqual(100, numTrans);
        }