use of io.aeron.archive.Archive.Context in project Aeron by real-logic.
the class ArchiveTest method recordChecksumBufferReturnsDataBufferIfThreadingModeIsNotDEDICATED.
@ParameterizedTest
@EnumSource(value = ArchiveThreadingMode.class, mode = EXCLUDE, names = "DEDICATED")
void recordChecksumBufferReturnsDataBufferIfThreadingModeIsNotDEDICATED(final ArchiveThreadingMode threadingMode) {
final Checksum recordChecksum = mock(Checksum.class);
final Archive.Context context = new Archive.Context().recordChecksum(recordChecksum).threadingMode(threadingMode);
final UnsafeBuffer buffer = context.recordChecksumBuffer();
assertSame(context.dataBuffer(), buffer);
}
use of io.aeron.archive.Archive.Context in project Aeron by real-logic.
the class ArchiveTest method shouldAllowMultipleConnectionsInParallel.
@Test
public void shouldAllowMultipleConnectionsInParallel() throws InterruptedException {
final int numberOfArchiveClients = 5;
final long connectTimeoutNs = TimeUnit.SECONDS.toNanos(10);
final CountDownLatch latch = new CountDownLatch(numberOfArchiveClients);
final ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(numberOfArchiveClients);
final ManyToOneConcurrentLinkedQueue<AeronArchive> archiveClientQueue = new ManyToOneConcurrentLinkedQueue<>();
final MediaDriver.Context driverCtx = new MediaDriver.Context().errorHandler(Tests::onError).clientLivenessTimeoutNs(connectTimeoutNs).dirDeleteOnStart(true).publicationUnblockTimeoutNs(connectTimeoutNs * 2).threadingMode(ThreadingMode.SHARED);
final Archive.Context archiveCtx = new Archive.Context().threadingMode(SHARED).connectTimeoutNs(connectTimeoutNs);
executor.prestartAllCoreThreads();
try (ArchivingMediaDriver driver = ArchivingMediaDriver.launch(driverCtx, archiveCtx)) {
for (int i = 0; i < numberOfArchiveClients; i++) {
executor.execute(() -> {
final AeronArchive.Context ctx = new AeronArchive.Context().messageTimeoutNs(connectTimeoutNs);
final AeronArchive archive = AeronArchive.connect(ctx);
archiveClientQueue.add(archive);
latch.countDown();
});
}
assertTrue(latch.await(driver.archive().context().connectTimeoutNs() * 2, TimeUnit.NANOSECONDS));
AeronArchive archiveClient;
while (null != (archiveClient = archiveClientQueue.poll())) {
archiveClient.close();
}
} finally {
executor.shutdownNow();
archiveCtx.deleteDirectory();
driverCtx.deleteDirectory();
}
}
use of io.aeron.archive.Archive.Context in project Aeron by real-logic.
the class ArchiveTest method recordChecksumBufferIsAllocatedOnDemandIfThreadingModeIsDEDICATED.
@Test
void recordChecksumBufferIsAllocatedOnDemandIfThreadingModeIsDEDICATED() {
final Checksum recordChecksum = mock(Checksum.class);
final Archive.Context context = new Archive.Context().recordChecksum(recordChecksum).threadingMode(DEDICATED);
final UnsafeBuffer buffer = context.recordChecksumBuffer();
assertNotNull(buffer);
assertEquals(context.fileIoMaxLength(), buffer.capacity());
assertSame(buffer, context.recordChecksumBuffer());
assertNotSame(context.dataBuffer(), buffer);
}
use of io.aeron.archive.Archive.Context in project Aeron by real-logic.
the class ArchiveTest method replayBufferIsAllocatedOnDemandIfThreadingModeIsDEDICATED.
@Test
void replayBufferIsAllocatedOnDemandIfThreadingModeIsDEDICATED() {
final Context context = new Context().threadingMode(DEDICATED);
final UnsafeBuffer buffer = context.replayBuffer();
assertNotNull(buffer);
assertEquals(context.fileIoMaxLength(), buffer.capacity());
assertSame(buffer, context.replayBuffer());
assertNotSame(context.dataBuffer(), buffer);
}
use of io.aeron.archive.Archive.Context in project Aeron by real-logic.
the class ArchiveTest method dataBufferReturnsValueAssigned.
@Test
void dataBufferReturnsValueAssigned() {
final UnsafeBuffer buffer = mock(UnsafeBuffer.class);
final Context context = new Context();
context.dataBuffer(buffer);
assertSame(buffer, context.dataBuffer());
}
Aggregations