Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static int findCutoffIndex(java.util.Collection<org.neo4j.kernel.impl.transaction.TransactionRepresentation> transactions) throws java.io.IOException
        private static int FindCutoffIndex(ICollection <TransactionRepresentation> transactions)
        {
            IEnumerator <TransactionRepresentation> iterator = transactions.GetEnumerator();

            for (int i = 0; iterator.MoveNext(); i++)
            {
                TransactionRepresentation tx        = iterator.Current;
                CommandExtractor          extractor = new CommandExtractor();
                tx.Accept(extractor);
                IList <StorageCommand> commands     = extractor.Commands;
                IList <StorageCommand> nodeCommands = commands.Where(command => command is NodeCommand).ToList();
                if (nodeCommands.Count == 1)
                {
                    return(i);
                }
            }
            throw new AssertionError("Couldn't find the transaction which would be the cut-off point");
        }
        /// <returns> A TransactionCommitment instance with metadata about the committed transaction, such as whether or not
        /// this transaction contains any explicit index changes. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private TransactionCommitment appendToLog(org.neo4j.kernel.impl.transaction.TransactionRepresentation transaction, long transactionId) throws java.io.IOException
        private TransactionCommitment AppendToLog(TransactionRepresentation transaction, long transactionId)
        {
            // Reset command writer so that we, after we've written the transaction, can ask it whether or
            // not any explicit index command was written. If so then there's additional ordering to care about below.
            _indexCommandDetector.reset();

            // The outcome of this try block is either of:
            // a) transaction successfully appended, at which point we return a Commitment to be used after force
            // b) transaction failed to be appended, at which point a kernel panic is issued
            // The reason that we issue a kernel panic on failure in here is that at this point we're still
            // holding the logFile monitor, and a failure to append needs to be communicated with potential
            // log rotation, which will wait for all transactions closed or fail on kernel panic.
            try
            {
                LogPosition logPositionBeforeCommit = _writer.getCurrentPosition(_positionMarker).newPosition();
                _transactionLogWriter.append(transaction, transactionId);
                LogPosition logPositionAfterCommit = _writer.getCurrentPosition(_positionMarker).newPosition();

                long transactionChecksum = checksum(transaction.AdditionalHeader(), transaction.MasterId, transaction.AuthorId);
                _transactionMetadataCache.cacheTransactionMetadata(transactionId, logPositionBeforeCommit, transaction.MasterId, transaction.AuthorId, transactionChecksum, transaction.TimeCommitted);

                transaction.Accept(_indexCommandDetector);
                bool hasExplicitIndexChanges = _indexCommandDetector.hasWrittenAnyExplicitIndexCommand();
                if (hasExplicitIndexChanges)
                {
                    // Offer this transaction id to the queue so that the explicit index applier can take part in the ordering
                    _explicitIndexTransactionOrdering.offer(transactionId);
                }
                return(new TransactionCommitment(hasExplicitIndexChanges, transactionId, transactionChecksum, transaction.TimeCommitted, logPositionAfterCommit, _transactionIdStore));
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final Throwable panic)
            catch (Exception panic)
            {
                _databaseHealth.panic(panic);
                throw panic;
            }
        }
Example #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void serialize(org.neo4j.kernel.impl.transaction.TransactionRepresentation tx) throws java.io.IOException
        public virtual void Serialize(TransactionRepresentation tx)
        {
            tx.Accept(_serializer);
        }