Class BasicBrowserManager
-
- All Implemented Interfaces:
-
ai.platon.pulsar.skeleton.crawl.fetch.driver.BrowserManager,java.lang.AutoCloseable
public class BasicBrowserManager implements BrowserManager
-
-
Field Summary
Fields Modifier and Type Field Description private final Map<BrowserId, Browser>browsersprivate final BrowserFactorybrowserFactoryprivate final ImmutableConfigconf
-
Constructor Summary
Constructors Constructor Description BasicBrowserManager(BrowserFactory browserFactory, ImmutableConfig conf)
-
Method Summary
Modifier and Type Method Description Map<BrowserId, Browser>getBrowsers()The active browsers final BrowserFactorygetBrowserFactory()final ImmutableConfiggetConf()final BooleanisActive(BrowserId browserId)Check if the browser is active. BrowserfindBrowserOrNull(BrowserId browserId)Find an existing browser by id. UnitcloseBrowser(BrowserId browserId)Close a browser. UnitcloseBrowser(Browser browser)final UnitdestroyBrowserForcibly(BrowserId browserId)UnitcloseDriver(WebDriver driver)final WebDriverfindLeastValuableDriver()final UnitcloseLeastValuableDriver()final UnitdestroyZombieBrowsersForcibly()Destroy the zombie browsers forcibly, kill the associated browser processes, release all allocated resources, regardless of whether the browser is closed or not. final Unitmaintain()Unitclose()-
-
Method Detail
-
getBrowsers
Map<BrowserId, Browser> getBrowsers()
The active browsers
-
getBrowserFactory
final BrowserFactory getBrowserFactory()
-
getConf
final ImmutableConfig getConf()
-
isActive
final Boolean isActive(BrowserId browserId)
Check if the browser is active.
-
findBrowserOrNull
@Synchronized() Browser findBrowserOrNull(BrowserId browserId)
Find an existing browser by id. If the browser is not found, return null.
- Parameters:
browserId- The browser id- Returns:
The browser or null if not found
-
closeBrowser
@Synchronized() Unit closeBrowser(BrowserId browserId)
Close a browser.
-
closeBrowser
@Synchronized() Unit closeBrowser(Browser browser)
-
destroyBrowserForcibly
@Synchronized() final Unit destroyBrowserForcibly(BrowserId browserId)
-
closeDriver
@Synchronized() Unit closeDriver(WebDriver driver)
-
findLeastValuableDriver
@Synchronized() final WebDriver findLeastValuableDriver()
-
closeLeastValuableDriver
@Synchronized() final Unit closeLeastValuableDriver()
-
destroyZombieBrowsersForcibly
@Synchronized() final Unit destroyZombieBrowsersForcibly()
Destroy the zombie browsers forcibly, kill the associated browser processes, release all allocated resources, regardless of whether the browser is closed or not.
-
close
@Synchronized() Unit close()
-
-
-
-