コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAppendBatchOfTransactions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAppendBatchOfTransactions()
        {
            // GIVEN
            when(_logFile.Writer).thenReturn(_channel);
            TransactionAppender appender = Life.add(CreateTransactionAppender());

            when(_transactionIdStore.nextCommittingTransactionId()).thenReturn(2L, 3L, 4L);
            TransactionToApply batch = BatchOf(Transaction(SingleCreateNodeCommand(0), new sbyte[0], 0, 0, 0, 1, 0), Transaction(SingleCreateNodeCommand(1), new sbyte[0], 0, 0, 0, 1, 0), Transaction(SingleCreateNodeCommand(2), new sbyte[0], 0, 0, 0, 1, 0));

            // WHEN
            appender.Append(batch, _logAppendEvent);

            // THEN
            TransactionToApply tx = batch;

            assertEquals(2L, tx.TransactionId());
            tx = tx.Next();
            assertEquals(3L, tx.TransactionId());
            tx = tx.Next();
            assertEquals(4L, tx.TransactionId());
            assertNull(tx.Next());
        }
コード例 #2
0
        private void MatchAgainstExpectedTransactionIdIfAny(long transactionId, TransactionToApply tx)
        {
            long expectedTransactionId = tx.TransactionId();

            if (expectedTransactionId != TRANSACTION_ID_NOT_SPECIFIED)
            {
                if (transactionId != expectedTransactionId)
                {
                    System.InvalidOperationException ex = new System.InvalidOperationException("Received " + tx.TransactionRepresentation() + " with txId:" + expectedTransactionId + " to be applied, but appending it ended up generating an unexpected txId:" + transactionId);
                    _databaseHealth.panic(ex);
                    throw ex;
                }
            }
        }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void assertTransactionsCommitted(long startTxId, long expectedCount) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
        private void AssertTransactionsCommitted(long startTxId, long expectedCount)
        {
            ArgumentCaptor <TransactionToApply> batchCaptor = ArgumentCaptor.forClass(typeof(TransactionToApply));

            verify(_commitProcess).commit(batchCaptor.capture(), eq(NULL), eq(EXTERNAL));

            TransactionToApply batch = Iterables.single(batchCaptor.AllValues);
            long expectedTxId        = startTxId;
            long count = 0;

            while (batch != null)
            {
                assertEquals(expectedTxId, batch.TransactionId());
                expectedTxId++;
                batch = batch.Next();
                count++;
            }
            assertEquals(expectedCount, count);
        }
コード例 #4
0
        private void MarkUnsafeTransactionsForTermination(TransactionToApply first, TransactionToApply last)
        {
            long firstCommittedTimestamp = first.TransactionRepresentation().TimeCommitted;
            long lastCommittedTimestamp  = last.TransactionRepresentation().TimeCommitted;
            long earliestSafeTimestamp   = lastCommittedTimestamp - _idReuseSafeZoneTime;

            foreach (KernelTransactionHandle txHandle in _kernelTransactions.activeTransactions())
            {
                long commitTimestamp = txHandle.LastTransactionTimestampWhenStarted();

                if (commitTimestamp != Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_COMMIT_TIMESTAMP && commitTimestamp < earliestSafeTimestamp)
                {
                    if (txHandle.MarkForTermination(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.Outdated))
                    {
                        _log.info("Marking transaction for termination, " + "invalidated due to an upcoming batch of changes being applied:" + "\n" + "  Batch: firstCommittedTxId:" + first.TransactionId() + ", firstCommittedTimestamp:" + InformativeTimestamp(firstCommittedTimestamp) + ", lastCommittedTxId:" + last.TransactionId() + ", lastCommittedTimestamp:" + InformativeTimestamp(lastCommittedTimestamp) + ", batchTimeRange:" + InformativeDuration(lastCommittedTimestamp - firstCommittedTimestamp) + ", earliestSafeTimestamp:" + InformativeTimestamp(earliestSafeTimestamp) + ", safeZoneDuration:" + InformativeDuration(_idReuseSafeZoneTime) + "\n" + "  Transaction: lastCommittedTimestamp:" + InformativeTimestamp(txHandle.LastTransactionTimestampWhenStarted()) + ", lastCommittedTxId:" + txHandle.LastTransactionIdWhenStarted() + ", localStartTimestamp:" + InformativeTimestamp(txHandle.StartTime()));
                    }
                }
            }
        }