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 void
doStart()
protected void
doStop()
protected String
getCamelClusterPath
(String name) org.apache.camel.CamelContext
org.apache.curator.framework.CuratorFramework
int
boolean
boolean
isMaster()
protected Runnable
void
onInit
(org.apache.camel.Route route) protected Runnable
void
setCamelContext
(org.apache.camel.CamelContext camelContext) void
setContainerIdFactory
(ContainerIdFactory containerIdFactory) 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 usevoid
setMaximumConnectionTimeout
(int maximumConnectionTimeout) Timeout in millis to use when connecting to the zookeeper ensemblevoid
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 ensemblevoid
setZooKeeperUrl
(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, 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 interfaceorg.apache.camel.spi.HasCamelContext
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContext
in 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:
onInit
in interfaceorg.apache.camel.spi.RoutePolicy
- Overrides:
onInit
in classorg.apache.camel.support.RoutePolicySupport
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
onLockOwned
-
onDisconnected
-
getCamelClusterPath
-