类 GracefulShutdownManager
java.lang.Object
io.agentscope.core.shutdown.GracefulShutdownManager
Global manager for graceful shutdown lifecycle and active request tracking.
-
方法概要
修饰符和类型方法说明booleanawaitTermination(Duration timeout) Block until the shutdown state reaches TERMINATED or the given timeout elapses.voidbindSession(Agent agent, Session session, SessionKey sessionKey) booleanCheck whether the agent's session was previously interrupted by shutdown, and clear the flag.voidintstatic GracefulShutdownManagerreactor.core.publisher.Mono<Void> Returns aMonothat completes when the shutdown timeout is reached.getState()voidinterruptIfShuttingDown(Agent agent) booleanbooleanregisterRequest(Agent agent) voidReset manager state.voidsaveOnInterruptObserved(Agent agent) Called from agent's handleInterrupt when a SYSTEM interrupt is observed.voidsetConfig(GracefulShutdownConfig config) voidunregisterRequest(Agent agent)
-
方法详细资料
-
getInstance
-
getState
-
getConfig
-
setConfig
-
getShutdownTimeoutSignal
Returns aMonothat completes when the shutdown timeout is reached. Tool executors can race their execution against this signal to abort early. -
bindSession
-
checkAndClearShutdownInterrupted
Check whether the agent's session was previously interrupted by shutdown, and clear the flag.Called from
GracefulShutdownHookatPreCallEventto detect a client retry after shutdown interruption, so the duplicate user prompt can be replaced with a "continue" message.- 返回:
- true if the flag was present and cleared
-
isAcceptingRequests
public boolean isAcceptingRequests() -
getActiveRequestCount
public int getActiveRequestCount() -
ensureAcceptingRequests
public void ensureAcceptingRequests() -
registerRequest
-
unregisterRequest
-
interruptIfShuttingDown
-
saveOnInterruptObserved
Called from agent's handleInterrupt when a SYSTEM interrupt is observed. Always saves because memory may have been updated after the previous safe-point/timeout save. -
performGracefulShutdown
public boolean performGracefulShutdown() -
awaitTermination
Block until the shutdown state reaches TERMINATED or the given timeout elapses.- 参数:
timeout- maximum time to wait;nullmeans wait indefinitely- 返回:
- true if TERMINATED was reached, false if timed out
-
resetForTesting
public void resetForTesting()Reset manager state. Intended for testing and demo purposes only.
-