public class ZooKeeperElection extends Object
ZooKeeperElection
uses the leader election capabilities of a
ZooKeeper cluster to control which nodes are enabled. It is typically used in
fail-over scenarios controlling identical instances of an application across
a cluster of Camel based servers. The election is configured with a 'top n' number of servers that should be marked as master, for a simple master/slave scenario this would be 1. Each instance will execute the election algorithm to obtain its position in the hierarchy of servers, if it is within the 'top n' servers then the node is enabled and isMaster() will return 'true'. If not it waits for a change in the leader hierarchy and then reruns this scenario to see if it is now in the top n.
All instances of the election must also be configured with the same path on the ZooKeeper cluster where the election will be carried out. It is good practice for this to indicate the application e.g. /someapplication/someroute/ note that these nodes should exist before using the election.
See for more on how Leader election is archived with ZooKeeper.
Constructor and Description |
---|
ZooKeeperElection(CamelContext camelContext,
String uri,
int enabledCount) |
ZooKeeperElection(ProducerTemplate producerTemplate,
CamelContext camelContext,
String uri,
int enabledCount) |
Modifier and Type | Method and Description |
---|---|
boolean |
addElectionWatcher(ElectionWatcher e) |
boolean |
isMaster() |
boolean |
removeElectionWatcher(ElectionWatcher o) |
public ZooKeeperElection(CamelContext camelContext, String uri, int enabledCount)
public ZooKeeperElection(ProducerTemplate producerTemplate, CamelContext camelContext, String uri, int enabledCount)
public boolean isMaster()
public boolean addElectionWatcher(ElectionWatcher e)
public boolean removeElectionWatcher(ElectionWatcher o)
Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.