use of org.sonatype.nexus.thread.NexusThreadFactory in project nexus-public by sonatype.
the class EventExecutor method doStart.
/**
* Move from direct to asynchronous subscriber processing.
*/
@Override
protected void doStart() throws Exception {
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(0, HOST_THREAD_POOL_SIZE, 60L, TimeUnit.SECONDS, // rendezvous only, zero capacity
new SynchronousQueue<>(fairThreading), new NexusThreadFactory("event", "event-manager"), CALLER_RUNS_FAILSAFE);
eventProcessor = NexusExecutorService.forCurrentSubject(threadPool);
if (affinityEnabled) {
Supplier<Executor> coordinator;
if (singleCoordinator) {
// like singleThreadExecutor but with custom rejection handler
ThreadPoolExecutor affinityThread = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, // allow queueing up of requests
new LinkedBlockingQueue<>(), new NexusThreadFactory("affinity", "affinity-manager"), CALLER_RUNS_FAILSAFE);
affinityProcessor = NexusExecutorService.forCurrentSubject(affinityThread);
// use single-thread queue to coordinate all events (delivery to subscribers is still multi-threaded)
coordinator = () -> affinityProcessor;
} else {
// multi-threaded coordination and delivery, with sequential coordination for events with same affinity
// wraps behaviour on top of eventProcessor
coordinator = () -> newSequentialExecutor(eventProcessor);
}
affinityBarriers = CacheBuilder.newBuilder().maximumSize(affinityCacheSize).build(CacheLoader.from(() -> new AffinityBarrier(coordinator.get(), eventProcessor, affinityTimeout)));
}
asyncProcessing = true;
}
use of org.sonatype.nexus.thread.NexusThreadFactory in project nexus-public by sonatype.
the class DatabaseBackupTask method makeExecutorService.
private ExecutorService makeExecutorService() {
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(MAX_QUEUED_BACKUPS);
ThreadFactory factory = new NexusThreadFactory("dbbackup", "dbbackup");
ThreadPoolExecutor backing = new ThreadPoolExecutor(MAX_CONCURRENT_BACKUPS, MAX_CONCURRENT_BACKUPS, 1, TimeUnit.NANOSECONDS, queue, factory);
backing.allowCoreThreadTimeOut(true);
return NexusExecutorService.forFixedSubject(backing, FakeAlmightySubject.TASK_SUBJECT);
}
use of org.sonatype.nexus.thread.NexusThreadFactory in project nexus-public by sonatype.
the class SearchEventHandler method doStart.
@Override
protected void doStart() throws Exception {
if (flushOnCount > 1) {
periodicJobService.startUsing();
flushTask = periodicJobService.schedule(this::pollSearchUpdateRequest, flushOnSeconds);
}
this.threadPoolExecutor = new ThreadPoolExecutor(// core-size
poolSize, // max-size
poolSize, // keep-alive
0L, TimeUnit.MILLISECONDS, // allow queueing up of requests
new LinkedBlockingQueue<>(), new NexusThreadFactory("searchEventHandler", "flushAndPurge", MIN_PRIORITY), new AbortPolicy());
}
use of org.sonatype.nexus.thread.NexusThreadFactory in project nexus-public by sonatype.
the class StreamCopier method makeExecutorService.
private static ExecutorService makeExecutorService() {
final String name = StreamCopier.class.getSimpleName().toLowerCase();
final int nThreads = getInteger(join(".", "nexus", name, "poolSize"), DEFAULT_POOL_SIZE);
ThreadFactory factory = new NexusThreadFactory(name, name);
ThreadPoolExecutor backing = new ThreadPoolExecutor(0, nThreads, 60L, SECONDS, new SynchronousQueue<>(), factory);
return forFixedSubject(backing, TASK_SUBJECT);
}
Aggregations