Package org.apache.camel.support.cluster
Class RebalancingCamelClusterService
- java.lang.Object
-
- org.apache.camel.support.cluster.RebalancingCamelClusterService
-
- 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.spi.HasId,org.apache.camel.spi.IdAware
public class RebalancingCamelClusterService extends Object implements org.apache.camel.cluster.CamelPreemptiveClusterService
ARebalancingCamelClusterServiceadds rebalancing capabilities to an underlyingCamelPreemptiveClusterService. Each view is treated as a partition by this cluster service and it makes sure that all services belonging to the cluster own a balanced number of partitions (same number or difference at most 1 when not possible).
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.camel.CamelContextcamelContextprotected org.apache.camel.cluster.CamelPreemptiveClusterServicedelegateprotected longperiodMillisprotected ScheduledExecutorServiceserializedExecutor
-
Constructor Summary
Constructors Constructor Description RebalancingCamelClusterService(org.apache.camel.CamelContext camelContext, org.apache.camel.cluster.CamelPreemptiveClusterService delegate, long periodMillis)RebalancingCamelClusterService(org.apache.camel.cluster.CamelPreemptiveClusterService delegate, long periodMillis)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.camel.CamelContextgetCamelContext()org.apache.camel.cluster.CamelPreemptiveClusterServicegetDelegate()StringgetId()Collection<String>getNamespaces()longgetPeriodMillis()org.apache.camel.cluster.CamelPreemptiveClusterViewgetView(String namespace)booleanisLeader(String namespace)protected Integermembers()protected List<String>owned(List<String> partitions)protected List<String>partitionList()protected voidrebalanceGroup(List<String> partitions, int quota)protected voidreconcile()voidreleaseView(org.apache.camel.cluster.CamelClusterView view)voidsetCamelContext(org.apache.camel.CamelContext camelContext)voidsetDelegate(org.apache.camel.cluster.CamelPreemptiveClusterService delegate)protected voidsetDisabled(String partition, boolean disabled)voidsetId(String id)voidstart()voidstartView(String namespace)voidstop()voidstopView(String namespace)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
serializedExecutor
protected ScheduledExecutorService serializedExecutor
-
delegate
protected org.apache.camel.cluster.CamelPreemptiveClusterService delegate
-
camelContext
protected org.apache.camel.CamelContext camelContext
-
periodMillis
protected long periodMillis
-
-
Constructor Detail
-
RebalancingCamelClusterService
public RebalancingCamelClusterService(org.apache.camel.cluster.CamelPreemptiveClusterService delegate, long periodMillis)
-
RebalancingCamelClusterService
public RebalancingCamelClusterService(org.apache.camel.CamelContext camelContext, org.apache.camel.cluster.CamelPreemptiveClusterService delegate, long periodMillis)
-
-
Method Detail
-
start
public void start()
- Specified by:
startin interfaceorg.apache.camel.Service
-
stop
public void stop()
- Specified by:
stopin interfaceorg.apache.camel.Service
-
getDelegate
public org.apache.camel.cluster.CamelPreemptiveClusterService getDelegate()
-
getPeriodMillis
public long getPeriodMillis()
-
setDelegate
public void setDelegate(org.apache.camel.cluster.CamelPreemptiveClusterService delegate)
-
reconcile
protected void reconcile()
-
setDisabled
protected void setDisabled(String partition, boolean disabled)
-
members
protected Integer members()
-
getView
public org.apache.camel.cluster.CamelPreemptiveClusterView getView(String namespace) throws Exception
- Specified by:
getViewin interfaceorg.apache.camel.cluster.CamelClusterService- Specified by:
getViewin interfaceorg.apache.camel.cluster.CamelPreemptiveClusterService- Throws:
Exception
-
releaseView
public void releaseView(org.apache.camel.cluster.CamelClusterView view) throws Exception- Specified by:
releaseViewin interfaceorg.apache.camel.cluster.CamelClusterService- Throws:
Exception
-
getNamespaces
public Collection<String> getNamespaces()
- Specified by:
getNamespacesin interfaceorg.apache.camel.cluster.CamelClusterService
-
startView
public void startView(String namespace) throws Exception
- Specified by:
startViewin interfaceorg.apache.camel.cluster.CamelClusterService- Throws:
Exception
-
stopView
public void stopView(String namespace) throws Exception
- Specified by:
stopViewin interfaceorg.apache.camel.cluster.CamelClusterService- Throws:
Exception
-
isLeader
public boolean isLeader(String namespace)
- Specified by:
isLeaderin interfaceorg.apache.camel.cluster.CamelClusterService
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()
- Specified by:
getCamelContextin interfaceorg.apache.camel.CamelContextAware
-
setId
public void setId(String id)
- Specified by:
setIdin interfaceorg.apache.camel.spi.IdAware
-
getId
public String getId()
- Specified by:
getIdin interfaceorg.apache.camel.spi.HasId
-
-