Interface SharedIndexInformer<T>

  • All Superinterfaces:
    AutoCloseable

    public interface SharedIndexInformer<T>
    extends AutoCloseable
    SharedInxedInformer extends SharedInformer and provides indexer operability additionally.
    • Method Detail

      • removeNamespaceIndex

        default SharedIndexInformer<T> removeNamespaceIndex()
        Remove the namesapce index
        Returns:
        this
      • getIndexer

        Indexer<T> getIndexer()
        returns the internal indexer store.
        Returns:
        the internal indexer store
      • 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 handler
        resyncPeriod - the specific resync period
      • run

        SharedIndexInformer<T> run()
        Starts the shared informer, which will be stopped when stop() 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

      • 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 running

        See also stopped()

      • getApiTypeClass

        Class<T> getApiTypeClass()
        Return the class this informer is watching
      • isWatching

        boolean isWatching()
        Return true if the informer is actively watching

        Will 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.

      • getStore

        Store<T> getStore()
        Return the Store associated with this informer
        Returns:
        the store
      • 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 -
      • start

        CompletionStage<Void> start()
        A non-blocking alternative to run. Starts the shared informer, which will normally be stopped when stop() 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 the ExceptionHandler for 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 a CompletionStage that 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