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;
}
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;
}
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;
}
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();
}
}
}
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);
}
}
}
Aggregations