public override long Commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode) { Debug.Assert(Transaction == null, "Designed to only allow one transaction"); Debug.Assert(batch.Next() == null, "Designed to only allow one transaction"); Transaction = batch.TransactionRepresentation(); return(++TxId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAppendSingleTransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAppendSingleTransaction() { // GIVEN when(_logFile.Writer).thenReturn(_channel); long txId = 15; when(_transactionIdStore.nextCommittingTransactionId()).thenReturn(txId); TransactionAppender appender = Life.add(CreateTransactionAppender()); // WHEN TransactionRepresentation transaction = transaction(SingleCreateNodeCommand(0), new sbyte[] { 1, 2, 5 }, 2, 1, 12345, 4545, 12345 + 10); appender.Append(new TransactionToApply(transaction), _logAppendEvent); // THEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader<ReadableLogChannel> logEntryReader = new org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader<>(); LogEntryReader <ReadableLogChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableLogChannel>(); using (PhysicalTransactionCursor <ReadableLogChannel> reader = new PhysicalTransactionCursor <ReadableLogChannel>(_channel, logEntryReader)) { reader.Next(); TransactionRepresentation tx = reader.Get().TransactionRepresentation; assertArrayEquals(transaction.AdditionalHeader(), tx.AdditionalHeader()); assertEquals(transaction.MasterId, tx.MasterId); assertEquals(transaction.AuthorId, tx.AuthorId); assertEquals(transaction.TimeStarted, tx.TimeStarted); assertEquals(transaction.TimeCommitted, tx.TimeCommitted); assertEquals(transaction.LatestCommittedTxWhenStarted, tx.LatestCommittedTxWhenStarted); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSerializeAndDeserializeTransactionRepresentation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSerializeAndDeserializeTransactionRepresentation() { // GIVEN PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation(JustOneNode()); sbyte[] additionalHeader = "extra".GetBytes(); int masterId = 1; int authorId = 2; long timeStarted = 12345; long lastTxWhenStarted = 12; long timeCommitted = timeStarted + 10; transaction.SetHeader(additionalHeader, masterId, authorId, timeStarted, lastTxWhenStarted, timeCommitted, -1); Protocol.TransactionSerializer serializer = new Protocol.TransactionSerializer(transaction); ChannelBuffer buffer = new ChannelBufferWrapper(new InMemoryClosableChannel()); // WHEN serializing the transaction serializer.Write(buffer); // THEN deserializing the same transaction should yield the same data. // ... remember that this deserializer doesn't read the data source name string. Read it manually here assertEquals(NeoStoreDataSource.DEFAULT_DATA_SOURCE_NAME, Protocol.ReadString(buffer)); VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(); TransactionRepresentation readTransaction = (new Protocol.TransactionRepresentationDeserializer(reader)).Read(buffer, ByteBuffer.allocate(1000)); assertArrayEquals(additionalHeader, readTransaction.AdditionalHeader()); assertEquals(masterId, readTransaction.MasterId); assertEquals(authorId, readTransaction.AuthorId); assertEquals(timeStarted, readTransaction.TimeStarted); assertEquals(lastTxWhenStarted, readTransaction.LatestCommittedTxWhenStarted); assertEquals(timeCommitted, readTransaction.TimeCommitted); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAllowCommitIfClientHoldsNoLocks() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAllowCommitIfClientHoldsNoLocks() { // Given MasterImpl.SPI spi = mock(typeof(MasterImpl.SPI)); Config config = config(); DefaultConversationSPI conversationSpi = MockedConversationSpi(); ConversationManager conversationManager = new ConversationManager(conversationSpi, config); when(spi.Accessible).thenReturn(true); when(spi.GetTransactionChecksum(anyLong())).thenReturn(1L); MockEmptyResponse(spi); MasterImpl master = new MasterImpl(spi, conversationManager, mock(typeof(MasterImpl.Monitor)), config); master.Start(); HandshakeResult handshake = master.Handshake(1, newStoreIdForCurrentVersion()).response(); const int noLockSession = -1; RequestContext ctx = new RequestContext(handshake.Epoch(), 1, noLockSession, 0, 0); TransactionRepresentation tx = mock(typeof(TransactionRepresentation)); // When master.Commit(ctx, tx); // Then verify(spi).applyPreparedTransaction(tx); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotCallTransactionClosedOnFailedAppendedTransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotCallTransactionClosedOnFailedAppendedTransaction() { // GIVEN long txId = 3; string failureMessage = "Forces a failure"; FlushablePositionAwareChannel channel = spy(new PositionAwarePhysicalFlushableChannel(mock(typeof(PhysicalLogVersionedStoreChannel)))); IOException failure = new IOException(failureMessage); when(channel.PutInt(anyInt())).thenThrow(failure); when(_logFile.Writer).thenReturn(channel); when(_transactionIdStore.nextCommittingTransactionId()).thenReturn(txId); Mockito.reset(_databaseHealth); TransactionAppender appender = Life.add(CreateTransactionAppender()); // WHEN TransactionRepresentation transaction = mock(typeof(TransactionRepresentation)); when(transaction.AdditionalHeader()).thenReturn(new sbyte[0]); try { appender.Append(new TransactionToApply(transaction), _logAppendEvent); fail("Expected append to fail. Something is wrong with the test itself"); } catch (IOException e) { // THEN assertSame(failure, e); verify(_transactionIdStore, times(1)).nextCommittingTransactionId(); verify(_transactionIdStore, never()).transactionClosed(eq(txId), anyLong(), anyLong()); verify(_databaseHealth).panic(failure); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void verifyTransaction(TransactionIdStore transactionIdStore, TransactionMetadataCache positionCache, byte[] additionalHeader, int masterId, int authorId, long timeStarted, long latestCommittedTxWhenStarted, long timeCommitted, LogicalTransactionStore store) throws java.io.IOException private void VerifyTransaction(TransactionIdStore transactionIdStore, TransactionMetadataCache positionCache, sbyte[] additionalHeader, int masterId, int authorId, long timeStarted, long latestCommittedTxWhenStarted, long timeCommitted, LogicalTransactionStore store) { TransactionMetadata expectedMetadata; using (TransactionCursor cursor = store.GetTransactions(TransactionIdStore_Fields.BASE_TX_ID + 1)) { bool hasNext = cursor.next(); assertTrue(hasNext); CommittedTransactionRepresentation tx = cursor.get(); TransactionRepresentation transaction = tx.TransactionRepresentation; assertArrayEquals(additionalHeader, transaction.AdditionalHeader()); assertEquals(masterId, transaction.MasterId); assertEquals(authorId, transaction.AuthorId); assertEquals(timeStarted, transaction.TimeStarted); assertEquals(timeCommitted, transaction.TimeCommitted); assertEquals(latestCommittedTxWhenStarted, transaction.LatestCommittedTxWhenStarted); expectedMetadata = new TransactionMetadata(masterId, authorId, tx.StartEntry.StartPosition, tx.StartEntry.checksum(), timeCommitted); } positionCache.Clear(); TransactionMetadata actualMetadata = store.GetMetadataFor(transactionIdStore.LastCommittedTransactionId); assertEquals(expectedMetadata, actualMetadata); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void append(org.neo4j.kernel.impl.transaction.TransactionRepresentation transaction, long transactionId) throws java.io.IOException public virtual void Append(TransactionRepresentation transaction, long transactionId) { _writer.writeStartEntry(transaction.MasterId, transaction.AuthorId, transaction.TimeStarted, transaction.LatestCommittedTxWhenStarted, transaction.AdditionalHeader()); // Write all the commands to the log channel _writer.serialize(transaction); // Write commit record _writer.writeCommitEntry(transactionId, transaction.TimeCommitted); }
public override bool Visit(CommittedTransactionRepresentation tx) { TransactionRepresentation transaction = tx.TransactionRepresentation; assertArrayEquals(AdditionalHeader, transaction.AdditionalHeader()); assertEquals(MasterId, transaction.MasterId); assertEquals(AuthorId, transaction.AuthorId); assertEquals(TimeStarted, transaction.TimeStarted); assertEquals(TimeCommitted, transaction.TimeCommitted); assertEquals(LatestCommittedTxWhenStarted, transaction.LatestCommittedTxWhenStarted); VisitedTransactionsConflict++; return(false); }
public override string ToString() { TransactionRepresentation tr = this._transactionRepresentation; return("Transaction #" + _transactionId + (_logPosition != null ? " at log position " + _logPosition : " (no log position)") + " {started " + date(tr.TimeStarted) + ", committed " + date(tr.TimeCommitted) + ", with " + CountCommands() + " commands in this transaction" + ", authored by " + tr.AuthorId + ", with master id " + tr.MasterId + ", lock session " + tr.LockSessionId + ", latest committed transaction id when started was " + tr.LatestCommittedTxWhenStarted + ", additional header bytes: " + HexPrinter.hex(tr.AdditionalHeader(), int.MaxValue, "") + "}"); }
private CommittedTransactionRepresentation CreateTxWithId(long txId) { CommittedTransactionRepresentation tx = mock(typeof(CommittedTransactionRepresentation)); LogEntryCommit commitEntry = mock(typeof(LogEntryCommit)); when(commitEntry.TxId).thenReturn(txId); TransactionRepresentation txRep = mock(typeof(TransactionRepresentation)); sbyte[] encodedRaftLogIndex = encodeLogIndexAsTxHeader(txId - 5); // just some arbitrary offset when(txRep.AdditionalHeader()).thenReturn(encodedRaftLogIndex); when(tx.TransactionRepresentation).thenReturn(txRep); when(tx.CommitEntry).thenReturn(commitEntry); return(tx); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static org.neo4j.kernel.impl.api.TransactionToApply newTransactionThatFailsWith(Exception error) throws java.io.IOException private static TransactionToApply NewTransactionThatFailsWith(Exception error) { TransactionRepresentation transaction = mock(typeof(TransactionRepresentation)); when(transaction.AdditionalHeader()).thenReturn(new sbyte[0]); // allow to build validated index updates but fail on actual tx application doThrow(error).when(transaction).accept(any()); long txId = ThreadLocalRandom.current().nextLong(0, 1000); TransactionToApply txToApply = new TransactionToApply(transaction); FakeCommitment commitment = new FakeCommitment(txId, mock(typeof(TransactionIdStore))); commitment.HasExplicitIndexChanges = false; txToApply.Commitment(commitment, txId); return(txToApply); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private long applyTransactions(java.io.File fromPath, org.neo4j.kernel.internal.GraphDatabaseAPI toDb, org.neo4j.kernel.configuration.Config toConfig, long fromTxExclusive, long toTxInclusive, java.io.PrintStream out) throws Exception private long ApplyTransactions( File fromPath, GraphDatabaseAPI toDb, Config toConfig, long fromTxExclusive, long toTxInclusive, PrintStream @out ) { DependencyResolver resolver = toDb.DependencyResolver; TransactionRepresentationCommitProcess commitProcess = new TransactionRepresentationCommitProcess( resolver.ResolveDependency( typeof( TransactionAppender ) ), resolver.ResolveDependency( typeof( StorageEngine ) ) ); LifeSupport life = new LifeSupport(); try { using ( DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), JobScheduler jobScheduler = createInitialisedScheduler(), PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem, jobScheduler) ) { LogicalTransactionStore source = life.Add( new ReadOnlyTransactionStore( pageCache, fileSystem, DatabaseLayout.of( fromPath ), Config.defaults(), new Monitors() ) ); life.Start(); long lastAppliedTx = fromTxExclusive; // Some progress if there are more than a couple of transactions to apply ProgressListener progress = toTxInclusive - fromTxExclusive >= 100 ? textual( @out ).singlePart( "Application progress", toTxInclusive - fromTxExclusive ) : Org.Neo4j.Helpers.progress.ProgressListener_Fields.None; using ( IOCursor<CommittedTransactionRepresentation> cursor = source.GetTransactions( fromTxExclusive + 1 ) ) { while ( cursor.next() ) { CommittedTransactionRepresentation transaction = cursor.get(); TransactionRepresentation transactionRepresentation = transaction.TransactionRepresentation; try { commitProcess.Commit( new TransactionToApply( transactionRepresentation ), NULL, EXTERNAL ); progress.Add( 1 ); } //JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#: //ORIGINAL LINE: catch (final Throwable e) catch ( Exception e ) { Console.Error.WriteLine( "ERROR applying transaction " + transaction.CommitEntry.TxId ); throw e; } lastAppliedTx = transaction.CommitEntry.TxId; if ( lastAppliedTx == toTxInclusive ) { break; } } } return lastAppliedTx; } } finally { life.Shutdown(); } }
//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"); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertMarshalingEquality(io.netty.buffer.ByteBuf buffer, org.neo4j.causalclustering.core.state.machines.tx.TransactionRepresentationReplicatedTransaction replicatedTx) throws java.io.IOException, org.neo4j.causalclustering.messaging.EndOfStreamException private void AssertMarshalingEquality(ByteBuf buffer, TransactionRepresentationReplicatedTransaction replicatedTx) { _marshal.marshal(replicatedTx, new NetworkWritableChannel(buffer)); ReplicatedContent unmarshal = _marshal.unmarshal(new NetworkReadableClosableChannelNetty4(buffer)); TransactionRepresentation tx = replicatedTx.Tx(); sbyte[] extraHeader = tx.AdditionalHeader(); if (extraHeader == null) { // hackishly set additional header to empty array... (( PhysicalTransactionRepresentation )tx).setHeader(new sbyte[0], tx.MasterId, tx.AuthorId, tx.TimeStarted, tx.LatestCommittedTxWhenStarted, tx.TimeCommitted, tx.LockSessionId); extraHeader = tx.AdditionalHeader(); } TransactionRepresentation representation = ReplicatedTransactionFactory.extractTransactionRepresentation(( ReplicatedTransaction )unmarshal, extraHeader); assertThat(representation, equalTo(tx)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAppendCommittedTransactions() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAppendCommittedTransactions() { // GIVEN when(_logFile.Writer).thenReturn(_channel); long nextTxId = 15; when(_transactionIdStore.nextCommittingTransactionId()).thenReturn(nextTxId); TransactionAppender appender = Life.add(new BatchingTransactionAppender(_logFiles, NO_ROTATION, _positionCache, _transactionIdStore, BYPASS, _databaseHealth)); // WHEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte[] additionalHeader = new byte[]{1, 2, 5}; sbyte[] additionalHeader = new sbyte[] { 1, 2, 5 }; const int masterId = 2; int authorId = 1; const long timeStarted = 12345; long latestCommittedTxWhenStarted = nextTxId - 5; long timeCommitted = timeStarted + 10; PhysicalTransactionRepresentation transactionRepresentation = new PhysicalTransactionRepresentation(SingleCreateNodeCommand(0)); transactionRepresentation.SetHeader(additionalHeader, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted, -1); LogEntryStart start = new LogEntryStart(0, 0, 0L, latestCommittedTxWhenStarted, null, LogPosition.UNSPECIFIED); LogEntryCommit commit = new LogEntryCommit(nextTxId, 0L); CommittedTransactionRepresentation transaction = new CommittedTransactionRepresentation(start, transactionRepresentation, commit); appender.Append(new TransactionToApply(transactionRepresentation, transaction.CommitEntry.TxId), _logAppendEvent); // THEN LogEntryReader <ReadableLogChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableLogChannel>(); using (PhysicalTransactionCursor <ReadableLogChannel> reader = new PhysicalTransactionCursor <ReadableLogChannel>(_channel, logEntryReader)) { reader.Next(); TransactionRepresentation result = reader.Get().TransactionRepresentation; assertArrayEquals(additionalHeader, result.AdditionalHeader()); assertEquals(masterId, result.MasterId); assertEquals(authorId, result.AuthorId); assertEquals(timeStarted, result.TimeStarted); assertEquals(timeCommitted, result.TimeCommitted); assertEquals(latestCommittedTxWhenStarted, result.LatestCommittedTxWhenStarted); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotCallTransactionClosedOnFailedForceLogToDisk() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotCallTransactionClosedOnFailedForceLogToDisk() { // GIVEN long txId = 3; string failureMessage = "Forces a failure"; FlushablePositionAwareChannel channel = spy(new InMemoryClosableChannel()); IOException failure = new IOException(failureMessage); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.io.Flushable flushable = mock(java.io.Flushable.class); Flushable flushable = mock(typeof(Flushable)); doAnswer(invocation => { invocation.callRealMethod(); return(flushable); }).when(channel).prepareForFlush(); doThrow(failure).when(flushable).flush(); when(_logFile.Writer).thenReturn(channel); TransactionMetadataCache metadataCache = new TransactionMetadataCache(); TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore)); when(transactionIdStore.NextCommittingTransactionId()).thenReturn(txId); Mockito.reset(_databaseHealth); TransactionAppender appender = Life.add(new BatchingTransactionAppender(_logFiles, NO_ROTATION, metadataCache, transactionIdStore, BYPASS, _databaseHealth)); // WHEN TransactionRepresentation transaction = mock(typeof(TransactionRepresentation)); when(transaction.AdditionalHeader()).thenReturn(new sbyte[0]); try { appender.Append(new TransactionToApply(transaction), _logAppendEvent); fail("Expected append to fail. Something is wrong with the test itself"); } catch (IOException e) { // THEN assertSame(failure, e); verify(transactionIdStore, times(1)).nextCommittingTransactionId(); verify(transactionIdStore, never()).transactionClosed(eq(txId), anyLong(), anyLong()); verify(_databaseHealth).panic(failure); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldIncludeRandomBytesInAdditionalHeader() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldIncludeRandomBytesInAdditionalHeader() { // Given TransactionRepresentation[] transactionRepresentation = new TransactionRepresentation[1]; KernelTransactions registry = NewKernelTransactions(NewRememberingCommitProcess(transactionRepresentation)); // When using (KernelTransaction transaction = GetKernelTransaction(registry)) { // Just pick anything that can flag that changes have been made to this transaction (( KernelTransactionImplementation )transaction).TxState().nodeDoCreate(0); transaction.Success(); } // Then sbyte[] additionalHeader = transactionRepresentation[0].AdditionalHeader(); assertNotNull(additionalHeader); assertTrue(additionalHeader.Length > 0); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.com.Response<long> commit(org.neo4j.com.RequestContext context, org.neo4j.kernel.impl.transaction.TransactionRepresentation preparedTransaction) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException public override Response <long> Commit(RequestContext context, TransactionRepresentation preparedTransaction) { AssertCorrectEpoch(context); // There are two constraints relating to locking during commit: // 1) If the client is has grabbed locks, we need to ensure those locks remain live during commit // 2) We must hold a schema read lock while committing, to not race with schema transactions on the master // // To satisfy this, we must determine if the client is holding locks, and if so, use that lock client, and if // not, we use a one-off lock client. The way the client signals this is via the 'eventIdentifier' in the // request. -1 means no locks are held, any other number means there should be a matching lock session. if (context.EventIdentifier == Org.Neo4j.Kernel.impl.locking.Locks_Client_Fields.NO_LOCK_SESSION_ID) { // Client is not holding locks, use a temporary lock client using (Conversation conversation = _conversationManager.acquire()) { return(Commit0(context, preparedTransaction)); } } else { // Client is holding locks, use the clients lock session try { Conversation conversation = _conversationManager.acquire(context); try { return(Commit0(context, preparedTransaction)); } finally { _conversationManager.release(context); } } catch (Exception e) when(e is NoSuchEntryException || e is ConcurrentAccessException) { throw new TransactionNotPresentOnMasterException(context); } } }
/// <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; } }
internal TransactionRepresentationWriter(TransactionRepresentation tx) { NextJob = channel => { channel.putInt(tx.AuthorId); channel.putInt(tx.MasterId); channel.putLong(tx.LatestCommittedTxWhenStarted); channel.putLong(tx.TimeStarted); channel.putLong(tx.TimeCommitted); channel.putInt(tx.LockSessionId); sbyte[] additionalHeader = tx.AdditionalHeader(); if (additionalHeader != null) { channel.putInt(additionalHeader.Length); channel.put(additionalHeader, additionalHeader.Length); } else { channel.putInt(0); } }; Commands = tx.GetEnumerator(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.com.Response<long> commit0(org.neo4j.com.RequestContext context, org.neo4j.kernel.impl.transaction.TransactionRepresentation preparedTransaction) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException private Response <long> Commit0(RequestContext context, TransactionRepresentation preparedTransaction) { long txId = _spi.applyPreparedTransaction(preparedTransaction); return(_spi.packTransactionObligationResponse(context, txId)); }
//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); }
public CommittedTransactionRepresentation(LogEntryStart startEntry, TransactionRepresentation transactionRepresentation, LogEntryCommit commitEntry) { this._startEntry = startEntry; this._transactionRepresentation = transactionRepresentation; this._commitEntry = commitEntry; }
/// <summary> /// Used when committing a transaction that hasn't already gotten a transaction id assigned. /// </summary> public TransactionToApply(TransactionRepresentation transactionRepresentation, VersionContext versionContext) : this(transactionRepresentation, TRANSACTION_ID_NOT_SPECIFIED, versionContext) { }
public TransactionToApply(TransactionRepresentation transactionRepresentation, long transactionId) : this(transactionRepresentation, transactionId, EmptyVersionContext.EMPTY) { }
internal ChunkedTransaction(TransactionRepresentation tx) { _txWriter = ReplicatedTransactionFactory.TransactionalRepresentationWriter(tx); }
public static TransactionRepresentationWriter TransactionalRepresentationWriter(TransactionRepresentation transactionCommand) { return(new TransactionRepresentationWriter(transactionCommand)); }
public TransactionToApply(TransactionRepresentation transactionRepresentation, long transactionId, VersionContext versionContext) { this._transactionRepresentation = transactionRepresentation; this._transactionId = transactionId; this._versionContext = versionContext; }
public override long ApplyPreparedTransaction(TransactionRepresentation preparedTransaction) { // sleeping here and hope to be noticed by conversation killer. Sleep(); return(0); }
public TransactionSerializer(TransactionRepresentation tx) { this.Tx = tx; }