use of io.aeron.driver.media.ReceiveChannelEndpoint in project Aeron by real-logic.
the class DriverConductor method createSubscriberPositions.
private List<SubscriberPosition> createSubscriberPositions(final int sessionId, final int streamId, final ReceiveChannelEndpoint channelEndpoint, final long joiningPosition) {
final ArrayList<SubscriberPosition> subscriberPositions = new ArrayList<>();
for (int i = 0, size = subscriptionLinks.size(); i < size; i++) {
final SubscriptionLink subscription = subscriptionLinks.get(i);
if (subscription.matches(channelEndpoint, streamId)) {
final Position position = SubscriberPos.allocate(countersManager, subscription.registrationId(), sessionId, streamId, subscription.uri(), joiningPosition);
position.setOrdered(joiningPosition);
subscriberPositions.add(new SubscriberPosition(subscription, position));
}
}
return subscriberPositions;
}
use of io.aeron.driver.media.ReceiveChannelEndpoint in project Aeron by real-logic.
the class DriverConductorTest method shouldKeepSubscriptionMediaEndpointUponRemovalOfAllButOneSubscriber.
@Test
public void shouldKeepSubscriptionMediaEndpointUponRemovalOfAllButOneSubscriber() throws Exception {
final UdpChannel udpChannel = UdpChannel.parse(CHANNEL_4000);
final long id1 = driverProxy.addSubscription(CHANNEL_4000, STREAM_ID_1);
final long id2 = driverProxy.addSubscription(CHANNEL_4000, STREAM_ID_2);
driverProxy.addSubscription(CHANNEL_4000, STREAM_ID_3);
driverConductor.doWork();
final ReceiveChannelEndpoint channelEndpoint = driverConductor.receiverChannelEndpoint(udpChannel);
assertNotNull(channelEndpoint);
assertThat(channelEndpoint.streamCount(), is(3));
driverProxy.removeSubscription(id1);
driverProxy.removeSubscription(id2);
driverConductor.doWork();
assertNotNull(driverConductor.receiverChannelEndpoint(udpChannel));
assertThat(channelEndpoint.streamCount(), is(1));
}
use of io.aeron.driver.media.ReceiveChannelEndpoint in project Aeron by real-logic.
the class DriverConductorTest method shouldTimeoutSubscription.
@Test
public void shouldTimeoutSubscription() throws Exception {
driverProxy.addSubscription(CHANNEL_4000, STREAM_ID_1);
driverConductor.doWork();
final ReceiveChannelEndpoint receiveChannelEndpoint = driverConductor.receiverChannelEndpoint(UdpChannel.parse(CHANNEL_4000));
assertNotNull(receiveChannelEndpoint);
verify(receiverProxy).addSubscription(eq(receiveChannelEndpoint), eq(STREAM_ID_1));
doWorkUntil(() -> nanoClock.nanoTime() >= CLIENT_LIVENESS_TIMEOUT_NS * 2);
verify(receiverProxy, times(1)).removeSubscription(eq(receiveChannelEndpoint), eq(STREAM_ID_1));
assertNull(driverConductor.receiverChannelEndpoint(UdpChannel.parse(CHANNEL_4000)));
}
use of io.aeron.driver.media.ReceiveChannelEndpoint in project Aeron by real-logic.
the class DriverConductorTest method shouldNotTimeoutSubscriptionOnKeepAlive.
@Test
public void shouldNotTimeoutSubscriptionOnKeepAlive() throws Exception {
driverProxy.addSubscription(CHANNEL_4000, STREAM_ID_1);
driverConductor.doWork();
final ReceiveChannelEndpoint receiveChannelEndpoint = driverConductor.receiverChannelEndpoint(UdpChannel.parse(CHANNEL_4000));
assertNotNull(receiveChannelEndpoint);
verify(receiverProxy).addSubscription(eq(receiveChannelEndpoint), eq(STREAM_ID_1));
doWorkUntil(() -> nanoClock.nanoTime() >= CLIENT_LIVENESS_TIMEOUT_NS);
driverProxy.sendClientKeepalive();
doWorkUntil(() -> nanoClock.nanoTime() >= CLIENT_LIVENESS_TIMEOUT_NS + 1000);
driverProxy.sendClientKeepalive();
doWorkUntil(() -> nanoClock.nanoTime() >= CLIENT_LIVENESS_TIMEOUT_NS * 2);
verify(receiverProxy, never()).removeSubscription(any(), anyInt());
assertNotNull(driverConductor.receiverChannelEndpoint(UdpChannel.parse(CHANNEL_4000)));
}
use of io.aeron.driver.media.ReceiveChannelEndpoint in project Aeron by real-logic.
the class DriverConductor method cleanupSubscriptionLink.
void cleanupSubscriptionLink(final SubscriptionLink subscription) {
final ReceiveChannelEndpoint channelEndpoint = subscription.channelEndpoint();
if (null != channelEndpoint) {
final int streamId = subscription.streamId();
if (0 == channelEndpoint.decRefToStream(subscription.streamId())) {
receiverProxy.removeSubscription(channelEndpoint, streamId);
}
if (channelEndpoint.shouldBeClosed()) {
channelEndpoint.closeStatusIndicator();
receiveChannelEndpointByChannelMap.remove(channelEndpoint.udpChannel().canonicalForm());
receiverProxy.closeReceiveChannelEndpoint(channelEndpoint);
}
}
}
Aggregations