Пример #1
0
        private IList GetSlots(IFreespaceManager freespaceManager)
        {
            IList retVal = new ArrayList();

            freespaceManager.Traverse(new _IVisitor4_110(retVal));
            return(retVal);
        }
Пример #2
0
 private void InstallFreespaceManager(IFreespaceManager blockedFreespaceManager)
 {
     _freespaceManager = BlockSize() == 1
         ? blockedFreespaceManager
         : new BlockAwareFreespaceManager
                             (blockedFreespaceManager, _blockConverter);
 }
Пример #3
0
        /// <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()));
        }
Пример #4
0
 public virtual void Rollback(IFreespaceManager freespaceManager)
 {
     if (IsFreeOnRollback())
     {
         freespaceManager.Free(_newSlot);
     }
 }
Пример #5
0
 protected virtual void FreePreviouslyModifiedSlot(IFreespaceManager freespaceManager
                                                   )
 {
     if (Slot.IsNull(_newSlot))
     {
         return;
     }
     Free(freespaceManager, _newSlot);
     _newSlot = null;
 }
Пример #6
0
 public virtual void NotifyDeleted(IFreespaceManager freespaceManager)
 {
     if (DTrace.enabled)
     {
         DTrace.NotifySlotDeleted.Log(_key);
     }
     Operation(SlotChange.SlotChangeOperation.delete);
     FreePreviouslyModifiedSlot(freespaceManager);
     _newSlot = Slot.Zero;
 }
Пример #7
0
 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);
        }
Пример #9
0
 public virtual void NotifySlotUpdated(IFreespaceManager freespaceManager, Slot slot
                                       )
 {
     if (DTrace.enabled)
     {
         DTrace.NotifySlotUpdated.LogLength(_key, slot);
     }
     FreePreviouslyModifiedSlot(freespaceManager);
     _newSlot = slot;
     Operation(SlotChange.SlotChangeOperation.update);
 }
Пример #10
0
        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());
        }
Пример #12
0
 protected virtual void Free(IFreespaceManager freespaceManager, Slot slot)
 {
     if (slot.IsNull())
     {
         return;
     }
     if (freespaceManager == null)
     {
         return;
     }
     freespaceManager.Free(slot);
 }
Пример #13
0
 protected override void Free(IFreespaceManager freespaceManager, Slot slot)
 {
     if (slot.IsNull())
     {
         return;
     }
     if (_freed == null)
     {
         _freed = new Collection4();
     }
     _freed.Add(slot);
 }
Пример #14
0
		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());
        }
Пример #16
0
        private void FreeSlot(Slot slot)
        {
            if (Slot.IsNull(slot))
            {
                return;
            }
            IFreespaceManager freespaceManager = _container.FreespaceManager();

            if (freespaceManager == null)
            {
                return;
            }
            freespaceManager.FreeSafeSlot(slot);
        }
Пример #17
0
        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();
            }
        }
Пример #19
0
 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));
        }
Пример #22
0
        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;
 }
Пример #24
0
 public virtual void MigrateTo(IFreespaceManager fm)
 {
 }
Пример #25
0
 public override void MigrateTo(IFreespaceManager fm)
 {
     base.MigrateTo(fm);
     _delegate.MigrateTo(fm);
 }
Пример #26
0
		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);
		}
Пример #27
0
		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);
		}
Пример #28
0
		public virtual void NotifySlotUpdated(IFreespaceManager freespaceManager, Slot slot
			)
		{
			if (DTrace.enabled)
			{
				DTrace.NotifySlotUpdated.LogLength(_key, slot);
			}
			FreePreviouslyModifiedSlot(freespaceManager);
			_newSlot = slot;
			Operation(SlotChange.SlotChangeOperation.update);
		}
		public virtual void MigrateTo(IFreespaceManager fm)
		{
		}
Пример #30
0
			public _IVisitor4_74(IFreespaceManager fm)
			{
				this.fm = fm;
			}
Пример #31
0
		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();
		}
Пример #32
0
		protected virtual void Free(IFreespaceManager freespaceManager, Slot slot)
		{
			if (slot.IsNull())
			{
				return;
			}
			if (freespaceManager == null)
			{
				return;
			}
			freespaceManager.Free(slot);
		}
Пример #33
0
 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)
			{
			}
Пример #36
0
		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());
 }
Пример #38
0
 public virtual void MigrateTo(IFreespaceManager fm)
 {
     Traverse(new _IVisitor4_74(fm));
 }
Пример #39
0
		private void InstallFreespaceManager(IFreespaceManager blockedFreespaceManager)
		{
			_freespaceManager = BlockSize() == 1 ? blockedFreespaceManager : new BlockAwareFreespaceManager
				(blockedFreespaceManager, _blockConverter);
		}
Пример #40
0
 public _IVisitor4_74(IFreespaceManager fm)
 {
     this.fm = fm;
 }
 public virtual void MigrateTo(IFreespaceManager fm)
 {
     throw new InvalidOperationException();
 }
Пример #42
0
 public static void Migrate(IFreespaceManager oldFM, IFreespaceManager newFM)
 {
     oldFM.MigrateTo(newFM);
     oldFM.FreeSelf();
 }
Пример #43
0
		public override void MigrateTo(IFreespaceManager fm)
		{
			base.MigrateTo(fm);
			_delegate.MigrateTo(fm);
		}
Пример #44
0
		public virtual void InstallDebugFreespaceManager(IFreespaceManager manager)
		{
			_freespaceManager = manager;
		}
 public FreespaceCommitter(IFreespaceManager freespaceManager)
 {
     _freespaceManager = freespaceManager == null ? NullFreespaceManager.Instance : freespaceManager;
 }
Пример #46
0
		public static void Migrate(IFreespaceManager oldFM, IFreespaceManager newFM)
		{
			oldFM.MigrateTo(newFM);
			oldFM.FreeSelf();
		}
Пример #47
0
		public virtual void Rollback(IFreespaceManager freespaceManager)
		{
			if (IsFreeOnRollback())
			{
				freespaceManager.Free(_newSlot);
			}
		}
Пример #48
0
 protected virtual void AssertSame(IFreespaceManager fm1, IFreespaceManager fm2)
 {
     Assert.AreEqual(fm1.SlotCount(), fm2.SlotCount());
     Assert.AreEqual(fm1.TotalFreespace(), fm2.TotalFreespace());
 }
Пример #49
0
		protected virtual void FreePreviouslyModifiedSlot(IFreespaceManager freespaceManager
			)
		{
			if (Slot.IsNull(_newSlot))
			{
				return;
			}
			Free(freespaceManager, _newSlot);
			_newSlot = null;
		}
Пример #50
0
		public BlockAwareFreespaceManager(IFreespaceManager delegate_, IBlockConverter blockConverter
			)
		{
			_delegate = delegate_;
			_blockConverter = blockConverter;
		}
Пример #51
0
		public virtual void NotifyDeleted(IFreespaceManager freespaceManager)
		{
			if (DTrace.enabled)
			{
				DTrace.NotifySlotDeleted.Log(_key);
			}
			Operation(SlotChange.SlotChangeOperation.delete);
			FreePreviouslyModifiedSlot(freespaceManager);
			_newSlot = Slot.Zero;
		}
Пример #52
0
		public virtual void MigrateTo(IFreespaceManager fm)
		{
			throw new InvalidOperationException();
		}
Пример #53
0
 // TODO Auto-generated method stub
 public override void MigrateTo(IFreespaceManager fm)
 {
 }
Пример #54
0
		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);
		}