Ejemplo n.º 1
0
 public sealed override void ReleaseSemaphore(Transaction trans, string name)
 {
     lock (_lock)
     {
         if (_semaphores == null)
         {
             return;
         }
     }
     _semaphoresLock.Run(new _IClosure4_579(this, trans, name));
 }
Ejemplo n.º 2
0
            /// <exception cref="System.Exception"></exception>
            public virtual void TestCommittedCallbacks()
            {
                Lock4        lockObject  = new Lock4();
                BooleanByRef ownEvent    = new BooleanByRef(false);
                BooleanByRef gotEvent    = new BooleanByRef(false);
                BooleanByRef shallListen = new BooleanByRef(false);

                OwnCommittedCallbacksFixture.IContainerFactory factory = ((OwnCommittedCallbacksFixture.IContainerFactory
                                                                           )Factory.Value);
                OwnCommittedCallbacksFixture.CommitAction action = ((OwnCommittedCallbacksFixture.CommitAction
                                                                     )Action.Value);
                factory.Open();
                IObjectContainer clientA  = factory.OpenClient();
                IObjectContainer clientB  = factory.OpenClient();
                IEventRegistry   registry = EventRegistryFactory.ForObjectContainer(clientA);

                registry.Committed += new System.EventHandler <Db4objects.Db4o.Events.CommitEventArgs>
                                          (new _IEventListener4_153(shallListen, gotEvent, ownEvent, lockObject).OnEvent);
                lockObject.Run(new _IClosure4_170(shallListen, action, clientA, clientB, lockObject
                                                  ));
                shallListen.value = false;
                clientB.Close();
                clientA.Close();
                factory.Close();
                Assert.IsTrue(gotEvent.value);
                Assert.AreEqual(action.SelectsFirstClient(), ownEvent.value);
            }
        /// <exception cref="System.Exception"></exception>
        public virtual void Test()
        {
            BooleanByRef disconnected = new BooleanByRef();
            Lock4        Lock         = new Lock4();

            if (IsNetworking())
            {
                IDb4oClientServerFixture clientServerFixture = (IDb4oClientServerFixture)Fixture(
                    );
                IObjectServerEvents objectServerEvents = (IObjectServerEvents)clientServerFixture
                                                         .Server();
                objectServerEvents.ClientDisconnected += new System.EventHandler <Db4objects.Db4o.Events.StringEventArgs>
                                                             (new _IEventListener4_46(Lock, disconnected).OnEvent);
            }
            DeleteOnDeletingCallbackTestCase.RootItem root = ((DeleteOnDeletingCallbackTestCase.RootItem
                                                               )RetrieveOnlyInstance(typeof(DeleteOnDeletingCallbackTestCase.RootItem)));
            root.child = new DeleteOnDeletingCallbackTestCase.Item();
            Db().Store(root);
            Db().Delete(root);
            Reopen();
            if (IsNetworking())
            {
                Lock.Run(new _IClosure4_63(disconnected, Lock));
            }
            AssertClassIndexIsEmpty();
        }
        /// <exception cref="System.Exception"></exception>
        public virtual void Test()
        {
            var disconnected = new BooleanByRef();
            var Lock         = new Lock4();

            if (IsNetworking())
            {
                var clientServerFixture = (IDb4oClientServerFixture)Fixture(
                    );
                var objectServerEvents = (IObjectServerEvents)clientServerFixture
                                         .Server();
                objectServerEvents.ClientDisconnected += new _IEventListener4_46(Lock, disconnected).OnEvent;
            }
            var root = ((RootItem
                         )RetrieveOnlyInstance(typeof(RootItem)));

            root.child = new Item();
            Db().Store(root);
            Db().Delete(root);
            Reopen();
            if (IsNetworking())
            {
                Lock.Run(new _IClosure4_63(disconnected, Lock));
            }
            AssertClassIndexIsEmpty();
        }
Ejemplo n.º 5
0
            /// <exception cref="System.Exception"></exception>
            public virtual void TestCommittedCallbacks()
            {
                var lockObject  = new Lock4();
                var ownEvent    = new BooleanByRef(false);
                var gotEvent    = new BooleanByRef(false);
                var shallListen = new BooleanByRef(false);
                var factory     = ((IContainerFactory
                                    )Factory.Value);
                var action = ((CommitAction
                               )Action.Value);

                factory.Open();
                var clientA  = factory.OpenClient();
                var clientB  = factory.OpenClient();
                var registry = EventRegistryFactory.ForObjectContainer(clientA);

                registry.Committed += new _IEventListener4_153(shallListen, gotEvent, ownEvent, lockObject).OnEvent;
                lockObject.Run(new _IClosure4_170(shallListen, action, clientA, clientB, lockObject
                                                  ));
                shallListen.value = false;
                clientB.Close();
                clientA.Close();
                factory.Close();
                Assert.IsTrue(gotEvent.value);
                Assert.AreEqual(action.SelectsFirstClient(), ownEvent.value);
            }
Ejemplo n.º 6
0
        private void CloseConnectionInNetworkingCS(IExtObjectContainer client)
        {
            var eventWasRaised         = new BooleanByRef();
            var clientDisconnectedLock = new Lock4();
            var serverEvents           = (IObjectServerEvents)ClientServerFixture().Server
                                             ();

            serverEvents.ClientDisconnected += new _IEventListener4_85(clientDisconnectedLock, eventWasRaised).OnEvent;
            clientDisconnectedLock.Run(new _IClosure4_96(client, clientDisconnectedLock));
            Assert.IsTrue(eventWasRaised.value, "ClientDisconnected event was not raised.");
        }
Ejemplo n.º 7
0
        // closing is asynchronous, relying on completion is hard
        // That's why there is no test here.
        // ClientProcessesTestCase tests closing.
        public virtual void TestClientDisconnectedEvent()
        {
            var client      = (ClientObjectContainer)OpenClient();
            var clientName  = client.UserName;
            var eventRaised = new BooleanByRef();
            var events      = (IObjectServerEvents)server;
            var Lock        = new Lock4();

            events.ClientDisconnected += new _IEventListener4_51(clientName, eventRaised, Lock).OnEvent;
            Lock.Run(new _IClosure4_58(client, eventRaised, Lock));
        }
        private void CloseConnectionInNetworkingCS(IExtObjectContainer client)
        {
            BooleanByRef        eventWasRaised         = new BooleanByRef();
            Lock4               clientDisconnectedLock = new Lock4();
            IObjectServerEvents serverEvents           = (IObjectServerEvents)ClientServerFixture().Server
                                                             ();

            serverEvents.ClientDisconnected += new System.EventHandler <Db4objects.Db4o.Events.StringEventArgs>
                                                   (new _IEventListener4_85(clientDisconnectedLock, eventWasRaised).OnEvent);
            clientDisconnectedLock.Run(new _IClosure4_96(client, clientDisconnectedLock));
            Assert.IsTrue(eventWasRaised.value, "ClientDisconnected event was not raised.");
        }
        // closing is asynchronous, relying on completion is hard
        // That's why there is no test here.
        // ClientProcessesTestCase tests closing.
        public virtual void TestClientDisconnectedEvent()
        {
            ClientObjectContainer client    = (ClientObjectContainer)OpenClient();
            string              clientName  = client.UserName;
            BooleanByRef        eventRaised = new BooleanByRef();
            IObjectServerEvents events      = (IObjectServerEvents)server;
            Lock4 Lock = new Lock4();

            events.ClientDisconnected += new System.EventHandler <Db4objects.Db4o.Events.StringEventArgs>
                                             (new _IEventListener4_51(clientName, eventRaised, Lock).OnEvent);
            Lock.Run(new _IClosure4_58(client, eventRaised, Lock));
        }
Ejemplo n.º 10
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test()
        {
            var server = (ObjectServerImpl)Db4oClientServer.OpenServer(TempFile(
                                                                           ), Db4oClientServer.ArbitraryPort);
            var Lock = new Lock4();

            server.ClientDisconnected += new _IEventListener4_39(Lock).OnEvent;
            server.GrantAccess(User, Password);
            var client        = OpenClient(server.Port());
            var msgDispatcher = FirstMessageDispatcherFor(server);
            var transaction   = msgDispatcher.Transaction();
            var idSystem      = transaction.IdSystem();
            var prefetchedID  = idSystem.PrefetchID();

            Assert.IsGreater(0, prefetchedID);
            Lock.Run(new _IClosure4_58(client, Lock, idSystem, prefetchedID));
            // This wont work with the PointerBasedIdSystem
            server.Close();
        }
Ejemplo n.º 11
0
        /// <exception cref="System.Exception"></exception>
        public virtual void Test()
        {
            ObjectServerImpl server = (ObjectServerImpl)Db4oClientServer.OpenServer(TempFile(
                                                                                        ), Db4oClientServer.ArbitraryPort);
            Lock4 Lock = new Lock4();

            server.ClientDisconnected += new System.EventHandler <Db4objects.Db4o.Events.StringEventArgs>
                                             (new _IEventListener4_39(Lock).OnEvent);
            server.GrantAccess(User, Password);
            IObjectContainer            client        = OpenClient(server.Port());
            ServerMessageDispatcherImpl msgDispatcher = FirstMessageDispatcherFor(server);
            Transaction            transaction        = msgDispatcher.Transaction();
            ITransactionalIdSystem idSystem           = transaction.IdSystem();
            int prefetchedID = idSystem.PrefetchID();

            Assert.IsGreater(0, prefetchedID);
            Lock.Run(new _IClosure4_58(client, Lock, idSystem, prefetchedID));
            // This wont work with the PointerBasedIdSystem
            server.Close();
        }