Package 

Class MultiPrivacyContextManager

    • Constructor Detail

      • MultiPrivacyContextManager

        MultiPrivacyContextManager(WebDriverPoolManager driverPoolManager, ImmutableConfig immutableConfig)
      • MultiPrivacyContextManager

        MultiPrivacyContextManager(WebDriverPoolManager driverPoolManager, ProxyPoolManager proxyPoolManager, CoreMetrics coreMetrics, ImmutableConfig immutableConfig)
    • Method Detail

      • getConf

         final ImmutableConfig getConf()
      • run

         FetchResult run(FetchTask task, SuspendFunction2<FetchTask, WebDriver, FetchResult> fetchFun)

        Run a task in a privacy context.

        The privacy context is selected from the active privacy context pool, and it is supposed to have at least one ready web driver to run the task.

        If the privacy context chosen is not ready to serve, especially, it has no any ready web driver, the task will be canceled.

        Parameters:
        task - the fetch task
        fetchFun - the fetch function
      • computeNextContext

         PrivacyContext computeNextContext(Fingerprint fingerprint)

        Try to get a ready privacy context.

        If the total number of active contexts is less than the maximum number allowed, a new privacy context will be created.

        If the privacy context is inactive, close it and create a new one immediately, and return the new one.

        This method can return a non-ready privacy context, in which case the task will be canceled.

        A ready privacy context is:

        • is active

        • requirement removed not idle

        • the associated driver pool promises to provide an available driver (but the promise can be failed)

        Parameters:
        fingerprint - The fingerprint of this privacy context.
      • computeIfNecessary

         PrivacyContext computeIfNecessary(Fingerprint fingerprint)

        Gets an under-loaded privacy context, which can be either active or inactive.

        If the total number of active contexts is less than the maximum number allowed, a new privacy context will be created.

        This method can return an inactive privacy context, in which case, the task should be canceled, and the privacy context should be closed.

        Parameters:
        fingerprint - The fingerprint of this privacy context.
      • maintain

         Unit maintain()

        Maintain all the privacy contexts, check and report inconsistency, illness, idleness, etc., close bad contexts if necessary.

        If "takePrivacyContextSnapshot" is in file AppPaths.PATH_LOCAL_COMMAND, perform the action.

        If the tmp dir is the default one, run the following command to take snapshot once: echo takePrivacyContextSnapshot /tmp/pulsar/pulsar-commands