コード例 #1
0
ファイル: TestJournal.cs プロジェクト: orf53975/hadoop.net
		/// <summary>
		/// Test that, if the writer crashes at the very beginning of a segment,
		/// before any transactions are written, that the next newEpoch() call
		/// returns the prior segment txid as its most recent segment.
		/// </summary>
		/// <exception cref="System.Exception"/>
		public virtual void TestNewEpochAtBeginningOfSegment()
		{
			journal.NewEpoch(FakeNsinfo, 1);
			journal.StartLogSegment(MakeRI(1), 1, NameNodeLayoutVersion.CurrentLayoutVersion);
			journal.Journal(MakeRI(2), 1, 1, 2, QJMTestUtil.CreateTxnData(1, 2));
			journal.FinalizeLogSegment(MakeRI(3), 1, 2);
			journal.StartLogSegment(MakeRI(4), 3, NameNodeLayoutVersion.CurrentLayoutVersion);
			QJournalProtocolProtos.NewEpochResponseProto resp = journal.NewEpoch(FakeNsinfo, 
				2);
			NUnit.Framework.Assert.AreEqual(1, resp.GetLastSegmentTxId());
		}
コード例 #2
0
ファイル: TestJournal.cs プロジェクト: orf53975/hadoop.net
		/// <exception cref="System.Exception"/>
		public virtual void TestEpochHandling()
		{
			NUnit.Framework.Assert.AreEqual(0, journal.GetLastPromisedEpoch());
			QJournalProtocolProtos.NewEpochResponseProto newEpoch = journal.NewEpoch(FakeNsinfo
				, 1);
			NUnit.Framework.Assert.IsFalse(newEpoch.HasLastSegmentTxId());
			NUnit.Framework.Assert.AreEqual(1, journal.GetLastPromisedEpoch());
			journal.NewEpoch(FakeNsinfo, 3);
			NUnit.Framework.Assert.IsFalse(newEpoch.HasLastSegmentTxId());
			NUnit.Framework.Assert.AreEqual(3, journal.GetLastPromisedEpoch());
			try
			{
				journal.NewEpoch(FakeNsinfo, 3);
				NUnit.Framework.Assert.Fail("Should have failed to promise same epoch twice");
			}
			catch (IOException ioe)
			{
				GenericTestUtils.AssertExceptionContains("Proposed epoch 3 <= last promise 3", ioe
					);
			}
			try
			{
				journal.StartLogSegment(MakeRI(1), 12345L, NameNodeLayoutVersion.CurrentLayoutVersion
					);
				NUnit.Framework.Assert.Fail("Should have rejected call from prior epoch");
			}
			catch (IOException ioe)
			{
				GenericTestUtils.AssertExceptionContains("epoch 1 is less than the last promised epoch 3"
					, ioe);
			}
			try
			{
				journal.Journal(MakeRI(1), 12345L, 100L, 0, new byte[0]);
				NUnit.Framework.Assert.Fail("Should have rejected call from prior epoch");
			}
			catch (IOException ioe)
			{
				GenericTestUtils.AssertExceptionContains("epoch 1 is less than the last promised epoch 3"
					, ioe);
			}
		}
コード例 #3
0
 /// <exception cref="System.Exception"/>
 public virtual void TestReturnsSegmentInfoAtEpochTransition()
 {
     ch.NewEpoch(1).Get();
     ch.SetEpoch(1);
     ch.StartLogSegment(1, NameNodeLayoutVersion.CurrentLayoutVersion).Get();
     ch.SendEdits(1L, 1, 2, QJMTestUtil.CreateTxnData(1, 2)).Get();
     // Switch to a new epoch without closing earlier segment
     QJournalProtocolProtos.NewEpochResponseProto response = ch.NewEpoch(2).Get();
     ch.SetEpoch(2);
     NUnit.Framework.Assert.AreEqual(1, response.GetLastSegmentTxId());
     ch.FinalizeLogSegment(1, 2).Get();
     // Switch to a new epoch after just closing the earlier segment.
     response = ch.NewEpoch(3).Get();
     ch.SetEpoch(3);
     NUnit.Framework.Assert.AreEqual(1, response.GetLastSegmentTxId());
     // Start a segment but don't write anything, check newEpoch segment info
     ch.StartLogSegment(3, NameNodeLayoutVersion.CurrentLayoutVersion).Get();
     response = ch.NewEpoch(4).Get();
     ch.SetEpoch(4);
     // Because the new segment is empty, it is equivalent to not having
     // started writing it. Hence, we should return the prior segment txid.
     NUnit.Framework.Assert.AreEqual(1, response.GetLastSegmentTxId());
 }