Exemplo n.º 1
0
        public void fCreateDatabasesPreSizeServer()
        {
            Database database;

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginUpdate();
                for (uint i = 50000100; i < 50000200; i++)
                {
                    database = session.NewDatabase(i, i - 50000100, "myServerSetDbName");
                    Assert.NotNull(database);
                }
                session.Commit();
            }
            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginUpdate();
                for (uint i = 50000000; i < 50000200; i++)
                {
                    database = session.OpenDatabase(i);
                    Assert.NotNull(database);
                }
                session.Commit();
            }
        }
Exemplo n.º 2
0
 public void CreateLocationSameHostServer(bool optimisticLocking)
 {
     using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
     {
         session.BeginUpdate();
         DatabaseLocation remoteLocation = new DatabaseLocation(Dns.GetHostName(), location2Dir, locationStartDbNum, locationEndDbNum, session, PageInfo.compressionKind.LZ4, 0);
         remoteLocation = session.NewLocation(remoteLocation);
         Database database = session.NewDatabase(remoteLocation.StartDatabaseNumber);
         Assert.NotNull(database);
         session.Commit();
     }
     using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
     {
         session.BeginUpdate();
         Database database = session.OpenDatabase(locationStartDbNum, false);
         Assert.NotNull(database);
         session.DeleteDatabase(database);
         session.Commit();
     }
     using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
     {
         session.BeginUpdate();
         foreach (DatabaseLocation loc in session.DatabaseLocations)
         {
             Console.WriteLine(loc.ToStringDetails(session, false));
         }
         session.DeleteLocation(session.DatabaseLocations.LocationForDb(locationStartDbNum));
         foreach (DatabaseLocation loc in session.DatabaseLocations)
         {
             Console.WriteLine(loc.ToStringDetails(session, false));
         }
         session.Commit();
     }
 }
 public void CreateLocationSameHostServer(bool optimisticLocking)
 {
   using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
   {
     session.BeginUpdate();
     DatabaseLocation remoteLocation = new DatabaseLocation(Dns.GetHostName(), location2Dir, locationStartDbNum, locationEndDbNum, session, PageInfo.compressionKind.LZ4, 0);
     remoteLocation = session.NewLocation(remoteLocation);
     Database database = session.NewDatabase(remoteLocation.StartDatabaseNumber);
     Assert.NotNull(database);
     session.Commit();
   }
   using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
   {
     session.BeginUpdate();
     Database database = session.OpenDatabase(locationStartDbNum, false);
     Assert.NotNull(database);
     session.DeleteDatabase(database);
     session.Commit();
   }
   using (ServerClientSession session = new ServerClientSession(systemDir, Dns.GetHostName(), 2000, optimisticLocking))
   {
     session.BeginUpdate();
     foreach (DatabaseLocation loc in session.DatabaseLocations)
       Console.WriteLine(loc.ToStringDetails(session, false));
     session.DeleteLocation(session.DatabaseLocations.LocationForDb(locationStartDbNum));
     foreach (DatabaseLocation loc in session.DatabaseLocations)
       Console.WriteLine(loc.ToStringDetails(session, false));
     session.Commit();
   }
 }
Exemplo n.º 4
0
 public void bServerIterateDatabases()
 {
   Database database;
   using (ServerClientSession session = new ServerClientSession(systemDir))
   {
     session.BeginRead();
     for (uint i = 50000000; i < 50001000; i++)
       database = session.OpenDatabase(i);
     session.Commit();
   }
 }
Exemplo n.º 5
0
        public void multipleServersOKCleanup()
        {
            using (ServerClientSession session = new ServerClientSession(systemDir, systemHost, 2000, false)) // TO DO, change back to use optimistic locking
            {
                //session.SetTraceDbActivity(0);
                session.BeginUpdate();
                Database db = session.OpenDatabase(10000, true, false);
                if (db != null)
                {
                    session.DeleteDatabase(db);
                }
                db = session.OpenDatabase(20001, true, false);
                if (db != null)
                {
                    session.DeleteDatabase(db);
                }
                db = session.OpenDatabase(30001, true, false);
                if (db != null)
                {
                    session.DeleteDatabase(db);
                }
                db = session.OpenDatabase(40001, true, false);
                if (db != null)
                {
                    session.DeleteDatabase(db);
                }
                session.Commit();
                if (Directory.Exists(copyDir))
                {
                    Directory.Delete(copyDir, true);
                }
            }

            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();

            using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
            {
                Assert.True(session.OptimisticLocking);
            }
        }
Exemplo n.º 6
0
        public void bServerIterateDatabases()
        {
            Database database;

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginRead();
                for (uint i = 50000000; i < 50001000; i++)
                {
                    database = session.OpenDatabase(i);
                }
                session.Commit();
            }
        }
Exemplo n.º 7
0
        public void gDeleteDatabasesServer()
        {
            Database database;

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginUpdate();
                for (uint i = 50000000; i < 50000100; i++)
                {
                    database = session.OpenDatabase(i);
                    session.DeleteDatabase(database);
                }
                session.Commit();
            }
        }
Exemplo n.º 8
0
    [Repeat(3)] // remove when propagation of optimistic locking flag is done to slave database locations TO DO (issue caused by CopyAllDatabasdesTo that uses pessimistic locking)
    public void multipleServersOK()
    {
      using (SessionNoServer session = new SessionNoServer(systemDir))
      {
        session.BeginRead();
        foreach (DatabaseLocation loc in session.DatabaseLocations)
          Console.WriteLine(loc.ToStringDetails(session, false));
        session.Commit();
      }

      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
      {
        session.SetTraceDbActivity(0);
        DatabaseLocation localLocation = new DatabaseLocation(systemHost, location2Dir, 10000, 20000, session, PageInfo.compressionKind.LZ4, 0);
        Placement place = new Placement(10000, 2);
        session.BeginUpdate();
        foreach (DatabaseLocation loc in session.DatabaseLocations)
          Console.WriteLine(loc.ToStringDetails(session, false));
        Console.WriteLine();
        session.NewLocation(localLocation);
        foreach (DatabaseLocation loc in session.DatabaseLocations)
          Console.WriteLine(loc.ToStringDetails(session, false));
        Man aMan = null;
        Woman aWoman = null;

        for (int j = 1; j <= 5; j++)
        {
          aMan = new Man(null, aMan, DateTime.UtcNow);
          aMan.Persist(place, session);
          aWoman = new Woman(aMan, aWoman);
          aWoman.Persist(place, session);
          aMan.m_spouse = new WeakIOptimizedPersistableReference<VelocityDbSchema.Person>(aWoman);
          if (j % 1000 == 0)
          {
            session.FlushUpdates();
          }
        }
        localLocation = new DatabaseLocation(systemHost2, systemDir, 20001, 30000, session, PageInfo.compressionKind.LZ4, 0);
        session.NewLocation(localLocation);
        foreach (DatabaseLocation loc in session.DatabaseLocations)
          Console.WriteLine(loc.ToStringDetails(session, false));
        place = new Placement(20001);
        //localDatabase = session.NewDatabase(20001, localLocation);
        for (int j = 1; j <= 5; j++)
        {
          aMan = new Man(null, aMan, DateTime.UtcNow);
          aMan.Persist(place, session);
          aWoman = new Woman(aMan, aWoman);
          aWoman.Persist(place, session);
          aMan.m_spouse = new WeakIOptimizedPersistableReference<VelocityDbSchema.Person>(aWoman);
          if (j % 1000 == 0)
          {
            session.FlushUpdates();
          }
        }
        DatabaseLocation serverLocation = new DatabaseLocation(systemHost2, location2Dir, 30001, 40000, session, PageInfo.compressionKind.LZ4, 0);
        session.NewLocation(serverLocation);
        foreach (DatabaseLocation loc in session.DatabaseLocations)
          Console.WriteLine(loc.ToStringDetails(session, false));
        place = new Placement(30001);
        for (int j = 1; j <= 5; j++)
        {
          aMan = new Man(null, aMan, DateTime.UtcNow);
          aMan.Persist(place, session);
          aWoman = new Woman(aMan, aWoman);
          aWoman.Persist(place, session);
          aMan.m_spouse = new WeakIOptimizedPersistableReference<VelocityDbSchema.Person>(aWoman);
          if (j % 1000 == 0)
          {
            session.FlushUpdates();
          }
        }
        localLocation = new DatabaseLocation(systemHost3, systemDir, 40001, 50000, session, PageInfo.compressionKind.None, 0);
        session.NewLocation(localLocation);
        place = new Placement(40001);
        //localDatabase = session.NewDatabase(20001, localLocation);
        for (int j = 1; j <= 5; j++)
        {
          aMan = new Man(null, aMan, DateTime.UtcNow);
          aMan.Persist(place, session);
          aWoman = new Woman(aMan, aWoman);
          aWoman.Persist(place, session);
          aMan.m_spouse = new WeakIOptimizedPersistableReference<VelocityDbSchema.Person>(aWoman);
          if (j % 1000 == 0)
          {
            session.FlushUpdates();
          }
        }
        session.Commit();
      }

      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
      {
        session.CopyAllDatabasesTo(copyDir);
        using (SessionNoServer copySession = new SessionNoServer(copyDir))
        {
          copySession.Verify();
        }
      }

      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost, 2000, false)) // TO DO, change back to use optimistic locking
      {
        //session.SetTraceDbActivity(0);
        session.BeginUpdate();
        Database db = session.OpenDatabase(10000);
        session.DeleteDatabase(db);
        db = session.OpenDatabase(20001);
        session.DeleteDatabase(db);
        db = session.OpenDatabase(30001);
        session.DeleteDatabase(db);
        db = session.OpenDatabase(40001);
        session.DeleteDatabase(db);
        session.Commit();
        Directory.Delete(copyDir, true);
      }

      System.GC.Collect();
      System.GC.WaitForPendingFinalizers();

      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
      {
        Assert.True(session.OptimisticLocking);
      }
    }
Exemplo n.º 9
0
        [Repeat(3)] // remove when propagtion of optimistic locking flag is done to slave database locations TO DO (issue caused by CopyAllDatabasdesTo that uses pessimistic locking)
        public void multipleServersOK()
        {
            using (SessionNoServer session = new SessionNoServer(systemDir))
            {
                session.BeginRead();
                foreach (DatabaseLocation loc in session.DatabaseLocations)
                {
                    Console.WriteLine(loc.ToStringDetails(session, false));
                }
                session.Commit();
            }

            using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
            {
                session.SetTraceDbActivity(0);
                DatabaseLocation localLocation = new DatabaseLocation(systemHost, location2Dir, 10000, 20000, session, PageInfo.compressionKind.LZ4, 0);
                Placement        place         = new Placement(10000, 2);
                session.BeginUpdate();
                foreach (DatabaseLocation loc in session.DatabaseLocations)
                {
                    Console.WriteLine(loc.ToStringDetails(session, false));
                }
                Console.WriteLine();
                session.NewLocation(localLocation);
                foreach (DatabaseLocation loc in session.DatabaseLocations)
                {
                    Console.WriteLine(loc.ToStringDetails(session, false));
                }
                Man   aMan   = null;
                Woman aWoman = null;

                for (int j = 1; j <= 5; j++)
                {
                    aMan = new Man(null, aMan, DateTime.UtcNow);
                    aMan.Persist(place, session);
                    aWoman = new Woman(aMan, aWoman);
                    aWoman.Persist(place, session);
                    aMan.m_spouse = new WeakIOptimizedPersistableReference <VelocityDbSchema.Person>(aWoman);
                    if (j % 1000 == 0)
                    {
                        session.FlushUpdates();
                    }
                }
                localLocation = new DatabaseLocation(systemHost2, systemDir, 20001, 30000, session, PageInfo.compressionKind.LZ4, 0);
                session.NewLocation(localLocation);
                foreach (DatabaseLocation loc in session.DatabaseLocations)
                {
                    Console.WriteLine(loc.ToStringDetails(session, false));
                }
                place = new Placement(20001);
                //localDatabase = session.NewDatabase(20001, localLocation);
                for (int j = 1; j <= 5; j++)
                {
                    aMan = new Man(null, aMan, DateTime.UtcNow);
                    aMan.Persist(place, session);
                    aWoman = new Woman(aMan, aWoman);
                    aWoman.Persist(place, session);
                    aMan.m_spouse = new WeakIOptimizedPersistableReference <VelocityDbSchema.Person>(aWoman);
                    if (j % 1000 == 0)
                    {
                        session.FlushUpdates();
                    }
                }
                DatabaseLocation serverLocation = new DatabaseLocation(systemHost2, location2Dir, 30001, 40000, session, PageInfo.compressionKind.LZ4, 0);
                session.NewLocation(serverLocation);
                foreach (DatabaseLocation loc in session.DatabaseLocations)
                {
                    Console.WriteLine(loc.ToStringDetails(session, false));
                }
                place = new Placement(30001);
                for (int j = 1; j <= 5; j++)
                {
                    aMan = new Man(null, aMan, DateTime.UtcNow);
                    aMan.Persist(place, session);
                    aWoman = new Woman(aMan, aWoman);
                    aWoman.Persist(place, session);
                    aMan.m_spouse = new WeakIOptimizedPersistableReference <VelocityDbSchema.Person>(aWoman);
                    if (j % 1000 == 0)
                    {
                        session.FlushUpdates();
                    }
                }
                localLocation = new DatabaseLocation(systemHost3, systemDir, 40001, 50000, session, PageInfo.compressionKind.None, 0);
                session.NewLocation(localLocation);
                place = new Placement(40001);
                //localDatabase = session.NewDatabase(20001, localLocation);
                for (int j = 1; j <= 5; j++)
                {
                    aMan = new Man(null, aMan, DateTime.UtcNow);
                    aMan.Persist(place, session);
                    aWoman = new Woman(aMan, aWoman);
                    aWoman.Persist(place, session);
                    aMan.m_spouse = new WeakIOptimizedPersistableReference <VelocityDbSchema.Person>(aWoman);
                    if (j % 1000 == 0)
                    {
                        session.FlushUpdates();
                    }
                }
                session.Commit();
            }

            using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
            {
                session.CopyAllDatabasesTo(copyDir);
                using (SessionNoServer copySession = new SessionNoServer(copyDir))
                {
                    copySession.Verify();
                }
            }

            using (ServerClientSession session = new ServerClientSession(systemDir, systemHost, 2000, false)) // TO DO, change back to use optimistic locking
            {
                //session.SetTraceDbActivity(0);
                session.BeginUpdate();
                Database db = session.OpenDatabase(10000);
                session.DeleteDatabase(db);
                db = session.OpenDatabase(20001);
                session.DeleteDatabase(db);
                db = session.OpenDatabase(30001);
                session.DeleteDatabase(db);
                db = session.OpenDatabase(40001);
                session.DeleteDatabase(db);
                session.Commit();
                Directory.Delete(copyDir, true);
            }

            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();

            using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
            {
                Assert.True(session.OptimisticLocking);
            }
        }
Exemplo n.º 10
0
 public void SingleServerReaderSingleServerUpdater2(bool useReaderCommit)
 {
   const UInt32 dbNum = 567;
   using (ServerClientSession updater = new ServerClientSession(systemDir))
   using (ServerClientSession reader = new ServerClientSession(systemDir, null, 2000, true, false, CacheEnum.No)) // CacheEnum.No or cache validating on session.Begin() - makes test fail
   {
     updater.BeginUpdate();
     Database db = updater.OpenDatabase(dbNum, true, false);
     if (db != null)
       updater.DeleteDatabase(db);
     updater.Commit();
     updater.BeginUpdate();
     Man man;
     Placement place = new Placement(dbNum, 1, 1, 2);
     for (int i = 0; i < 100; i++)
     {
       man = new Man();
       man.Persist(place, updater);
     }
     updater.Commit();
     reader.BeginRead();
     db = reader.OpenDatabase(dbNum);
     foreach (Page page in db)
       Assert.True(page.PageInfo.VersionNumber == 1);
     if (useReaderCommit)
       reader.Commit();
     updater.BeginUpdate();
     if (useReaderCommit)
       reader.BeginRead();
     else
       reader.ForceDatabaseCacheValidation();
     for (int i = 1; i < 25; i++)
     {
       db = reader.OpenDatabase(dbNum);
       foreach (Page page in db)
       {
         if (page.PageNumber > 0)
         {
           Assert.True(page.PageInfo.VersionNumber == (ulong)i);
           Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
           Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
         }
       }
       if (useReaderCommit)
       {
         reader.Commit();
         reader.BeginRead();
       }
       else
         reader.ForceDatabaseCacheValidation();
       updater.Commit();
       updater.BeginUpdate();
     }
     Database db2 = reader.OpenDatabase(dbNum);
     db = updater.OpenDatabase(dbNum);
     for (int i = 25; i < 50; i++)
     {
       foreach (Page page in db)
       {
         if (page.PageNumber > 0)
         {
           Assert.True(page.PageInfo.VersionNumber == (ulong)i);
           Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
         }
       }
       updater.FlushUpdates(); // now server will see updated version of pages
       foreach (Page page in db2)
       {
         if (page.PageNumber > 0)
         {                           // BUG Nov 8, 2011 1.0.4.0 reader sees version 28 when it should see version 27 
           Assert.True(page.PageInfo.VersionNumber == (ulong)i); // reader should see the commited version of the page, not the uncommited updated version
           Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
         }
       }
       reader.ClearPageCache(); // required or else we will use cached page and Assert (see line above) will fail
       System.GC.Collect(); // force weak referenced pages to be garbage collected (again to avoid Assert failure)
       updater.Commit();
       updater.BeginUpdate();
     }
     reader.Commit();
     updater.DeleteDatabase(db);
     updater.Commit();
   }
 }
Exemplo n.º 11
0
 public void SingleServerReaderSingleServerUpdater1()
 {
   ServerClientSession updater = new ServerClientSession(systemDir);
   ServerClientSession reader = new ServerClientSession(systemDir);
   const UInt32 dbNum = 345;
   try
   {
     updater.BeginUpdate();
     Man man;
     Placement place = new Placement(dbNum, 1, 1, 2);
     for (int i = 0; i < 100; i++)
     {
       man = new Man();
       man.Persist(place, updater);
     }
     updater.Commit();
     reader.BeginRead();
     Database db = reader.OpenDatabase(dbNum);
     foreach (Page page in db)
       Assert.True(page.PageInfo.VersionNumber == 1);
     reader.Commit();
     updater.BeginUpdate();
     reader.BeginRead();
     for (int i = 1; i < 25; i++)
     {
       db = reader.OpenDatabase(dbNum);
       foreach (Page page in db)
       {
         if (page.PageNumber > 0)
         {
           Assert.True(page.PageInfo.VersionNumber == (ulong)i);
           Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
           Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
         }
       }
       reader.Commit();
       reader.BeginRead();
       updater.Commit();
       updater.BeginUpdate();
       reader.ForceDatabaseCacheValidation(); // we now validate on BeginRead so to make this test pass, we need to add this call after updater commit.
     }
     Database db2 = reader.OpenDatabase(dbNum);
     db = updater.OpenDatabase(dbNum);
     for (int i = 25; i < 50; i++)
     {
       foreach (Page page in db)
       {
         if (page.PageNumber > 0)
         {
           Assert.True(page.PageInfo.VersionNumber == (ulong)i);
           Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
         }
       }
       updater.Commit();
       updater.BeginUpdate();
       foreach (Page page in db2)
       {
         if (page.PageNumber > 0)
         {
           Assert.True(page.PageInfo.VersionNumber == (ulong)i + 1);
           Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
         }
       }
       reader.ClearPageCache(); // required or else we will use cached page and Assert (see line above) will fail
       System.GC.Collect(); // force weak referenced pages to be garbage collected (again to avoid Assert failure)
     }
     reader.Commit();
     updater.DeleteDatabase(db);
     updater.Commit();
   }
   finally
   {
     updater.Dispose();
     reader.Dispose();
   }
 }
Exemplo n.º 12
0
        public void SimpleApiServer()
        {
            long   ssn = 555555;
            UInt16 age = 1;

            VelocityDbSchema.Person mats;
            Placement place;

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                // skip delete database since it invalidates indices

                session.BeginUpdate();
                Database db = session.OpenDatabase(10, true, false);
                if (db != null)
                {
                    session.DeleteDatabase(db);
                }
                session.Commit();
                session.BeginUpdate();
                place = new Placement(10, 2, 1, 1, 10);
                DateTime birthday = new DateTime(1960, 6, 13);
                mats = new Man("Mats", "Persson", age++, ssn++, birthday);
                mats.Persist(place, session);
                session.Commit();
                session.ClearServerCache();
            }
            UInt64 mOid1 = Oid.Encode(10, 2, 1);

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginUpdate();
                UInt32 dbNum = Oid.DatabaseNumber(mOid1);
                mats = (VelocityDbSchema.Person)session.Open(mOid1);
                Woman kinga = null;
                mats = new Man("Mats", "Persson", age++, ssn++, new DateTime(1960, 6, 13));
                Cat cat = new Cat("Boze", 8);
                mats.m_pets.Add(cat);
                Bird bird = new Bird("Pippi", 1);
                cat.friends.Add(bird);
                mats.Persist(place, session);
                kinga = new Woman("Kinga", "Persson", age, ssn, mats, mats);
                kinga.Persist(place, session);
                VelocityDbSchema.Person robin = new VelocityDbSchema.Person("Robin", "Persson", 13, 1, mats, null);
                robin.Persist(place, session);
                mOid1 = mats.Id;
                mats  = null;
                mats  = (VelocityDbSchema.Person)session.Open(mOid1);
                session.Commit();
                session.ClearServerCache();
            }

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginUpdate();
                mats = (VelocityDbSchema.Person)session.Open(mOid1);
                session.Commit();
                session.ClearServerCache();
            }

            using (ServerClientSession session = new ServerClientSession(systemDir))
            {
                session.BeginRead();
                ulong mOid2 = mats.Id;
                mats = (VelocityDbSchema.Person)session.Open(mOid2);
                session.Commit();
                session.ClearServerCache();
            }
        }
Exemplo n.º 13
0
        public void SingleServerReaderSingleServerUpdater2(bool useReaderCommit)
        {
            const UInt32 dbNum = 567;

            using (ServerClientSession updater = new ServerClientSession(systemDir))
                using (ServerClientSession reader = new ServerClientSession(systemDir, null, 2000, true, false, CacheEnum.No)) // CacheEnum.No or cache validating on session.Begin() - makes test fail
                {
                    updater.BeginUpdate();
                    Database db = updater.OpenDatabase(dbNum, true, false);
                    if (db != null)
                    {
                        updater.DeleteDatabase(db);
                    }
                    updater.Commit();
                    updater.BeginUpdate();
                    Man       man;
                    Placement place = new Placement(dbNum, 1, 1, 2);
                    for (int i = 0; i < 100; i++)
                    {
                        man = new Man();
                        man.Persist(place, updater);
                    }
                    updater.Commit();
                    reader.BeginRead();
                    db = reader.OpenDatabase(dbNum);
                    foreach (Page page in db)
                    {
                        Assert.True(page.PageInfo.VersionNumber == 1);
                    }
                    if (useReaderCommit)
                    {
                        reader.Commit();
                    }
                    updater.BeginUpdate();
                    if (useReaderCommit)
                    {
                        reader.BeginRead();
                    }
                    else
                    {
                        reader.ForceDatabaseCacheValidation();
                    }
                    for (int i = 1; i < 25; i++)
                    {
                        db = reader.OpenDatabase(dbNum);
                        foreach (Page page in db)
                        {
                            if (page.PageNumber > 0)
                            {
                                Assert.True(page.PageInfo.VersionNumber == (ulong)i);
                                Man man2       = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
                                Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
                            }
                        }
                        if (useReaderCommit)
                        {
                            reader.Commit();
                            reader.BeginRead();
                        }
                        else
                        {
                            reader.ForceDatabaseCacheValidation();
                        }
                        updater.Commit();
                        updater.BeginUpdate();
                    }
                    Database db2 = reader.OpenDatabase(dbNum);
                    db = updater.OpenDatabase(dbNum);
                    for (int i = 25; i < 50; i++)
                    {
                        foreach (Page page in db)
                        {
                            if (page.PageNumber > 0)
                            {
                                Assert.True(page.PageInfo.VersionNumber == (ulong)i);
                                Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
                            }
                        }
                        updater.FlushUpdates(); // now server will see updated version of pages
                        foreach (Page page in db2)
                        {
                            if (page.PageNumber > 0)
                            {                                                         // BUG Nov 8, 2011 1.0.4.0 reader sees version 28 when it should see version 27
                                Assert.True(page.PageInfo.VersionNumber == (ulong)i); // reader should see the commited version of the page, not the uncommited updated version
                                Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
                            }
                        }
                        reader.ClearPageCache(); // required or else we will use cached page and Assert (see line above) will fail
                        System.GC.Collect();     // force weak referenced pages to be garbage collected (again to avoid Assert failure)
                        updater.Commit();
                        updater.BeginUpdate();
                    }
                    reader.Commit();
                    updater.DeleteDatabase(db);
                    updater.Commit();
                }
        }
Exemplo n.º 14
0
        public void SingleServerReaderSingleServerUpdater1()
        {
            ServerClientSession updater = new ServerClientSession(systemDir);
            ServerClientSession reader  = new ServerClientSession(systemDir);
            const UInt32        dbNum   = 345;

            try
            {
                updater.BeginUpdate();
                Man       man;
                Placement place = new Placement(dbNum, 1, 1, 2);
                for (int i = 0; i < 100; i++)
                {
                    man = new Man();
                    man.Persist(place, updater);
                }
                updater.Commit();
                reader.BeginRead();
                Database db = reader.OpenDatabase(dbNum);
                foreach (Page page in db)
                {
                    Assert.True(page.PageInfo.VersionNumber == 1);
                }
                reader.Commit();
                updater.BeginUpdate();
                reader.BeginRead();
                for (int i = 1; i < 25; i++)
                {
                    db = reader.OpenDatabase(dbNum);
                    foreach (Page page in db)
                    {
                        if (page.PageNumber > 0)
                        {
                            Assert.True(page.PageInfo.VersionNumber == (ulong)i);
                            Man man2       = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
                            Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
                        }
                    }
                    reader.Commit();
                    reader.BeginRead();
                    updater.Commit();
                    updater.BeginUpdate();
                    reader.ForceDatabaseCacheValidation(); // we now validate on BeginRead so to make this test pass, we need to add this call after updater commit.
                }
                Database db2 = reader.OpenDatabase(dbNum);
                db = updater.OpenDatabase(dbNum);
                for (int i = 25; i < 50; i++)
                {
                    foreach (Page page in db)
                    {
                        if (page.PageNumber > 0)
                        {
                            Assert.True(page.PageInfo.VersionNumber == (ulong)i);
                            Man manUpdated = (Man)updater.Open(dbNum, page.PageNumber, 1, true);
                        }
                    }
                    updater.Commit();
                    updater.BeginUpdate();
                    foreach (Page page in db2)
                    {
                        if (page.PageNumber > 0)
                        {
                            Assert.True(page.PageInfo.VersionNumber == (ulong)i + 1);
                            Man man2 = (Man)reader.Open(dbNum, page.PageNumber, 1, false);
                        }
                    }
                    reader.ClearPageCache(); // required or else we will use cached page and Assert (see line above) will fail
                    System.GC.Collect();     // force weak referenced pages to be garbage collected (again to avoid Assert failure)
                }
                reader.Commit();
                updater.DeleteDatabase(db);
                updater.Commit();
            }
            finally
            {
                updater.Dispose();
                reader.Dispose();
            }
        }
Exemplo n.º 15
0
   public void multipleServersOKCleanup()
    {
      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost, 2000, false)) // TO DO, change back to use optimistic locking
      {
        //session.SetTraceDbActivity(0);
        session.BeginUpdate();
        Database db = session.OpenDatabase(10000, true, false);
        if (db != null)
          session.DeleteDatabase(db);
        db = session.OpenDatabase(20001, true, false);
        if (db != null)
          session.DeleteDatabase(db);
        db = session.OpenDatabase(30001, true, false);
        if (db != null)
          session.DeleteDatabase(db);
        db = session.OpenDatabase(40001, true, false);
        if (db != null)
          session.DeleteDatabase(db);
        session.Commit();
        if (Directory.Exists(copyDir))
          Directory.Delete(copyDir, true);
      }

      System.GC.Collect();
      System.GC.WaitForPendingFinalizers();

      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
      {
        Assert.True(session.OptimisticLocking);
      }
    }
Exemplo n.º 16
0
 public void gDeleteDatabasesServer()
 {
   Database database;
   using (ServerClientSession session = new ServerClientSession(systemDir))
   {
     session.BeginUpdate();
     for (uint i = 50000000; i < 50000100; i++)
     {
       database = session.OpenDatabase(i);
       session.DeleteDatabase(database);
     }
     session.Commit();
   }
 }
Exemplo n.º 17
0
 public void fCreateDatabasesPreSizeServer()
 {
   Database database;
   using (ServerClientSession session = new ServerClientSession(systemDir))
   {
     session.BeginUpdate();
     for (uint i = 50000100; i < 50000200; i++)
     {
       database = session.NewDatabase(i, i - 50000100, "myServerSetDbName");
       Assert.NotNull(database);
     }
     session.Commit();
   }
   using (ServerClientSession session = new ServerClientSession(systemDir))
   {
     session.BeginUpdate();
     for (uint i = 50000000; i < 50000200; i++)
     {
       database = session.OpenDatabase(i);
       Assert.NotNull(database);
     }
     session.Commit();
   }
 }