Search in sources :

Example 1 with TimeoutException

use of io.aeron.exceptions.TimeoutException in project Aeron by real-logic.

the class ArchiveConductor method abort.

/**
 * {@inheritDoc}
 */
protected void abort() {
    try {
        isAbort = true;
        if (null != recorder) {
            recorder.abort();
        }
        if (null != replayer) {
            replayer.abort();
        }
        ctx.errorCounter().close();
        if (!ctx.abortLatch().await(AgentRunner.RETRY_CLOSE_TIMEOUT_MS * 3L, TimeUnit.MILLISECONDS)) {
            errorHandler.onError(new TimeoutException("awaiting abort latch", AeronException.Category.WARN));
        }
    } catch (final InterruptedException ignore) {
        Thread.currentThread().interrupt();
    }
}
Also used : TimeoutException(io.aeron.exceptions.TimeoutException)

Example 2 with TimeoutException

use of io.aeron.exceptions.TimeoutException in project Aeron by real-logic.

the class ReplicationSession method srcRecordingPosition.

private int srcRecordingPosition() {
    int workCount = 0;
    if (NULL_VALUE == activeCorrelationId) {
        final long correlationId = aeron.nextCorrelationId();
        if (srcArchive.archiveProxy().getRecordingPosition(srcRecordingId, correlationId, srcArchive.controlSessionId())) {
            workCount += trackAction(correlationId);
        } else if (epochClock.time() >= (timeOfLastActionMs + actionTimeoutMs)) {
            throw new TimeoutException("failed to send recording position request");
        }
    } else {
        final ControlResponsePoller poller = srcArchive.controlResponsePoller();
        workCount += poller.poll();
        if (hasResponse(poller)) {
            srcRecordingPosition = poller.relevantId();
            if (NULL_POSITION == srcRecordingPosition && null != liveDestination) {
                throw new ArchiveException("cannot live merge without active source recording");
            }
            state(State.EXTEND);
        } else if (epochClock.time() >= (timeOfLastActionMs + actionTimeoutMs)) {
            throw new TimeoutException("failed to get recording position");
        }
    }
    return workCount;
}
Also used : TimeoutException(io.aeron.exceptions.TimeoutException)

Example 3 with TimeoutException

use of io.aeron.exceptions.TimeoutException in project Aeron by real-logic.

the class ReplicationSession method replicateDescriptor.

private int replicateDescriptor() {
    int workCount = 0;
    if (NULL_VALUE == activeCorrelationId) {
        final long correlationId = aeron.nextCorrelationId();
        if (srcArchive.archiveProxy().listRecording(srcRecordingId, correlationId, srcArchive.controlSessionId())) {
            workCount += trackAction(correlationId);
            srcArchive.recordingDescriptorPoller().reset(correlationId, 1, this);
        } else if (epochClock.time() >= (timeOfLastActionMs + actionTimeoutMs)) {
            throw new TimeoutException("failed to list remote recording descriptor");
        }
    } else {
        final RecordingDescriptorPoller poller = srcArchive.recordingDescriptorPoller();
        final int fragments = poller.poll();
        if (poller.isDispatchComplete() && poller.remainingRecordCount() > 0) {
            state(State.DONE);
            error("unknown src recording id " + srcRecordingId, ArchiveException.UNKNOWN_RECORDING);
        }
        if (0 == fragments && epochClock.time() >= (timeOfLastActionMs + actionTimeoutMs)) {
            throw new TimeoutException("failed to fetch remote recording descriptor");
        }
        workCount += fragments;
    }
    return workCount;
}
Also used : TimeoutException(io.aeron.exceptions.TimeoutException)

Example 4 with TimeoutException

use of io.aeron.exceptions.TimeoutException in project Aeron by real-logic.

the class ReplicationSession method attemptLiveJoin.

private int attemptLiveJoin() {
    int workCount = 0;
    if (NULL_VALUE == activeCorrelationId) {
        final long correlationId = aeron.nextCorrelationId();
        if (srcArchive.archiveProxy().getRecordingPosition(srcRecordingId, correlationId, srcArchive.controlSessionId())) {
            workCount += trackAction(correlationId);
        } else if (epochClock.time() >= (timeOfLastActionMs + actionTimeoutMs)) {
            throw new TimeoutException("failed to send recording position request");
        }
    } else {
        final ControlResponsePoller poller = srcArchive.controlResponsePoller();
        workCount += poller.poll();
        if (hasResponse(poller)) {
            trackAction(NULL_VALUE);
            retryAttempts = RETRY_ATTEMPTS;
            srcRecordingPosition = poller.relevantId();
            if (NULL_POSITION == srcRecordingPosition && null != liveDestination) {
                throw new ArchiveException("cannot live merge without active source recording");
            }
            final long position = image.position();
            if (shouldAddLiveDestination(position)) {
                recordingSubscription.asyncAddDestination(liveDestination);
                isLiveAdded = true;
            } else if (shouldStopReplay(position)) {
                recordingSubscription.asyncRemoveDestination(replayDestination);
                replayDestination = null;
                recordingSubscription = null;
                signal(position, MERGE);
                state(State.DONE);
            }
            workCount += 1;
        } else if (image.isClosed()) {
            throw new ArchiveException("replication image closed unexpectedly");
        } else if (epochClock.time() >= (timeOfLastActionMs + actionTimeoutMs)) {
            if (--retryAttempts == 0) {
                throw new TimeoutException("failed to get recording position");
            }
            trackAction(NULL_VALUE);
        }
    }
    return workCount;
}
Also used : TimeoutException(io.aeron.exceptions.TimeoutException)

Example 5 with TimeoutException

use of io.aeron.exceptions.TimeoutException in project Aeron by real-logic.

the class ReplicationSession method awaitImage.

private int awaitImage() {
    int workCount = 0;
    image = recordingSubscription.imageBySessionId(replaySessionId);
    if (null != image) {
        state(null == liveDestination ? State.REPLICATE : State.CATCHUP);
        workCount += 1;
    } else if (epochClock.time() >= (timeOfLastActionMs + actionTimeoutMs)) {
        throw new TimeoutException("failed get replay image for sessionId " + replaySessionId + " on channel " + recordingSubscription.channel());
    }
    return workCount;
}
Also used : TimeoutException(io.aeron.exceptions.TimeoutException)

Aggregations

TimeoutException (io.aeron.exceptions.TimeoutException)31 EpochClock (org.agrona.concurrent.EpochClock)4 ClusterException (io.aeron.cluster.client.ClusterException)2 MediaDriver (io.aeron.driver.MediaDriver)2 RedirectingNameResolver (io.aeron.test.driver.RedirectingNameResolver)2 AgentTerminationException (org.agrona.concurrent.AgentTerminationException)2 ReadableCounter (io.aeron.status.ReadableCounter)1