public unsafe void MallocFixedPageSizeRecoveryTest() { int seed = 123; var rand1 = new Random(seed); var device = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\MallocFixedPageSizeRecoveryTest.dat", deleteOnClose: true); var allocator = new MallocFixedPageSize <HashBucket>(); allocator.Acquire(); //do something int numBucketsToAdd = 16 * allocator.GetPageSize(); long[] logicalAddresses = new long[numBucketsToAdd]; for (int i = 0; i < numBucketsToAdd; i++) { long logicalAddress = allocator.Allocate(); logicalAddresses[i] = logicalAddress; var bucket = (HashBucket *)allocator.GetPhysicalAddress(logicalAddress); for (int j = 0; j < Constants.kOverflowBucketIndex; j++) { bucket->bucket_entries[j] = rand1.Next(); } } //issue call to checkpoint allocator.BeginCheckpoint(device, 0, out ulong numBytesWritten); //wait until complete allocator.IsCheckpointCompleted(true); allocator.Release(); allocator.Dispose(); var recoveredAllocator = new MallocFixedPageSize <HashBucket>(); recoveredAllocator.Acquire(); //issue call to recover recoveredAllocator.BeginRecovery(device, 0, numBucketsToAdd, numBytesWritten, out ulong numBytesRead); //wait until complete recoveredAllocator.IsRecoveryCompleted(true); Assert.IsTrue(numBytesWritten == numBytesRead); var rand2 = new Random(seed); for (int i = 0; i < numBucketsToAdd; i++) { var logicalAddress = logicalAddresses[i]; var bucket = (HashBucket *)recoveredAllocator.GetPhysicalAddress(logicalAddress); for (int j = 0; j < Constants.kOverflowBucketIndex; j++) { Assert.IsTrue(bucket->bucket_entries[j] == rand2.Next()); } } recoveredAllocator.Release(); recoveredAllocator.Dispose(); }
public void MallocFixedPageSizeRecoveryTest() { Setup_MallocFixedPageSizeRecoveryTest(out int seed, out IDevice device, out int numBucketsToAdd, out long[] logicalAddresses, out ulong numBytesWritten); var recoveredAllocator = new MallocFixedPageSize <HashBucket>(); //issue call to recover recoveredAllocator.BeginRecovery(device, 0, numBucketsToAdd, numBytesWritten, out ulong numBytesRead); //wait until complete recoveredAllocator.IsRecoveryCompleted(true); Finish_MallocFixedPageSizeRecoveryTest(seed, device, numBucketsToAdd, logicalAddresses, numBytesWritten, recoveredAllocator, numBytesRead); }
public unsafe void MallocFixedPageSizeRecoveryTest() { int seed = 123; var rand1 = new Random(seed); IDevice device = new LocalStorageDevice("test_ofb.dat", false, false, true, true); var allocator = new MallocFixedPageSize <HashBucket>(); //do something int numBucketsToAdd = 16 * MallocFixedPageSize <HashBucket> .PageSize; long[] logicalAddresses = new long[numBucketsToAdd]; for (int i = 0; i < numBucketsToAdd; i++) { long logicalAddress = allocator.Allocate(); logicalAddresses[i] = logicalAddress; var bucket = (HashBucket *)allocator.GetPhysicalAddress(logicalAddress); for (int j = 0; j < Constants.kOverflowBucketIndex; j++) { bucket->bucket_entries[j] = rand1.Next(); } } //issue call to checkpoint allocator.begin_checkpoint(device, 0, out ulong numBytesWritten); //wait until complete allocator.IsCheckpointCompleted(true); var recoveredAllocator = new MallocFixedPageSize <HashBucket>(); //issue call to recover recoveredAllocator.begin_recovery(device, 0, numBucketsToAdd, numBytesWritten, out ulong numBytesRead); //wait until complete recoveredAllocator.IsRecoveryCompleted(true); Assert.IsTrue(numBytesWritten == numBytesRead); var rand2 = new Random(seed); for (int i = 0; i < numBucketsToAdd; i++) { var logicalAddress = logicalAddresses[i]; var bucket = (HashBucket *)recoveredAllocator.GetPhysicalAddress(logicalAddress); for (int j = 0; j < Constants.kOverflowBucketIndex; j++) { Assert.IsTrue(bucket->bucket_entries[j] == rand2.Next()); } } }