Exemple #1
0
        public virtual void Test1()
        {
            NeoDatis.Odb.Core.Transaction.ICache cache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
                                                         .GetLocalCache(null, "test");
            string s1 = "ola1";
            string s2 = "ola2";
            string s3 = "ola3";

            cache.StartInsertingObjectWithOid(s1, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                  (1), null);
            cache.StartInsertingObjectWithOid(s2, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                  (2), null);
            cache.StartInsertingObjectWithOid(s3, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                  (3), null);
            AssertTrue(cache.IdOfInsertingObject(s1) != NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s2) != NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s3) != NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
            cache.EndInsertingObject(s3);
            cache.EndInsertingObject(s2);
            cache.EndInsertingObject(s1);
            AssertTrue(cache.IdOfInsertingObject(s1) == NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s2) == NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s3) == NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
        }
Exemple #2
0
        /// <summary>This method is used to make sure that client oids and server oids are equal.
        ///     </summary>
        /// <remarks>
        /// This method is used to make sure that client oids and server oids are equal.
        /// <pre>
        /// When storing an object, the client side does nt know the oid that each object will receive. So the client create
        /// temporary (sequencial) oids. These oids are sent to the server in the object meta-representations. On the server side,
        /// real OIDs are created and associated to the objects and to the client side ids. After calling the store on the server side
        /// The client use the the synchronizeIds method to replace client ids by the right server side ids.
        /// </pre>
        /// </remarks>
        public virtual void SynchronizeIds(NeoDatis.Odb.OID[] clientIds, NeoDatis.Odb.OID
                                           [] serverIds)
        {
            if (clientIds.Length != clientOids.Count)
            {
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ClientServerSynchronizeIds
                                                           .AddParameter(clientOids.Count).AddParameter(clientIds.Length));
            }
            NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = null;
            NeoDatis.Odb.Core.Transaction.ICache cache = GetSession().GetCache();
            object @object = null;

            NeoDatis.Odb.OID id = null;
            NeoDatis.Odb.Core.Transaction.ICrossSessionCache crossSessionCache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
                                                                                 .GetCrossSessionCache(storageEngine.GetBaseIdentification().GetIdentification());
            for (int i = 0; i < clientIds.Length; i++)
            {
                id      = clientIds[i];
                cnnoi   = aois[id];
                @object = objects[id];
                // Server ids may be null when an object or part of an object has been updated.
                // In these case local objects have already the correct ids
                if (serverIds[i] != null)
                {
                    cnnoi.SetOid(serverIds[i]);
                    cache.AddObject(serverIds[i], @object, cnnoi.GetHeader());
                }
                // As serverIds may be null, we need to check it
                if (NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession() && serverIds[i] !=
                    null)
                {
                    crossSessionCache.AddObject(@object, serverIds[i]);
                }
            }
        }
		public Session(string id, string baseIdentification)
		{
			cache = BuildCache();
			tmpCache = BuildTmpCache();
			this.id = id;
			this.baseIdentification = baseIdentification;
		}
 public Session(string id, string baseIdentification)
 {
     cache    = BuildCache();
     tmpCache = BuildTmpCache();
     this.id  = id;
     this.baseIdentification = baseIdentification;
 }
Exemple #5
0
        /// <exception cref="System.IO.IOException"></exception>
        public virtual void Test2()
        {
            NeoDatis.Odb.Core.Transaction.ICache cache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
                                                         .GetLocalCache(null, "temp");
            string s1 = "ola1";
            string s2 = "ola2";
            string s3 = "ola3";

            for (int i = 0; i < 1000 * 3; i += 3)
            {
                cache.StartInsertingObjectWithOid(s1, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                      (i + 1), null);
                cache.StartInsertingObjectWithOid(s2, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                      (i + 2), null);
                cache.StartInsertingObjectWithOid(s3, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                      (i + 3), null);
            }
            AssertEquals(1000, cache.InsertingLevelOf(s1));
            AssertEquals(1000, cache.InsertingLevelOf(s2));
            AssertEquals(1000, cache.InsertingLevelOf(s3));
            for (int i = 0; i < 1000; i++)
            {
                cache.EndInsertingObject(s1);
                cache.EndInsertingObject(s2);
                cache.EndInsertingObject(s3);
            }
            AssertEquals(0, cache.InsertingLevelOf(s1));
            AssertEquals(0, cache.InsertingLevelOf(s2));
            AssertEquals(0, cache.InsertingLevelOf(s3));
            cache.StartInsertingObjectWithOid(s1, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                  (1), null);
            cache.StartInsertingObjectWithOid(s1, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                  (1), null);
            cache.StartInsertingObjectWithOid(s1, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                  (1), null);
            cache.StartInsertingObjectWithOid(s2, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                  (2), null);
            cache.StartInsertingObjectWithOid(s3, NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                  (3), null);
            AssertTrue(cache.IdOfInsertingObject(s1) != NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s2) != NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s3) != NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
            cache.EndInsertingObject(s3);
            cache.EndInsertingObject(s2);
            cache.EndInsertingObject(s1);
            AssertTrue(cache.IdOfInsertingObject(s1) != NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s2) == NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s3) == NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
                       .NullObjectId);
        }
Exemple #6
0
 public virtual void Test3()
 {
     NeoDatis.Odb.Core.Transaction.ICache cache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
                                                  .GetLocalCache(null, "temp");
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                                                             (this.GetType().FullName);
     ci.SetPosition(1);
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih1 = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader
                                                                      ();
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih2 = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader
                                                                      ();
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih3 = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader
                                                                      ();
     oih1.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(1));
     oih2.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(10));
     oih3.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(100));
     NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi1 = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                          (oih1, ci);
     NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi2 = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                          (oih2, ci);
     NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoi3 = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                                          (oih3, ci);
     cache.StartReadingObjectInfoWithOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                             (1), nnoi1);
     cache.StartReadingObjectInfoWithOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                             (10), nnoi2);
     cache.StartReadingObjectInfoWithOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                             (100), nnoi3);
     AssertTrue(cache.IsReadingObjectInfoWithOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                     (1)));
     AssertTrue(cache.IsReadingObjectInfoWithOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                     (10)));
     AssertTrue(cache.IsReadingObjectInfoWithOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                     (100)));
     cache.EndReadingObjectInfo(nnoi1.GetOid());
     cache.EndReadingObjectInfo(nnoi2.GetOid());
     cache.EndReadingObjectInfo(nnoi3.GetOid());
     AssertFalse(cache.IsReadingObjectInfoWithOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                      (1)));
     AssertFalse(cache.IsReadingObjectInfoWithOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                      (10)));
     AssertFalse(cache.IsReadingObjectInfoWithOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID
                                                      (100)));
 }
Exemple #7
0
 public override NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo BuildNnoi
     (object o, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo info, NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo
     [] values, long[] attributesIdentification, int[] attributeIds, System.Collections.Generic.IDictionary
     <object, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo> alreadyReadObjects
     )
 {
     NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = new
                                                                                   NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo(null, info
                                                                                                                                                         , values, attributesIdentification, attributeIds);
     cnnoi.SetLocalOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(alreadyReadObjects
                                                                       .Count + 1));
     NeoDatis.Odb.OID id = cnnoi.GetLocalOid();
     NeoDatis.Odb.Core.Transaction.ICache cache = GetSession().GetCache();
     // Check if object is in the cache, if so sets its id
     NeoDatis.Odb.OID oid = cache.GetOid(o, false);
     if (oid != null)
     {
         cnnoi.SetOid(oid);
     }
     clientOids.Add(id);
     aois.Add(id, cnnoi);
     objects.Add(id, o);
     return(cnnoi);
 }