Search in sources :

Example 1 with RaftClientMessagingProtocol

use of io.atomix.protocols.raft.test.protocol.RaftClientMessagingProtocol in project atomix by atomix.

the class RaftPerformanceTest method createClient.

/**
 * Creates a Raft client.
 */
private RaftClient createClient() throws Exception {
    Member member = nextNode();
    RaftClientProtocol protocol;
    if (USE_NETTY) {
        MessagingService messagingService = new NettyMessagingService("test", member.address(), new MessagingConfig()).start().join();
        protocol = new RaftClientMessagingProtocol(messagingService, PROTOCOL_SERIALIZER, addressMap::get);
    } else {
        protocol = protocolFactory.newClientProtocol(member.id());
    }
    RaftClient client = RaftClient.builder().withMemberId(member.id()).withPartitionId(PartitionId.from("test", 1)).withProtocol(protocol).withThreadModel(ThreadModel.SHARED_THREAD_POOL).build();
    client.connect(members.stream().map(Member::id).collect(Collectors.toList())).join();
    clients.add(client);
    return client;
}
Also used : MessagingConfig(io.atomix.cluster.messaging.MessagingConfig) RaftClientProtocol(io.atomix.protocols.raft.protocol.RaftClientProtocol) NettyMessagingService(io.atomix.cluster.messaging.impl.NettyMessagingService) RaftClientMessagingProtocol(io.atomix.protocols.raft.test.protocol.RaftClientMessagingProtocol) Member(io.atomix.cluster.Member) RaftMember(io.atomix.protocols.raft.cluster.RaftMember) DefaultRaftMember(io.atomix.protocols.raft.cluster.impl.DefaultRaftMember) RaftClient(io.atomix.protocols.raft.RaftClient) MessagingService(io.atomix.cluster.messaging.MessagingService) NettyMessagingService(io.atomix.cluster.messaging.impl.NettyMessagingService) ManagedMessagingService(io.atomix.cluster.messaging.ManagedMessagingService)

Example 2 with RaftClientMessagingProtocol

use of io.atomix.protocols.raft.test.protocol.RaftClientMessagingProtocol in project atomix by atomix.

the class RaftFuzzTest method createClient.

/**
 * Creates a Raft client.
 */
private RaftClient createClient() throws Exception {
    MemberId memberId = nextNodeId();
    RaftClientProtocol protocol;
    if (USE_NETTY) {
        Address address = Address.from(++port);
        MessagingService messagingManager = new NettyMessagingService("test", address, new MessagingConfig()).start().join();
        addressMap.put(memberId, address);
        protocol = new RaftClientMessagingProtocol(messagingManager, PROTOCOL_SERIALIZER, addressMap::get);
    } else {
        protocol = protocolFactory.newClientProtocol(memberId);
    }
    RaftClient client = RaftClient.builder().withMemberId(memberId).withProtocol(protocol).build();
    client.connect(members.stream().map(RaftMember::memberId).collect(Collectors.toList())).join();
    clients.add(client);
    return client;
}
Also used : MessagingConfig(io.atomix.cluster.messaging.MessagingConfig) MemberId(io.atomix.cluster.MemberId) RaftClientProtocol(io.atomix.protocols.raft.protocol.RaftClientProtocol) Address(io.atomix.utils.net.Address) NettyMessagingService(io.atomix.cluster.messaging.impl.NettyMessagingService) RaftClientMessagingProtocol(io.atomix.protocols.raft.test.protocol.RaftClientMessagingProtocol) RaftClient(io.atomix.protocols.raft.RaftClient) MessagingService(io.atomix.cluster.messaging.MessagingService) NettyMessagingService(io.atomix.cluster.messaging.impl.NettyMessagingService)

Aggregations

MessagingConfig (io.atomix.cluster.messaging.MessagingConfig)2 MessagingService (io.atomix.cluster.messaging.MessagingService)2 NettyMessagingService (io.atomix.cluster.messaging.impl.NettyMessagingService)2 RaftClient (io.atomix.protocols.raft.RaftClient)2 RaftClientProtocol (io.atomix.protocols.raft.protocol.RaftClientProtocol)2 RaftClientMessagingProtocol (io.atomix.protocols.raft.test.protocol.RaftClientMessagingProtocol)2 Member (io.atomix.cluster.Member)1 MemberId (io.atomix.cluster.MemberId)1 ManagedMessagingService (io.atomix.cluster.messaging.ManagedMessagingService)1 RaftMember (io.atomix.protocols.raft.cluster.RaftMember)1 DefaultRaftMember (io.atomix.protocols.raft.cluster.impl.DefaultRaftMember)1 Address (io.atomix.utils.net.Address)1