Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Term, Vote and RaftLog file-based implementations use writeAll instea…
…d of write Previous implementations did not properly check the return value of write() calls, so half written entries were a possibility. This ensures that the complete buffer contents always end up on disk or failure is raised. Renames the previous Vote, Term and RaftLog tests to Contract tests to allow for file based, implementation specific testing.
- Loading branch information
1 parent
80d4838
commit 8d372cf
Showing
15 changed files
with
325 additions
and
44 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
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
40 changes: 40 additions & 0 deletions
40
.../core-edge/src/test/java/org/neo4j/coreedge/raft/log/NaiveDurableRaftLogContractTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
/* | |||
* Copyright (c) 2002-2015 "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.log; | |||
|
|||
import java.io.File; | |||
import java.io.IOException; | |||
|
|||
import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction; | |||
import org.neo4j.io.fs.FileSystemAbstraction; | |||
import org.neo4j.kernel.monitoring.Monitors; | |||
|
|||
public class NaiveDurableRaftLogContractTest extends RaftLogContractTest | |||
{ | |||
@Override | |||
public RaftLog createRaftLog() throws IOException | |||
{ | |||
FileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction(); | |||
File directory = new File( "raft-log" ); | |||
fileSystem.mkdir( directory ); | |||
|
|||
return new NaiveDurableRaftLog( fileSystem, directory, new DummyRaftableContentSerializer(), new Monitors() ); | |||
} | |||
} |
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
37 changes: 37 additions & 0 deletions
37
...e/core-edge/src/test/java/org/neo4j/coreedge/raft/state/DurableTermStoreContractTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,37 @@ | |||
/* | |||
* Copyright (c) 2002-2015 "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.state; | |||
|
|||
import java.io.File; | |||
|
|||
import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction; | |||
import org.neo4j.io.fs.FileSystemAbstraction; | |||
|
|||
public class DurableTermStoreContractTest extends TermStoreContractTest | |||
{ | |||
@Override | |||
public TermStore createTermStore() | |||
{ | |||
FileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction(); | |||
File directory = new File( "raft-log" ); | |||
fileSystem.mkdir( directory ); | |||
return new DurableTermStore( fileSystem, directory ); | |||
} | |||
} |
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
45 changes: 45 additions & 0 deletions
45
...e/core-edge/src/test/java/org/neo4j/coreedge/raft/state/DurableVoteStoreContractTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,45 @@ | |||
/* | |||
* Copyright (c) 2002-2015 "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.state; | |||
|
|||
import java.io.File; | |||
|
|||
import org.junit.Rule; | |||
|
|||
import org.neo4j.coreedge.server.CoreMember; | |||
import org.neo4j.io.fs.DefaultFileSystemAbstraction; | |||
import org.neo4j.io.fs.FileSystemAbstraction; | |||
import org.neo4j.test.TargetDirectory; | |||
|
|||
public class DurableVoteStoreContractTest extends VoteStoreContractTest | |||
{ | |||
@Rule | |||
public final TargetDirectory.TestDirectory testDirectory = TargetDirectory.testDirForTest( getClass() ); | |||
|
|||
@Override | |||
public VoteStore<CoreMember> createVoteStore() | |||
{ | |||
FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); | |||
File directory = testDirectory.directory( "raft-log" ); | |||
return new DurableVoteStore( fileSystem, directory ); | |||
} | |||
|
|||
|
|||
} |
Oops, something went wrong.