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;
}
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;
}
Aggregations