Call the
CasCrawler.stopCrawl() method to stop a crawl.
The syntax of the method is:
CasCrawler.stopCrawl(CrawlId crawlId)
The
crawlId parameter is a
CrawlId object that contains the name of the crawl
to stop.
To stop a crawl:
Make sure that you have created a connection to the CAS Server. (A
CasCrawlerobject namedcrawleris used in this example.)Set the name for the crawl to stop by first instantiating a
CrawlIdobject and then its Id.For example:
// Create a new crawl Id with the name set to Demo. CrawlId crawlId = new CrawlId("Demo");Call the
CasCrawler.stopCrawl()method with the crawl ID. To catch an exception, use atryblock with the appropriatecatchclause.For example:
try { crawler.stopCrawl(crawlId); } catch (CrawlNotFoundException e) { System.out.println(e.getLocalizedMessage()); }
The
CasCrawler.stopCrawl() method throws a
CrawlNotFoundException if the specified crawl (the
crawlId parameter) does not exist or is
otherwise not found.
When the stop request is issued, the crawl first goes into a
STOPPING state and then (when it finally stops) into
a
NOT_RUNNING state.
Note

