Class MasterRoutePolicy

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.RoutePolicySupport
org.apache.camel.component.zookeepermaster.policy.MasterRoutePolicy
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.RoutePolicy, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

@ManagedResource(description="Managed MasterRoutePolicy") public class MasterRoutePolicy extends org.apache.camel.support.RoutePolicySupport implements org.apache.camel.CamelContextAware
RoutePolicy to run the route in master/slave mode.

Important: Make sure to set the route to autoStartup=false as the route lifecycle is controlled by this route policy which will start/stop the route accordingly to being the master in the zookeeper cluster group.

  • Field Summary

    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
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
     
    protected String
     
    org.apache.camel.CamelContext
     
     
    org.apache.curator.framework.CuratorFramework
     
     
    int
     
     
     
     
    boolean
     
    boolean
     
     
    protected Runnable
     
    void
    onInit(org.apache.camel.Route route)
     
    protected Runnable
     
    void
    setCamelContext(org.apache.camel.CamelContext camelContext)
     
    void
    To use a custom ContainerIdFactory for creating container ids.
    void
    setCurator(org.apache.curator.framework.CuratorFramework curator)
    To use a custom configured CuratorFramework as connection to zookeeper ensemble.
    void
    setGroupName(String groupName)
    The name of the cluster group to use
    void
    setMaximumConnectionTimeout(int maximumConnectionTimeout)
    Timeout in millis to use when connecting to the zookeeper ensemble
    void
    setZkRoot(String zkRoot)
    The root path to use in zookeeper where information is stored which nodes are master/slave etc.
    void
    setZooKeeperPassword(String zooKeeperPassword)
    The password to use when connecting to the zookeeper ensemble
    void
    setZooKeeperUrl(String zooKeeperUrl)
    The url for the zookeeper ensemble
     
     

    Methods inherited from class org.apache.camel.support.RoutePolicySupport

    controller, getExceptionHandler, handleException, onExchangeBegin, onExchangeDone, onRemove, onResume, onStart, onStop, onSuspend, resumeOrStartConsumer, resumeRoute, setExceptionHandler, startConsumer, startRoute, stopConsumer, stopRoute, stopRoute, stopRouteAsync, suspendOrStopConsumer, suspendRoute, suspendRoute

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

    build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, 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.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
  • Constructor Details

    • MasterRoutePolicy

      public MasterRoutePolicy()
  • Method Details

    • getCamelContext

      public org.apache.camel.CamelContext getCamelContext()
      Specified by:
      getCamelContext in interface org.apache.camel.spi.HasCamelContext
    • setCamelContext

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

      public String getZkRoot()
    • setZkRoot

      public void setZkRoot(String zkRoot)
      The root path to use in zookeeper where information is stored which nodes are master/slave etc. Will by default use: /camel/zookeepermaster/clusters/master
    • getGroupName

      @ManagedAttribute(description="The name of the cluster group to use") public String getGroupName()
    • setGroupName

      public void setGroupName(String groupName)
      The name of the cluster group to use
    • getContainerIdFactory

      public ContainerIdFactory getContainerIdFactory()
    • setContainerIdFactory

      public void setContainerIdFactory(ContainerIdFactory containerIdFactory)
      To use a custom ContainerIdFactory for creating container ids.
    • getCurator

      public org.apache.curator.framework.CuratorFramework getCurator()
    • setCurator

      public void setCurator(org.apache.curator.framework.CuratorFramework curator)
      To use a custom configured CuratorFramework as connection to zookeeper ensemble.
    • getMaximumConnectionTimeout

      @ManagedAttribute(description="Timeout in millis to use when connecting to the zookeeper ensemble") public int getMaximumConnectionTimeout()
    • setMaximumConnectionTimeout

      public void setMaximumConnectionTimeout(int maximumConnectionTimeout)
      Timeout in millis to use when connecting to the zookeeper ensemble
    • getZooKeeperUrl

      @ManagedAttribute(description="The url for the zookeeper ensemble") public String getZooKeeperUrl()
    • setZooKeeperUrl

      public void setZooKeeperUrl(String zooKeeperUrl)
      The url for the zookeeper ensemble
    • getZooKeeperPassword

      public String getZooKeeperPassword()
    • setZooKeeperPassword

      public void setZooKeeperPassword(String zooKeeperPassword)
      The password to use when connecting to the zookeeper ensemble
    • isConnected

      @ManagedAttribute(description="Are we connected to ZooKeeper") public boolean isConnected()
    • isMaster

      @ManagedAttribute(description="Are we the master") public boolean isMaster()
    • slaves

      @ManagedOperation(description="Information about all the slaves") public String slaves()
    • lastEvent

      @ManagedOperation(description="Information about the last event in the cluster group") public String lastEvent()
    • thisNode

      @ManagedOperation(description="Information about this node") public String thisNode()
    • onInit

      public void onInit(org.apache.camel.Route route)
      Specified by:
      onInit in interface org.apache.camel.spi.RoutePolicy
      Overrides:
      onInit in class org.apache.camel.support.RoutePolicySupport
    • 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
    • onLockOwned

      protected Runnable onLockOwned()
    • onDisconnected

      protected Runnable onDisconnected()
    • getCamelClusterPath

      protected String getCamelClusterPath(String name)