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.HasCamelContext
,org.apache.camel.spi.HasId
,org.apache.camel.spi.IdAware
public class RebalancingCamelClusterService
extends Object
implements org.apache.camel.cluster.CamelPreemptiveClusterService
A
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).-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.camel.cluster.CamelClusterService
org.apache.camel.cluster.CamelClusterService.Selector
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.camel.CamelContext
protected org.apache.camel.cluster.CamelPreemptiveClusterService
protected final long
protected ScheduledExecutorService
Fields inherited from interface org.apache.camel.Ordered
HIGHEST, LOWEST
-
Constructor Summary
ConstructorsConstructorDescriptionRebalancingCamelClusterService
(org.apache.camel.CamelContext camelContext, org.apache.camel.cluster.CamelPreemptiveClusterService delegate, long periodMillis) RebalancingCamelClusterService
(org.apache.camel.cluster.CamelPreemptiveClusterService delegate, long periodMillis) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.camel.CamelContext
org.apache.camel.cluster.CamelPreemptiveClusterService
getId()
long
org.apache.camel.cluster.CamelPreemptiveClusterView
boolean
protected Integer
members()
protected void
rebalanceGroup
(List<String> partitions, int quota) protected void
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
void
start()
void
void
stop()
void
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, getOrder, unwrap
Methods inherited from interface org.apache.camel.spi.IdAware
setGeneratedId
Methods inherited from interface org.apache.camel.Service
build, close, init
-
Field Details
-
serializedExecutor
-
delegate
protected org.apache.camel.cluster.CamelPreemptiveClusterService delegate -
camelContext
protected org.apache.camel.CamelContext camelContext -
periodMillis
protected final long periodMillis
-
-
Constructor Details
-
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 Details
-
start
public void start()- Specified by:
start
in interfaceorg.apache.camel.Service
-
stop
public void stop()- Specified by:
stop
in 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() -
rebalanceGroup
-
setDisabled
-
owned
-
partitionList
-
members
-
getView
public org.apache.camel.cluster.CamelPreemptiveClusterView getView(String namespace) throws Exception - Specified by:
getView
in interfaceorg.apache.camel.cluster.CamelClusterService
- Specified by:
getView
in interfaceorg.apache.camel.cluster.CamelPreemptiveClusterService
- Throws:
Exception
-
releaseView
- Specified by:
releaseView
in interfaceorg.apache.camel.cluster.CamelClusterService
- Throws:
Exception
-
getNamespaces
- Specified by:
getNamespaces
in interfaceorg.apache.camel.cluster.CamelClusterService
-
startView
- Specified by:
startView
in interfaceorg.apache.camel.cluster.CamelClusterService
- Throws:
Exception
-
stopView
- Specified by:
stopView
in interfaceorg.apache.camel.cluster.CamelClusterService
- Throws:
Exception
-
isLeader
- Specified by:
isLeader
in interfaceorg.apache.camel.cluster.CamelClusterService
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContext
in interfaceorg.apache.camel.CamelContextAware
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
getCamelContext
in interfaceorg.apache.camel.spi.HasCamelContext
-
setId
- Specified by:
setId
in interfaceorg.apache.camel.spi.IdAware
-
getId
- Specified by:
getId
in interfaceorg.apache.camel.spi.HasId
-