idleStrategy = new BackoffIdleStrategy( IDLE_MAX_SPINS, IDLE_MAX_YIELDS, IDLE_MIN_PARK_NS, IDLE_MAX_PARK_NS); break;
public static void main(final String[] args) throws IOException { if (args.length < 1) { System.err.println("Usage: HistogramLogReader <logFile> [-s]"); System.err.println("Where <logFile> is the path to histogram log file"); System.exit(-1); } final String path = args[0]; final boolean justSample = args.length == 2 && "-s".equals(args[1]); final boolean loop = !justSample; final File file = new File(path); final double scalingFactor = MICROSECONDS.toNanos(1); final BackoffIdleStrategy idleStrategy = new BackoffIdleStrategy(0, 0, MILLISECONDS.toNanos(1), MINUTES.toNanos(1)); try (HistogramLogReader logReader = new HistogramLogReader(file)) { do { final int sampleCount = logReader.read( (recordedAtTime, name, histogram) -> prettyPrint(recordedAtTime, histogram, name, scalingFactor)); idleStrategy.idle(sampleCount); } while (loop); } }
protected void onIdle() { if (!isIdle) { clock.update(); idleTimeStart = clock.getNanoTime(); metrics.recordRunnerBusyTime(idleTimeStart - busyTimeStart); isIdle = true; } backoff.idle(); }
protected void onTaskExecuted() { backoff.reset(); if (isIdle) { busyTimeStart = clock.getNanoTime(); metrics.recordRunnerIdleTime(busyTimeStart - idleTimeStart); isIdle = false; } } }
protected void onIdle() { if (!isIdle) { clock.update(); idleTimeStart = clock.getNanoTime(); metrics.recordRunnerBusyTime(idleTimeStart - busyTimeStart); isIdle = true; } backoff.idle(); }
protected void onTaskExecuted() { backoff.reset(); if (isIdle) { busyTimeStart = clock.getNanoTime(); metrics.recordRunnerIdleTime(busyTimeStart - idleTimeStart); isIdle = false; } } }
private void replayRecording(final long recordingLength, final long recordingId) { try (Subscription subscription = aeronArchive.replay( recordingId, 0L, recordingLength, REPLAY_URI, REPLAY_STREAM_ID)) { while (!subscription.isConnected()) { Thread.yield(); } messageCount = 0; final IdleStrategy idleStrategy = new BackoffIdleStrategy(10, 10, 1000, 1000); while (messageCount < NUMBER_OF_MESSAGES) { final int fragments = subscription.poll(fragmentHandler, FRAGMENT_COUNT_LIMIT); if (0 == fragments) { if (!subscription.isConnected()) { System.out.println("unexpected end of stream at message count: " + messageCount); break; } } idleStrategy.idle(fragments); } } }
Subscription subscription = aeron.addSubscription(channel, streamId)) final IdleStrategy idleStrategy = new BackoffIdleStrategy( 100, 10, TimeUnit.MICROSECONDS.toNanos(1), TimeUnit.MICROSECONDS.toNanos(100));
/** * Conclude configuration by setting up defaults when specifics are not provided. */ public void conclude() { if (null == aeron) { aeron = Aeron.connect(new Aeron.Context().aeronDirectoryName(aeronDirectoryName)); ownsAeronClient = true; } if (null == idleStrategy) { idleStrategy = new BackoffIdleStrategy( IDLE_MAX_SPINS, IDLE_MAX_YIELDS, IDLE_MIN_PARK_NS, IDLE_MAX_PARK_NS); } if (null == lock) { lock = new ReentrantLock(); } final ChannelUri uri = ChannelUri.parse(controlRequestChannel); uri.put(CommonContext.TERM_LENGTH_PARAM_NAME, Integer.toString(controlTermBufferLength)); uri.put(CommonContext.MTU_LENGTH_PARAM_NAME, Integer.toString(controlMtuLength)); uri.put(CommonContext.SPARSE_PARAM_NAME, Boolean.toString(controlTermBufferSparse)); controlRequestChannel = uri.toString(); }
public static void main(final String[] args) throws Exception { loadPropertiesFiles(args); final MediaDriver.Context ctx = new MediaDriver.Context() .threadingMode(ThreadingMode.DEDICATED) .conductorIdleStrategy(new BackoffIdleStrategy(1, 1, 1, 1)) .receiverIdleStrategy(new NoOpIdleStrategy()) .senderIdleStrategy(new NoOpIdleStrategy()); try (MediaDriver ignored = MediaDriver.launch(ctx)) { final Thread pongThread = startPong(ignored.aeronDirectoryName()); pongThread.start(); runPing(ignored.aeronDirectoryName()); RUNNING.set(false); pongThread.join(); System.out.println("Shutdown Driver..."); } }
Subscription subscription2 = aeron.addSubscription(CHANNEL, STREAM_ID_2)) final IdleStrategy idleStrategy = new BackoffIdleStrategy( 100, 10, TimeUnit.MICROSECONDS.toNanos(1), TimeUnit.MICROSECONDS.toNanos(100));
idleStrategy = new BackoffIdleStrategy(1, 10, 1000, 1000);
public static IdleStrategy backoffIdleStrategy() { return new BackoffIdleStrategy(BACKOFF_SPINS, BACKOFF_YIELDS, 1, 1 << 20); }
@Override public void run() { final IdleStrategy idleStrategy = new BackoffIdleStrategy(MAX_SPINS, MAX_YIELDS, MIN_PARK_NS, MAX_PARK_NS); while (!shutdown) { int workCount = 0; workCount += executeTasks(); idleStrategy.idle(workCount); } shutdownLatch.countDown(); }
@Override public void run() { final IdleStrategy idleStrategy = new BackoffIdleStrategy(MAX_SPINS, MAX_YIELDS, MIN_PARK_NS, MAX_PARK_NS); while (!shutdown) { int workCount = 0; workCount += executeTasks(); idleStrategy.idle(workCount); } shutdownLatch.countDown(); }
@Override public void run() { final IdleStrategy idleStrategy = new BackoffIdleStrategy(MAX_SPINS, MAX_YIELDS, MIN_PARK_NS, MAX_PARK_NS); while (!shutdown) { int workCount = 0; workCount += executeTasks(); workCount += readMessges(); idleStrategy.idle(workCount); } shutdownLatch.countDown(); }
idleStrategy = new BackoffIdleStrategy( IDLE_MAX_SPINS, IDLE_MAX_YIELDS, IDLE_MIN_PARK_NS, IDLE_MAX_PARK_NS); break;