/// <exception cref="System.IO.IOException"/> private void TestAppend(string bpid, FsDatasetImpl dataSet, ExtendedBlock[] blocks ) { long newGS = blocks[Finalized].GetGenerationStamp() + 1; FsVolumeImpl v = (FsVolumeImpl)dataSet.volumeMap.Get(bpid, blocks[Finalized].GetLocalBlock ()).GetVolume(); long available = v.GetCapacity() - v.GetDfsUsed(); long expectedLen = blocks[Finalized].GetNumBytes(); try { v.DecDfsUsed(bpid, -available); blocks[Finalized].SetNumBytes(expectedLen + 100); dataSet.Append(blocks[Finalized], newGS, expectedLen); NUnit.Framework.Assert.Fail("Should not have space to append to an RWR replica" + blocks[Rwr]); } catch (DiskChecker.DiskOutOfSpaceException e) { NUnit.Framework.Assert.IsTrue(e.Message.StartsWith("Insufficient space for appending to " )); } v.DecDfsUsed(bpid, available); blocks[Finalized].SetNumBytes(expectedLen); newGS = blocks[Rbw].GetGenerationStamp() + 1; dataSet.Append(blocks[Finalized], newGS, blocks[Finalized].GetNumBytes()); // successful blocks[Finalized].SetGenerationStamp(newGS); try { dataSet.Append(blocks[Temporary], blocks[Temporary].GetGenerationStamp() + 1, blocks [Temporary].GetNumBytes()); NUnit.Framework.Assert.Fail("Should not have appended to a temporary replica " + blocks[Temporary]); } catch (ReplicaNotFoundException e) { NUnit.Framework.Assert.AreEqual(ReplicaNotFoundException.UnfinalizedReplica + blocks [Temporary], e.Message); } try { dataSet.Append(blocks[Rbw], blocks[Rbw].GetGenerationStamp() + 1, blocks[Rbw].GetNumBytes ()); NUnit.Framework.Assert.Fail("Should not have appended to an RBW replica" + blocks [Rbw]); } catch (ReplicaNotFoundException e) { NUnit.Framework.Assert.AreEqual(ReplicaNotFoundException.UnfinalizedReplica + blocks [Rbw], e.Message); } try { dataSet.Append(blocks[Rwr], blocks[Rwr].GetGenerationStamp() + 1, blocks[Rbw].GetNumBytes ()); NUnit.Framework.Assert.Fail("Should not have appended to an RWR replica" + blocks [Rwr]); } catch (ReplicaNotFoundException e) { NUnit.Framework.Assert.AreEqual(ReplicaNotFoundException.UnfinalizedReplica + blocks [Rwr], e.Message); } try { dataSet.Append(blocks[Rur], blocks[Rur].GetGenerationStamp() + 1, blocks[Rur].GetNumBytes ()); NUnit.Framework.Assert.Fail("Should not have appended to an RUR replica" + blocks [Rur]); } catch (ReplicaNotFoundException e) { NUnit.Framework.Assert.AreEqual(ReplicaNotFoundException.UnfinalizedReplica + blocks [Rur], e.Message); } try { dataSet.Append(blocks[NonExistent], blocks[NonExistent].GetGenerationStamp(), blocks [NonExistent].GetNumBytes()); NUnit.Framework.Assert.Fail("Should not have appended to a non-existent replica " + blocks[NonExistent]); } catch (ReplicaNotFoundException e) { NUnit.Framework.Assert.AreEqual(ReplicaNotFoundException.NonExistentReplica + blocks [NonExistent], e.Message); } newGS = blocks[Finalized].GetGenerationStamp() + 1; dataSet.RecoverAppend(blocks[Finalized], newGS, blocks[Finalized].GetNumBytes()); // successful blocks[Finalized].SetGenerationStamp(newGS); try { dataSet.RecoverAppend(blocks[Temporary], blocks[Temporary].GetGenerationStamp() + 1, blocks[Temporary].GetNumBytes()); NUnit.Framework.Assert.Fail("Should not have appended to a temporary replica " + blocks[Temporary]); } catch (ReplicaNotFoundException e) { NUnit.Framework.Assert.IsTrue(e.Message.StartsWith(ReplicaNotFoundException.UnfinalizedAndNonrbwReplica )); } newGS = blocks[Rbw].GetGenerationStamp() + 1; dataSet.RecoverAppend(blocks[Rbw], newGS, blocks[Rbw].GetNumBytes()); blocks[Rbw].SetGenerationStamp(newGS); try { dataSet.RecoverAppend(blocks[Rwr], blocks[Rwr].GetGenerationStamp() + 1, blocks[Rbw ].GetNumBytes()); NUnit.Framework.Assert.Fail("Should not have appended to an RWR replica" + blocks [Rwr]); } catch (ReplicaNotFoundException e) { NUnit.Framework.Assert.IsTrue(e.Message.StartsWith(ReplicaNotFoundException.UnfinalizedAndNonrbwReplica )); } try { dataSet.RecoverAppend(blocks[Rur], blocks[Rur].GetGenerationStamp() + 1, blocks[Rur ].GetNumBytes()); NUnit.Framework.Assert.Fail("Should not have appended to an RUR replica" + blocks [Rur]); } catch (ReplicaNotFoundException e) { NUnit.Framework.Assert.IsTrue(e.Message.StartsWith(ReplicaNotFoundException.UnfinalizedAndNonrbwReplica )); } try { dataSet.RecoverAppend(blocks[NonExistent], blocks[NonExistent].GetGenerationStamp (), blocks[NonExistent].GetNumBytes()); NUnit.Framework.Assert.Fail("Should not have appended to a non-existent replica " + blocks[NonExistent]); } catch (ReplicaNotFoundException e) { NUnit.Framework.Assert.IsTrue(e.Message.StartsWith(ReplicaNotFoundException.NonExistentReplica )); } }