mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
queue size in metrics
This commit is contained in:
@@ -3,6 +3,7 @@ package com.commafeed.backend.feeds;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -57,6 +58,7 @@ public class FeedRefreshUpdater {
|
||||
FeedSubscriptionDAO feedSubscriptionDAO;
|
||||
|
||||
private ThreadPoolExecutor pool;
|
||||
private BlockingQueue<Runnable> queue;
|
||||
private Striped<Lock> locks;
|
||||
|
||||
@PostConstruct
|
||||
@@ -66,8 +68,8 @@ public class FeedRefreshUpdater {
|
||||
log.info("Creating database pool with {} threads", threads);
|
||||
locks = Striped.lock(threads);
|
||||
pool = new ThreadPoolExecutor(threads, threads, 0,
|
||||
TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(
|
||||
100 * threads));
|
||||
TimeUnit.MILLISECONDS,
|
||||
queue = new ArrayBlockingQueue<Runnable>(100 * threads));
|
||||
pool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
|
||||
@Override
|
||||
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
|
||||
@@ -149,4 +151,8 @@ public class FeedRefreshUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
public int getQueueSize() {
|
||||
return queue.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user