Class AbstractPrivacyContext

    • Constructor Detail

      • AbstractPrivacyContext

        AbstractPrivacyContext(PrivacyAgent privacyAgent, ImmutableConfig conf)
    • Method Detail

      • isIdle

         Boolean isIdle()

        Check whether the privacy context is idle.

      • isGood

         Boolean isGood()

        Check whether the privacy context is good.

        A good privacy context has to meet the following requirements:

        • the fetch speed is good

      • isLeaked

         Boolean isLeaked()

        Check whether the privacy context is leaked.

        This property indicates whether the privacy context has been marked as leaked. It returns the value of the leaked field, which is a boolean indicating the leakage status.

        Returns:

        true if the privacy context is leaked, false otherwise.

      • isRetired

         Boolean isRetired()

        Check whether the privacy context is retired.

        This property indicates whether the privacy context has been marked as retired. It returns the value of the retired field, which is a boolean indicating the retirement status.

        Returns:

        true if the privacy context is retired, false otherwise.

      • isActive

         Boolean isActive()

        Check whether the privacy context is active.

        TODO: check and distinct from isReady in use cases.

        An active privacy context has to meet the following requirements:

        • not closed

        • not leaked

        • not retired

        Note: this flag does not guarantee consistency, and can change immediately after it's read

      • isReady

         Boolean isReady()

        A ready privacy context is ready to serve tasks.

        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:

        Note: this flag does not guarantee consistency, and can change immediately after it's read

      • isFullCapacity

         Boolean isFullCapacity()

        Check whether the privacy context is at full capacity. If the privacy context is indeed at full capacity, it should not be used for processing new tasks, and the underlying services may potentially refuse to provide service.

        A privacy context is running at full capacity when the underlying webdriver pool is full capacity, so the webdriver pool can not provide a webdriver for new tasks.

        Note that if a driver pool is retired or closed, it's not full capacity.

        Returns:

        True if the privacy context is running at full capacity, false otherwise.

      • getConf

         final ImmutableConfig getConf()
      • promisedWebDriverCount

         abstract Integer promisedWebDriverCount()

        The promised workers (free web drivers) count.

        The implementation has to tell the caller how many workers (free web drivers) it can provide.

        The number of workers can change immediately after reading, so the caller only has promises but no guarantees.

        Returns:

        the number of workers promised.

      • markSuccess

         final Unit markSuccess()

        Marks a task as successful and updates relevant metrics.

      • markLeaked

         final Unit markLeaked()

        Mark the privacy context as leaked. A leaked privacy context should not serve anymore, and will be closed soon.

      • open

         abstract FetchResult open(String url)

        Open an url in the privacy context.

        Parameters:
        url - The URL to open.
      • open

         abstract FetchResult open(String url, LoadOptions options)

        Open an url in the privacy context, with the specified options.

        Parameters:
        url - The URL to open.
        options - The load options to use.
      • dismiss

         Unit dismiss()

        Dismisses the privacy context and marks it as retired, indicating that it should be closed later. This function sets the retired flag to true, signaling that the privacy context is no longer active and should be handled accordingly (e.g., closed or cleaned up).

        This function does not take any parameters and does not return any value.

      • maintain

         abstract Unit maintain()

        Do the maintaining jobs.

      • buildReport

         String buildReport()

        Build the privacy context report.

        This method is used to build the privacy context report. It should be called periodically to keep the privacy context alive.