Search in sources :

Example 36 with UdpChannel

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

the class UdpChannelTest method shouldParseWithNameResolver.

@ParameterizedTest
@CsvSource({ "NAME_ENDPOINT,192.168.1.1,,,UDP-127.0.0.1:0-NAME_ENDPOINT", "localhost:41024,127.0.0.1,,,UDP-127.0.0.1:0-localhost:41024", "[fe80::5246:5dff:fe73:df06]:40456,[fe80::5246:5dff:fe73:df06],,," + "UDP-127.0.0.1:0-[fe80::5246:5dff:fe73:df06]:40456", "NAME_ENDPOINT,224.0.1.1,,,UDP-127.0.0.1:0-224.0.1.1:40124", "NAME_ENDPOINT,192.168.1.1,NAME_CONTROL,192.168.1.2,UDP-NAME_CONTROL-NAME_ENDPOINT", "NAME_ENDPOINT,224.0.1.1,NAME_CONTROL,127.0.0.1,UDP-127.0.0.1:0-224.0.1.1:40124", "192.168.1.1:40124,192.168.1.1,NAME_CONTROL,192.168.1.2,UDP-NAME_CONTROL-192.168.1.1:40124", "192.168.1.1:40124,192.168.1.1,192.168.1.2:40192,192.168.1.2,UDP-192.168.1.2:40192-192.168.1.1:40124" })
void shouldParseWithNameResolver(final String endpointName, final String endpointAddress, final String controlName, final String controlAddress, final String canonicalForm) {
    final int port = 40124;
    final NameResolver resolver = new NameResolver() {

        public InetAddress resolve(final String name, final String uriParamName, final boolean isReResolution) {
            return DefaultNameResolver.INSTANCE.resolve(name, uriParamName, isReResolution);
        }

        public String lookup(final String name, final String uriParamName, final boolean isReLookup) {
            if (endpointName.equals(name)) {
                return endpointAddress + ":" + port;
            } else if (controlName.equals(name)) {
                return controlAddress + ":" + port;
            }
            return name;
        }
    };
    final ChannelUriStringBuilder uriBuilder = new ChannelUriStringBuilder().media("udp").networkInterface("localhost");
    if (!Strings.isEmpty(endpointName)) {
        uriBuilder.endpoint(endpointName);
    }
    if (!Strings.isEmpty(controlName)) {
        uriBuilder.controlEndpoint(controlName);
    }
    final UdpChannel udpChannel = UdpChannel.parse(uriBuilder.build(), resolver);
    assertThat(udpChannel.canonicalForm(), is(canonicalForm));
}
Also used : ChannelUriStringBuilder(io.aeron.ChannelUriStringBuilder) UdpChannel(io.aeron.driver.media.UdpChannel) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 37 with UdpChannel

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

the class UdpChannelTest method shouldHandleImpliedLocalPortFormat.

@Test
public void shouldHandleImpliedLocalPortFormat() {
    final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?interface=localhost|endpoint=localhost:40124");
    assertThat(udpChannel.localData(), is(new InetSocketAddress("localhost", 0)));
    assertThat(udpChannel.localControl(), is(new InetSocketAddress("localhost", 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) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 38 with UdpChannel

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

the class UdpChannelTest method shouldParseSocketRcvAndSndBufSizes.

@Test
void shouldParseSocketRcvAndSndBufSizes() {
    final UdpChannel udpChannelWithBufferSizes = UdpChannel.parse("aeron:udp?endpoint=127.0.0.1:9999|so-sndbuf=4096|so-rcvbuf=8192");
    assertEquals(4096, udpChannelWithBufferSizes.socketSndbufLength());
    assertEquals(8192, udpChannelWithBufferSizes.socketRcvbufLength());
    final UdpChannel udpChannelWithoutBufferSizes = UdpChannel.parse("aeron:udp?endpoint=127.0.0.1:9999");
    assertEquals(0, udpChannelWithoutBufferSizes.socketRcvbufLength());
    assertEquals(0, udpChannelWithoutBufferSizes.socketSndbufLength());
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 39 with UdpChannel

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

the class UdpChannelTest method shouldHandleCanonicalFormForMulticastCorrectlyWithAeronUri.

@ParameterizedTest
@CsvSource("endpoint,interface")
public void shouldHandleCanonicalFormForMulticastCorrectlyWithAeronUri(final String endpointKey, final String interfaceKey) {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "localhost"));
    final UdpChannel udpChannelLocal = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "127.0.0.1"));
    final UdpChannel udpChannelAllSystems = UdpChannel.parse(uri(endpointKey, "224.0.0.1:40456", interfaceKey, "127.0.0.1"));
    final UdpChannel udpChannelDefault = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456"));
    final UdpChannel udpChannelSubnet = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "localhost/24"));
    final UdpChannel udpChannelSubnetLocal = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "127.0.0.0/24"));
    assertThat(udpChannel.canonicalForm(), is("UDP-127.0.0.1:0-224.0.1.1:40456"));
    assertThat(udpChannelLocal.canonicalForm(), is("UDP-127.0.0.1:0-224.0.1.1:40456"));
    assertThat(udpChannelAllSystems.canonicalForm(), is("UDP-127.0.0.1:0-224.0.0.1:40456"));
    final Pattern canonicalFormPattern = Pattern.compile("UDP-127\\.0\\.0\\.[1-7]:0-224\\.0\\.1\\.1:40456");
    assertThat(udpChannelSubnet.canonicalForm(), matchesPattern(canonicalFormPattern));
    assertThat(udpChannelSubnetLocal.canonicalForm(), matchesPattern(canonicalFormPattern));
    assertThat(udpChannelDefault.localInterface(), supportsMulticastOrIsLoopback());
}
Also used : Pattern(java.util.regex.Pattern) UdpChannel(io.aeron.driver.media.UdpChannel) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 40 with UdpChannel

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

the class UdpChannelTest method shouldHandleIPv6AnyAddressAsInterfaceAddressForUnicast.

@ParameterizedTest
@CsvSource("endpoint,interface")
public void shouldHandleIPv6AnyAddressAsInterfaceAddressForUnicast(final String endpointKey, final String interfaceKey) {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "[::1]:40124", interfaceKey, "[::]"));
    assertThat(udpChannel.localData(), is(new InetSocketAddress("::", 0)));
    assertThat(udpChannel.localControl(), is(new InetSocketAddress("::", 0)));
    assertThat(udpChannel.remoteData(), is(new InetSocketAddress("::1", 40124)));
    assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("::1", 40124)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

UdpChannel (io.aeron.driver.media.UdpChannel)94 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)70 Test (org.junit.jupiter.api.Test)52 CsvSource (org.junit.jupiter.params.provider.CsvSource)22 ReceiveChannelEndpoint (io.aeron.driver.media.ReceiveChannelEndpoint)14 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)8 ControlProtocolException (io.aeron.exceptions.ControlProtocolException)6 ChannelUri (io.aeron.ChannelUri)4 PublicationParams (io.aeron.driver.PublicationParams)4 ReceiveDestinationTransport (io.aeron.driver.media.ReceiveDestinationTransport)4 Pattern (java.util.regex.Pattern)3 Aeron (io.aeron.Aeron)2 SPY_QUALIFIER (io.aeron.ChannelUri.SPY_QUALIFIER)2 CommonContext (io.aeron.CommonContext)2 FORCE_TRUE (io.aeron.CommonContext.InferableBoolean.FORCE_TRUE)2 INFER (io.aeron.CommonContext.InferableBoolean.INFER)2 ErrorCode (io.aeron.ErrorCode)2 Context (io.aeron.driver.MediaDriver.Context)2 SubscriptionParams.validateInitialWindowForRcvBuf (io.aeron.driver.SubscriptionParams.validateInitialWindowForRcvBuf)2 LogFactory (io.aeron.driver.buffer.LogFactory)2