Class GridExporterConcurrentSettings

java.lang.Object
com.flowingcode.vaadin.addons.gridexporter.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 Details

    • GridExporterConcurrentSettings

      public GridExporterConcurrentSettings()
  • Method Details

    • setConcurrentDownloadLimit

      public static void setConcurrentDownloadLimit(float limit)
      Sets the limit for the cost of concurrent downloads. If all the downloads have a cost of GridExporter.DEFAULT_COST, the limit represents the number of concurrent downloads that are allowed.

      Finite limits are capped to GridExporter.MAX_COST (32767). If the limit is POSITIVE_INFINITY, concurrent downloads will not be limited.

      Parameters:
      limit - the maximum cost of concurrent downloads allowed
      Throws:
      IllegalArgumentException - if the limit is zero or negative.
    • 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 com.vaadin.flow.shared.Registration addGlobalConcurrentDownloadTimeoutEvent(com.vaadin.flow.function.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