Search in sources :

Example 31 with MutableBoolean

use of org.agrona.collections.MutableBoolean in project aeron by real-logic.

the class ClusterTest method shouldRejectTakeSnapshotRequestWithAnAuthorisationError.

@Test
@InterruptAfter(10)
void shouldRejectTakeSnapshotRequestWithAnAuthorisationError() {
    cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    final List<TestNode> followers = cluster.followers();
    final long requestCorrelationId = System.nanoTime();
    final MutableBoolean responseReceived = injectAdminResponseEgressListener(requestCorrelationId, AdminRequestType.SNAPSHOT, AdminResponseCode.UNAUTHORISED_ACCESS, "Execution of the " + AdminRequestType.SNAPSHOT + " request was not authorised");
    final AeronCluster client = cluster.connectClient();
    while (!client.sendAdminRequestToTakeASnapshot(requestCorrelationId)) {
        Tests.yield();
    }
    while (!responseReceived.get()) {
        client.pollEgress();
        Tests.yield();
    }
    long time = System.nanoTime();
    final long deadline = time + TimeUnit.SECONDS.toNanos(2);
    do {
        assertEquals(0, cluster.getSnapshotCount(leader));
        for (final TestNode follower : followers) {
            assertEquals(0, cluster.getSnapshotCount(follower));
        }
        Tests.sleep(10);
        time = System.nanoTime();
    } while (time < deadline);
}
Also used : MutableBoolean(org.agrona.collections.MutableBoolean) AeronCluster(io.aeron.cluster.client.AeronCluster) TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test)

Example 32 with MutableBoolean

use of org.agrona.collections.MutableBoolean in project aeron by real-logic.

the class ArchiveTest method postPublicationValidations.

private void postPublicationValidations(final ArchiveProxy archiveProxy, final Subscription recordingEvents, final int termBufferLength, final int initialTermId, final int maxPayloadLength) {
    verifyDescriptorListOngoingArchive(archiveProxy, termBufferLength);
    assertNull(trackerError);
    final long requestCorrelationId = client.nextCorrelationId();
    if (!archiveProxy.stopRecording(publishUri, PUBLISH_STREAM_ID, requestCorrelationId, controlSessionId)) {
        throw new IllegalStateException("failed to send stop recording");
    }
    ArchiveTests.awaitOk(controlResponse, requestCorrelationId);
    final MutableBoolean isRecordingStopped = new MutableBoolean();
    final RecordingEventsAdapter recordingEventsAdapter = new RecordingEventsAdapter(new FailRecordingEventsListener() {

        public void onStop(final long id, final long startPosition, final long stopPosition) {
            assertEquals(recordingId, id);
            isRecordingStopped.set(true);
        }
    }, recordingEvents, 1);
    while (!isRecordingStopped.get()) {
        if (recordingEventsAdapter.poll() == 0) {
            Tests.yield();
        }
    }
    verifyDescriptorListOngoingArchive(archiveProxy, termBufferLength);
    validateArchiveFile(recordingId);
    validateReplay(archiveProxy, initialTermId, maxPayloadLength, termBufferLength);
}
Also used : MutableBoolean(org.agrona.collections.MutableBoolean) RecordingEventsAdapter(io.aeron.archive.client.RecordingEventsAdapter)

Aggregations

MutableBoolean (org.agrona.collections.MutableBoolean)32 Test (org.junit.jupiter.api.Test)12 AeronCluster (io.aeron.cluster.client.AeronCluster)10 TestNode (io.aeron.test.cluster.TestNode)6 Publication (io.aeron.Publication)4 RecordingEventsAdapter (io.aeron.archive.client.RecordingEventsAdapter)4 ControlledEgressListener (io.aeron.cluster.client.ControlledEgressListener)4 Header (io.aeron.logbuffer.Header)4 DirectBuffer (org.agrona.DirectBuffer)4 Aeron (io.aeron.Aeron)2 CommonContext (io.aeron.CommonContext)2 ControlResponseAdapter (io.aeron.archive.client.ControlResponseAdapter)2 EgressListener (io.aeron.cluster.client.EgressListener)2 BufferClaim (io.aeron.logbuffer.BufferClaim)2 InterruptAfter (io.aeron.test.InterruptAfter)2 TestMediaDriver (io.aeron.test.driver.TestMediaDriver)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicCounter (org.agrona.concurrent.status.AtomicCounter)2 CountersReader (org.agrona.concurrent.status.CountersReader)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2