Java Code Examples for org.jgroups.util.Util#createRandomAddress()
The following examples show how to use
org.jgroups.util.Util#createRandomAddress() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppendEntriesTest.java From jgroups-raft with Apache License 2.0 | 6 votes |
public void testRAFTPaperAppendOnLeader() throws Exception { Address leader=Util.createRandomAddress("A"); initB(); RaftImpl impl=getImpl(b); Log log=impl.raft().log(); byte[] buf=new byte[10]; append(impl, 1, 0, new LogEntry(1, buf), leader, 1); append(impl, 2, 1, new LogEntry(1, buf), leader, 1); append(impl, 3, 1, new LogEntry(1, buf), leader, 1); append(impl, 4, 1, new LogEntry(4, buf), leader, 1); append(impl, 5, 4, new LogEntry(4, buf), leader, 1); append(impl, 6, 4, new LogEntry(5, buf), leader, 1); append(impl, 7, 5, new LogEntry(5, buf), leader, 1); append(impl, 8, 5, new LogEntry(6, buf), leader, 1); append(impl, 9, 6, new LogEntry(6, buf), leader, 1); append(impl, 10, 6, new LogEntry(6, buf), leader, 10); AppendResult result=append(impl, 11, 6, new LogEntry(6, buf), leader, 1); assertTrue(result.isSuccess()); assertEquals(result.getIndex(), 11); assertLogIndices(log, 11, 10, 6); }
Example 2
Source File: AppendEntriesTest.java From jgroups-raft with Apache License 2.0 | 6 votes |
public void testRAFTPaperScenarioA() throws Exception { Address leader=Util.createRandomAddress("A"); initB(); RaftImpl impl=getImpl(b); Log log=impl.raft().log(); byte[] buf=new byte[10]; append(impl, 1, 0, new LogEntry(1, buf), leader, 1); append(impl, 2, 1, new LogEntry(1, buf), leader, 1); append(impl, 3, 1, new LogEntry(1, buf), leader, 1); append(impl, 4, 1, new LogEntry(4, buf), leader, 1); append(impl, 5, 4, new LogEntry(4, buf), leader, 1); append(impl, 6, 4, new LogEntry(5, buf), leader, 1); append(impl, 7, 5, new LogEntry(5, buf), leader, 1); append(impl, 8, 5, new LogEntry(6, buf), leader, 1); append(impl, 9, 6, new LogEntry(6, buf), leader, 9); AppendResult result = append(impl, 11, 6, new LogEntry(6, buf), leader, 9); assertFalse(result.isSuccess()); assertEquals(result.getIndex(), 9); assertLogIndices(log, 9, 9, 6); }
Example 3
Source File: AppendEntriesTest.java From jgroups-raft with Apache License 2.0 | 6 votes |
public void testRAFTPaperScenarioC() throws Exception { Address leader=Util.createRandomAddress("A"); initB(); RaftImpl impl=getImpl(b); Log log=impl.raft().log(); byte[] buf=new byte[10]; append(impl, 1, 0, new LogEntry(1, buf), leader, 1); append(impl, 2, 1, new LogEntry(1, buf), leader, 1); append(impl, 3, 1, new LogEntry(1, buf), leader, 1); append(impl, 4, 1, new LogEntry(4, buf), leader, 1); append(impl, 5, 4, new LogEntry(4, buf), leader, 1); append(impl, 6, 4, new LogEntry(5, buf), leader, 1); append(impl, 7, 5, new LogEntry(5, buf), leader, 1); append(impl, 8, 5, new LogEntry(6, buf), leader, 1); append(impl, 9, 6, new LogEntry(6, buf), leader, 1); append(impl, 10, 6, new LogEntry(6, buf), leader, 1); append(impl, 11, 6, new LogEntry(6, buf), leader, 11); // Overwrites existing entry; does *not* advance last_applied in log AppendResult result=append(impl, 11, 6, new LogEntry(6, buf), leader, 11); assertTrue(result.isSuccess()); assertEquals(result.getIndex(), 11); assertLogIndices(log, 11, 11, 6); }
Example 4
Source File: AppendEntriesTest.java From jgroups-raft with Apache License 2.0 | 6 votes |
public void testRAFTPaperScenarioD() throws Exception { Address leader=Util.createRandomAddress("A"); initB(); RaftImpl impl=getImpl(b); Log log=impl.raft().log(); byte[] buf=new byte[10]; append(impl, 1, 0, new LogEntry(1, buf), leader, 1); append(impl, 2, 1, new LogEntry(1, buf), leader, 1); append(impl, 3, 1, new LogEntry(1, buf), leader, 1); append(impl, 4, 1, new LogEntry(4, buf), leader, 1); append(impl, 5, 4, new LogEntry(4, buf), leader, 1); append(impl, 6, 4, new LogEntry(5, buf), leader, 1); append(impl, 7, 5, new LogEntry(5, buf), leader, 1); append(impl, 8, 5, new LogEntry(6, buf), leader, 1); append(impl, 9, 6, new LogEntry(6, buf), leader, 1); append(impl, 10, 6, new LogEntry(6, buf), leader, 1); append(impl, 11, 6, new LogEntry(7, buf), leader, 1); append(impl, 12, 7, new LogEntry(7, buf), leader, 12); AppendResult result=append(impl, buf, leader, 10, 6, 8, 12); assertTrue(result.isSuccess()); assertEquals(result.getIndex(), 11); assertLogIndices(log, 11, 11, 8); }
Example 5
Source File: AppendEntriesTest.java From jgroups-raft with Apache License 2.0 | 6 votes |
public void testRAFTPaperScenarioE() throws Exception { Address leader=Util.createRandomAddress("A"); initB(); RaftImpl impl=getImpl(b); Log log=impl.raft().log(); byte[] buf=new byte[10]; append(impl, 1, 0, new LogEntry(1, buf), leader, 1); append(impl, 2, 1, new LogEntry(1, buf), leader, 1); append(impl, 3, 1, new LogEntry(1, buf), leader, 1); append(impl, 4, 1, new LogEntry(4, buf), leader, 1); append(impl, 5, 4, new LogEntry(4, buf), leader, 1); append(impl, 6, 4, new LogEntry(4, buf), leader, 1); append(impl, 7, 4, new LogEntry(4, buf), leader, 7); AppendResult result=append(impl, 11, 6, new LogEntry(6, buf), leader, 7); assertFalse(result.isSuccess()); assertEquals(result.getIndex(), 7); assertLogIndices(log, 7, 7, 4); }
Example 6
Source File: AppendEntriesTest.java From jgroups-raft with Apache License 2.0 | 6 votes |
public void testRAFTPaperScenarioF() throws Exception { Address leader=Util.createRandomAddress("A"); initB(); RaftImpl impl=getImpl(b); Log log=impl.raft().log(); byte[] buf=new byte[10]; append(impl, 1, 0, new LogEntry(1, buf), leader, 1); append(impl, 2, 1, new LogEntry(1, buf), leader, 1); append(impl, 3, 1, new LogEntry(1, buf), leader, 1); append(impl, 4, 1, new LogEntry(2, buf), leader, 1); append(impl, 5, 2, new LogEntry(2, buf), leader, 1); append(impl, 6, 2, new LogEntry(2, buf), leader, 1); append(impl, 7, 2, new LogEntry(3, buf), leader, 1); append(impl, 8, 3, new LogEntry(3, buf), leader, 1); append(impl, 9, 3, new LogEntry(3, buf), leader, 1); append(impl, 10, 3, new LogEntry(3, buf), leader, 1); append(impl, 11, 3, new LogEntry(3, buf), leader, 11); AppendResult result=append(impl, 11, 6, new LogEntry(6, buf), leader, 11); assertFalse(result.isSuccess()); assertEquals(result.getIndex(), 7); assertLogIndices(log, 11, 11, 3); }
Example 7
Source File: LogTest.java From jgroups-raft with Apache License 2.0 | 5 votes |
public void testFields(Log log) throws Exception { Address addr=Util.createRandomAddress("A"); this.log=log; log.init(filename, null); log.currentTerm(22); int current_term=log.currentTerm(); assertEquals(current_term, 22); log.votedFor(addr); Address voted_for=log.votedFor(); assertEquals(addr, voted_for); log.close(); log.init(filename, null); current_term=log.currentTerm(); assertEquals(current_term, 22); voted_for=log.votedFor(); assertEquals(addr, voted_for); log.close(); log.delete(); log.init(filename, null); current_term=log.currentTerm(); assertEquals(current_term, 0); voted_for=log.votedFor(); assertNull(voted_for); }
Example 8
Source File: AppendEntriesTest.java From jgroups-raft with Apache License 2.0 | 5 votes |
public void testRAFTPaperScenarioB() throws Exception { Address leader=Util.createRandomAddress("A"); initB(); RaftImpl impl=getImpl(b); Log log=impl.raft().log(); byte[] buf=new byte[10]; append(impl, 1, 0, new LogEntry(1, buf), leader, 1); append(impl, 2, 1, new LogEntry(1, buf), leader, 1); append(impl, 3, 1, new LogEntry(1, buf), leader, 1); append(impl, 4, 1, new LogEntry(4, buf), leader, 4); AppendResult result=append(impl, 11, 6, new LogEntry(6, buf), leader, 4); assertFalse(result.isSuccess()); assertEquals(result.getIndex(), 4); assertLogIndices(log, 4, 4, 4); }
Example 9
Source File: RaftHeaderTest.java From jgroups-raft with Apache License 2.0 | 5 votes |
public void testInstallSnapshotHeader() throws Exception { InstallSnapshotRequest hdr=new InstallSnapshotRequest(5); _testSize(hdr, InstallSnapshotRequest.class); hdr=new InstallSnapshotRequest(5, Util.createRandomAddress("A"), 5, 4); _testSize(hdr, InstallSnapshotRequest.class); }
Example 10
Source File: RaftHeaderTest.java From jgroups-raft with Apache License 2.0 | 4 votes |
public void testHeatbeatHeader() throws Exception { HeartbeatRequest hb=new HeartbeatRequest(22, Util.createRandomAddress("A")); _testSize(hb, HeartbeatRequest.class); }
Example 11
Source File: RaftHeaderTest.java From jgroups-raft with Apache License 2.0 | 4 votes |
public void testAppendEntriesRequest() throws Exception { AppendEntriesRequest req=new AppendEntriesRequest(22, Util.createRandomAddress("A"), 4, 21, 22, 18, true); _testSize(req, AppendEntriesRequest.class); }