[
https://issues.apache.org/jira/browse/ZOOKEEPER-1807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13968654#comment-13968654
]
Raul Gutierrez Segales commented on ZOOKEEPER-1807:
---------------------------------------------------
Sorry guys - I totally mixed things up. FWIW, this is what we've been using for
a couple of months now:
{noformat}
diff --git
a/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java
b/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderEle
index 9876c3d..38ae999 100644
--- a/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java
+++ b/src/java/main/org/apache/zookeeper/server/quorum/FastLeaderElection.java
@@ -582,7 +582,7 @@ public class FastLeaderElection implements Election {
* Send notifications to all peers upon a change in our vote
*/
private void sendNotifications() {
- for (long sid : self.getAllKnownServerIds()) {
+ for (long sid : self.getCurrentAndNextConfigVoters()) {
QuorumVerifier qv = self.getQuorumVerifier();
ToSend notmsg = new ToSend(ToSend.mType.notification,
proposedLeader,
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java
b/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java
index 8926a82..06cf7d4 100644
--- a/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java
+++ b/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java
@@ -1112,12 +1112,12 @@ public class QuorumPeer extends Thread implements
QuorumStats.Provider {
return getQuorumVerifier().getObservingMembers();
}
- public synchronized Set<Long> getAllKnownServerIds(){
- Set<Long> tmp = new
HashSet<Long>(getQuorumVerifier().getAllMembers().keySet());
+ public synchronized Set<Long> getCurrentAndNextConfigVoters(){
+ Set<Long> voterIds = new
HashSet<Long>(getQuorumVerifier().getVotingMembers().keySet());
if (getLastSeenQuorumVerifier()!=null) {
- tmp.addAll(getLastSeenQuorumVerifier().getAllMembers().keySet());
+
voterIds.addAll(getLastSeenQuorumVerifier().getVotingMembers().keySet());
}
- return tmp;
+ return voterIds;
}
/**
{noformat}
> Observers spam each other creating connections to the election addr
> -------------------------------------------------------------------
>
> Key: ZOOKEEPER-1807
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1807
> Project: ZooKeeper
> Issue Type: Bug
> Reporter: Raul Gutierrez Segales
> Assignee: Alexander Shraer
> Priority: Blocker
> Fix For: 3.5.0
>
> Attachments: ZOOKEEPER-1807-alex.patch, ZOOKEEPER-1807-ver2.patch,
> ZOOKEEPER-1807-ver3.patch, ZOOKEEPER-1807-ver4.patch,
> ZOOKEEPER-1807-ver5.patch, ZOOKEEPER-1807.patch, notifications-loop.png
>
>
> Hey [~shralex],
> I noticed today that my Observers are spamming each other trying to open
> connections to the election port. I've got tons of these:
> {noformat}
> 2013-11-01 22:19:45,819 - DEBUG [WorkerSender[myid=13]] - There is a
> connection already for server 9
> 2013-11-01 22:19:45,819 - DEBUG [WorkerSender[myid=13]] - There is a
> connection already for server 10
> 2013-11-01 22:19:45,819 - DEBUG [WorkerSender[myid=13]] - There is a
> connection already for server 6
> 2013-11-01 22:19:45,819 - DEBUG [WorkerSender[myid=13]] - There is a
> connection already for server 12
> 2013-11-01 22:19:45,819 - DEBUG [WorkerSender[myid=13]] - There is a
> connection already for server 14
> {noformat}
> and so and so on ad nauseam.
> Now, looking around I found this inside FastLeaderElection.java from when you
> committed ZOOKEEPER-107:
> {noformat}
> private void sendNotifications() {
> - for (QuorumServer server : self.getVotingView().values()) {
> - long sid = server.id;
> -
> + for (long sid : self.getAllKnownServerIds()) {
> + QuorumVerifier qv = self.getQuorumVerifier();
> {noformat}
> Is that really desired? I suspect that is what's causing Observers to try to
> connect to each other (as opposed as just connecting to participants). I'll
> give it a try now and let you know. (Also, we use observer ids that are > 0,
> and I saw some parts of the code that might not deal with that assumption -
> so it could be that too..).
--
This message was sent by Atlassian JIRA
(v6.2#6252)