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.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.CamelContextAwareRoutePolicyto 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.
-
-
Constructor Summary
Constructors Constructor Description MasterRoutePolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoStart()protected voiddoStop()protected StringgetCamelClusterPath(String name)org.apache.camel.CamelContextgetCamelContext()ContainerIdFactorygetContainerIdFactory()org.apache.curator.framework.CuratorFrameworkgetCurator()StringgetGroupName()intgetMaximumConnectionTimeout()StringgetZkRoot()StringgetZooKeeperPassword()StringgetZooKeeperUrl()booleanisConnected()booleanisMaster()StringlastEvent()protected RunnableonDisconnected()voidonInit(org.apache.camel.Route route)protected RunnableonLockOwned()voidsetCamelContext(org.apache.camel.CamelContext camelContext)voidsetContainerIdFactory(ContainerIdFactory containerIdFactory)To use a custom ContainerIdFactory for creating container ids.voidsetCurator(org.apache.curator.framework.CuratorFramework curator)To use a custom configured CuratorFramework as connection to zookeeper ensemble.voidsetGroupName(String groupName)The name of the cluster group to usevoidsetMaximumConnectionTimeout(int maximumConnectionTimeout)Timeout in millis to use when connecting to the zookeeper ensemblevoidsetZkRoot(String zkRoot)The root path to use in zookeeper where information is stored which nodes are master/slave etc.voidsetZooKeeperPassword(String zooKeeperPassword)The password to use when connecting to the zookeeper ensemblevoidsetZooKeeperUrl(String zooKeeperUrl)The url for the zookeeper ensembleStringslaves()StringthisNode()-
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
-
-
-
-
Method Detail
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()
- Specified by:
getCamelContextin interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext)
- Specified by:
setCamelContextin interfaceorg.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:
onInitin interfaceorg.apache.camel.spi.RoutePolicy- Overrides:
onInitin classorg.apache.camel.support.RoutePolicySupport
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.RoutePolicySupport- Throws:
Exception
-
doStop
protected void doStop() throws Exception- Overrides:
doStopin classorg.apache.camel.support.RoutePolicySupport- Throws:
Exception
-
onLockOwned
protected Runnable onLockOwned()
-
onDisconnected
protected Runnable onDisconnected()
-
-