private void WriteThis(Slot reservedSlot) { // We need a little dance here to keep filling free slots // with X bytes. The FreespaceManager would do it immediately // upon the free call, but then our CrashSimulatingTestCase // fails because we have the Xses in the file before flushing. Slot xByteSlot = null; int slotLength = SlotLength(); if (reservedSlot.Length() >= slotLength) { _slot = reservedSlot; reservedSlot = null; } else { _slot = AllocateSlot(true, slotLength); } ByteArrayBuffer buffer = new ByteArrayBuffer(_slot.Length()); buffer.WriteInt(_childId); _idGenerator.Write(buffer); TreeInt.Write(buffer, _ids); _container.WriteBytes(buffer, _slot.Address(), 0); _container.SystemData().IdSystemSlot(_slot); IRunnable commitHook = _container.CommitHook(); _container.SyncFiles(commitHook); FreeSlot(reservedSlot); }
public override void Write(LocalObjectContainer container) { Slot slot = container.AllocateSlot(MarshalledLength()); while (slot.Length() < MarshalledLength()) { // This can happen if DatabaseGrowthSize is configured. // Allocating a slot may produce an additional entry // in this FreespaceManager. container.Free(slot); slot = container.AllocateSlot(MarshalledLength()); } ByteArrayBuffer buffer = new ByteArrayBuffer(slot.Length()); TreeInt.Write(buffer, (TreeInt)_freeBySize); container.WriteEncrypt(buffer, slot.Address(), 0); container.SystemData().InMemoryFreespaceSlot(slot); }