Search in sources :

Example 1 with CountersManager

use of org.agrona.concurrent.status.CountersManager in project Aeron by real-logic.

the class DriverConductorTest method setUp.

@Before
public void setUp() throws Exception {
    // System GC required in order to ensure that the direct byte buffers get cleaned and avoid OOM.
    System.gc();
    when(mockRawLogFactory.newNetworkPublication(anyString(), anyInt(), anyInt(), anyLong(), anyInt())).thenReturn(LogBufferHelper.newTestLogBuffers(TERM_BUFFER_LENGTH));
    when(mockRawLogFactory.newNetworkedImage(anyString(), anyInt(), anyInt(), anyLong(), eq(TERM_BUFFER_LENGTH))).thenReturn(LogBufferHelper.newTestLogBuffers(TERM_BUFFER_LENGTH));
    when(mockRawLogFactory.newIpcPublication(anyInt(), anyInt(), anyLong(), anyInt())).thenReturn(LogBufferHelper.newTestLogBuffers(TERM_BUFFER_LENGTH));
    currentTimeNs = 0;
    final UnsafeBuffer counterBuffer = new UnsafeBuffer(ByteBuffer.allocateDirect(BUFFER_LENGTH));
    final CountersManager countersManager = new CountersManager(new UnsafeBuffer(ByteBuffer.allocateDirect(BUFFER_LENGTH * 2)), counterBuffer);
    final MediaDriver.Context ctx = new MediaDriver.Context().unicastFlowControlSupplier(Configuration.unicastFlowControlSupplier()).multicastFlowControlSupplier(Configuration.multicastFlowControlSupplier()).toConductorFromReceiverCommandQueue(new OneToOneConcurrentArrayQueue<>(1024)).toConductorFromSenderCommandQueue(new OneToOneConcurrentArrayQueue<>(1024)).errorLog(mockErrorLog).rawLogBuffersFactory(mockRawLogFactory).countersManager(countersManager).nanoClock(nanoClock).sendChannelEndpointSupplier(Configuration.sendChannelEndpointSupplier()).receiveChannelEndpointSupplier(Configuration.receiveChannelEndpointSupplier()).congestControlSupplier(Configuration.congestionControlSupplier());
    ctx.toDriverCommands(fromClientCommands);
    ctx.clientProxy(mockClientProxy);
    ctx.countersValuesBuffer(counterBuffer);
    final SystemCounters mockSystemCounters = mock(SystemCounters.class);
    ctx.systemCounters(mockSystemCounters);
    when(mockSystemCounters.get(any())).thenReturn(mockErrorCounter);
    ctx.epochClock(new SystemEpochClock());
    ctx.receiverProxy(receiverProxy);
    ctx.senderProxy(senderProxy);
    ctx.fromReceiverDriverConductorProxy(fromReceiverConductorProxy);
    ctx.fromSenderDriverConductorProxy(fromSenderConductorProxy);
    ctx.clientLivenessTimeoutNs(CLIENT_LIVENESS_TIMEOUT_NS);
    ctx.receiveChannelEndpointThreadLocals(new ReceiveChannelEndpointThreadLocals(ctx));
    driverProxy = new DriverProxy(fromClientCommands);
    driverConductor = new DriverConductor(ctx);
    doAnswer(closeChannelEndpointAnswer).when(receiverProxy).closeReceiveChannelEndpoint(any());
}
Also used : OneToOneConcurrentArrayQueue(org.agrona.concurrent.OneToOneConcurrentArrayQueue) SystemCounters(io.aeron.driver.status.SystemCounters) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) DriverProxy(io.aeron.DriverProxy) CountersManager(org.agrona.concurrent.status.CountersManager) SystemEpochClock(org.agrona.concurrent.SystemEpochClock) ReceiveChannelEndpointThreadLocals(io.aeron.driver.media.ReceiveChannelEndpointThreadLocals) Before(org.junit.Before)

Example 2 with CountersManager

use of org.agrona.concurrent.status.CountersManager in project Aeron by real-logic.

the class IpcPublicationTest method setUp.

@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
    final RingBuffer fromClientCommands = new ManyToOneRingBuffer(new UnsafeBuffer(ByteBuffer.allocateDirect(Configuration.CONDUCTOR_BUFFER_LENGTH)));
    final RawLogFactory mockRawLogFactory = mock(RawLogFactory.class);
    final UnsafeBuffer counterBuffer = new UnsafeBuffer(ByteBuffer.allocateDirect(BUFFER_LENGTH));
    final CountersManager countersManager = new CountersManager(new UnsafeBuffer(ByteBuffer.allocateDirect(BUFFER_LENGTH * 2)), counterBuffer);
    when(mockRawLogFactory.newIpcPublication(anyInt(), anyInt(), anyLong(), anyInt())).thenReturn(LogBufferHelper.newTestLogBuffers(TERM_BUFFER_LENGTH));
    final MediaDriver.Context ctx = new MediaDriver.Context().toDriverCommands(fromClientCommands).rawLogBuffersFactory(mockRawLogFactory).clientProxy(mock(ClientProxy.class)).toConductorFromReceiverCommandQueue(mock(OneToOneConcurrentArrayQueue.class)).toConductorFromSenderCommandQueue(mock(OneToOneConcurrentArrayQueue.class)).epochClock(new SystemEpochClock()).countersManager(countersManager).systemCounters(mock(SystemCounters.class)).nanoClock(nanoClock);
    ctx.countersValuesBuffer(counterBuffer);
    driverProxy = new DriverProxy(fromClientCommands);
    driverConductor = new DriverConductor(ctx);
    driverProxy.addPublication(CommonContext.IPC_CHANNEL, STREAM_ID);
    driverConductor.doWork();
    ipcPublication = driverConductor.getIpcSharedPublication(STREAM_ID);
    publisherLimit = new UnsafeBufferPosition(counterBuffer, ipcPublication.publisherLimitId());
}
Also used : RawLogFactory(io.aeron.driver.buffer.RawLogFactory) ManyToOneRingBuffer(org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer) 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) Before(org.junit.Before)

Aggregations

DriverProxy (io.aeron.DriverProxy)2 CountersManager (org.agrona.concurrent.status.CountersManager)2 Before (org.junit.Before)2 RawLogFactory (io.aeron.driver.buffer.RawLogFactory)1 ReceiveChannelEndpointThreadLocals (io.aeron.driver.media.ReceiveChannelEndpointThreadLocals)1 SystemCounters (io.aeron.driver.status.SystemCounters)1 OneToOneConcurrentArrayQueue (org.agrona.concurrent.OneToOneConcurrentArrayQueue)1 SystemEpochClock (org.agrona.concurrent.SystemEpochClock)1 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)1 ManyToOneRingBuffer (org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer)1 RingBuffer (org.agrona.concurrent.ringbuffer.RingBuffer)1 UnsafeBufferPosition (org.agrona.concurrent.status.UnsafeBufferPosition)1