use of io.aeron.driver.media.UdpChannel in project aeron by real-logic.
the class UdpChannelTest method shouldHandleBeingUsedAsMapKey.
@Test
public void shouldHandleBeingUsedAsMapKey() {
final UdpChannel udpChannel1 = UdpChannel.parse("aeron:udp?endpoint=localhost:40124");
final UdpChannel udpChannel2 = UdpChannel.parse("aeron:udp?endpoint=localhost:40124");
final Map<UdpChannel, Integer> map = new HashMap<>();
map.put(udpChannel1, 1);
assertThat(map.get(udpChannel2), is(1));
}
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));
}
use of io.aeron.driver.media.UdpChannel in project aeron by real-logic.
the class UdpChannelTest method shouldHandleExplicitLocalAddressAndPortFormatWithAeronUri.
@ParameterizedTest
@CsvSource("endpoint,interface")
public void shouldHandleExplicitLocalAddressAndPortFormatWithAeronUri(final String endpointKey, final String interfaceKey) {
final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "localhost:40124", interfaceKey, "localhost:40123"));
assertThat(udpChannel.localData(), is(new InetSocketAddress("localhost", 40123)));
assertThat(udpChannel.localControl(), is(new InetSocketAddress("localhost", 40123)));
assertThat(udpChannel.remoteData(), is(new InetSocketAddress("localhost", 40124)));
assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("localhost", 40124)));
}
use of io.aeron.driver.media.UdpChannel in project aeron by real-logic.
the class UdpChannelTest method shouldParseValidMulticastAddress.
@Test
public void shouldParseValidMulticastAddress() throws IOException {
final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?interface=localhost|endpoint=224.10.9.9:40124");
assertThat(udpChannel.localControl(), is(new InetSocketAddress("localhost", 0)));
assertThat(udpChannel.remoteControl(), isMulticastAddress("224.10.9.10", 40124));
assertThat(udpChannel.localData(), is(new InetSocketAddress("localhost", 0)));
assertThat(udpChannel.remoteData(), isMulticastAddress("224.10.9.9", 40124));
assertThat(udpChannel.localInterface(), is(NetworkInterface.getByInetAddress(getByName("localhost"))));
}
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)));
}
Aggregations