protected HostStatSampler(CancelCriterion stopper, StatSamplerStats samplerStats, NanoTimer timer, LogFile logFile) { this.stopper = stopper; this.statSamplerInitializedLatch = new StoppableCountDownLatch(this.stopper, 1); this.samplerStats = samplerStats; this.fileSizeLimitInKB = Boolean.getBoolean(TEST_FILE_SIZE_LIMIT_IN_KB_PROPERTY); this.callbackSampler = new CallbackSampler(stopper, samplerStats); this.timer = timer; this.logFile = logFile; }
public void start(StatisticsManager statisticsManager, int sampleInterval, TimeUnit timeUnit) { ScheduledExecutorService executor = LoggingExecutors.newSingleThreadScheduledExecutor("CallbackSampler"); start(executor, statisticsManager, sampleInterval, timeUnit); }
void start(ScheduledExecutorService executor, StatisticsManager statisticsManager, int sampleInterval, TimeUnit timeUnit) { stop(); this.statisticsManager = statisticsManager; this.executor = executor; executor.scheduleAtFixedRate(() -> sampleCallbacks(), sampleInterval, sampleInterval, timeUnit); }
private void stop(boolean interruptIfAlive) { synchronized (HostStatSampler.class) { this.callbackSampler.stop(); if (statThread == null) { return;
private Runnable invokeStartAndGetTask() { sampler.start(executorService, statisticsManager, 1, TimeUnit.MILLISECONDS); ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class); verify(executorService).scheduleAtFixedRate(runnableCaptor.capture(), eq(1L), eq(1L), eq(TimeUnit.MILLISECONDS)); return runnableCaptor.getValue(); }
@Before public void createSampler() { sampler = new CallbackSampler(cancelCriterion, statSamplerStats); }
this.callbackSampler.start(getStatisticsManager(), getSampleRate(), TimeUnit.MILLISECONDS); statThread = new LoggingThread("StatSampler", this); statThread.setPriority(Thread.MAX_PRIORITY);