Exemplo n.º 1
0
 /// <summary>
 /// Returns a session to the cache.To be sure we have no transactiona ctive we abort in case
 /// the caller of this method did not commit or abort
 /// </summary>
 void ReturnSessionToCache(ServerClientSession pSession)
 {
     pSession.Abort();
     lock (sessions)
     {
         sessions.Add(pSession);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Returns a session to the cache.To be sure we have no transactiona ctive we abort in case
 /// the caller of this method did not commit or abort
 /// </summary>
 void ReturnSessionToCache(ServerClientSession pSession)
 {
     pSession.Abort();
     lock (sessions)
     {
         sessions.Add(pSession);
     }
 }
Exemplo n.º 3
0
        public void AppendFile()
        {
            Placement place = new Placement(798, 1, 1, 1, UInt16.MaxValue);

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginUpdate();
                ObjWithArray a = new ObjWithArray(10);
                a.Persist(place, session);
                session.Commit(); // commit Database 798
            }
            place = new Placement(798, 2, 1, 100, UInt16.MaxValue);
            for (int i = 0; i < 25; i++)
            {
                using (ServerClientSession session = new ServerClientSession(systemDir))
                {
                    //session.SetTraceAllDbActivity();
                    session.BeginUpdate();
                    for (int j = 0; j < 1000; j++)
                    {
                        ObjWithArray a = new ObjWithArray(j * 10);
                        a.Persist(place, session);
                    }
                    session.FlushUpdates();
                    session.FlushUpdatesServers(); // check if this will cause file to be appended
                    Database db = session.NewDatabase(3567);
                    using (ServerClientSession session2 = new ServerClientSession(systemDir))
                    {
                        session2.BeginUpdate();
                        ObjWithArray a = new ObjWithArray(10);
                        a.Persist(place, session2);
                        session2.Commit();
                    }
                    session.Abort(); // appended page space now unused? Need tidy?
                }
            }
        }
Exemplo n.º 4
0
 public void AppendFile()
 {
   Placement place = new Placement(798, 1, 1, 1, UInt16.MaxValue);
   using (ServerClientSession session = new ServerClientSession(systemDir))
   {
     session.BeginUpdate();
     ObjWithArray a = new ObjWithArray(10);
     a.Persist(place, session);
     session.Commit(); // commit Database 798
   }
   place = new Placement(798, 2, 1, 100, UInt16.MaxValue);
   for (int i = 0; i < 25; i++)
   {
     using (ServerClientSession session = new ServerClientSession(systemDir))
     {
       //session.SetTraceAllDbActivity();
       session.BeginUpdate();
       for (int j = 0; j < 1000; j++)
       {
         ObjWithArray a = new ObjWithArray(j * 10);
         a.Persist(place, session);
       }
       session.FlushUpdates();
       session.FlushUpdatesServers(); // check if this will cause file to be appended
       Database db = session.NewDatabase(3567);
       using (ServerClientSession session2 = new ServerClientSession(systemDir))
       {
         session2.BeginUpdate();
         ObjWithArray a = new ObjWithArray(10);
         a.Persist(place, session2);
         session2.Commit();
       }
       session.Abort(); // appended page space now unused? Need tidy?
     }
   }
 }
Exemplo n.º 5
0
        public void CachedSessionTest()
        {
            ServerClientSession lSession = GetCachedSession();

            //lets simulate that we did some prior work, return the session and get it again
            ReturnSessionToCache(lSession);
            lSession = GetCachedSession();
            TestClass lTestClass = new TestClass();

            lTestClass.SomeIntVar    = 123;
            lTestClass.SomeStringVar = "test";
            UInt64  id      = lTestClass.Persist(lSession, lTestClass);
            var     c       = new Class_A();
            UInt64  id2     = lSession.Persist(c);
            Class_B class_b = new Class_B();

            class_b.IntField    = 11;
            class_b.StringField = "sss";
            Class_A class_a = new Class_A();

            class_a.string_field = "xxx";
            class_a.b_field      = class_b;
            UInt64 id3 = lSession.Persist(class_a);

            lSession.Commit();
            //return to cache, get it again and query the object
            //as this test is to verify it does not hang we do it in separate thread and kill after timeout
            ReturnSessionToCache(lSession);
            lSession = GetCachedSession();
            lSession.Abort();
            lSession.BeginUpdate();
            Class_A cA = lSession.Open <Class_A>(id2);

            cA         = lSession.Open <Class_A>(id3);
            lTestClass = lSession.Open <TestClass>(id);
            Assert.NotNull(lTestClass.GeoCord);
            Assert.NotNull(lTestClass.StoredStructInObjectField);
            lTestClass.SomeIntVar    = 1234;
            lTestClass.SomeStringVar = "test2";
            lTestClass.Persist(lSession, lTestClass);
            lSession.Commit();
            //return to cache, get it again and query the object
            //as this test is to verify it does not hang we do it in separate thread and kill after timeout
            ReturnSessionToCache(lSession);
            lSession = GetCachedSession();
            counter  = (int)lSession.AllObjects <TestClass>(true, false).Count();
            ReturnSessionToCache(lSession);
            Thread lThread = new Thread(new ThreadStart(() =>
            {
                lSession = GetCachedSession();
                counter  = (int)lSession.AllObjects <TestClass>(true, false).Count();
                ReturnSessionToCache(lSession);
            }));

            lThread.Start();
            lEvent.WaitOne(5000);
            if (lThread.IsAlive)
            {
                lThread.Abort();
            }
            Assert.AreNotEqual(0, counter, "Invalid number of objects retrieved");
        }