Search in sources :

Example 11 with TimeoutException

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

the class Election method followerCatchupInit.

private int followerCatchupInit(final long nowNs) {
    if (null == logSubscription) {
        logSubscription = addFollowerSubscription();
        addCatchupLogDestination();
    }
    String catchupEndpoint = null;
    final String endpoint = thisMember.catchupEndpoint();
    if (endpoint.endsWith(":0")) {
        final String resolvedEndpoint = logSubscription.resolvedEndpoint();
        if (null != resolvedEndpoint) {
            final int i = resolvedEndpoint.lastIndexOf(':');
            catchupEndpoint = endpoint.substring(0, endpoint.length() - 2) + resolvedEndpoint.substring(i);
        }
    } else {
        catchupEndpoint = endpoint;
    }
    if (null != catchupEndpoint && sendCatchupPosition(catchupEndpoint)) {
        timeOfLastUpdateNs = nowNs;
        consensusModuleAgent.catchupInitiated(nowNs);
        state(FOLLOWER_CATCHUP_AWAIT, nowNs);
    } else if (nowNs >= (timeOfLastStateChangeNs + ctx.leaderHeartbeatTimeoutNs())) {
        throw new TimeoutException("failed to send catchup position", AeronException.Category.WARN);
    }
    return 1;
}
Also used : TimeoutException(io.aeron.exceptions.TimeoutException)

Example 12 with TimeoutException

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

the class TestCluster method awaitServiceState.

public void awaitServiceState(final TestNode node, final Predicate<TestNode> predicate) {
    final EpochClock epochClock = client.context().aeron().context().epochClock();
    long keepAliveDeadlineMs = epochClock.time() + TimeUnit.SECONDS.toMillis(1);
    while (!predicate.test(node)) {
        Thread.yield();
        if (Thread.interrupted()) {
            throw new TimeoutException("timeout while awaiting condition");
        }
        final long nowMs = epochClock.time();
        if (nowMs > keepAliveDeadlineMs) {
            client.sendKeepAlive();
            keepAliveDeadlineMs = nowMs + TimeUnit.SECONDS.toMillis(1);
        }
    }
}
Also used : EpochClock(org.agrona.concurrent.EpochClock) TimeoutException(io.aeron.exceptions.TimeoutException)

Example 13 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 14 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 15 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)

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