Class QuorumMaj
- java.lang.Object
-
- org.apache.zookeeper.server.quorum.flexible.QuorumMaj
-
- All Implemented Interfaces:
QuorumVerifier
- Direct Known Subclasses:
QuorumOracleMaj
public class QuorumMaj extends Object implements QuorumVerifier
This class implements a validator for majority quorums. The implementation is straightforward.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
half
-
Constructor Summary
Constructors Constructor Description QuorumMaj(Map<Long,QuorumPeer.QuorumServer> allMembers)
Defines a majority to avoid computing it every time.QuorumMaj(Properties props)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsQuorum(Set<Long> ackSet)
Verifies if a set is a majority.boolean
equals(Object o)
Map<Long,QuorumPeer.QuorumServer>
getAllMembers()
Map<Long,QuorumPeer.QuorumServer>
getObservingMembers()
long
getVersion()
Map<Long,QuorumPeer.QuorumServer>
getVotingMembers()
long
getWeight(long id)
Returns weight of 1 by default.int
hashCode()
void
setVersion(long ver)
String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.zookeeper.server.quorum.flexible.QuorumVerifier
askOracle, getNeedOracle, getOraclePath, overrideQuorumDecision, revalidateOutstandingProp, revalidateVoteset, updateNeedOracle
-
-
-
-
Constructor Detail
-
QuorumMaj
public QuorumMaj(Map<Long,QuorumPeer.QuorumServer> allMembers)
Defines a majority to avoid computing it every time.
-
QuorumMaj
public QuorumMaj(Properties props) throws QuorumPeerConfig.ConfigException
- Throws:
QuorumPeerConfig.ConfigException
-
-
Method Detail
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceQuorumVerifier
- Overrides:
equals
in classObject
-
getWeight
public long getWeight(long id)
Returns weight of 1 by default.- Specified by:
getWeight
in interfaceQuorumVerifier
- Parameters:
id
-
-
toString
public String toString()
- Specified by:
toString
in interfaceQuorumVerifier
- Overrides:
toString
in classObject
-
containsQuorum
public boolean containsQuorum(Set<Long> ackSet)
Verifies if a set is a majority. Assumes that ackSet contains acks only from votingMembers- Specified by:
containsQuorum
in interfaceQuorumVerifier
-
getAllMembers
public Map<Long,QuorumPeer.QuorumServer> getAllMembers()
- Specified by:
getAllMembers
in interfaceQuorumVerifier
-
getVotingMembers
public Map<Long,QuorumPeer.QuorumServer> getVotingMembers()
- Specified by:
getVotingMembers
in interfaceQuorumVerifier
-
getObservingMembers
public Map<Long,QuorumPeer.QuorumServer> getObservingMembers()
- Specified by:
getObservingMembers
in interfaceQuorumVerifier
-
getVersion
public long getVersion()
- Specified by:
getVersion
in interfaceQuorumVerifier
-
setVersion
public void setVersion(long ver)
- Specified by:
setVersion
in interfaceQuorumVerifier
-
-