Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void endLockSessionDoesNotUnpackResponse() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void EndLockSessionDoesNotUnpackResponse()
        {
            StoreId storeId       = new StoreId(1, 2, 3, 4, 5);
            long    txChecksum    = 123;
            long    lastAppliedTx = 5;

            ResponseUnpacker responseUnpacker = mock(typeof(ResponseUnpacker));

            MasterImpl.SPI masterImplSPI = MasterImplTest.mockedSpi(storeId);
            when(masterImplSPI.PackTransactionObligationResponse(any(typeof(RequestContext)), ArgumentMatchers.any())).thenReturn(Response.empty());
            when(masterImplSPI.GetTransactionChecksum(anyLong())).thenReturn(txChecksum);

            NewMasterServer(masterImplSPI);

            MasterClient client = NewMasterClient320(storeId, responseUnpacker);

            HandshakeResult handshakeResult;

            using (Response <HandshakeResult> handshakeResponse = client.Handshake(1, storeId))
            {
                handshakeResult = handshakeResponse.ResponseConflict();
            }
            verify(responseUnpacker).unpackResponse(any(typeof(Response)), any(typeof(TxHandler)));
            reset(responseUnpacker);

            RequestContext context = new RequestContext(handshakeResult.Epoch(), 1, 1, lastAppliedTx, txChecksum);

            client.EndLockSession(context, false);
            verify(responseUnpacker, never()).unpackResponse(any(typeof(Response)), any(typeof(TxHandler)));
        }
Example #2
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)));
        }
Example #3
0
        private void ShouldGatherForensicsInFullBackupRequest(bool forensics)
        {
            // GIVEN
            Response <Void> response = Response.empty();
            StoreId         storeId  = response.StoreId;
            string          host     = "localhost";
            int             port     = PortAuthority.allocatePort();
            LifeSupport     life     = new LifeSupport();

            LogEntryReader <ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            NullLogProvider    logProvider        = NullLogProvider.Instance;
            ResponseUnpacker   responseUnpacker   = mock(typeof(ResponseUnpacker));
            ByteCounterMonitor byteCounterMonitor = mock(typeof(ByteCounterMonitor));
            RequestMonitor     requestMonitor     = mock(typeof(RequestMonitor));
            BackupClient       client             = new BackupClient(host, port, null, logProvider, storeId, 10_000, responseUnpacker, byteCounterMonitor, requestMonitor, reader);

            life.Add(client);
            ControlledBackupInterface backup = new ControlledBackupInterface();
            HostnamePort hostnamePort        = new HostnamePort(host, port);

            life.Add(new BackupServer(backup, hostnamePort, logProvider, byteCounterMonitor, requestMonitor));
            life.Start();

            try
            {
                // WHEN
                StoreWriter writer = mock(typeof(StoreWriter));
                client.FullBackup(writer, forensics);

                // THEN
                assertEquals(forensics, backup.ReceivedForensics);
            }
            finally
            {
                life.Shutdown();
            }
        }
Example #4
0
 public MasterClient310(string destinationHostNameOrIp, int destinationPort, string originHostNameOrIp, LogProvider logProvider, StoreId storeId, long readTimeoutMillis, long lockReadTimeout, int maxConcurrentChannels, int chunkSize, ResponseUnpacker unpacker, ByteCounterMonitor byteCounterMonitor, RequestMonitor requestMonitor, LogEntryReader <ReadableClosablePositionAwareChannel> entryReader) : base(destinationHostNameOrIp, destinationPort, originHostNameOrIp, logProvider, storeId, readTimeoutMillis, lockReadTimeout, maxConcurrentChannels, chunkSize, unpacker, byteCounterMonitor, requestMonitor, entryReader)
 {
 }
Example #5
0
        private MasterClient NewMasterClient320(StoreId storeId, ResponseUnpacker responseUnpacker)
        {
//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 MasterClient320(MASTER_SERVER_HOST, MASTER_SERVER_PORT, null, NullLogProvider.Instance, storeId, TIMEOUT, TIMEOUT, 1, CHUNK_SIZE, responseUnpacker, _monitors.newMonitor(typeof(ByteCounterMonitor), typeof(MasterClient320).FullName), _monitors.newMonitor(typeof(RequestMonitor), typeof(MasterClient320).FullName), _logEntryReader)));
        }
Example #6
0
 public MasterClient214(string destinationHostNameOrIp, int destinationPort, string originHostNameOrIp, LogProvider logProvider, StoreId storeId, long readTimeoutMillis, long lockReadTimeoutMillis, int maxConcurrentChannels, int chunkSize, ResponseUnpacker responseUnpacker, ByteCounterMonitor byteCounterMonitor, RequestMonitor requestMonitor, LogEntryReader <ReadableClosablePositionAwareChannel> entryReader) : base(destinationHostNameOrIp, destinationPort, originHostNameOrIp, logProvider, storeId, MasterServer.FRAME_LENGTH, readTimeoutMillis, maxConcurrentChannels, chunkSize, responseUnpacker, byteCounterMonitor, requestMonitor, entryReader)
 {
     this._lockReadTimeoutMillis  = lockReadTimeoutMillis;
     this._requestTypes           = new HaRequestType210(entryReader, CreateLockResultSerializer());
     this._lockResultDeserializer = CreateLockResultDeserializer();
 }