@Test public void shouldSetImageInactiveOnRemoveSubscription() { dispatcher.addSubscription(STREAM_ID); dispatcher.addPublicationImage(mockImage); dispatcher.removeSubscription(STREAM_ID); verify(mockImage).ifActiveGoInactive(); }
@Test public void shouldSetImageInactiveOnRemoveImage() { dispatcher.addSubscription(STREAM_ID); dispatcher.addPublicationImage(mockImage); dispatcher.removePublicationImage(mockImage); verify(mockImage).ifActiveGoInactive(); }
public void removeSubscription(final int streamId, final int sessionId) { final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); if (null == streamInterest) { throw new UnknownSubscriptionException("No subscription registered on stream " + streamId); } final SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.remove(sessionId); if (null != sessionInterest && null != sessionInterest.image) { sessionInterest.image.ifActiveGoInactive(); } streamInterest.subscribedSessionIds.remove(sessionId); if (!streamInterest.isForAllSessions && streamInterest.subscribedSessionIds.isEmpty()) { streamInterestByIdMap.remove(streamId); } }
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 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 shouldSignalInactiveImageWhenImageTimesOut() { final InetSocketAddress sourceAddress = new InetSocketAddress("localhost", 4400); final long subId = 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, 1, 1, 0, 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(); publicationImage.activate(); publicationImage.ifActiveGoInactive(); doWorkUntil(() -> nanoClock.nanoTime() >= IMAGE_LIVENESS_TIMEOUT_NS + 1000); verify(mockClientProxy).onUnavailableImage( eq(publicationImage.correlationId()), eq(subId), eq(STREAM_ID_1), anyString()); }
publicationImage.ifActiveGoInactive();
publicationImage.ifActiveGoInactive();
public void removeSubscription(final int streamId) { final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); if (null == streamInterest) { throw new UnknownSubscriptionException("No subscription registered on stream " + streamId); } for (final int sessionId : streamInterest.sessionInterestByIdMap.keySet()) { final SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.get(sessionId); if (!streamInterest.subscribedSessionIds.contains(sessionId)) { if (null != sessionInterest.image) { sessionInterest.image.ifActiveGoInactive(); } streamInterest.sessionInterestByIdMap.remove(sessionId); } } streamInterest.isForAllSessions = false; if (streamInterest.subscribedSessionIds.isEmpty()) { streamInterestByIdMap.remove(streamId); } }
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 removeSubscription(final int streamId, final int sessionId) { final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); if (null == streamInterest) { throw new UnknownSubscriptionException("No subscription registered on stream " + streamId); } final SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.remove(sessionId); if (null != sessionInterest && null != sessionInterest.image) { sessionInterest.image.ifActiveGoInactive(); } streamInterest.subscribedSessionIds.remove(sessionId); if (!streamInterest.isForAllSessions && streamInterest.subscribedSessionIds.isEmpty()) { streamInterestByIdMap.remove(streamId); } }
public void removeSubscription(final int streamId, final int sessionId) { final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); if (null == streamInterest) { throw new UnknownSubscriptionException("No subscription registered on stream " + streamId); } final SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.remove(sessionId); if (null != sessionInterest && null != sessionInterest.image) { sessionInterest.image.ifActiveGoInactive(); } streamInterest.subscribedSessionIds.remove(sessionId); if (!streamInterest.isForAllSessions && streamInterest.subscribedSessionIds.isEmpty()) { streamInterestByIdMap.remove(streamId); } }
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 removeSubscription(final int streamId) { final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); if (null == streamInterest) { throw new UnknownSubscriptionException("No subscription registered on stream " + streamId); } for (final int sessionId : streamInterest.sessionInterestByIdMap.keySet()) { final SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.get(sessionId); if (!streamInterest.subscribedSessionIds.contains(sessionId)) { if (null != sessionInterest.image) { sessionInterest.image.ifActiveGoInactive(); } streamInterest.sessionInterestByIdMap.remove(sessionId); } } streamInterest.isForAllSessions = false; if (streamInterest.subscribedSessionIds.isEmpty()) { streamInterestByIdMap.remove(streamId); } }
public void removeSubscription(final int streamId) { final StreamInterest streamInterest = streamInterestByIdMap.get(streamId); if (null == streamInterest) { throw new UnknownSubscriptionException("No subscription registered on stream " + streamId); } for (final int sessionId : streamInterest.sessionInterestByIdMap.keySet()) { final SessionInterest sessionInterest = streamInterest.sessionInterestByIdMap.get(sessionId); if (!streamInterest.subscribedSessionIds.contains(sessionId)) { if (null != sessionInterest.image) { sessionInterest.image.ifActiveGoInactive(); } streamInterest.sessionInterestByIdMap.remove(sessionId); } } streamInterest.isForAllSessions = false; if (streamInterest.subscribedSessionIds.isEmpty()) { streamInterestByIdMap.remove(streamId); } }