Class GridExporterConcurrentSettings


  • public class GridExporterConcurrentSettings
    extends Object
    Provides global settings for managing concurrent downloads in GridExporter.

    This class allows for setting limits on concurrent downloads, configuring timeouts for acquiring download permits, and adding global listeners for concurrent download timeout events.

    • Constructor Detail

      • GridExporterConcurrentSettings

        public GridExporterConcurrentSettings()
    • Method Detail

      • getConcurrentDownloadLimit

        public static float getConcurrentDownloadLimit()
        Returns the limit for the number of concurrent downloads.
        Returns:
        the limit for the number of concurrent downloads, or Float.POSITIVE_INFINITY if concurrent downloads are not limited.
      • setFailOnUiChange

        public static void setFailOnUiChange​(boolean failOnUiChange)
        Configures the behavior of the stream operation when the UI changes during execution.
        Parameters:
        failOnUiChange - If true, the operation will throw an IOException if the UI changes (e.g., becomes detached) after acquiring the semaphore. If false, the operation will proceed regardless of any UI changes.
      • setConcurrentDownloadTimeout

        public static void setConcurrentDownloadTimeout​(long timeout,
                                                        TimeUnit unit)
        Sets the timeout for acquiring a permit to start a download when the maximum number of concurrent downloads is reached. If the timeout is less than or equal to zero, the downloads will fail immediately if no enough permits can be acquired. This timeout is crucial for preventing the system from hanging indefinitely while waiting for available resources. If the timeout expires before a permit can be acquired, the download is cancelled.
        Parameters:
        timeout - the maximum time to wait for a permit
        unit - the time unit of the timeout argument
      • getConcurrentDownloadTimeout

        public static long getConcurrentDownloadTimeout​(TimeUnit unit)
      • addGlobalConcurrentDownloadTimeoutEvent

        public static Registration addGlobalConcurrentDownloadTimeoutEvent​(SerializableConsumer<ConcurrentDownloadTimeoutEvent> listener)
        Adds a global listener for concurrent download timeout events.

        The listener will be called whenever a concurrent download timeout event occurs.

        Note that instance-specific listeners take precedence over global listeners. If an instance listener stops the event propagation by calling stopPropagation(), the global listeners will not be notified.

        Parameters:
        listener - the listener to be added
        Returns:
        a Registration object that can be used to remove the listener