public void RestoreToBackupServer() { using (ServerClientSession session = new ServerClientSession(s_systemDir, systemHost)) { session.ClearServerCache(); // normally don't use this function but use it here to simulate a server going down and restarting } using (ServerClientSession session = new ServerClientSession(s_systemDir, backupHost, 1000, true, inMemoryOnly)) { session.BeginUpdate(); DatabaseLocation backupLocation = new DatabaseLocation(backupHost, backupDir, backupLocationStartDbNum, UInt32.MaxValue, session, PageInfo.compressionKind.LZ4, PageInfo.encryptionKind.noEncryption, true, session.DatabaseLocations.Default()); session.RestoreFrom(backupLocation, DateTime.MaxValue); session.Commit(false, true); } }
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(); } }