Interface SharedIndexInformer<T>
-
- All Superinterfaces:
AutoCloseable
public interface SharedIndexInformer<T> extends AutoCloseable
SharedInxedInformer extends SharedInformer and provides indexer operability additionally.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description SharedIndexInformer<T>addEventHandler(ResourceEventHandler<? super T> handler)Add event handler.SharedIndexInformer<T>addEventHandlerWithResyncPeriod(ResourceEventHandler<? super T> handle, long resyncPeriod)Adds an event handler to the shared informer using the specified resync period.SharedIndexInformer<T>addIndexers(Map<String,Function<T,List<String>>> indexers)Add indexersdefault voidclose()SharedIndexInformer<T>exceptionHandler(ExceptionHandler handler)Sets theExceptionHandlerfor this informer.Class<T>getApiTypeClass()Return the class this informer is watchingIndexer<T>getIndexer()returns the internal indexer store.Store<T>getStore()Return the Store associated with this informerdefault booleanhasSynced()Return true if the informer has ever syncedSharedIndexInformer<T>initialState(Stream<T> items)Sets the initial state of the informer store, which will be replaced by the initial list operation.booleanisRunning()Return true if the informer is runningbooleanisWatching()Return true if the informer is actively watchingSharedIndexInformer<T>itemStore(ItemStore<T> itemStore)StringlastSyncResourceVersion()The resource version observed when last synced with the underlying store.SharedIndexInformer<T>removeEventHandler(ResourceEventHandler<? super T> handler)Remove event handler.SharedIndexInformer<T>removeIndexer(String name)Remove the named indexdefault SharedIndexInformer<T>removeNamespaceIndex()Remove the namesapce indexSharedIndexInformer<T>run()Starts the shared informer, which will be stopped whenstop()is called.CompletionStage<Void>start()A non-blocking alternative to run.voidstop()Stops the shared informer.CompletionStage<Void>stopped()Return aCompletionStagethat will allow notification of the informer stopping.
-
-
-
Method Detail
-
addIndexers
SharedIndexInformer<T> addIndexers(Map<String,Function<T,List<String>>> indexers)
Add indexers- Parameters:
indexers- indexers
-
removeNamespaceIndex
default SharedIndexInformer<T> removeNamespaceIndex()
Remove the namesapce index- Returns:
- this
-
removeIndexer
SharedIndexInformer<T> removeIndexer(String name)
Remove the named index- Parameters:
name-- Returns:
- this
-
getIndexer
Indexer<T> getIndexer()
returns the internal indexer store.- Returns:
- the internal indexer store
-
addEventHandler
SharedIndexInformer<T> addEventHandler(ResourceEventHandler<? super T> handler)
Add event handler.The handler methods will be called using the client's
Executor- Parameters:
handler- event handler
-
removeEventHandler
SharedIndexInformer<T> removeEventHandler(ResourceEventHandler<? super T> handler)
Remove event handler.- Parameters:
handler- event handler
-
addEventHandlerWithResyncPeriod
SharedIndexInformer<T> addEventHandlerWithResyncPeriod(ResourceEventHandler<? super T> handle, long resyncPeriod)
Adds an event handler to the shared informer using the specified resync period. Events to a single handler are delivered sequentially, but there is no coordination between different handlers.The handler methods will be called using the client's
Executor- Parameters:
handle- the event handlerresyncPeriod- the specific resync period
-
run
SharedIndexInformer<T> run()
Starts the shared informer, which will be stopped whenstop()is called.
Only one start attempt is made - subsequent calls will not re-start the informer.
If the informer is not already running, this is a blocking call
-
stop
void stop()
Stops the shared informer. The informer cannot be started again.Once this call completes the informer will stop processing events, but the underlying watch closure may not yet be completed
-
close
default void close()
- Specified by:
closein interfaceAutoCloseable
-
hasSynced
default boolean hasSynced()
Return true if the informer has ever synced
-
lastSyncResourceVersion
String lastSyncResourceVersion()
The resource version observed when last synced with the underlying store. The value returned is not synchronized with access to the underlying store and is not thread-safe.Since the store processes events asynchronously this value should not be used as an indication of the last resourceVersion seen. Also after an informer is stopped any pending event processing may not happen.
- Returns:
- string value or null if never synced
-
isRunning
boolean isRunning()
Return true if the informer is runningSee also
stopped()
-
isWatching
boolean isWatching()
Return true if the informer is actively watchingWill return false even when
isRunning()is true if the watch needs to be re-established due to connectivity issues, 410 Gone response, etc.A single false observation does not mean the informer is unhealthy as it will likely be able to resume normal operations.
-
initialState
SharedIndexInformer<T> initialState(Stream<T> items)
Sets the initial state of the informer store, which will be replaced by the initial list operation. This will emit relevant delete and update events, rather than just adds.
Can only be called before the informer is running- Parameters:
items-
-
itemStore
SharedIndexInformer<T> itemStore(ItemStore<T> itemStore)
-
start
CompletionStage<Void> start()
A non-blocking alternative to run. Starts the shared informer, which will normally be stopped whenstop()is called.
The stage will be completed normally once the Informer starts watching successfully for the first time.By default the informer will attempt only a single start attempt. Use
exceptionHandler(ExceptionHandler)to modify this behavior.
-
exceptionHandler
SharedIndexInformer<T> exceptionHandler(ExceptionHandler handler)
Sets theExceptionHandlerfor this informer. For example, exceptionHandler((b, t) -> true)), will keep retrying no matter what the exception is.May only be called prior to the informer starting
- Parameters:
handler-
-
stopped
CompletionStage<Void> stopped()
Return aCompletionStagethat will allow notification of the informer stopping. This will be completed after event processing has stopped.If
stop()is called, the CompletionStage will complete normally.If an exception occurs that terminates the informer, then it will be exceptionally completed with that exception - typically a
WatcherException
-
-