Class SubmitterSchedulerQueueLimitRejector

    • Constructor Detail

      • SubmitterSchedulerQueueLimitRejector

        public SubmitterSchedulerQueueLimitRejector​(SubmitterScheduler parentScheduler,
                                                    int queuedTaskLimit)
        Constructs a new SubmitterSchedulerQueueLimitRejector with the provided scheduler and limit.
        Parameters:
        parentScheduler - Scheduler to execute and schedule tasks on to
        queuedTaskLimit - Maximum number of queued tasks before executions should be rejected
      • SubmitterSchedulerQueueLimitRejector

        public SubmitterSchedulerQueueLimitRejector​(SubmitterScheduler parentScheduler,
                                                    int queuedTaskLimit,
                                                    RejectedExecutionHandler rejectedExecutionHandler)
        Constructs a new SubmitterSchedulerQueueLimitRejector with the provided scheduler and limit.
        Parameters:
        parentScheduler - Scheduler to execute and schedule tasks on to
        queuedTaskLimit - Maximum number of queued tasks before executions should be rejected
        rejectedExecutionHandler - Handler to accept tasks which could not be executed due to queue size
        Since:
        4.8.0
    • Method Detail

      • scheduleWithFixedDelay

        public void scheduleWithFixedDelay​(java.lang.Runnable task,
                                           long initialDelay,
                                           long recurringDelay)
        Description copied from interface: SubmitterScheduler
        Schedule a fixed delay recurring task to run. The recurring delay time will be from the point where execution has finished. So the execution frequency is the recurringDelay + runtime for the provided task.

        Unlike ScheduledExecutorService if the task throws an exception, subsequent executions are NOT suppressed or prevented. So if the task throws an exception on every run, the task will continue to be executed at the provided recurring delay (possibly throwing an exception on each execution).

        Parameters:
        task - runnable to be executed
        initialDelay - delay in milliseconds until first run
        recurringDelay - delay in milliseconds for running task after last finish
      • scheduleAtFixedRate

        public void scheduleAtFixedRate​(java.lang.Runnable task,
                                        long initialDelay,
                                        long period)
        Description copied from interface: SubmitterScheduler
        Schedule a fixed rate recurring task to run. The recurring delay will be the same, regardless of how long task execution takes. A given runnable will not run concurrently (unless it is submitted to the scheduler multiple times). Instead of execution takes longer than the period, the next run will occur immediately (given thread availability in the pool).

        Unlike ScheduledExecutorService if the task throws an exception, subsequent executions are NOT suppressed or prevented. So if the task throws an exception on every run, the task will continue to be executed at the provided recurring delay (possibly throwing an exception on each execution).

        Parameters:
        task - runnable to be executed
        initialDelay - delay in milliseconds until first run
        period - amount of time in milliseconds between the start of recurring executions
      • getQueuedTaskCount

        public int getQueuedTaskCount()
        Invoked to check how many tasks are currently being tracked as queued by this limiter.
        Returns:
        Number of tracked tasks waiting for execution to start
      • getQueueLimit

        public int getQueueLimit()
        Invoked to check the currently set queue limit.
        Returns:
        Maximum number of tasks allowed to queue in the parent executor
      • setQueueLimit

        public void setQueueLimit​(int newLimit)
        Invoked to change the set limit. Negative and zero limits are allowed, but they will cause all executions to be rejected. If set below the current queue size, those tasks will still remain queued for execution.
        Parameters:
        newLimit - New limit to avoid executions