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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart()protected voiddoStop()protected StringgetCamelClusterPath(String name) org.apache.camel.CamelContextorg.apache.curator.framework.CuratorFrameworkintbooleanbooleanisMaster()protected RunnablevoidonInit(org.apache.camel.Route route) protected RunnablevoidsetCamelContext(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 ensemblevoidThe 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 ensembleslaves()thisNode()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, suspendRouteMethods 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, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods 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:
getCamelContextin interfaceorg.apache.camel.spi.HasCamelContext
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
getZkRoot
-
setZkRoot
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
-
setGroupName
The name of the cluster group to use -
getContainerIdFactory
-
setContainerIdFactory
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
-
setZooKeeperUrl
The url for the zookeeper ensemble -
getZooKeeperPassword
-
setZooKeeperPassword
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
-
lastEvent
@ManagedOperation(description="Information about the last event in the cluster group") public String lastEvent() -
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
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
onLockOwned
-
onDisconnected
-
getCamelClusterPath
-