org.agrona.ErrorHandler Java Examples

The following examples show how to use org.agrona.ErrorHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HistogramLogAgent.java    From artio with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("FinalParameters")
public HistogramLogAgent(
    final List<Timer> timers,
    final String logFile,
    final long intervalInMs,
    final ErrorHandler errorHandler,
    final EpochClock milliClock,
    HistogramHandler histogramHandler,
    final String agentNamePrefix)
{
    this.timers = timers;
    this.intervalInMs = intervalInMs;
    this.milliClock = milliClock;
    this.agentNamePrefix = agentNamePrefix;

    if (histogramHandler == null)
    {
        histogramHandler = new HistogramLogWriter(timers.size(), logFile, errorHandler);
    }

    this.histogramHandler = histogramHandler;
    timers.forEach(timer -> this.histogramHandler.identifyTimer(timer.id(), timer.name()));
    histogramHandler.onEndTimerIdentification();
}
 
Example #2
Source File: Indexer.java    From artio with Apache License 2.0 6 votes vote down vote up
public Indexer(
    final List<Index> indices,
    final Subscription subscription,
    final String agentNamePrefix,
    final CompletionPosition completionPosition,
    final AeronArchive aeronArchive,
    final ErrorHandler errorHandler,
    final int archiveReplayStream,
    final boolean gracefulShutdown)
{
    this.indices = indices;
    this.subscription = subscription;
    this.agentNamePrefix = agentNamePrefix;
    this.completionPosition = completionPosition;
    this.archiveReplayStream = archiveReplayStream;
    this.gracefulShutdown = gracefulShutdown;
    catchIndexUp(aeronArchive, errorHandler);
}
 
Example #3
Source File: DirectSessionProxy.java    From artio with Apache License 2.0 6 votes vote down vote up
public DirectSessionProxy(
    final int sessionBufferSize,
    final GatewayPublication gatewayPublication,
    final SessionIdStrategy sessionIdStrategy,
    final SessionCustomisationStrategy customisationStrategy,
    final EpochClock clock,
    final long connectionId,
    final int libraryId,
    final ErrorHandler errorHandler,
    final EpochFractionFormat epochFractionPrecision)
{
    this.gatewayPublication = gatewayPublication;
    this.sessionIdStrategy = sessionIdStrategy;
    this.customisationStrategy = customisationStrategy;
    this.clock = clock;
    this.connectionId = connectionId;
    this.libraryId = libraryId;
    this.buffer = new MutableAsciiBuffer(new byte[sessionBufferSize]);
    this.errorHandler = errorHandler;
    lowSequenceNumber = new AsciiFormatter("MsgSeqNum too low, expecting %s but received %s");
    timestampEncoder = new UtcTimestampEncoder(epochFractionPrecision);
    timestampEncoder.initialise(clock.time());
}
 
Example #4
Source File: ReplayQuery.java    From artio with Apache License 2.0 6 votes vote down vote up
public ReplayQuery(
    final String logFileDir,
    final int cacheNumSets,
    final int cacheSetSize,
    final ExistingBufferFactory indexBufferFactory,
    final int requiredStreamId,
    final IdleStrategy idleStrategy,
    final AeronArchive aeronArchive,
    final ErrorHandler errorHandler,
    final int archiveReplayStream)
{
    this.logFileDir = logFileDir;
    this.indexBufferFactory = indexBufferFactory;
    this.requiredStreamId = requiredStreamId;
    this.idleStrategy = idleStrategy;
    this.aeronArchive = aeronArchive;
    this.errorHandler = errorHandler;
    this.archiveReplayStream = archiveReplayStream;

    logFileDirFile = new File(logFileDir);
    fixSessionToIndex = new Long2ObjectCache<>(cacheNumSets, cacheSetSize, SessionQuery::close);
}
 
Example #5
Source File: EndPointFactory.java    From artio with Apache License 2.0 6 votes vote down vote up
EndPointFactory(
    final EngineConfiguration configuration,
    final SessionContexts sessionContexts,
    final GatewayPublication inboundLibraryPublication,
    final FixCounters fixCounters,
    final ErrorHandler errorHandler,
    final GatewaySessions gatewaySessions,
    final SenderSequenceNumbers senderSequenceNumbers,
    final MessageTimingHandler messageTimingHandler)
{
    this.configuration = configuration;
    this.sessionContexts = sessionContexts;
    this.inboundLibraryPublication = inboundLibraryPublication;
    this.fixCounters = fixCounters;
    this.errorHandler = errorHandler;
    this.gatewaySessions = gatewaySessions;
    this.senderSequenceNumbers = senderSequenceNumbers;
    this.messageTimingHandler = messageTimingHandler;
}
 
Example #6
Source File: ReplayOperation.java    From artio with Apache License 2.0 6 votes vote down vote up
ReplayOperation(
    final List<RecordingRange> ranges,
    final AeronArchive aeronArchive,
    final ErrorHandler errorHandler,
    final Subscription subscription,
    final int archiveReplayStream,
    final LogTag logTag,
    final MessageTracker messageTracker)
{
    this.messageTracker = messageTracker;
    assembler = new ControlledFragmentAssembler(this.messageTracker);

    this.ranges = ranges;
    this.aeronArchive = aeronArchive;
    this.errorHandler = errorHandler;
    this.archiveReplayStream = archiveReplayStream;
    this.logTag = logTag;

    final Aeron aeron = aeronArchive.context().aeron();
    countersReader = aeron.countersReader();
    this.subscription = subscription;
}
 
Example #7
Source File: SessionContexts.java    From artio with Apache License 2.0 6 votes vote down vote up
public SessionContexts(
    final MappedFile mappedFile,
    final SessionIdStrategy idStrategy,
    final int initialSequenceIndex,
    final ErrorHandler errorHandler)
{
    this.mappedFile = mappedFile;
    this.buffer = mappedFile.buffer();
    this.byteBuffer = this.buffer.byteBuffer();
    sectorFramer = new SectorFramer(buffer.capacity());
    this.idStrategy = idStrategy;
    this.initialSequenceIndex = initialSequenceIndex;
    this.errorHandler = errorHandler;
    loadBuffer();
    allSessions.addAll(compositeToContext.values());
}
 
Example #8
Source File: ReentrantClientTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public 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));
    }
}
 
Example #9
Source File: PossDupEnabler.java    From artio with Apache License 2.0 6 votes vote down vote up
public PossDupEnabler(
    final UtcTimestampEncoder utcTimestampEncoder,
    final BufferClaim bufferClaim,
    final Claimer claimer,
    final PreCommit onPreCommit,
    final Consumer<String> onIllegalStateFunc,
    final ErrorHandler errorHandler,
    final EpochClock clock,
    final int maxPayloadLength,
    final LogTag logTag)
{
    this.utcTimestampEncoder = utcTimestampEncoder;
    this.bufferClaim = bufferClaim;
    this.claimer = claimer;
    this.onPreCommit = onPreCommit;
    this.onIllegalStateFunc = onIllegalStateFunc;
    this.errorHandler = errorHandler;
    this.clock = clock;
    this.maxPayloadLength = maxPayloadLength;
    this.logTag = logTag;
}
 
Example #10
Source File: SessionScheduler.java    From artio with Apache License 2.0 6 votes vote down vote up
/**
 * Define a {@link SessionScheduler} that connects between specified times on specified days.
 *
 * @param clock the clock to use as a source of time.
 * @param library the <code>{@link FixLibrary}</code> instance to use to connect.
 * @param sessionConfiguration the configuration for the session to use to connect.
 * @param timezone the timezone that days start and end in.
 * @param startDay the first day of the week to connect on.
 * @param endDay the name of the last day of the week to connect on.
 * @param startTime the time to start a connection to the exchange.
 * @param endTime the time to end a connection to the exchange.
 * @param errorHandler a callback for connection errors.
 */
public SessionScheduler(
    final Clock clock,
    final FixLibrary library,
    final SessionConfiguration sessionConfiguration,
    final ZoneId timezone,
    final DayOfWeek startDay,
    final DayOfWeek endDay,
    final LocalTime startTime,
    final LocalTime endTime,
    final ErrorHandler errorHandler)
{
    this.clock = clock.withZone(timezone);
    this.library = library;
    this.sessionConfiguration = sessionConfiguration;
    this.startTime = startTime;
    this.endTime = endTime;
    this.errorHandler = errorHandler;

    daysOfWeek = Arrays
        .stream(DayOfWeek.values())
        .filter(dayOfWeek -> dayOfWeek.compareTo(startDay) >= 0 && dayOfWeek.compareTo(endDay) <= 0)
        .collect(Collectors.toSet());

    scheduleStart();
}
 
Example #11
Source File: AgentRunner.java    From agrona with Apache License 2.0 6 votes vote down vote up
/**
 * Create an agent runner and initialise it.
 *
 * @param idleStrategy to use for Agent run loop
 * @param errorHandler to be called if an {@link Throwable} is encountered
 * @param errorCounter to be incremented each time an exception is encountered. This may be null.
 * @param agent        to be run in this thread.
 */
public AgentRunner(
    final IdleStrategy idleStrategy,
    final ErrorHandler errorHandler,
    final AtomicCounter errorCounter,
    final Agent agent)
{
    Objects.requireNonNull(idleStrategy, "idleStrategy");
    Objects.requireNonNull(errorHandler, "errorHandler");
    Objects.requireNonNull(agent, "agent");

    this.idleStrategy = idleStrategy;
    this.errorHandler = errorHandler;
    this.errorCounter = errorCounter;
    this.agent = agent;
}
 
Example #12
Source File: SessionScheduler.java    From artio with Apache License 2.0 6 votes vote down vote up
/**
 * Define a session that connects non-stop on a given number of days.
 *
 * @param library the <code>{@link FixLibrary}</code> instance to use to connect.
 * @param sessionConfiguration the configuration for the session to use to connect.
 * @param timezoneName the name of the timezone that days start and end in.
 * @param startDayName the name of the first day of the week to connect on.
 * @param endDayName the name of the last day of the week to connect on.
 * @param errorHandler a callback for connection errors.
 * @return the SessionScheduler object.
 */
public static SessionScheduler nonStopSession(
    final FixLibrary library,
    final SessionConfiguration sessionConfiguration,
    final String timezoneName,
    final String startDayName,
    final String endDayName,
    final ErrorHandler errorHandler)
{
    return new SessionScheduler(
        java.time.Clock.systemDefaultZone(),
        library,
        sessionConfiguration,
        ZoneId.of(timezoneName),
        DayOfWeek.valueOf(startDayName),
        DayOfWeek.valueOf(endDayName),
        LocalTime.of(0, 0),
        LocalTime.of(0, 0),
        errorHandler);
}
 
Example #13
Source File: SpecifiedPositionPublicationTest.java    From aeron with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldRejectSpecifiedPositionForConcurrentPublications()
{
    final ErrorHandler mockErrorHandler = mock(ErrorHandler.class);
    final MediaDriver.Context context = new MediaDriver.Context()
        .errorHandler(mockErrorHandler)
        .dirDeleteOnStart(true)
        .publicationTermBufferLength(LogBufferDescriptor.TERM_MIN_LENGTH)
        .threadingMode(ThreadingMode.SHARED);

    try (TestMediaDriver ignore = TestMediaDriver.launch(context, testWatcher);
        Aeron aeron = Aeron.connect())
    {
        final String channel = new ChannelUriStringBuilder()
            .media("ipc")
            .initialPosition(1024, -873648623, 65536)
            .build();

        assertThrows(RegistrationException.class, () -> aeron.addPublication(channel, 1001));
    }
    finally
    {
        context.deleteDirectory();
    }
}
 
Example #14
Source File: ArchivingMediaDriver.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
static ArchivingMediaDriver launchArchiveWithEmbeddedDriver()
{
    MediaDriver driver = null;
    Archive archive = null;
    try
    {
        final MediaDriver.Context driverCtx = new MediaDriver.Context()
            .dirDeleteOnStart(true)
            .spiesSimulateConnection(true);

        driver = MediaDriver.launch(driverCtx);

        final Archive.Context archiveCtx = new Archive.Context()
            .aeronDirectoryName(driverCtx.aeronDirectoryName())
            .deleteArchiveOnStart(true);

        final int errorCounterId = SystemCounterDescriptor.ERRORS.id();
        final AtomicCounter errorCounter = null == archiveCtx.errorCounter() ?
            new AtomicCounter(driverCtx.countersValuesBuffer(), errorCounterId) : archiveCtx.errorCounter();

        final ErrorHandler errorHandler = null == archiveCtx.errorHandler() ?
            driverCtx.errorHandler() : archiveCtx.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;
    }
}
 
Example #15
Source File: ClusteredMediaDriver.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * 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
            .spiesSimulateConnection(true));

        final int errorCounterId = SystemCounterDescriptor.ERRORS.id();
        final AtomicCounter errorCounter = null == archiveCtx.errorCounter() ?
            new AtomicCounter(driverCtx.countersValuesBuffer(), errorCounterId) : archiveCtx.errorCounter();

        final ErrorHandler errorHandler = null == archiveCtx.errorHandler() ?
            driverCtx.errorHandler() : archiveCtx.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;
    }
}
 
Example #16
Source File: AeronArchive.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * Close any allocated resources.
 */
public void close()
{
    if (5 != step)
    {
        final ErrorHandler errorHandler = ctx.errorHandler();
        CloseHelper.close(errorHandler, controlResponsePoller.subscription());
        CloseHelper.close(errorHandler, archiveProxy.publication());
        ctx.close();
    }
}
 
Example #17
Source File: AeronArchive.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * Notify the archive that this control session is closed so it can promptly release resources then close the
 * local resources associated with the client.
 */
public void close()
{
    lock.lock();
    try
    {
        if (!isClosed)
        {
            isClosed = true;
            final ErrorHandler errorHandler = context.errorHandler();

            if (archiveProxy.publication().isConnected())
            {
                CloseHelper.close(errorHandler, () -> archiveProxy.closeSession(controlSessionId));
            }

            if (!context.ownsAeronClient())
            {
                CloseHelper.close(errorHandler, archiveProxy.publication());
                CloseHelper.close(errorHandler, controlResponsePoller.subscription());
            }

            context.close();
        }
    }
    finally
    {
        lock.unlock();
    }
}
 
Example #18
Source File: FileStoreLogFactoryTest.java    From aeron with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void createDataDir()
{
    IoUtil.ensureDirectoryExists(DATA_DIR, "data");
    final String absolutePath = DATA_DIR.getAbsolutePath();
    fileStoreLogFactory = new FileStoreLogFactory(
        absolutePath, PAGE_SIZE, PERFORM_STORAGE_CHECKS, LOW_STORAGE_THRESHOLD, mock(ErrorHandler.class));
}
 
Example #19
Source File: DynamicLibraryScheduler.java    From artio with Apache License 2.0 5 votes vote down vote up
private CombinedAgent(
    final int libraryId,
    final Agent monitoringAgent,
    final Agent clientConductorAgent,
    final ErrorHandler errorHandler)
{
    this.roleName = "[Library:" + libraryId + ":monitoring+conductor]";
    this.monitoringAgent = monitoringAgent;
    this.clientConductorAgent = clientConductorAgent;
    this.errorHandler = errorHandler;
}
 
Example #20
Source File: DefaultLibraryScheduler.java    From artio with Apache License 2.0 5 votes vote down vote up
public void launch(
    final LibraryConfiguration configuration,
    final ErrorHandler errorHandler,
    final Agent monitoringAgent,
    final Agent conductorAgent)
{
    if (monitoringRunner != null)
    {
        EngineScheduler.fail();
    }

    if (monitoringAgent != null)
    {
        monitoringRunner = new AgentRunner(
            configuration.monitoringThreadIdleStrategy(),
            errorHandler,
            null,
            new CompositeAgent(monitoringAgent, conductorAgent)
            {
                public void onStart()
                {
                    FixLibrary.setClientConductorThread();
                    super.onStart();
                }
            });
        startOnThread(monitoringRunner, configuration.threadFactory());
    }
}
 
Example #21
Source File: DynamicLibraryScheduler.java    From artio with Apache License 2.0 5 votes vote down vote up
public synchronized void launch(
    final LibraryConfiguration configuration,
    final ErrorHandler errorHandler,
    final Agent monitoringAgent,
    final Agent conductorAgent)
{
    if (runner == null)
    {
        // We shouldn't reach this default error handler because we catch exceptions in the CombinedAgent below.
        runner = new AgentRunner(
            configuration.monitoringThreadIdleStrategy(),
            Throwable::printStackTrace,
            null,
            dynamicAgent);
        AgentRunner.startOnThread(runner, configuration.threadFactory());

        // Wait for it to start
        while (dynamicAgent.status() != ACTIVE)
        {
            Thread.yield();
        }
    }

    final int libraryId = configuration.libraryId();
    final Agent combinedAgent = new CombinedAgent(libraryId, monitoringAgent, conductorAgent, errorHandler);

    libraryIdToDelegateAgent.put(libraryId, combinedAgent);

    while (!dynamicAgent.tryAdd(combinedAgent))
    {
        Thread.yield();
    }

    while (!dynamicAgent.hasAddAgentCompleted())
    {
        Thread.yield();
    }
}
 
Example #22
Source File: ErrorHandlerVerifier.java    From artio with Apache License 2.0 5 votes vote down vote up
static void verify(
    final ErrorHandler mockErrorHandler,
    final VerificationMode times,
    final Class<? extends Throwable> exception)
{
    try
    {
        Mockito.verify(mockErrorHandler, times).onError(any(exception));
    }
    finally
    {
        reset(mockErrorHandler);
    }
}
 
Example #23
Source File: RecordingSubscriptionDescriptorPoller.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * Create a poller for a given subscription to an archive for control response messages.
 *
 * @param subscription     to poll for new events.
 * @param errorHandler     to call for asynchronous errors.
 * @param controlSessionId to filter the responses.
 * @param fragmentLimit    to apply for each polling operation.
 */
public RecordingSubscriptionDescriptorPoller(
    final Subscription subscription,
    final ErrorHandler errorHandler,
    final long controlSessionId,
    final int fragmentLimit)
{
    this.subscription = subscription;
    this.errorHandler = errorHandler;
    this.fragmentLimit = fragmentLimit;
    this.controlSessionId = controlSessionId;
}
 
Example #24
Source File: ArchivingMediaDriver.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * 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() ?
            new AtomicCounter(driverCtx.countersValuesBuffer(), errorCounterId) : archiveCtx.errorCounter();

        final ErrorHandler errorHandler = null == archiveCtx.errorHandler() ?
            driverCtx.errorHandler() : archiveCtx.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;
    }
}
 
Example #25
Source File: AbstractILink3Offsets.java    From artio with Apache License 2.0 5 votes vote down vote up
public static AbstractILink3Offsets make(final ErrorHandler errorHandler)
{
    try
    {
        final Class<?> cls = Class.forName("uk.co.real_logic.artio.ilink.ILink3Offsets");
        return (AbstractILink3Offsets)cls.getConstructor().newInstance();
    }
    catch (final ClassNotFoundException | NoSuchMethodException | InstantiationException |
        IllegalAccessException | InvocationTargetException e)
    {
        errorHandler.onError(e);
        return null;
    }
}
 
Example #26
Source File: AgentInvoker.java    From agrona with Apache License 2.0 5 votes vote down vote up
/**
 * Create an agent and initialise it.
 *
 * @param errorHandler to be called if an {@link Throwable} is encountered
 * @param errorCounter to be incremented each time an exception is encountered. This may be null.
 * @param agent        to be run in this thread.
 */
public AgentInvoker(final ErrorHandler errorHandler, final AtomicCounter errorCounter, final Agent agent)
{
    Objects.requireNonNull(errorHandler, "errorHandler");
    Objects.requireNonNull(agent, "agent");

    this.errorHandler = errorHandler;
    this.errorCounter = errorCounter;
    this.agent = agent;
}
 
Example #27
Source File: DedicatedModeArchiveConductor.java    From aeron with Apache License 2.0 5 votes vote down vote up
DedicatedModeRecorder(
    final ErrorHandler errorHandler,
    final AtomicCounter errorCounter,
    final ManyToOneConcurrentLinkedQueue<Session> closeQueue,
    final CountDownLatch abortLatch)
{
    super("archive-recorder", errorHandler);

    this.closeQueue = closeQueue;
    this.errorCounter = errorCounter;
    this.sessionsQueue = new ManyToOneConcurrentLinkedQueue<>();
    this.abortLatch = abortLatch;
}
 
Example #28
Source File: SectorFramer.java    From artio with Apache License 2.0 5 votes vote down vote up
public static void validateCheckSum(
    final String fileName,
    final int start,
    final int end,
    final int savedChecksum,
    final int calculatedChecksum,
    final ErrorHandler errorHandler)
{
    if (calculatedChecksum != savedChecksum)
    {
        final FileSystemCorruptionException exception = new FileSystemCorruptionException(
            fileName, start, end, savedChecksum, calculatedChecksum);
        errorHandler.onError(exception);
    }
}
 
Example #29
Source File: DefaultEngineScheduler.java    From artio with Apache License 2.0 5 votes vote down vote up
public void launch(
    final EngineConfiguration configuration,
    final ErrorHandler errorHandler,
    final Agent framer,
    final Agent indexingAgent,
    final Agent monitoringAgent,
    final Agent conductorAgent,
    final RecordingCoordinator recordingCoordinator)
{
    this.recordingCoordinator = recordingCoordinator;
    if (framerRunner != null)
    {
        EngineScheduler.fail();
    }

    framerRunner = new AgentRunner(
        configuration.framerIdleStrategy(), errorHandler, null, framer);
    archivingRunner = new AgentRunner(
        configuration.archiverIdleStrategy(), errorHandler, null, indexingAgent);

    final ThreadFactory threadFactory = configuration.threadFactory();
    startOnThread(framerRunner, threadFactory);
    startOnThread(archivingRunner, threadFactory);

    if (monitoringAgent != null)
    {
        monitoringRunner = new AgentRunner(
            configuration.monitoringThreadIdleStrategy(),
            errorHandler,
            null,
            monitoringAgent);
        startOnThread(monitoringRunner, configuration.threadFactory());
    }
}
 
Example #30
Source File: ClusterMember.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * Close the publications associated with members of the cluster used for the consensus protocol.
 *
 * @param errorHandler   to capture errors during close.
 * @param clusterMembers to close the publications for.
 */
public static void closeConsensusPublications(final ErrorHandler errorHandler, final ClusterMember[] clusterMembers)
{
    for (final ClusterMember member : clusterMembers)
    {
        member.closePublication(errorHandler);
    }
}