Class SharedInformerFactory
- java.lang.Object
-
- io.fabric8.kubernetes.client.dsl.base.OperationSupport
-
- io.fabric8.kubernetes.client.dsl.base.BaseOperation
-
- io.fabric8.kubernetes.client.informers.SharedInformerFactory
-
- All Implemented Interfaces:
AnyNamespaceable
,Cascading
,CascadingEditReplacePatchDeletable
,Createable
,CreateFromServerGettable
,CreateOrReplaceable
,Deletable
,DryRunable
,Editable
,EditReplacePatchable
,EditReplacePatchDeletable
,Filterable
,FilterWatchListDeletable
,FilterWatchListMultiDeletable
,FromServerable
,Gettable
,Listable
,Loadable
,Lockable
,MixedOperation
,MultiDeleteable
,Nameable
,Namespaceable
,NonNamespaceOperation
,Operation
,Patchable
,Readiable
,Replaceable
,Requirable
,Resource
,StatusUpdatable
,Versionable
,VersionWatchAndWaitable
,Waitable
,Watchable
,WatchAndWaitable
,WatchListDeletable
,WritableOperation
,FromServerGettable
,GracePeriodConfigurable
,OperationInfo
,PropagationPolicyConfigurable
public class SharedInformerFactory extends BaseOperation
SharedInformerFactory class constructs and caches informers for api types. This has been taken from https://github.com/kubernetes-client/java/blob/master/util/src/main/java/io/kubernetes/client/informer/SharedInformerFactory.java which is ported from offical go client https://github.com/kubernetes/client-go/blob/master/informers/factory.go
-
-
Field Summary
-
Fields inherited from class io.fabric8.kubernetes.client.dsl.base.BaseOperation
apiVersion, listType, type
-
Fields inherited from class io.fabric8.kubernetes.client.dsl.base.OperationSupport
apiGroupName, apiGroupVersion, client, config, context, dryRun, JSON, JSON_MAPPER, JSON_PATCH, name, namespace, resourceT, STRATEGIC_MERGE_JSON_PATCH, YAML_MAPPER
-
Fields inherited from interface io.fabric8.kubernetes.client.dsl.Waitable
DEFAULT_BACKOFF_MULTIPLIER, DEFAULT_INITIAL_BACKOFF_MILLIS
-
-
Constructor Summary
Constructors Constructor Description SharedInformerFactory(ExecutorService threadPool, okhttp3.OkHttpClient okHttpClient, Config configuration)
Constructor with thread pool specified.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addSharedInformerEventListener(SharedInformerEventListener event)
<T> SharedIndexInformer<T>
getExistingSharedIndexInformer(Class<T> apiTypeClass)
Gets existing shared index informer, return null if the requesting informer is never constructed.SharedInformerFactory
inNamespace(String namespace)
Configure Namespace forSharedInformerFactory
<T extends io.fabric8.kubernetes.api.model.HasMetadata>
SharedIndexInformer<T>sharedIndexInformerFor(Class<T> apiTypeClass, long resyncPeriodInMillis)
Constructs and returns a shared index informer with resync period specified.<T extends io.fabric8.kubernetes.api.model.HasMetadata>
SharedIndexInformer<T>sharedIndexInformerFor(Class<T> apiTypeClass, OperationContext operationContext, long resyncPeriodInMillis)
Constructs and returns a shared index informer with resync period specified.<T extends CustomResource<?,?>,L extends io.fabric8.kubernetes.api.model.KubernetesResourceList<T>>
SharedIndexInformer<T>sharedIndexInformerForCustomResource(CustomResourceDefinitionContext customResourceContext, Class<T> apiTypeClass, Class<L> apiListTypeClass, long resyncPeriodInMillis)
Deprecated.Since 5.x versions of clientCustomResourceDefinitionContext
are configured via annotations in CustomResource implementations, please use any of the alternative sharedIndexInformerForCustomResource methods<T extends CustomResource<?,?>>
SharedIndexInformer<T>sharedIndexInformerForCustomResource(Class<T> apiTypeClass, long resyncPeriodInMillis)
Constructs and returns a shared index informer with resync period specified for custom resources.<T extends CustomResource<?,?>>
SharedIndexInformer<T>sharedIndexInformerForCustomResource(Class<T> apiTypeClass, OperationContext operationContext, long resyncPeriodInMillis)
Constructs and returns a shared index informer with resync period specified for custom resources.<T extends CustomResource<?,?>,L extends io.fabric8.kubernetes.api.model.KubernetesResourceList<T>>
SharedIndexInformer<T>sharedIndexInformerForCustomResource(Class<T> apiTypeClass, Class<L> apiListTypeClass, long resyncPeriodInMillis)
Constructs and returns a shared index informer with resync period specified for custom resources.void
startAllRegisteredInformers()
Starts all registered informers.void
stopAllRegisteredInformers()
Stop all registered informers and shut down thread pool.void
stopAllRegisteredInformers(boolean shutDownThreadPool)
Stop all registered informersSharedInformerFactory
withName(String name)
Configure Name forSharedInformerFactory
-
Methods inherited from class io.fabric8.kubernetes.client.dsl.base.BaseOperation
accept, cascading, create, create, createOrReplace, delete, delete, delete, dryRun, edit, edit, edit, fetchListUrl, forOperationType, fromServer, get, getApiVersion, getConfigType, getFieldQueryParam, getFields, getFieldsNot, getGracePeriodSeconds, getItem, getKind, getLabelQueryParam, getLabels, getLabelsIn, getLabelsNot, getLabelsNotIn, getListType, getMandatory, getOperationType, getPropagationPolicy, getReadiness, getResourceT, getResourceVersion, getRootPaths, getType, handleCreate, handleDeploymentRollback, handleGet, handlePatch, handlePatch, handleReplace, handleResponse, handleScale, inAnyNamespace, isApiGroup, isCascading, isReady, isReloadingFromServer, isResourceNamespaced, list, list, list, load, load, load, load, lockResourceVersion, newInstance, patch, replace, require, sendPatchedObject, setListType, setNamespace, setType, updateApiVersion, updateApiVersion, updateStatus, waitUntilCondition, waitUntilReady, watch, watch, watch, withField, withFields, withGracePeriod, withInvolvedObject, withItem, withLabel, withLabel, withLabelIn, withLabelNotIn, withLabels, withLabelSelector, withoutField, withoutFields, withoutLabel, withoutLabel, withoutLabels, withPropagationPolicy, withResourceVersion, withWaitRetryBackoff
-
Methods inherited from class io.fabric8.kubernetes.client.dsl.base.OperationSupport
assertResponseCode, checkName, checkNamespace, createStatus, createStatus, getAPIGroup, getAPIVersion, getConfig, getName, getNamespace, getNamespacedUrl, getNamespacedUrl, getNamespacedUrl, getObjectValueAsMap, getResourceUrl, getResourceUrl, getResourceURLForWriteOperation, getRootUrl, handleCreate, handleDelete, handleDelete, handleDeploymentRollback, handleGet, handleGet, handleMetric, handlePatch, handlePatch, handleReplace, handleReplace, handleResponse, handleResponse, handleResponse, handleResponse, handleScale, handleStatusUpdate, requestException, requestFailure, unmarshal, unmarshal, unmarshal
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.fabric8.kubernetes.client.dsl.DryRunable
dryRun
-
Methods inherited from interface io.fabric8.kubernetes.client.OperationInfo
getName, getNamespace
-
-
-
-
Constructor Detail
-
SharedInformerFactory
public SharedInformerFactory(ExecutorService threadPool, okhttp3.OkHttpClient okHttpClient, Config configuration)
Constructor with thread pool specified.- Parameters:
threadPool
- specified thread pool.okHttpClient
- OkHttp clientconfiguration
- configuration for client
-
-
Method Detail
-
inNamespace
public SharedInformerFactory inNamespace(String namespace)
Configure Namespace forSharedInformerFactory
- Specified by:
inNamespace
in interfaceNamespaceable
- Overrides:
inNamespace
in classBaseOperation
- Parameters:
namespace
- namespace to configure- Returns:
SharedInformerFactory
with namespace configured
-
withName
public SharedInformerFactory withName(String name)
Configure Name forSharedInformerFactory
- Specified by:
withName
in interfaceNameable
- Overrides:
withName
in classBaseOperation
- Parameters:
name
- name to be configured- Returns:
SharedInformerFactory
with name configured
-
sharedIndexInformerFor
public <T extends io.fabric8.kubernetes.api.model.HasMetadata> SharedIndexInformer<T> sharedIndexInformerFor(Class<T> apiTypeClass, long resyncPeriodInMillis)
Constructs and returns a shared index informer with resync period specified. And the informer cache will be overwritten. Note:It watches for events in ALL NAMESPACES.- Type Parameters:
T
- the type parameter (should extendHasMetadata
and implementNamespaced
) if Namespace scoped resource- Parameters:
apiTypeClass
- apiType classresyncPeriodInMillis
- resync period in milliseconds- Returns:
- the shared index informer
-
sharedIndexInformerFor
public <T extends io.fabric8.kubernetes.api.model.HasMetadata> SharedIndexInformer<T> sharedIndexInformerFor(Class<T> apiTypeClass, OperationContext operationContext, long resyncPeriodInMillis)
Constructs and returns a shared index informer with resync period specified. Note:It watches for events in ALL NAMESPACES.- Type Parameters:
T
- the type parameter (should extendHasMetadata
and implementNamespaced
) if Namespace scoped resource- Parameters:
apiTypeClass
- apiType classoperationContext
-OperationContext
Operation ContextresyncPeriodInMillis
- resync period in milliseconds- Returns:
- the shared index informer
-
sharedIndexInformerForCustomResource
@Deprecated public <T extends CustomResource<?,?>,L extends io.fabric8.kubernetes.api.model.KubernetesResourceList<T>> SharedIndexInformer<T> sharedIndexInformerForCustomResource(CustomResourceDefinitionContext customResourceContext, Class<T> apiTypeClass, Class<L> apiListTypeClass, long resyncPeriodInMillis)
Deprecated.Since 5.x versions of clientCustomResourceDefinitionContext
are configured via annotations in CustomResource implementations, please use any of the alternative sharedIndexInformerForCustomResource methodsConstructs and returns a shared index informer with resync period specified for custom resources. Note:It watches for events in ALL NAMESPACES.- Type Parameters:
T
- the type parameter (should extendHasMetadata
and implementNamespaced
)L
- the type's list parameter (should extendKubernetesResourceList
- Parameters:
customResourceContext
- basic information about the Custom Resource Definition corresponding to that custom resourceapiTypeClass
- apiType classapiListTypeClass
- api list type classresyncPeriodInMillis
- resync period in milliseconds- Returns:
- the shared index informer
-
sharedIndexInformerForCustomResource
public <T extends CustomResource<?,?>> SharedIndexInformer<T> sharedIndexInformerForCustomResource(Class<T> apiTypeClass, OperationContext operationContext, long resyncPeriodInMillis)
Constructs and returns a shared index informer with resync period specified for custom resources.- Type Parameters:
T
- the type parameter (should extendCustomResource
and implementNamespaced
)- Parameters:
apiTypeClass
- apiType classresyncPeriodInMillis
- resync period in milliseconds- Returns:
- the shared index informer
-
sharedIndexInformerForCustomResource
public <T extends CustomResource<?,?>> SharedIndexInformer<T> sharedIndexInformerForCustomResource(Class<T> apiTypeClass, long resyncPeriodInMillis)
Constructs and returns a shared index informer with resync period specified for custom resources. POJO- Type Parameters:
T
- the type parameter (should extendHasMetadata
and implementNamespaced
)- Parameters:
apiTypeClass
- apiType classresyncPeriodInMillis
- resync period in milliseconds- Returns:
- the shared index informer
-
sharedIndexInformerForCustomResource
public <T extends CustomResource<?,?>,L extends io.fabric8.kubernetes.api.model.KubernetesResourceList<T>> SharedIndexInformer<T> sharedIndexInformerForCustomResource(Class<T> apiTypeClass, Class<L> apiListTypeClass, long resyncPeriodInMillis)
Constructs and returns a shared index informer with resync period specified for custom resources. Note:It watches for events in ALL NAMESPACES.- Type Parameters:
T
- the type parameter (should extendHasMetadata
and implementNamespaced
)L
- the type's list parameter (should extendKubernetesResourceList
- Parameters:
apiTypeClass
- apiType classapiListTypeClass
- api list type classresyncPeriodInMillis
- resync period in milliseconds- Returns:
- the shared index informer
-
getExistingSharedIndexInformer
public <T> SharedIndexInformer<T> getExistingSharedIndexInformer(Class<T> apiTypeClass)
Gets existing shared index informer, return null if the requesting informer is never constructed. If there are multiple SharedIndexInformer objects corresponding to a Kubernetes resource, then it returns the first one- Type Parameters:
T
- type of API type- Parameters:
apiTypeClass
- API type class- Returns:
- SharedIndexInformer object
-
startAllRegisteredInformers
public void startAllRegisteredInformers()
Starts all registered informers.
-
stopAllRegisteredInformers
public void stopAllRegisteredInformers()
Stop all registered informers and shut down thread pool.
-
stopAllRegisteredInformers
public void stopAllRegisteredInformers(boolean shutDownThreadPool)
Stop all registered informers- Parameters:
shutDownThreadPool
- Whether to shut down thread pool or not.
-
addSharedInformerEventListener
public void addSharedInformerEventListener(SharedInformerEventListener event)
-
-