Ejemplo n.º 1
0
 static void Main(string[] args)
 {
   using (ServerClientSession session = new ServerClientSession(s_systemDir))
   {
     session.BeginUpdate();
     File.Copy(s_licenseDbFile, Path.Combine(s_systemDir, "4.odb"), true);
     session.RegisterClass(typeof(Woman));
     session.RegisterClass(typeof(Man));
     session.SubscribeToChanges(typeof(Person));
     session.SubscribeToChanges(typeof(Woman), "OlderThan50");
     Person robinHood = new Person("Robin", "Hood", 30, 1234, null, null);
     session.Persist(robinHood);
     Person billGates = new Person("Bill", "Gates", 56, 234, robinHood, null);
     session.Persist(billGates);
     Person steveJobs = new Person("Steve", "Jobs", 56, 456, billGates, null);
     session.Persist(steveJobs);
     session.Commit();
     Thread t = new Thread(UpdaterThread);
     t.Start();
     Thread.Sleep(600);
     
     for (int i = 0; i < 50; i++)
     {
       List<Oid> changes = session.BeginReadWithEvents();
       if (changes.Count == 0)
       {
         Console.WriteLine("No changes events at: " + DateTime.Now.ToString("HH:mm:ss:fff"));
         Thread.Sleep(250);
       }
       foreach (Oid id in changes)
       {
         object obj = session.Open(id);
         Console.WriteLine("Received change event for: " + obj + " at: " + DateTime.Now.ToString("HH:mm:ss:fff"));;
         //session.UnsubscribeToChanges(typeof(Person));
       }
       Console.WriteLine();
       session.Commit();
     }       
     t.Join();
   }
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            using (ServerClientSession session = new ServerClientSession(s_systemDir))
            {
                session.BeginUpdate();
                File.Copy(s_licenseDbFile, Path.Combine(s_systemDir, "4.odb"), true);
                session.RegisterClass(typeof(Woman));
                session.RegisterClass(typeof(Man));
                session.SubscribeToChanges(typeof(Person));
                session.SubscribeToChanges(typeof(Woman), "OlderThan50");
                Person robinHood = new Person("Robin", "Hood", 30, 1234, null, null);
                session.Persist(robinHood);
                Person billGates = new Person("Bill", "Gates", 56, 234, robinHood, null);
                session.Persist(billGates);
                Person steveJobs = new Person("Steve", "Jobs", 56, 456, billGates, null);
                session.Persist(steveJobs);
                session.Commit();
                Thread t = new Thread(UpdaterThread);
                t.Start();
                Thread.Sleep(600);

                for (int i = 0; i < 50; i++)
                {
                    List <Oid> changes = session.BeginReadWithEvents();
                    if (changes.Count == 0)
                    {
                        Console.WriteLine("No changes events at: " + DateTime.Now.ToString("HH:mm:ss:fff"));
                        Thread.Sleep(250);
                    }
                    foreach (Oid id in changes)
                    {
                        object obj = session.Open(id);
                        Console.WriteLine("Received change event for: " + obj + " at: " + DateTime.Now.ToString("HH:mm:ss:fff"));;
                        //session.UnsubscribeToChanges(typeof(Person));
                    }
                    Console.WriteLine();
                    session.Commit();
                }
                t.Join();
            }
        }
Ejemplo n.º 3
0
 public void ServerPageFlush()
 {
     using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
     {
         //DatabaseLocation location = new DatabaseLocation(systemHost, location2Dir, 700, UInt32.MaxValue, session, false, PageInfo.encryptionKind.noEncryption);
         Placement place = new Placement(789, 1, 1, 1);
         //session.SetTraceAllDbActivity();
         session.BeginUpdate();
         session.RegisterClass(typeof(ObjWithArray));                                                  // avoid lock failure by registrty ahead of running parallell sessions.
         session.RegisterClass(typeof(Person));                                                        // avoid lock failure by registrty ahead of running parallell sessions.
         session.RegisterClass(typeof(VelocityDbSchema.Samples.AllSupportedSample.Pet));               // avoid lock failure by registrty ahead of running parallell sessions.
         session.RegisterClass(typeof(VelocityDbList <WeakIOptimizedPersistableReference <Person> >)); // avoid lock failure by registrty ahead of running parallell sessions.
         // session.NewLocation(location);
         session.Commit();
         session.BeginUpdate();
         for (int i = 0; i < 4000; i++)
         {
             ObjWithArray person = new ObjWithArray(i * 10);
             person.Persist(place, session);
         }
         session.FlushUpdates();
         for (int i = 0; i < 1000; i++)
         {
             ObjWithArray person = new ObjWithArray(i);
             person.Persist(place, session);
         }
         using (ServerClientSession session2 = new ServerClientSession(systemDir, systemHost))
         {
             Placement place2 = new Placement(7891, 1, 1, 1);
             session2.BeginUpdate();
             for (int i = 0; i < 1000; i++)
             {
                 ObjWithArray person = new ObjWithArray(i);
                 person.Persist(place2, session2);
             }
             session2.FlushUpdates();
             for (int i = 0; i < 1000; i++)
             {
                 ObjWithArray person = new ObjWithArray(i);
                 person.Persist(place2, session2);
             }
             session2.Commit();
         }
         using (ServerClientSession session2 = new ServerClientSession(systemDir, systemHost))
         {
             Placement place2 = new Placement(7894, 1, 1, 1);
             session2.BeginUpdate();
             for (int i = 0; i < 5000; i++)
             {
                 ObjWithArray person = new ObjWithArray(i);
                 person.Persist(place2, session2);
             }
             session2.FlushUpdates();
             for (int i = 0; i < 1000; i++)
             {
                 ObjWithArray person = new ObjWithArray(i);
                 person.Persist(place2, session2);
             }
             session2.Commit();
         }
         using (ServerClientSession session2 = new ServerClientSession(systemDir, systemHost))
         {
             Placement place2 = new Placement(7897, 1, 1, 1);
             session2.BeginUpdate();
             for (int i = 0; i < 5000; i++)
             {
                 ObjWithArray person = new ObjWithArray(i);
                 person.Persist(place2, session2);
             }
             session2.FlushUpdates();
             for (int i = 0; i < 1000; i++)
             {
                 ObjWithArray person = new ObjWithArray(i);
                 person.Persist(place2, session2);
             }
             using (ServerClientSession session3 = new ServerClientSession(systemDir, systemHost))
             {
                 Placement place3 = new Placement(7900, 1, 1, 1);
                 session3.BeginUpdate();
                 for (int i = 0; i < 1000; i++)
                 {
                     ObjWithArray person = new ObjWithArray(i);
                     person.Persist(place3, session3);
                 }
                 session3.FlushUpdates();
                 for (int i = 0; i < 1000; i++)
                 {
                     ObjWithArray person = new ObjWithArray(i);
                     person.Persist(place3, session3);
                 }
                 session.Commit();
                 session2.Commit();
                 session3.Commit();
             }
         }
     }
 }
Ejemplo n.º 4
0
 public void PagesWritten()
 {
     using (ServerClientSession session = new ServerClientSession(systemDir, systemHost))
     {
         Placement place = new Placement(789);
         session.BeginUpdate();
         session.RegisterClass(typeof(Person));
         session.RegisterClass(typeof(VelocityDbList <WeakIOptimizedPersistableReference <Person> >));
         session.RegisterClass(typeof(VelocityDbSchema.Samples.AllSupportedSample.Pet));
         session.RegisterClass(typeof(System.Guid));
         session.RegisterClass(typeof(AutoPlacement));
         session.Commit();
         session.BeginUpdate();
         Person person = new Person();
         person.m_friends.Persist(place, session);
         person.Persist(place, session);
         session.FlushUpdates();
         person = new Person();
         person.Persist(place, session);
         using (ServerClientSession session2 = new ServerClientSession(systemDir, systemHost))
         {
             Placement place2 = new Placement(7891);
             session2.BeginUpdate();
             Person person2 = new Person();
             person2.m_friends.Persist(place2, session2);
             person2.Persist(place2, session2);
             session2.FlushUpdates();
             person2 = new Person();
             person2.Persist(place2, session2);
             session2.Commit();
         }
         using (ServerClientSession session2 = new ServerClientSession(systemDir, systemHost))
         {
             Placement place2 = new Placement(7892);
             session2.BeginUpdate();
             Person person2 = new Person();
             person2.m_friends.Persist(place2, session2);
             person2.Persist(place2, session2);
             session2.FlushUpdates();
             person2 = new Person();
             person2.m_friends.Persist(place2, session2);
             person2.Persist(place2, session2);
             session2.Commit();
         }
         using (ServerClientSession session2 = new ServerClientSession(systemDir, systemHost))
         {
             Placement place2 = new Placement(7893);
             session2.BeginUpdate();
             Person person2 = new Person();
             person2.m_friends.Persist(place2, session2);
             person2.Persist(place2, session2);
             session2.FlushUpdates();
             person2 = new Person();
             person2.Persist(place2, session2);
             using (ServerClientSession session3 = new ServerClientSession(systemDir, systemHost))
             {
                 Placement place3 = new Placement(7894);
                 session3.BeginUpdate();
                 Person person3 = new Person();
                 person3.m_friends.Persist(place3, session3);
                 person3.Persist(place3, session3);
                 session3.FlushUpdates();
                 person3 = new Person();
                 person3.m_friends.Persist(place3, session3);
                 person3.Persist(place3, session3);
                 session.Commit();
                 session2.Commit();
                 session3.Commit();
             }
         }
     }
 }