List of usage examples for io.netty.util HashedWheelTimer HashedWheelTimer
public HashedWheelTimer(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, int ticksPerWheel, boolean leakDetection)
From source file:io.pravega.controller.timeout.TimerWheelTimeoutService.java
License:Open Source License
@VisibleForTesting TimerWheelTimeoutService(final StreamTransactionMetadataTasks streamTransactionMetadataTasks, final TimeoutServiceConfig timeoutServiceConfig, final BlockingQueue<Optional<Throwable>> taskCompletionQueue) { this.streamTransactionMetadataTasks = streamTransactionMetadataTasks; this.hashedWheelTimer = new HashedWheelTimer(THREAD_FACTORY, TICK_DURATION, TIME_UNIT, TICKS_PER_WHEEL, LEAK_DETECTION);/*from w ww . j a va2 s . c om*/ this.map = new ConcurrentHashMap<>(); this.maxLeaseValue = timeoutServiceConfig.getMaxLeaseValue(); this.maxScaleGracePeriod = timeoutServiceConfig.getMaxScaleGracePeriod(); this.taskCompletionQueue = taskCompletionQueue; this.startAsync(); }
From source file:org.apache.bookkeeper.clients.utils.ClientResources.java
License:Apache License
private ClientResources() { this.scheduler = new Resource<OrderedScheduler>() { private static final String name = "client-scheduler"; @Override/*from w w w .ja v a 2 s . c om*/ public OrderedScheduler create() { return OrderedScheduler.newSchedulerBuilder() .numThreads(Runtime.getRuntime().availableProcessors() * 2).name(name).build(); } @Override public void close(OrderedScheduler instance) { instance.shutdown(); } @Override public String toString() { return name; } }; this.timer = new Resource<HashedWheelTimer>() { private static final String name = "client-timer"; @Override public HashedWheelTimer create() { HashedWheelTimer timer = new HashedWheelTimer( new ThreadFactoryBuilder().setNameFormat(name + "-%d").build(), 200, TimeUnit.MILLISECONDS, 512, true); timer.start(); return timer; } @Override public void close(HashedWheelTimer instance) { instance.stop(); } @Override public String toString() { return name; } }; this.executor = new Resource<ExecutorService>() { private static final String name = "stream-client-executor"; @Override public ExecutorService create() { return Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); } @Override public void close(ExecutorService instance) { instance.shutdown(); } @Override public String toString() { return name; } }; }
From source file:org.apache.bookkeeper.stream.storage.StorageResources.java
License:Apache License
private StorageResources(StorageResourcesSpec spec) { this.scheduler = createSchedulerResource("storage-scheduler", spec.numSchedulerThreads()); this.ioWriteScheduler = createSchedulerResource("io-write-scheduler", spec.numIOWriteThreads()); this.ioReadScheduler = createSchedulerResource("io-read-scheduler", spec.numIOReadThreads()); this.checkpointScheduler = createSchedulerResource("io-checkpoint-scheduler", spec.numCheckpointThreads()); this.timer = new Resource<HashedWheelTimer>() { private static final String name = "storage-timer"; @Override//w w w.ja va2s . c o m public HashedWheelTimer create() { HashedWheelTimer timer = new HashedWheelTimer( new ThreadFactoryBuilder().setNameFormat(name + "-%d").build(), 200, TimeUnit.MILLISECONDS, 512, true); timer.start(); return timer; } @Override public void close(HashedWheelTimer instance) { instance.stop(); } @Override public String toString() { return name; } }; }