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.Returns the name of the node queueing start references in this run.booleanReturns whether all start references of this crawl session were queued, by this run or a previous one.booleanReturns whether start-reference queuing has completed.Loads the current crawl state directly from the distributed cache.voidsetStartRefsAllQueued(boolean allQueued) Marks whether all start references of this crawl session were queued.voidsetStartRefsQueueingComplete(boolean isComplete) Marks whether start-reference queuing has completed.voidsetStartRefsQueueingNode(String nodeName) Records the name of the node queueing start references in this run.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
-
isStartRefsAllQueued
public boolean isStartRefsAllQueued()Returns whether all start references of this crawl session were queued, by this run or a previous one. UnlikeisStartRefsQueueingComplete(), it persists across runs, so a resumed crawl knows whether queueing was left unfinished.- Returns:
trueonce every start reference was queued
-
setStartRefsAllQueued
public void setStartRefsAllQueued(boolean allQueued) Marks whether all start references of this crawl session were queued.- Parameters:
allQueued-trueonce every start reference was queued
-
getStartRefsQueueingNode
Returns the name of the node queueing start references in this run.- Returns:
- node name, or empty if queueing has not started
-
setStartRefsQueueingNode
Records the name of the node queueing start references in this run.- Parameters:
nodeName- node name
-
getSessionAttributes
Returns the session-scoped attribute store backed by the session cache.- Returns:
- session attributes
-