Class LoadComponent
-
- All Implemented Interfaces:
-
java.lang.AutoCloseable
public final class LoadComponent implements AutoCloseable
Created by vincent on 17-7-15. Copyright @ 2013-2023 Platon AI. All rights reserved
The load component is the core component of the Pulsar framework, it is responsible for loading pages from the local storage or fetching them from the Internet.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classLoadComponent.LazyFieldLoaderpublic classLoadComponent.Companion
-
Field Summary
Fields Modifier and Type Field Description private final GlobalCacheglobalCacheprivate final ConcurrentExpiringLRUCache<String, WebPage>pageCacheprivate final ConcurrentExpiringLRUCache<String, FeaturedDocument>documentCacheprivate final WebDbwebDbprivate final GlobalCacheFactoryglobalCacheFactoryprivate final BatchFetchComponentfetchComponentprivate final ParseComponentparseComponentprivate final UpdateComponentupdateComponentprivate final ImmutableConfigimmutableConfigprivate final AppStatusTrackerstatusTrackerpublic final static LoadComponent.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description LoadComponent(WebDb webDb, GlobalCacheFactory globalCacheFactory, BatchFetchComponent fetchComponent, ParseComponent parseComponent, UpdateComponent updateComponent, ImmutableConfig immutableConfig, AppStatusTracker statusTracker)
-
Method Summary
Modifier and Type Method Description final GlobalCachegetGlobalCache()final ConcurrentExpiringLRUCache<String, WebPage>getPageCache()final ConcurrentExpiringLRUCache<String, FeaturedDocument>getDocumentCache()final WebDbgetWebDb()final GlobalCacheFactorygetGlobalCacheFactory()final BatchFetchComponentgetFetchComponent()final ParseComponentgetParseComponent()final UpdateComponentgetUpdateComponent()final ImmutableConfiggetImmutableConfig()final AppStatusTrackergetStatusTracker()final CheckStatefetchState(WebPage page, LoadOptions options)Retrieve the fetch state of a page, which determines whether the page should be fetched from the Internet. final WebPageopen(NormURL normURL, WebDriver driver)Connect a page to a web driver. final WebPageload(URL url, LoadOptions options)Load a page specified by url with the given arguments. final WebPageload(NormURL normURL)Load a page specified by normURL. final WebPageloadDeferred(NormURL normURL)Load a page specified by normURL. final WebPageloadWithRetry(NormURL normURL)final WebPageloadWithRetryDeferred(NormURL normURL)final List<WebPage>loadAll(Iterable<NormURL> normUrls)Load all pages specified by normUrls, wait until all pages are loaded or timeout final CompletableFuture<WebPage>loadAsync(NormURL normURL)Load a page specified by normURL final List<CompletableFuture<WebPage>>loadAllAsync(Iterable<NormURL> normUrls)Load all pages specified by normUrls, wait until all pages are loaded or timeout final Unitflush()Unitclose()-
-
Constructor Detail
-
LoadComponent
LoadComponent(WebDb webDb, GlobalCacheFactory globalCacheFactory, BatchFetchComponent fetchComponent, ParseComponent parseComponent, UpdateComponent updateComponent, ImmutableConfig immutableConfig, AppStatusTracker statusTracker)
-
-
Method Detail
-
getGlobalCache
final GlobalCache getGlobalCache()
-
getPageCache
final ConcurrentExpiringLRUCache<String, WebPage> getPageCache()
-
getDocumentCache
final ConcurrentExpiringLRUCache<String, FeaturedDocument> getDocumentCache()
-
getWebDb
final WebDb getWebDb()
-
getGlobalCacheFactory
final GlobalCacheFactory getGlobalCacheFactory()
-
getFetchComponent
final BatchFetchComponent getFetchComponent()
-
getParseComponent
final ParseComponent getParseComponent()
-
getUpdateComponent
final UpdateComponent getUpdateComponent()
-
getImmutableConfig
final ImmutableConfig getImmutableConfig()
-
getStatusTracker
final AppStatusTracker getStatusTracker()
-
fetchState
final CheckState fetchState(WebPage page, LoadOptions options)
Retrieve the fetch state of a page, which determines whether the page should be fetched from the Internet.
- Parameters:
page- The page to be fetchedoptions- The load options- Returns:
The fetch state
-
load
final WebPage load(URL url, LoadOptions options)
Load a page specified by url with the given arguments.
This method initially verifies the presence of the page in the local store. If the page exists and meets the specified requirements, it returns the local version. Otherwise, it fetches the page from the Internet.
Other fetch conditions can be specified by load arguments:
expiration
page size requirement
fields requirement
other
- Parameters:
url- The url of the pageoptions- The load options- Returns:
The page
-
load
final WebPage load(NormURL normURL)
Load a page specified by normURL.
This method initially verifies the presence of the page in the local store. If the page exists and meets the specified requirements, it returns the local version. Otherwise, it fetches the page from the Internet.
Other fetch conditions can be specified by load arguments:
expiration
page size requirement
fields requirement
other
- Parameters:
normURL- The normalized url of the page- Returns:
The page
-
loadDeferred
final WebPage loadDeferred(NormURL normURL)
Load a page specified by normURL.
This method initially verifies the presence of the page in the local store. If the page exists and meets the specified requirements, it returns the local version. Otherwise, it fetches the page from the Internet.
This method is a coroutine version of load.
Other fetch conditions can be specified by load arguments:
expiration
page size requirement
fields requirement
other
- Parameters:
normURL- The normalized url of the page- Returns:
The page
-
loadWithRetry
final WebPage loadWithRetry(NormURL normURL)
-
loadWithRetryDeferred
final WebPage loadWithRetryDeferred(NormURL normURL)
-
loadAll
final List<WebPage> loadAll(Iterable<NormURL> normUrls)
Load all pages specified by normUrls, wait until all pages are loaded or timeout
-
loadAsync
final CompletableFuture<WebPage> loadAsync(NormURL normURL)
Load a page specified by normURL
- Parameters:
normURL- The normalized url- Returns:
A completable future of webpage
-
loadAllAsync
final List<CompletableFuture<WebPage>> loadAllAsync(Iterable<NormURL> normUrls)
Load all pages specified by normUrls, wait until all pages are loaded or timeout
-
-
-
-