-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make membership waiter block until leader commit is available
before executing the catchup algorithm At the moment we unnecessarily wait for up to 2 rounds because in the first round of catchup the leader commit is nearly always -1 since we go into this code path before the RAFT machinery is up and running. This commit introduces a job which blocks waiting for the leader commit to be -1. The code in MembershipWaiter#waitUntilCaughtUpMember relies on MembershipWaiterLifecycle to timeout if the leader commit is never discovered.
- Loading branch information
Mark Needham
authored and
Max Sumrall
committed
Oct 28, 2016
1 parent
51ccd5f
commit 7689b08
Showing
6 changed files
with
216 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
enterprise/core-edge/src/main/java/org/neo4j/coreedge/catchup/Sleeper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.coreedge.catchup; | ||
|
||
public interface Sleeper | ||
{ | ||
void sleep( long millis ); | ||
} |
36 changes: 36 additions & 0 deletions
36
enterprise/core-edge/src/main/java/org/neo4j/coreedge/catchup/ThreadSleeper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.coreedge.catchup; | ||
|
||
public class ThreadSleeper implements Sleeper | ||
{ | ||
@Override | ||
public void sleep( long millis ) | ||
{ | ||
try | ||
{ | ||
Thread.sleep( millis ); | ||
} | ||
catch ( InterruptedException ignored ) | ||
{ | ||
// ignore me | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...rprise/core-edge/src/main/java/org/neo4j/coreedge/raft/membership/LeaderCommitWaiter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.coreedge.raft.membership; | ||
|
||
import org.neo4j.coreedge.catchup.Sleeper; | ||
import org.neo4j.coreedge.raft.state.ReadableRaftState; | ||
|
||
public class LeaderCommitWaiter<MEMBER> | ||
{ | ||
private Sleeper sleeper; | ||
|
||
public LeaderCommitWaiter( Sleeper sleeper ) | ||
{ | ||
this.sleeper = sleeper; | ||
} | ||
|
||
public void waitMore() | ||
{ | ||
sleeper.sleep( 100 ); | ||
} | ||
|
||
public boolean keepWaiting( ReadableRaftState<MEMBER> raftState ) | ||
{ | ||
return raftState.leaderCommit() == -1; | ||
} | ||
} |
Empty file.