Search in sources :

Example 1 with UdpChannel

use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.

the class DriverConductorTest method shouldOnlyRemoveSubscriptionMediaEndpointUponRemovalOfAllSubscribers.

@Test
public void shouldOnlyRemoveSubscriptionMediaEndpointUponRemovalOfAllSubscribers() 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);
    final long id3 = driverProxy.addSubscription(CHANNEL_4000, STREAM_ID_3);
    driverConductor.doWork();
    final ReceiveChannelEndpoint channelEndpoint = driverConductor.receiverChannelEndpoint(udpChannel);
    assertNotNull(channelEndpoint);
    assertThat(channelEndpoint.streamCount(), is(3));
    driverProxy.removeSubscription(id2);
    driverProxy.removeSubscription(id3);
    driverConductor.doWork();
    assertNotNull(driverConductor.receiverChannelEndpoint(udpChannel));
    assertThat(channelEndpoint.streamCount(), is(1));
    driverProxy.removeSubscription(id1);
    driverConductor.doWork();
    assertNull(driverConductor.receiverChannelEndpoint(udpChannel));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) Test(org.junit.Test)

Example 2 with UdpChannel

use of io.aeron.driver.media.UdpChannel in project aeron by real-logic.

the class DriverConductorTest method shouldKeepSubscriptionMediaEndpointUponRemovalOfAllButOneSubscriber.

@Test
public void shouldKeepSubscriptionMediaEndpointUponRemovalOfAllButOneSubscriber() {
    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 3 with UdpChannel

use of io.aeron.driver.media.UdpChannel in project aeron by real-logic.

the class UdpChannelTest method shouldGetProtocolFamilyForIpV6.

@Test
public void shouldGetProtocolFamilyForIpV6() {
    final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?endpoint=[::1]:12345|interface=[::1]");
    assertThat(udpChannel.protocolFamily(), is(StandardProtocolFamily.INET6));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Test(org.junit.Test)

Example 4 with UdpChannel

use of io.aeron.driver.media.UdpChannel in project aeron by real-logic.

the class UdpChannelTest method shouldHandleLocalhostLookup.

@Test
public void shouldHandleLocalhostLookup() {
    final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?endpoint=localhost:40124");
    assertThat(udpChannel.remoteData(), is(new InetSocketAddress("127.0.0.1", 40124)));
    assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("127.0.0.1", 40124)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Test(org.junit.Test)

Example 5 with UdpChannel

use of io.aeron.driver.media.UdpChannel in project aeron by real-logic.

the class UdpChannelTest method shouldHandleIPv4AnyAddressAsInterfaceAddressForUnicast.

@Theory
public void shouldHandleIPv4AnyAddressAsInterfaceAddressForUnicast(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "localhost:40124", interfaceKey, "0.0.0.0"));
    assertThat(udpChannel.localData(), is(new InetSocketAddress("0.0.0.0", 0)));
    assertThat(udpChannel.localControl(), is(new InetSocketAddress("0.0.0.0", 0)));
    assertThat(udpChannel.remoteData(), is(new InetSocketAddress("localhost", 40124)));
    assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("localhost", 40124)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Theory(org.junit.experimental.theories.Theory)

Aggregations

UdpChannel (io.aeron.driver.media.UdpChannel)78 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)35 Test (org.junit.jupiter.api.Test)26 Test (org.junit.Test)18 ReceiveChannelEndpoint (io.aeron.driver.media.ReceiveChannelEndpoint)12 Theory (org.junit.experimental.theories.Theory)11 CsvSource (org.junit.jupiter.params.provider.CsvSource)11 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)7 ChannelUri (io.aeron.ChannelUri)3 PublicationParams (io.aeron.driver.PublicationParams)3 ControlProtocolException (io.aeron.exceptions.ControlProtocolException)3 RawLog (io.aeron.driver.buffer.RawLog)2 ReceiveDestinationTransport (io.aeron.driver.media.ReceiveDestinationTransport)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Pattern (java.util.regex.Pattern)2 Aeron (io.aeron.Aeron)1 SPY_QUALIFIER (io.aeron.ChannelUri.SPY_QUALIFIER)1 ChannelUriStringBuilder (io.aeron.ChannelUriStringBuilder)1 CommonContext (io.aeron.CommonContext)1