Search in sources :

Example 1 with SnapshotThrottle

use of org.apache.ignite.raft.jraft.storage.SnapshotThrottle in project ignite-3 by apache.

the class ItNodeTest method testInstallLargeSnapshotWithThrottle.

// TODO add test for timeout on snapshot install https://issues.apache.org/jira/browse/IGNITE-14832
@Test
@Disabled("https://issues.apache.org/jira/browse/IGNITE-16467")
public void testInstallLargeSnapshotWithThrottle() throws Exception {
    List<PeerId> peers = TestUtils.generatePeers(4);
    cluster = new TestCluster("unitest", dataPath, peers.subList(0, 3), testInfo);
    for (int i = 0; i < peers.size() - 1; i++) {
        PeerId peer = peers.get(i);
        boolean started = cluster.start(peer.getEndpoint(), false, 200, false);
        assertTrue(started);
    }
    cluster.waitLeader();
    // get leader
    Node leader = cluster.getLeader();
    assertNotNull(leader);
    cluster.ensureLeader(leader);
    // apply tasks to leader
    sendTestTaskAndWait(leader, 0, RaftError.SUCCESS);
    cluster.ensureSame();
    // apply something more
    for (int i = 1; i < 100; i++) sendTestTaskAndWait(leader, i * 10, RaftError.SUCCESS);
    Thread.sleep(1000);
    // trigger leader snapshot
    triggerLeaderSnapshot(cluster, leader);
    // apply something more
    for (int i = 100; i < 200; i++) sendTestTaskAndWait(leader, i * 10, RaftError.SUCCESS);
    // trigger leader snapshot
    triggerLeaderSnapshot(cluster, leader, 2);
    // wait leader to compact logs
    Thread.sleep(1000);
    // add follower
    PeerId newPeer = peers.get(3);
    SnapshotThrottle snapshotThrottle = new ThroughputSnapshotThrottle(128, 1);
    boolean started = cluster.start(newPeer.getEndpoint(), false, 300, false, snapshotThrottle);
    assertTrue(started);
    CountDownLatch latch = new CountDownLatch(1);
    leader.addPeer(newPeer, status -> {
        assertTrue(status.isOk(), status.toString());
        latch.countDown();
    });
    waitLatch(latch);
    cluster.ensureSame();
    assertEquals(4, cluster.getFsms().size());
    for (MockStateMachine fsm : cluster.getFsms()) assertEquals(2000, fsm.getLogs().size());
}
Also used : ThroughputSnapshotThrottle(org.apache.ignite.raft.jraft.storage.snapshot.ThroughputSnapshotThrottle) Node(org.apache.ignite.raft.jraft.Node) SnapshotThrottle(org.apache.ignite.raft.jraft.storage.SnapshotThrottle) ThroughputSnapshotThrottle(org.apache.ignite.raft.jraft.storage.snapshot.ThroughputSnapshotThrottle) CountDownLatch(java.util.concurrent.CountDownLatch) Endpoint(org.apache.ignite.raft.jraft.util.Endpoint) PeerId(org.apache.ignite.raft.jraft.entity.PeerId) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 Node (org.apache.ignite.raft.jraft.Node)1 PeerId (org.apache.ignite.raft.jraft.entity.PeerId)1 SnapshotThrottle (org.apache.ignite.raft.jraft.storage.SnapshotThrottle)1 ThroughputSnapshotThrottle (org.apache.ignite.raft.jraft.storage.snapshot.ThroughputSnapshotThrottle)1 Endpoint (org.apache.ignite.raft.jraft.util.Endpoint)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1