public boolean matches(final PublicationImage image) { return image.channelEndpoint() == this.channelEndpoint && image.streamId() == this.streamId && isWildcardOrSessionIdMatch(image.sessionId()); }
void transitionToLinger(final PublicationImage image) { for (int i = 0, size = subscriptionLinks.size(); i < size; i++) { final SubscriptionLink link = subscriptionLinks.get(i); if (link.isLinked(image)) { clientProxy.onUnavailableImage( image.correlationId(), link.registrationId(), image.streamId(), image.channel()); } } receiverProxy.removeCoolDown(image.channelEndpoint(), image.sessionId(), image.streamId()); }
@Before public void setUp() { when(mockHeader.sessionId()).thenReturn(SESSION_ID); when(mockHeader.streamId()).thenReturn(STREAM_ID); when(mockHeader.termId()).thenReturn(ACTIVE_TERM_ID); when(mockHeader.termOffset()).thenReturn(TERM_OFFSET); when(mockImage.sessionId()).thenReturn(SESSION_ID); when(mockImage.streamId()).thenReturn(STREAM_ID); when(mockSetupHeader.sessionId()).thenReturn(SESSION_ID); when(mockSetupHeader.streamId()).thenReturn(STREAM_ID); when(mockSetupHeader.activeTermId()).thenReturn(ACTIVE_TERM_ID); when(mockSetupHeader.initialTermId()).thenReturn(INITIAL_TERM_ID); when(mockSetupHeader.termOffset()).thenReturn(TERM_OFFSET); when(mockSetupHeader.mtuLength()).thenReturn(MTU_LENGTH); when(mockSetupHeader.termLength()).thenReturn(TERM_LENGTH); }
@Advice.OnMethodEnter static void cleanupImageInterceptor(final PublicationImage image) { LOGGER.logImageRemoval(image.channel(), image.sessionId(), image.streamId(), image.correlationId()); } }
@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); }
public void addPublicationImage(final PublicationImage image) { final int sessionId = image.sessionId(); final int streamId = image.streamId(); final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.get(sessionId); if (null == sessionInterest) { sessionInterest = new SessionInterest(ACTIVE); streamInterest.sessionInterestByIdMap.put(sessionId, sessionInterest); } else { sessionInterest.state = ACTIVE; } sessionInterest.image = image; image.activate(); }
public void removePublicationImage(final PublicationImage image) { final int sessionId = image.sessionId(); final int streamId = image.streamId(); final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); if (null != streamInterest) { final SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.get(sessionId); if (null != sessionInterest && null != sessionInterest.image) { if (sessionInterest.image.correlationId() == image.correlationId()) { sessionInterest.state = ON_COOL_DOWN; sessionInterest.image = null; } } } image.ifActiveGoInactive(); }
@Test public void shouldCreateImageOnSubscription() { final InetSocketAddress sourceAddress = new InetSocketAddress("localhost", 4400); final int initialTermId = 1; final int activeTermId = 2; final int termOffset = 100; driverProxy.addSubscription(CHANNEL_4000, STREAM_ID_1); driverConductor.doWork(); final ReceiveChannelEndpoint receiveChannelEndpoint = driverConductor.receiverChannelEndpoint(UdpChannel.parse(CHANNEL_4000)); assertNotNull(receiveChannelEndpoint); receiveChannelEndpoint.openChannel(driverConductorProxy); driverConductor.onCreatePublicationImage( SESSION_ID, STREAM_ID_1, initialTermId, activeTermId, termOffset, TERM_BUFFER_LENGTH, MTU_LENGTH, 0, mock(InetSocketAddress.class), sourceAddress, receiveChannelEndpoint); final ArgumentCaptor<PublicationImage> captor = ArgumentCaptor.forClass(PublicationImage.class); verify(receiverProxy).newPublicationImage(eq(receiveChannelEndpoint), captor.capture()); final PublicationImage publicationImage = captor.getValue(); assertThat(publicationImage.sessionId(), is(SESSION_ID)); assertThat(publicationImage.streamId(), is(STREAM_ID_1)); verify(mockClientProxy).onAvailableImage( anyLong(), eq(STREAM_ID_1), eq(SESSION_ID), anyLong(), anyInt(), anyString(), anyString()); }
@Test public void shouldNotRemoveImageFromDispatcherOnRemoveSubscription() { receiverProxy.registerReceiveChannelEndpoint(receiveChannelEndpoint); receiverProxy.addSubscription(receiveChannelEndpoint, STREAM_ID); receiver.doWork(); fillSetupFrame(setupHeader); receiveChannelEndpoint.onSetupMessage(setupHeader, setupBuffer, SetupFlyweight.HEADER_LENGTH, senderAddress, 0); final PublicationImage mockImage = mock(PublicationImage.class); when(mockImage.sessionId()).thenReturn(SESSION_ID); when(mockImage.streamId()).thenReturn(STREAM_ID); when(mockImage.hasActivityAndNotEndOfStream(anyLong())).thenReturn(true); receiver.onNewPublicationImage(receiveChannelEndpoint, mockImage); receiver.onRemoveSubscription(receiveChannelEndpoint, STREAM_ID); receiver.doWork(); verify(mockImage).ifActiveGoInactive(); verify(mockImage, never()).removeFromDispatcher(); }
@Test public void shouldRemoveImageFromDispatcherWithNoActivity() { receiverProxy.registerReceiveChannelEndpoint(receiveChannelEndpoint); receiverProxy.addSubscription(receiveChannelEndpoint, STREAM_ID); receiver.doWork(); fillSetupFrame(setupHeader); receiveChannelEndpoint.onSetupMessage(setupHeader, setupBuffer, SetupFlyweight.HEADER_LENGTH, senderAddress, 0); final PublicationImage mockImage = mock(PublicationImage.class); when(mockImage.sessionId()).thenReturn(SESSION_ID); when(mockImage.streamId()).thenReturn(STREAM_ID); when(mockImage.hasActivityAndNotEndOfStream(anyLong())).thenReturn(false); receiver.onNewPublicationImage(receiveChannelEndpoint, mockImage); receiver.doWork(); verify(mockImage).removeFromDispatcher(); }
public boolean matches(final PublicationImage image) { return image.channelEndpoint() == this.channelEndpoint && image.streamId() == this.streamId && isWildcardOrSessionIdMatch(image.sessionId()); }
public boolean matches(final PublicationImage image) { return image.channelEndpoint() == this.channelEndpoint && image.streamId() == this.streamId && isWildcardOrSessionIdMatch(image.sessionId()); }
void transitionToLinger(final PublicationImage image) { for (int i = 0, size = subscriptionLinks.size(); i < size; i++) { final SubscriptionLink link = subscriptionLinks.get(i); if (link.isLinked(image)) { clientProxy.onUnavailableImage( image.correlationId(), link.registrationId(), image.streamId(), image.channel()); } } receiverProxy.removeCoolDown(image.channelEndpoint(), image.sessionId(), image.streamId()); }
void transitionToLinger(final PublicationImage image) { for (int i = 0, size = subscriptionLinks.size(); i < size; i++) { final SubscriptionLink link = subscriptionLinks.get(i); if (link.isLinked(image)) { clientProxy.onUnavailableImage( image.correlationId(), link.registrationId(), image.streamId(), image.channel()); } } receiverProxy.removeCoolDown(image.channelEndpoint(), image.sessionId(), image.streamId()); }
@Advice.OnMethodEnter static void cleanupImageInterceptor(final PublicationImage image) { LOGGER.logImageRemoval(image.channel(), image.sessionId(), image.streamId(), image.correlationId()); } }
public void removePublicationImage(final PublicationImage image) { final int sessionId = image.sessionId(); final int streamId = image.streamId(); final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); if (null != streamInterest) { final SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.get(sessionId); if (null != sessionInterest && null != sessionInterest.image) { if (sessionInterest.image.correlationId() == image.correlationId()) { sessionInterest.state = ON_COOL_DOWN; sessionInterest.image = null; } } } image.ifActiveGoInactive(); }
public void addPublicationImage(final PublicationImage image) { final int sessionId = image.sessionId(); final int streamId = image.streamId(); final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.get(sessionId); if (null == sessionInterest) { sessionInterest = new SessionInterest(ACTIVE); streamInterest.sessionInterestByIdMap.put(sessionId, sessionInterest); } else { sessionInterest.state = ACTIVE; } sessionInterest.image = image; image.activate(); }
public void addPublicationImage(final PublicationImage image) { final int sessionId = image.sessionId(); final int streamId = image.streamId(); final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.get(sessionId); if (null == sessionInterest) { sessionInterest = new SessionInterest(ACTIVE); streamInterest.sessionInterestByIdMap.put(sessionId, sessionInterest); } else { sessionInterest.state = ACTIVE; } sessionInterest.image = image; image.activate(); }
public void removePublicationImage(final PublicationImage image) { final int sessionId = image.sessionId(); final int streamId = image.streamId(); final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); if (null != streamInterest) { final SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.get(sessionId); if (null != sessionInterest && null != sessionInterest.image) { if (sessionInterest.image.correlationId() == image.correlationId()) { sessionInterest.state = ON_COOL_DOWN; sessionInterest.image = null; } } } image.ifActiveGoInactive(); }