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