Package io.deephaven.kv
Interface WatchClient.Watch
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
WatchBase
- Enclosing interface:
- WatchClient
Represents the watch.
Implementations should prefer to extend WatchBase
Callers should be aware that the await methods match against the current state only. For
example, simply calling watch.await(STARTED) will not necessarily return as expected if
the state quickly transitions from WatchClient.WatchState.INIT to WatchClient.WatchState.STARTED to
WatchClient.WatchState.REGISTERED. Instead, it's more appropriate to call
watch.await(EnumSet.of(STARTED, REGISTERED, COMPLETED, ERRORED), and to then check the
returned state, or call wasStarted(), if necessary.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidawait(WatchClient.WatchState state) Equivalent toawait(EnumSet.of(state)).default booleanawait(WatchClient.WatchState state, Duration timeout) Equivalent toawait(EnumSet.of(state), timeout).isPresent().await(EnumSet<WatchClient.WatchState> states) Waits until thestateis instates.await(EnumSet<WatchClient.WatchState> states, Duration timeout) default voidclose()InvokesendWatch().voidendWatch()Close this watch and all its resources.getState()Start this watch.booleanWhether or not this watch was started.
-
Method Details
-
getState
WatchClient.WatchState getState()- Returns:
- the watch state
-
startWatch
WatchClient.Watch startWatch()Start this watch. The listener will not be invoked at all until start is invoked.Only has an effect the first time it is called.
Will transition the
statefromWatchClient.WatchState.INITtoWatchClient.WatchState.STARTEDon success.- Returns:
- this watch
-
wasStarted
boolean wasStarted()Whether or not this watch was started.- Returns:
- true iff the transition from
WatchClient.WatchState.INITtoWatchClient.WatchState.STARTEDhas happened
-
endWatch
void endWatch()Close this watch and all its resources. The listener may receive onNext messages after endWatch is invoked, but we expect onCompleted or onError to follow shortly after.Only has an effect the first time it is called.
-
await
Waits until thestateis instates.- Parameters:
states- the states to wait for- Returns:
- the current state, guaranteed to be in
states - Throws:
InterruptedException- if the current thread is interrupted while waiting
-
await
Optional<WatchClient.WatchState> await(EnumSet<WatchClient.WatchState> states, Duration timeout) throws InterruptedException - Parameters:
states- the states to wait fortimeout- the duration to wait- Returns:
- if present, the current state, guaranteed to be in
states- empty if timed out - Throws:
InterruptedException- if the current thread is interrupted while waiting
-
await
Equivalent toawait(EnumSet.of(state)).- Parameters:
state- the state to wait for- Throws:
InterruptedException- if the current thread is interrupted while waiting
-
await
Equivalent toawait(EnumSet.of(state), timeout).isPresent().- Parameters:
state- the state to wait fortimeout- the duration to wait- Returns:
- true if the wait for
statewas successful, false if the wait timed out - Throws:
InterruptedException- if the current thread is interrupted while waiting
-
close
default void close()InvokesendWatch().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-