Package org.jdrupes.vmoperator.manager
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 contextL
- 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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclient()
Return the client.Sets the client to be used.io.kubernetes.client.Discovery.APIResource
context()
Returns the observed context.context
(io.kubernetes.client.Discovery.APIResource context) Sets the context to observe.protected abstract void
handleChange
(K8sClient client, io.kubernetes.client.util.Watch.Response<O> change) Handle an observed change.Return the observed namespace.Sets the namespace to be observed.void
Looks for a key “namespace” in the configuration and, if found, sets the namespace to its value.void
Handle the start event.io.kubernetes.client.util.generic.options.ListOptions
options()
Returns the options for selecting the objects to observe.options
(io.kubernetes.client.util.generic.options.ListOptions options) Sets the options for selecting the objects to observe.protected void
Invoked byonStart(Start)
after the namespace has been configured and before starting the observer.Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
AbstractMonitor
Initializes the instance.- Parameters:
componentChannel
- the component channelobjectClass
- the class of the Kubernetes object to watchobjectListClass
- the class of the list of Kubernetes objects to watch
-
-
Method Details
-
client
Return the client.- Returns:
- the client
-
client
Sets the client to be used.- Parameters:
client
- the client- Returns:
- the abstract monitor
-
namespace
Return the observed namespace.- Returns:
- the namespace
-
namespace
Sets the namespace to be observed.- Parameters:
namespace
- the namespaceToWatch to set- Returns:
- the abstract monitor
-
options
Returns the options for selecting the objects to observe.- Returns:
- the options
-
options
public AbstractMonitor<O,L, optionsC> (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
Returns the observed context.- Returns:
- the context
-
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
Handle the start event.Configures the namespace, invokes
prepareMonitoring()
and starts the observers.- Parameters:
event
- the event
-
prepareMonitoring
Invoked byonStart(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 clientchange
- the change
-