コード例 #1
0
        internal Publication(ClientConductor clientConductor, string channel, int streamId, int sessionId, IReadablePosition positionLimit, LogBuffers logBuffers, long registrationId)
        {
            var buffers           = logBuffers.AtomicBuffers();
            var logMetaDataBuffer = buffers[LogBufferDescriptor.LOG_META_DATA_SECTION_INDEX];

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

            var termLength = logBuffers.TermLength();

            _maxPayloadLength    = LogBufferDescriptor.MtuLength(logMetaDataBuffer) - DataHeaderFlyweight.HEADER_LENGTH;
            MaxMessageLength     = FrameDescriptor.ComputeMaxMessageLength(termLength);
            _clientConductor     = 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 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);
        }
コード例 #3
0
ファイル: Image.cs プロジェクト: yksi7417/Aeron.NET
        /// <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;

            _termBuffers = logBuffers.TermBuffers();

            var termLength = logBuffers.TermLength();

            _termLengthMask      = termLength - 1;
            _positionBitsToShift = IntUtil.NumberOfTrailingZeros(termLength);
            _header = new Header(LogBufferDescriptor.InitialTermId(logBuffers.MetaDataBuffer()), _positionBitsToShift);
        }
コード例 #4
0
ファイル: Image.cs プロジェクト: kiwipiet/Aeron.NET
        /// <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;

            var buffers = logBuffers.AtomicBuffers();

            Array.Copy(buffers, 0, _termBuffers, 0, LogBufferDescriptor.PARTITION_COUNT);

            var termLength = logBuffers.TermLength();

            _termLengthMask      = termLength - 1;
            _positionBitsToShift = IntUtil.NumberOfTrailingZeros(termLength);
            _header = new Header(LogBufferDescriptor.InitialTermId(buffers[LogBufferDescriptor.LOG_META_DATA_SECTION_INDEX]), _positionBitsToShift);
        }