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