Esempio n. 1
0
            public virtual void TestNewIdOverflow()
            {
                if (!((IdSystemTestSuite.IIdSystemProvider)_fixture.Value).SupportsIdOverflow())
                {
                    return;
                }
                LocalObjectContainer container = (LocalObjectContainer)Container();
                IIdSystem            idSystem  = ((IdSystemTestSuite.IIdSystemProvider)_fixture.Value).NewInstance
                                                     (container);
                IList allFreeIds = AllocateAllAvailableIds(idSystem);

                AssertNoMoreIdAvailable(idSystem);
                IList subSetOfIds = new ArrayList();
                int   counter     = 0;

                for (IEnumerator currentIdIter = allFreeIds.GetEnumerator(); currentIdIter.MoveNext
                         ();)
                {
                    int currentId = ((int)currentIdIter.Current);
                    counter++;
                    if (counter % 3 == 0)
                    {
                        subSetOfIds.Add(currentId);
                    }
                }
                AssertFreeAndReallocate(idSystem, subSetOfIds);
                AssertFreeAndReallocate(idSystem, allFreeIds);
            }
        private long IdSystemUsage()
        {
            IIdSystem idSystem = _db.IdSystem();
            long      usage    = 0;

            while (idSystem is BTreeIdSystem)
            {
                IIdSystem parentIdSystem = ((IIdSystem)FieldValue(idSystem, "_parentIdSystem"));
                usage += BTreeUsage(_db.SystemTransaction(), parentIdSystem, (BTree)FieldValue(idSystem
                                                                                               , "_bTree"), _slots);
                PersistentIntegerArray persistentState = (PersistentIntegerArray)FieldValue(idSystem
                                                                                            , "_persistentState");
                int persistentStateId = persistentState.GetID();
                Db4objects.Db4o.Internal.Slots.Slot persistentStateSlot = parentIdSystem.CommittedSlot
                                                                              (persistentStateId);
                _slots.Add(persistentStateSlot);
                usage   += persistentStateSlot.Length();
                idSystem = parentIdSystem;
            }
            if (idSystem is InMemoryIdSystem)
            {
                Db4objects.Db4o.Internal.Slots.Slot idSystemSlot = ((Db4objects.Db4o.Internal.Slots.Slot
                                                                     )FieldValue(idSystem, "_slot"));
                usage += idSystemSlot.Length();
                _slots.Add(idSystemSlot);
            }
            return(usage);
        }
Esempio n. 3
0
        private void MapIdSystem()
        {
            IIdSystem idSystem = _db.IdSystem();

            if (idSystem is BTreeIdSystem)
            {
                ((BTreeIdSystem)idSystem).TraverseIds(new _IVisitor4_220(this));
            }
        }
Esempio n. 4
0
 internal void FreePrefetchedIDs(IIdSystem idSystem)
 {
     if (_prefetchedIDs == null)
     {
         return;
     }
     idSystem.ReturnUnusedIds(_prefetchedIDs);
     _prefetchedIDs = null;
 }
Esempio n. 5
0
        private void MapIdSystem()
        {
            IIdSystem idSystem = _db.IdSystem();

            if (!(idSystem is BTreeIdSystem))
            {
                Sharpen.Runtime.Err.WriteLine("No btree id system found - not mapping ids.");
                return;
            }
            ((BTreeIdSystem)idSystem).TraverseIds(new _IVisitor4_127(this));
            idSystem.TraverseOwnSlots(new _IProcedure4_138(this));
        }
Esempio n. 6
0
            private IList AllocateAllAvailableIds(IIdSystem idSystem)
            {
                IList ids   = new ArrayList();
                int   newId = 0;

                do
                {
                    newId = idSystem.NewId();
                    ids.Add(newId);
                }while (newId < MaxValidId);
                return(ids);
            }
Esempio n. 7
0
        private static long BTreeUsage(Transaction transaction, IIdSystem idSystem, BTree
                                       btree, ISlotMap slotMap)
        {
            IEnumerator nodeIter = btree.AllNodeIds(transaction);

            Db4objects.Db4o.Internal.Slots.Slot btreeSlot = idSystem.CommittedSlot(btree.GetID
                                                                                       ());
            slotMap.Add(btreeSlot);
            long usage = btreeSlot.Length();

            while (nodeIter.MoveNext())
            {
                int curNodeId = ((int)nodeIter.Current);
                Db4objects.Db4o.Internal.Slots.Slot slot = idSystem.CommittedSlot(curNodeId);
                slotMap.Add(slot);
                usage += slot.Length();
            }
            return(usage);
        }
Esempio n. 8
0
        private static long BTreeUsage(Transaction transaction, IIdSystem idSystem, BTree
                                       btree, ISlotMap slotMap)
        {
            var nodeIter  = btree.AllNodeIds(transaction);
            var btreeSlot = idSystem.CommittedSlot(btree.GetID
                                                       ());

            slotMap.Add(btreeSlot);
            long usage = btreeSlot.Length();

            while (nodeIter.MoveNext())
            {
                var curNodeId = ((int)nodeIter.Current);
                var slot      = idSystem.CommittedSlot(curNodeId);
                slotMap.Add(slot);
                usage += slot.Length();
            }
            return(usage);
        }
Esempio n. 9
0
            private void AssertFreeAndReallocate(IIdSystem idSystem, IList ids)
            {
                // Boundary condition: Last ID. Produced a bug when implementing.
                if (!ids.Contains(MaxValidId))
                {
                    ids.Add(MaxValidId);
                }
                Assert.IsGreater(0, ids.Count);
                idSystem.ReturnUnusedIds(new _IVisitable_184(ids));
                int freedCount = ids.Count;

                for (int i = 0; i < freedCount; i++)
                {
                    int newId = idSystem.NewId();
                    Assert.IsTrue(ids.Contains(newId));
                    ids.Remove((object)newId);
                }
                Assert.IsTrue(ids.Count == 0);
                AssertNoMoreIdAvailable(idSystem);
            }
Esempio n. 10
0
        private IList CheckClassIndices()
        {
            IList     invalidIds = new ArrayList();
            IIdSystem idSystem   = _db.IdSystem();

            if (!(idSystem is BTreeIdSystem))
            {
                return(invalidIds);
            }
            ClassMetadataIterator clazzIter = _db.ClassCollection().Iterator();

            while (clazzIter.MoveNext())
            {
                ClassMetadata clazz = clazzIter.CurrentClass();
                if (!clazz.HasClassIndex())
                {
                    continue;
                }
                BTreeClassIndexStrategy index = (BTreeClassIndexStrategy)clazz.Index();
                index.TraverseAll(_db.SystemTransaction(), new _IVisitor4_143(this, invalidIds, clazz
                                                                              ));
            }
            return(invalidIds);
        }
Esempio n. 11
0
			private IList AllocateAllAvailableIds(IIdSystem idSystem)
			{
				IList ids = new ArrayList();
				int newId = 0;
				do
				{
					newId = idSystem.NewId();
					ids.Add(newId);
				}
				while (newId < MaxValidId);
				return ids;
			}
Esempio n. 12
0
			private void AssertFreeAndReallocate(IIdSystem idSystem, IList ids)
			{
				// Boundary condition: Last ID. Produced a bug when implementing. 
				if (!ids.Contains(MaxValidId))
				{
					ids.Add(MaxValidId);
				}
				Assert.IsGreater(0, ids.Count);
				idSystem.ReturnUnusedIds(new _IVisitable_184(ids));
				int freedCount = ids.Count;
				for (int i = 0; i < freedCount; i++)
				{
					int newId = idSystem.NewId();
					Assert.IsTrue(ids.Contains(newId));
					ids.Remove((object)newId);
				}
				Assert.IsTrue(ids.Count == 0);
				AssertNoMoreIdAvailable(idSystem);
			}
Esempio n. 13
0
		protected virtual void CreateIdSystem()
		{
			_idSystem = StandardIdSystemFactory.NewInstance(this);
		}
Esempio n. 14
0
 public DelegatingIdSystem(LocalObjectContainer container)
 {
     _delegate = new InMemoryIdSystem(container);
 }
 protected virtual void CreateIdSystem()
 {
     _idSystem = StandardIdSystemFactory.NewInstance(this);
 }
Esempio n. 16
0
		public DelegatingIdSystem(LocalObjectContainer container)
		{
			_delegate = new InMemoryIdSystem(container);
		}
Esempio n. 17
0
 public _ICodeBlock_219(IIdSystem idSystem)
 {
     this.idSystem = idSystem;
 }
Esempio n. 18
0
 private void AssertNoMoreIdAvailable(IIdSystem idSystem)
 {
     Assert.Expect(typeof(Db4oFatalException), new _ICodeBlock_219(idSystem));
 }
Esempio n. 19
0
		private static long BTreeUsage(Transaction transaction, IIdSystem idSystem, BTree
			 btree, ISlotMap slotMap)
		{
			IEnumerator nodeIter = btree.AllNodeIds(transaction);
			Db4objects.Db4o.Internal.Slots.Slot btreeSlot = idSystem.CommittedSlot(btree.GetID
				());
			slotMap.Add(btreeSlot);
			long usage = btreeSlot.Length();
			while (nodeIter.MoveNext())
			{
				int curNodeId = ((int)nodeIter.Current);
				Db4objects.Db4o.Internal.Slots.Slot slot = idSystem.CommittedSlot(curNodeId);
				slotMap.Add(slot);
				usage += slot.Length();
			}
			return usage;
		}
Esempio n. 20
0
			private void AssertNoMoreIdAvailable(IIdSystem idSystem)
			{
				Assert.Expect(typeof(Db4oFatalException), new _ICodeBlock_219(idSystem));
			}
Esempio n. 21
0
		internal void FreePrefetchedIDs(IIdSystem idSystem)
		{
			if (_prefetchedIDs == null)
			{
				return;
			}
			idSystem.ReturnUnusedIds(_prefetchedIDs);
			_prefetchedIDs = null;
		}
Esempio n. 22
0
				public _ICodeBlock_219(IIdSystem idSystem)
				{
					this.idSystem = idSystem;
				}
Esempio n. 23
0
 private static long BTreeUsage(Transaction transaction, IIdSystem idSystem, BTree
     btree, ISlotMap slotMap)
 {
     var nodeIter = btree.AllNodeIds(transaction);
     var btreeSlot = idSystem.CommittedSlot(btree.GetID
         ());
     slotMap.Add(btreeSlot);
     long usage = btreeSlot.Length();
     while (nodeIter.MoveNext())
     {
         var curNodeId = ((int) nodeIter.Current);
         var slot = idSystem.CommittedSlot(curNodeId);
         slotMap.Add(slot);
         usage += slot.Length();
     }
     return usage;
 }