public void onRttMeasurement(final long nowNs, final long rttNs, final InetSocketAddress srcAddress) { outstandingRttMeasurements--; lastRttTimestampNs = nowNs; this.rttInNs = rttNs; rttIndicator.setOrdered(rttNs); }
public void timeOfLastKeepaliveMs(final long nowMs) { timeOfLastKeepaliveMs = nowMs; heartbeatStatus.setOrdered(nowMs); }
public AeronClient( final long clientId, final long clientLivenessTimeoutNs, final long nowMs, final AtomicCounter clientTimeouts, final AtomicCounter heartbeatStatus) { this.clientId = clientId; this.clientLivenessTimeoutMs = Math.max(1, TimeUnit.NANOSECONDS.toMillis(clientLivenessTimeoutNs)); this.timeOfLastKeepaliveMs = nowMs; this.clientTimeouts = clientTimeouts; this.heartbeatStatus = heartbeatStatus; heartbeatStatus.setOrdered(nowMs); }
public void indicateActive() { final long currentStatus = statusIndicator.get(); if (currentStatus != ChannelEndpointStatus.INITIALIZING) { throw new IllegalStateException( "channel cannot be registered unless INITALIZING: status=" + status(currentStatus)); } statusIndicator.setOrdered(ChannelEndpointStatus.ACTIVE); }
public void closeStatusIndicator() { if (!statusIndicator.isClosed()) { statusIndicator.setOrdered(ChannelEndpointStatus.CLOSING); statusIndicator.close(); } }
public void closeStatusIndicator() { if (!statusIndicator.isClosed()) { statusIndicator.setOrdered(ChannelEndpointStatus.CLOSING); statusIndicator.close(); } }
windowIndicator.setOrdered(window);
public void indicateActive() { final long currentStatus = statusIndicator.get(); if (currentStatus != ChannelEndpointStatus.INITIALIZING) { throw new AeronException( "channel cannot be registered unless INITIALISING: status=" + status(currentStatus)); } statusIndicator.setOrdered(ChannelEndpointStatus.ACTIVE); }
private void awaitActiveLog() { idleStrategy.reset(); while (null == activeLogEvent) { serviceAdapter.poll(); checkInterruptedStatus(); heartbeatCounter.setOrdered(epochClock.time()); idleStrategy.idle(); } }
private boolean checkForClockTick() { final long nowMs = epochClock.time(); if (cachedTimeMs != nowMs) { cachedTimeMs = nowMs; if (consensusModuleProxy.isConnected()) { markFile.updateActivityTimestamp(nowMs); heartbeatCounter.setOrdered(nowMs); } else { ctx.countedErrorHandler().onError(new ClusterException("Consensus Module not connected")); ctx.terminationHook().run(); } return true; } return false; }
private int awaitRecoveryCounter(final CountersReader counters) { idleStrategy.reset(); int counterId = RecoveryState.findCounterId(counters); while (NULL_COUNTER_ID == counterId) { checkInterruptedStatus(); idleStrategy.idle(); heartbeatCounter.setOrdered(epochClock.time()); counterId = RecoveryState.findCounterId(counters); } return counterId; }
udpChannel.originalUriString()); rttIndicator.setOrdered(0); windowIndicator.setOrdered(minWindow);
private void checkForSnapshot(final CountersReader counters, final int recoveryCounterId) { clusterTimeMs = RecoveryState.getTimestamp(counters, recoveryCounterId); final long leadershipTermId = RecoveryState.getLeadershipTermId(counters, recoveryCounterId); if (NULL_VALUE != leadershipTermId) { loadSnapshot(RecoveryState.getSnapshotRecordingId(counters, recoveryCounterId, serviceId)); } heartbeatCounter.setOrdered(epochClock.time()); consensusModuleProxy.ack(RecoveryState.getLogPosition(counters, recoveryCounterId), ackId++, serviceId); }
private ReadableCounter awaitCommitPositionCounter(final CountersReader counters) { idleStrategy.reset(); int counterId = CommitPos.findCounterId(counters); while (NULL_COUNTER_ID == counterId) { checkInterruptedStatus(); idleStrategy.idle(); heartbeatCounter.setOrdered(epochClock.time()); counterId = CommitPos.findCounterId(counters); } return new ReadableCounter(counters, counterId); }
private void checkForReplay(final CountersReader counters, final int recoveryCounterId) { if (RecoveryState.hasReplay(counters, recoveryCounterId)) { awaitActiveLog(); try (Subscription subscription = aeron.addSubscription(activeLogEvent.channel, activeLogEvent.streamId)) { consensusModuleProxy.ack(activeLogEvent.logPosition, ackId++, serviceId); final Image image = awaitImage(activeLogEvent.sessionId, subscription); final BoundedLogAdapter adapter = new BoundedLogAdapter(image, commitPosition, this); consumeImage(image, adapter, activeLogEvent.maxLogPosition); } activeLogEvent = null; heartbeatCounter.setOrdered(epochClock.time()); } }
public void onStart() { final CountersReader counters = aeron.countersReader(); roleCounter = awaitClusterRoleCounter(counters); heartbeatCounter = awaitHeartbeatCounter(counters); commitPosition = awaitCommitPositionCounter(counters); service.onStart(this); isServiceActive = true; final int recoveryCounterId = awaitRecoveryCounter(counters); heartbeatCounter.setOrdered(epochClock.time()); checkForSnapshot(counters, recoveryCounterId); checkForReplay(counters, recoveryCounterId); }
statusIndicator.setOrdered(ChannelEndpointStatus.ERRORED);
private void joinActiveLog() { final Subscription logSubscription = aeron.addSubscription(activeLogEvent.channel, activeLogEvent.streamId); consensusModuleProxy.ack(activeLogEvent.logPosition, ackId++, serviceId); final Image image = awaitImage(activeLogEvent.sessionId, logSubscription); heartbeatCounter.setOrdered(epochClock.time()); egressMessageHeaderEncoder.leadershipTermId(activeLogEvent.leadershipTermId); memberId = activeLogEvent.memberId; ctx.clusterMarkFile().memberId(memberId); logChannel = activeLogEvent.channel; activeLogEvent = null; logAdapter = new BoundedLogAdapter(image, commitPosition, this); role(Role.get((int)roleCounter.get())); for (final ClientSession session : sessionByIdMap.values()) { if (Role.LEADER == role) { if (ctx.isRespondingService()) { session.connect(aeron); } session.resetClosing(); } else { session.disconnect(); } } }
public void onRttMeasurement(final long nowNs, final long rttNs, final InetSocketAddress srcAddress) { outstandingRttMeasurements--; lastRttTimestampNs = nowNs; this.rttInNs = rttNs; rttIndicator.setOrdered(rttNs); }
public void indicateActive() { final long currentStatus = statusIndicator.get(); if (currentStatus != ChannelEndpointStatus.INITIALIZING) { throw new IllegalStateException( "channel cannot be registered unless INITALIZING: status=" + status(currentStatus)); } statusIndicator.setOrdered(ChannelEndpointStatus.ACTIVE); }