Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] Fix issue where multiple archive clients are trying to connect. #634

Merged
merged 1 commit into from Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -28,7 +28,7 @@
*/
public class ControlResponsePoller implements ControlledFragmentHandler
{
private static final int FRAGMENT_LIMIT = 10;
private static final int FRAGMENT_LIMIT = 1;

private final MessageHeaderDecoder messageHeaderDecoder = new MessageHeaderDecoder();
private final ControlResponseDecoder controlResponseDecoder = new ControlResponseDecoder();
Expand Down
39 changes: 39 additions & 0 deletions aeron-archive/src/test/java/io/aeron/archive/ArchiveTest.java
Expand Up @@ -15,8 +15,15 @@
*/
package io.aeron.archive;

import io.aeron.archive.client.AeronArchive;
import io.aeron.driver.MediaDriver;
import org.junit.Test;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

Expand All @@ -33,4 +40,36 @@ public void shouldGenerateRecordingName()

assertThat(actual, is(expected));
}

@Test
public void shouldAllowMultipleConnectionsInParallel() throws InterruptedException
{
final int numberOfArchiveClients = 5;
final CountDownLatch latch = new CountDownLatch(numberOfArchiveClients);
final ExecutorService executorService = Executors.newFixedThreadPool(numberOfArchiveClients);

final MediaDriver.Context driverCtx = new MediaDriver.Context();
final Archive.Context archiveCtx = new Archive.Context();

try (ArchivingMediaDriver driver = ArchivingMediaDriver.launch(driverCtx, archiveCtx))
{
for (int i = 0; i < numberOfArchiveClients; i++)
{
executorService.execute(() ->
{
AeronArchive.connect();
latch.countDown();
});
}

latch.await(10, TimeUnit.SECONDS);

assertThat(latch.getCount(), is(0L));
}
finally
{
archiveCtx.deleteArchiveDirectory();
driverCtx.deleteAeronDirectory();
}
}
}