Class ShutdownManager

java.lang.Object
io.temporal.internal.worker.ShutdownManager
All Implemented Interfaces:
Closeable, AutoCloseable

public class ShutdownManager extends Object implements Closeable
  • Constructor Details

    • ShutdownManager

      public ShutdownManager()
    • ShutdownManager

      public ShutdownManager(int checkPeriodMs)
      Parameters:
      checkPeriodMs - interval in milliseconds between shutdown-completion polls. Lower values speed up teardown at the cost of more frequent polling. Must be positive.
  • Method Details

    • shutdownExecutorNow

      public CompletableFuture<Void> shutdownExecutorNow(ExecutorService executorToShutdown, String executorName, Duration timeout)
      executorToShutdown.shutdownNow() -> timed wait for a graceful termination
    • shutdownExecutorNowUntimed

      public CompletableFuture<Void> shutdownExecutorNowUntimed(ExecutorService executorToShutdown, String executorName)
      executorToShutdown.shutdownNow() -> unlimited wait for termination
    • shutdownExecutor

      public CompletableFuture<Void> shutdownExecutor(ExecutorService executorToShutdown, String executorName, Duration timeout)
      executorToShutdown.shutdown() -> timed wait for graceful termination -> executorToShutdown.shutdownNow()
    • shutdownExecutorUntimed

      public CompletableFuture<Void> shutdownExecutorUntimed(ExecutorService executorToShutdown, String executorName)
      executorToShutdown.shutdown() -> unlimited wait for graceful termination
    • waitForSupplierPermitsReleasedUnlimited

      public CompletableFuture<Void> waitForSupplierPermitsReleasedUnlimited(TrackingSlotSupplier<?> slotSupplier, String name)
    • waitForStickyQueueBalancer

      public CompletableFuture<Void> waitForStickyQueueBalancer(io.temporal.internal.worker.DisableNormalPolling balancer, Duration timeout)
      waitForStickyQueueBalancer -> disableNormalPoll -> timed wait for graceful completion of sticky workflows
    • waitOnWorkerShutdownRequest

      public CompletableFuture<Void> waitOnWorkerShutdownRequest(com.google.common.util.concurrent.ListenableFuture<io.temporal.api.workflowservice.v1.ShutdownWorkerResponse> shutdownRequest)
      Wait for shutdownRequest to finish. shutdownRequest is considered best effort, so we do not fail the shutdown if it fails.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • awaitTermination

      public static long awaitTermination(@Nullable ExecutorService s, long timeoutMillis)
    • runAndGetRemainingTimeoutMs

      public static long runAndGetRemainingTimeoutMs(long initialTimeoutMs, Runnable toRun)
    • awaitTermination

      public static long awaitTermination(@Nullable Shutdownable s, long timeoutMillis)