Class MultiPrivacyContextManager

    • Constructor Detail

      • MultiPrivacyContextManager

        MultiPrivacyContextManager(WebDriverPoolManager driverPoolManager, ImmutableConfig conf)
      • MultiPrivacyContextManager

        MultiPrivacyContextManager(ImmutableConfig conf)
      • MultiPrivacyContextManager

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

      • run

         FetchResult run(FetchTask task, SuspendFunction2<FetchTask, <Error class: unknown class>, 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
        Returns:

        the fetch result

      • tryGetNextReadyPrivacyContext

         PrivacyContext tryGetNextReadyPrivacyContext(WebPage page, Fingerprint fingerprint, FetchTask task)

        Try to get a ready privacy context.

        The status of the privacy context can change immediately, so this method may return a non-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 returns a new one.

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

        A ready privacy context has to meet the following requirements:

        • not closed

        • not leaked

        • requirement removed not idle

        • not retired

        • if there is a proxy, the proxy has to be ready

        • the associated driver pool promises to provide an available driver, ether one of the following:

        Parameters:
        fingerprint - The fingerprint of this privacy context.
        Returns:

        A privacy context which is promised to be ready.

      • tryGetNextUnderLoadedPrivacyContext

         PrivacyContext tryGetNextUnderLoadedPrivacyContext(WebPage page, Fingerprint fingerprint, FetchTask task)

        Gets an under-loaded privacy context, which can be either ready or not ready.

        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.
        Returns:

        A privacy context which is promised to be ready.

      • getOrCreate

         PrivacyContext getOrCreate(BrowserProfile profile)
      • maintain

         Unit maintain(Boolean force)

        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