use of org.agrona.concurrent.NoOpLock in project aeron by real-logic.
the class ConsensusModuleHarness method makeRecordingLog.
public static long makeRecordingLog(final int numMessages, final int maxMessageLength, final Random random, final ConsensusModule.Context context) {
try (ConsensusModuleHarness harness = new ConsensusModuleHarness(context, new StubClusteredService(), null, true, false)) {
harness.awaitServiceOnStart();
final AeronCluster aeronCluster = AeronCluster.connect(new AeronCluster.Context().lock(new NoOpLock()));
final SessionDecorator sessionDecorator = new SessionDecorator(aeronCluster.clusterSessionId());
final Publication publication = aeronCluster.ingressPublication();
final ExpandableArrayBuffer msgBuffer = new ExpandableArrayBuffer(maxMessageLength);
for (int i = 0; i < numMessages; i++) {
final long messageCorrelationId = aeronCluster.context().aeron().nextCorrelationId();
final int length = (null == random) ? maxMessageLength : random.nextInt(maxMessageLength);
msgBuffer.putInt(0, i);
while (true) {
final long result = sessionDecorator.offer(publication, messageCorrelationId, msgBuffer, 0, length);
if (result > 0) {
break;
}
checkOfferResult(result);
TestUtil.checkInterruptedStatus();
Thread.yield();
}
}
harness.awaitServiceOnMessageCounter(numMessages);
return publication.position();
}
}
use of org.agrona.concurrent.NoOpLock in project aeron by real-logic.
the class ClusterTest method before.
@Before
public void before() {
final String aeronDirName = CommonContext.getAeronDirectoryName();
for (int i = 0; i < MEMBER_COUNT; i++) {
echoServices[i] = new EchoService(latch);
final String baseDirName = aeronDirName + "-" + i;
final AeronArchive.Context archiveCtx = new AeronArchive.Context().controlRequestChannel(memberSpecificPort(ARCHIVE_CONTROL_REQUEST_CHANNEL, i)).controlRequestStreamId(100 + i).controlResponseChannel(memberSpecificPort(ARCHIVE_CONTROL_RESPONSE_CHANNEL, i)).controlResponseStreamId(110 + i).aeronDirectoryName(baseDirName);
drivers[i] = ClusteredMediaDriver.launch(new MediaDriver.Context().aeronDirectoryName(baseDirName).threadingMode(ThreadingMode.SHARED).termBufferSparseFile(true).multicastFlowControlSupplier(new MinMulticastFlowControlSupplier()).errorHandler(Throwable::printStackTrace).dirDeleteOnStart(true), new Archive.Context().maxCatalogEntries(MAX_CATALOG_ENTRIES).aeronDirectoryName(baseDirName).archiveDir(new File(baseDirName, "archive")).controlChannel(archiveCtx.controlRequestChannel()).controlStreamId(archiveCtx.controlRequestStreamId()).localControlChannel("aeron:ipc?term-length=64k").localControlStreamId(archiveCtx.controlRequestStreamId()).threadingMode(ArchiveThreadingMode.SHARED).deleteArchiveOnStart(true), new ConsensusModule.Context().clusterMemberId(i).clusterMembers(CLUSTER_MEMBERS).appointedLeaderId(0).aeronDirectoryName(baseDirName).clusterDir(new File(baseDirName, "consensus-module")).ingressChannel("aeron:udp?term-length=64k").logChannel(memberSpecificPort(LOG_CHANNEL, i)).archiveContext(archiveCtx.clone()).deleteDirOnStart(true));
containers[i] = ClusteredServiceContainer.launch(new ClusteredServiceContainer.Context().aeronDirectoryName(baseDirName).archiveContext(archiveCtx.clone()).clusteredServiceDir(new File(baseDirName, "service")).clusteredService(echoServices[i]).errorHandler(Throwable::printStackTrace).deleteDirOnStart(true));
}
client = AeronCluster.connect(new AeronCluster.Context().aeronDirectoryName(aeronDirName + "-0").ingressChannel("aeron:udp").clusterMemberEndpoints("localhost:20110", "localhost:20111", "localhost:20112").lock(new NoOpLock()));
}
Aggregations