Example #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));
        }
Example #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));
 }
        internal ConcurrentPublication(
            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.ComputeMaxMessageLength(logBuffers.TermLength())
                )
        {
            var buffers = logBuffers.DuplicateTermBuffers();

            for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
            {
                _termAppenders[i] = new TermAppender(buffers[i], _logMetaDataBuffer, i);
            }
        }
Example #4
0
 public void ShouldReportMaxMessageLength()
 {
     Assert.AreEqual(_publication.MaxMessageLength, FrameDescriptor.ComputeMaxMessageLength(LogBufferDescriptor.TERM_MIN_LENGTH));
 }