runOnAllAttemptsFailed

void runOnAllAttemptsFailed ( )

Description

This will be called if all the retry attempts for the scrapeable file failed. In other words, if the policy said to retry 25 times, after 25 failures this method will be called. Note that runOnError will be called just before this, as it is called after each time the scrapeable file fails to load correctly, including the last time it fails to load.

This should only contain code that handles the final error. Any proxy rotating, cookie clearing, etc... should generally be done in the runOnError method, especially since it will still be called after the final error.

Parameters

This method takes no parameters

Return Value

This method returns void

Change Log

Version Description
6.0.37a Available in all editions.

Examples

Create a custom RetryPolicy

 import com.screenscraper.util.retry.RetryPolicy;
 
 _log = log;
 _session = session;
 
 RetryPolicy policy = new RetryPolicy()
 {
   Map errorMap = new HashMap();

   boolean isError() throws Exception
   {
     errorMap.put("Was Error On Request", scrapeableFile.wasErrorOnRequest());
     return scrapeableFile.wasErrorOnRequest();
   }

   void runOnError() throws Exception
   {
     session.executeScript("Rotate Proxy");
   }

   Map getErrorChecksMap() throws Exception
   {
     return errorMap;
   }

   boolean resetSessionVariablesBeforeRescrape()
   {
     return true;
   }

   boolean shouldLogErrors()
   {
     return true;
   }

   int getMaxRetryAttempts()
   {
     return 5;
   }
   
   boolean resetReferrerBeforeRescrape()
   {
      return false;
   }
   
   void runOnAllAttemptsFailed()
   {
      _log.logError("Failed to fix errors with the retry policy, stopping scrape");
      _session.stopScraping();
   }
 };

 scrapeableFile.setRetryPolicy(policy);