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