Esempio n. 1
0
  @Before
  public void setUp() {
    when(publicationLimit.getVolatile()).thenReturn(2L * SEND_BUFFER_CAPACITY);
    when(logBuffers.termBuffers()).thenReturn(termBuffers);
    when(logBuffers.termLength()).thenReturn(TERM_MIN_LENGTH);
    when(logBuffers.metaDataBuffer()).thenReturn(logMetaDataBuffer);
    when(conductor.mainLock()).thenReturn(conductorLock);

    initialTermId(logMetaDataBuffer, TERM_ID_1);
    timeOfLastStatusMessage(logMetaDataBuffer, 0);

    for (int i = 0; i < PARTITION_COUNT; i++) {
      termBuffers[i] = new UnsafeBuffer(allocateDirect(TERM_MIN_LENGTH));
    }

    publication =
        new Publication(
            conductor,
            CHANNEL,
            STREAM_ID_1,
            SESSION_ID_1,
            publicationLimit,
            logBuffers,
            CORRELATION_ID);

    publication.incRef();

    initialiseTailWithTermId(logMetaDataBuffer, PARTITION_INDEX, TERM_ID_1);
  }
Esempio n. 2
0
  @Before
  public void setUp() {
    when(publicationLimit.getVolatile()).thenReturn(2L * SEND_BUFFER_CAPACITY);
    when(logBuffers.atomicBuffers()).thenReturn(buffers);
    when(logBuffers.termLength()).thenReturn(TERM_MIN_LENGTH);

    initialTermId(logMetaDataBuffer, TERM_ID_1);
    activeTermId(logMetaDataBuffer, TERM_ID_1);

    for (int i = 0; i < PARTITION_COUNT; i++) {
      termBuffers[i] = new UnsafeBuffer(ByteBuffer.allocateDirect(TERM_MIN_LENGTH));
      termMetaDataBuffers[i] = new UnsafeBuffer(ByteBuffer.allocateDirect(TERM_META_DATA_LENGTH));

      buffers[i] = termBuffers[i];
      buffers[i + PARTITION_COUNT] = termMetaDataBuffers[i];
    }
    buffers[LOG_META_DATA_SECTION_INDEX] = logMetaDataBuffer;

    publication =
        new Publication(
            conductor,
            CHANNEL,
            STREAM_ID_1,
            SESSION_ID_1,
            publicationLimit,
            logBuffers,
            CORRELATION_ID);

    publication.incRef();
  }