@Test public void shouldIgnoreDataAndSetupAfterImageRemoved() { dispatcher.addSubscription(STREAM_ID); dispatcher.addPublicationImage(mockImage); dispatcher.removePublicationImage(mockImage); dispatcher.onDataPacket(mockChannelEndpoint, mockHeader, mockBuffer, LENGTH, SRC_ADDRESS, 0); dispatcher.onSetupMessage(mockChannelEndpoint, mockSetupHeader, SRC_ADDRESS, 0); verifyZeroInteractions(mockConductorProxy); verifyZeroInteractions(mockReceiver); }
public void removeCoolDown(final int sessionId, final int streamId) { dispatcher.removeCoolDown(sessionId, streamId); }
public void removePendingSetup(final int sessionId, final int streamId) { dispatcher.removePendingSetup(sessionId, streamId); }
@Test public void shouldNotRequestCreateImageOnceUponReceivingSetupAfterImageAdded() { dispatcher.addSubscription(STREAM_ID); dispatcher.addPublicationImage(mockImage); dispatcher.onSetupMessage(mockChannelEndpoint, mockSetupHeader, SRC_ADDRESS, 0); verifyZeroInteractions(mockConductorProxy); }
@Test public void shouldRemoveSessionSpecificSubscriptionWithoutAny() { dispatcher.addSubscription(STREAM_ID, SESSION_ID); dispatcher.removeSubscription(STREAM_ID, SESSION_ID); } }
@Test public void shouldNotRemoveNewPublicationImageFromOldRemovePublicationImageAfterRemoveSubscription() { final PublicationImage mockImage1 = mock(PublicationImage.class); final PublicationImage mockImage2 = mock(PublicationImage.class); when(mockImage1.sessionId()).thenReturn(SESSION_ID); when(mockImage1.streamId()).thenReturn(STREAM_ID); when(mockImage1.correlationId()).thenReturn(CORRELATION_ID_1); when(mockImage2.sessionId()).thenReturn(SESSION_ID); when(mockImage2.streamId()).thenReturn(STREAM_ID); when(mockImage2.correlationId()).thenReturn(CORRELATION_ID_2); dispatcher.addSubscription(STREAM_ID); dispatcher.addPublicationImage(mockImage1); dispatcher.removeSubscription(STREAM_ID); dispatcher.addSubscription(STREAM_ID); dispatcher.addPublicationImage(mockImage2); dispatcher.removePublicationImage(mockImage1); dispatcher.onDataPacket(mockChannelEndpoint, mockHeader, mockBuffer, LENGTH, SRC_ADDRESS, 0); verify(mockImage1, never()).insertPacket(anyInt(), anyInt(), any(), anyInt(), anyInt(), any()); verify(mockImage2).insertPacket(ACTIVE_TERM_ID, TERM_OFFSET, mockBuffer, LENGTH, 0, SRC_ADDRESS); }
@Test public void shouldSetImageInactiveOnRemoveImage() { dispatcher.addSubscription(STREAM_ID); dispatcher.addPublicationImage(mockImage); dispatcher.removePublicationImage(mockImage); verify(mockImage).ifActiveGoInactive(); }
@Test public void shouldSetImageInactiveOnRemoveSubscription() { dispatcher.addSubscription(STREAM_ID); dispatcher.addPublicationImage(mockImage); dispatcher.removeSubscription(STREAM_ID); verify(mockImage).ifActiveGoInactive(); }
@Test public void shouldElicitSetupMessageAgainWhenDataArrivesForSubscriptionWithoutImageAfterRemovePendingSetup() { dispatcher.addSubscription(STREAM_ID); dispatcher.onDataPacket(mockChannelEndpoint, mockHeader, mockBuffer, LENGTH, SRC_ADDRESS, 0); dispatcher.onDataPacket(mockChannelEndpoint, mockHeader, mockBuffer, LENGTH, SRC_ADDRESS, 0); dispatcher.removePendingSetup(SESSION_ID, STREAM_ID); dispatcher.onDataPacket(mockChannelEndpoint, mockHeader, mockBuffer, LENGTH, SRC_ADDRESS, 0); dispatcher.onDataPacket(mockChannelEndpoint, mockHeader, mockBuffer, LENGTH, SRC_ADDRESS, 0); verify(mockImage, never()).insertPacket(anyInt(), anyInt(), any(), anyInt(), anyInt(), any()); verify(mockChannelEndpoint, times(2)).sendSetupElicitingStatusMessage(0, SRC_ADDRESS, SESSION_ID, STREAM_ID); verify(mockReceiver, times(2)) .addPendingSetupMessage(SESSION_ID, STREAM_ID, 0, mockChannelEndpoint, false, SRC_ADDRESS); }
@Test public void shouldDispatchDataToCorrectImage() { dispatcher.addSubscription(STREAM_ID); dispatcher.addPublicationImage(mockImage); dispatcher.onDataPacket(mockChannelEndpoint, mockHeader, mockBuffer, LENGTH, SRC_ADDRESS, 0); verify(mockImage).activate(); verify(mockImage).insertPacket(ACTIVE_TERM_ID, TERM_OFFSET, mockBuffer, LENGTH, 0, SRC_ADDRESS); }
@Test public void shouldOnlyRequestCreateImageOnceUponReceivingSetup() { dispatcher.addSubscription(STREAM_ID); dispatcher.onSetupMessage(mockChannelEndpoint, mockSetupHeader, SRC_ADDRESS, 0); dispatcher.onSetupMessage(mockChannelEndpoint, mockSetupHeader, SRC_ADDRESS, 0); dispatcher.onSetupMessage(mockChannelEndpoint, mockSetupHeader, SRC_ADDRESS, 0); verify(mockConductorProxy).createPublicationImage( SESSION_ID, STREAM_ID, INITIAL_TERM_ID, ACTIVE_TERM_ID, TERM_OFFSET, TERM_LENGTH, MTU_LENGTH, 0, SRC_ADDRESS, SRC_ADDRESS, mockChannelEndpoint); }
@Test public void shouldOnlyElicitSetupMessageOnceWhenDataArrivesForSubscriptionWithoutImage() { dispatcher.addSubscription(STREAM_ID); dispatcher.onDataPacket(mockChannelEndpoint, mockHeader, mockBuffer, LENGTH, SRC_ADDRESS, 0); dispatcher.onDataPacket(mockChannelEndpoint, mockHeader, mockBuffer, LENGTH, SRC_ADDRESS, 0); dispatcher.onDataPacket(mockChannelEndpoint, mockHeader, mockBuffer, LENGTH, SRC_ADDRESS, 0); verify(mockImage, never()).insertPacket(anyInt(), anyInt(), any(), anyInt(), anyInt(), any()); verify(mockChannelEndpoint).sendSetupElicitingStatusMessage(0, SRC_ADDRESS, SESSION_ID, STREAM_ID); verify(mockReceiver).addPendingSetupMessage(SESSION_ID, STREAM_ID, 0, mockChannelEndpoint, false, SRC_ADDRESS); }
public void addSubscription(final int streamId) { dispatcher.addSubscription(streamId); }
public void removeSubscription(final int streamId, final int sessionId) { dispatcher.removeSubscription(streamId, sessionId); }
public int onDataPacket( final DataHeaderFlyweight header, final UnsafeBuffer buffer, final int length, final InetSocketAddress srcAddress, final int transportIndex) { return dispatcher.onDataPacket(this, header, buffer, length, srcAddress, transportIndex); }
private ReceiveChannelEndpoint getOrCreateReceiveChannelEndpoint(final UdpChannel udpChannel) { ReceiveChannelEndpoint channelEndpoint = findExistingReceiveChannelEndpoint(udpChannel); if (null == channelEndpoint) { channelEndpoint = ctx.receiveChannelEndpointSupplier().newInstance( udpChannel, new DataPacketDispatcher(ctx.driverConductorProxy(), receiverProxy.receiver()), ReceiveChannelStatus.allocate(tempBuffer, countersManager, udpChannel.originalUriString()), ctx); receiveChannelEndpointByChannelMap.put(udpChannel.canonicalForm(), channelEndpoint); receiverProxy.registerReceiveChannelEndpoint(channelEndpoint); } return channelEndpoint; }
public void addPublicationImage(final PublicationImage image) { dispatcher.addPublicationImage(image); }
public void onSetupMessage( final SetupFlyweight header, final UnsafeBuffer buffer, final int length, final InetSocketAddress srcAddress, final int transportIndex) { dispatcher.onSetupMessage(this, header, srcAddress, transportIndex); }
public void removePublicationImage(final PublicationImage publicationImage) { dispatcher.removePublicationImage(publicationImage); }
createPublicationImage( channelEndpoint, transportIndex, createPublicationImage( channelEndpoint, transportIndex,