Class SchedulingStrategy

  • All Implemented Interfaces:
    Destroyable

    public abstract class SchedulingStrategy
    extends Object
    implements Destroyable
    Specifies the strategy of scheduling whether sequential, or parallel. The strategy may use a thread pool shared with other strategies.
    One instance of strategy can be used just by one Scheduler.
    The strategy is scheduling tasks in schedule(Runnable) and awaiting them completed in finished(). Both methods should be used in one thread.
    Since:
    2.16
    Author:
    Tibor Digana (tibor17)
    • Constructor Detail

      • SchedulingStrategy

        protected SchedulingStrategy​(org.apache.maven.plugin.surefire.log.api.ConsoleLogger logger)
    • Method Detail

      • finished

        protected abstract boolean finished()
                                     throws InterruptedException
        Waiting for scheduled tasks to finish. New tasks will not be scheduled by calling this method.
        Returns:
        true if successfully stopped the scheduler, else false if already stopped (a shared thread pool was shutdown externally).
        Throws:
        InterruptedException - if interrupted while waiting for scheduled tasks to finish
        See Also:
        RunnerScheduler.finished()
      • stop

        protected abstract boolean stop()
        Stops scheduling new tasks (e.g. by ExecutorService.shutdown() on a private thread pool which cannot be shared with other strategy).
        Returns:
        true if successfully stopped the scheduler, else false if already stopped (a shared thread pool was shutdown externally).
        See Also:
        ExecutorService.shutdown()
      • stopNow

        protected boolean stopNow()
        Stops scheduling new tasks and interrupts running tasks (e.g. by ExecutorService.shutdownNow() on a private thread pool which cannot be shared with other strategy).
        This method calls stop() by default.
        Returns:
        true if successfully stopped the scheduler, else false if already stopped (a shared thread pool was shutdown externally).
        See Also:
        ExecutorService.shutdownNow()
      • disable

        protected boolean disable()
        Persistently disables this strategy. Atomically ignores Balancer to acquire a new permit.
        The method canSchedule() atomically returns false.
        Returns:
        true if canSchedule() has return true on the beginning of this method call.
      • hasSharedThreadPool

        protected abstract boolean hasSharedThreadPool()
        Returns:
        true if a thread pool associated with this strategy can be shared with other strategies.
      • canSchedule

        protected boolean canSchedule()
        Returns:
        true unless stopped, finished or disabled.
      • logQuietly

        protected void logQuietly​(Throwable t)