//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void raftIndexIsRecorded() throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RaftIndexIsRecorded() { // given int txLockSessionId = Org.Neo4j.Kernel.impl.locking.Locks_Client_Fields.NO_LOCK_SESSION_ID; long anyTransactionId = 1234; long lastCommittedIndex = 1357; long updatedCommandIndex = 2468; // and ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(txLockSessionId), _batchSize, _logProvider, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY); ReplicatedTransaction replicatedTransaction = ReplicatedTransaction.from(PhysicalTx(txLockSessionId)); // and TransactionCommitProcess localCommitProcess = CreateFakeTransactionCommitProcess(anyTransactionId); // when stateMachine.InstallCommitProcess(localCommitProcess, lastCommittedIndex); // then assertEquals(lastCommittedIndex, _commandIndexTracker.AppliedCommandIndex); // when stateMachine.ApplyCommand(replicatedTransaction, updatedCommandIndex, result => { }); stateMachine.EnsuredApplied(); // then assertEquals(updatedCommandIndex, _commandIndexTracker.AppliedCommandIndex); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public long commit(final org.neo4j.kernel.impl.api.TransactionToApply tx, final org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent, org.neo4j.storageengine.api.TransactionApplicationMode mode) 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: public override long Commit(TransactionToApply tx, CommitEvent commitEvent, TransactionApplicationMode mode) { TransactionRepresentationReplicatedTransaction transaction = ReplicatedTransaction.from(tx.TransactionRepresentation()); Future <object> futureTxId; try { futureTxId = _replicator.replicate(transaction, true); } catch (ReplicationFailureException e) { throw new TransactionFailureException(ReplicationFailure, e); } try { return(( long )futureTxId.get()); } catch (ExecutionException e) { if (e.InnerException is TransactionFailureException) { throw ( TransactionFailureException )e.InnerException; } // TODO: Panic? throw new Exception(e); } catch (InterruptedException e) { // TODO Wait for the transaction to possibly finish within a user configurable time, before aborting. throw new TransactionFailureException("Interrupted while waiting for txId", e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAcceptTransactionCommittedWithNoLockManager() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAcceptTransactionCommittedWithNoLockManager() { // given int txLockSessionId = Org.Neo4j.Kernel.impl.locking.Locks_Client_Fields.NO_LOCK_SESSION_ID; int currentLockSessionId = 24; long txId = 42L; ReplicatedTransaction tx = ReplicatedTransaction.from(PhysicalTx(txLockSessionId)); TransactionCommitProcess localCommitProcess = CreateFakeTransactionCommitProcess(txId); ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(currentLockSessionId), _batchSize, _logProvider, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY); stateMachine.InstallCommitProcess(localCommitProcess, -1L); AtomicBoolean called = new AtomicBoolean(); // when stateMachine.ApplyCommand(tx, 0, result => { // then called.set(true); try { assertEquals(txId, ( long )result.consume()); } catch (Exception e) { throw new Exception(e); } }); stateMachine.EnsuredApplied(); assertTrue(called.get()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static ReplicatedTransaction unmarshal(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException public static ReplicatedTransaction Unmarshal(ReadableChannel channel) { int txBytesLength = channel.Int; sbyte[] txBytes = new sbyte[txBytesLength]; channel.Get(txBytes, txBytesLength); return(ReplicatedTransaction.from(txBytes)); }
public static ReplicatedTransaction Decode(ByteBuf byteBuf) { int length = byteBuf.readableBytes(); sbyte[] bytes = new sbyte[length]; byteBuf.readBytes(bytes); return(ReplicatedTransaction.from(bytes)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldMarshalTransactionReferenceWithMissingHeader() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldMarshalTransactionReferenceWithMissingHeader() { ByteBuf buffer = Unpooled.buffer(); PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(Collections.emptyList()); TransactionRepresentationReplicatedTransaction replicatedTx = ReplicatedTransaction.from(representation); AssertMarshalingEquality(buffer, replicatedTx); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Parameterized.Parameters(name = "{0}") public static org.neo4j.causalclustering.core.replication.ReplicatedContent[] data() public static ReplicatedContent[] Data() { return(new ReplicatedContent[] { new DummyRequest(new sbyte[] { 1, 2, 3 }), ReplicatedTransaction.from(new sbyte[16 * 1024]), new MemberIdSet(new HashSet <MemberId>() { { add(new MemberId(System.Guid.randomUUID())); } }),
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowExceptionIfNotAllResourcesAreUsed() public virtual void ShouldThrowExceptionIfNotAllResourcesAreUsed() { try { RaftMessageComposer raftMessageComposer = new RaftMessageComposer(Clock.systemUTC()); ReplicatedTransaction replicatedTransaction = ReplicatedTransaction.from(new sbyte[0]); raftMessageComposer.Decode(null, replicatedTransaction, null); IList <object> @out = new List <object>(); raftMessageComposer.Decode(null, MessageCreator((a, b) => DummyRequest()), @out); } catch (System.InvalidOperationException e) { assertThat(e.Message, containsString("was composed without using all resources in the pipeline. Pipeline still contains Replicated contents")); return; } fail(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldMarshalToSameByteIfByteBufBackedOrNot() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldMarshalToSameByteIfByteBufBackedOrNot() { PhysicalTransactionRepresentation expectedTx = new PhysicalTransactionRepresentation(Collections.singleton(new Command.NodeCommand(new NodeRecord(1), new NodeRecord(2)))); expectedTx.SetHeader(new sbyte[0], 1, 2, 3, 4, 5, 6); TransactionRepresentationReplicatedTransaction replicatedTransaction = ReplicatedTransaction.from(expectedTx); MemoryStream stream = new MemoryStream(); ByteBuf buffer = Buffers.buffer(); OutputStreamWritableChannel outputStreamWritableChannel = new OutputStreamWritableChannel(stream); NetworkWritableChannel networkWritableChannel = new NetworkWritableChannel(buffer); replicatedTransaction.Marshal(outputStreamWritableChannel); replicatedTransaction.Marshal(networkWritableChannel); sbyte[] bufferArray = Arrays.copyOf(buffer.array(), buffer.writerIndex()); Assertions.assertArrayEquals(bufferArray, stream.toByteArray()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailFutureForTransactionCommittedUnderWrongLockSession() public virtual void ShouldFailFutureForTransactionCommittedUnderWrongLockSession() { // given int txLockSessionId = 23; int currentLockSessionId = 24; ReplicatedTransaction tx = ReplicatedTransaction.from(PhysicalTx(txLockSessionId)); TransactionCommitProcess localCommitProcess = mock(typeof(TransactionCommitProcess)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(commandIndexTracker, lockState(currentLockSessionId), batchSize, logProvider, org.neo4j.io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.NULL, org.neo4j.io.pagecache.tracing.cursor.context.EmptyVersionContextSupplier.EMPTY); ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(currentLockSessionId), _batchSize, _logProvider, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY); stateMachine.InstallCommitProcess(localCommitProcess, -1L); AtomicBoolean called = new AtomicBoolean(); // when stateMachine.ApplyCommand(tx, 0, result => { // then called.set(true); try { result.consume(); fail("should have thrown"); } catch (TransactionFailureException tfe) { assertEquals(Status.Transaction.LockSessionExpired, tfe.status()); } catch (Exception e) { throw new Exception(e); } }); stateMachine.EnsuredApplied(); assertTrue(called.get()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCommitTransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCommitTransaction() { // given int lockSessionId = 23; ReplicatedTransaction tx = ReplicatedTransaction.from(PhysicalTx(lockSessionId)); TransactionCommitProcess localCommitProcess = mock(typeof(TransactionCommitProcess)); PageCursorTracer cursorTracer = mock(typeof(PageCursorTracer)); ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(lockSessionId), _batchSize, _logProvider, () => cursorTracer, EmptyVersionContextSupplier.EMPTY); stateMachine.InstallCommitProcess(localCommitProcess, -1L); // when stateMachine.ApplyCommand(tx, 0, r => { }); stateMachine.EnsuredApplied(); // then verify(localCommitProcess, times(1)).commit(any(typeof(TransactionToApply)), any(typeof(CommitEvent)), any(typeof(TransactionApplicationMode))); verify(cursorTracer, times(1)).reportEvents(); }
private ReplicatedTransaction Tx(sbyte dataValue) { sbyte[] dataArray = new sbyte[30]; Arrays.fill(dataArray, dataValue); return(ReplicatedTransaction.from(dataArray)); }