Search in sources :

Example 6 with ReceiveChannelEndpoint

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;
}
Also used : Position(org.agrona.concurrent.status.Position) ReadablePosition(org.agrona.concurrent.status.ReadablePosition) ArrayList(java.util.ArrayList) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Example 7 with ReceiveChannelEndpoint

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));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) Test(org.junit.Test)

Example 8 with ReceiveChannelEndpoint

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)));
}
Also used : ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) Test(org.junit.Test)

Example 9 with ReceiveChannelEndpoint

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)));
}
Also used : ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) Test(org.junit.Test)

Example 10 with ReceiveChannelEndpoint

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);
        }
    }
}
Also used : ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Aggregations

ReceiveChannelEndpoint (io.aeron.driver.media.ReceiveChannelEndpoint)19 Test (org.junit.Test)9 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)6 InetSocketAddress (java.net.InetSocketAddress)6 UdpChannel (io.aeron.driver.media.UdpChannel)4 Position (org.agrona.concurrent.status.Position)2 ReadablePosition (org.agrona.concurrent.status.ReadablePosition)2 InOrder (org.mockito.InOrder)2 RawLog (io.aeron.driver.buffer.RawLog)1 ControlProtocolException (io.aeron.driver.exceptions.ControlProtocolException)1 ArrayList (java.util.ArrayList)1