Class KubernetesClusterService
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.cluster.AbstractCamelClusterService<KubernetesClusterView>
org.apache.camel.component.kubernetes.cluster.KubernetesClusterService
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,org.apache.camel.cluster.CamelClusterService,org.apache.camel.cluster.CamelPreemptiveClusterService,org.apache.camel.Ordered,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.HasCamelContext,org.apache.camel.spi.HasId,org.apache.camel.spi.IdAware,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
@DeferredContextBinding
public class KubernetesClusterService
extends org.apache.camel.support.cluster.AbstractCamelClusterService<KubernetesClusterView>
implements org.apache.camel.cluster.CamelPreemptiveClusterService
A Kubernetes based cluster service leveraging Kubernetes optimistic locks on resources (specifically ConfigMaps).
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.camel.cluster.CamelClusterService
org.apache.camel.cluster.CamelClusterService.Selector -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected KubernetesConfigurationprotected KubernetesLockConfigurationFields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDINGFields inherited from interface org.apache.camel.Ordered
HIGHEST, LOWEST -
Constructor Summary
ConstructorsConstructorDescriptionKubernetesClusterService(org.apache.camel.CamelContext camelContext, KubernetesConfiguration configuration) KubernetesClusterService(KubernetesConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToClusterLabels(String key, String value) protected KubernetesClusterViewcreateView(String namespace) Deprecated.doublelonglonglongprotected KubernetesLockConfigurationlockConfigWithGroupNameAndDefaults(String groupName) voidsetClusterLabels(Map<String, String> clusterLabels) Set the labels used to identify the pods composing the cluster.protected KubernetesConfigurationsetConfigDefaults(KubernetesConfiguration configuration, KubernetesLockConfiguration lockConfiguration) voidsetConfigMapName(String kubernetesResourceName) Deprecated.voidsetConnectionTimeoutMillis(Integer connectionTimeout) Connection timeout in milliseconds to use when making requests to the Kubernetes API server.voidsetJitterFactor(double jitterFactor) A jitter factor to apply in order to prevent all pods to call Kubernetes APIs in the same instant.voidsetKubernetesNamespace(String kubernetesNamespace) Set the name of the Kubernetes namespace containing the pods and the configmap (autodetected by default)voidsetKubernetesResourceName(String kubernetesResourceName) Set the name of the lease resource used to do optimistic locking (defaults to 'leaders').voidsetLeaseDurationMillis(long leaseDurationMillis) The default duration of the lease for the current leader.voidSet the lease resource type used in Kubernetes (defaults to 'Lease', from coordination.k8s.io).voidsetMasterUrl(String masterUrl) Set the URL of the Kubernetes master (read from Kubernetes client properties by default).voidsetPodName(String podName) Set the name of the current pod (autodetected from container host name by default).voidsetRenewDeadlineMillis(long renewDeadlineMillis) The deadline after which the leader must stop its services because it may have lost the leadership.voidsetRetryPeriodMillis(long retryPeriodMillis) The time between two subsequent attempts to check and acquire the leadership.Methods inherited from class org.apache.camel.support.cluster.AbstractCamelClusterService
doStart, doStop, getAttributes, getCamelContext, getId, getNamespaces, getOrder, isLeader, releaseView, setAttribute, setAttributes, setCamelContext, setId, setOrder, startView, stopViewMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.cluster.CamelClusterService
getAttributes, getNamespaces, getOrder, isLeader, releaseView, startView, stopView, unwrapMethods inherited from interface org.apache.camel.CamelContextAware
setCamelContextMethods inherited from interface org.apache.camel.spi.HasCamelContext
getCamelContextMethods inherited from interface org.apache.camel.spi.HasId
getIdMethods inherited from interface org.apache.camel.spi.IdAware
setGeneratedId, setIdMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
configuration
-
lockConfiguration
-
-
Constructor Details
-
KubernetesClusterService
public KubernetesClusterService() -
KubernetesClusterService
-
KubernetesClusterService
public KubernetesClusterService(org.apache.camel.CamelContext camelContext, KubernetesConfiguration configuration)
-
-
Method Details
-
createView
- Specified by:
createViewin classorg.apache.camel.support.cluster.AbstractCamelClusterService<KubernetesClusterView>- Throws:
Exception
-
getView
- Specified by:
getViewin interfaceorg.apache.camel.cluster.CamelClusterService- Specified by:
getViewin interfaceorg.apache.camel.cluster.CamelPreemptiveClusterService- Overrides:
getViewin classorg.apache.camel.support.cluster.AbstractCamelClusterService<KubernetesClusterView>- Throws:
Exception
-
setConfigDefaults
protected KubernetesConfiguration setConfigDefaults(KubernetesConfiguration configuration, KubernetesLockConfiguration lockConfiguration) -
lockConfigWithGroupNameAndDefaults
-
getMasterUrl
-
setMasterUrl
Set the URL of the Kubernetes master (read from Kubernetes client properties by default). -
getConnectionTimeoutMillis
-
setConnectionTimeoutMillis
Connection timeout in milliseconds to use when making requests to the Kubernetes API server. -
getKubernetesNamespace
-
setKubernetesNamespace
Set the name of the Kubernetes namespace containing the pods and the configmap (autodetected by default) -
getConfigMapName
Deprecated.- Returns:
- the resource name
-
setConfigMapName
Deprecated.Set the name of the ConfigMap used to do optimistic locking (defaults to 'leaders').- Parameters:
kubernetesResourceName- the resource name
-
getLeaseResourceType
-
setLeaseResourceType
Set the lease resource type used in Kubernetes (defaults to 'Lease', from coordination.k8s.io). -
getKubernetesResourceName
-
setKubernetesResourceName
Set the name of the lease resource used to do optimistic locking (defaults to 'leaders'). Resource name is used as prefix when the underlying Kubernetes resource can mange a single lock. -
getPodName
-
setPodName
Set the name of the current pod (autodetected from container host name by default). -
getClusterLabels
-
setClusterLabels
Set the labels used to identify the pods composing the cluster. -
addToClusterLabels
-
getJitterFactor
public double getJitterFactor() -
setJitterFactor
public void setJitterFactor(double jitterFactor) A jitter factor to apply in order to prevent all pods to call Kubernetes APIs in the same instant. -
getLeaseDurationMillis
public long getLeaseDurationMillis() -
setLeaseDurationMillis
public void setLeaseDurationMillis(long leaseDurationMillis) The default duration of the lease for the current leader. -
getRenewDeadlineMillis
public long getRenewDeadlineMillis() -
setRenewDeadlineMillis
public void setRenewDeadlineMillis(long renewDeadlineMillis) The deadline after which the leader must stop its services because it may have lost the leadership. -
getRetryPeriodMillis
public long getRetryPeriodMillis() -
setRetryPeriodMillis
public void setRetryPeriodMillis(long retryPeriodMillis) The time between two subsequent attempts to check and acquire the leadership. It is randomized using the jitter factor.
-
getKubernetesResourceName()