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).
-
-
Field Summary
Fields Modifier and Type Field Description protected KubernetesConfigurationconfigurationprotected KubernetesLockConfigurationlockConfiguration
-
Constructor Summary
Constructors Constructor Description KubernetesClusterService()KubernetesClusterService(org.apache.camel.CamelContext camelContext, KubernetesConfiguration configuration)KubernetesClusterService(KubernetesConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddToClusterLabels(String key, String value)protected KubernetesClusterViewcreateView(String namespace)Map<String,String>getClusterLabels()StringgetConfigMapName()Deprecated.IntegergetConnectionTimeoutMillis()doublegetJitterFactor()StringgetKubernetesNamespace()StringgetKubernetesResourceName()longgetLeaseDurationMillis()LeaseResourceTypegetLeaseResourceType()StringgetMasterUrl()StringgetPodName()longgetRenewDeadlineMillis()longgetRetryPeriodMillis()KubernetesClusterViewgetView(String namespace)protected 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.voidsetLeaseResourceType(LeaseResourceType type)Set 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, 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
-
-
-
-
Field Detail
-
configuration
protected KubernetesConfiguration configuration
-
lockConfiguration
protected KubernetesLockConfiguration lockConfiguration
-
-
Constructor Detail
-
KubernetesClusterService
public KubernetesClusterService()
-
KubernetesClusterService
public KubernetesClusterService(KubernetesConfiguration configuration)
-
KubernetesClusterService
public KubernetesClusterService(org.apache.camel.CamelContext camelContext, KubernetesConfiguration configuration)
-
-
Method Detail
-
createView
protected KubernetesClusterView createView(String namespace) throws Exception
- Specified by:
createViewin classorg.apache.camel.support.cluster.AbstractCamelClusterService<KubernetesClusterView>- Throws:
Exception
-
getView
public KubernetesClusterView getView(String namespace) throws Exception
- 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
protected KubernetesLockConfiguration lockConfigWithGroupNameAndDefaults(String groupName)
-
getMasterUrl
public String getMasterUrl()
-
setMasterUrl
public void setMasterUrl(String masterUrl)
Set the URL of the Kubernetes master (read from Kubernetes client properties by default).
-
getConnectionTimeoutMillis
public Integer getConnectionTimeoutMillis()
-
setConnectionTimeoutMillis
public void setConnectionTimeoutMillis(Integer connectionTimeout)
Connection timeout in milliseconds to use when making requests to the Kubernetes API server.
-
getKubernetesNamespace
public String getKubernetesNamespace()
-
setKubernetesNamespace
public void setKubernetesNamespace(String kubernetesNamespace)
Set the name of the Kubernetes namespace containing the pods and the configmap (autodetected by default)
-
getConfigMapName
@Deprecated public String getConfigMapName()
Deprecated.- Returns:
- the resource name
-
setConfigMapName
@Deprecated public void setConfigMapName(String kubernetesResourceName)
Deprecated.Set the name of the ConfigMap used to do optimistic locking (defaults to 'leaders').- Parameters:
kubernetesResourceName- the resource name
-
getLeaseResourceType
public LeaseResourceType getLeaseResourceType()
-
setLeaseResourceType
public void setLeaseResourceType(LeaseResourceType type)
Set the lease resource type used in Kubernetes (defaults to 'Lease', from coordination.k8s.io).
-
getKubernetesResourceName
public String getKubernetesResourceName()
-
setKubernetesResourceName
public void setKubernetesResourceName(String kubernetesResourceName)
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
public String getPodName()
-
setPodName
public void setPodName(String podName)
Set the name of the current pod (autodetected from container host name by default).
-
setClusterLabels
public void setClusterLabels(Map<String,String> clusterLabels)
Set the labels used to identify the pods composing the cluster.
-
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.
-
-