| 312 |
|
|
| 313 |
DaemonState::DaemonState() : |
DaemonState::DaemonState() : |
| 314 |
ThreadsManager(PinotSettings::getInstance().m_daemonIndexLocation, 4), |
ThreadsManager(PinotSettings::getInstance().m_daemonIndexLocation, 4), |
|
m_fullScan(false), |
|
| 315 |
m_isReindex(false), |
m_isReindex(false), |
| 316 |
m_reload(false), |
m_reload(false), |
| 317 |
m_flush(false), |
m_flush(false), |
| 459 |
// Monitoring is not necessary, but we still have to pass the handler |
// Monitoring is not necessary, but we still have to pass the handler |
| 460 |
// so that we can act on documents that have been deleted |
// so that we can act on documents that have been deleted |
| 461 |
pCrawlerThread = new CrawlerThread(locationToCrawl, isSource, |
pCrawlerThread = new CrawlerThread(locationToCrawl, isSource, |
| 462 |
m_fullScan, m_isReindex, NULL, m_pDiskHandler); |
m_isReindex, NULL, m_pDiskHandler); |
| 463 |
} |
} |
| 464 |
else |
else |
| 465 |
{ |
{ |
| 466 |
pCrawlerThread = new CrawlerThread(locationToCrawl, isSource, |
pCrawlerThread = new CrawlerThread(locationToCrawl, isSource, |
| 467 |
m_fullScan, m_isReindex, m_pDiskMonitor, m_pDiskHandler); |
m_isReindex, m_pDiskMonitor, m_pDiskHandler); |
| 468 |
} |
} |
| 469 |
pCrawlerThread->getFileFoundSignal().connect(sigc::mem_fun(*this, &DaemonState::on_message_filefound)); |
pCrawlerThread->getFileFoundSignal().connect(sigc::mem_fun(*this, &DaemonState::on_message_filefound)); |
| 470 |
|
|
| 479 |
return false; |
return false; |
| 480 |
} |
} |
| 481 |
|
|
| 482 |
void DaemonState::start(bool forceFullScan, bool isReindex) |
void DaemonState::start(bool isReindex) |
| 483 |
{ |
{ |
| 484 |
// Disable implicit flushing after a change |
// Disable implicit flushing after a change |
| 485 |
WorkerThread::immediateFlush(false); |
WorkerThread::immediateFlush(false); |
| 486 |
|
|
|
// Do full scans ? |
|
|
if (forceFullScan == true) |
|
|
{ |
|
|
m_fullScan = true; |
|
|
} |
|
|
else |
|
|
{ |
|
|
Rand randomStuff; |
|
|
guint32 randomArray[5]; |
|
|
|
|
|
randomStuff.set_seed(randomArray[2]); |
|
|
gint32 randomNum = randomStuff.get_int_range(0, 10); |
|
|
if (randomNum >= 7) |
|
|
{ |
|
|
m_fullScan = true; |
|
|
} |
|
|
#ifdef DEBUG |
|
|
cout << "DaemonState::start: picked " << randomNum << endl; |
|
|
#endif |
|
|
} |
|
| 487 |
m_isReindex = isReindex; |
m_isReindex = isReindex; |
| 488 |
|
|
| 489 |
// Fire up the disk monitor thread |
// Fire up the disk monitor thread |
| 505 |
cout << "DaemonState::start: " << m_crawlQueue.size() << " locations to crawl" << endl; |
cout << "DaemonState::start: " << m_crawlQueue.size() << " locations to crawl" << endl; |
| 506 |
#endif |
#endif |
| 507 |
|
|
| 508 |
if (m_fullScan == true) |
CrawlHistory crawlHistory(PinotSettings::getInstance().getHistoryDatabaseName()); |
|
{ |
|
|
CrawlHistory crawlHistory(PinotSettings::getInstance().getHistoryDatabaseName()); |
|
| 509 |
|
|
| 510 |
// Update all items status so that we can get rid of files from deleted sources |
// Update all items status so that we can get rid of files from deleted sources |
| 511 |
crawlHistory.updateItemsStatus(CrawlHistory::CRAWLING, CrawlHistory::TO_CRAWL, 0, true); |
crawlHistory.updateItemsStatus(CrawlHistory::CRAWLING, CrawlHistory::TO_CRAWL, 0, true); |
| 512 |
crawlHistory.updateItemsStatus(CrawlHistory::CRAWLED, CrawlHistory::TO_CRAWL, 0, true); |
crawlHistory.updateItemsStatus(CrawlHistory::CRAWLED, CrawlHistory::TO_CRAWL, 0, true); |
| 513 |
crawlHistory.updateItemsStatus(CrawlHistory::CRAWL_ERROR, CrawlHistory::TO_CRAWL, 0, true); |
crawlHistory.updateItemsStatus(CrawlHistory::CRAWL_ERROR, CrawlHistory::TO_CRAWL, 0, true); |
|
} |
|
| 514 |
|
|
| 515 |
// Initiate crawling |
// Initiate crawling |
| 516 |
start_crawling(); |
start_crawling(); |
| 543 |
|
|
| 544 |
startedCrawler = crawl_location(nextLocation); |
startedCrawler = crawl_location(nextLocation); |
| 545 |
} |
} |
| 546 |
else if (m_fullScan == true) |
else |
| 547 |
{ |
{ |
| 548 |
CrawlHistory crawlHistory(PinotSettings::getInstance().getHistoryDatabaseName()); |
CrawlHistory crawlHistory(PinotSettings::getInstance().getHistoryDatabaseName()); |
| 549 |
set<string> deletedFiles; |
set<string> deletedFiles; |
| 761 |
m_reload = false; |
m_reload = false; |
| 762 |
|
|
| 763 |
// ...and restart everything |
// ...and restart everything |
| 764 |
start(true, false); |
start(false); |
| 765 |
} |
} |
| 766 |
|
|
| 767 |
// Try to run a queued action unless threads were stopped |
// Try to run a queued action unless threads were stopped |