Class ServiceBeansConfig.DrainingTaskExecutor

java.lang.Object
org.springframework.scheduling.concurrent.ConcurrentTaskExecutor
ubic.gemma.core.config.ServiceBeansConfig.DrainingTaskExecutor
All Implemented Interfaces:
Executor, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.core.task.AsyncListenableTaskExecutor, org.springframework.core.task.AsyncTaskExecutor, org.springframework.core.task.TaskExecutor, org.springframework.scheduling.SchedulingTaskExecutor
Enclosing class:
ServiceBeansConfig

public static class ServiceBeansConfig.DrainingTaskExecutor extends org.springframework.scheduling.concurrent.ConcurrentTaskExecutor implements org.springframework.context.SmartLifecycle
A ConcurrentTaskExecutor that waits for its pending tasks when the context is stopped.

The tasks run on virtual threads, which are daemon threads: System.exit halts them mid-task. The DEA archive written after an analysis runs on this executor, so a CLI exiting right after an analysis would halt that write. GemmaCLI's shutdown hook closes the context, and the JVM halts daemon threads only once its shutdown hooks have returned.

The wait is in stop(), which the context calls before it destroys any bean, so the tasks still have the beans they use, the database included. Tasks still running after the timeout are interrupted.

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.scheduling.concurrent.ConcurrentTaskExecutor

    org.springframework.scheduling.concurrent.ConcurrentTaskExecutor.ManagedTaskBuilder
  • Field Summary

    Fields inherited from interface org.springframework.core.task.AsyncTaskExecutor

    TIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITE

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    void
     
    void
     

    Methods inherited from class org.springframework.scheduling.concurrent.ConcurrentTaskExecutor

    execute, execute, getConcurrentExecutor, setConcurrentExecutor, setTaskDecorator, submit, submit, submitListenable, submitListenable

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.core.task.AsyncTaskExecutor

    submitCompletable, submitCompletable

    Methods inherited from interface org.springframework.scheduling.SchedulingTaskExecutor

    prefersShortLivedTasks

    Methods inherited from interface org.springframework.context.SmartLifecycle

    getPhase, isAutoStartup, stop
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle