Search in sources :

Example 1 with ReadablePosition

use of org.agrona.concurrent.status.ReadablePosition in project Aeron by real-logic.

the class IpcPublication method close.

public void close() {
    publisherLimit.close();
    for (final ReadablePosition position : subscriberPositions) {
        position.close();
    }
    rawLog.close();
}
Also used : ReadablePosition(org.agrona.concurrent.status.ReadablePosition)

Example 2 with ReadablePosition

use of org.agrona.concurrent.status.ReadablePosition in project Aeron by real-logic.

the class IpcPublication method updatePublishersLimit.

int updatePublishersLimit(final long nowInMillis) {
    int workCount = 0;
    long minSubscriberPosition = Long.MAX_VALUE;
    long maxSubscriberPosition = consumerPosition;
    for (final ReadablePosition subscriberPosition : subscriberPositions) {
        final long position = subscriberPosition.getVolatile();
        minSubscriberPosition = Math.min(minSubscriberPosition, position);
        maxSubscriberPosition = Math.max(maxSubscriberPosition, position);
    }
    if (subscriberPositions.length > 0) {
        final long proposedLimit = minSubscriberPosition + termWindowLength;
        if (proposedLimit > tripLimit) {
            publisherLimit.setOrdered(proposedLimit);
            tripLimit = proposedLimit + tripGain;
            cleanBuffer(minSubscriberPosition);
            LogBufferDescriptor.timeOfLastStatusMessage(rawLog.metaData(), nowInMillis);
            workCount = 1;
        }
        consumerPosition = maxSubscriberPosition;
    }
    return workCount;
}
Also used : ReadablePosition(org.agrona.concurrent.status.ReadablePosition)

Example 3 with ReadablePosition

use of org.agrona.concurrent.status.ReadablePosition in project aeron by real-logic.

the class NetworkPublication method spiesFinishedConsuming.

private boolean spiesFinishedConsuming(final DriverConductor conductor, final long eosPosition) {
    if (spyPositions.length > 0) {
        for (final ReadablePosition spyPosition : spyPositions) {
            if (spyPosition.getVolatile() < eosPosition) {
                return false;
            }
        }
        hasSpies = false;
        conductor.cleanupSpies(this);
    }
    return true;
}
Also used : ReadablePosition(org.agrona.concurrent.status.ReadablePosition)

Example 4 with ReadablePosition

use of org.agrona.concurrent.status.ReadablePosition in project aeron by real-logic.

the class NetworkPublication method updatePublisherLimit.

/**
 * Update the publishers limit for flow control as part of the conductor duty cycle.
 *
 * @return 1 if the limit has been updated otherwise 0.
 */
final int updatePublisherLimit() {
    int workCount = 0;
    final long senderPosition = this.senderPosition.getVolatile();
    if (hasReceivers || (spiesSimulateConnection && spyPositions.length > 0)) {
        long minConsumerPosition = senderPosition;
        for (final ReadablePosition spyPosition : spyPositions) {
            minConsumerPosition = Math.min(minConsumerPosition, spyPosition.getVolatile());
        }
        final long proposedPublisherLimit = minConsumerPosition + termWindowLength;
        if (publisherLimit.proposeMaxOrdered(proposedPublisherLimit)) {
            cleanBuffer(proposedPublisherLimit);
            workCount = 1;
        }
    } else if (publisherLimit.get() > senderPosition) {
        publisherLimit.setOrdered(senderPosition);
    }
    return workCount;
}
Also used : SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint) ReadablePosition(org.agrona.concurrent.status.ReadablePosition)

Example 5 with ReadablePosition

use of org.agrona.concurrent.status.ReadablePosition in project aeron by real-logic.

the class PublicationImage method trackRebuild.

/**
 * Called from the {@link DriverConductor}.
 *
 * @param nowNs                  in nanoseconds
 * @param statusMessageTimeoutNs for sending of Status Messages.
 */
final void trackRebuild(final long nowNs, final long statusMessageTimeoutNs) {
    long minSubscriberPosition = Long.MAX_VALUE;
    long maxSubscriberPosition = Long.MIN_VALUE;
    for (final ReadablePosition subscriberPosition : subscriberPositions) {
        final long position = subscriberPosition.getVolatile();
        minSubscriberPosition = Math.min(minSubscriberPosition, position);
        maxSubscriberPosition = Math.max(maxSubscriberPosition, position);
    }
    final long rebuildPosition = Math.max(this.rebuildPosition.get(), maxSubscriberPosition);
    final long hwmPosition = this.hwmPosition.getVolatile();
    final long scanOutcome = lossDetector.scan(termBuffers[indexByPosition(rebuildPosition, positionBitsToShift)], rebuildPosition, hwmPosition, nowNs, termLengthMask, positionBitsToShift, initialTermId);
    final int rebuildTermOffset = (int) rebuildPosition & termLengthMask;
    final long newRebuildPosition = (rebuildPosition - rebuildTermOffset) + rebuildOffset(scanOutcome);
    this.rebuildPosition.proposeMaxOrdered(newRebuildPosition);
    final long ccOutcome = congestionControl.onTrackRebuild(nowNs, minSubscriberPosition, nextSmPosition, hwmPosition, rebuildPosition, newRebuildPosition, lossFound(scanOutcome));
    final int window = CongestionControlUtil.receiverWindowLength(ccOutcome);
    final long threshold = CongestionControlUtil.positionThreshold(window);
    if (CongestionControlUtil.shouldForceStatusMessage(ccOutcome) || (nowNs > (timeOfLastStatusMessageNs + statusMessageTimeoutNs)) || (minSubscriberPosition > (nextSmPosition + threshold))) {
        scheduleStatusMessage(nowNs, minSubscriberPosition, window);
        cleanBufferTo(minSubscriberPosition - (termLengthMask + 1));
    }
}
Also used : ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) ReadablePosition(org.agrona.concurrent.status.ReadablePosition)

Aggregations

ReadablePosition (org.agrona.concurrent.status.ReadablePosition)18 ReceiveChannelEndpoint (io.aeron.driver.media.ReceiveChannelEndpoint)5 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)4 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1