private IList GetSlots(IFreespaceManager freespaceManager) { IList retVal = new ArrayList(); freespaceManager.Traverse(new _IVisitor4_110(retVal)); return(retVal); }
private void InstallFreespaceManager(IFreespaceManager blockedFreespaceManager) { _freespaceManager = BlockSize() == 1 ? blockedFreespaceManager : new BlockAwareFreespaceManager (blockedFreespaceManager, _blockConverter); }
/// <exception cref="System.Exception"></exception> public static void AssertAllSlotsFreed(LocalTransaction trans, BTree bTree, ICodeBlock block) { LocalObjectContainer container = (LocalObjectContainer)trans.Container(); ITransactionalIdSystem idSystem = trans.IdSystem(); IEnumerator allSlotIDs = bTree.AllNodeIds(trans.SystemTransaction()); Collection4 allSlots = new Collection4(); while (allSlotIDs.MoveNext()) { int slotID = ((int)allSlotIDs.Current); Slot slot = idSystem.CurrentSlot(slotID); allSlots.Add(slot); } Slot bTreeSlot = idSystem.CurrentSlot(bTree.GetID()); allSlots.Add(bTreeSlot); Collection4 freedSlots = new Collection4(); IFreespaceManager freespaceManager = container.FreespaceManager(); container.InstallDebugFreespaceManager(new FreespaceManagerForDebug(new _ISlotListener_99 (freedSlots))); block.Run(); container.InstallDebugFreespaceManager(freespaceManager); Assert.IsTrue(freedSlots.ContainsAll(allSlots.GetEnumerator())); }
public virtual void Rollback(IFreespaceManager freespaceManager) { if (IsFreeOnRollback()) { freespaceManager.Free(_newSlot); } }
protected virtual void FreePreviouslyModifiedSlot(IFreespaceManager freespaceManager ) { if (Slot.IsNull(_newSlot)) { return; } Free(freespaceManager, _newSlot); _newSlot = null; }
public virtual void NotifyDeleted(IFreespaceManager freespaceManager) { if (DTrace.enabled) { DTrace.NotifySlotDeleted.Log(_key); } Operation(SlotChange.SlotChangeOperation.delete); FreePreviouslyModifiedSlot(freespaceManager); _newSlot = Slot.Zero; }
protected virtual void Clear(IFreespaceManager freespaceManager) { Slot slot = null; do { slot = freespaceManager.AllocateSlot(1); } while (slot != null); Assert.AreEqual(0, freespaceManager.SlotCount()); Assert.AreEqual(0, freespaceManager.TotalFreespace()); }
private void MigrateFreespace(IFreespaceManager oldFreespaceManager) { IFreespaceManager newFreespaceManager = AbstractFreespaceManager.CreateNew(this, ConfigImpl.FreespaceSystem()); newFreespaceManager.Start(0); SystemData().FreespaceSystem(ConfigImpl.FreespaceSystem()); InstallFreespaceManager(newFreespaceManager); AbstractFreespaceManager.Migrate(oldFreespaceManager, newFreespaceManager); _fileHeader.WriteVariablePart(this); }
public virtual void NotifySlotUpdated(IFreespaceManager freespaceManager, Slot slot ) { if (DTrace.enabled) { DTrace.NotifySlotUpdated.LogLength(_key, slot); } FreePreviouslyModifiedSlot(freespaceManager); _newSlot = slot; Operation(SlotChange.SlotChangeOperation.update); }
protected virtual void GrafittiFreeSpace() { if (!(Db() is IoAdaptedObjectContainer)) { return; } IoAdaptedObjectContainer file = ((IoAdaptedObjectContainer)Db()); IFreespaceManager fm = file.FreespaceManager(); fm.Traverse(new _IVisitor4_60(file)); }
protected virtual void Clear(IFreespaceManager freespaceManager) { Slot slot = null; do { slot = freespaceManager.AllocateSlot(1); }while (slot != null); Assert.AreEqual(0, freespaceManager.SlotCount()); Assert.AreEqual(0, freespaceManager.TotalFreespace()); }
protected virtual void Free(IFreespaceManager freespaceManager, Slot slot) { if (slot.IsNull()) { return; } if (freespaceManager == null) { return; } freespaceManager.Free(slot); }
protected override void Free(IFreespaceManager freespaceManager, Slot slot) { if (slot.IsNull()) { return; } if (_freed == null) { _freed = new Collection4(); } _freed.Add(slot); }
private void AssertMonitoredFreespaceIsCorrect() { IFreespaceManager freespaceManager = FileSession().FreespaceManager(); FreespaceCountingVisitor visitor = new FreespaceCountingVisitor(); freespaceManager.Traverse(visitor); int freespace = visitor.TotalFreespace; int slotCount = visitor.SlotCount; int averageSlotSize = slotCount == 0 ? 0 : freespace / slotCount; Assert.AreEqual(freespace, TotalFreespace()); Assert.AreEqual(slotCount, SlotCount()); Assert.AreEqual(averageSlotSize, AverageSlotSize()); }
private void FreeSlot(Slot slot) { if (Slot.IsNull(slot)) { return; } IFreespaceManager freespaceManager = _container.FreespaceManager(); if (freespaceManager == null) { return; } freespaceManager.FreeSafeSlot(slot); }
public override Slot AllocateSlot(bool appendToFile, int slotChangeCount) { int transactionLogByteCount = TransactionLogSlotLength(slotChangeCount); IFreespaceManager freespaceManager = _container.FreespaceManager(); if (!appendToFile && freespaceManager != null) { Slot slot = freespaceManager.AllocateTransactionLogSlot(transactionLogByteCount); if (slot != null) { return(slot); } } return(_container.AppendBytes(transactionLogByteCount)); }
/// <exception cref="Db4objects.Db4o.Ext.OldFormatException"></exception> internal virtual void ReadThis() { NewSystemData(AbstractFreespaceManager.FmLegacyRam, StandardIdSystemFactory.Legacy ); BlockSizeReadFromFile(1); _fileHeader = FileHeader.Read(this); if (Config().GenerateCommitTimestamps().IsUnspecified()) { Config().GenerateCommitTimestamps(_systemData.IdToTimestampIndexId() != 0); } CreateStringIO(_systemData.StringEncoding()); CreateIdSystem(); InitializeClassMetadataRepository(); InitalizeWeakReferenceSupport(); SetNextTimeStampId(SystemData().LastTimeStampID()); ClassCollection().SetID(_systemData.ClassCollectionID()); ClassCollection().Read(SystemTransaction()); Converter.Convert(new ConversionStage.ClassCollectionAvailableStage(this)); _fileHeader.ReadIdentity(this); if (_config.IsReadOnly()) { return; } if (!ConfigImpl.CommitRecoveryDisabled()) { _fileHeader.CompleteInterruptedTransaction(this); } IFreespaceManager blockedFreespaceManager = AbstractFreespaceManager.CreateNew(this , _systemData.FreespaceSystem()); InstallFreespaceManager(blockedFreespaceManager); blockedFreespaceManager.Read(this, _systemData.InMemoryFreespaceSlot()); blockedFreespaceManager.Start(_systemData.BTreeFreespaceId()); _fileHeader = _fileHeader.Convert(this); if (FreespaceMigrationRequired(blockedFreespaceManager)) { MigrateFreespace(blockedFreespaceManager); } WriteHeader(true, false); if (Converter.Convert(new ConversionStage.SystemUpStage(this))) { _systemData.ConverterVersion(Converter.Version); _fileHeader.WriteVariablePart(this); Transaction.Commit(); } }
private long FreespaceUsage(IFreespaceManager fsm) { if (fsm is InMemoryFreespaceManager) { return(0); } if (fsm is BTreeFreespaceManager) { return(BTreeUsage((BTree)FieldValue(fsm, "_slotsByAddress")) + BTreeUsage((BTree) FieldValue(fsm, "_slotsByLength"))); } if (fsm is BlockAwareFreespaceManager) { return(FreespaceUsage((IFreespaceManager)FieldValue(fsm, "_delegate"))); } throw new InvalidOperationException("Unknown freespace manager: " + fsm); }
public virtual void WriteHeader(bool startFileLockingThread, bool shuttingDown) { if (shuttingDown) { _freespaceManager.Write(this); _freespaceManager = null; } StatefulBuffer writer = CreateStatefulBuffer(SystemTransaction(), 0, _fileHeader. Length()); _fileHeader.WriteFixedPart(this, startFileLockingThread, shuttingDown, writer, BlockSize ()); if (shuttingDown) { EnsureLastSlotWritten(); } SyncFiles(); }
private bool FreespaceMigrationRequired(IFreespaceManager freespaceManager) { if (freespaceManager == null) { return(false); } byte readSystem = _systemData.FreespaceSystem(); byte configuredSystem = ConfigImpl.FreespaceSystem(); if (freespaceManager.SystemType() == configuredSystem) { return(false); } if (configuredSystem != 0) { return(true); } return(AbstractFreespaceManager.MigrationRequired(readSystem)); }
public void Apply(IInternalObjectContainer container) { if (!(container is LocalObjectContainer) || container.ConfigImpl.IsReadOnly()) { return; } LocalObjectContainer localObjectContainer = (LocalObjectContainer)container; IFreespaceManager freespaceManager = localObjectContainer.FreespaceManager(); FreespaceListener freespaceListener = new FreespaceListener(localObjectContainer); freespaceManager.Traverse(new FreespaceInitializingVisitor(freespaceListener)); IEventRegistry eventRegistry = EventRegistryFactory.ForObjectContainer(container); eventRegistry.Closing += delegate { freespaceListener.Dispose(); freespaceManager.Listener(NullFreespaceListener.Instance); }; freespaceManager.Listener(freespaceListener); }
public virtual void InstallDebugFreespaceManager(IFreespaceManager manager) { _freespaceManager = manager; }
public virtual void MigrateTo(IFreespaceManager fm) { }
public override void MigrateTo(IFreespaceManager fm) { base.MigrateTo(fm); _delegate.MigrateTo(fm); }
private bool FreespaceMigrationRequired(IFreespaceManager freespaceManager) { if (freespaceManager == null) { return false; } byte readSystem = _systemData.FreespaceSystem(); byte configuredSystem = ConfigImpl.FreespaceSystem(); if (freespaceManager.SystemType() == configuredSystem) { return false; } if (configuredSystem != 0) { return true; } return AbstractFreespaceManager.MigrationRequired(readSystem); }
public _IVisitor4_74(IFreespaceManager fm) { this.fm = fm; }
public FreespaceCommitter(IFreespaceManager freespaceManager) { _freespaceManager = freespaceManager == null ? NullFreespaceManager.Instance : freespaceManager; }
private IList GetSlots(IFreespaceManager freespaceManager) { IList retVal = new ArrayList(); freespaceManager.Traverse(new _IVisitor4_110(retVal)); return retVal; }
// TODO Auto-generated method stub public override void MigrateTo(IFreespaceManager fm) { }
public virtual void MigrateTo(IFreespaceManager fm) { Traverse(new _IVisitor4_74(fm)); }
protected virtual void AssertSame(IFreespaceManager fm1, IFreespaceManager fm2) { Assert.AreEqual(fm1.SlotCount(), fm2.SlotCount()); Assert.AreEqual(fm1.TotalFreespace(), fm2.TotalFreespace()); }
public virtual void MigrateTo(IFreespaceManager fm) { throw new InvalidOperationException(); }
public static void Migrate(IFreespaceManager oldFM, IFreespaceManager newFM) { oldFM.MigrateTo(newFM); oldFM.FreeSelf(); }
public BlockAwareFreespaceManager(IFreespaceManager delegate_, IBlockConverter blockConverter ) { _delegate = delegate_; _blockConverter = blockConverter; }
private long FreespaceUsage(IFreespaceManager fsm) { if (fsm is InMemoryFreespaceManager) { return 0; } if (fsm is BTreeFreespaceManager) { return BTreeUsage((BTree)FieldValue(fsm, "_slotsByAddress")) + BTreeUsage((BTree) FieldValue(fsm, "_slotsByLength")); } if (fsm is BlockAwareFreespaceManager) { return FreespaceUsage((IFreespaceManager)FieldValue(fsm, "_delegate")); } throw new InvalidOperationException("Unknown freespace manager: " + fsm); }