use of org.agrona.concurrent.SystemEpochClock 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());
}
Aggregations