final MediaDriver.Context ctx = new MediaDriver.Context() .tempBuffer(new UnsafeBuffer(new byte[METADATA_LENGTH])) .publicationTermBufferLength(TERM_BUFFER_LENGTH) .ipcTermBufferLength(TERM_BUFFER_LENGTH) .unicastFlowControlSupplier(Configuration.unicastFlowControlSupplier()) .multicastFlowControlSupplier(Configuration.multicastFlowControlSupplier()) .driverCommandQueue(new ManyToOneConcurrentArrayQueue<>(Configuration.CMD_QUEUE_CAPACITY)) .errorHandler(mockErrorHandler) .rawLogBuffersFactory(mockRawLogFactory) .countersManager(spyCountersManager) .epochClock(epochClock) .nanoClock(nanoClock) .cachedEpochClock(new CachedEpochClock()) .cachedNanoClock(new CachedNanoClock()) .sendChannelEndpointSupplier(Configuration.sendChannelEndpointSupplier()) .receiveChannelEndpointSupplier(Configuration.receiveChannelEndpointSupplier()) .congestControlSupplier(Configuration.congestionControlSupplier()); ctx.toDriverCommands(fromClientCommands) .clientProxy(mockClientProxy) .countersValuesBuffer(counterBuffer); ctx.systemCounters(mockSystemCounters) .receiverProxy(receiverProxy) .senderProxy(senderProxy) .driverConductorProxy(driverConductorProxy) .clientLivenessTimeoutNs(CLIENT_LIVENESS_TIMEOUT_NS) .receiveChannelEndpointThreadLocals(new ReceiveChannelEndpointThreadLocals(ctx));
new MediaDriver.Context() .termBufferSparseFile(true) .threadingMode(threadingMode) .sharedIdleStrategy(new YieldingIdleStrategy()) .spiesSimulateConnection(true) .errorHandler(Throwable::printStackTrace) .dirDeleteOnStart(true)); .threadingMode(archiveThreadingMode) .idleStrategySupplier(YieldingIdleStrategy::new) .errorCounter(driver.context().systemCounters().get(SystemCounterDescriptor.ERRORS)) .errorHandler(driver.context().errorHandler()));
@Test(timeout = 10_000L) public void shouldLogMessages() throws Exception final MediaDriver.Context driverCtx = new MediaDriver.Context() .errorHandler(Throwable::printStackTrace); .aeronDirectoryName(driverCtx.aeronDirectoryName()); driverCtx.deleteAeronDirectory();
final MediaDriver.Context mediaDriverCtx = new MediaDriver.Context().threadingMode(ThreadingMode.DEDICATED) .dirsDeleteOnStart(deleteDirectoryOnStart).termBufferSparseFile(false) .ipcTermBufferLength(ipcLength).publicationTermBufferLength(ipcLength) .maxTermBufferLength(ipcLength).conductorIdleStrategy(new BusySpinIdleStrategy()) .receiverIdleStrategy(new BusySpinIdleStrategy()) .senderIdleStrategy(new BusySpinIdleStrategy());
params.isSparse = context.termBufferSparseFile();
ctx.concludeAeronDirectory(); ctx.conclude(); ctx.receiverProxy().receiver(receiver); ctx.senderProxy().sender(sender); ctx.driverConductorProxy().driverConductor(conductor); final AtomicCounter errorCounter = ctx.systemCounters().get(ERRORS); final ErrorHandler errorHandler = ctx.errorHandler(); switch (ctx.threadingMode()) ctx.sharedIdleStrategy(), errorHandler, errorCounter, ctx.sharedNetworkIdleStrategy(), errorHandler, errorCounter, new CompositeAgent(sender, receiver)); conductorRunner = new AgentRunner(ctx.conductorIdleStrategy(), errorHandler, errorCounter, conductor); sharedRunner = null; receiverRunner = null; senderRunner = new AgentRunner(ctx.senderIdleStrategy(), errorHandler, errorCounter, sender); receiverRunner = new AgentRunner(ctx.receiverIdleStrategy(), errorHandler, errorCounter, receiver); conductorRunner = new AgentRunner(ctx.conductorIdleStrategy(), errorHandler, errorCounter, conductor); sharedNetworkRunner = null; sharedRunner = null;
ctx.concludeAeronDirectory(); ctx.conclude(); ctx.receiverProxy().receiver(receiver); ctx.senderProxy().sender(sender); ctx.driverConductorProxy().driverConductor(conductor); final AtomicCounter errorCounter = ctx.systemCounters().get(ERRORS); final ErrorHandler errorHandler = ctx.errorHandler(); switch (ctx.threadingMode()) ctx.sharedIdleStrategy(), errorHandler, errorCounter, ctx.sharedNetworkIdleStrategy(), errorHandler, errorCounter, new CompositeAgent(sender, receiver)); conductorRunner = new AgentRunner(ctx.conductorIdleStrategy(), errorHandler, errorCounter, conductor); sharedRunner = null; receiverRunner = null; senderRunner = new AgentRunner(ctx.senderIdleStrategy(), errorHandler, errorCounter, sender); receiverRunner = new AgentRunner(ctx.receiverIdleStrategy(), errorHandler, errorCounter, receiver); conductorRunner = new AgentRunner(ctx.conductorIdleStrategy(), errorHandler, errorCounter, conductor); sharedNetworkRunner = null; sharedRunner = null;
params.isSparse = context.termBufferSparseFile();
@Setup public synchronized void setup() { for (int i = 0; i < MAX_THREAD_COUNT; i++) { responseQueues[i] = new OneToOneConcurrentArrayQueue<>(RESPONSE_QUEUE_CAPACITY); } values = new int[burstLength]; for (int i = 0; i < burstLength; i++) { values[i] = -(burstLength - i); } ctx = new MediaDriver.Context() .termBufferSparseFile(false) .threadingMode(ThreadingMode.SHARED) .sharedIdleStrategy(new BusySpinIdleStrategy()) .dirDeleteOnStart(true); mediaDriver = MediaDriver.launch(ctx); aeron = Aeron.connect(); publication = aeron.addExclusivePublication(CommonContext.IPC_CHANNEL, STREAM_ID); subscription = aeron.addSubscription(CommonContext.IPC_CHANNEL, STREAM_ID); consumerThread = new Thread(new Subscriber(subscription, running, responseQueues)); consumerThread.setName("consumer"); consumerThread.start(); }
@Setup public synchronized void setup() { for (int i = 0; i < MAX_THREAD_COUNT; i++) { responseQueues[i] = new OneToOneConcurrentArrayQueue<>(RESPONSE_QUEUE_CAPACITY); } values = new int[burstLength]; for (int i = 0; i < burstLength; i++) { values[i] = -(burstLength - i); } ctx = new MediaDriver.Context() .termBufferSparseFile(false) .threadingMode(ThreadingMode.SHARED) .sharedIdleStrategy(new BusySpinIdleStrategy()) .dirDeleteOnStart(true); mediaDriver = MediaDriver.launch(ctx); aeron = Aeron.connect(); publication = aeron.addPublication(CommonContext.IPC_CHANNEL, STREAM_ID); subscription = aeron.addSubscription(CommonContext.IPC_CHANNEL, STREAM_ID); consumerThread = new Thread(new Subscriber(subscription, running, responseQueues)); consumerThread.setName("consumer"); consumerThread.start(); }
public static void main(final String[] args) throws Exception { final MessageValidationStrategy validationStrategy = MessageValidationStrategy.targetCompId(ACCEPTOR_COMP_ID) .and(MessageValidationStrategy.senderCompId(Collections.singletonList(INITIATOR_COMP_ID))); final AuthenticationStrategy authenticationStrategy = AuthenticationStrategy.of(validationStrategy); // Static configuration lasts the duration of a FIX-Gateway instance final EngineConfiguration configuration = new EngineConfiguration() .bindTo("localhost", 9999) .libraryAeronChannel(IPC_CHANNEL); configuration.authenticationStrategy(authenticationStrategy); cleanupOldLogFileDir(configuration); final MediaDriver.Context context = new MediaDriver.Context() .threadingMode(SHARED) .sharedIdleStrategy(backoffIdleStrategy()) .dirDeleteOnStart(true); final Archive.Context archiveContext = new Archive.Context() .threadingMode(ArchiveThreadingMode.SHARED) .idleStrategySupplier(CommonConfiguration::backoffIdleStrategy) .deleteArchiveOnStart(true); try (ArchivingMediaDriver driver = ArchivingMediaDriver.launch(context, archiveContext); FixEngine gateway = FixEngine.launch(configuration)) { SampleUtil.runAgentUntilSignal(new ExchangeAgent(), driver.mediaDriver()); } System.exit(0); }
public static void main(final String[] args) throws InterruptedException { System.setProperty(CONTROL_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:9010"); System.setProperty(CONTROL_RESPONSE_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:9020"); final MediaDriver.Context context = new MediaDriver.Context() .threadingMode(SHARED) .dirDeleteOnStart(true) .aeronDirectoryName(AERON_DIRECTORY_NAME); final Archive.Context archiveContext = new Archive.Context() .threadingMode(ArchiveThreadingMode.SHARED) .deleteArchiveOnStart(true) .aeronDirectoryName(AERON_DIRECTORY_NAME) .recordingEventsChannel(RECORDING_EVENTS_CHANNEL); try (ArchivingMediaDriver driver = ArchivingMediaDriver.launch(context, archiveContext)) { SampleUtil.runAgentUntilSignal( new BuyerAgent(), driver.mediaDriver()); } } }
@SuppressWarnings("checkstyle:UncommentedMain") public static void main(final String... args) { MediaDriver.loadPropertiesFiles(args); setProperty(DISABLE_BOUNDS_CHECKS_PROP_NAME, "true"); setProperty("aeron.mtu.length", "16384"); setProperty("aeron.socket.so_sndbuf", "2097152"); setProperty("aeron.socket.so_rcvbuf", "2097152"); setProperty("aeron.rcv.initial.window.length", "2097152"); final MediaDriver.Context ctx = new MediaDriver.Context().threadingMode(ThreadingMode.DEDICATED).dirsDeleteOnStart(true) .termBufferSparseFile(false).conductorIdleStrategy(new BusySpinIdleStrategy()) .receiverIdleStrategy(new BusySpinIdleStrategy()) .senderIdleStrategy(new BusySpinIdleStrategy()); try (MediaDriver ignored = MediaDriver.launch(ctx)) { new SigIntBarrier().await(); } }
public static void main(final String[] args) { final MediaDriver.Context context = new MediaDriver.Context() .threadingMode(SHARED) .dirDeleteOnStart(true); final Archive.Context archiveContext = new Archive.Context() .threadingMode(ArchiveThreadingMode.SHARED) .deleteArchiveOnStart(true); try (ArchivingMediaDriver ignore = ArchivingMediaDriver.launch(context, archiveContext)) { StressUtil.awaitKeyPress(); } } }
private PublicationParams(final MediaDriver.Context context, final boolean isIpc) { termLength = isIpc ? context.ipcTermBufferLength() : context.publicationTermBufferLength(); mtuLength = isIpc ? context.ipcMtuLength() : context.mtuLength(); lingerTimeoutNs = context.publicationLingerTimeoutNs(); isSparse = context.termBufferSparseFile(); }
public static ArchivingMediaDriver launchMediaDriver(final MediaDriver.Context context) { final Archive.Context archiveCtx = new Archive.Context().deleteArchiveOnStart(context.dirDeleteOnStart()); final ArchivingMediaDriver mediaDriver = ArchivingMediaDriver.launch(context, archiveCtx); archiveCtx.threadingMode(ArchiveThreadingMode.INVOKER); final String aeronDirectoryName = context.aeronDirectoryName(); CloseChecker.onOpen(aeronDirectoryName, mediaDriver); return mediaDriver; }
/** * Used to access the configured aeronDirectoryName for this MediaDriver, typically used after the * {@link #launchEmbedded()} method is used. * * @return the context aeronDirectoryName */ public String aeronDirectoryName() { return ctx.aeronDirectoryName(); }
public static MediaDriver.Context mediaDriverContext(final int termBufferLength, final boolean dirsDeleteOnStart) { return new MediaDriver.Context() .useWindowsHighResTimer(true) .threadingMode(SHARED) .sharedIdleStrategy(new YieldingIdleStrategy()) .dirDeleteOnStart(dirsDeleteOnStart) .warnIfDirectoryExists(false) .publicationTermBufferLength(termBufferLength) .ipcTermBufferLength(termBufferLength); }
private PublicationParams(final MediaDriver.Context context, final boolean isIpc) { termLength = isIpc ? context.ipcTermBufferLength() : context.publicationTermBufferLength(); mtuLength = isIpc ? context.ipcMtuLength() : context.mtuLength(); lingerTimeoutNs = context.publicationLingerTimeoutNs(); isSparse = context.termBufferSparseFile(); }
ctx.concludeAeronDirectory(); ctx.conclude(); ctx.receiverProxy().receiver(receiver); ctx.senderProxy().sender(sender); ctx.driverConductorProxy().driverConductor(conductor); final AtomicCounter errorCounter = ctx.systemCounters().get(ERRORS); final ErrorHandler errorHandler = ctx.errorHandler(); switch (ctx.threadingMode()) ctx.sharedIdleStrategy(), errorHandler, errorCounter, ctx.sharedNetworkIdleStrategy(), errorHandler, errorCounter, new CompositeAgent(sender, receiver)); conductorRunner = new AgentRunner(ctx.conductorIdleStrategy(), errorHandler, errorCounter, conductor); sharedRunner = null; receiverRunner = null; senderRunner = new AgentRunner(ctx.senderIdleStrategy(), errorHandler, errorCounter, sender); receiverRunner = new AgentRunner(ctx.receiverIdleStrategy(), errorHandler, errorCounter, receiver); conductorRunner = new AgentRunner(ctx.conductorIdleStrategy(), errorHandler, errorCounter, conductor); sharedNetworkRunner = null; sharedRunner = null;