Beispiel #1
0
        public static void WatchUser()
        {
            using (ServerClientSession session = new ServerClientSession(systemDir, systemHost, 1000, true, false))
            {
                session.BeginRead();
                session.SubscribeToChanges(typeof(Vertex));
                Graph g = Graph.Open(session);
                session.Commit();
                Thread.Sleep(5000);

                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(1000);
                    }
                    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));
                    }
                    session.Commit();
                    Thread.Sleep(2000);
                }
            }
        }
 public void b2ServerIterateDatabases()
 {
   using (ServerClientSession session = new ServerClientSession(systemDir))
   {
     session.BeginRead();
     session.OpenAllDatabases();
     session.Commit();
   }
 }
 public void dServerIterateDatabases()
 {
     using (ServerClientSession session = new ServerClientSession(systemDir))
     {
         session.BeginRead();
         session.OpenAllDatabases();
         session.Commit();
     }
 }
Beispiel #4
0
 public void OneMillionFindSingleRecordInTheMiddleServer()
 {
   using (ServerClientSession session = new ServerClientSession(systemDir))
   {
     session.BeginRead();
     var result = (from ComputerFileData computerFileData in session.AllObjects<ComputerFileData>()
                   where computerFileData.FileID == 500000
                   select computerFileData).First();
     session.Commit();
   }
 }
 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();
   }
 }
Beispiel #6
0
 public void OneMillionFindSingleRecordInTheMiddleServer()
 {
     using (ServerClientSession session = new ServerClientSession(systemDir))
     {
         session.BeginRead();
         var result = (from ComputerFileData computerFileData in session.AllObjects <ComputerFileData>()
                       where computerFileData.FileID == 500000
                       select computerFileData).First();
         session.Commit();
     }
 }
        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();
            }
        }
        public void ReadSomeData()
        {
            int ct = 0;

            using (ServerClientSession session = new ServerClientSession(s_systemDir, systemHost, 1000, true, inMemoryOnly))
            {
                session.BeginRead();
                foreach (Man man in session.AllObjects <Man>())
                {
                    ct++;
                }
                Console.WriteLine("Commit, number of Men found: " + ct);
                session.Commit();
            }
        }
 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();
   }
 }
 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();
   }
 }
Beispiel #11
0
        public void HighAvalailabiltyByReplication()
        {
            var alternateSystemBoot = new List <ReplicaInfo> {
                new ReplicaInfo {
                    Path = "Replica1"
                }, new ReplicaInfo {
                    Path = "Replica2"
                }
            };
            var p1       = SessionBase.BaseDatabasePath + "/Replica1";
            var p2       = SessionBase.BaseDatabasePath + "/Replica2";
            var p3       = SessionBase.BaseDatabasePath + "/Replica3";
            var p3remote = $"\\{s_systemHost2}/databases/Replica3";

            if (Directory.Exists(p1))
            {
                Directory.Delete(p1, true);
            }
            if (Directory.Exists(p2))
            {
                Directory.Delete(p2, true);
            }
            if (Directory.Exists(p3))
            {
                Directory.Delete(p3, true);
            }
            if (Directory.Exists(p3remote))
            {
                Directory.Delete(p3remote, true);
            }

            using (var session = new ServerClientSession(alternateSystemBoot))
            {
                session.BeginUpdate();
                for (int i = 0; i < 100; i++)
                {
                    var s = i.ToString();
                    session.Persist(s);
                }
                session.Commit();
            }

            alternateSystemBoot = new List <ReplicaInfo> {
                new ReplicaInfo {
                    Path = "Replica1"
                }, new ReplicaInfo {
                    Path = "Replica2"
                }, new ReplicaInfo {
                    Path = "Replica3", Host = s_systemHost2
                }
            };
            using (var session = new ServerClientSession(alternateSystemBoot))
            {
                session.BeginUpdate();
                for (int i = 0; i < 100; i++)
                {
                    var s = i.ToString();
                    session.Persist(s);
                }
                session.Commit();
            }

            using (var session = new ServerClientSession(alternateSystemBoot))
            {
                session.BeginUpdate();
                for (int i = 0; i < 10; i++)
                {
                    var s = i.ToString();
                    session.Persist(s);
                }
                if (Directory.Exists(p2))
                {
                    Directory.Delete(p2, true);
                }
                session.Commit();
            }

            using (var session = new ServerClientSession(alternateSystemBoot))
            {
                session.BeginRead();
                foreach (var s in session.AllObjects <string>())
                {
                    Console.WriteLine(s);
                }
                session.Commit();
            }

            using (var session = new ServerClientSession(alternateSystemBoot))
            {
                session.BeginUpdate();
                for (int i = 0; i < 10; i++)
                {
                    var s = i.ToString();
                    session.Persist(s);
                    if (Directory.Exists(p2))
                    {
                        Directory.Delete(p2, true);
                    }
                }
                session.Commit();
            }

            using (var session = new ServerClientSession(alternateSystemBoot))
            {
                session.BeginRead();
                foreach (var s in session.AllObjects <string>())
                {
                    Console.WriteLine(s);
                }
                session.Commit();
            }

            using (var session = new SessionNoServer("Replica1"))
            {
                session.Verify();
            }
            using (var session = new SessionNoServer("Replica2"))
            {
                session.Verify();
            }
            using (var session = new ServerClientSession("Replica3", s_systemHost2))
            {
                session.Verify();
            }
        }
Beispiel #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();
            }
        }
 public void ReadSomeData()
 {
   int ct = 0;
   using (ServerClientSession session = new ServerClientSession(s_systemDir, systemHost, 1000, true, inMemoryOnly))
   {
     session.BeginRead();
     foreach (Man man in session.AllObjects<Man>())
     {
       ct++;
     }
     Console.WriteLine("Commit, number of Men found: " + ct);
     session.Commit();
   }
 }
        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();
                }
        }
        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();
            }
        }
    public static void WatchUser()
    {
      using (ServerClientSession session = new ServerClientSession(systemDir, systemHost, 1000, true, false))
      {
        session.BeginRead();
        session.SubscribeToChanges(typeof(Vertex));
        Graph g = Graph.Open(session);
        session.Commit();
        Thread.Sleep(5000);

        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(1000);
          }
          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));
          }
          session.Commit();
          Thread.Sleep(2000);
        }
      }
    }
        static readonly string s_systemDir = "VelocityGraphSample"; // appended to SessionBase.BaseDatabasePath

        static void Main(string[] args)
        {
            using (SessionNoServer session = new SessionNoServer(s_systemDir))
            {
                if (Directory.Exists(session.SystemDirectory))
                {
                    Directory.Delete(session.SystemDirectory, true); // remove systemDir from prior runs and all its databases.
                }
                Directory.CreateDirectory(session.SystemDirectory);
                Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
                session.BeginUpdate();
                Graph g = new Graph(session);
                session.Persist(g);

                // SCHEMA
                // Add a node type for the movies, with a unique identifier and two indexed Propertys
                VertexType   movieType      = g.NewVertexType("MOVIE");
                PropertyType movieTitleType = g.NewVertexProperty(movieType, "TITLE", DataType.String, PropertyKind.Indexed);
                PropertyType movieYearType  = g.NewVertexProperty(movieType, "YEAR", DataType.Integer, PropertyKind.Indexed);

                // Add a node type for the people, with a unique identifier and an indexed Property
                VertexType   peopleType     = g.NewVertexType("PEOPLE");
                PropertyType peopleNameType = g.NewVertexProperty(peopleType, "NAME", DataType.String, PropertyKind.Indexed);

                // Add an undirected edge type with a Property for the cast of a movie
                EdgeType     castType          = g.NewEdgeType("CAST", false);
                PropertyType castCharacterType = g.NewEdgeProperty(castType, "CHARACTER", DataType.String, PropertyKind.Indexed);

                // Add a directed edge type restricted to go from people to movie for the director of a movie
                EdgeType directsType = g.NewEdgeType("DIRECTS", true, peopleType, movieType);

                // DATA
                // Add some MOVIE nodes

                Vertex mLostInTranslation = movieType.NewVertex();
                mLostInTranslation.SetProperty(movieTitleType, "Lost in Translation");
                mLostInTranslation.SetProperty(movieYearType, (int)2003);

                Vertex mVickyCB = movieType.NewVertex();
                mVickyCB.SetProperty(movieTitleType, "Vicky Cristina Barcelona");
                mVickyCB.SetProperty(movieYearType, (int)2008);

                Vertex mManhattan = movieType.NewVertex();
                mManhattan.SetProperty(movieTitleType, "Manhattan");
                mManhattan.SetProperty(movieYearType, (int)1979);

                // Add some PEOPLE nodes
                Vertex pScarlett = peopleType.NewVertex();
                pScarlett.SetProperty(peopleNameType, "Scarlett Johansson");

                Vertex pBill = peopleType.NewVertex();
                pBill.SetProperty(peopleNameType, "Bill Murray");

                Vertex pSofia = peopleType.NewVertex();
                pSofia.SetProperty(peopleNameType, "Sofia Coppola");

                Vertex pWoody = peopleType.NewVertex();
                pWoody.SetProperty(peopleNameType, "Woody Allen");

                Vertex pPenelope = peopleType.NewVertex();
                pPenelope.SetProperty(peopleNameType, "Penélope Cruz");

                Vertex pDiane = peopleType.NewVertex();
                pDiane.SetProperty(peopleNameType, "Diane Keaton");

                // Add some CAST edges
                Edge anEdge;
                anEdge = g.NewEdge(castType, mLostInTranslation, pScarlett);
                anEdge.SetProperty(castCharacterType, "Charlotte");

                anEdge = g.NewEdge(castType, mLostInTranslation, pBill);
                anEdge.SetProperty(castCharacterType, "Bob Harris");

                anEdge = g.NewEdge(castType, mVickyCB, pScarlett);
                anEdge.SetProperty(castCharacterType, "Cristina");

                anEdge = g.NewEdge(castType, mVickyCB, pPenelope);
                anEdge.SetProperty(castCharacterType, "Maria Elena");

                anEdge = g.NewEdge(castType, mManhattan, pDiane);
                anEdge.SetProperty(castCharacterType, "Mary");

                anEdge = g.NewEdge(castType, mManhattan, pWoody);
                anEdge.SetProperty(castCharacterType, "Isaac");

                // Add some DIRECTS edges
                anEdge = g.NewEdge(directsType, pSofia, mLostInTranslation);
                anEdge = g.NewEdge(directsType, pWoody, mVickyCB);
                anEdge = g.NewEdge(directsType, pWoody, mManhattan);

                // QUERIES
                // Get the movies directed by Woody Allen
                Dictionary <Vertex, HashSet <Edge> > directedByWoody = pWoody.Traverse(directsType, Direction.Out);

                // Get the cast of the movies directed by Woody Allen
                Dictionary <Vertex, HashSet <Edge> > castDirectedByWoody = g.Traverse(directedByWoody.Keys.ToArray(), castType, Direction.Both);

                // Get the movies directed by Sofia Coppola
                Dictionary <Vertex, HashSet <Edge> > directedBySofia = pSofia.Traverse(directsType, Direction.Out);

                // Get the cast of the movies directed by Sofia Coppola
                Dictionary <Vertex, HashSet <Edge> > castDirectedBySofia = g.Traverse(directedBySofia.Keys.ToArray(), castType, Direction.Both);

                // We want to know the people that acted in movies directed by Woody AND in movies directed by Sofia.
                IEnumerable <Vertex> castFromBoth = castDirectedByWoody.Keys.Intersect(castDirectedBySofia.Keys);

                // Say hello to the people found
                foreach (Vertex person in castFromBoth)
                {
                    object value = person.GetProperty(peopleNameType);
                    System.Console.WriteLine("Hello " + value);
                }

                var billM = g.Traverse(directedBySofia.Keys.ToArray(), castType, Direction.Both).Keys.Where(vertex => vertex.GetProperty(peopleNameType).Equals("Bill Murray"));

                // Say hello to Bill Murray
                foreach (Vertex person in billM)
                {
                    object value = person.GetProperty(peopleNameType);
                    System.Console.WriteLine("Hello " + value);
                }

                session.Commit();
            }

            using (ServerClientSession session = new ServerClientSession(s_systemDir, System.Net.Dns.GetHostName()))
            {
                session.BeginRead();
                Graph        g                  = Graph.Open(session);
                VertexType   movieType          = g.FindVertexType("MOVIE");
                PropertyType movieTitleProperty = g.FindVertexProperty(movieType, "TITLE");
                Vertex       obj                = g.FindVertex(movieTitleProperty, "Manhattan");
                session.Commit();
            }
        }
    static readonly string systemDir = "VelocityGraphSample"; // appended to SessionBase.BaseDatabasePath

    static void Main(string[] args)
    {
      using (SessionNoServer session = new SessionNoServer(systemDir))
      {
        if (Directory.Exists(session.SystemDirectory))
          Directory.Delete(session.SystemDirectory, true); // remove systemDir from prior runs and all its databases.
        Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
        session.BeginUpdate();
        Graph g = new Graph(session);
        session.Persist(g);

        // SCHEMA
        // Add a node type for the movies, with a unique identifier and two indexed Propertys
        VertexType movieType = g.NewVertexType("MOVIE");
        PropertyType movieTitleType = g.NewVertexProperty(movieType, "TITLE", DataType.String, PropertyKind.Indexed);
        PropertyType movieYearType = g.NewVertexProperty(movieType, "YEAR", DataType.Integer, PropertyKind.Indexed);

        // Add a node type for the people, with a unique identifier and an indexed Property
        VertexType peopleType = g.NewVertexType("PEOPLE");
        PropertyType peopleNameType = g.NewVertexProperty(peopleType, "NAME", DataType.String, PropertyKind.Indexed);

        // Add an undirected edge type with a Property for the cast of a movie
        EdgeType castType = g.NewEdgeType("CAST", false);
        PropertyType castCharacterType = g.NewEdgeProperty(castType, "CHARACTER", DataType.String, PropertyKind.Indexed);

        // Add a directed edge type restricted to go from people to movie for the director of a movie
        EdgeType directsType = g.NewEdgeType("DIRECTS", true, peopleType, movieType);

        // DATA
        // Add some MOVIE nodes

        Vertex mLostInTranslation = movieType.NewVertex();
        mLostInTranslation.SetProperty(movieTitleType, "Lost in Translation");
        mLostInTranslation.SetProperty(movieYearType, (int)2003);

        Vertex mVickyCB = movieType.NewVertex();
        mVickyCB.SetProperty(movieTitleType, "Vicky Cristina Barcelona");
        mVickyCB.SetProperty(movieYearType, (int)2008);

        Vertex mManhattan = movieType.NewVertex();
        mManhattan.SetProperty(movieTitleType, "Manhattan");
        mManhattan.SetProperty(movieYearType, (int)1979);

        // Add some PEOPLE nodes
        Vertex pScarlett = peopleType.NewVertex();
        pScarlett.SetProperty(peopleNameType, "Scarlett Johansson");

        Vertex pBill = peopleType.NewVertex();
        pBill.SetProperty(peopleNameType, "Bill Murray");

        Vertex pSofia = peopleType.NewVertex();
        pSofia.SetProperty(peopleNameType, "Sofia Coppola");

        Vertex pWoody = peopleType.NewVertex();
        pWoody.SetProperty(peopleNameType, "Woody Allen");

        Vertex pPenelope = peopleType.NewVertex();
        pPenelope.SetProperty(peopleNameType, "Penélope Cruz");

        Vertex pDiane = peopleType.NewVertex();
        pDiane.SetProperty(peopleNameType, "Diane Keaton");

        // Add some CAST edges
        Edge anEdge;
        anEdge = g.NewEdge(castType, mLostInTranslation, pScarlett);
        anEdge.SetProperty(castCharacterType, "Charlotte");

        anEdge = g.NewEdge(castType, mLostInTranslation, pBill);
        anEdge.SetProperty(castCharacterType, "Bob Harris");

        anEdge = g.NewEdge(castType, mVickyCB, pScarlett);
        anEdge.SetProperty(castCharacterType, "Cristina");

        anEdge = g.NewEdge(castType, mVickyCB, pPenelope);
        anEdge.SetProperty(castCharacterType, "Maria Elena");

        anEdge = g.NewEdge(castType, mManhattan, pDiane);
        anEdge.SetProperty(castCharacterType, "Mary");

        anEdge = g.NewEdge(castType, mManhattan, pWoody);
        anEdge.SetProperty(castCharacterType, "Isaac");

        // Add some DIRECTS edges
        anEdge = g.NewEdge(directsType, pSofia, mLostInTranslation);
        anEdge = g.NewEdge(directsType, pWoody, mVickyCB);
        anEdge = g.NewEdge(directsType, pWoody, mManhattan);

        // QUERIES
        // Get the movies directed by Woody Allen
        Dictionary<Vertex, HashSet<Edge>> directedByWoody = pWoody.Traverse(directsType, Direction.Out);

        // Get the cast of the movies directed by Woody Allen
        Dictionary<Vertex, HashSet<Edge>> castDirectedByWoody = g.Traverse(directedByWoody.Keys.ToArray(), castType, Direction.Both);

        // Get the movies directed by Sofia Coppola
        Dictionary<Vertex, HashSet<Edge>> directedBySofia = pSofia.Traverse(directsType, Direction.Out);

        // Get the cast of the movies directed by Sofia Coppola
        Dictionary<Vertex, HashSet<Edge>> castDirectedBySofia = g.Traverse(directedBySofia.Keys.ToArray(), castType, Direction.Both);

        // We want to know the people that acted in movies directed by Woody AND in movies directed by Sofia.
        IEnumerable<Vertex> castFromBoth = castDirectedByWoody.Keys.Intersect(castDirectedBySofia.Keys);

        // Say hello to the people found
        foreach (Vertex person in castFromBoth)
        {
          object value = person.GetProperty(peopleNameType);
          System.Console.WriteLine("Hello " + value);
        }

        var billM = g.Traverse(directedBySofia.Keys.ToArray(), castType, Direction.Both).Keys.Where(vertex => vertex.GetProperty(peopleNameType).Equals("Bill Murray"));

        // Say hello to Bill Murray
        foreach (Vertex person in billM)
        {
          object value = person.GetProperty(peopleNameType);
          System.Console.WriteLine("Hello " + value);
        }

        session.Commit();
      }

      using (ServerClientSession session = new ServerClientSession(systemDir, System.Net.Dns.GetHostName()))
      {
        session.BeginRead();
        Graph g = Graph.Open(session);
        VertexType movieType = g.FindVertexType("MOVIE");
        PropertyType movieTitleProperty = g.FindVertexProperty(movieType, "TITLE");
        Vertex obj = g.FindVertex(movieTitleProperty, "Manhattan");
        session.Commit();
      }
    }