Getting the status of a crawl

Call the IasCrawler.getStatus() method to retrieve the status of a crawl.

The syntax of the method is:
IasCrawler.getStatus(CrawlId crawlId)

The crawlId parameter is a CrawlId object that contains the name of the crawl for which status is to be returned.

The method returns a Status object, which will have the status of the crawl as a CrawlerState simple data type:
  • NOT_RUNNING
  • STOPPING
  • RUNNING

To get the status of a crawl:

  1. Make sure that you have created a connection to the IAS Server. (An IasCrawler object named crawler is used in this example.)
  2. Set the name for the crawl by first instantiating a CrawlId object and then setting its ID in the constructor.
    For example:
    // Create a new crawl ID with the name set to Demo.
    CrawlId crawlId = new CrawlId("Demo");
  3. Declare a CrawlerState variable and initialize it by calling the IasCrawler.getStatus() method with the crawl ID. Note that the status is actually returned by the State.getState() method.
    For example:
    CrawlerState state;
    state = crawler.getStatus(crawlId).getState();
  4. Print the status.
    For example:
    System.out.println("Crawl status: " + state);

The IasCrawler.getStatus() method throws a CrawlNotFoundException if the specified crawl (the crawlId parameter) does not exist or is otherwise not found. To catch an exception, use a try block with the appropriate catch clause.