use of com.codahale.metrics.InstrumentedScheduledExecutorService in project dropwizard by dropwizard.
the class DefaultHealthFactory method createScheduledExecutorForHealthChecks.
private ScheduledExecutorService createScheduledExecutorForHealthChecks(final int numberOfScheduledHealthChecks, final MetricRegistry metrics, final LifecycleEnvironment lifecycle, final String fullName) {
final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(fullName + "-%d").setDaemon(true).setUncaughtExceptionHandler((t, e) -> LOGGER.error("Thread={} died due to uncaught exception", t, e)).build();
final InstrumentedThreadFactory instrumentedThreadFactory = new InstrumentedThreadFactory(threadFactory, metrics);
final ScheduledExecutorService scheduledExecutorService = lifecycle.scheduledExecutorService(fullName + "-scheduled-executor", instrumentedThreadFactory).threads(numberOfScheduledHealthChecks).build();
return new InstrumentedScheduledExecutorService(scheduledExecutorService, metrics);
}
use of com.codahale.metrics.InstrumentedScheduledExecutorService in project atlasdb by palantir.
the class AsyncTimeLockServicesCreator method createRawAsyncTimelockService.
private static AsyncTimelockService createRawAsyncTimelockService(String client, Supplier<ManagedTimestampService> timestampServiceSupplier) {
ScheduledExecutorService reaperExecutor = new InstrumentedScheduledExecutorService(PTExecutors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setNameFormat("async-lock-reaper-" + client + "-%d").setDaemon(true).build()), AtlasDbMetrics.getMetricRegistry(), "async-lock-reaper");
ScheduledExecutorService timeoutExecutor = new InstrumentedScheduledExecutorService(PTExecutors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setNameFormat("async-lock-timeouts-" + client + "-%d").setDaemon(true).build()), AtlasDbMetrics.getMetricRegistry(), "async-lock-timeouts");
return new AsyncTimelockServiceImpl(AsyncLockService.createDefault(reaperExecutor, timeoutExecutor), timestampServiceSupplier.get());
}
Aggregations