示例#1
0
  /**
   * Called from the {@link Receiver} upon receiving an RTT Measurement that is a reply.
   *
   * @param header of the measurement
   * @param srcAddress from the sender of the measurement
   */
  public void onRttMeasurement(
      final RttMeasurementFlyweight header, final InetSocketAddress srcAddress) {
    final long now = nanoClock.nanoTime();
    final long rttInNanos = now - header.echoTimestamp() - header.receptionDelta();

    congestionControl.onRttMeasurement(now, rttInNanos, srcAddress);
  }
示例#2
0
  public int doWork() {
    final int workCount = commandQueue.drain(this);
    final int bytesSent = doSend(nanoClock.nanoTime());
    final int bytesReceived = controlTransportPoller.pollTransports();

    return workCount + bytesSent + bytesReceived;
  }
示例#3
0
 private void hwmCandidate(final long proposedPosition) {
   lastPacketTimestamp = nanoClock.nanoTime();
   hwmPosition.proposeMaxOrdered(proposedPosition);
 }
示例#4
0
 /**
  * Set status of the image.
  *
  * <p>Set by {@link Receiver} for INIT to ACTIVE to INACTIVE
  *
  * <p>Set by {@link DriverConductor} for INACTIVE to LINGER
  *
  * @param status of the image
  */
 public void status(final Status status) {
   timeOfLastStatusChange = nanoClock.nanoTime();
   this.status = status;
 }
示例#5
0
  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);
  }