//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.");
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pageCacheMetrics() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PageCacheMetrics()
        {
            Label testLabel = Label.label("testLabel");

            using (Transaction transaction = _database.beginTx())
            {
                Node node = _database.createNode(testLabel);
                node.SetProperty("property", "value");
                transaction.Success();
            }

            using (Transaction ignored = _database.beginTx())
            {
                ResourceIterator <Node> nodes = _database.findNodes(testLabel);
                assertEquals(1, nodes.Count());
            }

            AssertMetrics("Metrics report should include page cache pins", PC_PINS, greaterThan(0L));
            AssertMetrics("Metrics report should include page cache unpins", PC_UNPINS, greaterThan(0L));
            AssertMetrics("Metrics report should include page cache evictions", PC_EVICTIONS, greaterThanOrEqualTo(0L));
            AssertMetrics("Metrics report should include page cache page faults", PC_PAGE_FAULTS, greaterThan(0L));
            AssertMetrics("Metrics report should include page cache hits", PC_HITS, greaterThan(0L));
            AssertMetrics("Metrics report should include page cache flushes", PC_FLUSHES, greaterThanOrEqualTo(0L));
            AssertMetrics("Metrics report should include page cache exceptions", PC_EVICTION_EXCEPTIONS, equalTo(0L));

            assertEventually("Metrics report should include page cache hit ratio", () => readDoubleValue(metricsCsv(_metricsDirectory, PC_HIT_RATIO)), lessThanOrEqualTo(1.0), 5, SECONDS);

            assertEventually("Metrics report should include page cache usage ratio", () => readDoubleValue(metricsCsv(_metricsDirectory, PC_USAGE_RATIO)), lessThanOrEqualTo(1.0), 5, SECONDS);
        }
예제 #3
0
        private Node CreateNodeWithProperty(Label label, string key, object value)
        {
            Node node = _db.createNode(label);

            node.SetProperty(key, value);
            return(node);
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            _label = Label.label("LABEL");
            char[] chars = new char[1 << 15];
            Arrays.fill(chars, 'c');
            _longString  = new string( chars );
            _propertyKey = "name";
        }
 private static void CreateTestNode(Label marker)
 {
     using (Transaction transaction = _database.beginTx())
     {
         _database.createNode(marker);
         transaction.Success();
     }
 }
예제 #6
0
 private void AssertInTxNodeWith(Label label, string key, object value)
 {
     using (Transaction tx = _db.beginTx())
     {
         AssertNodeWith(label, key, value);
         tx.Success();
     }
 }
예제 #7
0
        private int LabelId(Label alien)
        {
            ThreadToStatementContextBridge contextBridge = (( GraphDatabaseAPI )_db).DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge));

            using (Transaction tx = _db.beginTx())
            {
                return(contextBridge.GetKernelTransactionBoundToThisThread(true).tokenRead().nodeLabel(alien.Name()));
            }
        }
예제 #8
0
 internal override void RemoveOffendingDataInRunningTx(GraphDatabaseService db)
 {
     using (ResourceIterator <Node> nodes = Db.findNodes(Label.label(KEY)))
     {
         while (nodes.MoveNext())
         {
             nodes.Current.delete();
         }
     }
 }
예제 #9
0
        private void AssertNodeWith(Label label, string key, object value)
        {
            using (ResourceIterator <Node> nodes = _db.findNodes(label, key, value))
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertTrue(nodes.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                Node foundNode = nodes.next();
                assertTrue(foundNode.HasLabel(label));
                assertEquals(value, foundNode.GetProperty(key));
            }
        }
예제 #10
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;
            });
        }
예제 #11
0
 internal override void CreateOffendingDataInRunningTx(GraphDatabaseService db)
 {
     Db.createNode(Label.label(KEY));
 }