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.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
public class KubernetesClusterService extends org.apache.camel.support.cluster.AbstractCamelClusterService<KubernetesClusterView>
A Kubernetes based cluster service leveraging Kubernetes optimistic locks on resources (specifically ConfigMaps).
-
-
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 Modifier and Type Method Description voidaddToClusterLabels(String key, String value)protected KubernetesClusterViewcreateView(String namespace)Map<String,String>getClusterLabels()StringgetConfigMapName()IntegergetConnectionTimeoutMillis()doublegetJitterFactor()StringgetKubernetesNamespace()longgetLeaseDurationMillis()StringgetMasterUrl()StringgetPodName()longgetRenewDeadlineMillis()longgetRetryPeriodMillis()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 configMapName)Set the name of the ConfigMap used to do optimistic locking (defaults to 'leaders').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)voidsetLeaseDurationMillis(long leaseDurationMillis)The default duration of the lease for the current leader.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, getView, 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
-
-
-
-
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
-
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
public String getConfigMapName()
-
setConfigMapName
public void setConfigMapName(String configMapName)
Set the name of the ConfigMap used to do optimistic locking (defaults to 'leaders').
-
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.
-
-