/// <summary> /// Closes the open database file connection. /// </summary> public void Close() { if (_databaseServer == null) { throw new Exception("Server is not running"); } _databaseServer.Close(); _databaseServer.Dispose(); _databaseServer = null; }
public override void TearDown() { _clientDisconnectedEvent.Close(); _server.Close(); base.TearDown(); }
private static void SimpleMessagingExample() { IObjectServer server = StartUpServer(); // #example: configure a message receiver for a client IClientConfiguration configuration = Db4oClientServer.NewClientConfiguration(); configuration.Networking.MessageRecipient = new ClientMessageReceiver(); // #end example // #example: Get the message sender and use it IMessageSender sender = configuration.MessageSender; using (IObjectContainer container = Db4oClientServer.OpenClient(configuration, "localhost", PortNumber, UserAndPassword, UserAndPassword)) { sender.Send(new HelloMessage("Hi Server!")); WaitForAWhile(); } // #end example server.Close(); }
public void Dispose() { if (null != _theDatabase) { _theDatabase.Close(); } }
public void Stop() { if (null != _theDatabase) { _theDatabase.Close(); } }
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()); } }
private void CloseDb4OContainer() { if (!UseClient && _emmbededServer == null) { return; } if (UseClient && _embeddedContainer == null) { return; } if (!UseClient) { _emmbededServer.Close(); _emmbededServer.Dispose(); _emmbededServer = null; } else { _embeddedContainer.Close(); _embeddedContainer.Dispose(); _embeddedContainer = null; } _isDb4OInitiated = false; }
public virtual void Test() { Collection4 expected = new Collection4(new object[] { "PING", true, 42 }); MessagingTestCaseBase.MessageCollector recipient = new MessagingTestCaseBase.MessageCollector (); IObjectServer server = OpenServerWith(recipient); try { IObjectContainer client = OpenClient("client", server); try { IMessageSender sender = MessageSender(client); SendAll(expected, sender); } finally { client.Close(); } } finally { server.Close(); } Assert.AreEqual(expected.ToString(), recipient.messages.ToString()); }
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 void TearDownStorage() { if (_db4oServer != null) { _db4oServer.Close(); } if (File.Exists(_DBPath)) { File.Delete(_DBPath); while (File.Exists(_DBPath)) { System.Threading.Thread.Sleep(5); } } }
/// <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(); } }
/// <exception cref="System.Exception"></exception> public virtual void Test() { IObjectServer server = Db4oClientServer.OpenServer(TempFile(), Db4oClientServer.ArbitraryPort ); server.GrantAccess(string.Empty, string.Empty); IObjectContainer client = Db4oClientServer.OpenClient("localhost", ((ObjectServerImpl )server).Port(), string.Empty, string.Empty); IObjectContainer client2 = Db4oClientServer.OpenClient("localhost", ((ObjectServerImpl )server).Port(), string.Empty, string.Empty); client.Commit(); client2.Commit(); try { server.Close(); } finally { try { client.Close(); client2.Close(); } catch (Db4oException) { } } }
private void WithDatabase(string file, IFunction4 function) { Configure(); IExtObjectContainer objectContainer = Db4oFactory.OpenFile(file).Ext(); try { function.Apply(objectContainer); } finally { objectContainer.Close(); } IObjectServer server = Db4oFactory.OpenServer(ClientServerFileName(file), -1); server.GrantAccess(Username, Password); objectContainer = Db4oFactory.OpenClient("localhost", server.Ext().Port(), Username , Password).Ext(); try { function.Apply(objectContainer); } finally { objectContainer.Close(); server.Close(); } }
public static void StopServer() { if (_Server != null) { _Server.Close(); _Server = null; } }
private void InitServer() { try { lock (this) { IObjectServer server = Db4oFactory.OpenServer(MiCliente.File, Convert.ToInt32(MiCliente.Port)); if (ValidoUsuario()) { AgregoUsuarios(ref server); server.Ext().Configure().AddAlias(new WildcardAlias("JerarquiaCheckList.*", "JerarquiaCheckList.*,JerarquiaCheckList")); server.Ext().Configure().ClientServer().SetMessageRecipient(this); try { while (!stop) { Monitor.Wait(this);/*wait 60000 ??*/ } } catch (ThreadInterruptedException) { server.Close(); stop = true; } finally { server.Close(); stop = true; } } else { server.Close(); stop = true; if (pub != null) { pub.SinAcceso(); } } } } catch (DatabaseFileLockedException) {//¿Que puedo hacer } }
private void Close(IObjectContainer objectContainer) { objectContainer.Close(); if (_server != null) { _server.Close(); _server = null; } }
// end Server /* * Procedure to close the server connection */ public static void CloseServer() { if (objectServer != null) { objectServer.Close(); } objectServer = null; }
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(); }
public static void Main(string[] args) { IObjectServer server = StartServer(); ConnectionPool connectionPool = new ConnectionPool(CreateClientConnection); UseThePool(connectionPool); server.Close(); }
public virtual void TestIsNotAlive() { IObjectServer server = OpenServer(); int port = server.Ext().Port(); ClientObjectContainer client = OpenClient(port); server.Close(); Assert.IsFalse(client.IsAlive()); client.Close(); }
protected virtual void OnStop(string[] args) { lock (this) { if (db4oServer == null) { throw new InvalidOperationException("Server is not running."); } db4oServer.Close(); db4oServer = null; } }
private void AssertReplyBehavior(ServerToClientTestCase.IClientWaitLogic clientWaitLogic ) { MessagingTestCaseBase.MessageCollector collector1 = new MessagingTestCaseBase.MessageCollector (); MessagingTestCaseBase.MessageCollector collector2 = new MessagingTestCaseBase.MessageCollector (); IObjectServer server = OpenServerWith(new ServerToClientTestCase.AutoReplyRecipient ()); try { IObjectContainer client1 = OpenClient("client1", server); try { SetMessageRecipient(client1, collector1); IMessageSender sender1 = MessageSender(client1); IObjectContainer client2 = OpenClient("client2", server); try { SetMessageRecipient(client2, collector2); IMessageSender sender2 = MessageSender(client2); SendEvenOddMessages(sender1, sender2); clientWaitLogic.Wait(client1, client2); try { // Give the message processor thread time to dispatch the message. Thread.Sleep(100); } catch (Exception e) { Sharpen.Runtime.PrintStackTrace(e); } Assert.AreEqual("[reply: 0, reply: 2, reply: 4, reply: 6, reply: 8]", collector1. messages.ToString()); Assert.AreEqual("[reply: 1, reply: 3, reply: 5, reply: 7, reply: 9]", collector2. messages.ToString()); } finally { client2.Close(); } } finally { client1.Close(); } } finally { server.Close(); } }
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(); }
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(); }
/// <exception cref="System.Exception"></exception> private void CloseServer() { if (null != _server) { IThreadPool4 serverThreadPool = ServerThreadPool(); _server.Close(); _server = null; if (null != serverThreadPool) { serverThreadPool.Join(ThreadpoolTimeout); } } }
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 Apply(object config) { IObjectServer server = this._enclosing.OpenServer(ConfigurationReuseTestSuite.NewInMemoryConfiguration (), "..", 0); try { this._enclosing.OpenClient(((IConfiguration)config), "localhost", server.Ext().Port (), "user", "password"); } finally { server.Close(); } }
public void Dispose() { if (null != _container) { _container.Close(); _container = null; } if (null != _server) { _server.Close(); _server = null; } // MAGIC: give some time for the db4o background threads to exit Thread.Sleep(1000); }
//private static IConfiguration _config = Db4oFactory.NewConfiguration(); public static void WithContainer(Action <IObjectContainer> action) { string _dbfile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "db4o_linq"); IObjectServer server = Db4oFactory.OpenServer(_dbfile, 0); try { using (var container = server.OpenClient()) { action(container); } } finally { server.Close(); } }
static bool LocalServerExecutor(MethodInfo method) { if (!CheckSignature(method, typeof(IObjectServer))) { return(false); } IObjectServer server = Db4oClientServer.OpenServer(Db4oClientServer.NewServerConfiguration(), DatabaseFileName, 0); try { method.Invoke(null, new object[] { server }); } finally { server.Close(); } return(true); }