Class CrawlerSession
java.lang.Object
com.norconex.crawler.core.session.CrawlerSession
- All Implemented Interfaces:
Closeable,AutoCloseable
A crawl session, representing a crawl from begin to finish, which may
include zero to multiple "resumes" from stops, or failures. There is
one crawl session per cluster, each node having their own instance
of this class, exposing the same information.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidShortcut method for firing an event equivalent to:session.getCrawlContext().getEventManager().fire(event).voidShortcut method for firing aCrawlerEventwith the supplied source and with thecrawlSessionfield already set.intThe crawler unique identifier, for a specific crawler setup and does not change across sessions.A crawl run unique identifier, which is renewed every time the crawler is launched, regardless whether we are resuming an existing session or creating a new one.A crawl session unique identifier, which represents a begin-to-end crawl, regardless how many times it may have been resumed due to stops or failures.Fires events through the underlying event manager.Coordinates task deduplication across session and run scopes.Manages persistent crawl state and session-scoped attributes.booleanisClosed()booleanbooleanbooleanvoidoncePerRun(String taskId, Runnable runnable) <T> ToncePerRunAndGet(String taskId, Supplier<T> supplier) voidoncePerSession(String taskId, Runnable runnable) <T> ToncePerSessionAndGet(String taskId, Supplier<T> supplier) voidsetPostCloseCleanup(Runnable cleanup) Registers a cleanup action to run AFTER the session has closed all its resources.voidsetStartRefsQueueingComplete(boolean isComplete) toString()voidupdateCrawlState(CrawlerState state)
-
Method Details
-
getCrawlerId
The crawler unique identifier, for a specific crawler setup and does not change across sessions. Same as configured in the crawler configuration.- Returns:
- crawler id
-
oncePerSession
-
oncePerSessionAndGet
-
oncePerRun
-
oncePerRunAndGet
-
getCrawlSessionId
A crawl session unique identifier, which represents a begin-to-end crawl, regardless how many times it may have been resumed due to stops or failures. Resuming crawls will keep the same session id.- Returns:
- crawl session id
-
getCrawlRunId
A crawl run unique identifier, which is renewed every time the crawler is launched, regardless whether we are resuming an existing session or creating a new one.- Returns:
- crawl run id
-
isIncremental
public boolean isIncremental() -
isResumed
public boolean isResumed() -
getCrawlState
-
isClosed
public boolean isClosed() -
getSessionAttributes
-
getCrawlRunAttributes
-
getCrawlerAttributes
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
setPostCloseCleanup
Registers a cleanup action to run AFTER the session has closed all its resources. This is useful for components like loggers that need to capture all session cleanup events before shutting down.- Parameters:
cleanup- the cleanup action to run after session close
-
getAdminPort
public int getAdminPort() -
isStartRefsQueueingComplete
public boolean isStartRefsQueueingComplete() -
setStartRefsQueueingComplete
public void setStartRefsQueueingComplete(boolean isComplete) -
updateCrawlState
-
fire
Shortcut method for firing an event equivalent to:session.getCrawlContext().getEventManager().fire(event).- Parameters:
event- the event to fire
-
fire
Shortcut method for firing aCrawlerEventwith the supplied source and with thecrawlSessionfield already set. Equivalent to:session.getCrawlContext().getEventManager().fire(crawlerEvent).- Parameters:
eventName- name of the event to firesource- the event source
-
loadState
-
toString
-
getCluster
-
getCrawlContext
-
getRunCoordinator
Coordinates task deduplication across session and run scopes. -
getStateStore
Manages persistent crawl state and session-scoped attributes. -
getEventBus
Fires events through the underlying event manager.
-