Class SharedProcessor<T>


  • public class SharedProcessor<T>
    extends Object
    SharedProcessor class manages all the registered ProcessListener and distributes notifications. This has been taken from official-client: https://github.com/kubernetes-client/java/blob/main/util/src/main/java/io/kubernetes/client/informer/cache/SharedProcessor.java
    Modified to simplify threading
    • Constructor Detail

      • SharedProcessor

        public SharedProcessor()
      • SharedProcessor

        public SharedProcessor​(Executor executor,
                               String informerDescription)
    • Method Detail

      • addListener

        public void addListener​(ProcessorListener<T> processorListener)
        Adds the specific processorListener
        Parameters:
        processorListener - specific processor listener
      • distribute

        public void distribute​(ProcessorListener.Notification<T> obj,
                               boolean isSync)
        Distribute the object amount listeners.
        Parameters:
        obj - specific obj
        isSync - whether in sync or not
      • distribute

        public void distribute​(Consumer<ProcessorListener<T>> operation,
                               boolean isSync)
        Distribute the operation to the respective listeners
      • shouldResync

        public boolean shouldResync()
      • stop

        public void stop()
      • addProcessorListener

        public ProcessorListener<T> addProcessorListener​(ResourceEventHandler<? super T> handler,
                                                         long resyncPeriodMillis,
                                                         Supplier<Collection<T>> initialItems)
        Adds a new listener. When running this will pause event distribution until the new listener has received an initial set of add events
      • getMinimalNonZeroResyncPeriod

        public Optional<Long> getMinimalNonZeroResyncPeriod()
      • executeIfPossible

        public void executeIfPossible​(Runnable runnable)