Last active
December 31, 2015 01:29
-
-
Save mgodave/7914212 to your computer and use it in GitHub Desktop.
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
public class Test implements StateMachine { | |
@Override | |
public void applyOperation(@Nonnull ByteBuffer entry) { | |
System.out.println(entry.getLong()); | |
} | |
public static void main(String... args) throws Exception { | |
ClusterConfig config = ClusterConfig.from( | |
Replica.fromString("localhost:10000"), // local | |
Replica.fromString("localhost:10001"), // remote | |
Replica.fromString("localhost:10002") // remote | |
); | |
File logDir = new File(args[0]); | |
logDir.mkdir(); | |
RaftService raft = | |
RaftService.newBuilder(config) | |
.logDir(logDir) | |
.timeout(300) | |
.build(new Test()); | |
raft.startAsync().awaitRunning(); | |
for (int i = 0; i < 10; i++) { | |
raft.commit(new byte[] {'O', '_', 'o'}).get(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment