Search in sources :

Example 1 with NewPublicationCmd

use of io.aeron.driver.cmd.NewPublicationCmd in project Aeron by real-logic.

the class SenderTest method setUp.

@Before
public void setUp() throws Exception {
    final SendChannelEndpoint mockSendChannelEndpoint = mock(SendChannelEndpoint.class);
    when(mockSendChannelEndpoint.udpChannel()).thenReturn(udpChannel);
    when(mockSendChannelEndpoint.send(any())).thenAnswer(saveByteBufferAnswer);
    when(mockSystemCounters.get(any())).thenReturn(mock(AtomicCounter.class));
    sender = new Sender(new MediaDriver.Context().controlTransportPoller(mockTransportPoller).systemCounters(mockSystemCounters).senderCommandQueue(senderCommandQueue).nanoClock(() -> currentTimestamp));
    LogBufferDescriptor.initialiseTailWithTermId(rawLog.metaData(), 0, INITIAL_TERM_ID);
    termAppenders = new TermAppender[PARTITION_COUNT];
    for (int i = 0; i < PARTITION_COUNT; i++) {
        termAppenders[i] = new TermAppender(rawLog.termBuffers()[i], rawLog.metaData(), i);
    }
    publication = new NetworkPublication(1, mockSendChannelEndpoint, () -> currentTimestamp, () -> currentTimestamp / (1_000_000L), rawLog, mock(Position.class), new AtomicLongPosition(), new AtomicLongPosition(), SESSION_ID, STREAM_ID, INITIAL_TERM_ID, MAX_FRAME_LENGTH, mockSystemCounters, flowControl, mockRetransmitHandler, new NetworkPublicationThreadLocals(), Configuration.PUBLICATION_UNBLOCK_TIMEOUT_NS, false);
    senderCommandQueue.offer(new NewPublicationCmd(publication));
}
Also used : SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint) TermAppender(io.aeron.logbuffer.TermAppender) AtomicCounter(org.agrona.concurrent.status.AtomicCounter) AtomicLongPosition(org.agrona.concurrent.status.AtomicLongPosition) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint) NewPublicationCmd(io.aeron.driver.cmd.NewPublicationCmd) Before(org.junit.Before)

Aggregations

NewPublicationCmd (io.aeron.driver.cmd.NewPublicationCmd)1 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)1 TermAppender (io.aeron.logbuffer.TermAppender)1 AtomicCounter (org.agrona.concurrent.status.AtomicCounter)1 AtomicLongPosition (org.agrona.concurrent.status.AtomicLongPosition)1 Before (org.junit.Before)1