Class AbstractWatchManager<T extends HasMetadata>
- java.lang.Object
-
- io.fabric8.kubernetes.client.dsl.internal.AbstractWatchManager<T>
-
- All Implemented Interfaces:
Watch,Closeable,AutoCloseable
- Direct Known Subclasses:
WatchConnectionManager,WatchHTTPManager
public abstract class AbstractWatchManager<T extends HasMetadata> extends Object implements Watch
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractWatchManager.WatchRequestState
-
Field Summary
Fields Modifier and Type Field Description protected BaseOperation<T,?,?>baseOperationprotected HttpClientclient
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()protected abstract voidcloseCurrentRequest()voidcloseRequest()Attempt to gracefully close the current request.booleanisWatching()protected voidonMessage(String message, AbstractWatchManager.WatchRequestState state, Runnable onComplete)Hand a freshly received frame off to the per-watchSerialExecutorfor deserialization and dispatch, returning immediately.protected booleanonStatus(Status status, AbstractWatchManager.WatchRequestState state)protected CompletableFuture<Void>schedule(Runnable command, long delay, TimeUnit unit)Schedule a delayed task on the operation executor.voidsetWatchEndCheckMs(int watchEndCheckMs)protected abstract voidstart(URL url, Map<String,String> headers, AbstractWatchManager.WatchRequestState state)protected voidstartWatch()Async start of the watch
-
-
-
Field Detail
-
client
protected final HttpClient client
-
baseOperation
protected BaseOperation<T extends HasMetadata,?,?> baseOperation
-
-
Method Detail
-
start
protected abstract void start(URL url, Map<String,String> headers, AbstractWatchManager.WatchRequestState state)
-
closeRequest
public void closeRequest()
Attempt to gracefully close the current request.If forceClosed has not been set, then it's expected that the watch will attempt to reconnect
-
schedule
protected CompletableFuture<Void> schedule(Runnable command, long delay, TimeUnit unit)
Schedule a delayed task on the operation executor. Test-overridable seam so unit tests can drive the fail-safe / reconnect timing deterministically without touchingUtils.schedule(java.util.concurrent.Executor, java.lang.Runnable, long, java.util.concurrent.TimeUnit)'s shared scheduler. Must return a non-null future:closeRequest()attaches a cancellation callback to it and will NPE otherwise.
-
setWatchEndCheckMs
public void setWatchEndCheckMs(int watchEndCheckMs)
-
closeCurrentRequest
protected abstract void closeCurrentRequest()
-
startWatch
protected void startWatch()
Async start of the watch
-
close
public void close()
-
onMessage
protected void onMessage(String message, AbstractWatchManager.WatchRequestState state, Runnable onComplete)
Hand a freshly received frame off to the per-watchSerialExecutorfor deserialization and dispatch, returning immediately. This keeps Jackson's deserializer-cold-path off the receive thread (the Vert.x event loop in the WebSocket path), where a single Pod-deep type warmup under CPU contention has been measured at tens of seconds and trips Vert.x's blocked-thread checker.onCompleteruns after the body finishes (success or failure) and is the point where WebSocket flow control should be re-armed by the caller. Fire-and-forget dispatch without it would let frames pile up faster than the executor can drain. It is also fired synchronously when the serial executor has already been shut down by the time this call enters, covering the common termination path. Two narrow races remain (ashutdownNow()interleaved between this check andSerialExecutor.execute, or betweenexecuteand the wrapper's own shutdown check) where the runnable can be dropped; both can only happen at watch teardown where the WebSocket is closing and back-pressure re-arm is moot. The runnable must not be null; if it throws, the error is logged and swallowed so a broken re-arm cannot wedge the queue.
-
onStatus
protected boolean onStatus(Status status, AbstractWatchManager.WatchRequestState state)
-
isWatching
public boolean isWatching()
-
-