Search in sources :

Example 1 with RaftServerMessagingProtocol

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

the class RaftPerformanceTest method createServer.

/**
 * Creates a Raft server.
 */
private RaftServer createServer(Node node, List<Node> members) throws UnknownHostException {
    RaftServerProtocol protocol;
    ManagedMessagingService messagingService;
    if (USE_NETTY) {
        messagingService = (ManagedMessagingService) NettyMessagingService.builder().withEndpoint(node.endpoint()).build().start().join();
        messagingServices.add(messagingService);
        protocol = new RaftServerMessagingProtocol(messagingService, protocolSerializer, endpointMap::get);
    } else {
        protocol = protocolFactory.newServerProtocol(node.id());
    }
    RaftServer.Builder builder = RaftServer.builder(node.id()).withProtocol(protocol).withThreadModel(ThreadModel.THREAD_PER_SERVICE).withClusterService(new DefaultClusterService(node, new DefaultClusterMetadataService(ClusterMetadata.builder().withBootstrapNodes(members).build(), messagingService), messagingService)).withStorage(RaftStorage.builder().withStorageLevel(StorageLevel.MAPPED).withDirectory(new File(String.format("target/perf-logs/%s", node.id()))).withSerializer(storageSerializer).withMaxEntriesPerSegment(32768).withMaxSegmentSize(1024 * 1024).build()).addPrimitiveType(TestPrimitiveType.INSTANCE);
    RaftServer server = builder.build();
    servers.add(server);
    return server;
}
Also used : RaftServerProtocol(io.atomix.protocols.raft.protocol.RaftServerProtocol) DefaultClusterMetadataService(io.atomix.cluster.impl.DefaultClusterMetadataService) RaftServerMessagingProtocol(io.atomix.protocols.raft.protocol.RaftServerMessagingProtocol) ManagedMessagingService(io.atomix.messaging.ManagedMessagingService) DefaultClusterService(io.atomix.cluster.impl.DefaultClusterService) File(java.io.File)

Example 2 with RaftServerMessagingProtocol

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

the class RaftFuzzTest method createServer.

/**
 * Creates a Raft server.
 */
private RaftServer createServer(RaftMember member) {
    RaftServerProtocol protocol;
    if (USE_NETTY) {
        try {
            Endpoint endpoint = new Endpoint(InetAddress.getLocalHost(), ++port);
            MessagingService messagingManager = NettyMessagingService.builder().withEndpoint(endpoint).build().start().join();
            messagingServices.add(messagingManager);
            endpointMap.put(member.nodeId(), endpoint);
            protocol = new RaftServerMessagingProtocol(messagingManager, protocolSerializer, endpointMap::get);
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }
    } else {
        protocol = protocolFactory.newServerProtocol(member.nodeId());
    }
    RaftServer.Builder builder = RaftServer.builder(member.nodeId()).withProtocol(protocol).withStorage(RaftStorage.builder().withStorageLevel(StorageLevel.DISK).withDirectory(new File(String.format("target/fuzz-logs/%s", member.nodeId()))).withSerializer(storageSerializer).withMaxSegmentSize(1024 * 1024).build()).addPrimitiveType(TestPrimitiveType.INSTANCE);
    RaftServer server = builder.build();
    servers.add(server);
    return server;
}
Also used : RaftServerProtocol(io.atomix.protocols.raft.protocol.RaftServerProtocol) RaftServerMessagingProtocol(io.atomix.protocols.raft.protocol.RaftServerMessagingProtocol) Endpoint(io.atomix.messaging.Endpoint) UnknownHostException(java.net.UnknownHostException) File(java.io.File) NettyMessagingService(io.atomix.messaging.impl.NettyMessagingService) MessagingService(io.atomix.messaging.MessagingService)

Aggregations

RaftServerMessagingProtocol (io.atomix.protocols.raft.protocol.RaftServerMessagingProtocol)2 RaftServerProtocol (io.atomix.protocols.raft.protocol.RaftServerProtocol)2 File (java.io.File)2 DefaultClusterMetadataService (io.atomix.cluster.impl.DefaultClusterMetadataService)1 DefaultClusterService (io.atomix.cluster.impl.DefaultClusterService)1 Endpoint (io.atomix.messaging.Endpoint)1 ManagedMessagingService (io.atomix.messaging.ManagedMessagingService)1 MessagingService (io.atomix.messaging.MessagingService)1 NettyMessagingService (io.atomix.messaging.impl.NettyMessagingService)1 UnknownHostException (java.net.UnknownHostException)1