Class AbstractPrivacyManager

  • All Implemented Interfaces:
    ai.platon.pulsar.skeleton.crawl.fetch.privacy.PrivacyManager , java.lang.AutoCloseable

    
    public abstract class AbstractPrivacyManager
     implements PrivacyManager
                        

    Manages the lifecycle of privacy contexts, including permanent and temporary contexts. Permanent contexts have a long lifecycle and are never deleted, while temporary contexts are short-lived and discarded if a privacy leak is detected.

    • Constructor Detail

      • AbstractPrivacyManager

        AbstractPrivacyManager(ImmutableConfig conf)
        Parameters:
        conf - The immutable configuration used to initialize the privacy manager.
    • Method Detail

      • getPermanentContexts

         final ConcurrentHashMap<PrivacyAgent, PrivacyContext> getPermanentContexts()

        Permanent contexts have a long lifecycle and are never deleted by the system. Predefined privacy agents for permanent contexts include:

        • PrivacyAgent.SYSTEM_DEFAULT

        • PrivacyAgent.PROTOTYPE

        • PrivacyAgent.DEFAULT

        • PrivacyAgent.NEXT_SEQUENTIAL

      • isClosed

         Boolean isClosed()

        Indicates whether the privacy manager is closed.

      • isActive

         Boolean isActive()

        Indicates whether the privacy manager is active.

      • getConf

         ImmutableConfig getConf()
      • tryGetNextReadyPrivacyContext

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

        Attempts to get the next ready privacy context for a given page, fingerprint, and task.

        Parameters:
        page - The web page associated with the context.
        fingerprint - The fingerprint used to identify the context.
        task - The fetch task associated with the context.
        Returns:

        The next ready privacy context.

      • tryGetNextReadyPrivacyContext

         abstract PrivacyContext tryGetNextReadyPrivacyContext(Fingerprint fingerprint)

        Attempts to get the next ready privacy context for a given fingerprint.

        Parameters:
        fingerprint - The fingerprint used to identify the context.
        Returns:

        The next ready privacy context.

      • tryGetNextUnderLoadedPrivacyContext

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

        Attempts to get the next under-loaded privacy context for a given page, fingerprint, and task.

        Parameters:
        page - The web page associated with the context.
        fingerprint - The fingerprint used to identify the context.
        task - The fetch task associated with the context.
        Returns:

        The next under-loaded privacy context, or null if none is available.

      • getOrCreate

         abstract PrivacyContext getOrCreate(PrivacyAgent privacyAgent)

        Gets or creates a privacy context for the given privacy agent.

        Parameters:
        privacyAgent - The privacy agent associated with the context.
        Returns:

        The privacy context.

      • createUnmanagedContext

         abstract PrivacyContext createUnmanagedContext(PrivacyAgent privacyAgent)

        Creates an unmanaged privacy context for the given privacy agent.

        Parameters:
        privacyAgent - The privacy agent associated with the context.
        Returns:

        The unmanaged privacy context.

      • createUnmanagedContext

         PrivacyContext createUnmanagedContext(PrivacyAgent privacyAgent, WebDriverFetcher fetcher)

        Creates an unmanaged privacy context for the given privacy agent and fetcher.

        Parameters:
        privacyAgent - The privacy agent associated with the context.
        fetcher - The web driver fetcher used to create the context.
        Returns:

        The unmanaged privacy context.

      • buildStatusString

         String buildStatusString()

        Builds a status string summarizing the current state of active contexts.

        Returns:

        A string representation of the active contexts' status.

      • maintain

         Unit maintain(Boolean force)

        Performs maintenance tasks on the privacy manager.

        Parameters:
        force - If true, forces maintenance tasks to run.
      • close

         Unit close(PrivacyContext privacyContext)

        Closes a given privacy context, moving it from the active list to the zombie list.

        Parameters:
        privacyContext - The privacy context to close.
      • close

         Unit close()

        Closes the privacy manager, including all active contexts.

      • reset

         Unit reset(String reason)

        Resets the privacy environment by closing all privacy contexts.

        Parameters:
        reason - The reason for resetting the privacy environment.