public virtual void TestMissingClassesInServer() { IList serverMissedClasses = new ArrayList(); IList clientMissedClasses = new ArrayList(); var serverConfig = Db4oClientServer.NewServerConfiguration(); PrepareHost(serverConfig.File, serverConfig.Common, serverMissedClasses); ExcludeClasses(serverConfig.Common, new[] { typeof(Pilot ), typeof(Car) }); var server = Db4oClientServer.OpenServer(serverConfig, DbUri, Port); server.GrantAccess(User, Password); try { var clientConfig = Db4oClientServer.NewClientConfiguration(); PrepareCommon(clientConfig.Common, clientMissedClasses); var client = Db4oClientServer.OpenClient(clientConfig, "localhost", Port, User, Password); client.Query(new AcceptAllPredicate()); client.Close(); } finally { server.Close(); } AssertPilotAndCarMissing(serverMissedClasses); Assert.AreEqual(0, clientMissedClasses.Count); }
/// <summary> /// opens the IObjectServer, and waits forever until Close() is called /// or a StopServer message is being received. /// </summary> public void RunServer() { lock (this) { IServerConfiguration config = Db4oClientServer.NewServerConfiguration(); // Using the messaging functionality to redirect all // messages to this.processMessage config.Networking.MessageRecipient = this; IObjectServer db4oServer = Db4oClientServer.OpenServer(config, FILE, PORT); db4oServer.GrantAccess(USER, PASS); try { if (!stop) { // wait forever until Close will change stop variable Monitor.Wait(this); } } catch (Exception e) { Console.WriteLine(e.ToString()); } db4oServer.Close(); } }
public virtual void TestMissingClassesInClient() { IList serverMissedClasses = new ArrayList(); IList clientMissedClasses = new ArrayList(); IServerConfiguration serverConfig = Db4oClientServer.NewServerConfiguration(); PrepareHost(serverConfig.File, serverConfig.Common, serverMissedClasses); IObjectServer server = Db4oClientServer.OpenServer(serverConfig, DbUri, Port); server.GrantAccess(User, Password); try { IClientConfiguration clientConfig = Db4oClientServer.NewClientConfiguration(); PrepareCommon(clientConfig.Common, clientMissedClasses); ExcludeClasses(clientConfig.Common, new Type[] { typeof(MissingClassDiagnosticsTestCase.Pilot ), typeof(MissingClassDiagnosticsTestCase.Car) }); IObjectContainer client = Db4oClientServer.OpenClient(clientConfig, "localhost", Port, User, Password); IObjectSet result = client.Query(new MissingClassDiagnosticsTestCase.AcceptAllPredicate ()); IterateOver(result); client.Close(); } finally { server.Close(); } Assert.AreEqual(0, serverMissedClasses.Count); AssertPilotAndCarMissing(clientMissedClasses); }
public static void Main(string[] args) { File.Delete(YapFileName); AccessLocalServer(); File.Delete(YapFileName); using (IObjectContainer db = Db4oEmbedded.OpenFile(YapFileName)) { SetFirstCar(db); SetSecondCar(db); } IServerConfiguration config = Db4oClientServer.NewServerConfiguration(); config.Common.ObjectClass(typeof(Car)).UpdateDepth(3); using (IObjectServer server = Db4oClientServer.OpenServer(config, YapFileName, 0)) { QueryLocalServer(server); DemonstrateLocalReadCommitted(server); DemonstrateLocalRollback(server); } AccessRemoteServer(); using (IObjectServer server = Db4oClientServer.OpenServer(Db4oClientServer.NewServerConfiguration(), YapFileName, ServerPort)) { server.GrantAccess(ServerUser, ServerPassword); QueryRemoteServer(ServerPort, ServerUser, ServerPassword); DemonstrateRemoteReadCommitted(ServerPort, ServerUser, ServerPassword); DemonstrateRemoteRollback(ServerPort, ServerUser, ServerPassword); } }
private void OpenDB() { if (IsCoverting) { return; } if (server != null) { return; } try { var server_config = Db4oClientServer.NewServerConfiguration(); server_config.Common.AllowVersionUpdates = true; server_config.Common.Add(new TransparentActivationSupport()); if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "do_defragment_backup"))) { DefragmentDB(); File.Delete(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "do_defragment_backup")); } server = Db4oClientServer.OpenServer(server_config, db_name, 0); } catch (Exception ex) { MessageBox.Show(string.Format("Ошибка открытия файла базы данных {0}.\n{1}\n ", db_name, ex.Message), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
public virtual void TestClientServerApi() { IServerConfiguration config = Db4oClientServer.NewServerConfiguration(); IObjectServer server = Db4oClientServer.OpenServer(config, TempFile(), unchecked ( (int)(0xdb40))); try { server.GrantAccess("user", "password"); IClientConfiguration clientConfig = Db4oClientServer.NewClientConfiguration(); IObjectContainer client1 = Db4oClientServer.OpenClient(clientConfig, "localhost", unchecked ((int)(0xdb40)), "user", "password"); try { } finally { Assert.IsTrue(client1.Close()); } } finally { Assert.IsTrue(server.Close()); } }
public virtual void TestConfigurationHierarchy() { Assert.IsInstanceOf(typeof(INetworkingConfigurationProvider), Db4oClientServer.NewClientConfiguration ()); Assert.IsInstanceOf(typeof(INetworkingConfigurationProvider), Db4oClientServer.NewServerConfiguration ()); }
public virtual void Open() { IServerConfiguration config = Db4oClientServer.NewServerConfiguration(); config.File.Storage = new MemoryStorage(); _server = Db4oClientServer.OpenServer(config, string.Empty, 0); }
private IObjectServer OpenServer() { IObjectServer server = Db4oClientServer.OpenServer(Db4oClientServer.NewServerConfiguration (), TempFile(), -1); server.GrantAccess(Username, Password); return(server); }
/// <exception cref="System.Exception"></exception> public virtual void SetUp() { IServerConfiguration config = Db4oClientServer.NewServerConfiguration(); config.File.Storage = new MemoryStorage(); this.server = Db4oClientServer.OpenServer(config, "InMemory:File", Port); this.server.GrantAccess(UsernameAndPassword, UsernameAndPassword); }
protected override void Db4oSetupAfterStore() { var cfg = Db4oClientServer.NewServerConfiguration(); cfg.File.Storage = new MemoryStorage(); testDB = Db4oClientServer.OpenServer(cfg, "No:File:Expected", 0); StoreTestData(testDB); }
public void TestUpdateDepth() { System.IO.File.Delete(@"c:\temp\bugzzinga\BDTest.yap"); var db4oConfig = Db4oClientServer.NewServerConfiguration(); //db4oConfig.Common.ObjectClass( typeof( Proyecto )).UpdateDepth(10); //db4oConfig.Common.ObjectClass( typeof( Proyecto ).FullName ).CascadeOnUpdate( true ); //db4oConfig.Common.UpdateDepth = 10; var servidor = Db4oClientServer.OpenServer(db4oConfig, @"c:\temp\bugzzinga\BDTest.yap", 0); //----------------------------------------------------------------------------------------- var db = servidor.OpenClient(); Proyecto proyecto = new Proyecto(); proyecto.Codigo = "P1"; proyecto.Nombre = "Proyecto de prueba"; var tiposItem = HelperInstanciacionItems.GetTiposDeItem("Proyecto de prueba", 2); foreach (var item in tiposItem) { proyecto.AgregarTipoDeItem(item); } db.Store(proyecto); db.Close(); //----------------------------------------------------------------------------------------- db = servidor.OpenClient(); proyecto = null; var proyectoTest = (from Proyecto p in db select p).ToList()[0]; tiposItem = null; var tipoItem = HelperInstanciacionItems.GetTiposDeItem("Proyecto de prueba", 3).ToList()[2]; proyectoTest.AgregarTipoDeItem(tipoItem); db.Store(proyectoTest); db.Close(); //----------------------------------------------------------------------------------------- db = servidor.OpenClient(); proyectoTest = null; var proyectoTest2 = (from Proyecto p in db select p).ToList()[0]; db.Close(); //----------------------------------------------------------------------------------------- servidor.Close(); }
public virtual void Open() { IServerConfiguration config = Db4oClientServer.NewServerConfiguration(); config.File.Storage = new MemoryStorage(); _server = Db4oClientServer.OpenServer(config, string.Empty, Db4oClientServer.ArbitraryPort ); _server.GrantAccess(User, Pass); }
private IObjectServer GetEmbeddedServer(DB4ODatabaseElement dataBaseData, int retries, HttpContext context) { IObjectServer database; var databaseAlias = dataBaseData.Alias; if (_repository.AnyDataBase()) { database = _repository.GetDataBase <IObjectServer>(databaseAlias); if (database != null) { Debug.WriteLine(String.Format("GetEmbeddedServer ({0}, retry {1}) return cached database from repository", dataBaseData.Alias, retries)); return(database); } } if (dataBaseData.ServerType == Db4oServerType.NetworkingServer) { throw new Exception(String.Format("The server '{0}' is remote and you can´t get a instance of this server", databaseAlias)); } lock (_thisLock) { var serverConfig = Db4oClientServer.NewServerConfiguration(); if (dataBaseData.ExistAnyCustomConfiguration()) { serverConfig = dataBaseData.GetServerConfig <IServerConfiguration>(); } try { database = Db4oClientServer.OpenServer( serverConfig, GetAbsolutePath(dataBaseData.FileDb4oPath, context), Embeddedportserver); } catch (DatabaseFileLockedException) { if (retries < dataBaseData.OpenServerRetries) { Debug.WriteLine(String.Format("DatabaseFileLockedException (database: {1}) retry {0}", retries, dataBaseData.Alias)); return(GetEmbeddedServer(dataBaseData, retries + 1, context)); } throw; } _repository.AddDataBase(databaseAlias, database); Debug.WriteLine(String.Format("AddDataBase (database: '{0}') to Repository", dataBaseData.Alias)); } return(database); }
private static void ServerConfiguration() { // #example: Configure the db4o-server IServerConfiguration configuration = Db4oClientServer.NewServerConfiguration(); // change the configuration... IObjectServer server = Db4oClientServer.OpenServer(configuration, "database.db4o", 1337); // #end example server.Close(); }
private void OpenServer() { IServerConfiguration serverConfig = Db4oClientServer.NewServerConfiguration(); //serverConfig.Common.ObjectClass(typeof(人员)).MinimumActivationDepth(5); //serverConfig.Common.ObjectClass(typeof(人员)).CascadeOnUpdate(true); //serverConfig.Common.ObjectClass(typeof(人员)).CascadeOnDelete(true); serverConfig.Common.Queries.EvaluationMode(QueryEvaluationMode.Lazy); _db4OServer = Db4oClientServer.OpenServer(serverConfig, _dbFilePath, 0); }
private static IObjectServer CreateInMemoryServer() { IServerConfiguration config = Db4oClientServer.NewServerConfiguration(); config.File.Storage = new MemoryStorage(); IObjectServer server = Db4oClientServer.OpenServer(config, "In:Memory", Port); server.GrantAccess(UserAndPassword, UserAndPassword); return(server); }
private static IObjectServer OpenDatabaseServer(string fileName) { IServerConfiguration configuration = Db4oClientServer.NewServerConfiguration(); configuration.File.GenerateUUIDs = ConfigScope.Globally; configuration.File.GenerateCommitTimestamps = true; IObjectServer srv = Db4oClientServer.OpenServer(configuration, fileName, Port); srv.GrantAccess(UserName, UserName); return(srv); }
protected virtual IObjectServer InitializeDb4oServer() { var config = Db4oClientServer.NewServerConfiguration(); InitializeExtendedConfiguration(config); ValidateConfiguration(config); this.EventLog.WriteEntry(String.Format("Opening db4o database {0} on port {1}.", Db4oFileName, ListenPort), System.Diagnostics.EventLogEntryType.Information); var server = Db4oClientServer.OpenServer(config, Db4oFileName, ListenPort); InitializeAccessControl(server); return(server); }
private static IObjectServer StartUpServer() { // #example: configure a message receiver for the server IServerConfiguration configuration = Db4oClientServer.NewServerConfiguration(); configuration.Networking.MessageRecipient = new ServerMessageReceiver(); IObjectServer server = Db4oClientServer.OpenServer(configuration, DatabaseFile, PortNumber); // #end example server.GrantAccess(UserAndPassword, UserAndPassword); return(server); }
public virtual void Run() { //store IServerConfiguration conf = Db4oClientServer.NewServerConfiguration(); IObjectServer server = Db4oClientServer.OpenServer(conf, File, Port); server.GrantAccess("db4o", "db4o"); //store //update //assert server.Close(); }
public override void SetUp() { Db4oPerformanceCounterInstaller.ReInstall(); IServerConfiguration serverConfiguration = Db4oClientServer.NewServerConfiguration(); serverConfiguration.AddConfigurationItem(new ClientConnectionsMonitoringSupport()); serverConfiguration.AddConfigurationItem(new ConnectionCloseEventSupport(ClientDisconnected)); _server = Db4oClientServer.OpenServer(serverConfiguration, TempFile(), Db4oClientServer.ArbitraryPort); _server.GrantAccess(UserName, Password); }
private static void SocketTimeout() { // #example: configure the socket-timeout IServerConfiguration configuration = Db4oClientServer.NewServerConfiguration(); configuration.TimeoutServerSocket = (10 * 60 * 1000); // #end example IObjectServer container = Db4oClientServer.OpenServer(configuration, "database.db4o", 1337); container.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void Test() { IServerConfiguration config = Db4oClientServer.NewServerConfiguration(); config.TimeoutServerSocket = Timeout; config.File.Storage = new MemoryStorage(); ObjectServerImpl server = (ObjectServerImpl)Db4oClientServer.OpenServer(config, string.Empty , Db4oClientServer.ArbitraryPort); Thread.Sleep(Timeout * 2); Assert.AreEqual(0, server.TransactionCount()); server.Close(); }
/// <exception cref="System.Exception"></exception> public virtual void SetUp() { var serverConfiguration = Db4oClientServer.NewServerConfiguration (); serverConfiguration.File.Storage = new MemoryStorage(); _server = Db4oClientServer.OpenServer(serverConfiguration, string.Empty, Db4oClientServer .ArbitraryPort).Ext(); _server.GrantAccess(Username, Password); _networkingClient = Db4oClientServer.OpenClient("localhost", _server.Port(), Username , Password).Ext(); _embeddedClient = ((ObjectContainerSession)_server.OpenClient().Ext()); }
public override IFixtureProvider[] FixtureProviders() { return(new[] { Subjects(new object[] { Db4oEmbedded.NewConfiguration (), Db4oClientServer.NewClientConfiguration(), Db4oClientServer.NewServerConfiguration () }) }); }
/// <summary> /// Opens a connection to the database file. /// </summary> /// <remarks>The <c>Open</c> method assumes that the connection string will /// contain user credentials which are used when calling the /// <see cref="Db4objects.Db4o.CS.Db4oClientServer"/> <c>GrantAccess</c> method.</remarks> /// <exception cref="System.Exception">Throws when the singleton /// is already initialized.</exception> public void Open() { if (_databaseServer != null) { throw new Exception("Server is running"); } var userInfo = _connectionString.UserInfo.Split(new char[] { ':' }); _user = new GenericIdentity(userInfo[0]); _config = Db4oClientServer.NewServerConfiguration(); _databaseServer = Db4oClientServer.OpenServer(_connectionString.AbsolutePath, _connectionString.Port); _databaseServer.GrantAccess(userInfo[0], userInfo[1]); }
public virtual void Test() { IServerConfiguration config = Db4oClientServer.NewServerConfiguration(); config.File.Storage = new MemoryStorage(); ServerConfigurationItemIntegrationTestCase.DummyConfigurationItem item = new ServerConfigurationItemIntegrationTestCase.DummyConfigurationItem (this); config.AddConfigurationItem(item); IObjectServer server = Db4oClientServer.OpenServer(config, string.Empty, Db4oClientServer .ArbitraryPort); item.Verify(config, server); server.Close(); }
public void RunServer(int port) { var config = Db4oClientServer.NewServerConfiguration(); config.TimeoutServerSocket = 1000 * 10; var server = Db4oClientServer.OpenServer(config, FILE, port); server.GrantAccess("uu", "pp"); while (Console.ReadLine() != "exit") { Thread.Sleep(1000); } Environment.Exit(0); }
private void EnsureDb4OEmbeddedServer(bool deletePreviousFile, bool weakReferences) { if (_isDb4OInitiated) { return; } if (deletePreviousFile && File.Exists(DataBaseFilePath)) { var fileName = Path.GetFileNameWithoutExtension(DataBaseFilePath); var folderPath = Path.GetDirectoryName(DataBaseFilePath); File.Move(DataBaseFilePath, String.IsNullOrEmpty(PreviousDataBaseBackupFilePath) ? Path.Combine(folderPath, fileName + DateTime.Now.ToString("yyMMddHHmmss")) : PreviousDataBaseBackupFilePath); File.Delete(DataBaseFilePath); } if (UseClient) { var clientConfig = Db4oEmbedded.NewConfiguration(); SetCommonConfiguration(clientConfig.Common, weakReferences); if (UseMemoryStorage) { clientConfig.File.Storage = new PagingMemoryStorage(); } _embeddedContainer = Db4oEmbedded.OpenFile(clientConfig, DataBaseFilePath); } else { var serverConfig = Db4oClientServer.NewServerConfiguration(); SetCommonConfiguration(serverConfig.Common, weakReferences); if (UseMemoryStorage) { serverConfig.File.Storage = new PagingMemoryStorage(); } _emmbededServer = Db4oClientServer.OpenServer(serverConfig, DataBaseFilePath, 0); } _isDb4OInitiated = true; }