use of org.agrona.ErrorHandler in project aeron by real-logic.
the class AuthorisationServiceTest method shouldForbidAllCommandsIfDenyAllIsUsed.
@Test
void shouldForbidAllCommandsIfDenyAllIsUsed() {
final byte[] encodedCredentials = { 0x4, 0x5, 0x6 };
final ErrorHandler errorHandler = mock(ErrorHandler.class);
final int protocolId = 77;
final int actionId = ThreadLocalRandom.current().nextInt();
assertFalse(DENY_ALL.isAuthorised(protocolId, actionId, null, encodedCredentials));
verifyNoInteractions(errorHandler);
}
use of org.agrona.ErrorHandler in project aeron by real-logic.
the class ArchivingMediaDriver method launch.
/**
* Launch a new {@link ArchivingMediaDriver} with provided contexts.
*
* @param driverCtx for configuring the {@link MediaDriver}.
* @param archiveCtx for configuring the {@link Archive}.
* @return a new {@link ArchivingMediaDriver} with the provided contexts.
*/
public static ArchivingMediaDriver launch(final MediaDriver.Context driverCtx, final Archive.Context archiveCtx) {
MediaDriver driver = null;
Archive archive = null;
try {
driver = MediaDriver.launch(driverCtx);
final int errorCounterId = SystemCounterDescriptor.ERRORS.id();
final AtomicCounter errorCounter = null != archiveCtx.errorCounter() ? archiveCtx.errorCounter() : new AtomicCounter(driverCtx.countersValuesBuffer(), errorCounterId);
final ErrorHandler errorHandler = null != archiveCtx.errorHandler() ? archiveCtx.errorHandler() : driverCtx.errorHandler();
archive = Archive.launch(archiveCtx.mediaDriverAgentInvoker(driver.sharedAgentInvoker()).aeronDirectoryName(driverCtx.aeronDirectoryName()).errorHandler(errorHandler).errorCounter(errorCounter));
return new ArchivingMediaDriver(driver, archive);
} catch (final Exception ex) {
CloseHelper.quietCloseAll(archive, driver);
throw ex;
}
}
use of org.agrona.ErrorHandler in project aeron by real-logic.
the class AsyncResourceTest method shouldDetectUnknownHost.
@Test
@SlowTest
@Timeout(60)
void shouldDetectUnknownHost() {
final ErrorHandler mockClientErrorHandler = mock(ErrorHandler.class);
final Aeron.Context clientCtx = new Aeron.Context().errorHandler(mockClientErrorHandler);
try (Aeron aeron = Aeron.connect(clientCtx)) {
testWatcher.ignoreErrorsMatching((s) -> s.contains("unresolved"));
final long registrationId = aeron.asyncAddPublication("aeron:udp?endpoint=wibble:1234", STREAM_ID);
verify(mockClientErrorHandler, timeout(55_000)).onError(any(RegistrationException.class));
assertFalse(aeron.isCommandActive(registrationId));
assertFalse(aeron.hasActiveCommands());
}
}
use of org.agrona.ErrorHandler in project aeron by real-logic.
the class SingleNodeCluster method close.
/**
* {@inheritDoc}
*/
public void close() {
final ErrorHandler errorHandler = clusteredMediaDriver.mediaDriver().context().errorHandler();
CloseHelper.close(errorHandler, client);
CloseHelper.close(errorHandler, clientMediaDriver);
CloseHelper.close(errorHandler, clusteredMediaDriver.consensusModule());
CloseHelper.close(errorHandler, container);
// ErrorHandler will be closed during that call so can't use it
CloseHelper.close(clusteredMediaDriver);
}
use of org.agrona.ErrorHandler in project aeron by real-logic.
the class ReentrantClientTest method shouldThrowWhenReentering.
@Test
void shouldThrowWhenReentering() {
final MutableReference<Throwable> expectedException = new MutableReference<>();
final ErrorHandler errorHandler = expectedException::set;
try (Aeron aeron = Aeron.connect(new Aeron.Context().errorHandler(errorHandler))) {
final String channel = CommonContext.IPC_CHANNEL;
final AvailableImageHandler mockHandler = mock(AvailableImageHandler.class);
doAnswer((invocation) -> aeron.addSubscription(channel, 3)).when(mockHandler).onAvailableImage(any(Image.class));
final Subscription sub = aeron.addSubscription(channel, 1001, mockHandler, null);
final Publication pub = aeron.addPublication(channel, 1001);
verify(mockHandler, timeout(5000L)).onAvailableImage(any(Image.class));
pub.close();
sub.close();
assertThat(expectedException.get(), instanceOf(AeronException.class));
}
}
Aggregations