mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
requeue feed immediatly if an entry fails to update
This commit is contained in:
@@ -69,7 +69,7 @@ public class FeedRefreshUpdater {
|
|||||||
locks = Striped.lazyWeakLock(threads);
|
locks = Striped.lazyWeakLock(threads);
|
||||||
pool = new ThreadPoolExecutor(threads, threads, 0,
|
pool = new ThreadPoolExecutor(threads, threads, 0,
|
||||||
TimeUnit.MILLISECONDS,
|
TimeUnit.MILLISECONDS,
|
||||||
queue = new ArrayBlockingQueue<Runnable>(100 * threads));
|
queue = new ArrayBlockingQueue<Runnable>(500 * threads));
|
||||||
pool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
|
pool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
|
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
|
||||||
@@ -111,36 +111,44 @@ public class FeedRefreshUpdater {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
boolean ok = true;
|
||||||
if (entries != null) {
|
if (entries != null) {
|
||||||
List<FeedSubscription> subscriptions = feedSubscriptionDAO
|
List<FeedSubscription> subscriptions = feedSubscriptionDAO
|
||||||
.findByFeed(feed);
|
.findByFeed(feed);
|
||||||
for (FeedEntry entry : entries) {
|
for (FeedEntry entry : entries) {
|
||||||
updateEntry(feed, entry, subscriptions);
|
ok &= updateEntry(feed, entry, subscriptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (applicationSettingsService.get().isPubsubhubbub()) {
|
if (applicationSettingsService.get().isPubsubhubbub()) {
|
||||||
handlePubSub(feed);
|
handlePubSub(feed);
|
||||||
}
|
}
|
||||||
|
if (!ok) {
|
||||||
|
feed.setDisabledUntil(null);
|
||||||
|
}
|
||||||
metricsBean.feedUpdated();
|
metricsBean.feedUpdated();
|
||||||
taskGiver.giveBack(feed);
|
taskGiver.giveBack(feed);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateEntry(final Feed feed, final FeedEntry entry,
|
private boolean updateEntry(final Feed feed, final FeedEntry entry,
|
||||||
final List<FeedSubscription> subscriptions) {
|
final List<FeedSubscription> subscriptions) {
|
||||||
Lock lock = locks.get(entry.getGuid());
|
Lock lock = locks.get(entry.getGuid());
|
||||||
|
boolean locked = false;
|
||||||
try {
|
try {
|
||||||
lock.tryLock(1, TimeUnit.MINUTES);
|
locked = lock.tryLock(1, TimeUnit.MINUTES);
|
||||||
feedUpdateService.updateEntry(feed, entry, subscriptions);
|
feedUpdateService.updateEntry(feed, entry, subscriptions);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
log.error("interrupted while waiting for lock for " + feed.getUrl()
|
log.error("interrupted while waiting for lock for " + feed.getUrl()
|
||||||
+ " : " + e.getMessage(), e);
|
+ " : " + e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
|
if (locked) {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return locked;
|
||||||
|
}
|
||||||
|
|
||||||
private void handlePubSub(final Feed feed) {
|
private void handlePubSub(final Feed feed) {
|
||||||
FeedPushInfo info = feed.getPushInfo();
|
FeedPushInfo info = feed.getPushInfo();
|
||||||
|
|||||||
Reference in New Issue
Block a user