//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 shouldAllowStartNewTransactionAfterClientSessionWasRemovedOnTimeout() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAllowStartNewTransactionAfterClientSessionWasRemovedOnTimeout() { //Given MasterImpl.SPI spi = MockedSpi(); DefaultConversationSPI conversationSpi = MockedConversationSpi(); Monitor monitor = mock(typeof(Monitor)); Config config = config(); Locks_Client client = mock(typeof(Locks_Client)); ConversationManager conversationManager = new ConversationManager(conversationSpi, config); int machineId = 1; MasterImpl master = new MasterImpl(spi, conversationManager, monitor, config); when(spi.Accessible).thenReturn(true); when(conversationSpi.AcquireClient()).thenReturn(client); master.Start(); HandshakeResult handshake = master.Handshake(1, newStoreIdForCurrentVersion()).response(); RequestContext requestContext = new RequestContext(handshake.Epoch(), machineId, 0, 0, 0); // When master.NewLockSession(requestContext); master.AcquireSharedLock(requestContext, ResourceTypes.NODE, 1L); conversationManager.Stop(requestContext); master.NewLockSession(requestContext); //Then IDictionary <int, ICollection <RequestContext> > transactions = master.OngoingTransactions; assertEquals(1, transactions.Count); assertThat(transactions[machineId], org.hamcrest.Matchers.hasItem(requestContext)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void failingToStartTxShouldNotLeadToNPE() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void FailingToStartTxShouldNotLeadToNPE() { // Given MasterImpl.SPI spi = MockedSpi(); DefaultConversationSPI conversationSpi = MockedConversationSpi(); Config config = config(); ConversationManager conversationManager = new ConversationManager(conversationSpi, config); when(spi.Accessible).thenReturn(true); when(conversationSpi.AcquireClient()).thenThrow(new Exception("Nope")); when(spi.GetTransactionChecksum(anyLong())).thenReturn(1L); MockEmptyResponse(spi); MasterImpl instance = new MasterImpl(spi, conversationManager, mock(typeof(MasterImpl.Monitor)), config); instance.Start(); Response <HandshakeResult> response = instance.Handshake(1, newStoreIdForCurrentVersion()); HandshakeResult handshake = response.ResponseConflict(); // When try { instance.NewLockSession(new RequestContext(handshake.Epoch(), 1, 2, 0, 0)); fail("Should have failed."); } catch (Exception e) { // Then assertThat(e, instanceOf(typeof(Exception))); assertThat(e.Message, equalTo("Nope")); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAllowCommitIfThereIsNoMatchingLockSession() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotAllowCommitIfThereIsNoMatchingLockSession() { // Given MasterImpl.SPI spi = mock(typeof(MasterImpl.SPI)); DefaultConversationSPI conversationSpi = MockedConversationSpi(); Config config = config(); 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(); RequestContext ctx = new RequestContext(handshake.Epoch(), 1, 2, 0, 0); // When try { master.Commit(ctx, mock(typeof(TransactionRepresentation))); fail("Should have failed."); } catch (TransactionNotPresentOnMasterException e) { // Then assertThat(e.Message, equalTo((new TransactionNotPresentOnMasterException(ctx)).Message)); } }
public MasterImpl(SPI spi, ConversationManager conversationManager, Monitor monitor, Config config) { this._spi = spi; this._config = config; this._monitor = monitor; this._conversationManager = conversationManager; this._epoch = GenerateEpoch(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCleanExistentLockSessionOnFinishOffChannel() public virtual void ShouldCleanExistentLockSessionOnFinishOffChannel() { Master master = mock(typeof(Master)); ConversationManager conversationManager = mock(typeof(ConversationManager)); LogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>(); MasterServer masterServer = new MasterServer(master, mock(typeof(LogProvider)), mock(typeof(Server.Configuration)), mock(typeof(TxChecksumVerifier)), mock(typeof(ByteCounterMonitor)), mock(typeof(RequestMonitor)), conversationManager, logEntryReader); RequestContext requestContext = new RequestContext(1L, 1, 1, 0, 0L); masterServer.StopConversation(requestContext); Mockito.verify(conversationManager).stop(requestContext); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testStart() public virtual void TestStart() { JobHandle reaperJobHandle = mock(typeof(JobHandle)); when(_config.get(HaSettings.lock_read_timeout)).thenReturn(Duration.ofMillis(1)); when(_conversationSPI.scheduleRecurringJob(any(typeof(Group)), any(typeof(Long)), any(typeof(ThreadStart)))).thenReturn(reaperJobHandle); _conversationManager = ConversationManager; _conversationManager.start(); assertNotNull(_conversationManager.conversations); verify(_conversationSPI).scheduleRecurringJob(any(typeof(Group)), any(typeof(Long)), any(typeof(ThreadStart))); }
private MasterImpl NewMasterWithLocksClient(Locks_Client client) { SPI spi = MockedSpi(); DefaultConversationSPI conversationSpi = MockedConversationSpi(); when(spi.Accessible).thenReturn(true); when(conversationSpi.AcquireClient()).thenReturn(client); Config config = config(); ConversationManager conversationManager = new ConversationManager(conversationSpi, config); MasterImpl master = new MasterImpl(spi, conversationManager, mock(typeof(Monitor)), config); master.Start(); return(master); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldStartStopConversationManager() public virtual void ShouldStartStopConversationManager() { MasterImpl.SPI spi = MockedSpi(); ConversationManager conversationManager = mock(typeof(ConversationManager)); Config config = config(); MasterImpl master = new MasterImpl(spi, conversationManager, null, config); master.Start(); master.Stop(); InOrder order = inOrder(conversationManager); order.verify(conversationManager).start(); order.verify(conversationManager).stop(); verifyNoMoreInteractions(conversationManager); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void lockResultMustHaveMessageWhenAcquiringSharedLockWithoutConversation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void LockResultMustHaveMessageWhenAcquiringSharedLockWithoutConversation() { MasterImpl.SPI spi = MockedSpi(); ConversationManager conversationManager = mock(typeof(ConversationManager)); Config config = config(); MasterImpl master = new MasterImpl(spi, conversationManager, null, config); RequestContext context = CreateRequestContext(master); when(conversationManager.Acquire(context)).thenThrow(new NoSuchEntryException("")); master.AcquireSharedLock(context, ResourceTypes.NODE, 1); ArgumentCaptor <LockResult> captor = ArgumentCaptor.forClass(typeof(LockResult)); verify(spi).packTransactionObligationResponse(MockitoHamcrest.argThat(@is(context)), captor.capture()); assertThat(captor.Value.Message, @is(not(nullValue()))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testConversationStop() public virtual void TestConversationStop() { RequestContext requestContext = RequestContext; _conversationManager = ConversationManager; Conversation conversation = mock(typeof(Conversation)); when(conversation.Active).thenReturn(true); TimedRepository conversationStorage = mock(typeof(TimedRepository)); when(conversationStorage.end(requestContext)).thenReturn(conversation); _conversationManager.conversations = conversationStorage; _conversationManager.stop(requestContext); verify(conversationStorage).end(requestContext); verify(conversation).stop(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testConversationWorkflow() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestConversationWorkflow() { RequestContext requestContext = RequestContext; _conversationManager = ConversationManager; TimedRepository conversationStorage = mock(typeof(TimedRepository)); _conversationManager.conversations = conversationStorage; _conversationManager.begin(requestContext); _conversationManager.acquire(requestContext); _conversationManager.release(requestContext); _conversationManager.end(requestContext); InOrder conversationOrder = inOrder(conversationStorage); conversationOrder.verify(conversationStorage).begin(requestContext); conversationOrder.verify(conversationStorage).acquire(requestContext); conversationOrder.verify(conversationStorage).release(requestContext); conversationOrder.verify(conversationStorage).end(requestContext); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void lockResultMustHaveMessageWhenAcquiringSharedLockThrowsIllegalResource() public virtual void LockResultMustHaveMessageWhenAcquiringSharedLockThrowsIllegalResource() { MasterImpl.SPI spi = MockedSpi(); DefaultConversationSPI conversationSpi = MockedConversationSpi(); Config config = config(); ConversationManager conversationManager = new ConversationManager(conversationSpi, config); conversationManager.Start(); Locks_Client locks = mock(typeof(Locks_Client)); MasterImpl master = new MasterImpl(spi, conversationManager, null, config); RequestContext context = CreateRequestContext(master); when(conversationSpi.AcquireClient()).thenReturn(locks); ResourceTypes type = ResourceTypes.NODE; doThrow(new IllegalResourceException("")).when(locks).acquireExclusive(LockTracer.NONE, type, 1); master.AcquireSharedLock(context, type, 1); ArgumentCaptor <LockResult> captor = ArgumentCaptor.forClass(typeof(LockResult)); verify(spi).packTransactionObligationResponse(MockitoHamcrest.argThat(@is(context)), captor.capture()); assertThat(captor.Value.Message, @is(not(nullValue()))); }
internal ConversationKiller(ConversationManager conversationManager) { this.ConversationManager = conversationManager; }
public MasterServer(Master requestTarget, LogProvider logProvider, Configuration config, TxChecksumVerifier txVerifier, ByteCounterMonitor byteCounterMonitor, RequestMonitor requestMonitor, ConversationManager conversationManager, LogEntryReader <ReadableClosablePositionAwareChannel> entryReader) : base(requestTarget, config, logProvider, FrameLength, CURRENT, txVerifier, Clocks.systemClock(), byteCounterMonitor, requestMonitor) { this._conversationManager = conversationManager; this._requestTypes = new HaRequestType210(entryReader, MasterClient320.LOCK_RESULT_OBJECT_SERIALIZER); }