Search in sources :

Example 71 with UdpChannel

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

the class StaticWindowCongestionControlTest method shouldSetWindowLengthFromTermLength.

@Test
void shouldSetWindowLengthFromTermLength() {
    final UdpChannel channelWithWindow = UdpChannel.parse("aeron:udp?endpoint=127.0.0.1:9999|rcv-wnd=8192");
    final MediaDriver.Context context = new MediaDriver.Context().initialWindowLength(16536);
    final int termLength = 8192;
    final StaticWindowCongestionControl staticWindowCongestionControl = new StaticWindowCongestionControl(0, channelWithWindow, 0, 0, termLength, 0, null, null, null, context, null);
    assertEquals(termLength / 2, staticWindowCongestionControl.initialWindowLength());
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Test(org.junit.jupiter.api.Test)

Example 72 with UdpChannel

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

the class TaggedMulticastFlowControlTest method shouldReturnLastWindowWhenUntilReceiversAreInGroupWithNoMinSize.

@Test
void shouldReturnLastWindowWhenUntilReceiversAreInGroupWithNoMinSize() {
    final UdpChannel channelGroupSizeThree = UdpChannel.parse("aeron:udp?endpoint=224.20.30.39:24326|interface=localhost|fc=tagged,g:123");
    flowControl.initialize(new MediaDriver.Context(), channelGroupSizeThree, 0, 0);
    final long groupTag = 123L;
    final long senderLimit = 5000L;
    final int termOffset0 = 10_000;
    final int termOffset1 = 9_999;
    assertEquals(termOffset0 + WINDOW_LENGTH, onStatusMessage(flowControl, 0, termOffset0, senderLimit, null));
    assertEquals(termOffset1 + WINDOW_LENGTH, onStatusMessage(flowControl, 1, termOffset1, senderLimit, groupTag));
    assertEquals(termOffset1 + WINDOW_LENGTH, onStatusMessage(flowControl, 0, termOffset0, senderLimit, null));
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 73 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.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 74 with UdpChannel

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

the class UdpChannelTest method shouldHandleImpliedLocalAddressAndPortFormat.

@Test
public void shouldHandleImpliedLocalAddressAndPortFormat() {
    final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?endpoint=localhost:40124");
    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) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 75 with UdpChannel

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

the class DriverConductor method onAddNetworkPublication.

void onAddNetworkPublication(final String channel, final int streamId, final long correlationId, final long clientId, final boolean isExclusive) {
    final UdpChannel udpChannel = UdpChannel.parse(channel, nameResolver);
    final ChannelUri channelUri = udpChannel.channelUri();
    final PublicationParams params = getPublicationParams(channelUri, ctx, this, false);
    validateEndpointForPublication(udpChannel);
    validateMtuForMaxMessage(params, channel);
    final SendChannelEndpoint channelEndpoint = getOrCreateSendChannelEndpoint(params, udpChannel, correlationId);
    NetworkPublication publication = null;
    if (!isExclusive) {
        publication = findPublication(networkPublications, streamId, channelEndpoint);
    }
    boolean isNewPublication = false;
    if (null == publication) {
        if (params.hasSessionId) {
            checkForSessionClash(params.sessionId, streamId, udpChannel.canonicalForm(), channel);
        }
        publication = newNetworkPublication(correlationId, clientId, streamId, channel, udpChannel, channelEndpoint, params, isExclusive);
        isNewPublication = true;
    } else {
        confirmMatch(channelUri, params, publication.rawLog(), publication.sessionId(), publication.channel(), publication.initialTermId(), publication.startingTermId(), publication.startingTermOffset());
        validateSpiesSimulateConnection(params, publication.spiesSimulateConnection(), channel, publication.channel());
    }
    publicationLinks.add(new PublicationLink(correlationId, getOrAddClient(clientId), publication));
    clientProxy.onPublicationReady(correlationId, publication.registrationId(), streamId, publication.sessionId(), publication.rawLog().fileName(), publication.publisherLimitId(), channelEndpoint.statusIndicatorCounterId(), isExclusive);
    if (isNewPublication) {
        linkSpies(subscriptionLinks, publication);
    }
}
Also used : ChannelUri(io.aeron.ChannelUri) PublicationParams(io.aeron.driver.PublicationParams) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint) UdpChannel(io.aeron.driver.media.UdpChannel)

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