@Override public void start() { handle = scheduler.schedule( Group.CHECKPOINT, job, recurringPeriodMillis, MILLISECONDS ); }
@Override public void execute( Runnable runnable ) { if ( latch.compareAndSet( false, true ) ) { jobScheduler.schedule( group, () -> { try { runnable.run(); } finally { latch.set( false ); } } ); } } }
private void scheduleJobs() { jobScheduler.schedule( Group.STORAGE_MAINTENANCE, allJobs() ); }
void startIndexPopulation( IndexPopulationJob job ) { populationJobs.add( job ); scheduler.schedule( Group.INDEX_POPULATION, new IndexPopulationJobWrapper( job, this ) ); }
@Override public void start() { featureDecayJob = scheduler.schedule( Group.UDC, get( UsageDataKeys.features )::sweep, 1, DAYS ); } }
private void updateCountersAndNotifyListeners() { counter.incrementAndGet(); long lastEventTime = clock.nanos() - startTimeNanos; accumulatedTotalTimeNanos.addAndGet( lastEventTime ); jobScheduler.schedule( Group.METRICS_EVENT, () -> { long millis = TimeUnit.NANOSECONDS.toMillis( lastEventTime ); monitor.lastLogRotationEventDuration( millis ); } ); } }
private void updateCountersAndNotifyListeners() { final long lastEventTime = clock.nanos() - startTimeNanos; // update counters counter.incrementAndGet(); accumulatedTotalTimeNanos.addAndGet( lastEventTime ); // notify async jobScheduler.schedule( Group.METRICS_EVENT, () -> { long millis = TimeUnit.NANOSECONDS.toMillis( lastEventTime ); monitor.lastCheckPointEventDuration( millis ); } ); } }
@Override public JobHandle schedule( Group group, Runnable job ) { counter.getAndIncrement(); return delegate.schedule( group, job ); }
@Override public JobHandle schedule( Group group, Runnable runnable, long initialDelay, TimeUnit timeUnit ) { counter.getAndIncrement(); return delegate.schedule( group, runnable, initialDelay, timeUnit ); }
public void start() { log.debug( "Starting VM pause monitor" ); checkState( job == null, "VM pause monitor is already started" ); job = requireNonNull( jobScheduler.schedule( Group.VM_PAUSE_MONITOR, this::run ) ); }
public void awaitUpdateApplication() { BinaryLatch updateLatch = new BinaryLatch(); scheduler.schedule( Group.INDEX_UPDATING, updateLatch::release ); updateLatch.await(); } }
public void closeUpdater( DatabaseIndex<? extends IndexReader> index, IndexUpdater indexUpdater ) { scheduler.schedule( Group.INDEX_UPDATING, () -> { try { indexUpdater.close(); } catch ( IndexEntryConflictException e ) { markAsFailed( index, e ); } } ); }
flushes.add( scheduler.schedule( Group.PAGE_CACHE, () ->
public void enqueueUpdate( DatabaseIndex<? extends IndexReader> index, IndexUpdater indexUpdater, IndexEntryUpdate<?> update ) { updateQueueLimit.acquireUninterruptibly(); Runnable eventualUpdate = () -> { try { indexUpdater.process( update ); } catch ( IndexEntryConflictException e ) { markAsFailed( index, e ); } finally { updateQueueLimit.release(); } }; try { scheduler.schedule( Group.INDEX_UPDATING, eventualUpdate ); } catch ( Exception e ) { updateQueueLimit.release(); // Avoid leaking permits if job scheduling fails. throw e; } }
jobScheduler.schedule( Group.INDEX_SAMPLING, () ->
@Before public void setUp() { doReturn( jobHandle ).when( jobScheduler ).schedule( any( Group.class ), any( Runnable.class ) ); }
@Override Result doCollect( Map<String,Object> config, long collectionId ) throws InvalidArgumentsException { int collectSeconds = QueryCollectorConfig.of( config ).collectSeconds; jobScheduler.schedule( Group.DATA_COLLECTOR, () -> QueryCollector.this.stop( collectionId ), collectSeconds, TimeUnit.SECONDS ); isCollecting = true; return success( "Collection started." ); }
/** * Note: Must be called while synchronizing on the MuninnPageCache instance. */ private void ensureThreadsInitialised() throws IOException { if ( threadsInitialised ) { return; } threadsInitialised = true; try { scheduler.schedule( Group.PAGE_CACHE, new EvictionTask( this ) ); } catch ( Exception e ) { IOException exception = new IOException( e ); try { close(); } catch ( Exception closeException ) { exception.addSuppressed( closeException ); } throw exception; } }
@Test public void testStartAndStop() { monitor.start(); monitor.stop(); verify( jobScheduler ).schedule( any( Group.class ), any( Runnable.class ) ); verify( jobHandle ).cancel( eq( true ) ); }
@Test public void testRestart() { monitor.start(); monitor.stop(); monitor.start(); verify( jobScheduler, times( 2 ) ).schedule( any( Group.class ), any( Runnable.class ) ); verify( jobHandle ).cancel( eq( true ) ); }