use of io.aeron.driver.media.ReceiveChannelEndpoint in project Aeron by real-logic.
the class DataPacketDispatcher method onDataPacket.
public int onDataPacket(final ReceiveChannelEndpoint channelEndpoint, final DataHeaderFlyweight header, final UnsafeBuffer buffer, final int length, final InetSocketAddress srcAddress) {
final int streamId = header.streamId();
final Int2ObjectHashMap<PublicationImage> imageBySessionIdMap = sessionsByStreamIdMap.get(streamId);
if (null != imageBySessionIdMap) {
final int sessionId = header.sessionId();
final int termId = header.termId();
final PublicationImage image = imageBySessionIdMap.get(sessionId);
if (null != image) {
return image.insertPacket(termId, header.termOffset(), buffer, length);
} else if (null == ignoredSessionsMap.get(sessionId, streamId)) {
elicitSetupMessageFromSource(channelEndpoint, srcAddress, streamId, sessionId);
}
}
return 0;
}
use of io.aeron.driver.media.ReceiveChannelEndpoint in project Aeron by real-logic.
the class DriverConductorTest method shouldSignalInactiveImageWhenImageTimesOut.
@Test
public void shouldSignalInactiveImageWhenImageTimesOut() throws Exception {
final InetSocketAddress sourceAddress = new InetSocketAddress("localhost", 4400);
driverProxy.addSubscription(CHANNEL_4000, STREAM_ID_1);
driverConductor.doWork();
final ReceiveChannelEndpoint receiveChannelEndpoint = driverConductor.receiverChannelEndpoint(UdpChannel.parse(CHANNEL_4000));
assertNotNull(receiveChannelEndpoint);
receiveChannelEndpoint.openChannel();
driverConductor.onCreatePublicationImage(SESSION_ID, STREAM_ID_1, 1, 1, 0, TERM_BUFFER_LENGTH, MTU_LENGTH, 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.status(PublicationImage.Status.INACTIVE);
doWorkUntil(() -> nanoClock.nanoTime() >= IMAGE_LIVENESS_TIMEOUT_NS + 1000);
verify(mockClientProxy).onUnavailableImage(eq(publicationImage.correlationId()), eq(STREAM_ID_1), anyString());
}
use of io.aeron.driver.media.ReceiveChannelEndpoint in project Aeron by real-logic.
the class DriverConductorTest method shouldCreateImageOnSubscription.
@Test
public void shouldCreateImageOnSubscription() throws Exception {
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();
driverConductor.onCreatePublicationImage(SESSION_ID, STREAM_ID_1, initialTermId, activeTermId, termOffset, TERM_BUFFER_LENGTH, MTU_LENGTH, 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), any(), any(), anyString());
}
use of io.aeron.driver.media.ReceiveChannelEndpoint in project Aeron by real-logic.
the class DriverConductorTest method shouldNotCreateImageOnUnknownSubscription.
@Test
public void shouldNotCreateImageOnUnknownSubscription() throws Exception {
final InetSocketAddress sourceAddress = new InetSocketAddress("localhost", 4400);
driverProxy.addSubscription(CHANNEL_4000, STREAM_ID_1);
driverConductor.doWork();
final ReceiveChannelEndpoint receiveChannelEndpoint = driverConductor.receiverChannelEndpoint(UdpChannel.parse(CHANNEL_4000));
assertNotNull(receiveChannelEndpoint);
receiveChannelEndpoint.openChannel();
driverConductor.onCreatePublicationImage(SESSION_ID, STREAM_ID_2, 1, 1, 0, TERM_BUFFER_LENGTH, MTU_LENGTH, mock(InetSocketAddress.class), sourceAddress, receiveChannelEndpoint);
verify(receiverProxy, never()).newPublicationImage(any(), any());
verify(mockClientProxy, never()).onAvailableImage(anyLong(), anyInt(), anyInt(), any(), any(), anyString());
}
Aggregations