@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.Constructor and Description |
---|
MasterRoutePolicy() |
Modifier and Type | Method and Description |
---|---|
protected void |
doStart() |
protected void |
doStop() |
protected String |
getCamelClusterPath(String name) |
org.apache.camel.CamelContext |
getCamelContext() |
ContainerIdFactory |
getContainerIdFactory() |
org.apache.curator.framework.CuratorFramework |
getCurator() |
String |
getGroupName() |
int |
getMaximumConnectionTimeout() |
String |
getZkRoot() |
String |
getZooKeeperPassword() |
String |
getZooKeeperUrl() |
boolean |
isConnected() |
boolean |
isMaster() |
String |
lastEvent() |
protected Runnable |
onDisconnected() |
void |
onInit(org.apache.camel.Route route) |
protected Runnable |
onLockOwned() |
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 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
|
String |
slaves() |
String |
thisNode() |
getExceptionHandler, handleException, onExchangeBegin, onExchangeDone, onRemove, onResume, onStart, onStop, onSuspend, resumeOrStartConsumer, resumeRoute, setExceptionHandler, startConsumer, startRoute, stopConsumer, stopRoute, stopRoute, stopRouteAsync, suspendOrStopConsumer, suspendRoute, suspendRoute
public org.apache.camel.CamelContext getCamelContext()
getCamelContext
in interface org.apache.camel.CamelContextAware
public void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext
in interface org.apache.camel.CamelContextAware
public String getZkRoot()
public void setZkRoot(String zkRoot)
@ManagedAttribute(description="The name of the cluster group to use") public String getGroupName()
public void setGroupName(String groupName)
public ContainerIdFactory getContainerIdFactory()
public void setContainerIdFactory(ContainerIdFactory containerIdFactory)
public org.apache.curator.framework.CuratorFramework getCurator()
public void setCurator(org.apache.curator.framework.CuratorFramework curator)
@ManagedAttribute(description="Timeout in millis to use when connecting to the zookeeper ensemble") public int getMaximumConnectionTimeout()
public void setMaximumConnectionTimeout(int maximumConnectionTimeout)
@ManagedAttribute(description="The url for the zookeeper ensemble") public String getZooKeeperUrl()
public void setZooKeeperUrl(String zooKeeperUrl)
public String getZooKeeperPassword()
public void setZooKeeperPassword(String zooKeeperPassword)
@ManagedAttribute(description="Are we connected to ZooKeeper") public boolean isConnected()
@ManagedAttribute(description="Are we the master") public boolean isMaster()
@ManagedOperation(description="Information about all the slaves") public String slaves()
@ManagedOperation(description="Information about the last event in the cluster group") public String lastEvent()
@ManagedOperation(description="Information about this node") public String thisNode()
public void onInit(org.apache.camel.Route route)
onInit
in interface org.apache.camel.spi.RoutePolicy
onInit
in class org.apache.camel.support.RoutePolicySupport
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.RoutePolicySupport
Exception
protected void doStop() throws Exception
doStop
in class org.apache.camel.support.RoutePolicySupport
Exception
protected Runnable onLockOwned()
protected Runnable onDisconnected()
Apache Camel