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);
}
use of org.agrona.collections.MutableBoolean in project Aeron by real-logic.
the class ClusterTest method shouldTakeASnapshotAfterReceivingAdminRequestOfTypeSnapshotAndNotifyViaControlledPoll.
@Test
@InterruptAfter(20)
void shouldTakeASnapshotAfterReceivingAdminRequestOfTypeSnapshotAndNotifyViaControlledPoll() {
cluster = aCluster().withStaticNodes(3).withAuthorisationServiceSupplier(() -> (protocolId, actionId, type, encodedPrincipal) -> {
assertEquals(MessageHeaderDecoder.SCHEMA_ID, protocolId);
assertEquals(AdminRequestEncoder.TEMPLATE_ID, actionId);
assertEquals(AdminRequestType.SNAPSHOT, type);
return true;
}).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final long requestCorrelationId = System.nanoTime();
final MutableBoolean responseReceived = injectAdminRequestControlledEgressListener(requestCorrelationId, AdminRequestType.SNAPSHOT, AdminResponseCode.OK, "");
final AeronCluster client = cluster.connectClient();
while (!client.sendAdminRequestToTakeASnapshot(requestCorrelationId)) {
Tests.yield();
}
while (!responseReceived.get()) {
client.controlledPollEgress();
Tests.yield();
}
cluster.awaitSnapshotCount(1);
cluster.awaitNeutralControlToggle(leader);
}
use of org.agrona.collections.MutableBoolean in project Aeron by real-logic.
the class DriverNameResolverTest method shouldFallbackToAnotherBootstrapNeighborIfOneBecomesUnavailable.
@SlowTest
@Test
@InterruptAfter(20)
public void shouldFallbackToAnotherBootstrapNeighborIfOneBecomesUnavailable() {
assumeTrue(TestMediaDriver.shouldRunJavaMediaDriver());
final NameResolver bootstrapResolver = DriverNameResolver.bootstrapNameResolver;
try {
final MutableBoolean resolveHostA = new MutableBoolean(true);
DriverNameResolver.bootstrapNameResolver = (name, uriParamName, isReResolution) -> (resolveHostA.get() || !name.endsWith("A")) ? DefaultNameResolver.INSTANCE.resolve(name.substring(0, name.length() - 1), uriParamName, isReResolution) : null;
addDriver(TestMediaDriver.launch(setDefaults(new MediaDriver.Context()).aeronDirectoryName(baseDir + "-A").resolverName("A").resolverInterface("0.0.0.0:8050"), testWatcher));
addDriver(TestMediaDriver.launch(setDefaults(new MediaDriver.Context()).aeronDirectoryName(baseDir + "-B").resolverName("B").resolverInterface("0.0.0.0:8051").resolverBootstrapNeighbor("localhostA:8050,localhostB:8051"), testWatcher));
addDriver(TestMediaDriver.launch(setDefaults(new MediaDriver.Context()).aeronDirectoryName(baseDir + "-C").resolverName("C").resolverInterface("0.0.0.0:8052").resolverBootstrapNeighbor("localhostA:8050,localhostB:8051"), testWatcher));
startClients();
final int aNeighborsCounterId = awaitNeighborsCounterId("A");
final int bNeighborsCounterId = awaitNeighborsCounterId("B");
final int cNeighborsCounterId = awaitNeighborsCounterId("C");
awaitCounterValue("A", aNeighborsCounterId, 2);
awaitCounterValue("B", bNeighborsCounterId, 2);
awaitCounterValue("C", cNeighborsCounterId, 2);
awaitCounterLabel("A", aNeighborsCounterId, "Resolver neighbors: bound 0.0.0.0:8050");
awaitCounterLabel("B", bNeighborsCounterId, "Resolver neighbors: bound 0.0.0.0:8051 bootstrap 127.0.0.1:8050");
awaitCounterLabel("C", cNeighborsCounterId, "Resolver neighbors: bound 0.0.0.0:8052 bootstrap 127.0.0.1:8050");
closeDriver("A");
resolveHostA.set(false);
awaitCounterValue("B", bNeighborsCounterId, 1);
awaitCounterValue("C", cNeighborsCounterId, 1);
awaitCounterLabel("B", bNeighborsCounterId, "Resolver neighbors: bound 0.0.0.0:8051 bootstrap 127.0.0.1:8051");
awaitCounterLabel("C", cNeighborsCounterId, "Resolver neighbors: bound 0.0.0.0:8052 bootstrap 127.0.0.1:8051");
addDriver(TestMediaDriver.launch(setDefaults(new MediaDriver.Context()).aeronDirectoryName(baseDir + "-D").resolverName("D").resolverInterface("0.0.0.0:8053").resolverBootstrapNeighbor("localhostA:8050,localhostB:8051"), testWatcher));
startClients();
final int dNeighborsCounterId = awaitNeighborsCounterId("D");
awaitCounterValue("B", bNeighborsCounterId, 2);
awaitCounterValue("C", cNeighborsCounterId, 2);
awaitCounterValue("D", dNeighborsCounterId, 2);
awaitCounterLabel("D", dNeighborsCounterId, "Resolver neighbors: bound 0.0.0.0:8053 bootstrap 127.0.0.1:8051");
} finally {
DriverNameResolver.bootstrapNameResolver = bootstrapResolver;
}
}
use of org.agrona.collections.MutableBoolean in project aeron by real-logic.
the class ArchiveToolTests method assertNoRecording.
private void assertNoRecording(final Catalog catalog, final long recordingId) {
final MutableBoolean found = new MutableBoolean();
catalog.forEach((recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> {
if (recordingId == descriptorDecoder.recordingId()) {
found.set(true);
}
});
assertFalse(found.get(), () -> "recordingId=" + recordingId + " was found");
}
use of org.agrona.collections.MutableBoolean in project aeron by real-logic.
the class ArchiveToolTests method assertRecording.
private void assertRecording(final Catalog catalog, final long recordingId, final CatalogEntryProcessor catalogEntryProcessor) {
final MutableBoolean found = new MutableBoolean();
catalog.forEach((recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder) -> {
if (recordingId == descriptorDecoder.recordingId()) {
found.set(true);
catalogEntryProcessor.accept(recordingDescriptorOffset, headerEncoder, headerDecoder, descriptorEncoder, descriptorDecoder);
}
});
assertTrue(found.get(), () -> "recordingId=" + recordingId + " was not found");
}
Aggregations