Class CrawlerStateStore
java.lang.Object
com.norconex.crawler.core.session.CrawlerStateStore
Manages persistent crawl-state and session-scoped attributes stored in the
distributed session cache. Can be injected directly in tests without the
full
CrawlerSession.-
Constructor Summary
ConstructorsConstructorDescriptionCrawlerStateStore(CacheMap<String> sessionCache, CrawlerAttributes sessionAttributes, CrawlerAttributes runAttributes) Creates a newCrawlerStateStoreinstance. -
Method Summary
Modifier and TypeMethodDescriptionReturns the current crawl state, reading fresh from the distributed cache each call.Returns the session-scoped attribute store backed by the session cache.booleanReturns whether start-reference queuing has completed.Loads the current crawl state directly from the distributed cache.voidsetStartRefsQueueingComplete(boolean isComplete) Marks whether start-reference queuing has completed.voidupdateCrawlState(CrawlerState state) Updates the crawl state in the distributed cache with a new timestamp.
-
Constructor Details
-
CrawlerStateStore
public CrawlerStateStore(CacheMap<String> sessionCache, CrawlerAttributes sessionAttributes, CrawlerAttributes runAttributes) Creates a newCrawlerStateStoreinstance.- Parameters:
sessionCache-sessionAttributes-runAttributes- Ephemeral (non-MapStore-backed) attributes for per-run flags that must survive partition migration after a node crash. Backed by theeph-crawlRuncache so that in-memory backup promotion is used directly without triggering a LAZY MapStore reload.
-
-
Method Details
-
loadState
Loads the current crawl state directly from the distributed cache.- Returns:
- the current state, or
nullif none has been saved yet
-
updateCrawlState
Updates the crawl state in the distributed cache with a new timestamp.- Parameters:
state- the new crawl state
-
getCrawlState
Returns the current crawl state, reading fresh from the distributed cache each call.- Returns:
- the current crawl state, or
null
-
isStartRefsQueueingComplete
public boolean isStartRefsQueueingComplete()Returns whether start-reference queuing has completed.- Returns:
truewhen all start references have been queued
-
setStartRefsQueueingComplete
public void setStartRefsQueueingComplete(boolean isComplete) Marks whether start-reference queuing has completed.- Parameters:
isComplete-trueonce all start references are queued
-
getSessionAttributes
Returns the session-scoped attribute store backed by the session cache.- Returns:
- session attributes
-