public class RebalancingCamelClusterService extends Object implements org.apache.camel.cluster.CamelPreemptiveClusterService
RebalancingCamelClusterService
adds rebalancing capabilities to an underlying
CamelPreemptiveClusterService
. 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).Modifier and Type | Field and Description |
---|---|
protected org.apache.camel.CamelContext |
camelContext |
protected org.apache.camel.cluster.CamelPreemptiveClusterService |
delegate |
protected long |
periodMillis |
protected ScheduledExecutorService |
serializedExecutor |
Constructor and Description |
---|
RebalancingCamelClusterService(org.apache.camel.CamelContext camelContext,
org.apache.camel.cluster.CamelPreemptiveClusterService delegate,
long periodMillis) |
RebalancingCamelClusterService(org.apache.camel.cluster.CamelPreemptiveClusterService delegate,
long periodMillis) |
Modifier and Type | Method and Description |
---|---|
org.apache.camel.CamelContext |
getCamelContext() |
org.apache.camel.cluster.CamelPreemptiveClusterService |
getDelegate() |
String |
getId() |
Collection<String> |
getNamespaces() |
long |
getPeriodMillis() |
org.apache.camel.cluster.CamelPreemptiveClusterView |
getView(String namespace) |
boolean |
isLeader(String namespace) |
protected Integer |
members() |
protected List<String> |
owned(List<String> partitions) |
protected List<String> |
partitionList() |
protected void |
rebalanceGroup(List<String> partitions,
int quota) |
protected void |
reconcile() |
void |
releaseView(org.apache.camel.cluster.CamelClusterView view) |
void |
setCamelContext(org.apache.camel.CamelContext camelContext) |
void |
setDelegate(org.apache.camel.cluster.CamelPreemptiveClusterService delegate) |
protected void |
setDisabled(String partition,
boolean disabled) |
void |
setId(String id) |
void |
start() |
void |
startView(String namespace) |
void |
stop() |
void |
stopView(String namespace) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected ScheduledExecutorService serializedExecutor
protected org.apache.camel.cluster.CamelPreemptiveClusterService delegate
protected org.apache.camel.CamelContext camelContext
protected long periodMillis
public RebalancingCamelClusterService(org.apache.camel.cluster.CamelPreemptiveClusterService delegate, long periodMillis)
public RebalancingCamelClusterService(org.apache.camel.CamelContext camelContext, org.apache.camel.cluster.CamelPreemptiveClusterService delegate, long periodMillis)
public void start()
start
in interface org.apache.camel.Service
public void stop()
stop
in interface org.apache.camel.Service
public org.apache.camel.cluster.CamelPreemptiveClusterService getDelegate()
public long getPeriodMillis()
public void setDelegate(org.apache.camel.cluster.CamelPreemptiveClusterService delegate)
protected void reconcile()
protected void setDisabled(String partition, boolean disabled)
protected Integer members()
public org.apache.camel.cluster.CamelPreemptiveClusterView getView(String namespace) throws Exception
getView
in interface org.apache.camel.cluster.CamelClusterService
getView
in interface org.apache.camel.cluster.CamelPreemptiveClusterService
Exception
public void releaseView(org.apache.camel.cluster.CamelClusterView view) throws Exception
releaseView
in interface org.apache.camel.cluster.CamelClusterService
Exception
public Collection<String> getNamespaces()
getNamespaces
in interface org.apache.camel.cluster.CamelClusterService
public void startView(String namespace) throws Exception
startView
in interface org.apache.camel.cluster.CamelClusterService
Exception
public void stopView(String namespace) throws Exception
stopView
in interface org.apache.camel.cluster.CamelClusterService
Exception
public boolean isLeader(String namespace)
isLeader
in interface org.apache.camel.cluster.CamelClusterService
public void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext
in interface org.apache.camel.CamelContextAware
public org.apache.camel.CamelContext getCamelContext()
getCamelContext
in interface org.apache.camel.CamelContextAware
public void setId(String id)
setId
in interface org.apache.camel.spi.IdAware
public String getId()
getId
in interface org.apache.camel.spi.HasId
Apache Camel