Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void clientShouldReadAndApplyTransactionLogsOnNewLockSessionRequest() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ClientShouldReadAndApplyTransactionLogsOnNewLockSessionRequest()
        {
            // Given
            MasterImpl master = spy(NewMasterImpl(MockMasterImplSpiWith(StoreId.DEFAULT)));

            doReturn(VoidResponseWithTransactionLogs()).when(master).newLockSession(any(typeof(RequestContext)));

            NewMasterServer(master);

            TransactionCommittingResponseUnpacker.Dependencies deps = mock(typeof(TransactionCommittingResponseUnpacker.Dependencies));
            TransactionCommitProcess commitProcess = mock(typeof(TransactionCommitProcess));

            when(deps.CommitProcess()).thenReturn(commitProcess);
            when(deps.LogService()).thenReturn(NullLogService.Instance);
            when(deps.VersionContextSupplier()).thenReturn(EmptyVersionContextSupplier.EMPTY);
            KernelTransactions transactions = mock(typeof(KernelTransactions));

            when(deps.KernelTransactions()).thenReturn(transactions);

            ResponseUnpacker unpacker = Life.add(new TransactionCommittingResponseUnpacker(deps, DEFAULT_BATCH_SIZE, 0));

            MasterClient masterClient = NewMasterClient320(StoreId.DEFAULT, unpacker);

            // When
            masterClient.NewLockSession(new RequestContext(1, 2, 3, 4, 5));

            // Then
            verify(commitProcess).commit(any(typeof(TransactionToApply)), any(typeof(CommitEvent)), any(typeof(TransactionApplicationMode)));
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailSubsequentRequestsAfterAllocateIdsAfterMasterSwitch() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailSubsequentRequestsAfterAllocateIdsAfterMasterSwitch()
        {
            // GIVEN
            MasterImpl.SPI spi = MasterImplTest.mockedSpi();
            IdAllocation   servedIdAllocation = IdAllocation(0, 999);

            when(spi.AllocateIds(any(typeof(IdType)))).thenReturn(servedIdAllocation);
            when(spi.GetTransactionChecksum(anyLong())).thenReturn(10L);
            StoreId         storeId   = newStoreIdForCurrentVersion();
            MasterImpl      master    = new MasterImpl(spi, mock(typeof(ConversationManager)), mock(typeof(MasterImpl.Monitor)), Config.defaults(ClusterSettings.server_id, "1"));
            HandshakeResult handshake = master.Handshake(1, storeId).response();

            master.Start();

            // WHEN/THEN
            IdAllocation idAllocation = master.AllocateIds(Context(handshake.Epoch()), IdType.NODE).response();

            assertEquals(servedIdAllocation.HighestIdInUse, idAllocation.HighestIdInUse);
            try
            {
                master.AllocateIds(Context(handshake.Epoch() + 1), IdType.NODE);
                fail("Should fail with invalid epoch");
            }
            catch (InvalidEpochException)
            {               // Good
            }
        }
Esempio n. 3
0
        private MasterServer NewMasterServer(MasterImpl masterImpl)
        {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            return(Life.add(new MasterServer(masterImpl, NullLogProvider.Instance, MasterServerConfiguration(), mock(typeof(TxChecksumVerifier)), _monitors.newMonitor(typeof(ByteCounterMonitor), typeof(MasterClient).FullName), _monitors.newMonitor(typeof(RequestMonitor), typeof(MasterClient).FullName), mock(typeof(ConversationManager)), _logEntryReader)));
        }
Esempio n. 4
0
        private MasterServer NewMasterServer(MasterImpl.SPI masterImplSPI)
        {
            MasterImpl masterImpl = new MasterImpl(masterImplSPI, mock(typeof(ConversationManager)), mock(typeof(MasterImpl.Monitor)), MasterConfig());

            return(NewMasterServer(masterImpl));
        }