Search in sources :

Example 16 with TimeoutException

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

the class Election method followerCatchupAwait.

private int followerCatchupAwait(final long nowNs) {
    int workCount = 0;
    final Image image = logSubscription.imageBySessionId(logSessionId);
    if (null != image) {
        verifyLogImage(image);
        if (consensusModuleAgent.tryJoinLogAsFollower(image, isLeaderStartup)) {
            state(FOLLOWER_CATCHUP, nowNs);
            workCount++;
        } else if (nowNs >= (timeOfLastStateChangeNs + ctx.leaderHeartbeatTimeoutNs())) {
            throw new TimeoutException("failed to join catchup log as follower", AeronException.Category.WARN);
        }
    } else if (nowNs >= (timeOfLastStateChangeNs + ctx.leaderHeartbeatTimeoutNs())) {
        throw new TimeoutException("failed to join catchup log", AeronException.Category.WARN);
    }
    return workCount;
}
Also used : TimeoutException(io.aeron.exceptions.TimeoutException)

Example 17 with TimeoutException

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

the class Election method followerLogReplication.

private int followerLogReplication(final long nowNs) {
    int workCount = 0;
    if (null == logReplication) {
        if (appendPosition < replicationStopPosition) {
            logReplication = consensusModuleAgent.newLogReplication(leaderMember.archiveEndpoint(), leaderRecordingId, replicationStopPosition, nowNs);
            replicationDeadlineNs = nowNs + ctx.leaderHeartbeatTimeoutNs();
            workCount++;
        } else {
            updateRecordingLogForReplication(replicationLeadershipTermId, replicationTermBaseLogPosition, replicationStopPosition, nowNs);
            state(CANVASS, nowNs);
        }
    } else {
        workCount += consensusModuleAgent.pollArchiveEvents();
        workCount += publishFollowerReplicationPosition(nowNs);
        if (logReplication.isDone(nowNs)) {
            if (replicationCommitPosition >= appendPosition) {
                appendPosition = logReplication.position();
                cleanupLogReplication();
                updateRecordingLogForReplication(replicationLeadershipTermId, replicationTermBaseLogPosition, replicationStopPosition, nowNs);
                state(CANVASS, nowNs);
                workCount++;
            } else if (nowNs >= replicationDeadlineNs) {
                throw new TimeoutException("timeout awaiting commit position", AeronException.Category.WARN);
            }
        }
    }
    return workCount;
}
Also used : TimeoutException(io.aeron.exceptions.TimeoutException)

Example 18 with TimeoutException

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

the class Election method followerLogAwait.

private int followerLogAwait(final long nowNs) {
    int workCount = 0;
    final Image image = logSubscription.imageBySessionId(logSessionId);
    if (null != image) {
        verifyLogImage(image);
        if (consensusModuleAgent.tryJoinLogAsFollower(image, isLeaderStartup)) {
            appendPosition = image.joinPosition();
            logPosition = image.joinPosition();
            updateRecordingLog(nowNs);
            state(FOLLOWER_READY, nowNs);
            workCount++;
        } else if (nowNs >= (timeOfLastStateChangeNs + ctx.leaderHeartbeatTimeoutNs())) {
            throw new TimeoutException("failed to join live log as follower", AeronException.Category.WARN);
        }
    } else if (nowNs >= (timeOfLastStateChangeNs + ctx.leaderHeartbeatTimeoutNs())) {
        throw new TimeoutException("failed to join live log", AeronException.Category.WARN);
    }
    return workCount;
}
Also used : TimeoutException(io.aeron.exceptions.TimeoutException)

Example 19 with TimeoutException

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

the class SequencerAgent method checkServiceHeartbeats.

private void checkServiceHeartbeats(final long nowMs) {
    final long heartbeatThreshold = nowMs - serviceHeartbeatTimeoutMs;
    for (final Counter serviceHeartbeat : serviceHeartbeats) {
        if (serviceHeartbeat.get() < heartbeatThreshold) {
            ctx.errorHandler().onError(new TimeoutException("No heartbeat from clustered service"));
            ctx.terminationHook().run();
        }
    }
}
Also used : ReadableCounter(io.aeron.status.ReadableCounter) TimeoutException(io.aeron.exceptions.TimeoutException)

Example 20 with TimeoutException

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

the class TestCluster method awaitServiceMessageCount.

public void awaitServiceMessageCount(final TestNode node, final int messageCount) {
    final TestNode.TestService service = node.service();
    final EpochClock epochClock = client.context().aeron().context().epochClock();
    long keepAliveDeadlineMs = epochClock.time() + TimeUnit.SECONDS.toMillis(1);
    long count;
    while ((count = service.messageCount()) < messageCount) {
        Thread.yield();
        if (Thread.interrupted()) {
            throw new TimeoutException("count=" + count + " awaiting=" + messageCount + " node=" + node);
        }
        if (service.hasReceivedUnexpectedMessage()) {
            fail("service received unexpected message");
        }
        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)

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