queue size in metrics

This commit is contained in:
Athou
2013-05-27 11:20:19 +02:00
parent db32c05689
commit 1ce2d854cb
3 changed files with 14 additions and 3 deletions

View File

@@ -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();
}
}