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

When started, it creates observers for all versions of the the Discovery.APIResource configured by context(APIResource). The APIResource is not passed to the constructor because in some cases it has to be evaluated lazily.

  • Constructor Details

    • AbstractMonitor

      protected AbstractMonitor(Channel componentChannel, Class<O> objectClass, Class<L> objectListClass)
      Initializes the instance.
      Parameters:
      componentChannel - the component channel
      objectClass - the class of the Kubernetes object to watch
      objectListClass - the class of the list of Kubernetes objects to watch
  • 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
    • 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.

      This is the last opportunity to invoke context(APIResource).

      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