Search in sources :

Example 1 with TestLogFactory

use of io.aeron.driver.buffer.TestLogFactory in project aeron by real-logic.

the class ReceiverTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    final SubscriptionLink subscriptionLink = mock(SubscriptionLink.class);
    when(subscriptionLink.isTether()).thenReturn(Boolean.TRUE);
    when(subscriptionLink.isReliable()).thenReturn(Boolean.TRUE);
    POSITIONS.add(new SubscriberPosition(subscriptionLink, null, POSITION));
    when(POSITION.getVolatile()).thenReturn(computePosition(ACTIVE_TERM_ID, 0, POSITION_BITS_TO_SHIFT, ACTIVE_TERM_ID));
    when(mockSystemCounters.get(any())).thenReturn(mock(AtomicCounter.class));
    when(congestionControl.onTrackRebuild(anyLong(), anyLong(), anyLong(), anyLong(), anyLong(), anyLong(), anyBoolean())).thenReturn(CongestionControl.packOutcome(INITIAL_WINDOW_LENGTH, false));
    when(congestionControl.initialWindowLength()).thenReturn(INITIAL_WINDOW_LENGTH);
    final DriverConductorProxy driverConductorProxy = new DriverConductorProxy(ThreadingMode.DEDICATED, toConductorQueue, mock(AtomicCounter.class));
    final MediaDriver.Context ctx = new MediaDriver.Context().driverCommandQueue(toConductorQueue).dataTransportPoller(mockDataTransportPoller).controlTransportPoller(mockControlTransportPoller).logFactory(new TestLogFactory()).systemCounters(mockSystemCounters).receiverCommandQueue(new OneToOneConcurrentArrayQueue<>(Configuration.CMD_QUEUE_CAPACITY)).nanoClock(nanoClock).cachedNanoClock(nanoClock).senderCachedNanoClock(nanoClock).receiverCachedNanoClock(nanoClock).receiveChannelEndpointThreadLocals(new ReceiveChannelEndpointThreadLocals()).driverConductorProxy(driverConductorProxy);
    receiverProxy = new ReceiverProxy(ThreadingMode.DEDICATED, ctx.receiverCommandQueue(), mock(AtomicCounter.class));
    receiver = new Receiver(ctx);
    receiverProxy.receiver(receiver);
    senderChannel = DatagramChannel.open();
    senderChannel.bind(senderAddress);
    senderChannel.configureBlocking(false);
    termBuffers = rawLog.termBuffers();
    final MediaDriver.Context receiverChannelContext = new MediaDriver.Context().receiveChannelEndpointThreadLocals(new ReceiveChannelEndpointThreadLocals()).systemCounters(mockSystemCounters).cachedNanoClock(nanoClock).senderCachedNanoClock(nanoClock).receiverCachedNanoClock(nanoClock);
    receiveChannelEndpoint = new ReceiveChannelEndpoint(UdpChannel.parse(URI), new DataPacketDispatcher(driverConductorProxy, receiver), mock(AtomicCounter.class), receiverChannelContext);
}
Also used : TestLogFactory(io.aeron.driver.buffer.TestLogFactory) AtomicCounter(org.agrona.concurrent.status.AtomicCounter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with TestLogFactory

use of io.aeron.driver.buffer.TestLogFactory in project aeron by real-logic.

the class IpcPublicationTest method setUp.

@SuppressWarnings("unchecked")
@BeforeEach
public void setUp() {
    final RingBuffer toDriverCommands = new ManyToOneRingBuffer(new UnsafeBuffer(ByteBuffer.allocate(Configuration.CONDUCTOR_BUFFER_LENGTH_DEFAULT)));
    final UnsafeBuffer counterBuffer = new UnsafeBuffer(ByteBuffer.allocate(BUFFER_LENGTH));
    final UnsafeBuffer metaDataBuffer = new UnsafeBuffer(ByteBuffer.allocate(Configuration.countersMetadataBufferLength(BUFFER_LENGTH)));
    final CountersManager countersManager = new CountersManager(metaDataBuffer, counterBuffer, StandardCharsets.US_ASCII);
    final SystemCounters systemCounters = new SystemCounters(countersManager);
    final MediaDriver.Context ctx = new MediaDriver.Context().tempBuffer(new UnsafeBuffer(new byte[METADATA_LENGTH])).ipcTermBufferLength(TERM_BUFFER_LENGTH).toDriverCommands(toDriverCommands).logFactory(new TestLogFactory()).clientProxy(mock(ClientProxy.class)).driverCommandQueue(mock(ManyToOneConcurrentArrayQueue.class)).epochClock(SystemEpochClock.INSTANCE).cachedEpochClock(new CachedEpochClock()).cachedNanoClock(new CachedNanoClock()).countersManager(countersManager).systemCounters(systemCounters).nameResolver(DefaultNameResolver.INSTANCE).nanoClock(new CachedNanoClock());
    ctx.countersValuesBuffer(counterBuffer);
    driverProxy = new DriverProxy(toDriverCommands, CLIENT_ID);
    driverConductor = new DriverConductor(ctx);
    driverConductor.onStart();
    driverProxy.addPublication(CommonContext.IPC_CHANNEL, STREAM_ID);
    driverConductor.doWork();
    ipcPublication = driverConductor.getSharedIpcPublication(STREAM_ID);
    publisherLimit = new UnsafeBufferPosition(counterBuffer, ipcPublication.publisherLimitId());
}
Also used : ManyToOneRingBuffer(org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer) TestLogFactory(io.aeron.driver.buffer.TestLogFactory) SystemCounters(io.aeron.driver.status.SystemCounters) RingBuffer(org.agrona.concurrent.ringbuffer.RingBuffer) ManyToOneRingBuffer(org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer) DriverProxy(io.aeron.DriverProxy) UnsafeBufferPosition(org.agrona.concurrent.status.UnsafeBufferPosition) CountersManager(org.agrona.concurrent.status.CountersManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with TestLogFactory

use of io.aeron.driver.buffer.TestLogFactory in project Aeron by real-logic.

the class ReceiverTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    final SubscriptionLink subscriptionLink = mock(SubscriptionLink.class);
    when(subscriptionLink.isTether()).thenReturn(Boolean.TRUE);
    when(subscriptionLink.isReliable()).thenReturn(Boolean.TRUE);
    POSITIONS.add(new SubscriberPosition(subscriptionLink, null, POSITION));
    when(POSITION.getVolatile()).thenReturn(computePosition(ACTIVE_TERM_ID, 0, POSITION_BITS_TO_SHIFT, ACTIVE_TERM_ID));
    when(mockSystemCounters.get(any())).thenReturn(mock(AtomicCounter.class));
    when(congestionControl.onTrackRebuild(anyLong(), anyLong(), anyLong(), anyLong(), anyLong(), anyLong(), anyBoolean())).thenReturn(CongestionControl.packOutcome(INITIAL_WINDOW_LENGTH, false));
    when(congestionControl.initialWindowLength()).thenReturn(INITIAL_WINDOW_LENGTH);
    final DriverConductorProxy driverConductorProxy = new DriverConductorProxy(ThreadingMode.DEDICATED, toConductorQueue, mock(AtomicCounter.class));
    final MediaDriver.Context ctx = new MediaDriver.Context().driverCommandQueue(toConductorQueue).dataTransportPoller(mockDataTransportPoller).controlTransportPoller(mockControlTransportPoller).logFactory(new TestLogFactory()).systemCounters(mockSystemCounters).receiverCommandQueue(new OneToOneConcurrentArrayQueue<>(Configuration.CMD_QUEUE_CAPACITY)).nanoClock(nanoClock).cachedNanoClock(nanoClock).senderCachedNanoClock(nanoClock).receiverCachedNanoClock(nanoClock).receiveChannelEndpointThreadLocals(new ReceiveChannelEndpointThreadLocals()).driverConductorProxy(driverConductorProxy);
    receiverProxy = new ReceiverProxy(ThreadingMode.DEDICATED, ctx.receiverCommandQueue(), mock(AtomicCounter.class));
    receiver = new Receiver(ctx);
    receiverProxy.receiver(receiver);
    senderChannel = DatagramChannel.open();
    senderChannel.bind(senderAddress);
    senderChannel.configureBlocking(false);
    termBuffers = rawLog.termBuffers();
    final MediaDriver.Context receiverChannelContext = new MediaDriver.Context().receiveChannelEndpointThreadLocals(new ReceiveChannelEndpointThreadLocals()).systemCounters(mockSystemCounters).cachedNanoClock(nanoClock).senderCachedNanoClock(nanoClock).receiverCachedNanoClock(nanoClock);
    receiveChannelEndpoint = new ReceiveChannelEndpoint(UdpChannel.parse(URI), new DataPacketDispatcher(driverConductorProxy, receiver), mock(AtomicCounter.class), receiverChannelContext);
}
Also used : TestLogFactory(io.aeron.driver.buffer.TestLogFactory) AtomicCounter(org.agrona.concurrent.status.AtomicCounter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with TestLogFactory

use of io.aeron.driver.buffer.TestLogFactory in project Aeron by real-logic.

the class IpcPublicationTest method setUp.

@SuppressWarnings("unchecked")
@BeforeEach
public void setUp() {
    final RingBuffer toDriverCommands = new ManyToOneRingBuffer(new UnsafeBuffer(ByteBuffer.allocate(Configuration.CONDUCTOR_BUFFER_LENGTH_DEFAULT)));
    final UnsafeBuffer counterBuffer = new UnsafeBuffer(ByteBuffer.allocate(BUFFER_LENGTH));
    final UnsafeBuffer metaDataBuffer = new UnsafeBuffer(ByteBuffer.allocate(Configuration.countersMetadataBufferLength(BUFFER_LENGTH)));
    final CountersManager countersManager = new CountersManager(metaDataBuffer, counterBuffer, StandardCharsets.US_ASCII);
    final SystemCounters systemCounters = new SystemCounters(countersManager);
    final MediaDriver.Context ctx = new MediaDriver.Context().tempBuffer(new UnsafeBuffer(new byte[METADATA_LENGTH])).ipcTermBufferLength(TERM_BUFFER_LENGTH).toDriverCommands(toDriverCommands).logFactory(new TestLogFactory()).clientProxy(mock(ClientProxy.class)).driverCommandQueue(mock(ManyToOneConcurrentArrayQueue.class)).epochClock(SystemEpochClock.INSTANCE).cachedEpochClock(new CachedEpochClock()).cachedNanoClock(new CachedNanoClock()).countersManager(countersManager).systemCounters(systemCounters).nameResolver(DefaultNameResolver.INSTANCE).nanoClock(new CachedNanoClock());
    ctx.countersValuesBuffer(counterBuffer);
    driverProxy = new DriverProxy(toDriverCommands, CLIENT_ID);
    driverConductor = new DriverConductor(ctx);
    driverConductor.onStart();
    driverProxy.addPublication(CommonContext.IPC_CHANNEL, STREAM_ID);
    driverConductor.doWork();
    ipcPublication = driverConductor.getSharedIpcPublication(STREAM_ID);
    publisherLimit = new UnsafeBufferPosition(counterBuffer, ipcPublication.publisherLimitId());
}
Also used : ManyToOneRingBuffer(org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer) TestLogFactory(io.aeron.driver.buffer.TestLogFactory) SystemCounters(io.aeron.driver.status.SystemCounters) RingBuffer(org.agrona.concurrent.ringbuffer.RingBuffer) ManyToOneRingBuffer(org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer) DriverProxy(io.aeron.DriverProxy) UnsafeBufferPosition(org.agrona.concurrent.status.UnsafeBufferPosition) CountersManager(org.agrona.concurrent.status.CountersManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with TestLogFactory

use of io.aeron.driver.buffer.TestLogFactory in project Aeron by real-logic.

the class DriverConductorTest method before.

@BeforeEach
public void before() {
    counterKeyAndLabel.putInt(COUNTER_KEY_OFFSET, 42);
    counterKeyAndLabel.putStringAscii(COUNTER_LABEL_OFFSET, COUNTER_LABEL);
    final UnsafeBuffer counterBuffer = new UnsafeBuffer(ByteBuffer.allocate(BUFFER_LENGTH));
    final UnsafeBuffer metaDataBuffer = new UnsafeBuffer(ByteBuffer.allocate(Configuration.countersMetadataBufferLength(BUFFER_LENGTH)));
    spyCountersManager = spy(new CountersManager(metaDataBuffer, counterBuffer, StandardCharsets.US_ASCII));
    spySystemCounters = spy(new SystemCounters(spyCountersManager));
    when(spySystemCounters.get(SystemCounterDescriptor.ERRORS)).thenReturn(mockErrorCounter);
    when(mockErrorCounter.appendToLabel(any())).thenReturn(mockErrorCounter);
    final MediaDriver.Context ctx = new MediaDriver.Context().tempBuffer(new UnsafeBuffer(new byte[METADATA_LENGTH])).timerIntervalNs(DEFAULT_TIMER_INTERVAL_NS).publicationTermBufferLength(TERM_BUFFER_LENGTH).ipcTermBufferLength(TERM_BUFFER_LENGTH).unicastFlowControlSupplier(Configuration.unicastFlowControlSupplier()).multicastFlowControlSupplier(Configuration.multicastFlowControlSupplier()).driverCommandQueue(new ManyToOneConcurrentArrayQueue<>(Configuration.CMD_QUEUE_CAPACITY)).errorHandler(mockErrorHandler).logFactory(new TestLogFactory()).countersManager(spyCountersManager).epochClock(epochClock).nanoClock(nanoClock).senderCachedNanoClock(nanoClock).receiverCachedNanoClock(nanoClock).cachedEpochClock(new CachedEpochClock()).cachedNanoClock(new CachedNanoClock()).sendChannelEndpointSupplier(Configuration.sendChannelEndpointSupplier()).receiveChannelEndpointSupplier(Configuration.receiveChannelEndpointSupplier()).congestControlSupplier(Configuration.congestionControlSupplier()).toDriverCommands(toDriverCommands).clientProxy(mockClientProxy).countersValuesBuffer(counterBuffer).systemCounters(spySystemCounters).receiverProxy(receiverProxy).senderProxy(senderProxy).driverConductorProxy(driverConductorProxy).receiveChannelEndpointThreadLocals(new ReceiveChannelEndpointThreadLocals()).conductorCycleThresholdNs(600_000_000).nameResolver(DefaultNameResolver.INSTANCE);
    driverProxy = new DriverProxy(toDriverCommands, toDriverCommands.nextCorrelationId());
    driverConductor = new DriverConductor(ctx);
    driverConductor.onStart();
    doAnswer(closeChannelEndpointAnswer).when(receiverProxy).closeReceiveChannelEndpoint(any());
}
Also used : TestLogFactory(io.aeron.driver.buffer.TestLogFactory) SystemCounters(io.aeron.driver.status.SystemCounters) DriverProxy(io.aeron.DriverProxy) ReceiveChannelEndpointThreadLocals(io.aeron.driver.media.ReceiveChannelEndpointThreadLocals) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

TestLogFactory (io.aeron.driver.buffer.TestLogFactory)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 DriverProxy (io.aeron.DriverProxy)4 SystemCounters (io.aeron.driver.status.SystemCounters)4 ReceiveChannelEndpointThreadLocals (io.aeron.driver.media.ReceiveChannelEndpointThreadLocals)2 ManyToOneRingBuffer (org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer)2 RingBuffer (org.agrona.concurrent.ringbuffer.RingBuffer)2 AtomicCounter (org.agrona.concurrent.status.AtomicCounter)2 CountersManager (org.agrona.concurrent.status.CountersManager)2 UnsafeBufferPosition (org.agrona.concurrent.status.UnsafeBufferPosition)2