Search in sources :

Example 1 with RaftServerMessagingProtocol

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

the class RaftPerformanceTest method createServer.

/**
 * Creates a Raft server.
 */
private RaftServer createServer(Member member, List<Node> members) {
    RaftServerProtocol protocol;
    ManagedMessagingService messagingService;
    if (USE_NETTY) {
        messagingService = (ManagedMessagingService) new NettyMessagingService("test", member.address(), new MessagingConfig()).start().join();
        messagingServices.add(messagingService);
        protocol = new RaftServerMessagingProtocol(messagingService, PROTOCOL_SERIALIZER, addressMap::get);
    } else {
        protocol = protocolFactory.newServerProtocol(member.id());
    }
    BootstrapService bootstrapService = new BootstrapService() {

        @Override
        public MessagingService getMessagingService() {
            return messagingService;
        }

        @Override
        public UnicastService getUnicastService() {
            return new UnicastServiceAdapter();
        }

        @Override
        public BroadcastService getBroadcastService() {
            return new BroadcastServiceAdapter();
        }
    };
    RaftServer.Builder builder = RaftServer.builder(member.id()).withProtocol(protocol).withThreadModel(ThreadModel.SHARED_THREAD_POOL).withMembershipService(new DefaultClusterMembershipService(member, Version.from("1.0.0"), new DefaultNodeDiscoveryService(bootstrapService, member, new BootstrapDiscoveryProvider(members)), bootstrapService, new HeartbeatMembershipProtocol(new HeartbeatMembershipProtocolConfig()))).withStorage(RaftStorage.builder().withStorageLevel(StorageLevel.DISK).withDirectory(new File(String.format("target/perf-logs/%s", member.id()))).withNamespace(STORAGE_NAMESPACE).withMaxSegmentSize(1024 * 1024 * 64).withDynamicCompaction().withFlushOnCommit(false).build());
    RaftServer server = builder.build();
    servers.add(server);
    return server;
}
Also used : RaftServerProtocol(io.atomix.protocols.raft.protocol.RaftServerProtocol) RaftServerMessagingProtocol(io.atomix.protocols.raft.test.protocol.RaftServerMessagingProtocol) DefaultNodeDiscoveryService(io.atomix.cluster.impl.DefaultNodeDiscoveryService) RaftServer(io.atomix.protocols.raft.RaftServer) BootstrapDiscoveryProvider(io.atomix.cluster.discovery.BootstrapDiscoveryProvider) ManagedMessagingService(io.atomix.cluster.messaging.ManagedMessagingService) HeartbeatMembershipProtocolConfig(io.atomix.cluster.protocol.HeartbeatMembershipProtocolConfig) MessagingConfig(io.atomix.cluster.messaging.MessagingConfig) DefaultClusterMembershipService(io.atomix.cluster.impl.DefaultClusterMembershipService) NettyMessagingService(io.atomix.cluster.messaging.impl.NettyMessagingService) HeartbeatMembershipProtocol(io.atomix.cluster.protocol.HeartbeatMembershipProtocol) File(java.io.File) BootstrapService(io.atomix.cluster.BootstrapService)

Example 2 with RaftServerMessagingProtocol

use of io.atomix.protocols.raft.test.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) {
        Address address = Address.from(++port);
        MessagingService messagingManager = new NettyMessagingService("test", address, new MessagingConfig()).start().join();
        messagingServices.add(messagingManager);
        addressMap.put(member.memberId(), address);
        protocol = new RaftServerMessagingProtocol(messagingManager, PROTOCOL_SERIALIZER, addressMap::get);
    } else {
        protocol = protocolFactory.newServerProtocol(member.memberId());
    }
    RaftServer.Builder builder = RaftServer.builder(member.memberId()).withProtocol(protocol).withStorage(RaftStorage.builder().withStorageLevel(StorageLevel.DISK).withDirectory(new File(String.format("target/fuzz-logs/%s", member.memberId()))).withNamespace(STORAGE_NAMESPACE).withMaxSegmentSize(1024 * 1024).build());
    RaftServer server = builder.build();
    servers.add(server);
    return server;
}
Also used : MessagingConfig(io.atomix.cluster.messaging.MessagingConfig) RaftServerProtocol(io.atomix.protocols.raft.protocol.RaftServerProtocol) RaftServerMessagingProtocol(io.atomix.protocols.raft.test.protocol.RaftServerMessagingProtocol) Address(io.atomix.utils.net.Address) RaftServer(io.atomix.protocols.raft.RaftServer) NettyMessagingService(io.atomix.cluster.messaging.impl.NettyMessagingService) File(java.io.File) MessagingService(io.atomix.cluster.messaging.MessagingService) NettyMessagingService(io.atomix.cluster.messaging.impl.NettyMessagingService)

Aggregations

MessagingConfig (io.atomix.cluster.messaging.MessagingConfig)2 NettyMessagingService (io.atomix.cluster.messaging.impl.NettyMessagingService)2 RaftServer (io.atomix.protocols.raft.RaftServer)2 RaftServerProtocol (io.atomix.protocols.raft.protocol.RaftServerProtocol)2 RaftServerMessagingProtocol (io.atomix.protocols.raft.test.protocol.RaftServerMessagingProtocol)2 File (java.io.File)2 BootstrapService (io.atomix.cluster.BootstrapService)1 BootstrapDiscoveryProvider (io.atomix.cluster.discovery.BootstrapDiscoveryProvider)1 DefaultClusterMembershipService (io.atomix.cluster.impl.DefaultClusterMembershipService)1 DefaultNodeDiscoveryService (io.atomix.cluster.impl.DefaultNodeDiscoveryService)1 ManagedMessagingService (io.atomix.cluster.messaging.ManagedMessagingService)1 MessagingService (io.atomix.cluster.messaging.MessagingService)1 HeartbeatMembershipProtocol (io.atomix.cluster.protocol.HeartbeatMembershipProtocol)1 HeartbeatMembershipProtocolConfig (io.atomix.cluster.protocol.HeartbeatMembershipProtocolConfig)1 Address (io.atomix.utils.net.Address)1