Class RebalancingCamelClusterService

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
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.ShutdownableService, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.HasId, org.apache.camel.spi.IdAware, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

public class RebalancingCamelClusterService extends org.apache.camel.support.service.ServiceSupport 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

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.camel.CamelContext
     
    protected org.apache.camel.cluster.CamelPreemptiveClusterService
     
    protected final long
     
     

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING

    Fields inherited from interface org.apache.camel.Ordered

    HIGHEST, LOWEST
  • 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

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
     
    protected void
     
    org.apache.camel.CamelContext
     
    org.apache.camel.cluster.CamelPreemptiveClusterService
     
     
     
    long
     
    org.apache.camel.cluster.CamelPreemptiveClusterView
    getView(String namespace)
     
    boolean
    isLeader(String namespace)
     
    protected Integer
     
    protected List<String>
    owned(List<String> partitions)
     
    protected List<String>
     
    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
    startView(String namespace)
     
    void
    stopView(String namespace)
     

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, 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

    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, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • 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

    • doInit

      protected void doInit() throws Exception
      Overrides:
      doInit in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • 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.spi.HasCamelContext
    • 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