Example #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);
  }
Example #2
0
 /** Release resources and forcibly close the Publication regardless of reference count. */
 void release() {
   if (!isClosed) {
     isClosed = true;
     clientConductor.releasePublication(this);
     logBuffers.close();
   }
 }
Example #3
0
 @Test
 public void shouldReportThatPublicationHasBeenConnectedYet() {
   when(conductor.isPublicationConnected(anyLong())).thenReturn(true);
   assertTrue(publication.isConnected());
 }
Example #4
0
 @Test
 public void shouldReportThatPublicationHasNotBeenConnectedYet() {
   when(publicationLimit.getVolatile()).thenReturn(0L);
   when(conductor.isPublicationConnected(anyLong())).thenReturn(false);
   assertFalse(publication.isConnected());
 }