use of io.aeron.archive.client.RecordingSubscriptionDescriptorConsumer in project Aeron by real-logic.
the class ArchiveTest method shouldListRegisteredRecordingSubscriptions.
@Test
@InterruptAfter(10)
public void shouldListRegisteredRecordingSubscriptions() {
final int expectedStreamId = 7;
final String channelOne = "aeron:ipc";
final String channelTwo = "aeron:udp?endpoint=localhost:5678";
final String channelThree = "aeron:udp?endpoint=localhost:4321";
final ArrayList<SubscriptionDescriptor> descriptors = new ArrayList<>();
@SuppressWarnings("Indentation") final RecordingSubscriptionDescriptorConsumer consumer = (controlSessionId, correlationId, subscriptionId, streamId, strippedChannel) -> descriptors.add(new SubscriptionDescriptor(controlSessionId, correlationId, subscriptionId, streamId, strippedChannel));
final MediaDriver.Context driverCtx = new MediaDriver.Context().dirDeleteOnStart(true).threadingMode(ThreadingMode.SHARED);
final Archive.Context archiveCtx = new Archive.Context().threadingMode(SHARED);
try (ArchivingMediaDriver ignore = ArchivingMediaDriver.launch(driverCtx, archiveCtx);
AeronArchive archive = AeronArchive.connect()) {
final long subIdOne = archive.startRecording(channelOne, expectedStreamId, LOCAL);
final long subIdTwo = archive.startRecording(channelTwo, expectedStreamId + 1, LOCAL);
final long subOdThree = archive.startRecording(channelThree, expectedStreamId + 2, LOCAL);
final int countOne = archive.listRecordingSubscriptions(0, 5, "ipc", expectedStreamId, true, consumer);
assertEquals(1, descriptors.size());
assertEquals(1, countOne);
descriptors.clear();
final int countTwo = archive.listRecordingSubscriptions(0, 5, "", expectedStreamId, false, consumer);
assertEquals(3, descriptors.size());
assertEquals(3, countTwo);
archive.stopRecording(subIdTwo);
descriptors.clear();
final int countThree = archive.listRecordingSubscriptions(0, 5, "", expectedStreamId, false, consumer);
assertEquals(2, descriptors.size());
assertEquals(2, countThree);
assertEquals(1L, descriptors.stream().filter((sd) -> sd.subscriptionId == subIdOne).count());
assertEquals(1L, descriptors.stream().filter((sd) -> sd.subscriptionId == subOdThree).count());
} finally {
archiveCtx.deleteDirectory();
driverCtx.deleteDirectory();
}
}
use of io.aeron.archive.client.RecordingSubscriptionDescriptorConsumer in project aeron by real-logic.
the class ArchiveTest method shouldListRegisteredRecordingSubscriptions.
@Test
@InterruptAfter(10)
public void shouldListRegisteredRecordingSubscriptions() {
final int expectedStreamId = 7;
final String channelOne = "aeron:ipc";
final String channelTwo = "aeron:udp?endpoint=localhost:5678";
final String channelThree = "aeron:udp?endpoint=localhost:4321";
final ArrayList<SubscriptionDescriptor> descriptors = new ArrayList<>();
@SuppressWarnings("Indentation") final RecordingSubscriptionDescriptorConsumer consumer = (controlSessionId, correlationId, subscriptionId, streamId, strippedChannel) -> descriptors.add(new SubscriptionDescriptor(controlSessionId, correlationId, subscriptionId, streamId, strippedChannel));
final MediaDriver.Context driverCtx = new MediaDriver.Context().dirDeleteOnStart(true).threadingMode(ThreadingMode.SHARED);
final Archive.Context archiveCtx = new Archive.Context().threadingMode(SHARED);
try (ArchivingMediaDriver ignore = ArchivingMediaDriver.launch(driverCtx, archiveCtx);
AeronArchive archive = AeronArchive.connect()) {
final long subIdOne = archive.startRecording(channelOne, expectedStreamId, LOCAL);
final long subIdTwo = archive.startRecording(channelTwo, expectedStreamId + 1, LOCAL);
final long subOdThree = archive.startRecording(channelThree, expectedStreamId + 2, LOCAL);
final int countOne = archive.listRecordingSubscriptions(0, 5, "ipc", expectedStreamId, true, consumer);
assertEquals(1, descriptors.size());
assertEquals(1, countOne);
descriptors.clear();
final int countTwo = archive.listRecordingSubscriptions(0, 5, "", expectedStreamId, false, consumer);
assertEquals(3, descriptors.size());
assertEquals(3, countTwo);
archive.stopRecording(subIdTwo);
descriptors.clear();
final int countThree = archive.listRecordingSubscriptions(0, 5, "", expectedStreamId, false, consumer);
assertEquals(2, descriptors.size());
assertEquals(2, countThree);
assertEquals(1L, descriptors.stream().filter((sd) -> sd.subscriptionId == subIdOne).count());
assertEquals(1L, descriptors.stream().filter((sd) -> sd.subscriptionId == subOdThree).count());
} finally {
archiveCtx.deleteDirectory();
driverCtx.deleteDirectory();
}
}
Aggregations