Java Code Examples for io.aeron.CommonContext#SESSION_ID_PARAM_NAME

The following examples show how to use io.aeron.CommonContext#SESSION_ID_PARAM_NAME . 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 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
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 13
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 14
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());
}