mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
don't batch refresh more than 100 feeds
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.Calendar;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.ejb.Lock;
|
import javax.ejb.Lock;
|
||||||
import javax.ejb.LockType;
|
import javax.ejb.LockType;
|
||||||
import javax.ejb.Singleton;
|
import javax.ejb.Singleton;
|
||||||
@@ -27,13 +28,21 @@ public class FeedRefreshTaskGiver {
|
|||||||
@Inject
|
@Inject
|
||||||
MetricsBean metricsBean;
|
MetricsBean metricsBean;
|
||||||
|
|
||||||
|
private int backgroundThreads;
|
||||||
private Queue<Feed> queue = Queues.newConcurrentLinkedQueue();
|
private Queue<Feed> queue = Queues.newConcurrentLinkedQueue();
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
backgroundThreads = applicationSettingsService.get()
|
||||||
|
.getBackgroundThreads();
|
||||||
|
}
|
||||||
|
|
||||||
@Lock(LockType.WRITE)
|
@Lock(LockType.WRITE)
|
||||||
public Feed take() {
|
public Feed take() {
|
||||||
Feed feed = queue.poll();
|
Feed feed = queue.poll();
|
||||||
if (feed == null) {
|
if (feed == null) {
|
||||||
List<Feed> feeds = feedDAO.findNextUpdatable(50);
|
int count = Math.min(100, 5 * backgroundThreads);
|
||||||
|
List<Feed> feeds = feedDAO.findNextUpdatable(count);
|
||||||
for (Feed f : feeds) {
|
for (Feed f : feeds) {
|
||||||
queue.add(f);
|
queue.add(f);
|
||||||
f.setLastUpdated(Calendar.getInstance().getTime());
|
f.setLastUpdated(Calendar.getInstance().getTime());
|
||||||
|
|||||||
Reference in New Issue
Block a user