示例#1
0
        internal Publication(ClientConductor clientConductor, string channel, int streamId, int sessionId, IReadablePosition positionLimit, LogBuffers logBuffers, long registrationId)
        {
            var buffers           = logBuffers.TermBuffers();
            var logMetaDataBuffer = logBuffers.MetaDataBuffer();

            for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
            {
                _termAppenders[i] = new TermAppender(buffers[i], logMetaDataBuffer, i);
            }

            var termLength = logBuffers.TermLength();

            MaxPayloadLength     = LogBufferDescriptor.MtuLength(logMetaDataBuffer) - DataHeaderFlyweight.HEADER_LENGTH;
            MaxMessageLength     = FrameDescriptor.ComputeMaxMessageLength(termLength);
            _conductor           = clientConductor;
            Channel              = channel;
            StreamId             = streamId;
            SessionId            = sessionId;
            InitialTermId        = LogBufferDescriptor.InitialTermId(logMetaDataBuffer);
            _logMetaDataBuffer   = logMetaDataBuffer;
            RegistrationId       = registrationId;
            _positionLimit       = positionLimit;
            _logBuffers          = logBuffers;
            _positionBitsToShift = IntUtil.NumberOfTrailingZeros(termLength);
            _headerWriter        = new HeaderWriter(LogBufferDescriptor.DefaultFrameHeader(logMetaDataBuffer));
        }
示例#2
0
 internal Publication(
     ClientConductor clientConductor,
     string channel,
     int streamId,
     int sessionId,
     IReadablePosition positionLimit,
     int channelStatusId,
     LogBuffers logBuffers,
     long originalRegistrationId,
     long registrationId)
 {
     _logMetaDataBuffer   = logBuffers.MetaDataBuffer();
     TermBufferLength     = logBuffers.TermLength();
     MaxMessageLength     = FrameDescriptor.ComputeMaxMessageLength(TermBufferLength);
     MaxPayloadLength     = LogBufferDescriptor.MtuLength(_logMetaDataBuffer) - DataHeaderFlyweight.HEADER_LENGTH;
     _maxPossiblePosition = TermBufferLength * (1L << 31);
     _conductor           = clientConductor;
     Channel                 = channel;
     StreamId                = streamId;
     SessionId               = sessionId;
     InitialTermId           = LogBufferDescriptor.InitialTermId(_logMetaDataBuffer);
     _originalRegistrationId = originalRegistrationId;
     RegistrationId          = registrationId;
     _positionLimit          = positionLimit;
     _channelStatusId        = channelStatusId;
     _logBuffers             = logBuffers;
     PositionBitsToShift     = LogBufferDescriptor.PositionBitsToShift(TermBufferLength);
     _headerWriter           = new HeaderWriter(LogBufferDescriptor.DefaultFrameHeader(_logMetaDataBuffer));
 }
示例#3
0
        /// <summary>
        /// Count of observed active transports within the image liveness timeout.
        ///
        /// If the image is closed, then this is 0. This may also be 0 if no actual datagrams have arrived. IPC
        /// Images also will be 0.
        /// </summary>
        /// <returns> count of active transports - 0 if Image is closed, no datagrams yet, or IPC. </returns>
        public int ActiveTransportCount()
        {
            if (_isClosed)
            {
                return(0);
            }

            return(LogBufferDescriptor.ActiveTransportCount(_logBuffers.MetaDataBuffer()));
        }
示例#4
0
        /// <summary>
        /// Construct a new image over a log to represent a stream of messages from a <seealso cref="Publication"/>.
        /// </summary>
        /// <param name="subscription">       to which this <seealso cref="Image"/> belongs. </param>
        /// <param name="sessionId">          of the stream of messages. </param>
        /// <param name="subscriberPosition"> for indicating the position of the subscriber in the stream. </param>
        /// <param name="logBuffers">         containing the stream of messages. </param>
        /// <param name="errorHandler">       to be called if an error occurs when polling for messages. </param>
        /// <param name="sourceIdentity">     of the source sending the stream of messages. </param>
        /// <param name="correlationId">      of the request to the media driver. </param>
        public Image(Subscription subscription, int sessionId, IPosition subscriberPosition, LogBuffers logBuffers, ErrorHandler errorHandler, string sourceIdentity, long correlationId)
        {
            Subscription        = subscription;
            SessionId           = sessionId;
            _subscriberPosition = subscriberPosition;
            _logBuffers         = logBuffers;
            _errorHandler       = errorHandler;
            SourceIdentity      = sourceIdentity;
            CorrelationId       = correlationId;
            _joiningPosition    = subscriberPosition.Get();

            _termBuffers = logBuffers.TermBuffers();

            var termLength = logBuffers.TermLength();

            _termLengthMask      = termLength - 1;
            _positionBitsToShift = IntUtil.NumberOfTrailingZeros(termLength);
            _initialTermId       = LogBufferDescriptor.InitialTermId(logBuffers.MetaDataBuffer());
            _header = new Header(LogBufferDescriptor.InitialTermId(logBuffers.MetaDataBuffer()), _positionBitsToShift, this);
        }
        internal ExclusivePublication(
            ClientConductor clientConductor,
            string channel,
            int streamId,
            int sessionId,
            IReadablePosition positionLimit,
            LogBuffers logBuffers,
            long originalRegistrationId,
            long registrationId)
        {
            var buffers           = logBuffers.TermBuffers();
            var logMetaDataBuffer = logBuffers.MetaDataBuffer();

            for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
            {
                _termAppenders[i] = new ExclusiveTermAppender(buffers[i], logMetaDataBuffer, i);
            }

            var termLength = logBuffers.TermLength();

            _termBufferLength    = termLength;
            MaxPayloadLength     = LogBufferDescriptor.MtuLength(logMetaDataBuffer) - DataHeaderFlyweight.HEADER_LENGTH;
            MaxMessageLength     = FrameDescriptor.ComputeExclusiveMaxMessageLength(termLength);
            _maxPossiblePosition = termLength * (1L << 31);
            _conductor           = clientConductor;
            Channel   = channel;
            StreamId  = streamId;
            SessionId = sessionId;

            _logMetaDataBuffer      = logMetaDataBuffer;
            _originalRegistrationId = originalRegistrationId;
            RegistrationId          = registrationId;
            _positionLimit          = positionLimit;
            _logBuffers             = logBuffers;
            _positionBitsToShift    = IntUtil.NumberOfTrailingZeros(termLength);
            _headerWriter           = new HeaderWriter(LogBufferDescriptor.DefaultFrameHeader(logMetaDataBuffer));
            InitialTermId           = LogBufferDescriptor.InitialTermId(logMetaDataBuffer);

            var activeIndex = LogBufferDescriptor.ActivePartitionIndex(logMetaDataBuffer);

            _activePartitionIndex = activeIndex;

            long rawTail = LogBufferDescriptor.RawTail(_logMetaDataBuffer, activeIndex);

            _termId            = LogBufferDescriptor.TermId(rawTail);
            _termOffset        = LogBufferDescriptor.TermOffset(rawTail, termLength);
            _termBeginPosition =
                LogBufferDescriptor.ComputeTermBeginPosition(_termId, _positionBitsToShift, InitialTermId);
        }
示例#6
0
        internal ExclusivePublication(
            ClientConductor clientConductor,
            string channel,
            int streamId,
            int sessionId,
            IReadablePosition positionLimit,
            int channelStatusId,
            LogBuffers logBuffers,
            long originalRegistrationId,
            long registrationId)
            : base(
                clientConductor,
                channel,
                streamId,
                sessionId,
                positionLimit,
                channelStatusId,
                logBuffers,
                originalRegistrationId,
                registrationId,
                FrameDescriptor.ComputeExclusiveMaxMessageLength(logBuffers.TermLength())
                )
        {
            var buffers           = logBuffers.DuplicateTermBuffers();
            var logMetaDataBuffer = logBuffers.MetaDataBuffer();

            for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
            {
                _termAppenders[i] = new ExclusiveTermAppender(buffers[i], logMetaDataBuffer, i);
            }

            var termCount = LogBufferDescriptor.ActiveTermCount(logMetaDataBuffer);
            var index     = LogBufferDescriptor.IndexByTermCount(termCount);

            _activePartitionIndex = index;

            var rawTail = LogBufferDescriptor.RawTail(_logMetaDataBuffer, index);

            _termId            = LogBufferDescriptor.TermId(rawTail);
            _termOffset        = LogBufferDescriptor.TermOffset(rawTail);
            _termBeginPosition =
                LogBufferDescriptor.ComputeTermBeginPosition(_termId, _positionBitsToShift, InitialTermId);
        }
示例#7
0
 /// <summary>
 /// The length in bytes of the MTU (Maximum Transmission Unit) the Sender used for the datagram.
 /// </summary>
 /// <returns> length in bytes of the MTU (Maximum Transmission Unit) the Sender used for the datagram. </returns>
 public int MtuLength()
 {
     return(LogBufferDescriptor.MtuLength(_logBuffers.MetaDataBuffer()));
 }
示例#8
0
文件: Image.cs 项目: dm3/Aeron.NET
 internal void Close()
 {
     _finalPosition = _subscriberPosition.GetVolatile();
     _isEos         = _finalPosition >= LogBufferDescriptor.EndOfStreamPosition(_logBuffers.MetaDataBuffer());
     _isClosed      = true;
 }