//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void timeoutOnAcquiringSharedLock() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TimeoutOnAcquiringSharedLock()
        {
            ExpectedException.expect(new RootCauseMatcher <>(typeof(LockAcquisitionTimeoutException), "The transaction has been terminated. " + "Retry your operation in a new transaction, and you should see a successful result. " + "Unable to acquire lock within configured timeout (dbms.lock.acquisition.timeout). " + "Unable to acquire lock for resource: LABEL with id: 1 within 2000 millis."));

            using (Transaction ignored = _database.beginTx())
            {
                Locks lockManger = LockManager;
                lockManger.NewClient().acquireExclusive(LockTracer.NONE, ResourceTypes.LABEL, 1);

                Future <Void> propertySetFuture = _secondTransactionExecutor.executeDontWait(state =>
                {
                    using (Transaction nestedTransaction = _database.beginTx())
                    {
                        ResourceIterator <Node> nodes = _database.findNodes(_marker);
                        Node node = nodes.next();
                        node.addLabel(Label.label("anotherLabel"));
                        nestedTransaction.success();
                    }
                    return(null);
                });

                _secondTransactionExecutor.waitUntilWaiting(SharedLockWaitingPredicate());
                _clockExecutor.execute((OtherThreadExecutor.WorkerCommand <Void, Void>)state =>
                {
                    _fakeClock.forward(3, TimeUnit.SECONDS);
                    return(null);
                });
                propertySetFuture.get();

                fail("Should throw termination exception.");
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void timeoutOnAcquiringExclusiveLock() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TimeoutOnAcquiringExclusiveLock()
        {
            ExpectedException.expect(new RootCauseMatcher <>(typeof(LockAcquisitionTimeoutException), "The transaction has been terminated. " + "Retry your operation in a new transaction, and you should see a successful result. " + "Unable to acquire lock within configured timeout (dbms.lock.acquisition.timeout). " + "Unable to acquire lock for resource: NODE with id: 0 within 2000 millis."));

            using (Transaction ignored = _database.beginTx())
            {
                ResourceIterator <Node> nodes = _database.findNodes(_marker);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                Node node = nodes.next();
                node.SetProperty(TEST_PROPERTY_NAME, "b");

                Future <Void> propertySetFuture = _secondTransactionExecutor.executeDontWait(state =>
                {
                    using (Transaction transaction1 = _database.beginTx())
                    {
                        node.SetProperty(TEST_PROPERTY_NAME, "b");
                        transaction1.success();
                    }
                    return(null);
                });

                _secondTransactionExecutor.waitUntilWaiting(ExclusiveLockWaitingPredicate());
                _clockExecutor.execute((OtherThreadExecutor.WorkerCommand <Void, Void>)state =>
                {
                    _fakeClock.forward(3, TimeUnit.SECONDS);
                    return(null);
                });
                propertySetFuture.get();

                fail("Should throw termination exception.");
            }
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void readOwnChangesFromRacingIndexNoBlock() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReadOwnChangesFromRacingIndexNoBlock()
        {
            Future <Void> t2Future = T2.execute(state =>
            {
                using (Transaction tx = _db.beginTx())
                {
                    CreateNodeWithProperty(_label, PROPERTY_KEY, VALUE_1);
                    AssertNodeWith(_label, PROPERTY_KEY, VALUE_1);

                    tx.success();
                }
                return(null);
            });

            Future <Void> t3Future = T3.execute(state =>
            {
                using (Transaction tx = _db.beginTx())
                {
                    CreateAndAwaitIndex(_label, PROPERTY_KEY);
                    tx.success();
                }
                return(null);
            });

            t3Future.get();
            t2Future.get();

            AssertInTxNodeWith(_label, PROPERTY_KEY, VALUE_1);
        }
示例#4
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private org.neo4j.test.OtherThreadExecutor.WorkerCommand<Void,Void> createAndAwaitIndex(final org.neo4j.graphdb.Label label, final String key)
        private WorkerCommand <Void, Void> CreateAndAwaitIndex(Label label, string key)
        {
            return(state =>
            {
                using (Transaction tx = _db.beginTx())
                {
                    _db.schema().indexFor(label).on(key).create();
                    tx.success();
                }
                using (Transaction ignore = _db.beginTx())
                {
                    _db.schema().awaitIndexesOnline(1, TimeUnit.MINUTES);
                }
                return null;
            });
        }