本文整理匯總了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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}