Search in sources :

Example 46 with RaftGroupService

use of org.apache.ignite.raft.client.service.RaftGroupService in project ignite-3 by apache.

the class RaftGroupServiceTest method testAddLearners.

/**
 * @throws Exception
 */
@Test
public void testAddLearners() throws Exception {
    String groupId = "test";
    List<String> addLearners = peersToIds(NODES.subList(1, 3));
    when(messagingService.invoke(any(NetworkAddress.class), eq(FACTORY.addLearnersRequest().learnersList(addLearners).groupId(groupId).build()), anyLong())).then(invocation -> completedFuture(FACTORY.learnersOpResponse().newLearnersList(addLearners).build()));
    mockLeaderRequest(false);
    RaftGroupService service = RaftGroupServiceImpl.start(groupId, cluster, FACTORY, TIMEOUT, NODES.subList(0, 1), true, DELAY, executor).get(3, TimeUnit.SECONDS);
    assertEquals(NODES.subList(0, 1), service.peers());
    assertEquals(Collections.emptyList(), service.learners());
    service.addLearners(NODES.subList(1, 3)).get();
    assertEquals(NODES.subList(0, 1), service.peers());
    assertEquals(NODES.subList(1, 3), service.learners());
}
Also used : NetworkAddress(org.apache.ignite.network.NetworkAddress) RaftGroupService(org.apache.ignite.raft.client.service.RaftGroupService) Test(org.junit.jupiter.api.Test)

Aggregations

RaftGroupService (org.apache.ignite.raft.client.service.RaftGroupService)46 Test (org.junit.jupiter.api.Test)33 NetworkAddress (org.apache.ignite.network.NetworkAddress)24 Peer (org.apache.ignite.raft.client.Peer)22 List (java.util.List)11 Path (java.nio.file.Path)9 ArrayList (java.util.ArrayList)8 CompletableFuture (java.util.concurrent.CompletableFuture)8 TimeoutException (java.util.concurrent.TimeoutException)8 Collectors (java.util.stream.Collectors)8 Loza (org.apache.ignite.internal.raft.Loza)8 IgniteLogger (org.apache.ignite.lang.IgniteLogger)8 NotNull (org.jetbrains.annotations.NotNull)8 ExecutionException (java.util.concurrent.ExecutionException)7 TxManager (org.apache.ignite.internal.tx.TxManager)7 IgniteInternalException (org.apache.ignite.lang.IgniteInternalException)7 AfterEach (org.junit.jupiter.api.AfterEach)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 IOException (java.io.IOException)6 UUID (java.util.UUID)6