Class MasterRoutePolicy

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Service, org.apache.camel.ShutdownableService, 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 Detail

      • MasterRoutePolicy

        public MasterRoutePolicy()
    • Method Detail

      • getCamelContext

        public org.apache.camel.CamelContext getCamelContext()
        Specified by:
        getCamelContext in interface org.apache.camel.CamelContextAware
      • 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
      • 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.RoutePolicySupport
        Throws:
        Exception
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.RoutePolicySupport
        Throws:
        Exception
      • onLockOwned

        protected Runnable onLockOwned()
      • onDisconnected

        protected Runnable onDisconnected()
      • getCamelClusterPath

        protected String getCamelClusterPath​(String name)