/** {@inheritDoc} */ public void close() { hwmPosition.close(); rebuildPosition.close(); for (final ReadablePosition position : subscriberPositions) { position.close(); } congestionControl.close(); rawLog.close(); }
private boolean isDrained() { long minSubscriberPosition = Long.MAX_VALUE; for (final ReadablePosition subscriberPosition : subscriberPositions) { minSubscriberPosition = Math.min(minSubscriberPosition, subscriberPosition.getVolatile()); } return minSubscriberPosition >= rebuildPosition.get(); }
private void hwmCandidate(final long proposedPosition) { lastPacketTimestamp = nanoClock.nanoTime(); hwmPosition.proposeMaxOrdered(proposedPosition); }
/** * The position up to which the current stream rebuild is complete for reception. * * @return the position up to which the current stream rebuild is complete for reception. */ long rebuildPosition() { return rebuildPosition.get(); }
public PublicationImage( final long correlationId, final long imageLivenessTimeoutNs, final ReceiveChannelEndpoint channelEndpoint, final InetSocketAddress controlAddress, final int sessionId, final int streamId, final int initialTermId, final int activeTermId, final int initialTermOffset, final RawLog rawLog, final FeedbackDelayGenerator lossFeedbackDelayGenerator, final List<ReadablePosition> subscriberPositions, final Position hwmPosition, final Position rebuildPosition, final NanoClock nanoClock, final EpochClock epochClock, final SystemCounters systemCounters, final InetSocketAddress sourceAddress, final CongestionControl congestionControl, final LossReport lossReport, final boolean isReliable) { this.correlationId = correlationId; this.imageLivenessTimeoutNs = imageLivenessTimeoutNs; this.channelEndpoint = channelEndpoint; this.controlAddress = controlAddress; this.sessionId = sessionId; this.streamId = streamId; this.rawLog = rawLog; this.subscriberPositions = subscriberPositions.toArray(new ReadablePosition[0]); this.hwmPosition = hwmPosition; this.rebuildPosition = rebuildPosition; this.sourceAddress = sourceAddress; this.initialTermId = initialTermId; this.congestionControl = congestionControl; this.lossReport = lossReport; this.isReliable = isReliable; heartbeatsReceived = systemCounters.get(HEARTBEATS_RECEIVED); statusMessagesSent = systemCounters.get(STATUS_MESSAGES_SENT); nakMessagesSent = systemCounters.get(NAK_MESSAGES_SENT); flowControlUnderRuns = systemCounters.get(FLOW_CONTROL_UNDER_RUNS); flowControlOverRuns = systemCounters.get(FLOW_CONTROL_OVER_RUNS); lossGapFills = systemCounters.get(LOSS_GAP_FILLS); this.nanoClock = nanoClock; this.epochClock = epochClock; final long time = nanoClock.nanoTime(); timeOfLastStatusChange = time; lastPacketTimestamp = time; termBuffers = rawLog.termBuffers(); lossDetector = new LossDetector(lossFeedbackDelayGenerator, this); final int termLength = rawLog.termLength(); termLengthMask = termLength - 1; positionBitsToShift = Integer.numberOfTrailingZeros(termLength); final long initialPosition = computePosition(activeTermId, initialTermOffset, positionBitsToShift, initialTermId); nextSmPosition = initialPosition; nextSmReceiverWindowLength = congestionControl.initialWindowLength(); cleanPosition = initialPosition; hwmPosition.setOrdered(initialPosition); rebuildPosition.setOrdered(initialPosition); }