_nThreads = nThreads;
}
public void run() {
ExecutorService exec = Executors.newFixedThreadPool(_nThreads);
BlockingExecutor bex = new BlockingExecutor(exec, 2*_nThreads);
// (allow a few sources to get queued up)
if (null != _sSourceType) {
_logger.info("(Starting harvest thread for " + _sSourceType + ")");
}
while (!_sources.isEmpty()) {
LinkedList<SourcePojo> sourceBatch = SourceUtils.getDistributedSourceList(_sources, _sSourceType, false);
while (!sourceBatch.isEmpty()) {
SourcePojo source = sourceBatch.pop();
SourceHarvesterRunnable sourceRunner = new SourceHarvesterRunnable(source);
boolean bSubmittedTask = false;
for (int i = 0; (i < 5) && !bSubmittedTask; ++i) {
try {
bex.submitTask(sourceRunner, true);
bSubmittedTask = true;
}
catch (Exception e) {
try {
_logger.info("(Thread failure for " + _sSourceType + ", can probably recover)");