Search in sources :

Example 21 with UdpChannel

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

the class DriverConductor method onAddSpySubscription.

void onAddSpySubscription(final String channel, final int streamId, final long registrationId, final long clientId) {
    final UdpChannel udpChannel = UdpChannel.parse(channel);
    final AeronClient client = getOrAddClient(clientId);
    final SpySubscriptionLink subscriptionLink = new SpySubscriptionLink(registrationId, udpChannel, streamId, client, context.clientLivenessTimeoutNs());
    subscriptionLinks.add(subscriptionLink);
    clientProxy.operationSucceeded(registrationId);
    final SendChannelEndpoint channelEndpoint = sendChannelEndpointByChannelMap.get(udpChannel.canonicalForm());
    for (int i = 0, size = networkPublications.size(); i < size; i++) {
        final NetworkPublication publication = networkPublications.get(i);
        if (streamId == publication.streamId() && channelEndpoint == publication.channelEndpoint() && NetworkPublication.Status.ACTIVE == publication.status()) {
            linkSpy(publication, subscriptionLink);
        }
    }
}
Also used : SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint) UdpChannel(io.aeron.driver.media.UdpChannel) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Example 22 with UdpChannel

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

the class UdpChannelTest method shouldHandleExplicitLocalAddressAndPortFormatWithAeronUri.

@Theory
public void shouldHandleExplicitLocalAddressAndPortFormatWithAeronUri(@Values({ "endpoint" }) final String endpointKey, @Values({ "interface" }) final String interfaceKey) throws Exception {
    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)));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Theory(org.junit.experimental.theories.Theory)

Example 23 with UdpChannel

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

the class UdpChannelTest method shouldHandleLocalhostLookupWithAeronUri.

@Theory
public void shouldHandleLocalhostLookupWithAeronUri(@Values({ "endpoint" }) final String endpointKey) throws Exception {
    final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "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) Theory(org.junit.experimental.theories.Theory)

Example 24 with UdpChannel

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

the class UdpChannelTest method shouldHandleCanonicalFormForUnicastCorrectly.

@Test
public void shouldHandleCanonicalFormForUnicastCorrectly() throws Exception {
    final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?endpoint=192.168.0.1:40456");
    final UdpChannel udpChannelLocal = UdpChannel.parse("aeron:udp?interface=127.0.0.1|endpoint=192.168.0.1:40456");
    final UdpChannel udpChannelLocalPort = UdpChannel.parse("aeron:udp?interface=127.0.0.1:40455|endpoint=192.168.0.1:40456");
    final UdpChannel udpChannelLocalhost = UdpChannel.parse("aeron:udp?interface=localhost|endpoint=localhost:40456");
    assertThat(udpChannel.canonicalForm(), is("UDP-00000000-0-c0a80001-40456"));
    assertThat(udpChannelLocal.canonicalForm(), is("UDP-7f000001-0-c0a80001-40456"));
    assertThat(udpChannelLocalPort.canonicalForm(), is("UDP-7f000001-40455-c0a80001-40456"));
    assertThat(udpChannelLocalhost.canonicalForm(), is("UDP-7f000001-0-7f000001-40456"));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Test(org.junit.Test)

Example 25 with UdpChannel

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

the class UdpChannelTest method shouldGetProtocolFamilyForIpV6WithoutLocalSpecified.

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

Aggregations

UdpChannel (io.aeron.driver.media.UdpChannel)31 Test (org.junit.Test)16 Theory (org.junit.experimental.theories.Theory)11 ReceiveChannelEndpoint (io.aeron.driver.media.ReceiveChannelEndpoint)6 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)4 RawLog (io.aeron.driver.buffer.RawLog)1 AeronUri (io.aeron.driver.uri.AeronUri)1 HashMap (java.util.HashMap)1