當前位置: 首頁>>代碼示例>>Java>>正文


Java CommonContext類代碼示例

本文整理匯總了Java中io.aeron.CommonContext的典型用法代碼示例。如果您正苦於以下問題:Java CommonContext類的具體用法?Java CommonContext怎麽用?Java CommonContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CommonContext類屬於io.aeron包,在下文中一共展示了CommonContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mapCounters

import io.aeron.CommonContext; //導入依賴的package包/類
public static CountersReader mapCounters()
{
    final File cncFile = CommonContext.newDefaultCncFile();
    System.out.println("Command `n Control file " + cncFile);

    final MappedByteBuffer cncByteBuffer = IoUtil.mapExistingFile(cncFile, "cnc");
    final DirectBuffer cncMetaData = createMetaDataBuffer(cncByteBuffer);
    final int cncVersion = cncMetaData.getInt(cncVersionOffset(0));

    if (CncFileDescriptor.CNC_VERSION != cncVersion)
    {
        throw new IllegalStateException(
            "Aeron CnC version does not match: version=" + cncVersion + " required=" + CNC_VERSION);
    }

    return new CountersReader(
        createCountersMetaDataBuffer(cncByteBuffer, cncMetaData),
        createCountersValuesBuffer(cncByteBuffer, cncMetaData),
        StandardCharsets.US_ASCII);
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:21,代碼來源:AeronStat.java

示例2: main

import io.aeron.CommonContext; //導入依賴的package包/類
public static void main(final String[] args)
{
    final File cncFile = CommonContext.newDefaultCncFile();
    System.out.println("Command `n Control file " + cncFile);

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

    if (CNC_VERSION != cncVersion)
    {
        throw new IllegalStateException(
            "Aeron CnC version does not match: version=" + cncVersion + " required=" + CNC_VERSION);
    }

    final AtomicBuffer buffer = CncFileDescriptor.createErrorLogBuffer(cncByteBuffer, cncMetaDataBuffer);
    final int distinctErrorCount = ErrorLogReader.read(buffer, ErrorStat::accept);

    System.out.format("%n%d distinct errors observed.%n", distinctErrorCount);
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:21,代碼來源:ErrorStat.java

示例3: transitionToLinger

import io.aeron.CommonContext; //導入依賴的package包/類
void transitionToLinger(final IpcPublication publication)
{
    for (int i = 0, size = subscriptionLinks.size(); i < size; i++)
    {
        final SubscriptionLink link = subscriptionLinks.get(i);

        if (link.isLinked(publication))
        {
            clientProxy.onUnavailableImage(
                publication.registrationId(),
                link.registrationId(),
                publication.streamId(),
                CommonContext.IPC_CHANNEL);
        }
    }
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:17,代碼來源:DriverConductor.java

示例4: linkSpies

import io.aeron.CommonContext; //導入依賴的package包/類
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))
        {
            final Position subPos = linkSpy(publication, subscription);

            clientProxy.onAvailableImage(
                publication.registrationId(),
                publication.streamId(),
                publication.sessionId(),
                subscription.registrationId(),
                subPos.id(),
                publication.rawLog().fileName(),
                CommonContext.IPC_CHANNEL);
        }
    }
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:21,代碼來源:DriverConductor.java

示例5: shouldAddPublicationWithSameSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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));
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:18,代碼來源:DriverConductorTest.java

示例6: shouldAddExclusivePublicationWithSameSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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));
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:20,代碼來源:DriverConductorTest.java

示例7: shouldErrorOnAddPublicationWithNonEqualSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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));
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:19,代碼來源:DriverConductorTest.java

示例8: shouldErrorOnAddPublicationWithClashingSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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));
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:19,代碼來源:DriverConductorTest.java

示例9: shouldAddIpcPublicationThenSubscriptionWithSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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());
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:20,代碼來源:DriverConductorTest.java

示例10: shouldAddIpcSubscriptionThenPublicationWithSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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());
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:20,代碼來源:DriverConductorTest.java

示例11: shouldNotAddIpcPublicationThenSubscriptionWithDifferentSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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());
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:20,代碼來源:DriverConductorTest.java

示例12: shouldNotAddIpcSubscriptionThenPublicationWithDifferentSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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());
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:20,代碼來源:DriverConductorTest.java

示例13: shouldAddNetworkPublicationThenSingleSpyWithSameSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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());
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:21,代碼來源:DriverConductorTest.java

示例14: shouldNotAddNetworkPublicationThenSingleSpyWithDifferentSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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());
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:22,代碼來源:DriverConductorTest.java

示例15: shouldAddSingleSpyThenNetworkPublicationWithSameSessionId

import io.aeron.CommonContext; //導入依賴的package包/類
@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());
}
 
開發者ID:real-logic,項目名稱:aeron,代碼行數:21,代碼來源:DriverConductorTest.java


注:本文中的io.aeron.CommonContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。