Class AbstractMonitor<O extends io.kubernetes.client.common.KubernetesObject,L extends io.kubernetes.client.common.KubernetesListObject,C extends Channel>

java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jdrupes.vmoperator.manager.AbstractMonitor<O,L,C>
Type Parameters:
O - the object type for the context
L - the object list type for the context
All Implemented Interfaces:
Iterable<ComponentType>, Channel, ComponentType, Eligible, Manager
Direct Known Subclasses:
DisplaySecretMonitor, ServiceMonitor, VmMonitor

public abstract class AbstractMonitor<O extends io.kubernetes.client.common.KubernetesObject,L extends io.kubernetes.client.common.KubernetesListObject,C extends Channel> extends Component
A base class for monitoring VM related resources.
  • Constructor Details

    • AbstractMonitor

      protected AbstractMonitor(Channel componentChannel, Class<O> objectClass, Class<L> objectListClass)
      Initializes the instance.
      Parameters:
      componentChannel - the component channel
  • Method Details

    • client

      public K8sClient client()
      Return the client.
      Returns:
      the client
    • client

      public AbstractMonitor<O,L,C> client(K8sClient client)
      Sets the client to be used.
      Parameters:
      client - the client
      Returns:
      the abstract monitor
    • namespace

      public String namespace()
      Return the observed namespace.
      Returns:
      the namespace
    • namespace

      public AbstractMonitor<O,L,C> namespace(String namespace)
      Sets the namespace to be observed.
      Parameters:
      namespace - the namespaceToWatch to set
      Returns:
      the abstract monitor
    • options

      public io.kubernetes.client.util.generic.options.ListOptions options()
      Returns the options for selecting the objects to observe.
      Returns:
      the options
    • options

      public AbstractMonitor<O,L,C> options(io.kubernetes.client.util.generic.options.ListOptions options)
      Sets the options for selecting the objects to observe.
      Parameters:
      options - the options to set
      Returns:
      the abstract monitor
    • context

      public io.kubernetes.client.Discovery.APIResource context()
      Returns the observed context.
      Returns:
      the context
    • context

      public AbstractMonitor<O,L,C> context(io.kubernetes.client.Discovery.APIResource context)
      Sets the context to observe.
      Parameters:
      context - the context
      Returns:
      the abstract monitor
    • channelManager

      Returns the channel manager.
      Returns:
      the context
    • channelManager

      public AbstractMonitor<O,L,C> channelManager(ChannelManager<String,C,?> channelManager)
      Sets the channel manager.
      Parameters:
      channelManager - the channel manager
      Returns:
      the abstract monitor
    • onConfigurationUpdate

      Looks for a key “namespace” in the configuration and, if found, sets the namespace to its value.
      Parameters:
      event - the event
    • onStart

      @Handler(priority=10) public void onStart(Start event)
      Handle the start event.

      Configures the namespace invokes prepareMonitoring() and starts the observers.

      Parameters:
      event - the event
    • prepareMonitoring

      protected void prepareMonitoring() throws IOException, io.kubernetes.client.openapi.ApiException
      Invoked by onStart(Start) after the namespace has been configured and before starting the observer.
      Throws:
      IOException - Signals that an I/O exception has occurred.
      io.kubernetes.client.openapi.ApiException - the api exception
    • handleChange

      protected abstract void handleChange(K8sClient client, io.kubernetes.client.util.Watch.Response<O> change)
      Handle an observed change.
      Parameters:
      client - the client
      change - the change
    • channel

      protected Optional<C> channel(String name)
      Returns the Channel for the given name.
      Parameters:
      name - the name
      Returns:
      the channel used for events related to the specified object