use of io.aeron.exceptions.TimeoutException in project Aeron by real-logic.
the class TestCluster method connectClient.
public AeronCluster connectClient(final AeronCluster.Context clientCtx) {
final String aeronDirName = CommonContext.getAeronDirectoryName();
if (null == clientMediaDriver) {
dataCollector.add(Paths.get(aeronDirName));
final MediaDriver.Context ctx = new MediaDriver.Context().threadingMode(ThreadingMode.SHARED).dirDeleteOnStart(true).dirDeleteOnShutdown(false).aeronDirectoryName(aeronDirName).nameResolver(new RedirectingNameResolver(nodeNameMappings()));
clientMediaDriver = MediaDriver.launch(ctx);
}
clientCtx.aeronDirectoryName(aeronDirName).isIngressExclusive(true).egressListener(egressListener).controlledEgressListener(controlledEgressListener).ingressEndpoints(staticClusterMemberEndpoints);
try {
CloseHelper.close(client);
client = AeronCluster.connect(clientCtx.clone());
} catch (final TimeoutException ex) {
System.out.println("Warning: " + ex);
CloseHelper.close(client);
client = AeronCluster.connect(clientCtx);
}
return client;
}
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 ClusterBackupAgent method doWork.
/**
* {@inheritDoc}
*/
public int doWork() {
final long nowMs = epochClock.time();
int workCount = 0;
try {
if (nowMs > slowTickDeadlineMs) {
slowTickDeadlineMs = nowMs + SLOW_TICK_INTERVAL_MS;
workCount += slowTick(nowMs);
}
workCount += consensusSubscription.poll(fragmentAssembler, ConsensusAdapter.FRAGMENT_LIMIT);
switch(state) {
case BACKUP_QUERY:
workCount += backupQuery(nowMs);
break;
case SNAPSHOT_RETRIEVE:
workCount += snapshotRetrieve(nowMs);
break;
case LIVE_LOG_RECORD:
workCount += liveLogRecord(nowMs);
break;
case LIVE_LOG_REPLAY:
workCount += liveLogReplay(nowMs);
break;
case UPDATE_RECORDING_LOG:
workCount += updateRecordingLog(nowMs);
break;
case BACKING_UP:
workCount += backingUp(nowMs);
break;
case RESET_BACKUP:
workCount += resetBackup(nowMs);
break;
}
if (hasProgressStalled(nowMs)) {
if (null != eventsListener) {
eventsListener.onPossibleFailure(new TimeoutException("progress has stalled", Category.WARN));
}
state(RESET_BACKUP, nowMs);
}
} catch (final AgentTerminationException ex) {
runTerminationHook(ex);
} catch (final Exception ex) {
if (null != eventsListener) {
eventsListener.onPossibleFailure(ex);
}
state(RESET_BACKUP, nowMs);
throw ex;
}
return workCount;
}
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;
}
use of io.aeron.exceptions.TimeoutException in project aeron by real-logic.
the class Election method followerReady.
private int followerReady(final long nowNs) {
if (consensusPublisher.appendPosition(leaderMember.publication(), leadershipTermId, logPosition, thisMember.id())) {
consensusModuleAgent.leadershipTermId(leadershipTermId);
consensusModuleAgent.electionComplete(nowNs);
state(CLOSED, nowNs);
} else if (nowNs >= (timeOfLastStateChangeNs + ctx.leaderHeartbeatTimeoutNs())) {
throw new TimeoutException("ready follower failed to notify leader", AeronException.Category.WARN);
}
return 1;
}
Aggregations