Class LifecyclePolicy.Builder
- Enclosing class:
LifecyclePolicy
LifecyclePolicy.-
Method Summary
Modifier and TypeMethodDescriptionbuild()forcedShutdownTimeout(@Nullable Duration forcedShutdownTimeout) Sets the forced shutdown timeout.gracefulShutdownTimeout(@Nullable Duration gracefulShutdownTimeout) Sets the graceful shutdown timeout.startupCancelationTimeout(@Nullable Duration startupCancelationTimeout) Sets the startup-cancelation budget.startupTimeout(@Nullable Duration startupTimeout) Sets the startup timeout.
-
Method Details
-
startupTimeout
Sets the startup timeout. Zero means an immediate boundary. A zero budget leaves no waiting allowance for framework setup or transport startup and can immediately produceStartupDisposition.TIMED_OUT; it does not disable the timeout. Passingnullrestores the built-in default of 30 seconds.- Parameters:
startupTimeout- startup timeout, ornullto use the default- Returns:
- this builder
- Throws:
IllegalArgumentException- if negative or not representable as signed nanoseconds
-
startupCancelationTimeout
public @NonNull LifecyclePolicy.Builder startupCancelationTimeout(@Nullable Duration startupCancelationTimeout) Sets the startup-cancelation budget. Zero means an immediate boundary. A zero budget leaves no waiting allowance for an active startup call to return after shutdown intent. Remaining startup work stays tracked through the graceful and forced shutdown phases. Passingnullrestores the built-in default of 2 seconds.- Parameters:
startupCancelationTimeout- cancelation budget, ornullto use the default- Returns:
- this builder
- Throws:
IllegalArgumentException- if negative or not representable as signed nanoseconds
-
gracefulShutdownTimeout
public @NonNull LifecyclePolicy.Builder gracefulShutdownTimeout(@Nullable Duration gracefulShutdownTimeout) Sets the graceful shutdown timeout. Zero means an immediate boundary. Passingnullrestores the built-in default of 15 seconds. A zero budget leaves no waiting allowance for graceful drain; participants without termination proof proceed to forced shutdown.This budget is independent of the server request-handler timeout (60 seconds by default). To let all permitted in-flight requests finish, allow their maximum remaining work and response transmission time. A shorter drain intentionally permits interruption and connection closure at the forced boundary. Interruption cannot guarantee that noncooperative application code stops. Long-lived streams need an explicit termination policy; the surrounding process/container budget must also include forced shutdown and operational margin.
After a closing response, the standard HTTP server closes promptly when the request was fully consumed and no surplus input was observed, including one nonblocking check for input already queued on the socket. If unread input may remain, its one-second lingering-input window consumes this budget even after the response has been written. Short graceful budgets can therefore proceed to forced shutdown while such a client connection still lingers.
- Parameters:
gracefulShutdownTimeout- graceful shutdown timeout, ornullto use the default- Returns:
- this builder
- Throws:
IllegalArgumentException- if negative or not representable as signed nanoseconds
-
forcedShutdownTimeout
public @NonNull LifecyclePolicy.Builder forcedShutdownTimeout(@Nullable Duration forcedShutdownTimeout) Sets the forced shutdown timeout. Zero means an immediate boundary. Passingnullrestores the built-in default of 3 seconds. A zero budget leaves no waiting allowance for forced termination proof. Any still-unproven or residual work produces an incomplete result. In particular, zero graceful and forced budgets can make even an idle running listener's shutdown incomplete because its stop calls and termination proof are asynchronous.- Parameters:
forcedShutdownTimeout- forced shutdown timeout, ornullto use the default- Returns:
- this builder
- Throws:
IllegalArgumentException- if negative or not representable as signed nanoseconds
-
build
- Returns:
- immutable lifecycle policy
- Throws:
IllegalArgumentException- if the combined startup-cancelation, graceful-shutdown, and forced-shutdown budget exceeds signed nanoseconds
-