/// <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; } }
private LogCreator LogFile(params Entry[] entries) { return((logVersion, positions) => { try { AtomicLong lastTxId = new AtomicLong(); _logVersionRepository.CurrentLogVersion = logVersion; LifeSupport logFileLife = new LifeSupport(); logFileLife.start(); logFileLife.add(_logFiles); LogFile logFile = _logFiles.LogFile; try { FlushablePositionAwareChannel writeChannel = logFile.Writer; LogPositionMarker positionMarker = new LogPositionMarker(); LogEntryWriter writer = new LogEntryWriter(writeChannel); foreach (Entry entry in entries) { LogPosition currentPosition = writeChannel.getCurrentPosition(positionMarker).newPosition(); positions.put(entry, currentPosition); if (entry is StartEntry) { writer.writeStartEntry(0, 0, 0, 0, new sbyte[0]); } else if (entry is CommitEntry) { CommitEntry commitEntry = ( CommitEntry )entry; writer.writeCommitEntry(commitEntry.TxId, 0); lastTxId.set(commitEntry.TxId); } else if (entry is CheckPointEntry) { CheckPointEntry checkPointEntry = ( CheckPointEntry )entry; Entry target = checkPointEntry.WithPositionOfEntry; LogPosition logPosition = target != null?positions.get(target) : currentPosition; Debug.Assert(logPosition != null, "No registered log position for " + target); writer.writeCheckPointEntry(logPosition); } else if (entry is PositionEntry) { // Don't write anything, this entry is just for registering a position so that // another CheckPointEntry can refer to it } else { throw new System.ArgumentException("Unknown entry " + entry); } } } finally { logFileLife.shutdown(); } } catch (IOException e) { throw new UncheckedIOException(e); } }); }