Skip to content

Commit

Permalink
Fixes #25.
Browse files Browse the repository at this point in the history
  • Loading branch information
abmargb committed Oct 22, 2014
1 parent ae667e0 commit 2fa956b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;
import org.apache.mahout.cf.taste.common.Refreshable;
import org.apache.mahout.cf.taste.common.TasteException;
import org.apache.mahout.cf.taste.impl.model.jdbc.PostgreSQLBooleanPrefJDBCDataModel;
Expand All @@ -42,6 +43,8 @@
*/
public class PostgreSQLRecommenderDataModel implements ChannelRecommenderDataModel {

private static Logger LOGGER = Logger.getLogger(PostgreSQLRecommenderDataModel.class);

private static final int REFRESH_DELAY = 30; // Minutes

private ChannelDirectoryDataSource dataSource;
Expand All @@ -68,7 +71,11 @@ private void scheduleRefreshAction() {
scheduledThreadPool.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
dataModel.refresh(new LinkedList<Refreshable>());
try {
dataModel.refresh(new LinkedList<Refreshable>());
} catch (Throwable t) {
LOGGER.warn("Could not reload mahout JDBC model.", t);
}
}
}, REFRESH_DELAY, REFRESH_DELAY, TimeUnit.MINUTES);
}
Expand Down

0 comments on commit 2fa956b

Please sign in to comment.