Example #1
0
        private TransactionToApply Tx(long id, long commitTimestamp)
        {
            PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(emptyList());

            representation.SetHeader(new sbyte[0], 0, 0, commitTimestamp - 10, id - 1, commitTimestamp, 0);
            return(new TransactionToApply(representation, id));
        }
Example #2
0
        private PhysicalTransactionRepresentation PhysicalTx(int lockSessionId)
        {
            PhysicalTransactionRepresentation physicalTx = mock(typeof(PhysicalTransactionRepresentation));

            when(physicalTx.LockSessionId).thenReturn(lockSessionId);
            return(physicalTx);
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            _lastSeenEventIdentifier = new AtomicInteger(-1);
            _master         = mock(typeof(Master));
            _requestContext = new RequestContext(10, 11, 12, 13, 14);
            RequestContextFactory reqFactory = new ConstantRequestContextFactoryAnonymousInnerClass(this, _requestContext);

            _response = new LongResponse(42L);
            _tx       = new PhysicalTransactionRepresentation(Collections.emptyList());
            _tx.setHeader(new sbyte[] {}, 1, 1, 1, 1, 1, 1337);

            _commitProcess = new SlaveTransactionCommitProcess(_master, reqFactory);
        }
Example #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void applyExternalTransaction(long transactionId, org.neo4j.kernel.impl.transaction.command.Command...commands) throws Exception
        private void ApplyExternalTransaction(long transactionId, params Command[] commands)
        {
            LockService lockService = mock(typeof(LockService));

            when(lockService.AcquireNodeLock(anyLong(), any(typeof(Org.Neo4j.Kernel.impl.locking.LockService_LockType)))).thenReturn(LockService.NO_LOCK);
            when(lockService.AcquireRelationshipLock(anyLong(), any(typeof(Org.Neo4j.Kernel.impl.locking.LockService_LockType)))).thenReturn(LockService.NO_LOCK);
            NeoStoreBatchTransactionApplier applier = new NeoStoreBatchTransactionApplier(_neoStores, mock(typeof(CacheAccessBackDoor)), lockService);
            TransactionRepresentation       tx      = new PhysicalTransactionRepresentation(Arrays.asList(commands));

            CommandHandlerContract.apply(applier, txApplier =>
            {
                tx.Accept(txApplier);
                return(false);
            }, new TransactionToApply(tx, transactionId));
        }
Example #5
0
        private CommittedTransactionRepresentation NewCommittedTransactionRepresentation()
        {
            const long arbitraryRecordId = 27L;

            Command.NodeCommand command = new Command.NodeCommand(new NodeRecord(arbitraryRecordId), new NodeRecord(arbitraryRecordId));

            PhysicalTransactionRepresentation physicalTransactionRepresentation = new PhysicalTransactionRepresentation(singletonList((new LogEntryCommand(command)).Command));

            physicalTransactionRepresentation.SetHeader(new sbyte[] {}, 0, 0, 0, 0, 0, 0);

            LogEntryStart  startEntry  = new LogEntryStart(0, 0, 0L, 0L, new sbyte[] {}, LogPosition.UNSPECIFIED);
            LogEntryCommit commitEntry = new LogEntryCommit(42, 0);

            return(new CommittedTransactionRepresentation(startEntry, physicalTransactionRepresentation, commitEntry));
        }
Example #6
0
//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());
        }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSuccessfullyCommitTransactionWithNoCommands() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSuccessfullyCommitTransactionWithNoCommands()
        {
            // GIVEN
            long txId            = 11;
            long commitTimestamp = DateTimeHelper.CurrentUnixTimeMillis();
            TransactionIdStore  transactionIdStore = mock(typeof(TransactionIdStore));
            TransactionAppender appender           = new TestableTransactionAppender(transactionIdStore);

            when(transactionIdStore.NextCommittingTransactionId()).thenReturn(txId);

            StorageEngine storageEngine = mock(typeof(StorageEngine));

            TransactionCommitProcess          commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine);
            PhysicalTransactionRepresentation noCommandTx   = new PhysicalTransactionRepresentation(Collections.emptyList());

            noCommandTx.SetHeader(new sbyte[0], -1, -1, -1, -1, -1, -1);

            // WHEN

            commitProcess.Commit(new TransactionToApply(noCommandTx), _commitEvent, INTERNAL);

            verify(transactionIdStore).transactionCommitted(txId, FakeCommitment.CHECKSUM, FakeCommitment.TIMESTAMP);
        }