Search in sources :

Example 1 with 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;
    }
}
Also used : ErrorHandler(org.agrona.ErrorHandler) MediaDriver(io.aeron.driver.MediaDriver) AtomicCounter(org.agrona.concurrent.status.AtomicCounter)

Example 2 with ErrorHandler

use of org.agrona.ErrorHandler in project Aeron by real-logic.

the class ClusteredMediaDriver method launch.

/**
 * Launch a new {@link ClusteredMediaDriver} with provided contexts.
 *
 * @param driverCtx          for configuring the {@link MediaDriver}.
 * @param archiveCtx         for configuring the {@link Archive}.
 * @param consensusModuleCtx for the configuration of the {@link ConsensusModule}.
 * @return a new {@link ClusteredMediaDriver} with the provided contexts.
 */
public static ClusteredMediaDriver launch(final MediaDriver.Context driverCtx, final Archive.Context archiveCtx, final ConsensusModule.Context consensusModuleCtx) {
    MediaDriver driver = null;
    Archive archive = null;
    ConsensusModule consensusModule = 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(driver.aeronDirectoryName()).errorHandler(errorHandler).errorCounter(errorCounter));
        consensusModule = ConsensusModule.launch(consensusModuleCtx.aeronDirectoryName(driverCtx.aeronDirectoryName()));
        return new ClusteredMediaDriver(driver, archive, consensusModule);
    } catch (final Exception ex) {
        CloseHelper.quietCloseAll(consensusModule, archive, driver);
        throw ex;
    }
}
Also used : ErrorHandler(org.agrona.ErrorHandler) Archive(io.aeron.archive.Archive) MediaDriver(io.aeron.driver.MediaDriver) AtomicCounter(org.agrona.concurrent.status.AtomicCounter)

Example 3 with ErrorHandler

use of org.agrona.ErrorHandler in project Aeron by real-logic.

the class ClusterBackupMediaDriver method launch.

/**
 * Launch a new {@link ClusterBackupMediaDriver} with provided contexts.
 *
 * @param driverCtx        for configuring the {@link MediaDriver}.
 * @param archiveCtx       for configuring the {@link Archive}.
 * @param clusterBackupCtx for the configuration of the {@link ClusterBackup}.
 * @return a new {@link ClusterBackupMediaDriver} with the provided contexts.
 */
public static ClusterBackupMediaDriver launch(final MediaDriver.Context driverCtx, final Archive.Context archiveCtx, final ClusterBackup.Context clusterBackupCtx) {
    MediaDriver driver = null;
    Archive archive = null;
    ClusterBackup clusterBackup = null;
    try {
        driver = MediaDriver.launch(driverCtx.spiesSimulateConnection(true));
        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.aeronDirectoryName(driverCtx.aeronDirectoryName()).mediaDriverAgentInvoker(driver.sharedAgentInvoker()).errorHandler(errorHandler).errorCounter(errorCounter));
        clusterBackup = ClusterBackup.launch(clusterBackupCtx.aeronDirectoryName(driverCtx.aeronDirectoryName()));
        return new ClusterBackupMediaDriver(driver, archive, clusterBackup);
    } catch (final Exception ex) {
        CloseHelper.quietCloseAll(clusterBackup, archive, driver);
        throw ex;
    }
}
Also used : ErrorHandler(org.agrona.ErrorHandler) Archive(io.aeron.archive.Archive) MediaDriver(io.aeron.driver.MediaDriver) AtomicCounter(org.agrona.concurrent.status.AtomicCounter)

Example 4 with ErrorHandler

use of org.agrona.ErrorHandler in project Aeron by real-logic.

the class AuthorisationServiceTest method shouldAllowAnyCommandIfAllowAllIsUsed.

@Test
void shouldAllowAnyCommandIfAllowAllIsUsed() {
    final byte[] encodedCredentials = { 0x1, 0x2, 0x3 };
    final ErrorHandler errorHandler = mock(ErrorHandler.class);
    final int protocolId = 77;
    final int actionId = ThreadLocalRandom.current().nextInt();
    assertTrue(ALLOW_ALL.isAuthorised(protocolId, actionId, null, encodedCredentials));
    verifyNoInteractions(errorHandler);
}
Also used : ErrorHandler(org.agrona.ErrorHandler) Test(org.junit.jupiter.api.Test)

Example 5 with ErrorHandler

use of org.agrona.ErrorHandler in project Aeron by real-logic.

the class DynamicJoin method close.

void close() {
    final ErrorHandler countedErrorHandler = ctx.countedErrorHandler();
    CloseHelper.closeAll(countedErrorHandler, consensusPublication);
    if (null != snapshotReplication) {
        snapshotReplication.close(localArchive);
    }
}
Also used : ErrorHandler(org.agrona.ErrorHandler)

Aggregations

ErrorHandler (org.agrona.ErrorHandler)30 Test (org.junit.jupiter.api.Test)18 MediaDriver (io.aeron.driver.MediaDriver)10 RegistrationException (io.aeron.exceptions.RegistrationException)6 AtomicCounter (org.agrona.concurrent.status.AtomicCounter)6 Archive (io.aeron.archive.Archive)4 SlowTest (io.aeron.test.SlowTest)4 TestMediaDriver (io.aeron.test.driver.TestMediaDriver)4 DistinctErrorLog (org.agrona.concurrent.errors.DistinctErrorLog)4 LoggingErrorHandler (org.agrona.concurrent.errors.LoggingErrorHandler)4 Timeout (org.junit.jupiter.api.Timeout)4 AeronException (io.aeron.exceptions.AeronException)2 FragmentHandler (io.aeron.logbuffer.FragmentHandler)2 InterruptAfter (io.aeron.test.InterruptAfter)2 InterruptingTestCallback (io.aeron.test.InterruptingTestCallback)2 SystemTestWatcher (io.aeron.test.SystemTestWatcher)2 Tests (io.aeron.test.Tests)2 Tests.awaitConnected (io.aeron.test.Tests.awaitConnected)2 MutableReference (org.agrona.collections.MutableReference)2 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)2