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);
}
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());
}
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);
}
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());
}
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());
}
Aggregations