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
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).
  • Field Details

    • serializedExecutor

      protected ScheduledExecutorService 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 interface org.apache.camel.Service
    • stop

      public void stop()
      Specified by:
      stop in interface org.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

      protected void rebalanceGroup(List<String> partitions, int quota)
    • setDisabled

      protected void setDisabled(String partition, boolean disabled)
    • owned

      protected List<String> owned(List<String> partitions)
    • partitionList

      protected List<String> partitionList()
    • members

      protected Integer members()
    • getView

      public org.apache.camel.cluster.CamelPreemptiveClusterView getView(String namespace) throws Exception
      Specified by:
      getView in interface org.apache.camel.cluster.CamelClusterService
      Specified by:
      getView in interface org.apache.camel.cluster.CamelPreemptiveClusterService
      Throws:
      Exception
    • releaseView

      public void releaseView(org.apache.camel.cluster.CamelClusterView view) throws Exception
      Specified by:
      releaseView in interface org.apache.camel.cluster.CamelClusterService
      Throws:
      Exception
    • getNamespaces

      public Collection<String> getNamespaces()
      Specified by:
      getNamespaces in interface org.apache.camel.cluster.CamelClusterService
    • startView

      public void startView(String namespace) throws Exception
      Specified by:
      startView in interface org.apache.camel.cluster.CamelClusterService
      Throws:
      Exception
    • stopView

      public void stopView(String namespace) throws Exception
      Specified by:
      stopView in interface org.apache.camel.cluster.CamelClusterService
      Throws:
      Exception
    • isLeader

      public boolean isLeader(String namespace)
      Specified by:
      isLeader in interface org.apache.camel.cluster.CamelClusterService
    • setCamelContext

      public void setCamelContext(org.apache.camel.CamelContext camelContext)
      Specified by:
      setCamelContext in interface org.apache.camel.CamelContextAware
    • getCamelContext

      public org.apache.camel.CamelContext getCamelContext()
      Specified by:
      getCamelContext in interface org.apache.camel.CamelContextAware
    • setId

      public void setId(String id)
      Specified by:
      setId in interface org.apache.camel.spi.IdAware
    • getId

      public String getId()
      Specified by:
      getId in interface org.apache.camel.spi.HasId