Search in sources :

Example 1 with RaftClientMessagingProtocol

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

the class RaftPerformanceTest method createClient.

/**
 * Creates a Raft client.
 */
private RaftClient createClient() throws Exception {
    Node node = nextNode(Node.Type.CLIENT);
    RaftClientProtocol protocol;
    if (USE_NETTY) {
        MessagingService messagingService = NettyMessagingService.builder().withEndpoint(node.endpoint()).build().start().join();
        protocol = new RaftClientMessagingProtocol(messagingService, protocolSerializer, endpointMap::get);
    } else {
        protocol = protocolFactory.newClientProtocol(node.id());
    }
    RaftClient client = RaftClient.builder().withNodeId(node.id()).withProtocol(protocol).withThreadModel(ThreadModel.THREAD_PER_SERVICE).build();
    client.connect(members.stream().map(Node::id).collect(Collectors.toList())).join();
    clients.add(client);
    return client;
}
Also used : RaftClientProtocol(io.atomix.protocols.raft.protocol.RaftClientProtocol) Node(io.atomix.cluster.Node) RaftClientMessagingProtocol(io.atomix.protocols.raft.protocol.RaftClientMessagingProtocol) NettyMessagingService(io.atomix.messaging.impl.NettyMessagingService) ManagedMessagingService(io.atomix.messaging.ManagedMessagingService) MessagingService(io.atomix.messaging.MessagingService)

Example 2 with RaftClientMessagingProtocol

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

the class RaftFuzzTest method createClient.

/**
 * Creates a Raft client.
 */
private RaftClient createClient() throws Exception {
    NodeId nodeId = nextNodeId();
    RaftClientProtocol protocol;
    if (USE_NETTY) {
        Endpoint endpoint = new Endpoint(InetAddress.getLocalHost(), ++port);
        MessagingService messagingManager = NettyMessagingService.builder().withEndpoint(endpoint).build().start().join();
        endpointMap.put(nodeId, endpoint);
        protocol = new RaftClientMessagingProtocol(messagingManager, protocolSerializer, endpointMap::get);
    } else {
        protocol = protocolFactory.newClientProtocol(nodeId);
    }
    RaftClient client = RaftClient.builder().withNodeId(nodeId).withProtocol(protocol).build();
    client.connect(members.stream().map(RaftMember::nodeId).collect(Collectors.toList())).join();
    clients.add(client);
    return client;
}
Also used : RaftClientProtocol(io.atomix.protocols.raft.protocol.RaftClientProtocol) Endpoint(io.atomix.messaging.Endpoint) NodeId(io.atomix.cluster.NodeId) RaftClientMessagingProtocol(io.atomix.protocols.raft.protocol.RaftClientMessagingProtocol) NettyMessagingService(io.atomix.messaging.impl.NettyMessagingService) MessagingService(io.atomix.messaging.MessagingService)

Aggregations

MessagingService (io.atomix.messaging.MessagingService)2 NettyMessagingService (io.atomix.messaging.impl.NettyMessagingService)2 RaftClientMessagingProtocol (io.atomix.protocols.raft.protocol.RaftClientMessagingProtocol)2 RaftClientProtocol (io.atomix.protocols.raft.protocol.RaftClientProtocol)2 Node (io.atomix.cluster.Node)1 NodeId (io.atomix.cluster.NodeId)1 Endpoint (io.atomix.messaging.Endpoint)1 ManagedMessagingService (io.atomix.messaging.ManagedMessagingService)1