Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static TransactionCommitProcess newRememberingCommitProcess(final org.neo4j.kernel.impl.transaction.TransactionRepresentation[] slot) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        private static TransactionCommitProcess NewRememberingCommitProcess(TransactionRepresentation[] slot)
        {
            TransactionCommitProcess commitProcess = mock(typeof(TransactionCommitProcess));

            when(commitProcess.Commit(any(typeof(TransactionToApply)), any(typeof(CommitEvent)), any(typeof(TransactionApplicationMode)))).then(invocation =>
            {
                slot[0] = (( TransactionToApply )invocation.getArgument(0)).TransactionRepresentation();
                return(1L);
            });

            return(commitProcess);
        }
Example #2
0
 public virtual void InstallCommitProcess(TransactionCommitProcess commitProcess, long lastCommittedIndex)
 {
     lock (this)
     {
         this._lastCommittedIndex = lastCommittedIndex;
         _commandIndexTracker.AppliedCommandIndex = lastCommittedIndex;
         _log.info(format("Updated lastCommittedIndex to %d", lastCommittedIndex));
         this._queue = new TransactionQueue(_maxBatchSize, (first, last) =>
         {
             commitProcess.Commit(first, CommitEvent.NULL, TransactionApplicationMode.EXTERNAL);
             _pageCursorTracerSupplier.get().reportEvents();                     // Report paging metrics for the commit
         });
     }
 }
Example #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.api.TransactionCommitProcess createFakeTransactionCommitProcess(long txId) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
        private TransactionCommitProcess CreateFakeTransactionCommitProcess(long txId)
        {
            TransactionCommitProcess localCommitProcess = mock(typeof(TransactionCommitProcess));

            when(localCommitProcess.Commit(any(typeof(TransactionToApply)), any(typeof(CommitEvent)), any(typeof(TransactionApplicationMode)))).thenAnswer(invocation =>
            {
                TransactionToApply txToApply = invocation.getArgument(0);
                txToApply.commitment(new FakeCommitment(txId, mock(typeof(TransactionIdStore))), txId);
                txToApply.commitment().publishAsCommitted();
                txToApply.commitment().publishAsClosed();
                txToApply.close();
                return(txId);
            });
            return(localCommitProcess);
        }
Example #4
0
        private static void Apply(GraphDatabaseAPI db, IList <TransactionRepresentation> transactions)
        {
            TransactionCommitProcess committer = Db.DependencyResolver.resolveDependency(typeof(TransactionCommitProcess));

            transactions.ForEach(tx =>
            {
                try
                {
                    committer.Commit(new TransactionToApply(tx), CommitEvent.NULL, EXTERNAL);
                }
                catch (TransactionFailureException e)
                {
                    throw new Exception(e);
                }
            });
        }
        private Future <object> ApplyInT2(GraphDatabaseAPI db, IList <TransactionRepresentation> transactions)
        {
            TransactionCommitProcess commitProcess = Db.DependencyResolver.resolveDependency(typeof(TransactionCommitProcess));

            return(T2.execute(state =>
            {
                transactions.ForEach(tx =>
                {
                    try
                    {
                        // It will matter if the transactions are supplied all in the same batch or one by one
                        // since the CountsTracker#apply lock is held and released per transaction
                        commitProcess.Commit(new TransactionToApply(tx), NULL, EXTERNAL);
                    }
                    catch (TransactionFailureException e)
                    {
                        throw new Exception(e);
                    }
                });
                return null;
            }));
        }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void indexShouldIncludeNodesCreatedPreviouslyInBatch() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void IndexShouldIncludeNodesCreatedPreviouslyInBatch()
        {
            // GIVEN a transaction stream leading up to this issue
            // perform the transactions from db-level and extract the transactions as commands
            // so that they can be applied batch-wise they way we'd like to later.

            // a bunch of nodes (to have the index population later on to decide to use label scan for population)
            IList <TransactionRepresentation> transactions;
            GraphDatabaseAPI db        = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newImpermanentDatabase();
            string           nodeN     = "our guy";
            string           otherNode = "just to create the tokens";

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode(_label).setProperty(PROPERTY_KEY, otherNode);
                    for (int i = 0; i < 10_000; i++)
                    {
                        Db.createNode();
                    }
                    tx.Success();
                }
                // node N
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode(_label).setProperty(PROPERTY_KEY, nodeN);
                    tx.Success();
                }
                // uniqueness constraint affecting N
                using (Transaction tx = Db.beginTx())
                {
                    Db.schema().constraintFor(_label).assertPropertyIsUnique(PROPERTY_KEY).create();
                    tx.Success();
                }
                transactions = ExtractTransactions(db);
            }
            finally
            {
                Db.shutdown();
            }

            db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newImpermanentDatabase();
            TransactionCommitProcess commitProcess = Db.DependencyResolver.resolveDependency(typeof(TransactionCommitProcess));

            try
            {
                int cutoffIndex = FindCutoffIndex(transactions);
                commitProcess.Commit(ToApply(transactions.subList(0, cutoffIndex)), NULL, EXTERNAL);

                // WHEN applying the two transactions (node N and the constraint) in the same batch
                commitProcess.Commit(ToApply(transactions.subList(cutoffIndex, transactions.Count)), NULL, EXTERNAL);

                // THEN node N should've ended up in the index too
                using (Transaction tx = Db.beginTx())
                {
                    assertNotNull("Verification node not found", singleOrNull(Db.findNodes(_label, PROPERTY_KEY, otherNode)));                                    // just to verify
                    assertNotNull("Node N not found", singleOrNull(Db.findNodes(_label, PROPERTY_KEY, nodeN)));
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }