Beispiel #1
0
        public virtual void SetUp()
        {
            RcvBuffer = new UnsafeBuffer(new byte[ALIGNED_FRAME_LENGTH]);
            DataHeader = new DataHeaderFlyweight();
            MockFragmentHandler = A.Fake<FragmentHandler>();
            MockControlledFragmentHandler = A.Fake<IControlledFragmentHandler>();
            Position = A.Fake<IPosition>(options => options.Wrapping(new AtomicLongPosition()));
            LogBuffers = A.Fake<LogBuffers>();
            ErrorHandler = A.Fake<ErrorHandler>();
            Subscription = A.Fake<Subscription>();

            AtomicBuffers = new UnsafeBuffer[(LogBufferDescriptor.PARTITION_COUNT * 2) + 1];
            TermBuffers = new UnsafeBuffer[LogBufferDescriptor.PARTITION_COUNT];

            DataHeader.Wrap(RcvBuffer);

            for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
            {
                AtomicBuffers[i] = new UnsafeBuffer(new byte[TERM_BUFFER_LENGTH]);
                TermBuffers[i] = AtomicBuffers[i];

                AtomicBuffers[i + LogBufferDescriptor.PARTITION_COUNT] = new UnsafeBuffer(new byte[LogBufferDescriptor.TERM_META_DATA_LENGTH]);
            }

            AtomicBuffers[LogBufferDescriptor.LOG_META_DATA_SECTION_INDEX] = new UnsafeBuffer(new byte[LogBufferDescriptor.LOG_META_DATA_LENGTH]);

            A.CallTo(() => LogBuffers.AtomicBuffers()).Returns(AtomicBuffers);
            A.CallTo(() => LogBuffers.TermLength()).Returns(TERM_BUFFER_LENGTH);
        }
Beispiel #2
0
        public void Setup()
        {
            AtomicReadBuffer = new UnsafeBuffer(new byte[READ_BUFFER_CAPACITY]);
            Conductor = A.Fake<ClientConductor>();
            FragmentHandler = A.Fake<FragmentHandler>();
            ImageOneMock = A.Fake<Image>();
            ImageTwoMock = A.Fake<Image>();
            Header = A.Fake<Header>();

            A.CallTo(() => Header.Flags).Returns(FLAGS);

            Subscription = new Subscription(Conductor, CHANNEL, STREAM_ID_1, SUBSCRIPTION_CORRELATION_ID);
            A.CallTo(() => Conductor.ReleaseSubscription(Subscription));
        }
Beispiel #3
0
        public void SetUp()
        {
            _sendBuffer = new byte[SendBufferCapacity];
            _atomicSendBuffer = new UnsafeBuffer(_sendBuffer);
            _logMetaDataBuffer = new UnsafeBuffer(new byte[LogBufferDescriptor.LOG_META_DATA_LENGTH]);
            _termBuffers = new UnsafeBuffer[LogBufferDescriptor.PARTITION_COUNT];
            _termMetaDataBuffers = new UnsafeBuffer[LogBufferDescriptor.PARTITION_COUNT];
            _buffers = new UnsafeBuffer[LogBufferDescriptor.PARTITION_COUNT*2 + 1];

            _conductor = A.Fake<ClientConductor>();
            _logBuffers = A.Fake<LogBuffers>();
            _publicationLimit = A.Fake<IReadablePosition>();

            A.CallTo(() => _publicationLimit.Volatile).Returns(2*SendBufferCapacity);
            A.CallTo(() => _logBuffers.AtomicBuffers()).Returns(_buffers);
            A.CallTo(() => _logBuffers.TermLength()).Returns(LogBufferDescriptor.TERM_MIN_LENGTH);

            LogBufferDescriptor.InitialTermId(_logMetaDataBuffer, TermID1);
            LogBufferDescriptor.TimeOfLastStatusMessage(_logMetaDataBuffer, 0);

            for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
            {
                _termBuffers[i] = new UnsafeBuffer(new byte[LogBufferDescriptor.TERM_MIN_LENGTH]);
                _termMetaDataBuffers[i] = new UnsafeBuffer(new byte[LogBufferDescriptor.TERM_META_DATA_LENGTH]);

                _buffers[i] = _termBuffers[i];
                _buffers[i + LogBufferDescriptor.PARTITION_COUNT] = _termMetaDataBuffers[i];
            }
            _buffers[LogBufferDescriptor.LOG_META_DATA_SECTION_INDEX] = _logMetaDataBuffer;

            _publication = new Publication(_conductor, Channel, StreamID1, SessionID1, _publicationLimit, _logBuffers, CorrelationID);

            _publication.IncRef();

            LogBufferDescriptor.InitialiseTailWithTermId(_termMetaDataBuffers[0], TermID1);
        }
Beispiel #4
0
 public static void FillMetaData(UnsafeBuffer cncMetaDataBuffer, int toDriverBufferLength, int toClientsBufferLength, int counterMetaDataBufferLength, int counterValuesBufferLength, long clientLivenessTimeout, int errorLogBufferLength)
 {
     cncMetaDataBuffer.PutInt(CncVersionOffset(0), CNC_VERSION);
     cncMetaDataBuffer.PutInt(ToDriverBufferLengthOffset(0), toDriverBufferLength);
     cncMetaDataBuffer.PutInt(ToClientsBufferLengthOffset(0), toClientsBufferLength);
     cncMetaDataBuffer.PutInt(CountersMetaDataBufferLengthOffset(0), counterMetaDataBufferLength);
     cncMetaDataBuffer.PutInt(CountersValuesBufferLengthOffset(0), counterValuesBufferLength);
     cncMetaDataBuffer.PutLong(ClientLivenessTimeoutOffset(0), clientLivenessTimeout);
     cncMetaDataBuffer.PutInt(ErrorLogBufferLengthOffset(0), errorLogBufferLength);
 }
Beispiel #5
0
 private void InitializeInstanceFields()
 {
     aBuff = new UnsafeBuffer(buffer);
 }
Beispiel #6
0
 /// <summary>
 /// Write the term id field for a frame.
 /// </summary>
 /// <param name="buffer">     containing the frame. </param>
 /// <param name="termOffset"> at which a frame begins. </param>
 /// <param name="termId">     value for the frame. </param>
 public static void FrameTermId(UnsafeBuffer buffer, int termOffset, int termId)
 {
     buffer.PutInt(TermIdOffset(termOffset), termId);
 }