Class QuorumHierarchical
- java.lang.Object
- 
- org.apache.zookeeper.server.quorum.flexible.QuorumHierarchical
 
- 
- All Implemented Interfaces:
- QuorumVerifier
 
 public class QuorumHierarchical extends Object implements QuorumVerifier This class implements a validator for hierarchical quorums. With this construction, zookeeper servers are split into disjoint groups, and each server has a weight. We obtain a quorum if we get more than half of the total weight of a group for a majority of groups. The configuration of quorums uses two parameters: group and weight. Groups are sets of ZooKeeper servers, and we set a group by passing a colon-separated list of server ids. It is also necessary to assign weights to server. Here is an example of a configuration that creates three groups and assigns a weight of 1 to each server: group.1=1:2:3 group.2=4:5:6 group.3=7:8:9 weight.1=1 weight.2=1 weight.3=1 weight.4=1 weight.5=1 weight.6=1 weight.7=1 weight.8=1 weight.9=1 Note that it is still necessary to define peers using the server keyword.
- 
- 
Constructor SummaryConstructors Constructor Description QuorumHierarchical(String filename)This constructor requires the quorum configuration to be declared in a separate file, and it takes the file as an input parameter.QuorumHierarchical(Properties qp)This constructor takes a set of properties.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsQuorum(Set<Long> set)Verifies if a given set is a quorum.booleanequals(Object o)Map<Long,QuorumPeer.QuorumServer>getAllMembers()Map<Long,QuorumPeer.QuorumServer>getObservingMembers()longgetVersion()Map<Long,QuorumPeer.QuorumServer>getVotingMembers()longgetWeight(long id)Returns the weight of a server.inthashCode()voidsetVersion(long ver)StringtoString()- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.apache.zookeeper.server.quorum.flexible.QuorumVerifieraskOracle, getNeedOracle, getOraclePath, overrideQuorumDecision, revalidateOutstandingProp, revalidateVoteset, updateNeedOracle
 
- 
 
- 
- 
- 
Constructor Detail- 
QuorumHierarchicalpublic QuorumHierarchical(String filename) throws QuorumPeerConfig.ConfigException This constructor requires the quorum configuration to be declared in a separate file, and it takes the file as an input parameter.- Throws:
- QuorumPeerConfig.ConfigException
 
 - 
QuorumHierarchicalpublic QuorumHierarchical(Properties qp) throws QuorumPeerConfig.ConfigException This constructor takes a set of properties. We use it in the unit test for this feature.- Throws:
- QuorumPeerConfig.ConfigException
 
 
- 
 - 
Method Detail- 
equalspublic boolean equals(Object o) - Specified by:
- equalsin interface- QuorumVerifier
- Overrides:
- equalsin class- Object
 
 - 
getWeightpublic long getWeight(long id) Returns the weight of a server.- Specified by:
- getWeightin interface- QuorumVerifier
- Parameters:
- id-
 
 - 
getAllMemberspublic Map<Long,QuorumPeer.QuorumServer> getAllMembers() - Specified by:
- getAllMembersin interface- QuorumVerifier
 
 - 
toStringpublic String toString() - Specified by:
- toStringin interface- QuorumVerifier
- Overrides:
- toStringin class- Object
 
 - 
containsQuorumpublic boolean containsQuorum(Set<Long> set) Verifies if a given set is a quorum.- Specified by:
- containsQuorumin interface- QuorumVerifier
 
 - 
getVotingMemberspublic Map<Long,QuorumPeer.QuorumServer> getVotingMembers() - Specified by:
- getVotingMembersin interface- QuorumVerifier
 
 - 
getObservingMemberspublic Map<Long,QuorumPeer.QuorumServer> getObservingMembers() - Specified by:
- getObservingMembersin interface- QuorumVerifier
 
 - 
getVersionpublic long getVersion() - Specified by:
- getVersionin interface- QuorumVerifier
 
 - 
setVersionpublic void setVersion(long ver) - Specified by:
- setVersionin interface- QuorumVerifier
 
 
- 
 
-