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.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
Modifier and TypeFieldDescriptionprotected KubernetesConfiguration
protected KubernetesLockConfiguration
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
Fields inherited from interface org.apache.camel.Ordered
HIGHEST, LOWEST
-
Constructor Summary
ConstructorDescriptionKubernetesClusterService
(org.apache.camel.CamelContext camelContext, KubernetesConfiguration configuration) KubernetesClusterService
(KubernetesConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToClusterLabels
(String key, String value) protected KubernetesClusterView
createView
(String namespace) Deprecated.double
long
long
long
protected KubernetesLockConfiguration
lockConfigWithGroupNameAndDefaults
(String groupName) void
setClusterLabels
(Map<String, String> clusterLabels) Set the labels used to identify the pods composing the cluster.protected KubernetesConfiguration
setConfigDefaults
(KubernetesConfiguration configuration, KubernetesLockConfiguration lockConfiguration) void
setConfigMapName
(String kubernetesResourceName) Deprecated.void
setConnectionTimeoutMillis
(Integer connectionTimeout) Connection timeout in milliseconds to use when making requests to the Kubernetes API server.void
setJitterFactor
(double jitterFactor) A jitter factor to apply in order to prevent all pods to call Kubernetes APIs in the same instant.void
setKubernetesNamespace
(String kubernetesNamespace) Set the name of the Kubernetes namespace containing the pods and the configmap (autodetected by default)void
setKubernetesResourceName
(String kubernetesResourceName) Set the name of the lease resource used to do optimistic locking (defaults to 'leaders').void
setLeaseDurationMillis
(long leaseDurationMillis) The default duration of the lease for the current leader.void
Set the lease resource type used in Kubernetes (defaults to 'Lease', from coordination.k8s.io).void
setMasterUrl
(String masterUrl) Set the URL of the Kubernetes master (read from Kubernetes client properties by default).void
setPodName
(String podName) Set the name of the current pod (autodetected from container host name by default).void
setRenewDeadlineMillis
(long renewDeadlineMillis) The deadline after which the leader must stop its services because it may have lost the leadership.void
setRetryPeriodMillis
(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, stopView
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.camel.cluster.CamelClusterService
getAttributes, getNamespaces, getOrder, isLeader, releaseView, startView, stopView, unwrap
Methods inherited from interface org.apache.camel.CamelContextAware
getCamelContext, setCamelContext
Methods inherited from interface org.apache.camel.spi.HasId
getId
Methods inherited from interface org.apache.camel.spi.IdAware
setGeneratedId, setId
Methods inherited from interface org.apache.camel.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods 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:
createView
in classorg.apache.camel.support.cluster.AbstractCamelClusterService<KubernetesClusterView>
- Throws:
Exception
-
getView
- Specified by:
getView
in interfaceorg.apache.camel.cluster.CamelClusterService
- Specified by:
getView
in interfaceorg.apache.camel.cluster.CamelPreemptiveClusterService
- Overrides:
getView
in 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()