io.aeron.CommonContext Java Examples

The following examples show how to use io.aeron.CommonContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldErrorOnAddPublicationWithNonEqualSessionId()
{
    driverProxy.addPublication(CHANNEL_4000, STREAM_ID_1);
    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> argumentCaptor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy).newNetworkPublication(argumentCaptor.capture());

    final String sessionIdParam =
        "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + (argumentCaptor.getValue().sessionId() + 1);
    final long correlationId = driverProxy.addPublication(CHANNEL_4000 + sessionIdParam, STREAM_ID_1);
    driverConductor.doWork();

    verify(mockClientProxy).onError(eq(correlationId), eq(GENERIC_ERROR), anyString());
    verify(mockErrorCounter).increment();
    verify(mockErrorHandler).onError(any(Throwable.class));
}
 
Example #2
Source File: DriverConductor.java    From aeron with Apache License 2.0 6 votes vote down vote up
void onReResolveControl(
    final String control,
    final UdpChannel udpChannel,
    final ReceiveChannelEndpoint channelEndpoint,
    final InetSocketAddress address)
{
    final InetSocketAddress newAddress;
    try
    {
        newAddress = UdpChannel.resolve(control, CommonContext.MDC_CONTROL_PARAM_NAME, true, nameResolver);

        if (!address.equals(newAddress))
        {
            receiverProxy.onResolutionChange(channelEndpoint, udpChannel, newAddress);
        }
    }
    catch (final UnknownHostException ex)
    {
        LangUtil.rethrowUnchecked(ex);
    }
}
 
Example #3
Source File: DriverConductor.java    From aeron with Apache License 2.0 6 votes vote down vote up
private SendChannelEndpoint findExistingSendChannelEndpoint(final UdpChannel udpChannel)
{
    if (udpChannel.hasTag())
    {
        for (final SendChannelEndpoint endpoint : sendChannelEndpointByChannelMap.values())
        {
            final UdpChannel endpointUdpChannel = endpoint.udpChannel();
            if (endpointUdpChannel.matchesTag(udpChannel))
            {
                return endpoint;
            }
        }

        if (!udpChannel.hasExplicitControl() && !udpChannel.isManualControlMode() &&
            !udpChannel.channelUri().containsKey(CommonContext.ENDPOINT_PARAM_NAME))
        {
            throw new InvalidChannelException(
                "URI must have explicit control, endpoint, or be manual control-mode when original: " +
                udpChannel.originalUriString());
        }
    }

    return sendChannelEndpointByChannelMap.get(udpChannel.canonicalForm());
}
 
Example #4
Source File: DriverConductor.java    From aeron with Apache License 2.0 6 votes vote down vote up
private void linkSpies(final ArrayList<SubscriptionLink> links, final NetworkPublication publication)
{
    for (int i = 0, size = links.size(); i < size; i++)
    {
        final SubscriptionLink subscription = links.get(i);
        if (subscription.matches(publication) && !subscription.isLinked(publication))
        {
            clientProxy.onAvailableImage(
                publication.registrationId(),
                publication.streamId(),
                publication.sessionId(),
                subscription.registrationId(),
                linkSpy(publication, subscription).id(),
                publication.rawLog().fileName(),
                CommonContext.IPC_CHANNEL);
        }
    }
}
 
Example #5
Source File: DriverConductor.java    From aeron with Apache License 2.0 6 votes vote down vote up
void onReResolveEndpoint(
    final String endpoint, final SendChannelEndpoint channelEndpoint, final InetSocketAddress address)
{
    final InetSocketAddress newAddress;
    try
    {
        newAddress = UdpChannel.resolve(endpoint, CommonContext.ENDPOINT_PARAM_NAME, true, nameResolver);

        if (!address.equals(newAddress))
        {
            senderProxy.onResolutionChange(channelEndpoint, endpoint, newAddress);
        }
    }
    catch (final UnknownHostException ex)
    {
        LangUtil.rethrowUnchecked(ex);
    }
}
 
Example #6
Source File: MultiRcvDestination.java    From aeron with Apache License 2.0 6 votes vote down vote up
void checkForReResolution(
    final ReceiveChannelEndpoint channelEndpoint, final long nowNs, final DriverConductorProxy conductorProxy)
{
    for (final ReceiveDestinationTransport transport : transports)
    {
        if (null != transport)
        {
            final UdpChannel udpChannel = transport.udpChannel();

            if (udpChannel.hasExplicitControl() &&
                (transport.timeOfLastActivityNs() + destinationEndpointTimeoutNs) < nowNs)
            {
                conductorProxy.reResolveControl(
                    udpChannel.channelUri().get(CommonContext.MDC_CONTROL_PARAM_NAME),
                    udpChannel,
                    channelEndpoint,
                    transport.currentControlAddress());
                transport.timeOfLastActivityNs(nowNs);
            }
        }
    }
}
 
Example #7
Source File: TerminateDriverTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
@Timeout(10)
public void shouldCallTerminationHookUponValidRequest()
{
    final AtomicBoolean hasTerminated = new AtomicBoolean(false);
    final MediaDriver.Context ctx = new MediaDriver.Context()
        .dirDeleteOnStart(true)
        .dirDeleteOnShutdown(true)
        .terminationHook(() -> hasTerminated.lazySet(true))
        .terminationValidator(mockTerminationValidator);

    when(mockTerminationValidator.allowTermination(any(), any(), anyInt(), anyInt())).thenReturn(true);

    try (MediaDriver ignore = MediaDriver.launch(ctx))
    {
        assertTrue(CommonContext.requestDriverTermination(ctx.aeronDirectory(), null, 0, 0));

        while (!hasTerminated.get())
        {
            Tests.yield();
        }
    }

    verify(mockTerminationValidator).allowTermination(any(), any(), anyInt(), anyInt());
}
 
Example #8
Source File: UdpChannel.java    From aeron with Apache License 2.0 6 votes vote down vote up
private static InetSocketAddress getEndpointAddress(final ChannelUri uri, final NameResolver nameResolver)
{
    InetSocketAddress address = null;
    final String endpointValue = uri.get(CommonContext.ENDPOINT_PARAM_NAME);
    if (null != endpointValue)
    {
        try
        {
            address = SocketAddressParser.parse(
                endpointValue, CommonContext.ENDPOINT_PARAM_NAME, false, nameResolver);
        }
        catch (final UnknownHostException ex)
        {
            LangUtil.rethrowUnchecked(ex);
        }
    }

    return address;
}
 
Example #9
Source File: SingleNodeCluster.java    From aeron with Apache License 2.0 6 votes vote down vote up
void connectClientToCluster()
{
    final String aeronDirectoryName = CommonContext.getAeronDirectoryName() + "-client";

    clientMediaDriver = MediaDriver.launch(
        new MediaDriver.Context()
            .threadingMode(ThreadingMode.SHARED)
            .dirDeleteOnStart(true)
            .dirDeleteOnShutdown(true)
            .errorHandler(Throwable::printStackTrace)
            .aeronDirectoryName(aeronDirectoryName));

    client = AeronCluster.connect(
        new AeronCluster.Context()
            .errorHandler(Throwable::printStackTrace)
            .egressListener(egressMessageListener)
            .aeronDirectoryName(aeronDirectoryName));
}
 
Example #10
Source File: UdpChannel.java    From aeron with Apache License 2.0 6 votes vote down vote up
private static InetSocketAddress getExplicitControlAddress(final ChannelUri uri, final NameResolver nameResolver)
{
    InetSocketAddress address = null;
    final String controlValue = uri.get(CommonContext.MDC_CONTROL_PARAM_NAME);
    if (null != controlValue)
    {
        try
        {
            address = SocketAddressParser.parse(
                controlValue, CommonContext.MDC_CONTROL_PARAM_NAME, false, nameResolver);
        }
        catch (final UnknownHostException ex)
        {
            LangUtil.rethrowUnchecked(ex);
        }
    }

    return address;
}
 
Example #11
Source File: ReceiveChannelEndpoint.java    From aeron with Apache License 2.0 6 votes vote down vote up
public void checkForReResolution(final long nowNs, final DriverConductorProxy conductorProxy)
{
    if (null != multiRcvDestination)
    {
        multiRcvDestination.checkForReResolution(this, nowNs, conductorProxy);
    }
    else if (udpChannel.hasExplicitControl() && (timeOfLastActivityNs + DESTINATION_ADDRESS_TIMEOUT) - nowNs < 0)
    {
        conductorProxy.reResolveControl(
            udpChannel.channelUri().get(CommonContext.MDC_CONTROL_PARAM_NAME),
            udpChannel,
            this,
            currentControlAddress);
        timeOfLastActivityNs = nowNs;
    }
}
 
Example #12
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAddPublicationWithSameSessionId()
{
    driverProxy.addPublication(CHANNEL_4000, STREAM_ID_1);
    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> argumentCaptor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy).newNetworkPublication(argumentCaptor.capture());

    final int sessionId = argumentCaptor.getValue().sessionId();
    final String sessionIdParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionId;
    driverProxy.addPublication(CHANNEL_4000 + sessionIdParam, STREAM_ID_1);
    driverConductor.doWork();

    verify(mockClientProxy, times(2)).onPublicationReady(
        anyLong(), anyLong(), eq(STREAM_ID_1), eq(sessionId), anyString(), anyInt(), anyInt(), eq(false));
}
 
Example #13
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAddExclusivePublicationWithSameSessionId()
{
    driverProxy.addPublication(CHANNEL_4000, STREAM_ID_1);
    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> argumentCaptor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy).newNetworkPublication(argumentCaptor.capture());

    final int sessionId = argumentCaptor.getValue().sessionId();
    final String sessionIdParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + (sessionId + 1);
    driverProxy.addExclusivePublication(CHANNEL_4000 + sessionIdParam, STREAM_ID_1);
    driverConductor.doWork();

    verify(mockClientProxy).onPublicationReady(
        anyLong(), anyLong(), eq(STREAM_ID_1), eq(sessionId), anyString(), anyInt(), anyInt(), eq(false));
    verify(mockClientProxy).onPublicationReady(
        anyLong(), anyLong(), eq(STREAM_ID_1), eq(sessionId + 1), anyString(), anyInt(), anyInt(), eq(true));
}
 
Example #14
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldErrorOnAddPublicationWithClashingSessionId()
{
    driverProxy.addPublication(CHANNEL_4000, STREAM_ID_1);
    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> argumentCaptor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy).newNetworkPublication(argumentCaptor.capture());

    final String sessionIdParam =
        "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + argumentCaptor.getValue().sessionId();
    final long correlationId = driverProxy.addExclusivePublication(CHANNEL_4000 + sessionIdParam, STREAM_ID_1);
    driverConductor.doWork();

    verify(mockClientProxy).onError(eq(correlationId), eq(GENERIC_ERROR), anyString());
    verify(mockErrorCounter).increment();
    verify(mockErrorHandler).onError(any(Throwable.class));
}
 
Example #15
Source File: MultiModuleSharedDriverTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
MultiClusterNode(final int nodeId)
{
    this.nodeId = nodeId;

    final MediaDriver.Context driverCtx = new MediaDriver.Context()
        .aeronDirectoryName(CommonContext.getAeronDirectoryName() + "-" + nodeId)
        .threadingMode(ThreadingMode.SHARED)
        .errorHandler(Tests::onError)
        .dirDeleteOnStart(true);

    final Archive.Context archiveCtx = new Archive.Context()
        .threadingMode(ArchiveThreadingMode.SHARED)
        .archiveDir(new File(SystemUtil.tmpDirName(), "archive-" + nodeId))
        .controlChannel("aeron:udp?endpoint=localhost:801" + nodeId)
        .errorHandler(Tests::onError)
        .recordingEventsEnabled(false)
        .deleteArchiveOnStart(true);

    archivingMediaDriver = ArchivingMediaDriver.launch(driverCtx, archiveCtx);
    consensusModule0 = consensusModule(0, driverCtx.aeronDirectoryName());
    container0 = container(consensusModule0.context());
    consensusModule1 = consensusModule(1, driverCtx.aeronDirectoryName());
    container1 = container(consensusModule1.context());
}
 
Example #16
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAddIpcPublicationThenSubscriptionWithSessionId()
{
    final int sessionId = -4097;
    final String sessionIdParam = "?" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionId;
    final String channelIpcAndSessionId = CHANNEL_IPC + sessionIdParam;

    driverProxy.addPublication(channelIpcAndSessionId, STREAM_ID_1);
    driverProxy.addSubscription(channelIpcAndSessionId, STREAM_ID_1);

    driverConductor.doWork();

    final IpcPublication ipcPublication = driverConductor.getSharedIpcPublication(STREAM_ID_1);
    assertNotNull(ipcPublication);

    verify(mockClientProxy).onAvailableImage(
        eq(ipcPublication.registrationId()), eq(STREAM_ID_1), eq(ipcPublication.sessionId()),
        anyLong(), anyInt(), eq(ipcPublication.rawLog().fileName()), anyString());
}
 
Example #17
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAddIpcSubscriptionThenPublicationWithSessionId()
{
    final int sessionId = -4097;
    final String sessionIdParam = "?" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionId;
    final String channelIpcAndSessionId = CHANNEL_IPC + sessionIdParam;

    driverProxy.addSubscription(channelIpcAndSessionId, STREAM_ID_1);
    driverProxy.addPublication(channelIpcAndSessionId, STREAM_ID_1);

    driverConductor.doWork();

    final IpcPublication ipcPublication = driverConductor.getSharedIpcPublication(STREAM_ID_1);
    assertNotNull(ipcPublication);

    verify(mockClientProxy).onAvailableImage(
        eq(ipcPublication.registrationId()), eq(STREAM_ID_1), eq(ipcPublication.sessionId()),
        anyLong(), anyInt(), eq(ipcPublication.rawLog().fileName()), anyString());
}
 
Example #18
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldNotAddIpcPublicationThenSubscriptionWithDifferentSessionId()
{
    final int sessionIdPub = -4097;
    final int sessionIdSub = -4098;
    final String sessionIdPubParam = "?" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionIdPub;
    final String sessionIdSubParam = "?" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionIdSub;

    driverProxy.addPublication(CHANNEL_IPC + sessionIdPubParam, STREAM_ID_1);
    driverProxy.addSubscription(CHANNEL_IPC + sessionIdSubParam, STREAM_ID_1);

    driverConductor.doWork();

    final IpcPublication ipcPublication = driverConductor.getSharedIpcPublication(STREAM_ID_1);
    assertNotNull(ipcPublication);

    verify(mockClientProxy, never()).onAvailableImage(
        anyLong(), eq(STREAM_ID_1), anyInt(), anyLong(), anyInt(), anyString(), anyString());
}
 
Example #19
Source File: DistinctErrorLogTestWatcher.java    From aeron with Apache License 2.0 6 votes vote down vote up
public void captureErrors(final String aeronDirectoryName)
{
    final File cncFile = CommonContext.newCncFile(aeronDirectoryName);
    assertTrue(cncFile.exists());

    MappedByteBuffer cncByteBuffer = null;

    try (RandomAccessFile file = new RandomAccessFile(cncFile, "r");
        FileChannel channel = file.getChannel())
    {
        cncByteBuffer = channel.map(READ_ONLY, 0, channel.size());
        final AtomicBuffer errorLogBuffer = CommonContext.errorLogBuffer(cncByteBuffer);

        ErrorLogReader.read(errorLogBuffer, this::onObservation);
    }
    catch (final IOException ex)
    {
        ex.printStackTrace();
    }
    finally
    {
        IoUtil.unmap(cncByteBuffer);
    }
}
 
Example #20
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldNotAddIpcSubscriptionThenPublicationWithDifferentSessionId()
{
    final int sessionIdPub = -4097;
    final int sessionIdSub = -4098;
    final String sessionIdPubParam = "?" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionIdPub;
    final String sessionIdSubParam = "?" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionIdSub;

    driverProxy.addSubscription(CHANNEL_IPC + sessionIdSubParam, STREAM_ID_1);
    driverProxy.addPublication(CHANNEL_IPC + sessionIdPubParam, STREAM_ID_1);

    driverConductor.doWork();

    final IpcPublication ipcPublication = driverConductor.getSharedIpcPublication(STREAM_ID_1);
    assertNotNull(ipcPublication);

    verify(mockClientProxy, never()).onAvailableImage(
        anyLong(), eq(STREAM_ID_1), anyInt(), anyLong(), anyInt(), anyString(), anyString());
}
 
Example #21
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAddNetworkPublicationThenSingleSpyWithSameSessionId()
{
    final int sessionId = -4097;
    final String sessionIdParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionId;
    driverProxy.addPublication(CHANNEL_4000 + sessionIdParam, STREAM_ID_1);
    driverProxy.addSubscription(spyForChannel(CHANNEL_4000 + sessionIdParam), STREAM_ID_1);

    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> captor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy, times(1)).newNetworkPublication(captor.capture());
    final NetworkPublication publication = captor.getValue();

    assertTrue(publication.hasSpies());

    verify(mockClientProxy).onAvailableImage(
        eq(networkPublicationCorrelationId(publication)), eq(STREAM_ID_1), eq(publication.sessionId()),
        anyLong(), anyInt(), eq(publication.rawLog().fileName()), anyString());
}
 
Example #22
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldNotAddNetworkPublicationThenSingleSpyWithDifferentSessionId()
{
    final int sessionIdPub = -4097;
    final int sessionIdSub = -4098;
    final String sessionIdPubParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionIdPub;
    final String sessionIdSubParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionIdSub;
    driverProxy.addPublication(CHANNEL_4000 + sessionIdPubParam, STREAM_ID_1);
    driverProxy.addSubscription(spyForChannel(CHANNEL_4000 + sessionIdSubParam), STREAM_ID_1);

    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> captor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy, times(1)).newNetworkPublication(captor.capture());
    final NetworkPublication publication = captor.getValue();

    assertFalse(publication.hasSpies());

    verify(mockClientProxy, never()).onAvailableImage(
        anyLong(), eq(STREAM_ID_1), anyInt(), anyLong(), anyInt(), anyString(), anyString());
}
 
Example #23
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAddSingleSpyThenNetworkPublicationWithSameSessionId()
{
    final int sessionId = -4097;
    final String sessionIdParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionId;
    driverProxy.addSubscription(spyForChannel(CHANNEL_4000 + sessionIdParam), STREAM_ID_1);
    driverProxy.addPublication(CHANNEL_4000 + sessionIdParam, STREAM_ID_1);

    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> captor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy, times(1)).newNetworkPublication(captor.capture());
    final NetworkPublication publication = captor.getValue();

    assertTrue(publication.hasSpies());

    verify(mockClientProxy).onAvailableImage(
        eq(networkPublicationCorrelationId(publication)), eq(STREAM_ID_1), eq(publication.sessionId()),
        anyLong(), anyInt(), eq(publication.rawLog().fileName()), anyString());
}
 
Example #24
Source File: ArchiveTool.java    From aeron with Apache License 2.0 6 votes vote down vote up
private static void printErrors(final PrintStream out, final ArchiveMarkFile markFile)
{
    out.println("Archive error log:");
    CommonContext.printErrorLog(markFile.errorBuffer(), out);

    final MarkFileHeaderDecoder decoder = markFile.decoder();
    decoder.skipControlChannel();
    decoder.skipLocalControlChannel();
    decoder.skipEventsChannel();
    final String aeronDirectory = decoder.aeronDirectory();

    out.println();
    out.println("Aeron driver error log (directory: " + aeronDirectory + "):");
    final File cncFile = new File(aeronDirectory, CncFileDescriptor.CNC_FILE);

    final MappedByteBuffer cncByteBuffer = IoUtil.mapExistingFile(cncFile, FileChannel.MapMode.READ_ONLY, "cnc");
    final DirectBuffer cncMetaDataBuffer = CncFileDescriptor.createMetaDataBuffer(cncByteBuffer);
    final int cncVersion = cncMetaDataBuffer.getInt(CncFileDescriptor.cncVersionOffset(0));

    CncFileDescriptor.checkVersion(cncVersion);
    CommonContext.printErrorLog(CncFileDescriptor.createErrorLogBuffer(cncByteBuffer, cncMetaDataBuffer), out);
}
 
Example #25
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldNotAddSingleSpyThenNetworkPublicationWithDifferentSessionId()
{
    final int sessionIdPub = -4097;
    final int sessionIdSub = -4098;
    final String sessionIdPubParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionIdPub;
    final String sessionIdSubParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionIdSub;
    driverProxy.addSubscription(spyForChannel(CHANNEL_4000 + sessionIdSubParam), STREAM_ID_1);
    driverProxy.addPublication(CHANNEL_4000 + sessionIdPubParam, STREAM_ID_1);

    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> captor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy, times(1)).newNetworkPublication(captor.capture());
    final NetworkPublication publication = captor.getValue();

    assertFalse(publication.hasSpies());

    verify(mockClientProxy, never()).onAvailableImage(
        anyLong(), eq(STREAM_ID_1), anyInt(), anyLong(), anyInt(), anyString(), anyString());
}
 
Example #26
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldAddPublicationWithMtu()
{
    final int mtuLength = 4096;
    final String mtuParam = "|" + CommonContext.MTU_LENGTH_PARAM_NAME + "=" + mtuLength;
    driverProxy.addPublication(CHANNEL_4000 + mtuParam, STREAM_ID_1);

    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> argumentCaptor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy).newNetworkPublication(argumentCaptor.capture());

    assertEquals(mtuLength, argumentCaptor.getValue().mtuLength());
}
 
Example #27
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldAddExclusivePublicationWithSessionId()
{
    final int sessionId = 4096;
    final String sessionIdParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionId;
    driverProxy.addExclusivePublication(CHANNEL_4000 + sessionIdParam, STREAM_ID_1);

    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> argumentCaptor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy).newNetworkPublication(argumentCaptor.capture());

    assertEquals(sessionId, argumentCaptor.getValue().sessionId());
}
 
Example #28
Source File: DriverConductorTest.java    From aeron with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldAddPublicationWithSessionId()
{
    final int sessionId = 4096;
    final String sessionIdParam = "|" + CommonContext.SESSION_ID_PARAM_NAME + "=" + sessionId;
    driverProxy.addPublication(CHANNEL_4000 + sessionIdParam, STREAM_ID_1);

    driverConductor.doWork();

    final ArgumentCaptor<NetworkPublication> argumentCaptor = ArgumentCaptor.forClass(NetworkPublication.class);
    verify(senderProxy).newNetworkPublication(argumentCaptor.capture());

    assertEquals(sessionId, argumentCaptor.getValue().sessionId());
}
 
Example #29
Source File: ReceiveChannelEndpoint.java    From aeron with Apache License 2.0 5 votes vote down vote up
public ReceiveChannelEndpoint(
    final UdpChannel udpChannel,
    final DataPacketDispatcher dispatcher,
    final AtomicCounter statusIndicator,
    final MediaDriver.Context context)
{
    super(udpChannel, udpChannel.remoteData(), udpChannel.remoteData(), null, context);

    this.dispatcher = dispatcher;
    this.statusIndicator = statusIndicator;

    shortSends = context.systemCounters().get(SHORT_SENDS);
    possibleTtlAsymmetry = context.systemCounters().get(POSSIBLE_TTL_ASYMMETRY);

    final ReceiveChannelEndpointThreadLocals threadLocals = context.receiveChannelEndpointThreadLocals();
    smBuffer = threadLocals.smBuffer();
    statusMessageFlyweight = threadLocals.statusMessageFlyweight();
    nakBuffer = threadLocals.nakBuffer();
    nakFlyweight = threadLocals.nakFlyweight();
    rttMeasurementBuffer = threadLocals.rttMeasurementBuffer();
    rttMeasurementFlyweight = threadLocals.rttMeasurementFlyweight();
    cachedNanoClock = context.cachedNanoClock();
    timeOfLastActivityNs = cachedNanoClock.nanoTime();
    receiverId = threadLocals.receiverId();

    final String groupTagValue = udpChannel.channelUri().get(CommonContext.GROUP_TAG_PARAM_NAME);
    groupTag = null == groupTagValue ? context.receiverGroupTag() : Long.valueOf(groupTagValue);

    multiRcvDestination = udpChannel.isManualControlMode() ?
        new MultiRcvDestination(context.nanoClock(), DESTINATION_ADDRESS_TIMEOUT, errorHandler) : null;
    currentControlAddress = udpChannel.localControl();
}
 
Example #30
Source File: UdpNameResolutionTransport.java    From aeron with Apache License 2.0 5 votes vote down vote up
public static InetSocketAddress getInetSocketAddress(final String hostAndPort)
{
    try
    {
        return SocketAddressParser.parse(
            hostAndPort, CommonContext.ENDPOINT_PARAM_NAME, false, DefaultNameResolver.INSTANCE);
    }
    catch (final UnknownHostException e)
    {
        LangUtil.rethrowUnchecked(e);
        return null;
    }
}